BiancoRoyal / node-red-contrib-iiot-opcua

deprecated - very new developed by PLUS for Node-RED - https://plus4nodered.com
https://www.npmjs.com/package/node-red-contrib-iiot-opcua
BSD 3-Clause "New" or "Revised" License
34 stars 8 forks source link

Sampling Interval = 0 #102

Closed MileBuurmeijer closed 4 years ago

MileBuurmeijer commented 5 years ago

Problem

Information

Current behavior When subscribing to an OPC UA server with 2 monitored items in a subscription and each with sampling interval set to zero, not every data value the OPC UA server creates is sent to this Node-Red IIOT OPC UA client

Expected behavior When setting sampling interval to zero on a monitored item the expected behavior is that each data value the OPC UA server creates is sent to this Node-Red IIOT OPC UA client

Minimal reproduction of the problem with instructions

  1. Created an OPC UA Server that simulates a sine and a cosine signal with a sampling rate of 5000 samples per second ( a Milo OPC UA server based project)
  2. Checked with UA Expert that it generates that much data per second with the UA Expert datalogger feature
  3. Created in Node-Red the following Node OPCUA Based flow (I hope interval on the inject node means sampling interval and if so it would be ok to rename interval to sampling-interval)
[{"id":"cb7e86be.302b18","type":"tab","label":"IIoT OPC UA Listener","disabled":false,"info":""},{"id":"eaa0d412.4cd698","type":"OPCUA-IIoT-Inject","z":"cb7e86be.302b18","injectType":"listen","payload":"{\"interval\":0,\"queueSize\":1000,\"options\":{\"requestedPublishingInterval\":500,\"requestedLifetimeCount\":60,\"requestedMaxKeepAliveCount\":10,\"maxNotificationsPerPublish\":500,\"publishingEnabled\":true,\"priority\":1}}","payloadType":"json","topic":"","repeat":"","crontab":"","once":true,"startDelay":"10","name":"Start/stop listening","addressSpaceItems":[{"name":"RunState","nodeId":"ns=2;s=Player/Runstate","datatypeName":""},{"name":"Sinus","nodeId":"ns=2;s=1001","datatypeName":""},{"name":"Cosinus","nodeId":"ns=2;s=1002","datatypeName":""}],"x":145,"y":178.99998259544373,"wires":[["e18fdb5d.95c838"]]},{"id":"84368c8d.230c1","type":"debug","z":"cb7e86be.302b18","name":"","active":false,"console":"false","complete":"true","x":564.9999504089355,"y":441.99997901916504,"wires":[]},{"id":"6e014e06.e6c6c","type":"debug","z":"cb7e86be.302b18","name":"","active":false,"console":"false","complete":"true","x":930,"y":180,"wires":[]},{"id":"e18fdb5d.95c838","type":"OPCUA-IIoT-Listener","z":"cb7e86be.302b18","connector":"e3b751d0.4b8dc","action":"subscribe","queueSize":"1000","name":"","topic":"","justValue":true,"useGroupItems":false,"showStatusActivities":false,"showErrors":true,"x":399.99998474121094,"y":309.9999828338623,"wires":[["84368c8d.230c1","3294aab6.004876","7df1ec8.085f614"]]},{"id":"3ece6924.c054c6","type":"debug","z":"cb7e86be.302b18","name":"","active":false,"console":"false","complete":"true","x":930,"y":240,"wires":[]},{"id":"3294aab6.004876","type":"OPCUA-IIoT-Result-Filter","z":"cb7e86be.302b18","nodeId":"ns=2;s=1002","datatype":"Double","fixedValue":false,"fixPoint":2,"withPrecision":true,"precision":"3","entry":1,"justValue":true,"withValueCheck":false,"minvalue":"","maxvalue":"","defaultvalue":"","topic":"","name":"","showErrors":false,"x":625.9999504089355,"y":204.99998474121094,"wires":[["3ece6924.c054c6","4f97666.5e7b398"]]},{"id":"7df1ec8.085f614","type":"OPCUA-IIoT-Result-Filter","z":"cb7e86be.302b18","nodeId":"ns=2;s=1001","datatype":"Double","fixedValue":false,"fixPoint":2,"withPrecision":true,"precision":"3","entry":1,"justValue":true,"withValueCheck":false,"minvalue":"","maxvalue":"","defaultvalue":"","topic":"","name":"","showErrors":true,"x":619.9999504089355,"y":146.99998664855957,"wires":[["6e014e06.e6c6c","ee2262ae.0e85f"]]},{"id":"ee2262ae.0e85f","type":"counter","z":"cb7e86be.302b18","name":"SinusEventCounter","init":"0","step":"1","lower":null,"upper":null,"mode":"increment","outputs":2,"x":796.6902618408203,"y":359.105055809021,"wires":[["fec393e9.f9f05"],[]]},{"id":"4f97666.5e7b398","type":"counter","z":"cb7e86be.302b18","name":"CosinusEventCounter","init":"0","step":"1","lower":"","upper":"","mode":"increment","outputs":2,"x":806.690315246582,"y":405.1036446094513,"wires":[["e4ebd23f.53b4b"],[]]},{"id":"e4ebd23f.53b4b","type":"debug","z":"cb7e86be.302b18","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1016.688835144043,"y":448.8508014678955,"wires":[]},{"id":"fec393e9.f9f05","type":"debug","z":"cb7e86be.302b18","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1016.688835144043,"y":391.8494167327881,"wires":[]},{"id":"e3b751d0.4b8dc","type":"OPCUA-IIoT-Connector","z":"","discoveryUrl":"","endpoint":"opc.tcp://localhost:12000/OPCUA-Player","keepSessionAlive":true,"loginEnabled":true,"securityPolicy":"None","securityMode":"NONE","name":"OPC UA Player","showErrors":true,"publicCertificateFile":"","privateKeyFile":"","defaultSecureTokenLifetime":"60000","endpointMustExist":true,"autoSelectRightEndpoint":false,"strategyMaxRetry":"10","strategyInitialDelay":"","strategyMaxDelay":""}]

Your Environment

Please tell us about your environment:

MileBuurmeijer commented 5 years ago

Finally I had the time to do testing of the underlying node-opcua node-module. I edited the sample-client.ts in the node-opcua-samples package so that it sets the sampling interval of the monitored item to zero. When I ran this sample-client.ts is published far more values than with the original sampling interval of 1000 in the sample client. I have no means to check if the used OPC UA server (opc.tcp://milo.digitalpetri.com:62541/milo) has sent all the samples that occurred, but for now, I think I can conclude the node-opcua package does support setting sampling interval to zero and that node-red-contrib-iiot-opcua should be able to support setting sampling interval to zero. If only I was more fluent in javascript I could check where in the source code it checks for non-zero values of the sampling interval. Could someone point me in the right direction? If so I would like to try to change it myself and do some more testing.

Ok I think I found it in the "core/opcua-iiot-core-listener.js" on row 224 and on row 277. If the part options.interval >= coreListener.MIN_LISTENER_INTERVAL is replaced by (options.interval >= coreListener.MIN_LISTENER_INTERVAL || options.interval == 0) it should work. I can not test is myself, but love to see this fixed and use this great IIOT-OPCUA package.

MileBuurmeijer commented 5 years ago

Did some more testing and found out that node-js itself is very fast. I could receive up to 7000 samples per second from my OPC UA server. The server was derived from the Eclipse Milo project (see github OPCUA-Player. Any ideas if node-red would be capable of processing up to 7000 s/s?

biancode commented 4 years ago

Minimum is set to 0 now -- you can test it if it works for you and if node-opcua will accept it