EtherNet/IP Protocol Adapter
This section presents the capabilities and configuration options of the EtherNet/IP Protocol Adapter, which translates the EtherNet/IP communication protocol into objects understandable by the Gateway Agent.
For a step-by-step guide on how to install the EtherNet/IP Protocol Adapter, see the Installation Guide.
Currently, communication in the EtherNet/IP Protocol Adapter is limited to unconnected messaging. Unconnected messaging is a Request-Response mechanism using a TCP connection. The adapter allows to send requests to multiple devices at arbitrarily selected intervals, with individual request timeouts.
The allowed configuration options of the request-response mechanism depend heavily on the target device you are using. To verify the service availability and the request-response structures, always refer to the target device documentation and the EtherNet/IP and CIP standard.
Configuring the EtherNet/IP Protocol Adapter
There are two configuration files of the EtherNet/IP Protocol Adapter:
Deployment configuration file - Configuration of the MQTT connection, PMQ connection and health monitoring.
Application configuration file - Configuration of connections, global adapter properties and device data (measurements, alerts and metadata).
When you modify the EtherNet/IP Protocol Adapter configuration, restart the adapter to apply the changes by means of the following command:
systemctl restart gwa-eip-adapter-cpp
The adapter configuration is then updated.
For an example of the EtherNet/IP Protocol Adapter configuration files, see here.
Deployment Configuration File
The deployment configuration file of the EtherNet/IP Protocol Adapter is located at:
/etc/relayr/gwa-eip-adapter-cpp/gwa-eip-adapter-config.json
To modify the file, edit it in a text editor.
The following configuration settings are available:
transport
- Communication channel used by the adapter. Available options:mqtt
orpmq
. By default,mqtt
.mqtt_connection
- Connection settings of the MQTT message broker:
Configuration Setting | Description | Default Value |
---|---|---|
host | IP address of the MQTT message broker. | localhost |
port | Port number for connecting to the MQTT broker. | 1883 |
keepalive | Keepalive value of the MQTT connection. | 20 |
max_inflight_messages | Maximum number of QoS 1 or 2 messages that can be in the process of being transmitted simultaneously. This includes messages currently going through handshakes and messages that are being retried. If set to 1 , it guarantees an in-order delivery of messages. | 100 |
qos_levels | Quality of Service level for each traffic type. | measurements: 0 , alerts: 1 . configuration: 1 , metadata: 1 |
postgres_connection
: For future use, currently not supported:
Configuration Setting | Description | Default Value |
---|---|---|
database_name | Database name. | db |
database_username | User name to authorize access to the database. | user |
database_password | Password to authorize access to the database. | pass |
health_monitor
- Health monitoring settings:
Configuration Setting | Description | Default Value |
---|---|---|
heartbeat_interval | Time interval at which the periodic heartbeat messages are sent, given in seconds. | 60 |
pmq_connection
- Configuration of the High Speed Bus (PMQ) connection. Configure this section to use thepmq
transport
:
Configuration Setting | Description | Default Value |
---|---|---|
output_queues | List of output PMQ queues, where the adapter reports all data, except for health monitoring messages, which are always reported via MQTT. Queue names must begin with / . | ["/eip_out_queue"] |
input_queues | List of PMQ queues to monitor for inbound messages, e.g. configuration update tasks. Queue names must begin with / . | ["/eip_in_queue"] |
message_size | Maximum size of a PMQ message, given in bytes. | 8192 |
message_count | Maximum number of messages in a PMQ queue. | 10 |
For an example of the deployment configuration file, see here.
Application Configuration File
The application configuration file of the EtherNet/IP Protocol Adapter is located at:
/etc/relayr/gwa-eip-adapter-cpp/gwa-eip-adapter-application-config.json
If you have the Configuration Manager installed, it becomes the primary way of editing application configuration files. If you do not have the Configuration Manager, edit the application configuration file in a text editor.
See sections below for information on:
Connections - List of EtherNet/IP (CIP) sessions.
Global Adapter Properties - Configuration of a global sampling interval and custom prefix.
Devices - List of connected devices and their measurements, alerts and metadata.
For an example of the application configuration file, see here.
Configuring EtherNet/IP Connections
The connections
section of the configuration file allows you to configure a list of EtherNet/IP (CIP) sessions used by devices.
For each of the configured connections, configure the following settings:
Configuration Setting | Description |
---|---|
id | Unique connection identifier, which is then used to identify a device connection. See the Configuring a Device Connection section for more information. |
host | Host name or IP address of the target device. |
port | Target host's port number that is used as a session port. By default, 44818 . |
timeout | Currently not supported, for future use. |
Global Adapter Properties
You can configure the following global settings that refer to the whole Protocol Adapter configuration:
Configuring Sampling Interval
The sampling interval determines how often the Agent gathers data from devices. It is a global setting that refers to retrieving data from all the connected devices.
The interval value is defined in milliseconds:
"sampling_interval" : 4000
Optionally, you can also define a local sampling interval for each object defined in the devices
section of the configuration file. In such a case, a local sampling interval overrides the global one.
Example: The global sampling interval is set to
4000
and the sampling interval for a temperaturemeasurement
object is2000
, so the Agent retrieves data about this temperature object every two seconds.
If you configure a local sampling interval for each object defined in the
devices
section, you do not need to configure a global sampling interval. However, if at least one object has no local sampling interval defined, the global one must be provided. Otherwise, the adapter configuration is invalid.
Configuring Custom Prefix
The custom prefix determines where to report data. If not defined, all data is reported to v1/sb
, by default.
The custom_prefix
option enables setting a different prefix to publish data e.g. to a custom MQTT topic for local data processing, or directly to the Gateway Agent northbound interface.
It is a global setting that refers to all data retrieved from devices.
Example:
"custom_prefix": "v1/nb"
Optionally, you can also define a local custom prefix for each measurement, alert, configuration parameter and metadata configured in the devices section of the configuration file. In such a case, a local custom prefix overrides the global one.
Instead of the
custom_prefix
option, you can also use thecustom_mqtt_prefix
option, which was implemented in the older adapter versions. However, it is recommended to usecustom_prefix
.
Configuring a List of Devices
In the devices
section of the configuration file, you can configure a list of devices.
For each device, the following configuration sections are available:
connection - CIP session used by a device.
measurements - List of measurements that can be reported by a device.
alerts - List of alerts that can be reported by a device.
metadata - List of metadata of a device.
configuration - Configuration parameters of a device (currently not supported).
Currently, the EtherNet/IP Protocol Adapter does not support configuration parameters. The
configuration
section of the configuration file is required by the Gateway Agent and should be an empty.json
array.
The devices
section has the following structure:
"devices" :
[
{
"connection" : { ... },
"measurements" : [ ... ],
"alerts" : [ ... ],
"configuration" : [ ... ],
"metadata" : [ ... ]
}
]
Configuring a Device Connection
In the connection.id
field, enter the EtherNet/IP (CIP) session identifier for a given device. Possible ID values are defined in the connections
section of the configuration file. See the Configuring EtherNet/IP Connections section for details.
It is mandatory to configure a connection ID for each device.
Here is an example of the device connection configuration:
"devices": [
{
"connection": {
"id": "dev"
},
You can also configure a local connection ID for a specific measurement, alert and metadata. If defined, the local connection ID overrides the global one, set in the
connection.id
field.
Configuring Measurements
You can define multiple measurements for a device, such as: temperature, humidity, pressure, etc.
To configure a measurement, define the following mandatory settings:
Configuration Setting | Description |
---|---|
id | Measurement identifier. A value provided here must match the measurement ID set in the device model version created in the relayr Cloud. For more information on creating device models and versions in the relayr Cloud, refer to the relayr Cloud API documentation. |
object | Protocol-specific object definition. See the EtherNet/IP Object Definition section for details. |
Optionally, you can define the following advanced settings for a measurement:
Configuration Setting | Description |
---|---|
filters.cov | Change of value functionality. If it is set to enabled , measurements are reported by a device only if their value differs from the latest reported value by at least a cov_delta value. |
filters.cov_delta | Delta for the change of value functionality. It specifies the minimum change of value (in relation to the latest reported value) that is required to report the measurement to the Agent. |
sampling_interval | Local sampling interval value, given in milliseconds, that overrides the global sampling interval setting. |
custom_prefix | Prefix of the MQTT topic that the object is reported to. An option to publish data to a custom MQTT topic for a local data processing or directly to the northbound interface. For example, if it is set to analytics for a temperature measurement, all data is published to the topic analytics/{did}/measurements/temperature . It overrides the global custom prefix. |
connection | Local connection ID used for a given measurement. It overrides the global connection set for the device. Possible ID values are defined in the connections section of the configuration file. See the Configuring EtherNet/IP Connections section for details. |
complex | Add this configuration section to configure a complex measurement. Specify how many data samples a complex measurement contains and, optionally, a collection_interval . For more information, see the Configuring Complex Measurements section. |
Here is an example of the measurement configuration:
{
"id" : "temperature",
"object" : { ... },
"sampling_interval" : 4000,
"filters" : {
"cov" : "enabled",
"cov_delta" : 0.04
}
},
In the example presented above, the temperature reading is reported by the device every four seconds (as defined in the
sampling_interval
field). The change of value (cov
) is enabled, and thecov_delta
is set to0.04
. It means that the temperature is reported only if it is different from the latest reported value by at least0.04
.
Configuring Complex Measurements
A complex measurement is a batch of measurement data, in which several samples of collected data values are published as a single message.
Complex measurements can be consumed by the Rule Engine and the GWA Analytics for further data processing and can be stored in the Storage Service. The Cloud Adapter supports publishing complex measurements to the relayr Cloud.
You can configure the size of a complex measurement by specifying how many data samples each batch contains. Optionally, you can also specify a collection interval. If specified, the adapter starts collecting data at every collection interval (e.g. 1h) and publishes a complex measurement when a configured number of samples are collected (e.g. 1000). Then, the adapter waits for the next collection interval and starts to acquire data again.
To configure a complex measurement, add the complex
section to the measurement configuration with the following settings:
Configuration Setting | Description |
---|---|
samples | Number of collected data samples in a complex measurement. For complex measurements, this setting is mandatory. |
collection_interval | Optional setting. Time interval, given in seconds, at which the adapter starts to acquire data for a complex measurement. |
Example:
{
"object": {},
"complex":
{
"samples": 10,
"collection_interval": 3600
}
}
If the
collection_interval
is lower than needed to collect the configured number of samples, the adapter collects data continuously. It starts to acquire data immediately after publishing the previous complex measurement.
If sensors stop sending data in the middle of data collection, e.g. due to connectivity problems, the adapter waits until the required number of samples are collected, despite the collection intervals. It publishes a complex measurement that contains data points not evenly distributed in time, e.g. with a 5h gap. Such a complex measurement may be considered as incorrect and may be discarded by the Rule Engine and/or the GWA Analytics, based on the
startTs
andendTs
values.
Complex Measurement Message
The collected data samples of a configured complex measurement are published as a complex measurement message. The Protocol Adapters support acquiring and publishing complex measurements in the time domain, but you can also use complex measurement messages to publish measurements in other domains, e.g. the frequency domain.
Complex measurements in the frequency domain may be reported by the Pico Adapter, or you may use the Rule Engine or the GWA Analytics to calculate them from the time-based measurements.
In a complex measurement message:
startTs
is a moment when data acquisition begins.endTs
is a moment when data acquisition finishes.xStart
is the first value on the X axis. ThexStart
unit depends on the measured value. For measurements in the time domain, it is a timestamp indicating the moment when the first data sample is collected. For measurements in the frequency domain, it is the first frequency on the X axis.xStep
represents a resolution of data on the X axis. For measurements in the time domain,xStep
is a time interval between consecutive data samples, given in milliseconds (you configure this interval in thesampling_interval
setting of the Protocol Adapters' configuration). ThexStep
value allows you to know the precise moment when each data sample was collected. For measurements in the frequency domain,xStep
represents the frequency resolution of data representation on the X axis.yValues
is an array of ordered measurement values.
Example 1: time-based measurement:
v1/sb/{UUID}/complex_measurements/temperature {
“id”:“temperature”,
“startTs”: 1492515087123,
“endTs”: 1492515092123,
“xStart”: 1492515087123,
“xStep”: 1000,
“yValues”: [42, 43, 39, 37, 40, 48, 45, 40, 38, 33, 30, 31...]
}
In this example,
temperature
is a time-based measurement. ThexStart
value is1492515087123
, which shows the moment when the first data sample (42
) was collected. ThexStep
value is1000
, which means that consecutive data samples were collected at the interval of 1000 milliseconds.
Example 2: frequency-based measurement:
v1/sb/{UUID}/complex_measurements/acceleration_xaxis_fft {
“id”:“acceleration_xaxis_fft”,
“startTs”: 1492515087123,
“endTs”: 1492515092123,
“xStart”: 90,
“xStep”: 10,
“yValues”: [3, 12, 48, 579, 644, 689, 711, 647, 78, 644, 669, 112, 638, 652, 617, 48...]
}
In this example,
acceleration_xaxis_fft
is a frequency-based measurement. ThexStart
value is90
, which shows that the first frequency on the X axis is 90 Hz. ThexStep
value is10
, which means that the frequency step on the X axis, between consecutive data samples, is 10 Hz.
Configuring Alerts
In the alerts
configuration section, you can define alerts for the configured devices.
To configure an alert, define the following mandatory settings:
Configuration Setting | Description |
---|---|
id | Alert identifier. A value provided here must match the alert ID of the device model created in the relayr Cloud. For more information on creating device models and versions in the relayr Cloud, refer to the relayr Cloud API documentation. |
measurement_id | Identifier of a measurement associated with the alert. The ID provided here must be configured in the measurements section of the configuration file. See the section above for details. Alternatively, you can configure the object section for an alert. See here for details. |
threshold_set | Threshold value based on which the alert is activated. |
logic_set | Logical relation for alert activation. Possible values are: "<", ">", "==", "">=", "<=". |
message_set | Message sent when the alert is activated. It is a free-form string. |
threshold_clear | Threshold value based on which the alert is cleared. |
logic_clear | Logical relation for clearing the alert. Possible values are: "<", ">", "==", "">=", "<=". |
message_clear | Message displayed when the alert is cleared. It is a free-form string. |
If both the
logic_clear
andlogic_set
conditions are fulfilled at the same time, the alert is set.
Optionally, you can define the following advanced settings for an alert:
Configuration Setting | Description |
---|---|
sampling_interval | Local sampling interval value, given in milliseconds, that overrides the global sampling interval. |
custom_prefix | Prefix of the MQTT topic that the object is reported to. An option to publish data to a custom MQTT topic for a local data processing or directly to the northbound interface. For example, if it is set to analytics for a temperature-based alert, all data is published to the topic analytics/{did}/alerts/alert_temp_high . It overrides the global custom prefix. |
connection | Local connection ID used for a given alert. It overrides the global connection set for the device. Possible ID values are defined in the connections section of the configuration file. See the Configuring EtherNet/IP Connections section for details. |
Here is an example of the alert configuration:
{
"id" : "alert_temp_high",
"measurement_id" : "temperature",
"threshold_set" : 38.5,
"logic_set" : ">=",
"message_set" : "TEMPERATURE IS TOO HIGH",
"threshold_clear" : 36.5,
"logic_clear" : "<=",
"message_clear" : "ALERT IS CLEAR",
"sampling_interval" : 4000
}
In the example presented above, the alert is activated if the temperature reaches a level defined in the
threshold_set
andlogic_set
fields, that is: if it is greater than or equal to 38.5. The message "TEMPERATURE IS TOO HIGH" is sent to the relayr Cloud when the alert is set.
When the temperature decreases and it is smaller than or equal to 36.5 (as specified in thethreshold_clear
andlogic_clear
fields), the alert is deactivated and the message "ALERT IS CLEAR" is sent to the relayr Cloud when the alert is deactivated.
The value provided in thesampling_interval
field means that the system verifies the alert data every four seconds.
Configuring Metadata
The metadata
section of the configuration file allows you to define device attributes, such as the device ID, model, version, location, owner's email address, etc.
There are two ways to configure metadata:
Static metadata - metadata is an
id
andvalue
pair. It is sent only once, at the application startup.Dynamic metadata - metadata has a defined
object
. It is reported not only at the application startup, but also when the metadata value changes.
Static Metadata
Static metadata is configured as an id
and value
pair.
Static metadata is reported only once, at the application startup. To provide support for reporting a changing metadata value, configure dynamic metadata.
To configure the device static metadata, define the following values:
Configuration Setting | Description |
---|---|
id | Metadata identifier. |
value | Metadata value. |
Optionally, you can configure the following metadata settings:
Configuration Setting | Description |
---|---|
custom_prefix | Prefix of the MQTT topic that the object is reported to. An option to publish data to a custom MQTT topic for a local data processing or directly to the northbound interface. For example, if it is set to analytics for metadata serial_number , all data is published to the topic analytics/{did}/metadata/serial_number . It overrides the global custom prefix. |
It is mandatory to define the device ID (
did
) for each device. Thedid
value must match the UUID of the device created in the relayr Cloud.
For more information on creating devices in the Cloud, refer to the relayr Cloud API documentation.
The device
did
cannot contain spaces and plus (+) characters.
Here is an example of the device static metadata:
"metadata": [
{
"id": "did",
"value": "f33c6bah-b31e-4f5a-964h-13a935a8b25f"
}
]
Dynamic Metadata
Dynamic metadata is configured with a protocol-specific object
.
Dynamic metadata is published only if its value changes.
To report a metadata value dynamically, configure the following settings:
Configuration Setting | Description |
---|---|
id | Metadata identifier. |
object | Protocol-specific object definition. See the EtherNet/IP Object Definition section for details. |
Optionally, you can configure the following dynamic metadata settings:
Configuration Setting | Description |
---|---|
custom_prefix | Prefix of the MQTT topic that the object is reported to. An option to publish data to a custom MQTT topic for a local data processing or directly to the northbound interface. For example, if it is set to analytics for metadata serial_number , all data is published to the topic analytics/{did}/metadata/serial_number . It overrides the global custom prefix. |
sampling_interval | Local sampling interval value, given in milliseconds, that overrides the global sampling interval. |
connection | Local connection ID used for given metadata. It overrides the global connection set for the device. Possible ID values are defined in the connections section of the configuration file. See the Configuring EtherNet/IP Connections section for details. |
Here is an example of the device dynamic metadata:
"metadata": [
{
"id" : "serial_number",
"object" : { ... },
"sampling_interval" : 4000,
"custom_prefix" : "v1/nb"
},
EtherNet/IP Object Definition
For each configured measurement and dynamic metadata, there is a protocol-specific object
configuration section, in which you configure the EtherNet/IP request settings.
For each request, it is necessary to specify a CIP path to the target object/class and a requested service code. If needed, the configuration allows you to specify data sent as request arguments. If a request is expected to return data, its format should be specified as well.
CIP specifies a number of services when configuring a request. To verify the service availability and the request/response structures, always refer to the target device documentation and the EtherNet/IP and CIP standard.
Mandatory Object Settings
In the EtherNet/IP Protocol Adapter, the following fields are mandatory to define an object
:
Configuration Setting | Description |
---|---|
path | Array specifying the connection path segments. The path is constructed retaining the order, using corresponding segment types. For the allowed path segments, see the Connection Path Segments section. |
service_code | Code of service to call on a target unit. Format: 8-bit hex as a string e.g. “service_code”: “0x01” . |
request_timeout | Timeout of a request, given in milliseconds. By default, 2000 . In accordance with the CIP standard, the request timeout for unconnected messages has the resolution of seconds, but the value should be given in ms and it will be rounded up by the adapter. |
To disable a timeout for a given request, set its value to 0. Note that if a response for such a request is not delivered for whatever reason, it will never be canceled, rendering the system partially or completely inoperable.
Example of the object configuration:
"measurements": [
{
"object": {
"path": [
{
"class": "0x01"
},
{
"instance": "0x01"
}
],
"service_code": "0x01",
"request_timeout": 100
},
Connection Path Segments
The following path segments are allowed in the EtherNet/IP Adapter object definition:
Logical:
“class”
(8-, 16-bit)“instance”
(8-, 16-, 32-bit)“attribute”
(8-, 16-bit)“member”
(8-, 16-bit)
Data:
“ansi_ext”
(extended ansi string symbol)
Other:
“raw”
(value under this key is used directly as a path)
All values must be given as strings, e.g.:
“class”
:“0xFF”
// 8-bit“instance”
:“0x00000000”
// 32-bit“attribute“
:“0x104F”
// 16-bit“ansi_ext”
:“ACT_TIME_T”
Optional Object Settings
In the object
configuration of the EtherNet/IP Protocol Adapter, you can include the following optional configuration settings of the request and response data:
Configuration Setting | Description |
---|---|
request_data_type | Type of data sent. Supported options are: “integer” “string” . If not specified, string is assumed. |
request_data_len | Size of data sent in bytes, given as an integer. If set to 0 or not specified, it is implicitly deduced. |
request_data | Data that is sent in requests. |
response_data_len | Size of an expected response in bytes. If not given, the value is 0 (auto size, try to use all available data). |
response_data_type | Type of expected data. Supported options are: integer , string , from_response . If not given, data is reported as a json array without any manipulation. |
The
from_response
option is used as theresponse_data_type
for services where the response has the following format:
Field Name | Size | Details |
---|---|---|
CIP Type code | 1 byte | For details, see the CIP Specification, Vol 1., Appendix C: Data Management, Table C-6.1 |
Info size | 1 byte | Count of words in the next field |
(info) | N words | Additional information e.g. CRC |
Data | X bytes | Actual data size depends on data type |
Examples of Configuration Files
Deployment Configuration File
{
"transport": "mqtt",
"mqtt_connection": {
"host": "localhost",
"port": 1883,
"keepalive": 20,
"max_inflight_messages": 100,
"qos_levels": {
"measurements": 0,
"alerts": 1,
"configuration": 1,
"metadata": 1
}
},
"postgres_connection": {
"database_name": "db",
"database_username": "user",
"database_password": "pass"
},
"health_monitor": {
"heartbeat_interval": 60
},
"pmq_connection":
{
"output_queues": ["/eip_out_queue"],
"input_queues": ["/eip_in_queue"],
"message_size": 8192,
"message_count": 10
}
}
Application Configuration File
{
"connections": [
{
"id": "OMRON",
"host": "10.10.6.40",
"port": "44818",
"timeout": 0
},
{
"id": "PROD",
"host": "10.10.6.192",
"port": 44818,
"timeout": 0
}
],
"devices": [
{
"connection": {
"id": "OMRON"
},
"measurements": [
{
"object": {
"path": [
{
"ansi_ext": "ACT_TIME_SEC"
}
],
"service_code": "0x4C",
"request_timeout": 500,
"request_data_type": "integer",
"request_data_len": 2,
"request_data": "1",
"response_data_size": 10,
"response_data_type": "from_response"
},
"id": "TIMES",
"sampling_interval": 5
},
{
"object": {
"path": [
{
"class": "0x01"
},
{
"instance": "0x01"
}
],
"service_code": "0x01",
"request_timeout": 1000
},
"id": "Identity",
"sampling_interval": 1000
}
],
"alerts": [],
"configuration": [],
"metadata": [
{
"id": "did",
"value": "Example1"
}
]
},
{
"connection": {
"id": "PROD"
},
"measurements": [
{
"object": {
"path": [
{
"class": "0x01"
},
{
"instance": "0x01"
}
],
"service_code": "0x01",
"request_timeout": 1000
},
"id": "Identity",
"sampling_interval": 1000
}
],
"alerts": [],
"configuration": [],
"metadata": [
{
"id": "did",
"value": "Example2"
}
]
}
]
}