“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).

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
description: >
    Temperature & Vibration Visualization for a Machine

metadata:
  name: Condition Monitoring
  icon: https://www.cybus.io/wp-content/uploads/2019/03/Cybus-logo-Claim-lang.svg
  provider: cybus
  homepage: https://www.cybus.io
  version: 0.0.1

definitions:
  SID: !ref Cybus::ServiceId

parameters:
  IP_Address:
    type: string
    default: 172.17.0.1

  Port_Number:
    type: integer
    default: 4840

  Azure_Iot_Hub_Connection_String:
    type: string
    default: some_azure_connection_string

resources:
  # OPC UA simulator container used for the demo
  opcuaServer:
    type: Cybus::Container
    properties:
      image: registry.cybus.io/cybus-factory/opcua-server:1.0.1
      ports:
        - 4840:50000/tcp
      command:
        - "--unsecuretransport"
        - "--autoaccept"
        - "--defaultuser=user"
        - "--defaultpassword=pass"

  opcuaConnection:
    type: Cybus::Connection
    properties:
      protocol: Opcua
      targetState: connected
      connection:
        host: !ref IP_Address
        port: !ref Port_Number
        username: user
        password: pass

  opcuaCurrentServerTime:
    type: Cybus::Endpoint
    properties:
      protocol: Opcua
      connection: !ref opcuaConnection
      subscribe:
        nodeId: i=2258
        samplingInterval: 1000

  opcuaTemperature:
    type: Cybus::Endpoint
    properties:
      protocol: Opcua
      connection: !ref opcuaConnection
      subscribe:
        nodeId: ns=2;s=SpikeData
        samplingInterval: 2000

  opcuaVibration:
    type: Cybus::Endpoint
    properties:
      protocol: Opcua
      connection: !ref opcuaConnection
      subscribe:
        nodeId: ns=2;s=DipData
        samplingInterval: 2000

  mapping:
    type: Cybus::Mapping
    properties:
      mappings:
        - subscribe:
            endpoint: !ref opcuaCurrentServerTime
          publish:
            topic: !sub "${Cybus::MqttRoot}/current-server-time"
        - subscribe:
            endpoint: !ref opcuaTemperature
          rules:
            - transform:
                expression: |
                  {
                    "timestamp": timestamp,
                    "value": (value - 32) * (5/9),
                    "unit": "celsius"
                  }
          publish:
            topic: !sub "${Cybus::MqttRoot}/temperature"
        - subscribe:
            endpoint: !ref opcuaVibration
          publish:
            topic: !sub "${Cybus::MqttRoot}/vibration"

  #----------------------------------------------------------------------------
  # VOLUMES
  #----------------------------------------------------------------------------

  grafanaVolume:
    type: Cybus::Volume

  influxdbVolume:
    type: Cybus::Volume

  #----------------------------------------------------------------------------
  # FRONTENDS
  #----------------------------------------------------------------------------

  # Grafana
  grafanaURL:
    type: Cybus::IngressRoute
    properties:
      container: !ref genericGrafana
      type: http
      slug: grafana
      target:
        path: '/'
        port: 3000

  dashboard:
    type: Cybus::Link
    properties:
      name: Dashboard
      ingressRoute: !ref grafanaURL
      href: ''

  #----------------------------------------------------------------------------
  # Cybus Timeseris & Dashboard service containers
  #----------------------------------------------------------------------------

  influxdbPush:
      type: Cybus::Container
      properties:
        image: registry.cybus.io/cybus-services/influxdb-push:0.0.3
        environment:
          MQTT_HOST: !ref Cybus::MqttHost
          MQTT_USER: !ref Cybus::MqttUser
          MQTT_PORT: !ref Cybus::MqttPort
          MQTT_PASS: !ref Cybus::MqttPassword
          MQTT_ROOT_TOPIC: !sub "${Cybus::MqttRoot}/#"
          INFLUX_HOST: !ref influxdb
          INFLUX_PORT: 8086
          INFLUX_DB: generic
          HTTP_ROOT: /

  influxdb:
    type: Cybus::Container
    properties:
      image: registry.cybus.io/cybus-services/influxdb:1.7.7-alpine
      ports:
        - 8086:8086/tcp
      volumes:
        - !sub "${influxdbVolume}:/var/lib/influxdb"
      environment:
        INFLUXDB_DB: generic

  genericGrafana:
    type: Cybus::Container
    properties:
      image: registry.cybus.io/cybus-services/generic-grafana:1.2.1
      volumes:
        - !sub "${grafanaVolume}:/var/lib/grafana"
      environment:
        GF_SERVER_ROOT_URL: !sub "/services/${SID}/grafana"
        GF_AUTH_ANONYMOUS_ENABLED: true
        INFLUX_DB: generic
        INFLUX_HOST: !ref influxdb
        INFLUX_PORT: 8086

  #----------------------------------------------------------------------------
  # Cybus Azure IoT Hub Connector Service
  #----------------------------------------------------------------------------

  azureIoTConnector:
    type: Cybus::Container
    properties:
      image: registry.cybus.io/cybus-services/azure-iot-connector:0.0.5
      environment:
        LOG_LEVEL: 'info'
        CONNECTOR_CONFIG: !sub  | 
          {
            "general": {
              "name": "Azure Connector"
            },
            "source": {
              "driver": "azure.iot",
              "connection": {
                "connectionString": "${Azure_Iot_Hub_Connection_String}"
              },
              "defaults": {
                "operation": "write"
              }
            },
            "target": {
              "driver": "mqtt",
              "connection": {
                "protocol": "mqtt",
                "host": "${Cybus::MqttHost}",
                "port": ${Cybus::MqttPort},
                "username": "admin",
                "password": "admin"
              },
              "defaults": {
                "operation": "subscribe",
                "topicPrefix": "${Cybus::MqttRoot}"
              }
            },
            "mappings": [
              {
                "source": {
                  "name": "temperature",
                  "type": "telemetry"
                },
                "target": {
                  "topic": "${Cybus::MqttRoot}/temperature"
                }
              },
              {
                "source": {
                  "name": "vibration",
                  "type": "telemetry",
                  "properties": {
                    "default": false,
                    "route": "storage"
                  }
                },
                "target": {
                  "topic": "${Cybus::MqttRoot}/vibration"
                }
              }
            ]
          }