使用azure iot hub连接到现有OPC

问题描述 投票:0回答:1

我想使用Azure连接到我工作地点的现有OPC。从我所看到的,它需要设置一个天蓝色的iot集线器。我找到了描述如何设置iot集线器的教程,但没有演示如何与现有OPC进行通信。基本上我想从OPC读取数据以运行机器学习工具(用azure ml),然后将该信息发送回OPC。任何指导我正确方向的帮助或想法都会很棒!

azure azure-iot-hub
1个回答
0
投票

有一个名为OPC-UA发布者的项目。

OPC-UA发布者是一个应用程序,充当OPC服务器和IoT Hub之间的桥梁。它可以订阅某些节点(您在配置中选择),并以所需格式将它们发布到IoT Hub。

您可以将其作为控制台应用程序,容器或与IoT Edge组合的容器运行。

如何设置以及如何工作:https://github.com/Azure/iot-edge-opc-publisher

如何在本地构建和运行的示例:

  1. 在终端中导航到下载项目的文件夹
  2. docker build -t your_container_registry / opcpublisher。
  3. 不要忘记最后一个命令中的点
  4. docker run your_container_registry / opcpublisher --dc =“device_connection_string_retrieved_from_iot_hub”--ns = true --ih = Http1 --pf =“C:\\ Users \\ User \\ Desktop \\ OPC \\ publishednodes.json”

ns - 没有关闭,发布者暂时运行

publishednodes.json示例:

[
    {
    // example for an EnpointUrl is: opc.tcp://192.168.178.26:62541/Quickstarts/ReferenceServer
    "EndpointUrl": "opc.tcp://192.168.16.183:4840/freeopcua/server",
    // allows to access the endpoint with SecurityPolicy.None when set to 'false' (no signing and encryption applied to the OPC UA communication), default is true
    "UseSecurity": false,
    "OpcNodes": [
      {
        // identifies the OPC node to publish in either NodeId format (contains "ns=") or ExpandedNodeId format (contains "nsu=")
        "Id": "nsu=http://example.proof.com;i=2",
        // specifies the sampling interval OPC Publisher requests the server to sample the node value
        "OpcSamplingInterval": 500,
        // specifies the publishing interval OPC Publisher requests the server to publish the node value, it will only be published if the value has changed
        "OpcPublishingInterval": 500,
        // specifies that there should be a heartbeat generated by OPC Publisher, this means that after the given interval the last message will be sent again with an updated SourceTimestamp value.
        "HeartbeatInterval": 1000,
        // specifies that the first event will not generate a telemetry event, this is useful when publishing a large amount of data to prevent a event flood at startup of OPC Publisher
        "SkipFirst": true
      },
      {
        // identifies the OPC node to publish in either NodeId format (contains "ns=") or ExpandedNodeId format (contains "nsu=")
        "Id": "nsu=http://example.proof.com;i=3",
        // specifies the sampling interval OPC Publisher requests the server to sample the node value
        "OpcSamplingInterval": 500,
        // specifies the publishing interval OPC Publisher requests the server to publish the node value, it will only be published if the value has changed
        "OpcPublishingInterval": 500,
        // specifies that there should be a heartbeat generated by OPC Publisher, this means that after the given interval the last message will be sent again with an updated SourceTimestamp value.
        "HeartbeatInterval": 1000,
        // specifies that the first event will not generate a telemetry event, this is useful when publishing a large amount of data to prevent a event flood at startup of OPC Publisher
        "SkipFirst": true
      }
    ]
  }
  // the format below (NodeId format) is only supported for backward compatibility. you need to ensure that the
  // OPC UA server on the configured EndpointUrl has the namespaceindex you expect with your configuration.
  // please use the ExpandedNodeId format as in the examples above instead.
  /* {
        "EndpointUrl": "opc.tcp://<your_opcua_server>:<your_opcua_server_port>/<your_opcua_server_path>",
        "NodeId": {
            "Identifier": "ns=0;i=2258"
        }
    } */
  // please consult the OPC UA specification for details on how OPC monitored node sampling interval and OPC subscription publishing interval settings are handled by the OPC UA stack.
  // the publishing interval of the data to Azure IoTHub is controlled by the command line settings (or the default: publish data to IoTHub at least each 1 second).
]
© www.soinside.com 2019 - 2024. All rights reserved.