description: >
  This service provides a connectivity to all endpoints provided by the
  simulated shop floor

metadata:

  name: Connectivity Layer
  icon: https://www.cybus.io/wp-content/uploads/2017/10/connection.svg
  provider: cybus
  homepage: https://www.cybus.io

parameters:

  agentName:
    type: string
    default: protocol-mapper

  modbusPort:
    type: integer
    default: 10502
  dockerBridgeNetworkIp:
    type: string
    default: 172.17.0.1
    description: The IP address of the docker bridge network gateway, see "docker network inspect bridge"

definitions:

  defaultModbusAddress:
    fc: 3
    length: 2
    interval: 1000
    dataType: uint16BE

resources:

  modbusConnection:
    type: Cybus::Connection
    properties:
      agentName: !ref agentName
      protocol: Modbus
      targetState: connected
      connection:
        host: !ref dockerBridgeNetworkIp
        port: !ref modbusPort

  currentState:
    type: Cybus::Endpoint
    properties:
      agentName: !ref agentName
      protocol: Modbus
      connection: !ref modbusConnection
      subscribe:
        !merge
          defaultModbusAddress:
          address: 0

  currentTool:
    type: Cybus::Endpoint
    properties:
      agentName: !ref agentName
      protocol: Modbus
      connection: !ref modbusConnection
      subscribe:
        !merge
          defaultModbusAddress:
          address: 2

  coolantLevel:
    type: Cybus::Endpoint
    properties:
      agentName: !ref agentName
      protocol: Modbus
      connection: !ref modbusConnection
      subscribe:
        !merge
          defaultModbusAddress:
          address: 4

  spindleSpeed:
    type: Cybus::Endpoint
    properties:
      agentName: !ref agentName
      protocol: Modbus
      connection: !ref modbusConnection
      subscribe:
        !merge
          defaultModbusAddress:
          address: 6
