Sub-Schema State


Operator Menu Location: Sub-Schemas


Operator Bitmap:


Functional Description:
The State Sub-Schema operator enables the creation of state-transition diagrams to represent finite state machines or directed graphs. They can be used to implement flowcharts and/or sequential function charts.


A state-transition diagram consists of a set of State Sub-Schema operators interconnected by directed arcs (transitions). Each State Sub-Schema operator is associated with a sub-schema file that executes while the operator is active. Only a single state within a connected state-transition diagram may be active at any instant of time. The system will transition from the active state to another state when a logical condition associated with the transition arc that connects the two states is met. For example, consider a state-transition diagram having two states, A and B, and a transition arc T that connects state A to state B. The system will exit active state A to enter state B when transition T is true.


As indicated above, only a single State Sub-Schema operator within a state-transition diagram may be active at a given time instant. However, a schema may contain multiple disjoint state-transition diagrams that execute concurrently. (A schema may then contain multiple State Sub-Schema operators that are active at the same time, provided that they belong to disjoint state-transition diagrams.)


Each State Sub-Schema operator must be linked to or associated with a schema (.scm) file that contains the desired functional behavior to be executed while the operator is active. The sub-schema file is itself a collection of interconnected graphical operators that may include other State Sub-Schema operators and/or Function Block Sub-Schema operators (which may themselves contain sub-schema operators).


Unlike most operators, the State Sub-Schema operator is not configured thru a property sheet. Instead, its configuration is defined by attributes of the linked schema file and thru a drop-down menu. This drop-down menu is accessed by right-clicking on the operator icon graphic (i.e., the circle). It contains various commands to manage the operator's link to a schema file. For instance, to link an existing schema file to the operator, select the Link Existing Schema item, and use the File Open dialog to select the desired file.


The schema link is stored as a relative file path to the parent schema. The link can be manually edited by selecting the Edit Schema Link item from the drop-down menu. This command is useful if the schema file is renamed or moved to a different directory outside of the Design Pad environment. The schema link can be removed altogether by selecting the Unlink Schema item from the drop-down menu.


Once a schema file is associated with a State Sub-Schema operator, the file can be opened by double-clicking the left mouse button on the sub-schema graphic. The file can also be opened by selecting the Open Linked Schema item from the drop-down menu.

Every connected state-transition diagram must define a single state to serve as its Initial State. This state will be the active state when the schema first begins executing. When a State Sub-Schema operator is designated as the Initial State its graphic (gray circle) is stamped with a dark green dot.

Each transition arc must be associated with a Boolean Variable operator. The transition takes effect when the associated variable's value is HIGH. To associate a transition with a Boolean Variable operator, double-click on the arc to view the Transition Properties dialog shown below.

To make the link, first select the Scope of the Boolean Variable to populate the Variable drop-down combo. If the Scope is set to Local, then the drop-down combo will contain only Boolean Variable operators of Local scope found in the schema containing the transition arc. If the Scope is set to Module, then the drop-down combo will contain all Boolean Variable operators of Module scope found in any schema related to the module that includes the schema that contains the transition arc (including the parent schema linked to the module and any of its descendent sub-schemas). If the Scope is set to Global, then the drop-down combo will contain all Boolean Variable operators of Global scope found in any schema related to the node that includes the schema that contains the transition arc (including the parent schema linked to each module in the node as well as any of their descendent sub-schemas).


When a state is activated (i.e., when the system transitions into that state) the operators in the underlying sub-schema file can be configured to re-initialize or to continue executing where they left off when the state was last active. This distinction applies only to operators that have memory, meaning that the computation of their output value depends on information from the past. The Addition operator for instance has no memory since its output at time t is simply the sum of its inputs at time t. The Delay Element operator however does have memory since its current output value is equal to a past input value. For example, consider a sub-schema that contains a Delay Element operator that has its Time Delay Multiple property set to 1. If the sub-schema is configured to re-initialize upon activation, then the Delay operator's initial output will be equal to its user-defined initial condition. If the sub-schema is configured to retain its state upon activation, then the Delay operator's initial output will be equal to the input value it sampled just before the state last became inactive.


The activation behavior of a sub-schema is defined in its Sub-Schema Setup dialog---to view the dialog select the Sub-Schema Setup item from the Schema menu. The dialog contains a check-box control in its bottom left quadrant to set the initialization behavior. The other settings in the dialog box do not affect the behavior of the schema when linked to a State Sub-Schema operator.


The concepts described above are best illustrated by example. Consider a hardware interface file consisting of a Chameleon node with one ACP-1 AC Power Module and one DAM-2 Discrete Automation Module linked to the schema shown in Figure (a). The schema contains a single state transition diagram with three State Sub-Schema operators, labeled A, B, and C. State A is designated as the initial state as indicated by the dark-green stamp in its graphic. The system can transition from state A to state B, from B to A, from A to C, and from C to B, as indicated by the directed arcs that connect the states. The transition arcs are labeled with the name of a Boolean Variable operator that they are associated with (for instance, the arc from A to B is associated with the Boolean Variable named bABTransition). The transition occurs when the associated Variable operator value is HIGH.

(a)
The schema diagram of Figure (a) contains a state transition diagram as well as other operators to execute digital logic (two Digital Input operators feed an AND Gate block which feeds an LED Display operator). At each computation interval, the schema of Figure (b) executes these digital logic functions as well as all of the operators contained in the sub-schema file linked to the currently active State Sub-Schema operator.


Each of the states in the Figure (a) schema is linked to the sub-schema files shown in the figures below. State A is linked to StateA.scm (Figure b); state B is linked to StateB.scm (Figure c); and state C is linked to StateC.scm (Figure d).

(b)

(c)

(d)
When the schema of Figure ab) first executes (i.e., when the hardware powers up), state A is active. In the underlying sub-schema for state A, a Digital Input operator associated with the DAM-2 module's DI Channel 3 drives two Boolean Variable operators. These variables, named bABTransition and bACTransition are associated with transitions from state A to state B and state A to state C, respectively. When DI Channel 3 in the DAM-2 module is ON, the output of the Digital Input operator is HIGH, thereby setting variables bABTransition HIGH, and bACTransition LOW. With bABTransition HIGH the system transitions from state A to state B. (State A as implemented can be thought of as an IF...THEN statement: if DI Channel 3 is OFF, execute state C, otherwise execute state B.)
The sub-schema associated with state B and shown in Figure (c) simply monitors the DAM-2 module's top push-button and initiates a transition back to state A when the button is pressed.


The sub-schema associated with state C and shown in Figure (d) itself contains another state-transition diagram that executes a three-step command sequence. The sub-schema files associated with each state (labeled Step 1, Step 2, and Step 3) are shown below.

(e)

(f)

(g)
Note that the same schema file (StateC12.scm) is associated with states Step 1 and Step 2. The schema activates a relay and monitors a digital input to initiate a transition. When the schema is associated with state Step 1--Figure (e)--the- Relay operator is linked to the DAM-2 module's DO Channel 1 and the Digital Input operator is linked to the DAM-2 module's DI Channel 4. When the schema is associated with state Step 2--Figure (f)--the Relay operator is linked to the DAM-2 module's DO Channel 2 and the Digital Input operator is linked to the DAM-2 module's DI Channel 5.


The schema file associated with State Step 3 (StateC3.scm) is shown in Figure (g). It de-activates the two relay outputs activated during the earlier steps in the sequence, and sets the Boolean Variable operator named bCBTransition to HIGH. The latter action causes the state-transition diagram in its parent schema to switch from executing state C to executing state B.


The schema file StateC3.scm is configured to re-initialize its operators upon activation. As a result, each time the system enters state C in Figure (a), the entire sequence executes (first state Step 1, then state Step 2, and then state Step 3). If the schema file were not configured to re-initialize upon activation, then the system would immediately resume executing Step 3.


Drop-Down Menu Commands:
Namespace. This property is used to uniquely identify multiple instances of the same Variable operator. When Namespace is activated, this operator's name (see Set Label command below) is pre-pended to Variable operators in the sub-schema file (or its associated sub-schemas) that have their Pre-Pend Name property also set to Namespace. A more complete description of variable namespaces can be found in the operator reference section for Variable operators.

 
Link Existing Schema. Associates an existing schema file (.scm) with the operator.


Link New Schema. Creates a new schema file and associates it with the operator.


Edit Schema Link. Permits manual editing of the link to the associated schema file. This is useful when the file name or path is modified outside of the Design Pad environment.


Unlink Schema. Deletes the association between the operator and schema file


Initial State. Indicates if the state will be the active state when the system initializes.

Set State Label. A string label that identifies the operator. This name may be pre-pended to other operator names (e.g., FairNET Networking operators, Variable operators, etc.) to uniquely identify them. The name is also used in a module's Hardware Connection Window to specify the location of generic hardware operators that have been linked to that module.


Open Linked Schema. Opens the linked schema document in a new window. If the document is already open, activates the window.


Process Linked Schema. Executes the Process Schema command on the linked schema file. As usual, processing results (e.g., errors, warnings, and other information) is displayed in the Message Window.


Comments:
• Design Pad will issue an error on processing of a connected state-transition diagram does not contain a State Sub-Schema operator that is designated as the Initial State. That is, Design Pad will issue an error if no state has been designated as the initial state or if more than one state have been designated as such.
•If the active state contains two or more outgoing transition arcs with associated Boolean Variable operator outputs that are HIGH, the system may execute any one of the enabled transitions (generally the first it encounters in its search).
•The currently active State Sub-Schema operator in a state-transition diagram executes with the same periodicity as the rest of the operators in the schema. The Periodic Compute Time setting in the lower left quadrant of the Sub-Schema Setup dialog does not apply to the State Sub-Schema operator.
•The input and output variable definitions in the upper half of the Sub-Schema Setup dialog do not apply to the State Sub-Schema operator.


See Also:
Function Block Sub-Schema