OPC UA driver

更新时间:
复制 MD 格式

Link IoT Edge provides an OPC UA driver to connect to OPC UA devices. You can deploy the driver to a gateway directly from the console or download the driver code from the console and modify it to create a custom driver.

The OPC UA driver runs only on Link IoT Edge Pro Edition (LE Pro).

Overview

The OPC UA driver connects to OPC UA devices through an OPC UA server. The driver uses the protocol interfaces exposed by the server to operate the devices. The following figure illustrates this process.OPCUA架构

This topic provides an example of how to use the official OPC UA driver.

Prerequisites

Before you use the official OPC UA driver, create an edge instance and ensure that the gateway is online. For more information, see Set up the environment.

Step 1: Assign the driver

  1. In the left-side navigation pane, click Edge Instances. On the Edge Instances page, find the edge instance that you want to use and click View in the Actions column.
  2. On the Instance Details page, click the Devices & Drivers tab and click the + icon next to All Drivers.
  3. In the Assign Driver dialog box, select Official Driver. Find the OPC UA driver and click Assign in the Actions column. Then, click Finish.分配OPC UA驱动到边缘实例

Step 2: Configure the driver

  1. Click the assigned OPC UA driver. To the right of the Device List, click Driver Configuration.
  2. On the page that appears, click Add Channel.添加通道
  3. Set the parameters as prompted and click OK.
    ParameterDescription
    Channel NameMust be unique for the gateway. The name can contain Chinese characters, letters, digits, and underscores (_). It must be 1 to 30 characters in length. A Chinese character is counted as two characters.
    Channel AddressExample: opc.tcp://localhost:4840.
    Security PolicyThe encryption algorithm policy. Options are None, Basic128Rsa15, and Basic256.
    Security ModeThe signature type. Options are None, Sign, and SignAndEncrypt.
    UsernameOptional.
    PasswordOptional.
    Method Invocation TimeoutThe unit is seconds.
  4. Optional. On the right side of Devices, click Container Configurations. On the Container Configurations page, configure the container for the driver based on the parameters that are described in the following table. Click Save.
    Note You can configure the container only when the Instance Type parameter of the edge instance is set to Pro Edition.
    ParameterDescription
    Use Host NetworkSpecifies whether to isolate the container's network and use the host network environment directly.
    • Yes: The container's network is not isolated. The host network is used directly.
    • No: The container's network is isolated. You must configure Port Mapping.
    Port MappingThis parameter appears when Use Host Network is set to No. The network environment of the function is completely isolated from the host environment. Through port mapping, you can map the listening port of the function in the container to a port on the host. This allows client programs on different hosts to access the service provided by the function. You can map up to 10 network ports.

    For example, the fc-http-server function runs in a container on the host and provides services on port 80. In this case, client programs on other hosts cannot access the fc-http-server function by accessing port 80 of the host. Therefore, you need to map the container port of the fc-http-server function to a port on the host. For example, map port 80 in the container to port 8080 on the host. This allows client programs on other hosts to access the fc-http-server function in the container by accessing Host IP address:8080.

    Enable Privileged Mode

    The root user in a container is actually a regular user on the host. To perform operations that require root permissions inside the container, such as modifying the system time or using the mount command, you must grant the container privileged mode.

    Note In privileged mode, the container has root permissions on the host. All host devices are mapped to the container by default. You do not need to configure Device Mapping.
    Device MappingThis parameter appears when Enable Privileged Mode is set to No. The device management system is completely isolated from the host environment. When a function needs to access a host device, such as a serial port, you must map the device to the container where the function runs. You can add up to 10 device mappings.
    Volume MappingThe file system is completely isolated from the host environment. When a function needs to access a host file, you must map the file to the container where the function runs. You can add up to 10 volume mappings.
    Memory LimitSet the maximum memory for the container.
    • If the container's memory usage exceeds the limit, the container is restarted.
    • If the memory limit is too small, the application in the container may fail to run.

    The default memory is 1024 MB. Increase the memory limit based on the size of the application in the container.

Step 3: Associate the driver with sub-devices

  1. In the Device List section, click Assign Sub-devices to assign a sub-device to the edge instance.
    You can assign an existing OPC UA device or create a new one.
    Note If you assign an existing OPC UA device, the product to which the device belongs must be connected to the gateway, and its gateway protocol must be set to OPC UA. For more information, see Create a product.
  2. In the Assign Sub-device panel, click Add Sub-device.
    Add Sub-device button
  3. In the Add Device dialog box, click Create Product to create a product for the OPC UA device.新建OPC UA产品
  4. In the Create Product dialog box, set the parameters and click Finish.
    OPC UA产品参数设置
    Table 1. Parameter description
    ParameterDescription
    Product NameSet a product name. The product name must be unique within your account. The name can be 4 to 30 characters in length and can contain Chinese characters, letters, digits, underscores (_), hyphens (-), at signs (@), and parentheses (()). A Chinese character is counted as two characters.
    CategorySelect a category to define a Thing Specification Language model for the product. Here, select Custom Category.
    Gateway ProtocolYou must select OPC UA.
    Authentication MethodSelect an authentication method that is suitable for your device. For more information, see Device security authentication.
  5. Return to the Add Device dialog box and add the OPC UA device.添加OPCUA设备_专有云
  6. On the Assign Sub-devices panel, assign the new OPC UA device to the edge instance.
  7. After the device is assigned to the edge instance, click Device Configuration in the Actions column. Then, associate the device with the OPC UA driver by selecting a channel.
    设备配置
    Table 2. Parameter description
    ParameterDescription
    Associated ChannelSelect the channel that you added in Step 3 of Step 2: Configure the driver.
    Node PathThe absolute path of the device in the OPC UA Server, starting from Objects to the device node.
    Note For more information about the OPC UA Server, see OPC UA device connection practice.

Step 4: Deploy the edge instance

On the Instance Details page, click Deploy in the upper-right corner to redeploy the instance.