---
# ----------------------------------------------------------------------------#
# Commissioning File
# ----------------------------------------------------------------------------#
# Protocol: Heidenhain
# Copyright: Cybus GmbH (2020)
# Contact: support@cybus.io
# ----------------------------------------------------------------------------#
description: >
  Heidenhain sample commissioning file

metadata:
  name: Heidenhain example
  icon: https://www.cybus.io/wp-content/uploads/2017/10/for-whom1.svg
  provider: cybus
  homepage: https://www.cybus.io
  version: 1.0.0

parameters:
  ipAddress:
    type: string
    description: The IP address of the CNC machine
    default: 10.0.0.2

  cncType:
    type: string
    description: The CNC type; can be tnc640, itnc530, tnc426
    default: tnc640

  agentName:
    type: string
    description: The name of the Cybus Heidenhain agent on the windows machine
    default: heidenhain-WIN1234

resources:
  heidenhainConnection:
    type: Cybus::Connection
    properties:
      protocol: Heidenhain
      connection:
        domain: edge.cybus
        agent: !ref agentName
        ipAddress: !ref ipAddress
        cncType: !ref cncType
        plcPassword: <password>
        usrPassword: <password>
        tablePassword: <password>
        sysPassword: <password>
        connectionStrategy:
          initialDelay: 5000
          maxDelay: 30000
          incrementFactor: 2

  getVersion:
    type: 'Cybus::Endpoint'
    properties:
      protocol: Heidenhain
      connection: !ref heidenhainConnection
      topic: getVersion
      read:
        method: getVersion

  getNcUpTime:
    type: Cybus::Endpoint
    properties:
      protocol: Heidenhain
      connection: !ref heidenhainConnection
      topic: getNcUpTime
      read:
        method: getNcUpTime

  getToolTable:
    type: Cybus::Endpoint
    properties:
      protocol: Heidenhain
      connection: !ref heidenhainConnection
      topic: getToolTable
      read:
        method: getToolTable

  onToolTableChanged:
    type: Cybus::Endpoint
    properties:
      protocol: Heidenhain
      connection: !ref heidenhainConnection
      topic: notify/onToolChanged
      subscribe:
        type: notify
        method: onToolTableChanged

  onProgramChanged:
    type: Cybus::Endpoint
    properties:
      protocol: Heidenhain
      connection: !ref heidenhainConnection
      topic: notify/onProgramChanged
      subscribe:
        type: notify
        method: onProgramChanged
