1

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.

4

2 回答 2

2

所以有些问题:

  1. 您使用的是哪个版本的 iotedge?
  2. 只是日志不按顺序排列还是消息接收顺序不正确?
  3. 您使用 MQTT 或 AMQP 什么协议?
于 2021-08-02T23:35:19.343 回答
2

在此处添加来自 GitHub 问题讨论的摘要:

  • OPC Publisher 为每个 OPC UA 端点生成一个唯一的消息 id(自动加一)
  • 上面的 python 客户端代码记录相同的消息超过 3500 次
    • 接收消息似乎没有阻塞,因此一遍又一遍地处理相同的消息
    • receive_on_message_input已弃用且不应再使用,请参阅API 文档

如果没有重复项,所有值更改都是有序的,但行为仍然不是 OP 需要的。

对多条消息(包含所有三个标签的值更改)进行批处理

OPC Publisher 尝试优化成本和性能,一次发送每条消息都不是,但可以通过将批量大小设置为 1 来配置 OPC Publisher 以直接发送数据的方式。

命令行参数--bs=1

不是从第一个值开始

OPC Publisher 建立与 OPC UA 服务器的连接并为其配置文件中的每个 OPC UA 节点创建监控项。默认情况下,OPC UA 监控项将发送带有当前值的默认通知。如果你想忽略它,你可以先使用跳过。

命令行参数--sk=true

但在上述情况下,第一个值也是相关的。如果第一条消息(消息 id = 1)不包含第一个值,则 OPC 服务器模拟之前更改了它们。

请注意,只有在完全建立 OPC UA 客户端/服务器连接(包括信任证书)、创建订阅和监控项后,OPC 发布者才能发布。这个时间也取决于 OPC UA 服务器和网络的性能。

建议:

  • 将 OPC 模拟更改为仅在客户端连接完全建立后才开始模拟序列

多次检索相同的消息

如果消息被多次接收,则可能是从一个 IoT 边缘模块到另一个 IoT 边缘模块的消息路由出现错误。请确保明确命名发送模块(在本例中为 OPC Publisher)

"$edgeHub": {
      "properties.desired": {
        "schemaVersion": "1.2",
        "routes": {
          "opcPublisherToPyDataConsumer": "FROM /messages/modules/opc-publisher INTO BrokeredEndpoint(\"/modules/PyDataConsumer/inputs/fromOPC\")"
        }
      }
    }
于 2021-08-14T13:00:48.383 回答