Node-Red OPC-UA Server only working for Double?

42 Views Asked by At

I am trying to create an OPC-UA server in Node-Red using node-red-contrib-opcua-server version 1.1.1. This works quite well for values declared as double.

The flow for this looks quite simple enter image description here

The configuration of the Node Compact server for a double value looks like this (and thus pretty much follows the example)

const WC01_raw_mat = namespace.addVariable({
 "organizedBy": wc01,
 "browseName": "raw_mat",
 "nodeId": "ns=1;s=wc01_raw_mat",
 "dataType": "Double",
 "value": {
   "get": function () {
     return new Variant({
       "dataType": DataType.Double,
       "value": flexServerInternals.sandboxFlowContext.get("WC01_raw_mat")
     });
   },
   "set": function (variant) {
     flexServerInternals.sandboxFlowContext.set(
       "WC01_raw_mat",
       parseFloat(variant.value)
     );
     return opcua.StatusCodes.Good;
   }
 }});

If I check the value with an OPC-UA Client I can see my double with a value 0.0

enter image description here

However, my attempt to transfer an integer or string in addition to a double value fails. The adjustments for integers look like this:

const WC01_raw_mat = namespace.addVariable({
 "organizedBy": wc01,
 "browseName": "raw_mat",
 "nodeId": "ns=1;s=wc01_raw_mat",
 "dataType": "Integer",
 "value": {
   "get": function () {
     return new Variant({
       "dataType": DataType.Integer,
       "value": flexServerInternals.sandboxFlowContext.get("WC01_raw_mat")
     });
   },
   "set": function (variant) {
     flexServerInternals.sandboxFlowContext.set(
       "WC01_raw_mat",
       parseInt(variant.value)
     );
     return opcua.StatusCodes.Good;
   }
 }});

(Modifications I made: "dataType": "Integer","dataType": DataType.Integer,parseInt(variant.value) ) Unfortunately, no more data is displayed.

enter image description here

So, what did I made wrong or what did I miss? I am grateful for any tips.

0

There are 0 best solutions below