Workflow Activities
Activities
The sequence workflow supports the execution of different activities, defined in each step. The different activity types are:
AcquireImageActivity
Activity that acquires an image from a camera setup in the CameraInterface service.
The activity requires a FileName, where the image must be saved. It is possible to use substitution values, where you can insert a workflow state as part of the filename. This is done by inserting {<workflow state>} in the filename parameter (see example later).
Optionally, it is possible to specify the following:
- ExposureUs : The image exposure measured in microseconds. Default is 15000. 
- ToBlob : Boolean flag, that determines if the file should be stored on the host file system or in blob storage. Default is host file system. 
- Container : If the image must be saved to blob storage, the container name must be specified. 
Example configuration:
{
    "name": "GetBrightfieldImage",
    "description": "Brightfield image acquire",
    "order": 2,
    "activityType": "CameraAcquireToFile",
    "parameters": {
        "filename": "img_bf_{Factory1.Line1.Id}.bmp",
        "exposureUs": "15000"
    },
    "stepOnError": 16
}If the workflow state "Factory1.Line1.Id" is 10, then the example configuration will produce an image with the name "img_bf_10.bmp". If the workflow state does not exist, the name will be "img_bf_Factory1.Line1.Id.bmp". If this activity fails, the next step will be number 16.
SetSceneActivity
Activity sets a lighting scene, as defined in the sequences configuration file.
- SceneId : The SceneId is a required parameter. 
Example configuration:
{
    "name": "SetBrightfieldScene",
    "description": "Set top light on",
    "order": 1,
    "activityType": "SetScene",
    "parameters": {
        "sceneId": "Scene1"
    },
    "stepOnError": 16
}The example changes the active scene to "Scene1".
UploadFolderActivity
Activity that triggers an upload of files from a source folder to a destination blob storage folder. Required parameters are:
- SourceFolder : Folder name that should be uploaded, from the base folder "/images/history". 
Optional parameters are:
- DestinationFolder : Source folder path is used, unless destination folder overrides this. Destination is always "<device id>/Images/<destination folder>". 
- Container : Defaults to "SyncFiles" container (that is used for upload to cloud), but is overridden by setting this parameter. 
- Table : Setting this parameter ensures that data is mapped and ingested to an ADX table. Defaults to empty (not ingested). 
- DataFormat : ADX ingestion format. Defaults to json. 
- Mapping : ADX ingestion mapping reference. Must be set if Table is also set. 
Example configuration:
{
    "name": "UploadFolder",
    "description": "Upload folders",
    "order": 3,
    "activityType": "UploadFolder",
    "parameters": {
        "sourceFolder": "2023-05-09",
        "destinationFolder": "destinationFolder",
        "container": "syncfiles",
        "table": "adxtable",
        "dataFormat": "json",
        "mapping": "adxmapping"
    },
    "stepOnError": 16
}The above example uploads all files and folders from the folder "2023-05-09" into the "destinationFolder" folder in the blob container "syncfiles".
BranchActivity
Activity that performs a workflow branch To prevent circular references, and thereby non-terminating workflows, only forward branches are allowed. Required parameter is:
- BranchTo : Order id of the step to branch to 
Example configuration:
{
    "name": "AlwaysBranch",
    "description": "Branch",
    "order": 3,
    "activityType": "Branch",
    "parameters": {
        "branchTo": "5"
    }
}The above example always branches to the step at order number 5.
ConditionalBranchActivity
Activity that performs a conditional branch, based on an equation To prevent circular references, and thereby non-terminating workflows, only forward branches are allowed. Required parameters:
- Expression : Symbolic expression, that must evaluate to true/false. Example: "a<b#a=state1;b=state2", where "state1" and "state2" are existing workflow states. 
- BranchOnTrue : Step order id to branch to, is expression evaluates to true. 
- BranchOnFalse : Step order id to branch to, is expression evaluates to false. 
Example configuration:
{
    "name": "ConditionalBranch",
    "description": "Conditional branch",
    "order": 3,
    "activityType": "ConditionalBranch",
    "parameters": {
        "branchOnTrue": "5",
        "branchOnFalse": "7",
        "expression": "a>b#a=state1;b=state2"
    }
}In the above example, the two workflow states state1 and state2 determines if the branch is to step 5 or 7. If state1 is larger than state2, the branch is to step order 5.
DelayActivity
Activity that performs a delay. Required parameter:
- DelayInMs : Delay specified in milliseconds 
Example configuration:
{
    "name": "Delay",
    "description": "Delay",
    "order": 3,
    "activityType": "Delay",
    "parameters": {
        "delayInMs": "50"
    }
}The above example performs a delay on 50 milliseconds.
EndWorkflowActivity
Activity that stops the workflow The activity can be configured to indicate workflow success or failure, based on optional parameters:
- SuccessFromState : workflow state (analog, digital or string value) 
- Success : activity parameter, indicating success 
If the optional SuccessFromState parameter is set, it overrides the Success parameter.
Example configuration:
{
    "name": "EndWithFailure",
    "description": "End Workflow with failure",
    "order": 3,
    "activityType": "EndWorkflow",
    "parameters": {
        "success": "false"
    }
}```
The above example ends the workflow execution and returns with an error. Another example is an ending workflow, where success is determined by a workflow state:
{ "name": "EndWithFailure", "description": "End Workflow with failure", "order": 3, "activityType": "EndWorkflow", "parameters": { "successFromState": "somestate" } }```
If the workflow state "somestate" is > 0, true or "true" (both digital, analog and string states are handled), then the workflow succeeds.
ExecuteModelActivity
Activity that executes a custom model. Required parameter:
- ModelName: Determines the model to execute, as configured in the OrchestratorModule. 
If the optional TimeoutInMs parameter is set, it overrides the default timeout of 30 seconds. The value is stated in milliseconds.
Example configuration:
{
    "name": "ExecuteModel",
    "description": "Executing vision model",
    "order": 10,
    "activityType": "ExecuteModel",
    "parameters": {
        "modelName": "VisionModel",
        "timeoutInMs": "20000"
    },
    "stepOnError": 16
}The above example executes a custom model named "VisionModel", with a timeout of 20 seconds.
PublishStateActivity
Activity that takes a state from the workflow state and publishes it as a measurement. The state can be either an analog, digital or a string measurment. Required parameter:
- TagName: specifies the name of the state that is sampled from the workflow state and published as a measurement. Optional parameter: 
- Value: If this value is set, it is used as a fixed value instead of the workflow state. Type is indicated in DataType property. 
- DefaultValue: If this value is set, it is used if the required state is not found in the workflow. Type is indicated in DataType property. 
- DataType: If fixed value or default is set, this value indicates state type. Valid values are "analog", "digital" and "string". Default is "string". 
Example configuration:
{
    "name": "PublishState",
    "description": "Publish state",
    "order": 10,
    "activityType": "PublishState",
    "parameters": {
        "tagName": "Area.Asset.SomeTag",
        "defaultValue": "20",
        "dataType": "analog"        
    }
}The above example publishes the workflow state "Area.Asset.SomeTag" as a measurement. If the workflow state does not exist, the default value of 20 is used. The data type is analog.
SetStateActivity
Activity that samples the latest measurement from a tag, and sets it into the workflow state. The state can be either an analog, digital or a string measurment. Required parameter:
- TagName: specifies the tag name of the measurment that is inserted into the workflow state. Optional parameter: 
- Value: If this value is set, it is used insted of latest measurement from tag. Type is indicated in DataType property. 
- DefaultValue: If this value is set, it is used of there are no measurements received from tag yet. Type is indicated in DataType property. 
- DataType: If fixed value or default is set, this value indicates measurement type. Valid values are "analog", "digital" and "string". Default is "string". 
Example configuration:
{
    "name": "SetState",
    "description": "Set state",
    "order": 10,
    "activityType": "SetState",
    "parameters": {
        "tagName": "Area.Asset.SomeTag",
        "defaultValue": "20",
        "dataType": "analog"        
    }
}The above example samples the latest values from the tag "Area.Asset.SomeTag" and inserts it into workflow state. If no measurements exist, the default value of 20 is used. The data type is analog.
WrapResultActivity
The activity is used to create a json file, that is enriched by different sources. The json output is based on a template, that is defined as a required input parameter. The template accepts the following replacement tokens:
- <STATE;stateid> : inserts a state from the workflow state (example: {"id": "<STATE;stateid>"}, where stateid is the id of the state in the workflow.) 
- <TEXT;FILE> : inserts text file content (example: {"textcontent": <TEXT;FILE>}, where FILE is the filename of the file to inserted.) 
- <JSON;FILE> json file content replacement (example: {"jsoncontent": <JSON;FILE>}, where FILE is the filename of the file to inserted.) 
If the optional parameter "FileName" is set, then the json content is saved to this file name. The json output is returned in the activity payload.
This is an example of a template, that inserts both json files, text files and workflow states into a nested output json document:
{
    "id": "<STATE;workflowid>",
    "payload1": <JSON;FILE1>,
    "payload2": <TEXT;FILE2>,
    "result": {
        "result1": "<STATE;Factory1.Line1.Reason>",
        "result2": "<STATE;Factory1.Line1.Output>"
    }
}Based on the above template, an example configuration looks like this:
{
    "name": "WriteErrorResultToFile",
    "description": "Write error vision output to file",
    "order": 19,
    "activityType": "WrapResult",
    "parameters": {
        "fileName": "result.json",
        "template": "{\"id\": <state;workflowid>,\"payload1\": <json;output.json>,\"payload2\": <TEXT;FILE2>,\"result\": { \"result1\": \"<STATE;Factory1.Line1.Reason>\", \"result2\": \"<STATE;Factory1.Line1.Output>\"} }"
    }
}The above example saves a new result.json file, based on the template.
EmptyActivity
Placeholder activity, that does not perform any operation. Optional parameter:
- ShouldFail : The activity can optionally be configured to always fail, if this is set to true. Default is false. 
Example configuration:
{
    "name": "EmptyActivity",
    "description": "DoNothing",
    "order": 9,
    "activityType": "None",
    "parameters": {
        "shouldFail": "true"
    },
    "stepOnError": 16
}The above example results in the activity failing, creating a branch to step 16.
Dependencies
Some activities do not have any external dependencies, whereas other activities require camera, lighting controller or access to the workflow state. The dependencies are:

New work item
Last updated
Was this helpful?