How to define Data Type STRING for opcua iiot flex server node

Dear Friends,
I am trying to create opc ua server using from "node-red-contrib-iiot-opcua".
I am able to get it working with data type as double. definition as shown below is working perfect:
const gpioDI1 = namespace.addVariable({
"organizedBy": isoInputs,
"browseName": "I1",
"nodeId": "ns=1;s=Isolated_Input1",
"dataType": "Double",
"value": {
"get": function() {
return new Variant({
"dataType": DataType.Double,
"value": flexServerInternals.sandboxFlowContext.get("data1")
});
},
"set": function(variant) {
flexServerInternals.sandboxFlowContext.set(
"isoInput1",
parseFloat(variant.value)
);
return opcua.StatusCodes.Good;
}
}
});

But when I try data type string as shown below, then it does not work, node status is always "waiting"
const gpioDI1 = namespace.addVariable({
"organizedBy": isoInputs,
"browseName": "I1",
"nodeId": "ns=1;s=String",
"dataType": "String",
"value": {
"get": function() {
return new Variant({
"dataType": DataType.String,
"value": flexServerInternals.sandboxFlowContext.get("data1")
});
},
"set": function(variant) {
flexServerInternals.sandboxFlowContext.set(
"isoInput1",
parseFloat(variant.value)
);
return opcua.StatusCodes.Good;
}
}
});

the flow which is running perfectly is as below:

[
    {
        "id": "89c9e23040c05321",
        "type": "OPCUA-IIoT-Flex-Server",
        "z": "96df9d1b.b1b87",
        "port": "55480",
        "endpoint": "UA/user1",
        "acceptExternalCommands": true,
        "maxAllowedSessionNumber": "",
        "maxConnectionsPerEndpoint": "",
        "maxAllowedSubscriptionNumber": "",
        "alternateHostname": "",
        "name": "user1",
        "showStatusActivities": false,
        "showErrors": false,
        "allowAnonymous": true,
        "individualCerts": false,
        "isAuditing": false,
        "serverDiscovery": true,
        "users": [],
        "xmlsets": [],
        "publicCertificateFile": "",
        "privateCertificateFile": "",
        "registerServerMethod": "1",
        "discoveryServerEndpointUrl": "",
        "capabilitiesForMDNS": "",
        "maxNodesPerRead": 1000,
        "maxNodesPerBrowse": 2000,
        "delayToClose": 1000,
        "addressSpaceScript": "function constructAlarmAddressSpace(server, addressSpace, eventObjects, done) {\n    // server = the created node-opcua server\n    // addressSpace = script placeholder\n    // eventObjects = to hold event variables in memory from this script\n    \n    // internal global sandbox objects are \n    // node = node of the flex server, \n    // coreServer = core iiot server object for debug and access to nodeOPCUA,\n    // and scriptObjects to hold variables and functions\n    const LocalizedText = opcua.LocalizedText;\n    const namespace = addressSpace.getOwnNamespace();\n    \n    coreServer.internalDebugLog('init dynamic address space')\n    node.warn('construct new address space for OPC UA')\n    \n    const Variant = opcua.Variant;\n    const DataType = opcua.DataType;\n    const DataValue = opcua.DataValue;\n    \n    var flexServerInternals = this;\n    \n    this.sandboxFlowContext.set(\"data1\", 0);\n    this.sandboxFlowContext.set(\"data2\", 0);\n \n    \n    this.sandboxFlowContext.set(\"data3\", 0);\n    this.sandboxFlowContext.set(\"data4\", 0);\n \n    \n    coreServer.internalDebugLog(\"init dynamic address space\");\n    const rootFolder = addressSpace.findNode(\"RootFolder\");\n    \n    node.warn(\"construct new address space for OPC UA\");\n    \n    const myDevice = namespace.addFolder(rootFolder.objects, {\n    \"browseName\": \"GNA_Scanner\"\n    });\n    const gpioFolder = namespace.addFolder(myDevice, { \"browseName\": \"GPIO\" });\n    const isoInputs = namespace.addFolder(gpioFolder, {\n    \"browseName\": \"Inputs\"\n    });\n    const isoOutputs = namespace.addFolder(gpioFolder, {\n    \"browseName\": \"Outputs\"\n    });\n    \n    const gpioDI1 = namespace.addVariable({\n    \"organizedBy\": isoInputs,\n    \"browseName\": \"I1\",\n      \"nodeId\": \"ns=1;s=Isolated_Input1\",\n    \"dataType\": \"Double\",\n    \"value\": {\n      \"get\": function() {\n        return new Variant({\n          \"dataType\": DataType.Double,\n          \"value\": flexServerInternals.sandboxFlowContext.get(\"data1\")\n        });\n      },\n      \"set\": function(variant) {\n        flexServerInternals.sandboxFlowContext.set(\n          \"isoInput1\",\n          variant.value\n        );\n        return opcua.StatusCodes.Good;\n      }\n    }\n    });\n    \n    const gpioDI2 = namespace.addVariable({\n    \"organizedBy\": isoInputs,\n    \"browseName\": \"I2\",\n    \"nodeId\": \"ns=1;s=Isolated_Input2\",\n    \"dataType\": \"Double\",\n    \"value\": {\n      \"get\": function() {\n        return new Variant({\n          \"dataType\": DataType.Double,\n          \"value\": flexServerInternals.sandboxFlowContext.get(\"data2\")\n        });\n      },\n      \"set\": function(variant) {\n        flexServerInternals.sandboxFlowContext.set(\n          \"isoInput2\",\n          parseFloat(variant.value)\n        );\n        return opcua.StatusCodes.Good;\n      }\n    }\n    });\n   \n    const gpioDO1 = namespace.addVariable({\n    \"organizedBy\": isoOutputs,\n    \"browseName\": \"O1\",\n    \"nodeId\": \"ns=1;s=Isolated_Output1\",\n    \"dataType\": \"Double\",\n    \"value\": {\n      \"get\": function() {\n        return new Variant({\n          \"dataType\": DataType.Double,\n          \"value\": flexServerInternals.sandboxFlowContext.get(\"data3\")\n        });\n      },\n      \"set\": function(variant) {\n        flexServerInternals.sandboxFlowContext.set(\n          \"isoOutput1\",\n          parseFloat(variant.value)\n        );\n        return opcua.StatusCodes.Good;\n      }\n    }\n    });\n    \n    const gpioDO2 = namespace.addVariable({\n    \"organizedBy\": isoOutputs,\n    \"browseName\": \"O2\",\n    \"nodeId\": \"ns=1;s=Isolated_Output2\",\n    \"dataType\": \"Double\",\n    \"value\": {\n      \"get\": function() {\n        return new Variant({\n          \"dataType\": DataType.Double,\n          \"value\": flexServerInternals.sandboxFlowContext.get(\"data4\")\n        });\n      },\n      \"set\": function(variant) {\n        flexServerInternals.sandboxFlowContext.set(\n          \"isoOutput2\",\n          parseFloat(variant.value)\n        );\n        return opcua.StatusCodes.Good;\n      }\n    }\n    });\n    \n    \n    //------------------------------------------------------------------------------\n    // Add a view\n    //------------------------------------------------------------------------------\n    const viewDI = namespace.addView({\n    \"organizedBy\": rootFolder.views,\n    \"browseName\": \"RPIW0-Digital-Ins\"\n    });\n    \n    const viewDO = namespace.addView({\n    \"organizedBy\": rootFolder.views,\n    \"browseName\": \"RPIW0-Digital-Outs\"\n    });\n    \n    viewDI.addReference({\n    \"referenceType\": \"Organizes\",\n    \"nodeId\": gpioDI1.nodeId\n    });\n    \n    viewDI.addReference({\n    \"referenceType\": \"Organizes\",\n    \"nodeId\": gpioDI2.nodeId\n    });\n \n    \n    viewDO.addReference({\n    \"referenceType\": \"Organizes\",\n    \"nodeId\": gpioDO1.nodeId\n    });\n    \n    viewDO.addReference({\n    \"referenceType\": \"Organizes\",\n    \"nodeId\": gpioDO2.nodeId\n    });\n    \n  \n    coreServer.internalDebugLog(\"create dynamic address space done\");\n    node.warn(\"construction of new address space for OPC UA done\");\n    \n    done();\n}\n",
        "x": 670,
        "y": 440,
        "wires": [
            []
        ]
    },
    {
        "id": "d322f02a5173c846",
        "type": "function",
        "z": "96df9d1b.b1b87",
        "name": "set flow context Inputs",
        "func": "flow.set('data1', 999)\nflow.set('data2', Math.random() + 13.0)\nflow.set('data3', Math.random() + 14.0)\nflow.set('data4', Math.random() + 15.0)\n\nmsg.payload = [\n    flow.get('data1'),\n    flow.get('data2'),\n    flow.get('data3'),\n    flow.get('data4'),\n]\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 460,
        "y": 380,
        "wires": [
            [
                "be3de210a03c018d"
            ]
        ]
    },
    {
        "id": "cc009cd686d0639d",
        "type": "inject",
        "z": "96df9d1b.b1b87",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "3",
        "crontab": "",
        "once": true,
        "onceDelay": "0.5",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 250,
        "y": 380,
        "wires": [
            [
                "d322f02a5173c846"
            ]
        ]
    },
    {
        "id": "be3de210a03c018d",
        "type": "debug",
        "z": "96df9d1b.b1b87",
        "name": "debug 1",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 680,
        "y": 380,
        "wires": []
    }
]

