Closed biancode closed 6 years ago
Please, test first with the whole new example flows
You'll find them under Node-RED > menu > Import > Examples > iiot opcua > ...
best practice for v2.2.x
You have to wire some nodes with a fresh drag&drop into the flow somtimes.
Klaus,
I'm having an issue with the listener node with the latest update. The addressSpaceItems name & datatypeName are not coming through. If you deselect send just values in the listener no message comes through at all. As you said above I have uninstalled the package, reinstalled and replaced the node. I also notice now that there is only a single output on the listener, is this as expected?
{"payload":{"value":{"dataType":"Double","arrayType":"Scalar","value":0.0852},"statusCode":{"value":0,"description":"No Error","name":"Good"},"sourceTimestamp":"2018-03-14T08:32:43.554Z","sourcePicoseconds":0,"serverTimestamp":"2018-03-14T13:06:38.055Z","serverPicoseconds":0},"addressSpaceItems":[{"name":"","nodeId":"ns=8;i=1244","datatypeName":""}],"nodetype":"listen","injectType":"subscribe","_msgid":"ea2d71aa.1e2bc"}
Another point to add is that when setting the publishing interval in the inject { "interval": 500, "queueSize": 10 }
it doesn't actually set the publishing interval on the server and stays at the default 100ms value.
If I put a function between the inject and listener with the below code (as per your documentation) it will set the publishing interval correctly.
msg.payload.options = { requestedPublishingInterval: 1000, requestedLifetimeCount: 60, requestedMaxKeepAliveCount: 10, maxNotificationsPerPublish: 4, publishingEnabled: true, priority: 1 } return msg;
@gar-syn a) I'll check the coming through of addressSpaceItems properties.
b) Yes, the listener has only one output since v2.2.x.
c) The interval in payload is and was the sample interval to monitor option - payload.options is new since v2.2.x
Thank you for your report! Klaus
@biancode
Just to let you know it's still the same in 2.3.2, the addressSpaceItems name & datatypeName are not coming through. I think that's more down to the below :-
addressSpaceItems: [{name: '', nodeId: monitoredItem.itemToMonitor.nodeId.toString(), datatypeName: ''}]
@gar-syn could you post your exmple flow, please?
@biancode See below (full flow):-
[{"id":"fcbb9e06.fe25f","type":"OPCUA-IIoT-Inject","z":"d23b7c33.7cccd","injectType":"listen","payload":"5000","payloadType":"num","topic":"Equipment_1","repeat":"","crontab":"","once":true,"startDelay":"2","name":"OPC Inject","addressSpaceItems":[{"name":"Pipe1001FTX001","nodeId":"ns=8;i=1244","datatypeName":""},{"name":"Pipe1001ValveX001","nodeId":"ns=8;i=1251","datatypeName":""},{"name":"Drum1001LIX001","nodeId":"ns=8;i=1258","datatypeName":""},{"name":"Pipe1002FTX002","nodeId":"ns=8;i=1267","datatypeName":""},{"name":"FC1001ControlOut","nodeId":"ns=8;i=1276","datatypeName":""},{"name":"FC1001Measurement","nodeId":"ns=8;i=1274","datatypeName":""},{"name":"FC1001SetPoint","nodeId":"ns=8;i=1275","datatypeName":""},{"name":"LC1001ControlOut","nodeId":"ns=8;i=1277","datatypeName":""},{"name":"LC1001Measurement","nodeId":"ns=8;i=1278","datatypeName":""},{"name":"LC1001SetPoint","nodeId":"ns=8;i=1279","datatypeName":""},{"name":"CC1001ControlOut","nodeId":"ns=8;i=1285","datatypeName":""},{"name":"CC1001Description","nodeId":"ns=8;i=1286","datatypeName":""},{"name":"CC1001Input1","nodeId":"ns=8;i=1282","datatypeName":""},{"name":"CC1001Input2","nodeId":"ns=8;i=1283","datatypeName":""},{"name":"CC1001Input3","nodeId":"ns=8;i=1284","datatypeName":""},{"name":"SimulationStart","nodeId":"ns=8;i=1343","datatypeName":""},{"name":"SimulationReset","nodeId":"ns=8;i=1347","datatypeName":""},{"name":"SimulationSuspend","nodeId":"ns=8;i=1344","datatypeName":""},{"name":"SimulationResume","nodeId":"ns=8;i=1345","datatypeName":""}],"x":110,"y":100,"wires":[["5728f88c.3028c8"]]},{"id":"c2364923.9129a8","type":"template","z":"d23b7c33.7cccd","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"INSERT INTO public.datalog (timestamp, tagname, tagvalue, tagquality) VALUES ($param1, $param2, $param3, $param4)","output":"str","x":390,"y":180,"wires":[["61cd841e.a6aa7c"]]},{"id":"1acb1c2e.edd174","type":"function","z":"d23b7c33.7cccd","name":"Func","func":"try {\n msg.queryParameters = msg.queryParameters || {};\n msg.queryParameters.param1 = msg.payload.serverTimestamp;\n msg.queryParameters.param2 = msg.addressSpaceItems[0].nodeId;\n msg.queryParameters.param3 = msg.payload.value.value;\n msg.queryParameters.param4 = msg.payload.statusCode.name;\n return msg;\n} catch (e) {}","outputs":1,"noerr":0,"x":310,"y":100,"wires":[["c2364923.9129a8"]]},{"id":"7312c53c.3c7fbc","type":"PG Listen","z":"d23b7c33.7cccd","postgreslisten":"1a0cb776.8258a9","name":"","channel":"addedrecord","x":140,"y":340,"wires":[["715237d4.7ef9f8"]]},{"id":"4567585c.a829b8","type":"comment","z":"d23b7c33.7cccd","name":"Read Data from OPC and store in DB","info":"","x":190,"y":40,"wires":[]},{"id":"5c1fbcdd.401284","type":"OPCUA-IIoT-Write","z":"d23b7c33.7cccd","connector":"bb9f0900.487ca8","name":"","justValue":false,"showStatusActivities":false,"showErrors":true,"x":310,"y":340,"wires":[["b9ffa323.d5b26"]]},{"id":"b9ffa323.d5b26","type":"OPCUA-IIoT-Response","z":"d23b7c33.7cccd","name":"","x":400,"y":420,"wires":[["4fab63a8.5ec08c"]]},{"id":"715237d4.7ef9f8","type":"function","z":"d23b7c33.7cccd","name":"","func":"if (msg.payload.complete === false) {\n \n global.set(\"equipmentCommandId\",msg.payload.id);\n \n var tagName = msg.payload.data.tagName;\n var tagAddress = msg.payload.data.tagAddress;\n var dateType = msg.payload.data.dateType;\n var value = msg.payload.data.value;\n\n msg.topic = \"\";\n msg.nodetype = \"write\";\n msg.injectType = \"write\";\n msg.addressSpaceItems = [];\n\n var object = {name:tagName, nodeId:tagAddress, datatypeName:dateType};\n \n msg.addressSpaceItems[0] = object;\n \n msg.valuesToWrite = [];\n \n msg.valuesToWrite[0] = value;\n \n return msg;\n}\n\n","outputs":1,"noerr":0,"x":230,"y":420,"wires":[["5c1fbcdd.401284"]]},{"id":"684e8088.dfde6","type":"comment","z":"d23b7c33.7cccd","name":"Read changes from DB and write to OPC","info":"","x":200,"y":280,"wires":[]},{"id":"4fab63a8.5ec08c","type":"function","z":"d23b7c33.7cccd","name":"","func":"var writeStatus = msg.payload.statusCodes[0].value;\n\nif (writeStatus === 0) {\n msg.queryParameters = msg.queryParameters || {};\n msg.queryParameters.param1 = global.get(\"equipmentCommandId\");\n return msg;\n}","outputs":1,"noerr":0,"x":490,"y":340,"wires":[["946eb9ef.fc66a8"]]},{"id":"946eb9ef.fc66a8","type":"template","z":"d23b7c33.7cccd","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"UPDATE public.equipment_commands SET complete = true WHERE id = $param1;","output":"str","x":570,"y":420,"wires":[["2ca5481.8c097b8"]]},{"id":"2ca5481.8c097b8","type":"link out","z":"d23b7c33.7cccd","name":"","links":["56fc3294.07e47c","6dea9de1.6fce04"],"x":615,"y":340,"wires":[]},{"id":"61cd841e.a6aa7c","type":"link out","z":"d23b7c33.7cccd","name":"","links":["56fc3294.07e47c","6dea9de1.6fce04"],"x":435,"y":100,"wires":[]},{"id":"c10d1ebd.38a3","type":"postgres","z":"d23b7c33.7cccd","postgresdb":"890b91cc.bc5c6","name":"PostDB","output":true,"outputs":1,"x":220,"y":580,"wires":[[]]},{"id":"6dea9de1.6fce04","type":"link in","z":"d23b7c33.7cccd","name":"DB Command","links":["2ca5481.8c097b8","61cd841e.a6aa7c"],"x":95,"y":580,"wires":[["c10d1ebd.38a3"]]},{"id":"ef2f943.db98568","type":"comment","z":"d23b7c33.7cccd","name":"Database Commands","info":"","x":140,"y":520,"wires":[]},{"id":"5728f88c.3028c8","type":"OPCUA-IIoT-Listener","z":"d23b7c33.7cccd","connector":"bb9f0900.487ca8","action":"subscribe","queueSize":"10000","name":"","justValue":true,"showStatusActivities":false,"showErrors":false,"x":220,"y":180,"wires":[["1acb1c2e.edd174"]]},{"id":"1a0cb776.8258a9","type":"postgreslisten","z":"","connectionstring":"","hostname":"localhost","port":"5432","db":"logging","ssl":false},{"id":"bb9f0900.487ca8","type":"OPCUA-IIoT-Connector","z":"","discoveryUrl":"","endpoint":"opc.tcp://localhost:51510/UA/DemoServer","keepSessionAlive":true,"loginEnabled":false,"securityPolicy":"None","securityMode":"NONE","name":"Equipment_1","showErrors":false,"publicCertificateFile":"","privateKeyFile":"","defaultSecureTokenLifetime":"60000","endpointMustExist":false,"autoSelectRightEndpoint":false},{"id":"890b91cc.bc5c6","type":"postgresdb","z":"","hostname":"localhost","port":"5432","db":"logging","ssl":false}]
@gar-syn it needs more work to fill the event data with that given data from addressSpaceItems input, because of the event driven behaviour it is not the same as the output addressSpaceItems array. That addressSpaceItems built from monitoredItem information and is to trigger read or browse on listener event.
@biancode Not quite sure I understand your response. Are you saying that more work is required in implementing that functional within the node? Or am I doing something wrong?
@gar-syn more work for implementation
Dear users,
I'm sorry to do that breaking change with v2.2.x for all node outputs, but with that we are now closer to the changes of the node-opcua API and node-opcua outputs.
Please, enter your questions and problems here! Thank you! Klaus