OPC-UA Server Compact

I'm trying to configure the node block OPC-UA Server Compact, I tried to follow one of the examples but I can't get the value of the inductive sensor in Ua Expert that I can even access the variable defined in the code but not get the value of sensor reading, I send my code, because I don't understand where I'm going wrong.

[{"id":"dc39bd3b.8134d","type":"opcua-compact-server","z":"465b9fc2.ac332","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":"3","discoveryServerEndpointUrl":"opc.tcp://10.6.3.244:4840","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 namespace = addressSpace.getOwnNamespace();\n const Variant = opcua.Variant;\n const DataType = opcua.DataType;\n const DataValue = opcua.DataValue;\n\n var ServerSensors = this;\n\n this.sandboxNodeContext.set(\"isoInput1\", 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\": \"CompactRIO\"\n });\n const sensorFolder = namespace.addFolder(myDevice, { \"browseName\": \"Sensors\" });\n const Inputs = namespace.addFolder(sensorFolder, {\n \"browseName\": \"Inputs\"\n });\n \n const sensor1 = namespace.addVariable({\n \"organizedBy\": Inputs,\n \"browseName\": \"Indutive\",\n \"nodeId\": \"ns=1;s=Indutive\",\n \"dataType\": \"Float\",\n \"value\": {\n \"get\": function() {\n return new Variant({\n \"dataType\": DataType.Float,\n \"value\": ServerSensors.sandboxNodeContext.get(\"ns=1;s=Indutive\")\n });\n },\n \"set\": function(variant) {\n ServerSensors.sandboxNodeContext.set(\n \"ns=1;s=Indutive\",\n parseFloat(variant.value)\n );\n return opcua.StatusCodes.Good;\n }\n }\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":960,"y":140,"wires":[]}]

1 Like

Hey, I have the same problem, did you find a solution?

Regards