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.
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 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.
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.
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.
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.
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:
PLC Type Name | Numeric Code (HEX) | Avro Type |
---|---|---|
NULL | 0x00 | stringType |
BOOL | 0x01 | booleanType |
BYTE | 0x02 | intType |
WORD | 0x03 | intType |
DWORD | 0x04 | longType |
LWORD | 0x05 | stringType |
USINT | 0x11 | intType |
UINT | 0x12 | intType |
UDINT | 0x13 | longType |
ULINT | 0x14 | stringType |
SINT | 0x21 | intType |
INT | 0x22 | intType |
DINT | 0x23 | intType |
LINT | 0x24 | longType |
REAL | 0x31 | floatType |
LREAL | 0x32 | doubleType |
CHAR | 0x41 | stringType |
WCHAR | 0x42 | stringType |
STRING | 0x43 | stringType |
WSTRING | 0x44 | stringType |
TIME | 0x51 | stringType |
LTIME | 0x52 | stringType |
DATE | 0x53 | stringType |
LDATE | 0x54 | stringType |
TIME_OF_DAY | 0x55 | stringType |
LTIME_OF_DAY | 0x56 | stringType |
DATE_AND_TIME | 0x57 | stringType |
LDATE_AND_TIME | 0x58 | stringType |
Struct | 0x61 | stringType |
List | 0x62 | array (of first element type) |
RAW_BYTE_ARRAY | 0x71 | bytesType |