---
# ----------------------------------------------------------------------------
# Service Commissioning File
# ----------------------------------------------------------------------------
# Copyright: Cybus GmbH
# Contact: support@cybus.io
# ----------------------------------------------------------------------------
# Migrating from HighByte Intelligence Hub (Example)
# ----------------------------------------------------------------------------

description: >
  Service commissioning file migrated from the Intelligence Hub connection
  Machine_OPC_UA with the input CNC_Temperature (Example)

metadata:
  name: HighByte Intelligence Hub Migration Example
  provider: cybus
  homepage: https://www.cybus.io
  version: 1.0.0

parameters:
  opcuaHost:
    description: Host of the connection Machine_OPC_UA
    type: string
    default: 192.168.1.100

  opcuaPort:
    description: Port of the connection Machine_OPC_UA
    type: integer
    default: 4840

  opcuaUsername:
    description: Username for the OPC UA server
    type: string
    default: ''

  opcuaPassword:
    description: Password for the OPC UA server (encrypted in the export, set on install)
    type: string
    default: ''

resources:
  # Intelligence Hub connection "Machine_OPC_UA"
  machineOpcuaConnection:
    type: Cybus::Connection
    properties:
      protocol: Opcua
      targetState: connected
      connection:
        host: !ref opcuaHost
        port: !ref opcuaPort
        username: !ref opcuaUsername
        password: !ref opcuaPassword
        options:
          securityPolicy: Basic256Sha256
          messageSecurityMode: SignAndEncrypt

  # Input "CNC_Temperature": subscription rate 1 second
  cncTemperature:
    type: Cybus::Endpoint
    properties:
      protocol: Opcua
      connection: !ref machineOpcuaConnection
      subscribe:
        nodeId: ns=2;s=Machines.CNC_1001.Temperature
        samplingInterval: 1000
        publishInterval: 1000

  # Output "UNS_Publish": topic moves to the integrated Connectware broker
  mapping:
    type: Cybus::Mapping
    properties:
      mappings:
        - subscribe:
            endpoint: !ref cncTemperature
          publish:
            topic: site/area/line/cnc1001/temperature
