# Common Sub Tasks

The following subtasks are common subtasks that are used in many different tasks.

## Commands Subtask

When a command string is received by the CommandHandler script, an equivalent CommandArgs object is created. This object contains all the data that is needed to execute the target task. The task scheduler passes the CommandArgs object to the target task and the object is made available to the task by the Command subtask. The Command subtask makes the object available in its output pin, and also publishes it as a tag. Various components within the task either use the tag or the output available at the pin to act appropriately. For example, a downstream subtask may use the tag to implement a Condition expression that conditionally executes the task. Or, the customer can intercept the object that is available at the output of the subtask to add any additional data that are required by their customizations.

The output of this subtask is the received command.

Output | Type | Description
--- | --- | ---
Command | CommandArgs | Received command from CommandHandler for current task

## Acquisition Subtask

Acquisition subtask acquires images in calibration tasks and feature finding tasks at given acquisition position encoded in the EncodedID of a command string and consequently in the CommandArgs object that is output by the Command subtask.

The input is current command which comes from Command subtask. Acquisition subtask only acquires images at given position index specified by input command.

Input | Type | Description
--- | --- | ---
Command | CommandArgs | Current input command of the task

The outputs are acquisition settings of current task, current command and image collection, as well as accumulated commands and images collections at all already acquired positions.

Output | Type | Description
--- | --- | ---
AccumlatedCommands | List<CommandArgs> | Accumulated commands that have been sent to Acquisition subtask to acquire a whole set of images at all acquisition positions.
AccumulatedImageCollection | List<CogImageCollection> | Accumulated images acquired at different acquisition positions.
AcquisitionSettings | AcquisitionSettings | The acquisition settings for current task, which includes camera indexes, camera enable/disable status, exposure time and position indexes.
Command | CommandArgs | Current command of the task, it's the same with the input Command.
ImageCollection | CogImageCollection | A collection of images acquired at current position index.

## Raw Image Display Subtask

Raw Image Display subtask creates raw image records(images captured by the cameras, without graphics) that will be shown on feature finder's display if user choose to display raw images.

Its inputs are the same with Acquisition subtask's outputs.

Input | Type | Description
--- | --- | ---
AccumlatedCommands | List<CommandArgs> | Accumulated commands that have been sent to Acquisition subtask to acquire a whole set of images at all acquisition positions.
AccumulatedImageCollection | List<CogImageCollection> | Accumulated images acquired at different acquisition positions.
AcquisitionSettings | AcquisitionSettings | The acquisition settings for current task, which includes camera indexes, camera enable/disable status, exposure time and position indexes.
Command | CommandArgs | Current command of the task, it's the same with the input Command.
ImageCollection | CogImageCollection | A collection of images acquired at current position index.

## ImageSaver2 Subtask

Image Saver2 subtask accumulates raw images and their corresponding commands every time when images arrive. The accumulated data would get cleared when a subsequent Image Saver2 Sync Trigger subtask executes.

Its inputs include command, image collection and user data at current acquisition position, and acquisition settings of current task.

Input | Type | Description
--- | --- | ---
AcquisitionSettings | AcquisitonSettings | The acquisition settings for current task, which includes camera indexes, camera enable/disable status, exposure time and position indexes.
Command | CommandArgs | Current command of the task
ImageCollection | CogImageCollection | A collect of images acquired at current position index.
UserData | IEnumerable<KeyValuePair<String,String>> | Metadata which will be saved into CDB files, not used in current version.

## ImageSaver2 Sync Trigger Subtask

Image Saver2 Sync Trigger subtask saves all accumulated raw images and their commands, received by the Image Saver2 subtask, into TIF files if raw image saving function of current task is enabled. It also saves image records into JPG images when screenshot saving is enabled.

Its inputs include current command, overall OK/NG judgement for current part, and VisionPro records for each camera at each acquisition position.

Input | Type | Description
--- | --- | ---
Command | CommandArgs | Current command of the task
IsNG | Nullable<Boolean> | Whether those images are NG images
VisionProRecords | IReadOnlyDictionary<String, VisionProRecord> | A dictionary of images and their graphics for each camera at each acquisition position