PutPLC

Purpose

This processor is supposed to write new values to specific registers of a PLC device.

General Concept

This processor requires one or more input records, that specify the values to be written into the device. A minimum setup requires an enabled PLC4X Connection Pool, a Record Reader, and any number of registers defined in the Address Map (dynamic properties). During execution, it takes the next available FlowFile, connects to the device defined by the Connection Pool, and processes each record.

Every record is a write operation. The record fields, that should be written to the device must be defined in the Address Map. Fields not mapped to any register address, are ignored.

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 are written in a single pass.

If the input records have a hierarchical structure, you can select the fields you wish to use, by defining them as NiFi RecordPaths. It is also possible to refer specific record values in the register address, by enclosing RecordPath definitions in %{...} blocks, similarly to the use of NiFi Expression Language. For example, if your input records consist of a item and an address field, you can define a dynamic property with name /item (or simply item), and with value %{/address}, so you can write each of the records to different PLC registers, based on the input. Please note that register addresses cannot be validated, if they contain either EL or RecordPath expressions.

Output

The individual records are forwarded in new FlowFiles on 'success' and 'failure' relationships, based on their success status. The records are written by a Record Writer, which is required to be set. The original input is always forwarded as-is on the 'original' relationship, which is auto-terminated by default.

Type Mapping

Due to the limitations of Avro, some data types cannot be represented in the schema, and can not be mapped to the correct PLC4X value type. An unpleasant consequence is, that registers having incompatible data type, cannot be written by the processor. Please find the mapping below:

Mapping of Avro field types to PLC4X data types
Avro Type PLC Type Name Numeric Code (HEX)
booleanTypeBOOL0x01
intTypeINT0x22
longTypeLINT0x24
floatTypeREAL0x31
doubleTypeLREAL0x32
stringTypeSTRING0x43
arrayList (of first element type)0x62
bytesTypeRAW_BYTE_ARRAY0x71

PLC4X Documentation

PLC4X Support