How-To Guides
Analytics Guides

Use the Combination Processor Function

11min

You can use the Combination processor function to combine fields from different input processors into a single JSON string.

Understanding Combination Types

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.

User Scenario

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.

Step 1: Add a Device

Follow the steps to Connect a Device and configure the following parameters:

  • Device Type: Simulator
  • Driver Name: Generator
  • Enable Alias Topics: Select the checkbox.

Step 2: Add Tags

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.

Tag 1: Combine_selected_fields

  • Name: Select S - Random value generator
  • Value Type: Select int64
  • Polling Interval: Enter 5
  • Tag Name: Enter Combine_selected_fields

Tag 2: Combine_all_fields

  • Name: Select S - Random value generator
  • Value Type: Select int64
  • Polling Interval: Enter 5
  • Tag Name: Enter Combine_all_fields

Step 3: Create Analytics Flows

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:

  1. Navigate to Analytics.
  2. On the analytics canvas, click Add processor. The Create a processor dialog box displays.

    The Add processor option
    The Add processor option
    
  3. Select DataHub Subscribe.
  4. 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.

    Create a Processor dialog box
    Create a Processor dialog box
    
  5. Click Save.
  6. Repeat steps 2-5 to add another DataHub Subscribe node. Select the alias topic for the Combine_all_fields tag.

Step 3a: Configure JSON String for Selected Fields

  1. 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.
  2. Click Save.

    Combination Pocessor dialog box
    Combination Pocessor dialog box
    
  3. 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.
  4. 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.
  5. On the analytics canvas, click Save.

Step 3b: Configure JSON String for All Fields

  1. 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.
  2. Click Save.

    Combination Pocessor dialog box
    Combination Pocessor dialog box
    
  3. 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.
  4. 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.
  5. On the analytics canvas, click Save.

The configured analytics flows should look like the following after completing either Step 3a or Step 3b.

Completed Analytics Flow
Completed Analytics Flow


Step 4: View Output of Processor

Click the View icon in the Combination processor to view combined field JSON strings on the analytics canvas.

View Combined JSON String for Selected Fields

The Combination processor returns a JSON string with the fields combineselect_tagName, combineselect_value, combineall_tagName, and combineall_value.

Selected Fields in Output
Selected Fields in Output


View Combined JSON String for All Fields

The Combination processor returns the full JSON string with all the fields from both input processors.

All Fields in Output
All Fields in Output