TwinCAT ADS controller

Allows to communicate with Beckhoff TwinCAT ADS PLCs and other equipment.

As TwinCAT ADS does not allow to connect more than a single client from a single machine (IP), the service instances require TwinCAT ADS bridge to be deployed for each TwinCAT system.

TwinCAT ADS bridge

Setup

Use the template EVA_DIR/share/svc-tpl/svc-tpl-controller-ads.yml:

# TwinCAT ADS controller gateway service
command: svc/eva-controller-ads
bus:
  path: var/bus.ipc
config:
  ads: 
    bridge_svc: eva.bridge.ads1
    ams_netid: 192.168.1.100.1.1
    #ams_port: 851
    # Allow SUMUP write and write_read requests (default: true)
    # Set false for ADS servers which unsupport this feature
    #bulk_allow: true
  # panic on critical errors in X seconds after happened (0 - panic immediately)
  panic_in: 0
  # default retry attempts for all operations (0 - no retries, give up if the
  # first attempt fails)
  retries: 2
  # an optional delay betwen writing symbols and verifying written value
  #verify_delay: 0.1
  # event queue size, pull events ARE DROPPED on overflow. consider ALWAYS
  # having queue size > max possible symbols pulled
  queue_size: 32768
  # ttl cache for pull events (sec, skip non-modified)
  pull_cache_sec: 3600
  # PLC pull interval, in seconds
  pull_interval: 1
  # pull symbols and parse maps
  #
  # by default, sends raw events with status=1, value=<pulled value>
  # if item statuses need to be collected, specify prop: status in the map
  # block
  #
  #pull:
     #pull an array
    #- symbol: test_arrays.test_float_array
      #map:
        #- idx: 0 # payload index, starting from zero
        #  oid: sensor:tests/test0
        #  prop: value # status or value (default = value)
        #- idx: 4
          #oid: sensor:tests/test1
          #value_delta: 0.5 # report event only if the new value difference is >=
          #transform:
            #- func: multiply # multiply the value by N
              #params: [ 1000 ]
            #- func: divide # divide the value by N
              #params: [ 1000 ]
            #- func: round # round the value to N digits after comma
              #params: [ 2 ]
            #- func: calc_speed # use the value as calc-speed gauge (with N seconds delta)
              #params: [ 1 ]
            #- func: invert # invert the value between 0/1
            # #params: []
    # pull a symbol
    #- symbol: test_arrays.test_float_array[5]
      #map:
         #- oid: sensor:tests/test2
  # action queue size, per item, actions on overflow are not dropped but wait
  # their attempt to enter the queue. The core marks an action as failed if it
  # does not enter the queue for <action timeout> seconds
  action_queue_size: 32
  # verify written data for actions
  actions_verify: true
  # OID map for actions
  #action_map:
    #unit:tests/u1:
      #value:
        #symbol: test_arrays.test_float_array[0]
      #status:
        #symbol: test_array.test_bool_array[0]
timeout:
  # startup timeout should be slightly langer than default to allow the
  # controller prepare connection pool and request pull/action handles
  startup: 10
user: nobody
react_to_fail: true

Create the service using eva-shell:

eva svc create eva.controller.ads1 /opt/eva4/share/svc-tpl/svc-tpl-controller-ads.yml

or using the bus CLI client:

cd /opt/eva4
cat DEPLOY.yml | ./bin/yml2mp | \
    ./sbin/bus ./var/bus.ipc rpc call eva.core svc.deploy -

(see eva.core::svc.deploy for more info)

EAPI methods

See EAPI commons for the common information about the bus, types, errors and RPC calls.

action

Description

Executes a mapped unit action

Parameters

See Unit actions

Returns

See Unit actions

kill

Description

Attempts to terinate/cancel all actions for a unit

Parameters

See Unit actions

Returns

See Unit actions

terminate

Description

Attempts to terminate/cancel a unit action

Parameters

See Unit actions

Returns

See Unit actions

var.get

Description

Get symbol from ADS

Parameters

required

Returns

Symbol value, single or list

Parameters

Name

Type

Description

Required

i

String

symbol name

yes

timeout

f64

Max operation timeout

no

retries

u8

Retry attempts

no

var.set

Description

Set symbol on ADS

Parameters

required

Returns

nothing

Parameters

Name

Type

Description

Required

i

String

symbol name

yes

value

Any

value to set

yes

verify

bool

Read the symbol back and verify its value

no

timeout

f64

Max operation timeout

no

retries

u8

Retry attempts

no

var.set_bulk

Description

Set symbols on ADS in bulk

Parameters

required

Returns

Operation status: failed-to-set symbols list or an empty dict

Parameters

Name

Type

Description

Required

i

Vec<String>

symbol names

yes

values

Vec<Any>

values to set

yes

verify

bool

Read the symbols back and verify their values

no

timeout

f64

Max operation timeout

no

retries

u8

Retry attempts

no

Return payload example:

{
  "failed": [ "var1" ]
}