# ===================================================================================================================
#
#  This commissioning file is an example of an OPC UA method endpoint. The endpoint multipyEndpoint requires two
#  input variables to publish to the .../set topic, calls the method on the server side, and publishes the result to
#  the .../res topic.
#
#  Example call:
#   mosquitto_pub -u admin -P admin -p 1883 -t 'services/opcuamethodendpoint/multiplyEndpoint/nodeId:ns=2;s=Demo.Method.Multiply/set' -m '{ "value": { "inputArguments":[{"value":42}, {"value":2} ] } }'
#
# -------------------------------------------------------------------------------------------------------------------
#
#                                           ┌──────────────────────────────┐
#                                           │        opcuaserver.com       │
#                                           └───────────────┬──────────────┘
#                                                           │
#                                           ┌───────────────┴──────────────┐
#      .....................................│        multiplyEndpoint      │......................................
#      .   CONNECTWARE                      └────┬────────────────────┬────┘                                     .
#      .                                         |                    |                                          .
#      .                  ┌──────────────────────┴───────┐     ┌──────┴───────────────────────┐                  .
#      .                  │            .../set           │     │             .../res          │                  .
#      .                  └──────────────────────────────┘     └──────────────────────────────┘                  .
#      .                                                                                                         .
#      .                                                                                                         .
#      ...........................................................................................................
#
#
# -------------------------------------------------------------------------------------------------------------------

description: OPC UA method endpoint

metadata:
  name: opcua-method-endpoint
  version: 1.0.0

resources:
  # --------------------------------------------------
  #   North Bound - OPC UA Client
  # --------------------------------------------------

  opcuaConnection:
    type: Cybus::Connection
    properties:
      protocol: Opcua
      connection: # opc.tcp://opcuaserver.com:48010
        host: opcuaserver.com
        port: 48010

  multiplyEndpoint:
    type: Cybus::Endpoint
    properties:
      protocol: Opcua
      connection: !ref opcuaConnection
      publishError: true
      write:
        nodeId: ns=2;s=Demo.Method.Multiply
        nodeType: Method