and the flow which is not working is as below:

[
    {
        "id": "89c9e23040c05321",
        "type": "OPCUA-IIoT-Flex-Server",
        "z": "96df9d1b.b1b87",
        "port": "55480",
        "endpoint": "UA/user1",
        "acceptExternalCommands": true,
        "maxAllowedSessionNumber": "",
        "maxConnectionsPerEndpoint": "",
        "maxAllowedSubscriptionNumber": "",
        "alternateHostname": "",
        "name": "user1",
        "showStatusActivities": false,
        "showErrors": false,
        "allowAnonymous": true,
        "individualCerts": false,
        "isAuditing": false,
        "serverDiscovery": true,
        "users": [],
        "xmlsets": [],
        "publicCertificateFile": "",
        "privateCertificateFile": "",
        "registerServerMethod": "1",
        "discoveryServerEndpointUrl": "",
        "capabilitiesForMDNS": "",
        "maxNodesPerRead": 1000,
        "maxNodesPerBrowse": 2000,
        "delayToClose": 1000,
        "addressSpaceScript": "function constructAlarmAddressSpace(server, addressSpace, eventObjects, done) {\n    // server = the created node-opcua server\n    // addressSpace = script placeholder\n    // eventObjects = to hold event variables in memory from this script\n    \n    // internal global sandbox objects are \n    // node = node of the flex server, \n    // coreServer = core iiot server object for debug and access to nodeOPCUA,\n    // and scriptObjects to hold variables and functions\n    const LocalizedText = opcua.LocalizedText;\n    const namespace = addressSpace.getOwnNamespace();\n    \n    coreServer.internalDebugLog('init dynamic address space')\n    node.warn('construct new address space for OPC UA')\n    \n    const Variant = opcua.Variant;\n    const DataType = opcua.DataType;\n    const DataValue = opcua.DataValue;\n    \n    var flexServerInternals = this;\n    \n    this.sandboxFlowContext.set(\"data1\", 0);\n    this.sandboxFlowContext.set(\"data2\", 0);\n \n    \n    this.sandboxFlowContext.set(\"data3\", 0);\n    this.sandboxFlowContext.set(\"data4\", 0);\n \n    \n    coreServer.internalDebugLog(\"init dynamic address space\");\n    const rootFolder = addressSpace.findNode(\"RootFolder\");\n    \n    node.warn(\"construct new address space for OPC UA\");\n    \n    const myDevice = namespace.addFolder(rootFolder.objects, {\n    \"browseName\": \"GNA_Scanner\"\n    });\n    const gpioFolder = namespace.addFolder(myDevice, { \"browseName\": \"GPIO\" });\n    const isoInputs = namespace.addFolder(gpioFolder, {\n    \"browseName\": \"Inputs\"\n    });\n    const isoOutputs = namespace.addFolder(gpioFolder, {\n    \"browseName\": \"Outputs\"\n    });\n    \n    const gpioDI1 = namespace.addVariable({\n    \"organizedBy\": isoInputs,\n    \"browseName\": \"I1\",\n      \"nodeId\": \"ns=1;s=Isolated_Input1\",\n    \"dataType\": \"String\",\n    \"value\": {\n      \"get\": function() {\n        return new Variant({\n          \"dataType\": DataType.String,\n          \"value\": flexServerInternals.sandboxFlowContext.get(\"data1\")\n        });\n      },\n      \"set\": function(variant) {\n        flexServerInternals.sandboxFlowContext.set(\n          \"isoInput1\",\n          variant.value\n        );\n        return opcua.StatusCodes.Good;\n      }\n    }\n    });\n    \n    const gpioDI2 = namespace.addVariable({\n    \"organizedBy\": isoInputs,\n    \"browseName\": \"I2\",\n    \"nodeId\": \"ns=1;s=Isolated_Input2\",\n    \"dataType\": \"Double\",\n    \"value\": {\n      \"get\": function() {\n        return new Variant({\n          \"dataType\": DataType.Double,\n          \"value\": flexServerInternals.sandboxFlowContext.get(\"data2\")\n        });\n      },\n      \"set\": function(variant) {\n        flexServerInternals.sandboxFlowContext.set(\n          \"isoInput2\",\n          parseFloat(variant.value)\n        );\n        return opcua.StatusCodes.Good;\n      }\n    }\n    });\n   \n    const gpioDO1 = namespace.addVariable({\n    \"organizedBy\": isoOutputs,\n    \"browseName\": \"O1\",\n    \"nodeId\": \"ns=1;s=Isolated_Output1\",\n    \"dataType\": \"Double\",\n    \"value\": {\n      \"get\": function() {\n        return new Variant({\n          \"dataType\": DataType.Double,\n          \"value\": flexServerInternals.sandboxFlowContext.get(\"data3\")\n        });\n      },\n      \"set\": function(variant) {\n        flexServerInternals.sandboxFlowContext.set(\n          \"isoOutput1\",\n          parseFloat(variant.value)\n        );\n        return opcua.StatusCodes.Good;\n      }\n    }\n    });\n    \n    const gpioDO2 = namespace.addVariable({\n    \"organizedBy\": isoOutputs,\n    \"browseName\": \"O2\",\n    \"nodeId\": \"ns=1;s=Isolated_Output2\",\n    \"dataType\": \"Double\",\n    \"value\": {\n      \"get\": function() {\n        return new Variant({\n          \"dataType\": DataType.Double,\n          \"value\": flexServerInternals.sandboxFlowContext.get(\"data4\")\n        });\n      },\n      \"set\": function(variant) {\n        flexServerInternals.sandboxFlowContext.set(\n          \"isoOutput2\",\n          parseFloat(variant.value)\n        );\n        return opcua.StatusCodes.Good;\n      }\n    }\n    });\n    \n    \n    //------------------------------------------------------------------------------\n    // Add a view\n    //------------------------------------------------------------------------------\n    const viewDI = namespace.addView({\n    \"organizedBy\": rootFolder.views,\n    \"browseName\": \"RPIW0-Digital-Ins\"\n    });\n    \n    const viewDO = namespace.addView({\n    \"organizedBy\": rootFolder.views,\n    \"browseName\": \"RPIW0-Digital-Outs\"\n    });\n    \n    viewDI.addReference({\n    \"referenceType\": \"Organizes\",\n    \"nodeId\": gpioDI1.nodeId\n    });\n    \n    viewDI.addReference({\n    \"referenceType\": \"Organizes\",\n    \"nodeId\": gpioDI2.nodeId\n    });\n \n    \n    viewDO.addReference({\n    \"referenceType\": \"Organizes\",\n    \"nodeId\": gpioDO1.nodeId\n    });\n    \n    viewDO.addReference({\n    \"referenceType\": \"Organizes\",\n    \"nodeId\": gpioDO2.nodeId\n    });\n    \n  \n    coreServer.internalDebugLog(\"create dynamic address space done\");\n    node.warn(\"construction of new address space for OPC UA done\");\n    \n    done();\n}\n",
        "x": 670,
        "y": 440,
        "wires": [
            []
        ]
    },
    {
        "id": "d322f02a5173c846",
        "type": "function",
        "z": "96df9d1b.b1b87",
        "name": "set flow context Inputs",
        "func": "flow.set('data1', \"ABC1234\")\nflow.set('data2', Math.random() + 13.0)\nflow.set('data3', Math.random() + 14.0)\nflow.set('data4', Math.random() + 15.0)\n\nmsg.payload = [\n    flow.get('data1'),\n    flow.get('data2'),\n    flow.get('data3'),\n    flow.get('data4'),\n]\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 460,
        "y": 380,
        "wires": [
            [
                "be3de210a03c018d"
            ]
        ]
    },
    {
        "id": "cc009cd686d0639d",
        "type": "inject",
        "z": "96df9d1b.b1b87",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "3",
        "crontab": "",
        "once": true,
        "onceDelay": "0.5",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 250,
        "y": 380,
        "wires": [
            [
                "d322f02a5173c846"
            ]
        ]
    },
    {
        "id": "be3de210a03c018d",
        "type": "debug",
        "z": "96df9d1b.b1b87",
        "name": "debug 1",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 680,
        "y": 380,
        "wires": []
    }
]

