Official | HULFT IoT EdgeStreaming Reverse Reference First Edition: July 1, 2021
Execute processing based on the timing when the input values are written to all the columns
This section describes the process for queuing asynchronous data by combining the writing of data to the table with the table record monitoring function.
This process outputs results such as the following:
- Example: if "interval" is "1" and temporary table content is output when the values are written in all the columns of the table.
-
The content of the file targeted for monitoring is input into the temporary table every second, and the temporary table content is output when the conditions are met.
Description of the processing
Asynchronous data is queued by combining the writing of data to the temporary table with the temporary table record monitoring function.
Here, the flow to create the processing is shown below.
1. Create a temporary table that contains the following three columns: "time", "uniqueNumber", and "Name".
The component icon that is used is Writing.
2. Create a process that obtains the current time and automatically incremented number every second and writes them to the temporary table columns "time" and "uniqueNumber."
The component icons that are used are Periodic event and Writing.
3. Create a process that monitors the targeted file, obtains the time when a line is written to the file, and then writes the value to the temporary table column "Name."
The component icons that are used are Monitoring of File Update operation and Writing.
4. The values written using the stream flows of 2. and 3. are joined with the "time" column as a key. Create a process that outputs values to the standard output when the values are written in all three "time," "uniqueNumber," and "Name" columns.
The component icons that are used are Monitoring records and Standard output.
Key features (component icons)
- Writing
-
This component can be used to set the properties of the write operation.
It can be set from Basic > Temporary table > Writing of the tool palette.
- Periodic event
-
This component can be used to set the interval at which events are executed.
It can be set from Basic > Basic > Periodic event of the tool palette.
- Monitoring of File Update operation
-
This component can be used to set the properties of the monitoring file updates operation.
It can be set from File > Basic > Monitoring of File Update of the tool palette.
- Monitoring records
-
This component can be used to set the properties of the record monitoring operation.
It can be set from Basic > Temporary table > Monitoring records of the tool palette.
- Standard output
-
This component can be used to set the properties of the standard output operation.
It can be set from Basic > Basic > Standard output of the tool palette.
Key features (Mapper logic)
- Current date/time (OS time zone)
-
This logic outputs the current date and time.
It can be set from Date > Basic > Current date/time (OS time zone) of the tool palette.
- Date/Time formatting(Standard format)
-
This logic formats the date and time to the selected format.
It can be set from String > Date > Date/Time formatting(Standard format) of the tool palette.
- Increment
-
This logic increases the value by one and outputs the result.
It can be set from Number > Basic > Increment of the tool palette.
Operation procedure
In this example, the processing that is described in "Description of the processing" is used.
1. Configure a temporary table setting (global resource).
-
From the tool palette, drag and drop Basic > Temporary table > Writing onto the script canvas.
The New Writing operation dialog box is displayed.
-
For Table on the Required settings tab, select Add.
The New Temporary table settings dialog box is displayed.
-
Configure a temporary table as shown below and click Finish.
-
Click Add, and create three columns with the column names time, unique Number, and Name.
-
Enter a value in Data lifetime period and Cleanup interval.
In this example, "60" is entered for each.
-
-
Click Finish.
2. Create a stream flow so that the automatically incremented number and time are written to the temporary table every second.
-
Drag and drop Basic > Basic > Periodic event from the tool palette onto the script canvas.
The New Periodic event operation dialog box is displayed.
-
Enter "1" for Interval and click Finish.
3. On the script canvas, drag and drop the Periodic event icon onto the Writing icon.
If a message that prompts you to add mapping appears, click Yes.
The mapping_1 icon and the stream flow are created.
4. On the script canvas, double-click mapping_1.
The Mapper editor is displayed.
5. Drag and drop the following logics from the tool palette onto the Mapper editor:
-
Date > Basic > Current date/time (OS time zone) (to obtain the current date and time)
-
String > Date > Date/Time formatting(Standard format) (to specify the date and time format that you want to output)
-
Number > Basic > Increment (to output the automatically incremented number)
The logics are placed on the Mapper editor.
6. Enter the property of the placed logic.
-
Double-click the Date/Time formatting(Standard format) logic.
The Date/Time formatting(Standard format) Logic Property dialog box is displayed.
-
Select a format from the Format pulldown menu.
In this example, hh:mm:ss is selected.
-
If necessary, also enter a comment in Comment and click Finish.
-
If necessary, double-click the Current date/time (OS time zone) logic and the Increment logic, enter a comment in Comment, and click Finish.
7. Drag and drop the Current date/time (OS time zone) logic onto the Date/Time formatting(Standard format) logic.
The mapping link from the Current date/time (OS time zone) logic to the Date/Time formatting(Standard format) logic is displayed.
8. Drag and drop the Date/Time formatting(Standard format) logic onto the output destination (time in this example).
The mapping link to time from the Date/Time formatting(Standard format) logic is displayed.
9. Drag and drop the Increment logic onto the output destination (uniqueNumber in this example).
The mapping link to uniqueNumber from the Increment logic is displayed.
The configuration for mapping_1 is now completed. Return to the script canvas.
10. Create a stream flow for writing the obtained time and the content of a line to a temporary table when the line is written to a file.
-
From the tool palette, drag and drop Basic > Temporary table > Writing onto the script canvas.
The New Writing operation dialog box is displayed.
-
For Table on the Required settings tab, select the table added in step 1. .
-
Click Finish.
-
Drag and drop File > Basic > Monitoring of File Update from the tool palette onto the script canvas.
The New Monitoring of File Update operation dialog box is displayed.
-
For File name on the Required settings tab, specify the file targeted for monitoring file updates.
-
Click Finish.
11. On the script canvas, drag and drop the Monitoring of File Update icon onto the Writing icon.
If a message that prompts you to add mapping appears, click Yes.
The mapping_2 icon and the stream flow are created.
12. On the script canvas, double-click mapping_2.
The Mapper editor is displayed.
13. Drag and drop payload of the input source onto Name of the output destination.
The mapping link from payload to Name is displayed.
The configuration for mapping_2 is now completed. Return to the script canvas.
14. Create a stream flow that outputs values to the standard output when the values are written to all the columns in the temporary table.
-
From the tool palette, drag and drop Basic > Temporary table > Monitoring records onto the script canvas.
The New Monitoring records operation dialog box is displayed.
-
Set the targets for monitoring as follows:
-
For Table on the Required settings tab, select the temporary table created in step 1. .
-
For Monitoring target, select all the items in Data monitoring target.
-
-
Click Finish.
-
Drag and drop Basic > Basic > Standard output from the tool palette onto the script canvas.
The New Standard output operation dialog box is displayed.
-
Click Finish.
15. On the script canvas, drag and drop the Monitoring records icon onto the Standard output icon.
If a message that prompts you to add mapping appears, click Yes.
The mapping_3 icon and the stream flow are created.
16. On the script canvas, double-click mapping_3.
The Mapper editor is displayed.
17. Create the schema of the output destination.
In this example, create the "root" element under "stdout," and then create "time," "uniqueNumber," and "Name" as child elements of the "root" element.
-
Right-click the output destination stdout, and select Add root element from the menu.
The root element is created.
-
Right-click the root element, and select Add > Child element from the menu.
The Add output source element dialog box appears.
-
Enter "time" for Element name. Enter a Comment if necessary.
-
Click OK.
The time element is created under root.
-
Use the same steps as for time to create the uniqueNumber element and Name element under root.
18. Drag and drop the following items from the input source onto the output destination:
-
time of the input source to time of the output destination
-
uniqueNumber of the input source to uniqueNumber of the output destination
-
Name of the input source to Name of the output destination
19. Save the script.
For information about how to save a script, refer to First Step Guide.
When the script is executed, the values for "time," "uniqueNumber," and "Name" are output together as standard output according to the timing when one line is written to the file targeted for monitoring.
{"stdout":{"Name":"product027","time":"08:49:27","uniqueNumber":3}}
Official | HULFT IoT EdgeStreaming Reverse Reference First Edition: July 1, 2021