4.0.9
我尝试通过 OPC UA 节点发送 HTTP 请求,但它根本不起作用。字符串节点永远不会更新。
OPCUA-IIoT-Flex-Server 节点(请将 AddressSpaceScript 附加到下一节)
导出.json:
{
"id": "e92d7a441a9d8f99",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "d82207d63fdea7e6",
"type": "inject",
"z": "e92d7a441a9d8f99",
"name": "CicloRepetición",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "5",
"crontab": "",
"once": true,
"onceDelay": "0.5",
"topic": "",
"payload": "",
"payloadType": "date",
"x": 150,
"y": 180,
"wires": [
[
"873a84fa008fe370"
]
]
},
{
"id": "9e551e92d50d566d",
"type": "OPCUA-IIoT-Flex-Server",
"z": "e92d7a441a9d8f99",
"port": "55480",
"endpoint": "",
"acceptExternalCommands": true,
"maxAllowedSessionNumber": "",
"maxConnectionsPerEndpoint": "",
"maxAllowedSubscriptionNumber": "",
"alternateHostname": "",
"name": "Servidor OPC UA",
"showStatusActivities": true,
"showErrors": true,
"allowAnonymous": true,
"individualCerts": false,
"isAuditing": false,
"serverDiscovery": true,
"users": [],
"xmlsets": [],
"publicCertificateFile": "",
"privateCertificateFile": "",
"registerServerMethod": "1",
"discoveryServerEndpointUrl": "",
"capabilitiesForMDNS": "",
"maxNodesPerRead": 1000,
"maxNodesPerBrowse": 2000,
"delayToClose": 1000,
"addressSpaceScript": "/**\n* @param {any} server\n* @param {{ getOwnNamespace: () => any; findNode: (arg0: string) => any; }} addressSpace\n* @param {any} eventObjects\n* @param {() => void} done\n*/\nfunction 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 // node.log(JSON.stringify(eventObjects));\n // node.log(JSON.stringify(server));\n \n var $this = this;\n\n this.sandboxFlowContext.set(\"ApiFact\", \"\");\n\n node.log($this.sandboxFlowContext.get(\"ApiFact\"));\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\": \"FotovoltaicasDallas\"\n });\n\n const apiFact = namespace.addVariable({\n \"organizedBy\": myDevice,\n \"browseName\": \"ApiFact\",\n \"nodeId\": \"ns=1;s=ApiFact\",\n \"dataType\": \"String\",\n \"value\": {\n \"get\": function() {\n return new Variant({\n \"dataType\": DataType.String,\n \"value\": $this.sandboxFlowContext.get(\"ApiFact\")\n });\n }\n /*,\n \"set\": function(variant) {\n flexServerInternals.sandboxFlowContext.set(\n \"apiFact\",\n parseFloat(variant.value) // TODO\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\": \"FotovoltaicasDallas-View\"\n });\n \n viewDI.addReference({\n \"referenceType\": \"Organizes\",\n \"nodeId\": apiFact.nodeId\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": 690,
"y": 200,
"wires": [
[]
]
},
{
"id": "1c27f9ba47285ad5",
"type": "function",
"z": "e92d7a441a9d8f99",
"name": "Asignar Flow",
"func": "// El input de este nodo se lee por \"msg.payload\"\n// Aquí se recibirá el objeto que la api devuelva por su output.\n\n// node.log(JSON.stringify(msg.payload, null, 2));\n\nflow.set('ApiFact', msg.payload.fact);\nflow.set('ApiLength', msg.payload.length);\n\nmsg.test = {\n ApiFact: msg.payload.fact\n}\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 410,
"y": 200,
"wires": [
[]
]
},
{
"id": "873a84fa008fe370",
"type": "http request",
"z": "e92d7a441a9d8f99",
"name": "FotovoltaicaDallas API Request",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "https://catfact.ninja/fact",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 370,
"y": 80,
"wires": [
[
"eb69022b3c8d6327",
"1c27f9ba47285ad5"
]
]
},
{
"id": "eb69022b3c8d6327",
"type": "debug",
"z": "e92d7a441a9d8f99",
"name": "debug 1",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 620,
"y": 80,
"wires": []
},
{
"id": "4383d0f36f9b9625",
"type": "opcua-compact-server",
"z": "e92d7a441a9d8f99",
"d": true,
"port": 54846,
"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\": \"Double\",\n \"value\": {\n \"get\": function() {\n return new Variant({\n \"dataType\": DataType.Double,\n \"value\": flexServerInternals.sandboxFlowContext.get(\"isoInput2\")\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 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": 680,
"y": 280,
"wires": []
}
]
地址空间:
/**
* @param {any} server
* @param {{ getOwnNamespace: () => any; findNode: (arg0: string) => any; }} addressSpace
* @param {any} eventObjects
* @param {() => void} done
*/
function constructAlarmAddressSpace(server, addressSpace, eventObjects, done) {
// server = the created node-opcua server
// addressSpace = script placeholder
// eventObjects = to hold event variables in memory from this script
// internal global sandbox objects are
// node = node of the flex server,
// coreServer = core iiot server object for debug and access to nodeOPCUA,
// and scriptObjects to hold variables and functions
const LocalizedText = opcua.LocalizedText;
const namespace = addressSpace.getOwnNamespace();
coreServer.internalDebugLog('init dynamic address space')
node.warn('construct new address space for OPC UA')
const Variant = opcua.Variant;
const DataType = opcua.DataType;
const DataValue = opcua.DataValue;
// node.log(JSON.stringify(eventObjects));
// node.log(JSON.stringify(server));
var $this = this;
this.sandboxFlowContext.set("ApiFact", "");
node.log($this.sandboxFlowContext.get("ApiFact"));
coreServer.internalDebugLog("init dynamic address space");
const rootFolder = addressSpace.findNode("RootFolder");
node.warn("construct new address space for OPC UA");
const myDevice = namespace.addFolder(rootFolder.objects, {
"browseName": "FotovoltaicasDallas"
});
const apiFact = namespace.addVariable({
"organizedBy": myDevice,
"browseName": "ApiFact",
"nodeId": "ns=1;s=ApiFact",
"dataType": "String",
"value": {
"get": function() {
return new Variant({
"dataType": DataType.String,
"value": $this.sandboxFlowContext.get("ApiFact")
});
}
/*,
"set": function(variant) {
flexServerInternals.sandboxFlowContext.set(
"apiFact",
parseFloat(variant.value) // TODO
);
return opcua.StatusCodes.Good;
}
*/
}
});
//------------------------------------------------------------------------------
// Add a view
//------------------------------------------------------------------------------
const viewDI = namespace.addView({
"organizedBy": rootFolder.views,
"browseName": "FotovoltaicasDallas-View"
});
viewDI.addReference({
"referenceType": "Organizes",
"nodeId": apiFact.nodeId
});
coreServer.internalDebugLog("create dynamic address space done");
node.warn("construction of new address space for OPC UA done");
done();
}
它应该更新 OPC UA 节点。
你有处理过这个问题吗?