Use the Combination Processor Function
You can use the Combination processor function to combine fields from different input processors into a single JSON string.
You have the following combination types:
- Combine selected fields: This option allows you to combine the selected number of fields from different input processors into a single JSON string.
- Combine all fields: This option allows you to combine all fields from different input processors into a single JSON string.
Review the following scenario for the combination processor function. Then, you will simulate PLC data and create combinations using input processors.
In your manufacturing plant, various PLCs control the production process for assembly lines, robotic arms, conveyor belts, and environmental controls. With the Combination Processor, you can merge the data from multiple or all PLCs into a single JSON string to get a complete view of the plant's operations.
Follow the steps to Connect a Device and configure the following parameters:
- Device Type: Simulator
- Driver Name: Generator
- Enable Alias Topics: Select the checkbox.
After connecting the device, add the following tags. See Add Tags to learn more. Each tag will represent one of the combination types mentioned above.
- Name: Select S - Random value generator
- Value Type: Select int64
- Polling Interval: Enter 5
- Tag Name: Enter Combine_selected_fields
- Name: Select S - Random value generator
- Value Type: Select int64
- Polling Interval: Enter 5
- Tag Name: Enter Combine_all_fields
You can now create the analytics flows using data from the device and tags you previously created. Follow the steps for either Step 3a or 3b, depending on whether you want to combine selected or all fields.
To create an analytics flow with the Combination Processor function:
- Navigate to Analytics.
On the analytics canvas, click Add processor. The Create a processor dialog box displays.
- Select DataHub Subscribe.
In the Topic field, click the Search icon, select the device you previously created, and then select the alias topic for the Combine_selected_fields tag.
- Click Save.
- Repeat steps 2-5 to add another DataHub Subscribe node. Select the alias topic for the Combine_all_fields tag.
- Click Add processor again and select Combination Processor. The following information defines this function:
- Combination Type: Select combine selected fields from the drop-down menu.
- What Timestamp to Take?: Select fresh timestamp from the drop-down menu.
- Fields to Combine: The fields to combine are defined as wire definition_fieldName. Enter combineselect_tagName, combineselect_value, combineall_tagName, combineall_value, with a comma as the separator.
Click Save.
- Connect the DataHub Subscribe processor (tag: Combine_selected_fields) to the Combination processor with a wire and enter the definition of combineselect for the connection.
- Connect the DataHub Subscribe processor (tag: Combine_all_fields) to the Combination processor with a wire and enter a definition of combineall for the connection.
- On the analytics canvas, click Save.
- Click Add processor again and select Combination Processor. The following information defines this function:
- Combination Type: Select combine all fields from the drop-down menu.
- What Timestamp to Take?: Select fresh timestamp from the drop-down menu.
- Fields to Combine: You may skip this field for this combination type.
Click Save.
- Connect the DataHub Subscribe processor (tag: Combine_selected_fields) to the Combination processor with a wire and enter the definition of combineselect for the connection.
- Connect the DataHub Subscribe processor (tag: Combine_all_fields) to the Combination processor with a wire and enter a definition of combineall for the connection.
- On the analytics canvas, click Save.
The configured analytics flows should look like the following after completing either Step 3a or Step 3b.
Click the View icon in the Combination processor to view combined field JSON strings on the analytics canvas.
The Combination processor returns a JSON string with the fields combineselect_tagName, combineselect_value, combineall_tagName, and combineall_value.
The Combination processor returns the full JSON string with all the fields from both input processors.