All Products
Search
Document Center

IoT Platform:Configure adjacent message computing

Last Updated:Nov 01, 2024

After parsing data from the source node with an expression or filter node, the adjacent message computing node can be utilized to perform calculations on a specific numeric field (supporting only BIGINT and DOUBLE types) from both the current and previous messages. The computed values are then assigned to a designated output field, enriching the data for further analysis or output.

Scenarios

Consider a smart meter that reports the cumulative electricity consumption value every hour. To determine the hourly incremental electricity consumption (kwh), the adjacent message computing node can be used to calculate the difference between the current and previous reported values.

Prerequisites

Ensure that data calculation expressions or data filtering filters are set up. For more information, see Configure data computing and data filtering.

Background information

Procedure

  1. Access the data parsing console.

  2. In the middle canvas, click the add icon following the current node.

  3. In the node list that appears, single click the Adjacent Message Computing node.

  4. Single click the Adjacent Message Computing node on the canvas. On the right configuration panel, set up adjacent message computing as detailed in the table below.

    Configuration Item

    Parameter

    Description

    Example

    Basic Configuration

    Previous Variable Field

    Select a numeric field from the previous message for use in the expression calculation.

    This field's value is denoted by ${pre_var} in the expression.

    Important

    Only numeric types (BIGINT, DOUBLE) from the output fields of the preceding node are supported.

    For an electricity meter scenario: select the kwh field here.

    Current Variable Field

    Select a numeric field from the current message for use in the expression calculation.

    This field's value is represented by ${current_var} in the expression.

    Important

    Only numeric types (BIGINT, DOUBLE) from the output fields of the preceding node are supported.

    For an electricity meter scenario: select the kwh field here.

    New Field Name

    Designate a name for the field where the adjacent message calculation result will be stored for output.

    Accepts numbers, letters, and underscores, must not start with a number, avoid existing field names, and limit to 30 characters.

    For an electricity meter scenario: name the field kwh_diff to represent the hourly incremental electricity consumption.

    Calculation Expression

    Define the expression for calculating the values of the Previous Variable Field and Current Variable Field.

    To represent the values of the Current Variable Field and the Previous Variable Field, you must use ${current_var} and ${pre_var}, respectively.

    Supports basic operations and all functions available in the expression node.

    For an electricity meter scenario: calculate the incremental consumption by subtracting the previous value from the current value.

    The expression is: ${current_var} - ${pre_var}.

    Advanced Configuration

    Message Partition Key

    Optional, specifies the fields within the same topic to be grouped for adjacent calculation.

    If unset, ProductKey and DeviceName are used by default as the partition key by the IoT Platform.

    For an electricity meter scenario:

    Group the reported kwh messages from the same meter for adjacent calculation, using the meter's ProductKey and DeviceName. Leave blank if appropriate.

    If data is reported through a gateway device and identified by a deviceId field, set deviceId as the partition key to ensure accurate adjacent calculations for the meter.

    Message Lifetime

    In seconds, defaults to one day, with a minimum of 1 second and a maximum of 30 days.

    • If no new message arrives to refresh the previous variable field within this time, the field will be purged. The lifetime is updated with each received message.

    • Should the previous variable field be purged due to elapsed time, the next message is treated as the first data point, and by default, no adjacent calculation is performed, resulting in an empty output value.

    For an electricity meter scenario: use the default lifetime of 86400 seconds.

    Below is a specific configuration example for the "Scenarios":

  5. Single click Save in the upper right corner of the Data Parsing Workbench to finalize the adjacent message computing node configuration.

    Important

    The output field of this node includes the newly set result field name and the output field from the previous node.

What to do next

Once the adjacent message computing node is configured, proceed to set up additional processing nodes or configure target nodes to complete the data parsing task.