OPCUA Usage
This chapter fully demonstrates the demo of collecting information from the OPCUA signal source through the OPCUA module. This demo uses PC as the edge node, and the OPCUA signal source uses the simulation server. The simulation server and node are located on the same PC.
I. Prerequisites
- The edge node has been connected to the Baidu AI Cloud per the Getting Started tutorial.
- OPCUA signal source. This demo uses the Prosys OPC UA Simulation Server to simulate the signal.
II. Settings of Prosys OPC UA Simulation Server
- Ensure that the simulation server is in the running status.
- Create the variable var3. The variable information will be used in the configuration item file of the node application.
III. Edge Application Configuration
OPCUA configuration
1. Create the OPCUA node
Create Node
2. Create the opcua-conf-test configuration item
- Variable name: conf.yml
- Variable value:
devices:
- id: 1 #设evice id
endpoint: 'opc.tcp://host.docker.internal:53530/OPCUA/SimulationServer' #Device endpoint
jobs:
- deviceid: 1 #Corresponding device for reading task
properties:
- name: var3 #variable name
type: int16 # Data type
nodeid: ns=3;i=1015 #The nodeid of the read data
publish:
topic: test #Read the mqtt topic sent by the data
logger:
filename: var/log/baetyl/service.log #Log path
level: info #Log level
Parameter file description:
- endpoint:
opc.tcp://<ip>:53530/OPCUA/SimulationServer
If the node and the simulation signal source are located on the same PC, you can also use the following address:
opc.tcp://host.docker.internal:53530/OPCUA/SimulationServer。
- If the signal source is set with the security authentication, add the following parameters:
id: 1 # Device id
endpoint: opc.tcp://test.local:53530/OPCUA/Server # Device endpoint
security:
policy: None # Optional None, Basic128Rsa15, Basic256, Basic256Sha256, Aes128Sha256RsaOaep, Aes256Sha256RsaPss
mode: None # Optional Invalid, None, Sign, SignAndEncrypt
auth:
username: test # username
password: test # password
3. Create the OPCUA application
Create the container application opcua-test, and add the container service opcua-test.
- Name: opcua-test
- Image address: baetyltechtest/opcua: git-71260d2
- Add the configuration item file created in the previous step. Container directory: etc/baetyl/
- Deploy the application to the edge node created in the previous step.
IV. Verify Collected Information
When the simulation server displays the following connection log, it indicates that the node has received the signal from the simulation server as a client.
Subscribe to the edge node broker service through the MQTT Box. The subscription topic is a test. When the following information is received, it indicates that the deployment is successful. For the connection mode of a broker, refer to the Connection Edge Node baetyl-broker Documentations in the application case.