“Machine Condition Monitoring Example” - Single File¶
This example shows an entire Machine condition monitoring service expressed within a single commissioning file.
Download: opcuaSimulated.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 Temperature & Vibration Visualization for a Machine
3
4metadata:
5 name: Condition Monitoring
6 icon: https://www.cybus.io/wp-content/uploads/2019/03/Cybus-logo-Claim-lang.svg
7 provider: cybus
8 homepage: https://www.cybus.io
9 version: 0.0.1
10
11definitions:
12 SID: !ref Cybus::ServiceId
13
14parameters:
15 IP_Address:
16 type: string
17 default: 172.17.0.1
18
19 Port_Number:
20 type: integer
21 default: 4840
22
23 Azure_Iot_Hub_Connection_String:
24 type: string
25 default: some_azure_connection_string
26
27resources:
28 # OPC UA simulator container used for the demo
29 opcuaServer:
30 type: Cybus::Container
31 properties:
32 image: registry.cybus.io/cybus-factory/opcua-server:1.0.1
33 ports:
34 - 4840:50000/tcp
35 command:
36 - "--unsecuretransport"
37 - "--autoaccept"
38 - "--defaultuser=user"
39 - "--defaultpassword=pass"
40
41 opcuaConnection:
42 type: Cybus::Connection
43 properties:
44 protocol: Opcua
45 targetState: connected
46 connection:
47 host: !ref IP_Address
48 port: !ref Port_Number
49 username: user
50 password: pass
51
52 opcuaCurrentServerTime:
53 type: Cybus::Endpoint
54 properties:
55 protocol: Opcua
56 connection: !ref opcuaConnection
57 subscribe:
58 nodeId: i=2258
59 samplingInterval: 1000
60
61 opcuaTemperature:
62 type: Cybus::Endpoint
63 properties:
64 protocol: Opcua
65 connection: !ref opcuaConnection
66 subscribe:
67 nodeId: ns=2;s=SpikeData
68 samplingInterval: 2000
69
70 opcuaVibration:
71 type: Cybus::Endpoint
72 properties:
73 protocol: Opcua
74 connection: !ref opcuaConnection
75 subscribe:
76 nodeId: ns=2;s=DipData
77 samplingInterval: 2000
78
79 mapping:
80 type: Cybus::Mapping
81 properties:
82 mappings:
83 - subscribe:
84 endpoint: !ref opcuaCurrentServerTime
85 publish:
86 topic: !sub "${Cybus::MqttRoot}/current-server-time"
87 - subscribe:
88 endpoint: !ref opcuaTemperature
89 rules:
90 - transform:
91 expression: |
92 {
93 "timestamp": timestamp,
94 "value": (value - 32) * (5/9),
95 "unit": "celsius"
96 }
97 publish:
98 topic: !sub "${Cybus::MqttRoot}/temperature"
99 - subscribe:
100 endpoint: !ref opcuaVibration
101 publish:
102 topic: !sub "${Cybus::MqttRoot}/vibration"
103
104 #----------------------------------------------------------------------------
105 # VOLUMES
106 #----------------------------------------------------------------------------
107
108 grafanaVolume:
109 type: Cybus::Volume
110
111 influxdbVolume:
112 type: Cybus::Volume
113
114 #----------------------------------------------------------------------------
115 # FRONTENDS
116 #----------------------------------------------------------------------------
117
118 # Grafana
119 grafanaURL:
120 type: Cybus::IngressRoute
121 properties:
122 container: !ref genericGrafana
123 type: http
124 slug: grafana
125 target:
126 path: '/'
127 port: 3000
128
129 dashboard:
130 type: Cybus::Link
131 properties:
132 name: Dashboard
133 ingressRoute: !ref grafanaURL
134 href: ''
135
136 #----------------------------------------------------------------------------
137 # Cybus Timeseris & Dashboard service containers
138 #----------------------------------------------------------------------------
139
140 influxdbPush:
141 type: Cybus::Container
142 properties:
143 image: registry.cybus.io/cybus-services/influxdb-push:0.0.3
144 environment:
145 MQTT_HOST: !ref Cybus::MqttHost
146 MQTT_USER: !ref Cybus::MqttUser
147 MQTT_PORT: !ref Cybus::MqttPort
148 MQTT_PASS: !ref Cybus::MqttPassword
149 MQTT_ROOT_TOPIC: !sub "${Cybus::MqttRoot}/#"
150 INFLUX_HOST: !ref influxdb
151 INFLUX_PORT: 8086
152 INFLUX_DB: generic
153 HTTP_ROOT: /
154
155 influxdb:
156 type: Cybus::Container
157 properties:
158 image: registry.cybus.io/cybus-services/influxdb:1.7.7-alpine
159 ports:
160 - 8086:8086/tcp
161 volumes:
162 - !sub "${influxdbVolume}:/var/lib/influxdb"
163 environment:
164 INFLUXDB_DB: generic
165
166 genericGrafana:
167 type: Cybus::Container
168 properties:
169 image: registry.cybus.io/cybus-services/generic-grafana:1.2.1
170 volumes:
171 - !sub "${grafanaVolume}:/var/lib/grafana"
172 environment:
173 GF_SERVER_ROOT_URL: !sub "/services/${SID}/grafana"
174 GF_AUTH_ANONYMOUS_ENABLED: true
175 INFLUX_DB: generic
176 INFLUX_HOST: !ref influxdb
177 INFLUX_PORT: 8086
178
179 #----------------------------------------------------------------------------
180 # Cybus Azure IoT Hub Connector Service
181 #----------------------------------------------------------------------------
182
183 azureIoTConnector:
184 type: Cybus::Container
185 properties:
186 image: registry.cybus.io/cybus-services/azure-iot-connector:0.0.5
187 environment:
188 LOG_LEVEL: 'info'
189 CONNECTOR_CONFIG: !sub |
190 {
191 "general": {
192 "name": "Azure Connector"
193 },
194 "source": {
195 "driver": "azure.iot",
196 "connection": {
197 "connectionString": "${Azure_Iot_Hub_Connection_String}"
198 },
199 "defaults": {
200 "operation": "write"
201 }
202 },
203 "target": {
204 "driver": "mqtt",
205 "connection": {
206 "protocol": "mqtt",
207 "host": "${Cybus::MqttHost}",
208 "port": ${Cybus::MqttPort},
209 "username": "admin",
210 "password": "admin"
211 },
212 "defaults": {
213 "operation": "subscribe",
214 "topicPrefix": "${Cybus::MqttRoot}"
215 }
216 },
217 "mappings": [
218 {
219 "source": {
220 "name": "temperature",
221 "type": "telemetry"
222 },
223 "target": {
224 "topic": "${Cybus::MqttRoot}/temperature"
225 }
226 },
227 {
228 "source": {
229 "name": "vibration",
230 "type": "telemetry",
231 "properties": {
232 "default": false,
233 "route": "storage"
234 }
235 },
236 "target": {
237 "topic": "${Cybus::MqttRoot}/vibration"
238 }
239 }
240 ]
241 }