mikakaraila / node-red-contrib-opcua

A Node-RED node to communicate OPC UA. Uses node-opcua library.
Other
208 stars 191 forks source link

Using historian, read or read-history, adds an extra record to the history #679

Open peza opened 2 months ago

peza commented 2 months ago

Using historian, read or read-history, adds an extra record to the history. I've been reading the server also with UAAutomation, where no extra records are added. Only in node-red via READ or HISTORY. Attached FLOW for reproducing and a screeenshot for additional explanation. image

[ { "id": "fdb793e979dca26e", "type": "tab", "label": "BUG", "disabled": false, "info": "This flow shows the BUG, that adds an extra\r\nrecord to the historizing variable on read", "env": [] }, { "id": "8554c947a60928b6", "type": "OpcUa-Server", "z": "fdb793e979dca26e", "port": "4841", "name": "Test Server 4841", "endpoint": "", "users": "", "nodesetDir": "", "autoAcceptUnknownCertificate": false, "registerToDiscovery": false, "constructDefaultAddressSpace": false, "allowAnonymous": true, "endpointNone": true, "endpointSign": false, "endpointSignEncrypt": false, "endpointBasic128Rsa15": false, "endpointBasic256": false, "endpointBasic256Sha256": false, "maxNodesPerBrowse": 0, "maxNodesPerHistoryReadData": "0", "maxNodesPerHistoryReadEvents": "0", "maxNodesPerHistoryUpdateData": "0", "maxNodesPerRead": 0, "maxNodesPerWrite": 0, "maxNodesPerMethodCall": 0, "maxNodesPerRegisterNodes": 0, "maxNodesPerNodeManagement": 0, "maxMonitoredItemsPerCall": 0, "maxNodesPerHistoryUpdateEvents": "0", "maxNodesPerTranslateBrowsePathsToNodeIds": 0, "maxConnectionsPerEndpoint": "0", "maxMessageSize": "0", "maxBufferSize": "0", "maxSessions": "", "x": 1170, "y": 120, "wires": [ [] ] }, { "id": "d18ee86b0f24dbda", "type": "inject", "z": "fdb793e979dca26e", "name": "opcuaCommand = installHistorian", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": true, "onceDelay": "6", "topic": "ns=1;s=TestVariable;datatype=Int32", "payload": "{ \"opcuaCommand\": \"installHistorian\" }", "payloadType": "json", "x": 200, "y": 120, "wires": [ [ "d9e12283056da28c", "8554c947a60928b6" ] ] }, { "id": "d77fb5adec16291f", "type": "delay", "z": "fdb793e979dca26e", "name": "", "pauseType": "delay", "timeout": "2", "timeoutUnits": "seconds", "rate": "1", "nbRateUnits": "1", "rateUnits": "second", "randomFirst": "1", "randomLast": "5", "randomUnits": "seconds", "drop": false, "allowrate": false, "outputs": 1, "x": 800, "y": 180, "wires": [ [ "125b124fb051582b" ] ] }, { "id": "d9e12283056da28c", "type": "debug", "z": "fdb793e979dca26e", "name": "debug 451", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 630, "y": 40, "wires": [] }, { "id": "cc644538fef2387f", "type": "inject", "z": "fdb793e979dca26e", "name": "add TestVariable", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": true, "onceDelay": "5", "topic": "ns=1;s=TestVariable;datatype=Int32", "payload": "{\"opcuaCommand\": \"addVariable\"}", "payloadType": "json", "x": 170, "y": 60, "wires": [ [ "8554c947a60928b6", "d9e12283056da28c" ] ] }, { "id": "d73d2a238d0a6b5b", "type": "inject", "z": "fdb793e979dca26e", "name": "Set TestVariable 0", "props": [ { "p": "payload.messageType", "v": "Variable", "vt": "str" }, { "p": "payload.variableName", "v": "TestVariable", "vt": "str" }, { "p": "payload.datatype", "v": "Int32", "vt": "str" }, { "p": "payload.namespace", "v": "1", "vt": "str" }, { "p": "payload.variableValue", "v": "0", "vt": "num" } ], "repeat": "", "crontab": "", "once": true, "onceDelay": "7", "topic": "", "x": 170, "y": 240, "wires": [ [ "125b124fb051582b", "f9866fbe5c85e751" ] ] }, { "id": "f9866fbe5c85e751", "type": "debug", "z": "fdb793e979dca26e", "name": "debug 452", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 410, "y": 200, "wires": [] }, { "id": "125b124fb051582b", "type": "function", "z": "fdb793e979dca26e", "name": "set new value", "func": "//msg.payload.messageType = 'Variable'\n//msg.payload.variableName = 'ns=1;s=TestVariable'\n//msg.payload.datatype = 'Int32'\n//msg.payload.namespace = '1'\nmsg.payload.variableValue = msg.payload.variableValue + 1 \nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 820, "y": 240, "wires": [ [ "d77fb5adec16291f", "9b098391218fb421", "8554c947a60928b6" ] ] }, { "id": "9b098391218fb421", "type": "debug", "z": "fdb793e979dca26e", "name": "debug 453", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 1130, "y": 300, "wires": [] }, { "id": "c9f019ce623cc5cc", "type": "inject", "z": "fdb793e979dca26e", "name": "", "props": [ { "p": "aggregate", "v": "raw", "vt": "str" }, { "p": "start", "v": "$toMillis(\"2024-04-17\")", "vt": "jsonata" }, { "p": "end", "v": "", "vt": "date" } ], "repeat": "10", "crontab": "", "once": true, "onceDelay": "8", "topic": "", "x": 110, "y": 380, "wires": [ [ "f284ce5f66e77382" ] ] }, { "id": "f284ce5f66e77382", "type": "OpcUa-Item", "z": "fdb793e979dca26e", "item": "ns=1;s=TestVariable", "datatype": "Int32", "value": "", "name": "", "x": 320, "y": 380, "wires": [ [ "eca31868acaca971" ] ] }, { "id": "eca31868acaca971", "type": "OpcUa-Client", "z": "fdb793e979dca26e", "endpoint": "71cb8fc28f03fd3a", "action": "history", "deadbandtype": "a", "deadbandvalue": 1, "time": 10, "timeUnit": "s", "certificate": "n", "localfile": "", "localkeyfile": "", "securitymode": "None", "securitypolicy": "None", "useTransport": false, "maxChunkCount": 1, "maxMessageSize": 8192, "receiveBufferSize": 8192, "sendBufferSize": 8192, "name": "Test client History", "x": 550, "y": 380, "wires": [ [ "b162f92c22587f6a" ], [] ] }, { "id": "b162f92c22587f6a", "type": "debug", "z": "fdb793e979dca26e", "name": "debug 454", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 770, "y": 380, "wires": [] }, { "id": "10958027bcd1f9b4", "type": "inject", "z": "fdb793e979dca26e", "name": "", "props": [], "repeat": "8", "crontab": "", "once": true, "onceDelay": "9", "topic": "", "x": 110, "y": 460, "wires": [ [ "53bb6dd018590c8f" ] ] }, { "id": "53bb6dd018590c8f", "type": "OpcUa-Item", "z": "fdb793e979dca26e", "item": "ns=1;s=TestVariable", "datatype": "Int32", "value": "", "name": "", "x": 320, "y": 460, "wires": [ [ "edebfe19535e5047" ] ] }, { "id": "edebfe19535e5047", "type": "OpcUa-Client", "z": "fdb793e979dca26e", "endpoint": "71cb8fc28f03fd3a", "action": "read", "deadbandtype": "a", "deadbandvalue": 1, "time": 10, "timeUnit": "s", "certificate": "n", "localfile": "", "localkeyfile": "", "securitymode": "None", "securitypolicy": "None", "useTransport": false, "maxChunkCount": 1, "maxMessageSize": 8192, "receiveBufferSize": 8192, "sendBufferSize": 8192, "name": "Test client Read", "x": 540, "y": 460, "wires": [ [ "1690cc29d62c52ca" ], [] ] }, { "id": "1690cc29d62c52ca", "type": "debug", "z": "fdb793e979dca26e", "name": "debug 455", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 770, "y": 460, "wires": [] }, { "id": "71cb8fc28f03fd3a", "type": "OpcUa-Endpoint", "endpoint": "opc.tcp://localhost:4841", "secpol": "None", "secmode": "None", "none": true, "login": false, "usercert": false, "usercertificate": "", "userprivatekey": "" } ]

mikakaraila commented 2 months ago

If I remember correctly it return by default bounds... look specification. This might need some extra options...

PeterGostol commented 2 months ago

Hi, @mikakaraila why is this labeled enhancement? This is a bug. The extra record shouldt'n have been added after reading historian in node-red.

Let me explain again; When reading the variable via node-red, an extra record is added, which shouldn't been there. If i'd be using UAExpert, correctly, no additional record is added. And also, the extra record, added by node-red, is seen on the graph inside UAEXpert.

The extra record gets the value of the last record read and new timestamps. So, we get two records with same value, which is wrong!

mikakaraila commented 2 months ago

I still think it is related to this: https://reference.opcfoundation.org/Core/Part11/v104/docs/4.4

As node-opcua test coverage is very high I expect this is tested. I am using existing functionality. So if you really think this is a bug then open issue in node-opcua.