---
# ----------------------------------------------------------------------------#
# Commissioning File
# ----------------------------------------------------------------------------#
# Copyright: Cybus GmbH (2020)
# Contact: support@cybus.io
# ----------------------------------------------------------------------------#
# Source Interface Definition - Siemens S7 PLC
# ----------------------------------------------------------------------------#
# ----------------------------------------------------------------------------#
description: |
  Sample commissioning file for Siemens S7 PLC connectivity and data mapping

metadata:

  name: S7 Protocol Connectivity
  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

parameters:

  IP_Address:
    type: string
    default: 192.168.10.60

  Port_Number:
    type: integer
    default: 102

  Rack_Number:
    type: integer
    default: 102

  Slot_Number:
    type: integer
    default: 102

  Poll_Interval:
    type: integer
    default: 1000

resources:

  s7Connection:
    type: Cybus::Connection
    properties:
      protocol: S7
      targetState: connected
      connection:
        host: !ref IP_Address
        port: !ref Port_Number
        rack: !ref Rack_Number
        slot: !ref Slot_Number
        pollInterval: !ref Poll_Interval

  s7EndpointQX00:
    type: Cybus::Endpoint
    properties:
      protocol: S7
      connection: !ref s7Connection
      subscribe:
        address: QX0.0

  s7EndpointAIB0:
    type: Cybus::Endpoint
    properties:
      protocol: S7
      connection: !ref s7Connection
      subscribe:
        address: IB0

  mapping:
    type: Cybus::Mapping
    properties:
      mappings:
        - subscribe:
            endpoint: !ref s7EndpointQX00
          publish:
            topic: !sub '${Cybus::MqttRoot}/QX00'
        - subscribe:
            endpoint: !ref s7EndpointAIB0
          publish:
            topic: !sub '${Cybus::MqttRoot}/AIB0'
