Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPC UA 64bit Data reading problem. #762

Open
DavidwWoo opened this issue Dec 10, 2024 · 3 comments
Open

OPC UA 64bit Data reading problem. #762

DavidwWoo opened this issue Dec 10, 2024 · 3 comments
Labels

Comments

@DavidwWoo
Copy link

I just testing for mutireading function /w KEPServer (node-red is running in mac /w M1 chip)

스크린샷 2024-12-10 오후 2 01 50

스크린샷 2024-12-10 오후 2 02 53

Ramp4 is getting correct value (it's 32bit data)
but Ramp5~Ramp7) get data little bit strange
AM i missing something? or set incorrectly?

I want to check my flow and guide from u!
Is bug or my mistake?

this is my testing flow

[ { "id": "b8398a925970a5fb", "type": "tab", "label": "플로우 1", "disabled": false, "info": "", "env": [] }, { "id": "2ab2468e8944774f", "type": "split", "z": "b8398a925970a5fb", "name": "", "splt": "\\n", "spltType": "str", "arraySplt": "1", "arraySpltType": "len", "stream": false, "addname": "", "x": 490, "y": 240, "wires": [ [ "7d9c88d37756f736" ] ] }, { "id": "4f5f8233500f7c47", "type": "function", "z": "b8398a925970a5fb", "name": "OPC UA Read Array (24개)", "func": "//전체 노드 Id 목록\n\nmsg.payload=[\n\n //Kepserver\n // \"ns=2;s=Simulation Examples.Functions.Ramp1;datatype=Int32\",\n // \"ns=2;s=Simulation Examples.Functions.Ramp2;datatype=Float\",\n // \"ns=2;s=Simulation Examples.Functions.Ramp3;datatype=UInt16\",\n \"ns=2;s=Simulation Examples.Functions.Ramp4;datatype=Int32\",\n \"ns=2;s=Simulation Examples.Functions.Ramp5\",\n \"ns=2;s=Simulation Examples.Functions.Ramp6\",\n \"ns=2;s=Simulation Examples.Functions.Ramp7\"\n // \"ns=2;s=Simulation Examples.Functions.Ramp8\",\n // \"ns=2;s=Simulation Examples.Functions.Random1\",\n // \"ns=2;s=Simulation Examples.Functions.Random2\",\n // \"ns=2;s=Simulation Examples.Functions.Random3\",\n // \"ns=2;s=Simulation Examples.Functions.Random4\",\n // \"ns=2;s=Simulation Examples.Functions.Random5\",\n // \"ns=2;s=Simulation Examples.Functions.Random6\",\n // \"ns=2;s=Simulation Examples.Functions.Random7\",\n // \"ns=2;s=Simulation Examples.Functions.Random8\",\n // \"ns=2;s=Simulation Examples.Functions.Sine1\",\n // \"ns=2;s=Simulation Examples.Functions.Sine2\",\n // \"ns=2;s=Simulation Examples.Functions.Sine3\",\n // \"ns=2;s=Simulation Examples.Functions.Sine4\",\n // \"ns=2;s=Simulation Examples.Functions.User1\",\n // \"ns=2;s=Simulation Examples.Functions.User2\",\n // \"ns=2;s=Simulation Examples.Functions.User3\",\n // \"ns=2;s=Simulation Examples.Functions.User4\"\n\n //prosys opcua server\n // \"ns=3;i=1007\",\n // \"ns=3;i=1001\"\n]\nreturn msg;", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 280, "y": 240, "wires": [ [ "2ab2468e8944774f" ] ] }, { "id": "9834cc89180fb8cd", "type": "inject", "z": "b8398a925970a5fb", "name": "Start", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": true, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 70, "y": 240, "wires": [ [ "4f5f8233500f7c47" ] ] }, { "id": "7d9c88d37756f736", "type": "function", "z": "b8398a925970a5fb", "name": "Change Payload to Topic", "func": "msg.topic=msg.payload\nreturn msg;", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 690, "y": 240, "wires": [ [ "5e3311ec23cbfb3d" ] ] }, { "id": "1630a058f1ee9b9c", "type": "function", "z": "b8398a925970a5fb", "name": "Read Multiple", "func": "msg.topic=\"readmultiple\"\nmsg.payload=\"ALL\"\nreturn msg;", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 400, "y": 360, "wires": [ [ "a1b75c00c2a193e1", "5e3311ec23cbfb3d" ] ] }, { "id": "a1b75c00c2a193e1", "type": "delay", "z": "b8398a925970a5fb", "name": "", "pauseType": "delayv", "timeout": "1000", "timeoutUnits": "milliseconds", "rate": "1", "nbRateUnits": "1", "rateUnits": "second", "randomFirst": "1", "randomLast": "5", "randomUnits": "seconds", "drop": false, "allowrate": false, "outputs": 1, "x": 220, "y": 360, "wires": [ [ "1630a058f1ee9b9c" ] ] }, { "id": "3a823777413fb4fe", "type": "inject", "z": "b8398a925970a5fb", "name": "Start", "props": [], "repeat": "", "crontab": "", "once": true, "onceDelay": 0.1, "topic": "", "x": 70, "y": 340, "wires": [ [ "a1b75c00c2a193e1" ] ] }, { "id": "cdccab90eb9df7d1", "type": "function", "z": "b8398a925970a5fb", "name": "Structure Change", "func": "/*\n{\n [nodeid]:\n {\n value: var\n //dataType: string\n statusCode: string\n timestamp: string (date)\n }\n}\n*/\n// Map OPC UA data type integer value to string description\nvar dataTypes = {\n \"1\": \"Boolean\",\n \"2\": \"SByte\",\n \"3\": \"Byte\",\n \"4\": \"Int16\",\n \"5\": \"UInt16\",\n \"6\": \"Int32\",\n \"7\": \"UInt32\",\n \"8\": \"Int64\",\n \"9\": \"UInt64\",\n \"10\": \"Float\",\n \"11\": \"Double\",\n \"12\": \"String\",\n \"13\": \"DateTime\",\n \"14\": \"Guid\",\n \"15\": \"ByteString\",\n \"16\": \"XmlElement\",\n \"17\": \"NodeId\",\n \"18\": \"ExpandedNodeId\",\n \"19\": \"StatusCode\",\n \"20\": \"QualifiedName\",\n \"21\": \"LocalizedText\",\n \"22\": \"ExtensionObject\",\n \"23\": \"DataValue\",\n \"24\": \"Variant\",\n \"25\": \"DiagnosticInfo\",\n}\nvar nodeId, value, dataType, statusCode, timestamp\nvar data={}\nfor(var i=0;i<msg.payload.length;i++){\n nodeId = msg.items[i].nodeId.value\n value = msg.payload[i].value.value.toString()\n dataType=dataTypes[msg.payload[i].value.dataType.toString()]\n statusCode = msg.payload[i].statusCode._name\n //timestamp = new Date()\n timestamp = new Date(msg.payload[i].sourceTimestamp)\n timestamp.setHours(timestamp.getHours() + timestamp.getTimezoneOffset() / (-60));\n timestamp = timestamp.toISOString().replace('T', ' ').substring(0, 23)\n data[nodeId]=\n {\n \"timestamp\": timestamp,\n \"nodeId\": nodeId,\n \"value\": value,\n \"dataType\": dataType,\n \"statusCode\": statusCode\n }\n}\nmsg.payload=data\nreturn msg;", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 830, "y": 340, "wires": [ [ "14213404f36cea7b" ] ] }, { "id": "14213404f36cea7b", "type": "function", "z": "b8398a925970a5fb", "name": "Process Name", "func": "msg.message=\"Node-RED: OPC UA Data Structue Change Complete\"\nreturn msg;", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1080, "y": 380, "wires": [ [ "63209d21fd7333a2" ] ] }, { "id": "63209d21fd7333a2", "type": "debug", "z": "b8398a925970a5fb", "name": "debug 1", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 820, "y": 500, "wires": [] }, { "id": "5e3311ec23cbfb3d", "type": "OpcUa-Client", "z": "b8398a925970a5fb", "endpoint": "85c4164544a8a87a", "action": "readmultiple", "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, "setstatusandtime": false, "keepsessionalive": false, "name": "", "x": 620, "y": 380, "wires": [ [ "cdccab90eb9df7d1" ], [], [] ] }, { "id": "85c4164544a8a87a", "type": "OpcUa-Endpoint", "endpoint": "opc.tcp://192.168.11.14:49320", "secpol": "None", "secmode": "None", "none": true, "login": false, "usercert": false, "usercertificate": "", "userprivatekey": "" } ]

@mikakaraila
Copy link
Owner

As JavaScript does not support 64bit values it is divided into two bytes as you see in payload.

@mikakaraila
Copy link
Owner

mikakaraila commented Dec 10, 2024

You can try to convert two bytes into 32bit as long as it does not overflow solution would work.

@mikakaraila
Copy link
Owner

You can combine two bytes and use these:
There are a few JS libraries around that can handle larger numbers, e.g., BigNumber and Int64.

As there only a few cases that really needs 64bit numbers, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants