Async Professional |
|||||||||||||||||||||||||||||||||||||||||||||
State Machine ComponentsA state machine is simply a device or technique that receives input and acts upon that input based on the current condition of the device or technique. Async Professional uses state machines for a variety of tasks; such as managing protocol file transfers, sending and receiving faxes, collecting data packets, and monitoring the progress of a connection attempt. State machines are one of the fundamental techniques used for asynchronous communications, where a command is transmitted and the reply is received later in the session. Consider the simple task of initializing a modem to detect Caller ID information and answering a call. The first step (after opening the correct serial port) is to send a generic initialization command (“ATZ”CR), then wait for the modem to return either a success response (“OK”) or a failure response (“ERROR”). The next step is to send the AT command to enable Caller ID detection and text responses (“AT#CID=1”CR) and wait for either a success or failure response. Finally, the project waits for the modem’s ring indicator (“RING”), answers the call (“ATA”CR) and waits for the connection response (“CONNECT”). Each instance of a command and response can be thought of as a separate state in a state machine, as the following table illustrates.
A simple, two or three-state state machine is relatively painless to create. The state machine is usually driven by TApdDataPacket components monitoring for success or fail conditions. When TApdDataPacket’s OnStringPacket event is generated, the state machine progresses according to the collected data. Once a state machine grows to twenty or thirty states, with multiple conditions defining the state progression, the project code can get cumbersome, difficult to maintain, and hard to visualize. The TApdStateMachine and TApdState components exist in order to assist in the development of orderly, well-defined, and easy to maintain and visualize state machines. The TApdStateMachine component is a container for TApdState components. TApdState components contain conditions that determine the accepted input to drive the state machine. To aid in the visualization of your state machine, the TApdStateMachine and TApdState components are visual components, showing connection lines with captions and customizable colors. When the state machine is executing, the currently active state is highlighted to aid in debugging and to show the progression of the state machine. |
|||||||||||||||||||||||||||||||||||||||||||||
This document maintained by the Async Professional Project. |
|||||||||||||||||||||||||||||||||||||||||||||