Ethernet/IP PLC controller gateway
Allows to communicate with Ethernet/IP-powered PLCs and other equipment.
Setup
Use the template EVA_DIR/share/svc-tpl/svc-tpl-controller-enip.yml:
# EthernetIP PLC controller gateway service
command: svc/eva-controller-enip
bus:
path: var/bus.ipc
config:
plc:
# only ab_eip is supported
protocol: ab_eip
host: 192.168.1.100
port: 44818
# PLC path
path: "1,0"
# PLC type, valid values are: LGX, MLGX, PLC, MLGX800
cpu: LGX
# panic on critical errors in X seconds after happened (0 - panic immediately)
panic_in: null
# default retry attempts for all operations (0 - no retries, give up if the
# first attempt fails)
retries: 2
# an optional delay betwen writing tags and verifying written value
#verify_delay: 0.1
# event queue size, pull events ARE DROPPED on overflow. consider ALWAYS
# having queue size > max possible tags 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 blocks and parse maps
#
# the configuration is very similar (but extended) to the widely-used
# https://github.com/alttch/pulr tool
#
# 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:
#- tag: test_array.test_float_array
# An optional size/count args for PLC tag read commands, required for
# arrays
#size: 4
#count: 10
#map:
#- offset: 0
#oid: sensor:tests/test0
# allowed types: real (REAL), real32, real64 (LREAL), uint8 (BOOL,
# USINT), int8, sint8 (SINT), byte, uint16 (UINT), word, uint32
# (UDINT), dword, sint16 (INT), int16, sint32 (DINT), int32, sint64
# (LINT), int64, uint64 (ULINT), qword
#type: real
# Offsets ARE NOT array indexes, but absolute offsets in block
# can be written as N+N+N
#- offset: 0+4
#oid: sensor:tests/test1
#type: real
#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 bits
#- tag: test_array.test_bool_array
#map:
#- offset: 0/0
#oid: sensor:tests/flag0
#- offset: 0/1
#oid: unit:tests/u1
#prop: status
# 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:
#tag: test_array.test_float_array[0]
#type: real
#status:
#tag: test_array.test_bool_array
#type: bit
#bit: 1
timeout:
# startup timeout should be slightly langer than default to allow the
# controller prepare connection pool
startup: 10
user: nobody
react_to_fail: true
Create the service using eva-shell:
eva svc create eva.controller.enip1 /opt/eva4/share/svc-tpl/svc-tpl-controller-enip.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 En/IP tag from PLC |
Parameters |
required |
Returns |
Tag value, single or list |
Name |
Type |
Description |
Required |
i |
String |
PLC tag |
yes |
type |
String |
Data type (e.g. DINT) |
yes |
size |
u32 |
Type size helper |
no |
count |
u32 |
Count of data blocks (e.g. for arrays) |
no |
bit |
u32 |
Get an individual bit |
no |
timeout |
f64 |
Max operation timeout |
no |
retries |
u8 |
Retry attempts |
no |
var.set
Description |
Set En/IP tag on PLC |
Parameters |
required |
Returns |
nothing |
Name |
Type |
Description |
Required |
i |
String |
PLC tag |
yes |
value |
Any |
value to set |
yes |
type |
String |
Data type (e.g. DINT) |
yes |
bit |
u32 |
Set an individual bit |
no |
verify |
bool |
Read the tag back and verify its value |
no |
timeout |
f64 |
Max operation timeout |
no |
retries |
u8 |
Retry attempts |
no |