This processor is supposed to read specific register values from a PLC device, and to generate NiFi records from these readings.
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, it compiles the Address Map into an Avro schema, and connects to the device, specified by the Connection Pool. Then reads the addresses from the device, and converts the results into a NiFi record, on success. Failing to read any of the specified registers count as an error, and in this case no record is generated, even if there is a partial result.
User can supply input FlowFile to this processor, by connecting it after another one. In this case, the attributes or the contents of the input can be referred in the Address Map, using Expression Language. Please note that, if Expression Language is present in the Address Map, the address syntax is not validated.
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 are fetched in a single pass.
The processor needs to compile the Address Map into an Avro Schema, which uses noticeable amount of the system resources for a short duration (a spike). Normally this is done only once, when the processor starts up.
With Expression Language, you can make the Address Map dynamic, that can require multiple schema versions to be generated, during execution. The Schema Cache stores these compilations in an associative FiFo array, so that the schemas are generated only once, if there are no more variations than the specified cache size.
Providing input is not necessary. In case you do, the processor will only read data, when an input FlowFile is available, and you can refer to the attributes of this file, when specifying the Address Map.
If input is not provided, the processor reads data as per Run Schedule.
In case of a successful reading, the emitted FlowFile contain a single NiFi record, written by the specified Record Writer. In case of failure, there is no output, if the processor has no ingress connection.
The failure relationship is only used, if the processor is driven by an input FlowFile, and was unable to read all the specified registers. In this case, the input FlowFile is forwarded as-is.
Note: Partial read results are always dropped.
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 |