Please suggest the solution to make second flow with string input working. thanks.

@Steve-Mcl , @mikakaraila : Can you please guide and support on this? Thanks a lot in advance.

Fix that link to be just variant.value

I had already tried it. It does not work.

Finally, I could find a way out by using:
"dataType": "LocalizedText", (instead of String)

My new flow is pasted below , may be someone else can get some help.

[
    {
        "id": "38ce10de.7d8c",
        "type": "opcua-compact-server",
        "z": "2e8c7f5c.ab73d",
        "port": 54845,
        "endpoint": "",
        "productUri": "",
        "acceptExternalCommands": true,
        "maxAllowedSessionNumber": "10",
        "maxConnectionsPerEndpoint": "10",
        "maxAllowedSubscriptionNumber": "100",
        "alternateHostname": "",
        "name": "",
        "showStatusActivities": false,
        "showErrors": true,
        "allowAnonymous": true,
        "individualCerts": false,
        "isAuditing": false,
        "serverDiscovery": true,
        "users": [],
        "xmlsetsOPCUA": [],
        "publicCertificateFile": "",
        "privateCertificateFile": "",
        "registerServerMethod": "1",
        "discoveryServerEndpointUrl": "",
        "capabilitiesForMDNS": "",
        "maxNodesPerRead": 1000,
        "maxNodesPerWrite": 1000,
        "maxNodesPerHistoryReadData": 100,
        "maxNodesPerBrowse": 3000,
        "maxBrowseContinuationPoints": "10",
        "maxHistoryContinuationPoints": "10",
        "delayToInit": "1000",
        "delayToClose": "200",
        "serverShutdownTimeout": "100",
        "addressSpaceScript": "function constructAlarmAddressSpace(server, addressSpace, eventObjects, done) {\n  // server = the created node-opcua server\n  // addressSpace = address space of the node-opcua server\n  // eventObjects = add event variables here to hold them in memory from this script\n\n  // internal sandbox objects are:\n  // node = the compact server node,\n  // coreServer = core compact server object for debug and access to NodeOPCUA\n  // this.sandboxNodeContext = node context node-red\n  // this.sandboxFlowContext = flow context node-red\n  // this.sandboxGlobalContext = global context node-red\n  // this.sandboxEnv = env variables\n  // timeout and interval functions as expected from nodejs\n\n  const opcua = coreServer.choreCompact.opcua;\n  const LocalizedText = opcua.LocalizedText;\n  const namespace = addressSpace.getOwnNamespace();\n\n  const Variant = opcua.Variant;\n  const DataType = opcua.DataType;\n  const DataValue = opcua.DataValue;\n\n  var flexServerInternals = this;\n\n  this.sandboxFlowContext.set(\"isoInput1\", 0);\n  this.setInterval(() => {\n    flexServerInternals.sandboxFlowContext.set(\n      \"isoInput1\",\n      Math.random() + 50.0\n    );\n  }, 500);\n  this.sandboxFlowContext.set(\"isoInput2\", 0);\n  this.sandboxFlowContext.set(\"isoInput3\", 0);\n  this.sandboxFlowContext.set(\"isoInput4\", 0);\n  this.sandboxFlowContext.set(\"isoInput5\", 0);\n  this.sandboxFlowContext.set(\"isoInput6\", 0);\n  this.sandboxFlowContext.set(\"isoInput7\", 0);\n  this.sandboxFlowContext.set(\"isoInput8\", 0);\n\n  this.sandboxFlowContext.set(\"isoOutput1\", 0);\n  this.setInterval(() => {\n    flexServerInternals.sandboxFlowContext.set(\n      \"isoOutput1\",\n      Math.random() + 10.0\n    );\n  }, 500);\n\n  this.sandboxFlowContext.set(\"isoOutput2\", 0);\n  this.sandboxFlowContext.set(\"isoOutput3\", 0);\n  this.sandboxFlowContext.set(\"isoOutput4\", 0);\n  this.sandboxFlowContext.set(\"isoOutput5\", 0);\n  this.sandboxFlowContext.set(\"isoOutput6\", 0);\n  this.sandboxFlowContext.set(\"isoOutput7\", 0);\n  this.sandboxFlowContext.set(\"isoOutput8\", 0);\n\n  coreServer.debugLog(\"init dynamic address space\");\n  const rootFolder = addressSpace.findNode(\"RootFolder\");\n\n  node.warn(\"construct new address space for OPC UA\");\n\n  const myDevice = namespace.addFolder(rootFolder.objects, {\n    \"browseName\": \"RaspberryPI-Zero-WLAN\"\n  });\n  const gpioFolder = namespace.addFolder(myDevice, { \"browseName\": \"GPIO\" });\n  const isoInputs = namespace.addFolder(gpioFolder, {\n    \"browseName\": \"Inputs\"\n  });\n  const isoOutputs = namespace.addFolder(gpioFolder, {\n    \"browseName\": \"Outputs\"\n  });\n\n  const gpioDI1 = namespace.addVariable({\n    \"organizedBy\": isoInputs,\n    \"browseName\": \"I1\",\n    \"nodeId\": \"ns=1;s=Isolated_Input1\",\n    \"dataType\": \"Double\",\n    \"value\": {\n      \"get\": function() {\n        return new Variant({\n          \"dataType\": DataType.Double,\n          \"value\": flexServerInternals.sandboxFlowContext.get(\"isoInput1\")\n        });\n      },\n      \"set\": function(variant) {\n        flexServerInternals.sandboxFlowContext.set(\n          \"isoInput1\",\n          parseFloat(variant.value)\n        );\n        return opcua.StatusCodes.Good;\n      }\n    }\n  });\n\n  const gpioDI2 = namespace.addVariable({\n    \"organizedBy\": isoInputs,\n    \"browseName\": \"I2\",\n    \"nodeId\": \"ns=1;s=Isolated_Input2\",\n    \"dataType\": \"LocalizedText\",\n    \"value\": {\n      \"get\": function() {\n        return new Variant({\n          \"dataType\": DataType.LocalizedText,\n          \"value\": flexServerInternals.sandboxFlowContext.get(\"isoInput2\")\n        });\n      },\n      \"set\": function(variant) {\n        flexServerInternals.sandboxFlowContext.set(\n          \"isoInput2\",\n          variant.value\n        );\n        return opcua.StatusCodes.Good;\n      }\n    }\n  });\n\n  const gpioDI3 = namespace.addVariable({\n    \"organizedBy\": isoInputs,\n    \"browseName\": \"I3\",\n    \"nodeId\": \"ns=1;s=Isolated_Input3\",\n    \"dataType\": \"Double\",\n    \"value\": {\n      \"get\": function() {\n        return new Variant({\n          \"dataType\": DataType.Double,\n          \"value\": flexServerInternals.sandboxFlowContext.get(\"isoInput3\")\n        });\n      },\n      \"set\": function(variant) {\n        flexServerInternals.sandboxFlowContext.set(\n          \"isoInput3\",\n          parseFloat(variant.value)\n        );\n        return opcua.StatusCodes.Good;\n      }\n    }\n  });\n\n  const gpioDI4 = namespace.addVariable({\n    \"organizedBy\": isoInputs,\n    \"browseName\": \"I4\",\n    \"nodeId\": \"ns=1;s=Isolated_Input4\",\n    \"dataType\": \"Double\",\n    \"value\": {\n      \"get\": function() {\n        return new Variant({\n          \"dataType\": DataType.Double,\n          \"value\": flexServerInternals.sandboxFlowContext.get(\"isoInput4\")\n        });\n      },\n      \"set\": function(variant) {\n        flexServerInternals.sandboxFlowContext.set(\n          \"isoInput4\",\n          parseFloat(variant.value)\n        );\n        return opcua.StatusCodes.Good;\n      }\n    }\n  });\n\n  const gpioDI5 = namespace.addVariable({\n    \"organizedBy\": isoInputs,\n    \"browseName\": \"I5\",\n    \"nodeId\": \"ns=1;s=Isolated_Input5\",\n    \"dataType\": \"Double\",\n    \"value\": {\n      \"get\": function() {\n        return new Variant({\n          \"dataType\": DataType.Double,\n          \"value\": flexServerInternals.sandboxFlowContext.get(\"isoInput5\")\n        });\n      },\n      \"set\": function(variant) {\n        flexServerInternals.sandboxFlowContext.set(\n          \"isoInput5\",\n          parseFloat(variant.value)\n        );\n        return opcua.StatusCodes.Good;\n      }\n    }\n  });\n\n  const gpioDI6 = namespace.addVariable({\n    \"organizedBy\": isoInputs,\n    \"browseName\": \"I6\",\n    \"nodeId\": \"ns=1;s=Isolated_Input6\",\n    \"dataType\": \"Double\",\n    \"value\": {\n      \"get\": function() {\n        return new Variant({\n          \"dataType\": DataType.Double,\n          \"value\": flexServerInternals.sandboxFlowContext.get(\"isoInput6\")\n        });\n      },\n      \"set\": function(variant) {\n        flexServerInternals.sandboxFlowContext.set(\n          \"isoInput6\",\n          parseFloat(variant.value)\n        );\n        return opcua.StatusCodes.Good;\n      }\n    }\n  });\n\n  const gpioDI7 = namespace.addVariable({\n    \"organizedBy\": isoInputs,\n    \"browseName\": \"I7\",\n    \"nodeId\": \"ns=1;s=Isolated_Input7\",\n    \"dataType\": \"Double\",\n    \"value\": {\n      \"get\": function() {\n        return new Variant({\n          \"dataType\": DataType.Double,\n          \"value\": flexServerInternals.sandboxFlowContext.get(\"isoInput7\")\n        });\n      },\n      \"set\": function(variant) {\n        flexServerInternals.sandboxFlowContext.set(\n          \"isoInput7\",\n          parseFloat(variant.value)\n        );\n        return opcua.StatusCodes.Good;\n      }\n    }\n  });\n\n  const gpioDI8 = namespace.addVariable({\n    \"organizedBy\": isoInputs,\n    \"browseName\": \"I8\",\n    \"nodeId\": \"ns=1;s=Isolated_Input8\",\n    \"dataType\": \"Double\",\n    \"value\": {\n      \"get\": function() {\n        return new Variant({\n          \"dataType\": DataType.Double,\n          \"value\": flexServerInternals.sandboxFlowContext.get(\"isoInput8\")\n        });\n      },\n      \"set\": function(variant) {\n        flexServerInternals.sandboxFlowContext.set(\n          \"isoInput8\",\n          parseFloat(variant.value)\n        );\n        return opcua.StatusCodes.Good;\n      }\n    }\n  });\n\n  const gpioDO1 = namespace.addVariable({\n    \"organizedBy\": isoOutputs,\n    \"browseName\": \"O1\",\n    \"nodeId\": \"ns=1;s=Isolated_Output1\",\n    \"dataType\": \"Double\",\n    \"value\": {\n      \"get\": function() {\n        return new Variant({\n          \"dataType\": DataType.Double,\n          \"value\": flexServerInternals.sandboxFlowContext.get(\"isoOutput1\")\n        });\n      },\n      \"set\": function(variant) {\n        flexServerInternals.sandboxFlowContext.set(\n          \"isoOutput1\",\n          parseFloat(variant.value)\n        );\n        return opcua.StatusCodes.Good;\n      }\n    }\n  });\n\n  const gpioDO2 = namespace.addVariable({\n    \"organizedBy\": isoOutputs,\n    \"browseName\": \"O2\",\n    \"nodeId\": \"ns=1;s=Isolated_Output2\",\n    \"dataType\": \"Double\",\n    \"value\": {\n      \"get\": function() {\n        return new Variant({\n          \"dataType\": DataType.Double,\n          \"value\": flexServerInternals.sandboxFlowContext.get(\"isoOutput2\")\n        });\n      },\n      \"set\": function(variant) {\n        flexServerInternals.sandboxFlowContext.set(\n          \"isoOutput2\",\n          parseFloat(variant.value)\n        );\n        return opcua.StatusCodes.Good;\n      }\n    }\n  });\n\n  const gpioDO3 = namespace.addVariable({\n    \"organizedBy\": isoOutputs,\n    \"browseName\": \"O3\",\n    \"nodeId\": \"ns=1;s=Isolated_Output3\",\n    \"dataType\": \"Double\",\n    \"value\": {\n      \"get\": function() {\n        return new Variant({\n          \"dataType\": DataType.Double,\n          \"value\": flexServerInternals.sandboxFlowContext.get(\"isoOutput3\")\n        });\n      },\n      \"set\": function(variant) {\n        flexServerInternals.sandboxFlowContext.set(\n          \"isoOutput3\",\n          parseFloat(variant.value)\n        );\n        return opcua.StatusCodes.Good;\n      }\n    }\n  });\n\n  const gpioDO4 = namespace.addVariable({\n    \"organizedBy\": isoOutputs,\n    \"browseName\": \"O4\",\n    \"nodeId\": \"ns=1;s=Isolated_Output4\",\n    \"dataType\": \"Double\",\n    \"value\": {\n      \"get\": function() {\n        return new Variant({\n          \"dataType\": DataType.Double,\n          \"value\": flexServerInternals.sandboxFlowContext.get(\"isoOutput4\")\n        });\n      },\n      \"set\": function(variant) {\n        flexServerInternals.sandboxFlowContext.set(\n          \"isoOutput4\",\n          parseFloat(variant.value)\n        );\n        return opcua.StatusCodes.Good;\n      }\n    }\n  });\n\n  const gpioDO5 = namespace.addVariable({\n    \"organizedBy\": isoOutputs,\n    \"browseName\": \"O5\",\n    \"nodeId\": \"ns=1;s=Isolated_Output5\",\n    \"dataType\": \"Double\",\n    \"value\": {\n      \"get\": function() {\n        return new Variant({\n          \"dataType\": DataType.Double,\n          \"value\": flexServerInternals.sandboxFlowContext.get(\"isoOutput5\")\n        });\n      },\n      \"set\": function(variant) {\n        flexServerInternals.sandboxFlowContext.set(\n          \"isoOutput5\",\n          parseFloat(variant.value)\n        );\n        return opcua.StatusCodes.Good;\n      }\n    }\n  });\n\n  const gpioDO6 = namespace.addVariable({\n    \"organizedBy\": isoOutputs,\n    \"browseName\": \"O6\",\n    \"nodeId\": \"ns=1;s=Isolated_Output6\",\n    \"dataType\": \"Double\",\n    \"value\": {\n      \"get\": function() {\n        return new Variant({\n          \"dataType\": DataType.Double,\n          \"value\": flexServerInternals.sandboxFlowContext.get(\"isoOutput6\")\n        });\n      },\n      \"set\": function(variant) {\n        flexServerInternals.sandboxFlowContext.set(\n          \"isoOutput6\",\n          parseFloat(variant.value)\n        );\n        return opcua.StatusCodes.Good;\n      }\n    }\n  });\n\n  const gpioDO7 = namespace.addVariable({\n    \"organizedBy\": isoOutputs,\n    \"browseName\": \"O7\",\n    \"nodeId\": \"ns=1;s=Isolated_Output7\",\n    \"dataType\": \"Double\",\n    \"value\": {\n      \"get\": function() {\n        return new Variant({\n          \"dataType\": DataType.Double,\n          \"value\": flexServerInternals.sandboxFlowContext.get(\"isoOutput7\")\n        });\n      },\n      \"set\": function(variant) {\n        flexServerInternals.sandboxFlowContext.set(\n          \"isoOutput7\",\n          parseFloat(variant.value)\n        );\n        return opcua.StatusCodes.Good;\n      }\n    }\n  });\n\n  const gpioDO8 = namespace.addVariable({\n    \"organizedBy\": isoOutputs,\n    \"browseName\": \"O8\",\n    \"nodeId\": \"ns=1;s=Isolated_Output8\",\n    \"dataType\": \"Double\",\n    \"value\": {\n      \"get\": function() {\n        return new Variant({\n          \"dataType\": DataType.Double,\n          \"value\": flexServerInternals.sandboxFlowContext.get(\"isoOutput8\")\n        });\n      },\n      \"set\": function(variant) {\n        flexServerInternals.sandboxFlowContext.set(\n          \"isoOutput8\",\n          parseFloat(variant.value)\n        );\n        return opcua.StatusCodes.Good;\n      }\n    }\n  });\n\n  //------------------------------------------------------------------------------\n  // Add a view\n  //------------------------------------------------------------------------------\n  const viewDI = namespace.addView({\n    \"organizedBy\": rootFolder.views,\n    \"browseName\": \"RPIW0-Digital-Ins\"\n  });\n\n  const viewDO = namespace.addView({\n    \"organizedBy\": rootFolder.views,\n    \"browseName\": \"RPIW0-Digital-Outs\"\n  });\n\n  viewDI.addReference({\n    \"referenceType\": \"Organizes\",\n    \"nodeId\": gpioDI1.nodeId\n  });\n\n  viewDI.addReference({\n    \"referenceType\": \"Organizes\",\n    \"nodeId\": gpioDI2.nodeId\n  });\n\n  viewDI.addReference({\n    \"referenceType\": \"Organizes\",\n    \"nodeId\": gpioDI3.nodeId\n  });\n\n  viewDI.addReference({\n    \"referenceType\": \"Organizes\",\n    \"nodeId\": gpioDI4.nodeId\n  });\n\n  viewDI.addReference({\n    \"referenceType\": \"Organizes\",\n    \"nodeId\": gpioDI5.nodeId\n  });\n\n  viewDI.addReference({\n    \"referenceType\": \"Organizes\",\n    \"nodeId\": gpioDI6.nodeId\n  });\n\n  viewDI.addReference({\n    \"referenceType\": \"Organizes\",\n    \"nodeId\": gpioDI7.nodeId\n  });\n\n  viewDI.addReference({\n    \"referenceType\": \"Organizes\",\n    \"nodeId\": gpioDI8.nodeId\n  });\n\n  viewDO.addReference({\n    \"referenceType\": \"Organizes\",\n    \"nodeId\": gpioDO1.nodeId\n  });\n\n  viewDO.addReference({\n    \"referenceType\": \"Organizes\",\n    \"nodeId\": gpioDO2.nodeId\n  });\n\n  viewDO.addReference({\n    \"referenceType\": \"Organizes\",\n    \"nodeId\": gpioDO3.nodeId\n  });\n\n  viewDO.addReference({\n    \"referenceType\": \"Organizes\",\n    \"nodeId\": gpioDO4.nodeId\n  });\n\n  viewDO.addReference({\n    \"referenceType\": \"Organizes\",\n    \"nodeId\": gpioDO5.nodeId\n  });\n\n  viewDO.addReference({\n    \"referenceType\": \"Organizes\",\n    \"nodeId\": gpioDO6.nodeId\n  });\n\n  viewDO.addReference({\n    \"referenceType\": \"Organizes\",\n    \"nodeId\": gpioDO7.nodeId\n  });\n\n  viewDO.addReference({\n    \"referenceType\": \"Organizes\",\n    \"nodeId\": gpioDO8.nodeId\n  });\n\n  coreServer.debugLog(\"create dynamic address space done\");\n  node.warn(\"construction of new address space for OPC UA done\");\n\n  done();\n}\n",
        "x": 380,
        "y": 480,
        "wires": []
    },
    {
        "id": "eea020c4.58aa",
        "type": "inject",
        "z": "2e8c7f5c.ab73d",
        "name": "",
        "repeat": "1",
        "crontab": "",
        "once": true,
        "onceDelay": "0.5",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 230,
        "y": 120,
        "wires": [
            [
                "11876179.c98d97"
            ]
        ]
    },
    {
        "id": "11876179.c98d97",
        "type": "function",
        "z": "2e8c7f5c.ab73d",
        "name": "set flow context Inputs",
        "func": "// flow.set('isoInput1', Math.random() + 11.0) interval comes from server\n//flow.set('isoInput2', \"777GNA777\")\nflow.set('isoInput3', Math.random() + 13.0)\nflow.set('isoInput4', Math.random() + 14.0)\nflow.set('isoInput5', Math.random() + 15.0)\nflow.set('isoInput6', Math.random() + 16.0)\nflow.set('isoInput7', Math.random() + 17.0)\nflow.set('isoInput8', Math.random() + 18.0)\n\nmsg.payload = [\n    flow.get('isoInput1'),\n    flow.get('isoInput2'),\n    flow.get('isoInput3'),\n    flow.get('isoInput4'),\n    flow.get('isoInput5'),\n    flow.get('isoInput6'),\n    flow.get('isoInput7'),\n    flow.get('isoInput8'),\n]\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 470,
        "y": 120,
        "wires": [
            [
                "c49994c7.8f5cc"
            ]
        ]
    },
    {
        "id": "c49994c7.8f5cc",
        "type": "debug",
        "z": "2e8c7f5c.ab73d",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 720,
        "y": 120,
        "wires": []
    },
    {
        "id": "71946cf3.646e14",
        "type": "function",
        "z": "2e8c7f5c.ab73d",
        "name": "set flow context Outputs",
        "func": "// flow.set('isoOutput1', Math.random() + 1.0) interval comes from server\nflow.set('isoOutput2', Math.random() + 2.0)\nflow.set('isoOutput3', Math.random() + 3.0)\nflow.set('isoOutput4', Math.random() + 4.0)\nflow.set('isoOutput5', Math.random() + 5.0)\nflow.set('isoOutput6', Math.random() + 6.0)\nflow.set('isoOutput7', Math.random() + 7.0)\nflow.set('isoOutput8', Math.random() + 8.0)\n\nmsg.payload = [\n    flow.get('isoOutput1'),\n    flow.get('isoOutput2'),\n    flow.get('isoOutput3'),\n    flow.get('isoOutput4'),\n    flow.get('isoOutput5'),\n    flow.get('isoOutput6'),\n    flow.get('isoOutput7'),\n    flow.get('isoOutput8'),\n]\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 480,
        "y": 180,
        "wires": [
            [
                "4eebf9d5.8843d8"
            ]
        ]
    },
    {
        "id": "494d041a.83d17c",
        "type": "inject",
        "z": "2e8c7f5c.ab73d",
        "name": "",
        "repeat": "1",
        "crontab": "",
        "once": true,
        "onceDelay": "0.5",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 230,
        "y": 180,
        "wires": [
            [
                "71946cf3.646e14"
            ]
        ]
    },
    {
        "id": "4eebf9d5.8843d8",
        "type": "debug",
        "z": "2e8c7f5c.ab73d",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 720,
        "y": 180,
        "wires": []
    },
    {
        "id": "201afb2df36b6105",
        "type": "inject",
        "z": "2e8c7f5c.ab73d",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 280,
        "y": 280,
        "wires": [
            [
                "6c457c17aa17fd5e",
                "0d432b2272fa7e4c"
            ]
        ]
    },
    {
        "id": "6c457c17aa17fd5e",
        "type": "function",
        "z": "2e8c7f5c.ab73d",
        "name": "function 4",
        "func": "flow.set(\"isoInput2\", \"Hello NR Forum\")\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 640,
        "y": 280,
        "wires": [
            []
        ]
    },
    {
        "id": "bcc5b2b921d0fc27",
        "type": "function",
        "z": "2e8c7f5c.ab73d",
        "name": "function 5",
        "func": "flow.set(\"isoInput2\", \"Hello World!!\")\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 640,
        "y": 340,
        "wires": [
            []
        ]
    },
    {
        "id": "0d432b2272fa7e4c",
        "type": "delay",
        "z": "2e8c7f5c.ab73d",
        "name": "",
        "pauseType": "delay",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 480,
        "y": 380,
        "wires": [
            [
                "bcc5b2b921d0fc27",
                "9e4e37bd6969d111"
            ]
        ]
    },
    {
        "id": "9e4e37bd6969d111",
        "type": "delay",
        "z": "2e8c7f5c.ab73d",
        "name": "",
        "pauseType": "delay",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 300,
        "y": 380,
        "wires": [
            [
                "6c457c17aa17fd5e"
            ]
        ]
    },
    {
        "id": "ec609dc628930ab7",
        "type": "OpcUa-Client",
        "z": "2e8c7f5c.ab73d",
        "endpoint": "bc51f3974cda2b3f",
        "action": "read",
        "deadbandtype": "a",
        "deadbandvalue": 1,
        "time": 10,
        "timeUnit": "s",
        "certificate": "n",
        "localfile": "",
        "localkeyfile": "",
        "securitymode": "None",
        "securitypolicy": "None",
        "folderName4PKI": "",
        "name": "",
        "x": 620,
        "y": 580,
        "wires": [
            [
                "5cca9ccea1e628a5"
            ]
        ]
    },
    {
        "id": "1319777f1c772415",
        "type": "inject",
        "z": "2e8c7f5c.ab73d",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "3",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 230,
        "y": 580,
        "wires": [
            [
                "1caf55a2a40b1c94"
            ]
        ]
    },
    {
        "id": "5cca9ccea1e628a5",
        "type": "debug",
        "z": "2e8c7f5c.ab73d",
        "name": "debug 2",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 820,
        "y": 580,
        "wires": []
    },
    {
        "id": "1caf55a2a40b1c94",
        "type": "OpcUa-Item",
        "z": "2e8c7f5c.ab73d",
        "item": "ns=1;s=Isolated_Input2",
        "datatype": "String",
        "value": "",
        "name": "",
        "x": 420,
        "y": 580,
        "wires": [
            [
                "ec609dc628930ab7"
            ]
        ]
    },
    {
        "id": "bc51f3974cda2b3f",
        "type": "OpcUa-Endpoint",
        "endpoint": "opc.tcp://localhost:54845/UA/NodeRED/Compact",
        "secpol": "None",
        "secmode": "None",
        "none": true,
        "login": false,
        "usercert": false,
        "usercertificate": "",
        "userprivatekey": ""
    }
]

Thanks NR Forum.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.