opc-uaopcazure-iot-edgeazure-industrial-iot

OPC Publisher doesn't send data in order as in generated by OPC simulation server


I have been trying to retrieve sensor data generated by OPC simulation server (data listed in excel file and read by OPC simulation) in to one of the custom modules in Azure IOT Edge. When the data logged in the console it shows me that data has not been logged in order. Following is the JSON for OPC publisher hosted in iot edge as a module.

        "OPCPublisher": {
        "version": "1.0",
        "type": "docker",
        "status": "running",
        "restartPolicy": "always",
        "settings": {
          "image": "mcr.microsoft.com/iotedge/opc-publisher:2.8",
          "createOptions": {
            "Hostname": "publisher",
            "Cmd": [
              "publisher",
              "--pf=/appdata/publishednodes.json",
              "--lf=/appdata/publisher.log",
              "--aa"
            ],
            "HostConfig": {
              "Binds": [
                "/home/sineth/iiotedge:/appdata"
              ]
            }
          }
        }
      }

Following is the published nodes json in gateway device. enter image description here Following is the screenshot of my excel sheet data enter image description here

But the OPC publisher will not route the data in to modules in order that starting from anywhere but in order . For an example it sends starting from the row ,value 11 for Tag11 and then again sends the next row which has the value 17 for tag 11. And sometimes sends a batch of data. no proper order. This is not a issue with OPC server simulation since i have tested Simulation server with a standalone OPC client and it gets the data in order. Excel is read by simulation server. Following image is a screenshot of my IoT edge module(python) where i log the data to console retrieving from OPC Publisher routing. enter image description here Appreciate any help on this. Thanks a lot.


Solution

  • Adding summary from GitHub Issues discussions here:

    Without the duplicates all value changes are in order but the behavior is still not what the OP needs.

    More than one message (containing value changes for all three tags) is batched

    OPC Publisher try to optimize for cost and performance, sending each message at a time is neither of them, but it is possible to configure OPC Publisher in a way to send data directly by setting the batch size to one.

    command line argument --bs=1

    Not starting by the first value

    OPC Publisher establish a connection to OPC UA server and creates monitored items, for every OPC UA nodes in it's config file. As default the OPC UA monitored item, will send a default notification with the current value. If you want to ignore it, you could use skip first.

    command line argument --sk=true

    But in the case described above also the first value is relevant. If the first message (message id = 1) don't contain the first value, then the OPC server simulation changed them before.

    Please be aware that the OPC Publisher can only publish once the OPC UA client/server connection is fully established (including trusting of certificates), the subscriptions and the monitored items are created. This time is also depending on the performance of OPC UA server and network.

    Proposals:

    Retrieve the same message multiple times

    If the messages are received multiple times it could be an error with the routing from the messages from one IoT edge module to another. Please make sure to explicitly name the sending module (in this case the OPC Publisher)

    "$edgeHub": {
          "properties.desired": {
            "schemaVersion": "1.2",
            "routes": {
              "opcPublisherToPyDataConsumer": "FROM /messages/modules/opc-publisher INTO BrokeredEndpoint(\"/modules/PyDataConsumer/inputs/fromOPC\")"
            }
          }
        }