Node programming task
With a node programming task, you can create data processing flows by dragging and dropping nodes. You can define relationships between device data inputs and outputs, filter data by setting properties, and split data streams. This topic describes how to create a node programming task.
Procedure
- Log in to the Data Analysis console and select task development in the top navigation bar.
- On the stream data task development page, click New Stream Data Task, configure the parameters, and then click Confirm.
Table 1. Parameter description Parameter Description Development Type Select node programming. Task Name The name of the node programming task. The name can contain Chinese characters, uppercase and lowercase letters, digits, underscores (_), hyphens (-), parentheses (), and spaces. The name must be no more than 40 characters in length. Task Description A required task description, up to 40 characters long. Usage Select whether the task runs on the cloud or edge. After you create the node programming task, the platform directs you to the stream data task development workbench. You can drag nodes to the canvas on the right to build your data flow.Note You can also go to the stream data task development page and click the task's card to open the node programming page.Node programming provides two required nodes, device input and output; two basic processing nodes, data filtering and aggregate computation; and two advanced nodes, anomaly detection and business table join.
You can use the toolbars at the top and bottom of the canvas to zoom in, zoom out, arrange nodes, and save your task.
NoteThe images in this topic show the default (light) theme. IoT Data Analytics allows you to customize the workbench theme. To do this, click the settings icon
in the upper-right corner of the workbench and select Dark Theme. - Each node programming task includes one input node and one output node by default. Click the input node icon to configure its parameters in the panel on the right.
Note Each node programming task supports only one device input node.
Select the product and device for the input node, and specify the required properties. The selected properties are then displayed in the output node.
To delete a node or a connection line, select it, right-click and select Delete, or press the Delete key.
Click the Input node in the flowchart. In the configuration panel on the right, enter a Node Name. From the Select Product drop-down list, select a target product, such as Geomagnetic Sensor. From the Select Device drop-down list, select a device scope, such as All Devices. In the Input Parameters section, select Property or Event and specify the scope of properties. After the configuration is complete, the Output Parameters section automatically lists the names and data types of your selected properties, such as time (TIMESTAMP), deviceName (STRING), longitude (DOUBLE), latitude (DOUBLE), and parkingStatus (ENUM). - Drag a data filtering node to filter out unwanted data.
Connect the output of the input node to the input of the data filtering node, and then click the data filtering node icon to configure its parameters.
The following example adds a data filtering condition: battery level is greater than or equal to 65.
You can then add another data filtering node with the inverse condition, for example, battery level is less than 65, to create a separate branch for the remaining data.
By using data filtering nodes, you can discard unwanted data or split a data stream into multiple branches.
- Connect an aggregate computation node to each of the two streams.
Configure the aggregate computation node: For Aggregation Granularity, select Single Device. For Dimension, select Device Name. For Measure, select Battery Level. For Aggregate Function, select Maximum and Minimum. For Time Window Type, select Sliding Window. After the configuration is complete, the data table at the bottom lists the following fields: time (TIMESTAMP), deviceName (STRING), batteryLevel_max (INT), and batteryLevel_min (INT).
Table 2. Parameter description Parameter Description Node Name The name of the aggregate computation node. Aggregation Granularity Specifies the granularity for aggregation. Valid values: - Single Device: Aggregates data for each selected device property individually.
- All Devices: Aggregates data for all selected device properties across the entire product.
Dimension Used for grouped statistics, similar to the GROUP BY clause in SQL. Only non-numeric properties are listed. Note If Aggregation Granularity is set to Single Device, Dimension defaults to Device Name.Measure Select numeric properties for aggregate computation. Aggregate Function Supported functions include maximum, minimum, average, and sum. Time window type Specifies a period of time over which to aggregate data. Two types are available: - Tumbling window: Data is processed in fixed, non-overlapping time windows. For example, if the window duration is 5 minutes, data is aggregated once every 5 minutes for the data within that interval.
- Sliding window: Data is processed in overlapping time windows. For example, if the window duration is 5 minutes and the sliding step is 2 minutes, data from the most recent 5-minute period is aggregated every 2 minutes. This means windows can overlap.
Window duration The length of the time window for the aggregation operation. Sliding step This parameter is required when the time window type is set to sliding window. It specifies the interval at which the window slides forward. - Add a data source output node to each stream to write the data to a database.
Click the data source output node to configure its settings.
Select an output data source and data table, and then map the output fields from the node to the corresponding fields in the data table.
For example, if you map the "operatingVoltage_max" field from the aggregate computation node to the "max_double" field in the table, the maximum operating voltage data will be available in the max_double field of the data table after export.Note The data type of a field in the data table must match the data type of the corresponding node field. Do not reuse fields in the table; each field must be mapped to a unique node field. - Click the Save icon above the canvas to save the task.
- After you finish configuring the task, click the Publish icon at the top.
Publishing the task starts a real-time data analytics process in the backend. The task continuously processes data and writes the results to the specified data table in your data source.Note If the task runs on the edge, you must also deploy the edge task as described in Stream Data Analytics on the Edge.
- (Optional) You can withdraw a published task.
Withdrawing the task stops the real-time data analytics process, and the data source output node no longer writes data to the data table. However, existing data in the table is retained.
Anomaly detection
This section describes how to create a task that uses an anomaly detection node.
- Drag a device input node and an anomaly detection node to the canvas.
- An anomaly is reported if the conditions of either rule are met. Two detection rules are supported: 'N consecutive points are less than threshold A' and 'N consecutive points exceed threshold B'.
- For the detection property, select a single numeric property, such as operating voltage.
For example, assume device 'a' reports data every 10 seconds, and detection rule 'b' is '3 consecutive data samples are less than threshold 9'. To collect 3 samples, a time period of 30 seconds is required.
If you want a larger sample size, for example, 6 times the required 3 samples, the time window must be at least 30 seconds × 6 = 3 minutes. This ensures at least 18 data samples. A 3-minute time window means that anomalies are detected within each 3-minute window by checking if any 3 consecutive samples out of the 18 are less than threshold 9. After one window closes, the next 3-minute window opens for detection.
- The output fields are time, detection rule, and anomaly data.
- Add a data source output node.
This allows you to output the detected anomaly data to the specified data table in your data source.
- Click the Save icon to save the task.
Business table join
This section describes how to use a business table join node.
Use a business table join node to import data from other data sources and enrich your dataset.
- Drag a device input node to the canvas.
- Drag a business table join node to the canvas and configure its parameters.
- Specify the data source you want to import by selecting a data source and a dimension table.
- Set the join type to determine how the tables are joined and to define the scope of the final dataset, as indicated by the shaded areas in the following figure. Two join types are supported: the left figure shows an inner join, and the right figure shows a left join.

- Add join conditions. You can only join two tables on primary keys of the same data type. You can add multiple join conditions.
- In the list, select the fields that you want to output. The primary key must be selected.
- Add a data source output node.
This allows the data to be output to the specified data table in your data source.
- Click the Save icon to save the task.