# AlignPlus Communication Workflow

In order to execute the various vision tasks in the vision application, command strings, whose format is defined in the Communication Protocol document, can be sent over a TCP/IP channel to the vision application by the customer PLC. Alternatively, other forms of communication can be used. However, the communication data should be converted into the equivalent AlignPlus command string. In return, the execution results will be sent back to the PLC in the form of strings through the same or a different TCP/IP channel depending on whether the tasks are executed in synchronous or asynchronous mode.

The TCP/IP communication procedures in synchronous and asynchronous mode are described below.

## Using Synchronous Mode

In synchronous mode, tasks are executed one by one sequentially, therefore, it takes longer time to finish executing all the tasks compared with asynchronous mode. Synchronous mode is recommended when execution sequence is more important than execution time. For example, hand-eye calibration should be finished before its unified cross calibration starts. Feature training is often executed synchronously since it requires many manual checks. In this mode, all command strings and result strings are sent in and out through the same TCP Server named CommandsFromPLC. The steps are:

1. A external device sends a command string to CommandsFromPLC.

2. The vision system decodes the command string to identify which task to call, and which execution mode to use.

3. The vision system sends an acknowledge string back to CommandsFromPLC so that the external device knows the command has been received.

4. The vision system runs the requested task and gets the results.

5. The vision system compiles the results into a string and sends it back to CommandsFromPLC

6. The external device receives the result string from CommandsFromPLC.

## Using Asynchronous Mode

In asynchronous mode, independent tasks can run asynchronously to reduce total time consumed by the vision system. Asynchronous mode is recommended during run time when reducing execution time is very important to the application. In this mode, two TCP/IP channels are used for data exchange: CommandsFromPLC receives commands from an external device and sends back the acknowledge string, ResultsToPLC only sends the result string back to the external device. This makes the external device be able to have separated channels to send or receive strings without waiting for each other, thus renders communication smoother.

The steps are:

1. An external device sends a command string to CommandsFromPLC

2. The vision system decodes the command string to identify which task to call, and which execution mode to use.

3. The vision system sends an acknowledge string back to CommandsFromPLC so that the external device knows that the command has been received.

4. The vision system runs the requested task and gets the results.

5. The vision system compiles the results into a string and sends it to ResultsToPLC.

6. The external device receives the result string from ResultsToPLC.

Whether to execute a task in asynchronous mode is encoded in the command string the external device sends to the vision system, together with other information such as task's ID, execution mode, stage's pose, etc. From here on, we will walk through how to get these pieces of information, how to make a command string, and which command should be used for which execution purpose.