ConsumePLC

Purpose

This processor is supposed to listen to events, generated on the PLC device, or in the loaded driver, and to generate NiFi records from these.

General Concept

A minimum setup requires an enabled PLC4X Connection Pool, a Record Writer, and any number of registers defined in the Address Map (dynamic properties). During execution, the processor configures the device driver to listen to events, associated with the specified registers. Most drivers create a background thread for this, which monitors the device. The events are asynchronously collected into an Event Queue, of which contents FlowFiles are generated, with each event converted to a NiFi record. The number of these records per FlowFile is limited by the Batch Size. The frequency of output is controlled by the Run Schedule.

Address Map

Address Map is defined as Dynamic Properties in the processor settings. Validation fails, if there is none defined. The generated record consists of fields, and the mapping defines which field should contain which PLC register's value. The name (key) defines the record field, the value defines the PLC register's address. (Please refer to the Driver documentation, to find the required address format.) You can define any number of fields, all of these will be monitored for events.

Event Types

There are 3 types of events supported by PLC4X technology:

Note: Not all drivers support all subscription types, or subscription at all. Refer to the driver documentation.

Event Queue

The events are collected into the memory, therefore it does not survive NiFi restarts, or fail-overs. The maximum number of collected events between processor schedules can be limited by configuration. In such case, when the queue is full, it does not store any more events, until at least one FlowFile is generated. This can cause data loss, so pick the value with care.

Output

In case of there is at least one event in the queue, the emitted FlowFile contain a number of NiFi records, written by the specified Record Writer. In case of any failure, there is no output.

Type Mapping

Due to the limitations of Avro, some data types are translated into plain string value, and the correct type information is not carried over in the generated records. You can find the exact mapping below:

Mapping of PLC4X data types to Avro field types
PLC Type Name Numeric Code (HEX) Avro Type
NULL0x00stringType
BOOL0x01booleanType
BYTE0x02intType
WORD0x03intType
DWORD0x04longType
LWORD0x05stringType
USINT0x11intType
UINT0x12intType
UDINT0x13longType
ULINT0x14stringType
SINT0x21intType
INT0x22intType
DINT0x23intType
LINT0x24longType
REAL0x31floatType
LREAL0x32doubleType
CHAR0x41stringType
WCHAR0x42stringType
STRING0x43stringType
WSTRING0x44stringType
TIME0x51stringType
LTIME0x52stringType
DATE0x53stringType
LDATE0x54stringType
TIME_OF_DAY0x55stringType
LTIME_OF_DAY0x56stringType
DATE_AND_TIME0x57stringType
LDATE_AND_TIME0x58stringType
Struct0x61stringType
List0x62array (of first element type)
RAW_BYTE_ARRAY0x71bytesType

PLC4X Documentation

PLC4X Support