BiancoRoyal / node-red-contrib-iiot-opcua

deprecated - very new developed by PLUS for Node-RED - https://plus4nodered.com
https://www.npmjs.com/package/node-red-contrib-iiot-opcua
BSD 3-Clause "New" or "Revised" License
34 stars 9 forks source link

Payload 0 converted to NaN for Int16 and Float #56

Closed StephanLeschke closed 6 years ago

StephanLeschke commented 6 years ago

Problem

Your Environment

biancode commented 6 years ago

please, use the OPC UA IIoT Inject

grafik

The OPC UA IIoT Node is for event-based injects and 0 or false is not possible for events for now. It is a signal to use the default (value) of the IIoT Node node like 0 or false or whatever.

StephanLeschke commented 6 years ago

I retested with node v8.11.4 and the problem was gone. So it seems to be related to node v10.

I used the manual inject just for the minimal reproduction. The intended application is a modbus to OPC-UA gateway (similar to your SDM630 example). In the application the payload is coming from the modbus read node and I am using the OPC UA IIoT Node to set the namespace information. I do not want to hide this in a function node like in your example. Here is another example which is closer to the code of my application: [ { "id": "c9b04afe.8458b", "type": "tab", "label": "OPC-Server", "disabled": false, "info": "" }, { "id": "e62720b3.9a2498", "type": "tab", "label": "Modbus2OPC", "disabled": false, "info": "" }, { "id": "f86f6dfa.5d5ff", "type": "OPCUA-IIoT-Connector", "z": "", "discoveryUrl": "", "endpoint": "opc.tcp://localhost:55388/", "keepSessionAlive": true, "loginEnabled": false, "securityPolicy": "None", "securityMode": "NONE", "name": "LOCAL SERVER", "showErrors": false, "publicCertificateFile": "", "privateKeyFile": "", "defaultSecureTokenLifetime": "", "endpointMustExist": true, "autoSelectRightEndpoint": true, "strategyMaxRetry": "", "strategyInitialDelay": "", "strategyMaxDelay": "", "strategyRandomisationFactor": "", "requestedSessionTimeout": "" }, { "id": "40ce404d.94b018", "type": "modbus-client", "z": "", "name": "Modbus Server", "clienttype": "tcp", "bufferCommands": true, "stateLogEnabled": false, "tcpHost": "127.0.0.1", "tcpPort": "502", "tcpType": "DEFAULT", "serialPort": "/dev/ttyUSB", "serialType": "RTU-BUFFERD", "serialBaudrate": "9600", "serialDatabits": "8", "serialStopbits": "1", "serialParity": "none", "serialConnectionDelay": "100", "unit_id": 1, "commandDelay": 1, "clientTimeout": 1000, "reconnectTimeout": 2000 }, { "id": "20874e14.2319ea", "type": "OPCUA-IIoT-Server", "z": "c9b04afe.8458b", "port": "55388", "endpoint": "", "acceptExternalCommands": true, "maxAllowedSessionNumber": "", "maxConnectionsPerEndpoint": "", "maxAllowedSubscriptionNumber": "", "alternateHostname": "", "name": "OPC-Server", "showStatusActivities": false, "showErrors": false, "asoDemo": false, "allowAnonymous": true, "isAuditing": false, "serverDiscovery": true, "users": [], "xmlsets": [], "publicCertificateFile": "", "privateCertificateFile": "", "maxNodesPerRead": 1000, "maxNodesPerBrowse": 2000, "x": 610, "y": 100, "wires": [ [] ] }, { "id": "28f2aed3.622ed2", "type": "OPCUA-IIoT-Server-ASO", "z": "c9b04afe.8458b", "nodeId": "ns=1;s=Mains", "browsename": "Mains", "displayname": "Mains", "objecttype": "FolderType", "datatype": "", "value": "", "referenceNodeId": "ns=0;i=85", "referencetype": "Organizes", "name": "Mains", "x": 330, "y": 100, "wires": [ [ "20874e14.2319ea" ] ] }, { "id": "4a8753da.11bb6c", "type": "OPCUA-IIoT-Inject", "z": "c9b04afe.8458b", "injectType": "inject", "payload": "0", "payloadType": "num", "topic": "", "repeat": "", "crontab": "", "once": true, "startDelay": "1", "name": "After 1 sec", "addressSpaceItems": [], "x": 170, "y": 100, "wires": [ [ "28f2aed3.622ed2" ] ] }, { "id": "9e6fff36.b2e288", "type": "OPCUA-IIoT-Server-ASO", "z": "c9b04afe.8458b", "nodeId": "ns=1;s=Mains.ApparentPower", "browsename": "ApparentPower", "displayname": "ApparentPower", "objecttype": "BaseDataVariableType", "datatype": "UInt16", "value": "0", "referenceNodeId": "ns=1;s=Mains", "referencetype": "Organizes", "name": "Mains.ApparentPower", "x": 380, "y": 180, "wires": [ [ "20874e14.2319ea" ] ] }, { "id": "41d43e56.cc3a58", "type": "OPCUA-IIoT-Server-ASO", "z": "c9b04afe.8458b", "nodeId": "ns=1;s=Mains.RealPower", "browsename": "RealPower", "displayname": "RealPower", "objecttype": "BaseDataVariableType", "datatype": "Int16", "value": "0", "referenceNodeId": "ns=1;s=Mains", "referencetype": "Organizes", "name": "Mains.RealPower", "x": 370, "y": 220, "wires": [ [ "20874e14.2319ea" ] ] }, { "id": "cce12bea.5bc6c8", "type": "OPCUA-IIoT-Server-ASO", "z": "c9b04afe.8458b", "nodeId": "ns=1;s=Mains.PowerFactor", "browsename": "PowerFactor", "displayname": "PowerFactor", "objecttype": "BaseDataVariableType", "datatype": "Float", "value": "0", "referenceNodeId": "ns=1;s=Mains", "referencetype": "Organizes", "name": "Mains.PowerFactor", "x": 370, "y": 260, "wires": [ [ "20874e14.2319ea" ] ] }, { "id": "59743432.65fc3c", "type": "OPCUA-IIoT-Inject", "z": "c9b04afe.8458b", "injectType": "inject", "payload": "0", "payloadType": "num", "topic": "", "repeat": "", "crontab": "", "once": true, "startDelay": "3", "name": "After 3 sec", "addressSpaceItems": [], "x": 170, "y": 180, "wires": [ [ "9e6fff36.b2e288", "41d43e56.cc3a58", "cce12bea.5bc6c8" ] ] }, { "id": "5a3cc2c6.ecd1dc", "type": "modbus-read", "z": "e62720b3.9a2498", "name": "Read Registers 100 - 102", "topic": "", "showStatusActivities": false, "logIOActivities": false, "showErrors": false, "unitid": "", "dataType": "HoldingRegister", "adr": "100", "quantity": "3", "rate": "1", "rateUnit": "s", "delayOnStart": false, "startDelayTime": "", "server": "40ce404d.94b018", "useIOFile": false, "ioFile": "", "useIOForPayload": false, "x": 150, "y": 80, "wires": [ [ "3b62bee7.18e15a" ], [] ] }, { "id": "3b62bee7.18e15a", "type": "split", "z": "e62720b3.9a2498", "name": "Register Separation", "splt": "\\n", "spltType": "str", "arraySplt": 1, "arraySpltType": "len", "stream": false, "addname": "", "x": 400, "y": 80, "wires": [ [ "1f9ae96b.48c117" ] ] }, { "id": "1f9ae96b.48c117", "type": "switch", "z": "e62720b3.9a2498", "name": "Register Selection", "property": "parts.index", "propertyType": "msg", "rules": [ { "t": "eq", "v": "0", "vt": "num" }, { "t": "eq", "v": "1", "vt": "num" }, { "t": "eq", "v": "2", "vt": "num" } ], "checkall": "true", "repair": false, "outputs": 3, "x": 630, "y": 80, "wires": [ [ "550edc9f.787bf4" ], [ "153abedc.2604b9" ], [ "fb97df5.b8ac0a" ] ] }, { "id": "e5a379e.9fb4108", "type": "OPCUA-IIoT-Write", "z": "e62720b3.9a2498", "connector": "f86f6dfa.5d5ff", "name": "", "justValue": true, "showStatusActivities": false, "showErrors": false, "x": 1170, "y": 80, "wires": [ [] ] }, { "id": "550edc9f.787bf4", "type": "OPCUA-IIoT-Node", "z": "e62720b3.9a2498", "injectType": "write", "nodeId": "ns=1;s=Mains.ApparentPower", "datatype": "UInt16", "value": "", "name": "Mains.ApparentPower", "topic": "", "showErrors": false, "x": 920, "y": 80, "wires": [ [ "e5a379e.9fb4108" ] ] }, { "id": "153abedc.2604b9", "type": "OPCUA-IIoT-Node", "z": "e62720b3.9a2498", "injectType": "write", "nodeId": "ns=1;s=Mains.RealPower", "datatype": "Int16", "value": "", "name": "Mains.RealPower", "topic": "", "showErrors": false, "x": 910, "y": 140, "wires": [ [ "e5a379e.9fb4108" ] ] }, { "id": "fb97df5.b8ac0a", "type": "OPCUA-IIoT-Node", "z": "e62720b3.9a2498", "injectType": "write", "nodeId": "ns=1;s=Mains.PowerFactor", "datatype": "UInt16", "value": "", "name": "Mains.PowerFactor", "topic": "", "showErrors": false, "x": 910, "y": 200, "wires": [ [ "e5a379e.9fb4108" ] ] } ] grafik I am currently dismissing the idea of implementing this in node-red and do it in node.js directly as the performance is really bad. I need to convert about 80 modbus registers into 150 OPC values and CPU load on a Raspberry is already above 100% with only half of the project finished.

biancode commented 6 years ago

Is the browser for Node-RED running on the same machine or is it a PI as backend and external PC to browse Node-RED?

StephanLeschke commented 6 years ago

The PI is the backend running node-red and the browser is running on desktop PC.

biancode commented 6 years ago

The flow is much to complicated too.

biancode commented 6 years ago

should look like that

grafik

biancode commented 6 years ago

grafik

StephanLeschke commented 6 years ago

I have seen this in your SDM630 example. My intention was to have the individual OPC items visible. But I can give it a try before moving completely away from a graphical implementation.