“Bearbeitungszentrum BAZ” - Agent Mode¶
This example shows an entire BAZ setup expressed within a single commissioning file, using explicit topics and involving an agent for providing the connection and endpoint resources.
The name of the agent must be specified in the agentName parameter, for example connectware-agent or whatever other name has been given to the agent instance.
Download: bazAgentMode.yml
Note
The example below uses an additional Docker image provided by Cybus that requires a suitable license. You can check the current capabilities and permissions of your Connectware license in the Cybus Portal (https://portal.cybus.io). If your license is not eligible to use the example Docker image, please contact Cybus Sales (sales@cybus.io).
1description: >
2 Entire simulated machining involving a protocol-mapper agent
3
4metadata:
5
6 name: Simulated Machining Center
7 icon: https://www.cybus.io/wp-content/themes/cybus/img/product-slide-img.png
8 provider: cybus
9 homepage: https://www.cybus.io
10 version: 2.0.0
11
12parameters:
13
14 agentName:
15 type: string
16 description: Agent Name
17 default: connectware-agent
18
19 modbusPort:
20 type: integer
21 default: 10502
22 dockerBridgeNetworkIp:
23 type: string
24 default: 172.17.0.1
25 description: The IP address of the docker bridge network gateway, see "docker network inspect bridge"
26
27
28definitions:
29
30 CYBUS_MQTT_ROOT: cybus/baz-simulator
31
32 defaultModbusAddress:
33 fc: 3
34 length: 2
35 interval: 1000
36 dataType: uint16BE
37
38resources:
39
40 machineSimulator:
41 type: Cybus::Container
42 properties:
43 image: registry.cybus.io/cybus-services/baz-machine-simulator:0.0.1
44 ports:
45 - !sub '${modbusPort}:10502/tcp'
46
47 modbusConnection:
48 type: Cybus::Connection
49 properties:
50 agentName: !ref agentName
51 protocol: Modbus
52 targetState: connected
53 connection:
54 host: !ref dockerBridgeNetworkIp
55 port: !ref modbusPort
56
57 currentState:
58 type: Cybus::Endpoint
59 properties:
60 protocol: Modbus
61 connection: !ref modbusConnection
62 topic: current-state
63 subscribe:
64 !merge
65 defaultModbusAddress:
66 address: 0
67
68 currentTool:
69 type: Cybus::Endpoint
70 properties:
71 protocol: Modbus
72 connection: !ref modbusConnection
73 topic: current-tool
74 subscribe:
75 !merge
76 defaultModbusAddress:
77 address: 2
78
79 coolantLevel:
80 type: Cybus::Endpoint
81 properties:
82 protocol: Modbus
83 connection: !ref modbusConnection
84 topic: coolant-level
85 subscribe:
86 !merge
87 defaultModbusAddress:
88 address: 4
89
90 spindleSpeed:
91 type: Cybus::Endpoint
92 properties:
93 protocol: Modbus
94 connection: !ref modbusConnection
95 topic: spindle-speed
96 subscribe:
97 !merge
98 defaultModbusAddress:
99 address: 6
100
101 dashboard:
102 type: Cybus::Container
103 properties:
104 image: registry.cybus.io/cybus-services/baz-dashboard:0.2.3
105 volumes:
106 - !sub '${dashboardData}:/root/.node-red'
107 environment:
108 MQTT_HOST: !ref Cybus::MqttHost
109 MQTT_USER: !ref Cybus::MqttUser
110 MQTT_PASS: !ref Cybus::MqttPassword
111 MQTT_PORT: !ref Cybus::MqttPort
112 HTTP_ROOT: /
113
114 dashboardData:
115 type: Cybus::Volume
116
117 dashboardRoute:
118 type: Cybus::IngressRoute
119 properties:
120 container: !ref dashboard
121 type: http
122 slug: dashboard
123 target:
124 path: /
125 port: 1880
126
127 dashboardLink:
128 type: Cybus::Link
129 properties:
130 ingressRoute: !ref dashboardRoute
131 href: ui/
132 name: Dashboard
How to deploy the agent¶
To run the above example, you must also deploy and run an agent, which is a container using the Connectware’s image protocol-mapper with some special environment variables (see also Agent Installation).
The first thing you need to set is the image and image tag (i.e. version) you are going to use. The agent’s container must use the protocol-mapper image of the exact same version as the Connectware, otherwise the system may run into unspecified behaviour. For the subsequent command the image tag (version) is stored as IMAGE_TAG= 1.7.3
Using the IMAGE_TAG environment variable, the following command will run the agent directly (but with the comment lines removed):
# The docker run command
docker run --rm \
# Attach a volume so the agent can store data across restarts
-v /tmp/cybus:/data \
# Set the name of the agent. This must match the agentName used in the commissioning file.
-e CYBUS_AGENT_NAME=connectware-agent \
# The IP address where the Connectware is running.
-e CYBUS_MQTT_HOST=10.11.12.13 \
# Make it run as an agent
-e CYBUS_AGENT_MODE=distributed \
# Some suitable hostname of the container.
--hostname=${HOSTNAME} \
# Run it in host mode networking
--net=host \
# The image to use
registry.cybus.io/cybus/protocol-mapper:${IMAGE_TAG}
Then, complete the set up by registering the new agent’s user in the Connectware using the “Client Registry” process, see Agent Registration and Client Registry
Alternative ways to run the agent can be found on Agent Installation.