Connect IoT - Control Flow Configuration Tutorial#
The goal of this tutorial is to showcase the use of the control flow designer in constructing integrations. It will use a file raw integration. The goal of the integration will be whenever a new file is created with a content of Test followed by a number, the integration will create a number of files equal to the number specified in the content with the file name being the number and the content being success. If the content does not contain the keyword Test, log saying file ignored.
Note
During this tutorial, the Automation Manager will run in console mode in order to highlight the most important events as they take place.
Automation Protocol#
The Automation Protocol will be quite simple, select the package @criticalmanufacturing/connect-iot-driver-fileraw in order to use the file raw protocol. Use the default configurations.
Note
Note that to do this in a real life context, it is important to have a general knowledge about the protocol, the equipment itself and its related documentation.
Automation Driver Definition#
The Automation Driver Definition will use the templates for the File Raw, as such it won't require any other configuration, besides depending on the previously created File Raw Protocol.
Note
Note that to do this in a real life context, it is important to have a general knowledge about the protocol, the equipment itself and its related documentation.
Automation Controller#
The Automation Controller will be of Workflow Type Control Flow. In the tutorial the entity type used was a of type Site. Use the File Raw Driver Definition previously created. In the Tasks, select also the File Driver Tasks.
Upon creating the Controller, the GUI will offer a default template for the driver created. This template will have the start cycle of the driver. In the Task Equipment Configuration, edit the path and provide the path for the watcher. For this tutorial the used path was c:/temp/Tutorial.
- In the page left panel select
Workflowsand then , selectControl Flow. Edit the page and rename the page to a more friendly name, for exampleOn New File - Read and Create File. -
Drag and drop the following tasks:
On Equipment Event: to listen to the Event "OnNewFile", to be notified on a new fileRead File: to read the file that was createdCondition: to perform conditional operationsCreate File: to create a new fileLog Message: to print the message into the console, in case the Temperature evaluation result is true
-
Go to the
On Equipment Eventsettings and for the Equipment Event, select the Event OnNewFile. -
Add the Read File Task as the next action. In Control Flow, all the context is available. You can either retrieve it from the general scope, or from a particular
Task. In this case, the Read Task will require the full path of the New File detected.Note
In
Control Flowitems in scope can be used using double curly braces and with dollar scope or dollar name of task, i.e {{\(scope.Test.Name}} or {{\)task_1.Test.Name}}. If the token is in the context of the task, as a setting or input, the token can be accessed directly for a setting or usinginput.for an input i.e {{path}} or {{input.path}}.Important
Only inputs and outputs are tokenizable. Currently, settings may not contain tokens, unless specific tasks mention that they can.
Note
Notice the caption is rendering the content of the input, even though it is described as {{ input.path }}.
-
Add a condition task. If the read task content includes a value
Test, it will be to process. -
In the
Ifcondition add an iterator task. This task will iterate through the content of the file after the keywordTest. To use tokens, we will add an inputend, with the token for the content of the read file task after theTest. The expression used will be{{ $readFile_5a9d.content.substring(size("Test")[0]) }}.Note
In
Control Flowtoken expressions allow for the use of more transformations. To apply transformation the engine applied is the mathjs ⧉ engine. For indexes, the 0 starting point will be used. -
In the
Iteratortask we can now add theCreate File. The goal will be to create a file with name of the index and with contentSuccess !!!. This file will be saved in the pathc:/temp/Tutorial/Finished. -
To finish our integration let us add a log message both for the else condition and for the end of the execution.
Execution#
Let`s now execute a run of our integration.
Drop a file with content Test3 in the c:/temp/Tutorial folder:
Notice that we see a new file being detected, the iterator being activated and creating three new files.
If we drop an invalid file:
It will not create any file and will log a warning notifying the user that it was not processed.
This tutorial tries to illustrate a simple use case for the use of control flow and how dynamic information can be propagated.









