Creating a State Automaton

Beside the usage of Code Specifications, there is also the possibility to define the behavior of components in a graphical State Automaton Diagram.

Drawing States and Transitions

Once you have added a state automaton to your component and opened it, you might drag&drop a state from the right Model Elements View to your diagram. In the same way you can add ports to your states.

To move a state, pick the state somewhere in the middle and move it. Same for ports, just pick them and move around the border of the state. To resize a state, pick the lower, the right, or the lower-right point of its bounding-box and then move it.

In order to create transitions between two states, press the <alt>-Key on your keyboard and drag the transitions from one port to another port of different I/O-kind (i.e., Entry/Exit). If you drag from one state to another state, new ports will be created automatically and the transition will be created between the new ports. Invalid transitions (e.g., between two Output/Exit-Ports) are avoided by disabling the dragging.

You should declare one state as initial. This can be done in the Properties View after you selected a state. This state is marked with a little black dot. If you forget to declare a state as initial, or if you declare more than one state as initial, this is detected by AutoFOCUS after you have saved the project. In this cases, an Error marker will be shown in the Model Markers View.

In the Properties View, you can edit the names of selected states, transitions and ports. You can also specify comments.

You can change the route of transitions by selecting it, pick the point shown in the middle and move it. Afterwards, two new points are shown between the moved middle point and the two ports. By moving these points, you can further define the route more precisely.

Note: Dragging&dropping a state inside a state, yields a Hierarchical State Automaton.

Data State Variables

Data State Variables (DSVs) are internal variables that can be accessed in all states of the corresponding state automaton. To add such a variable to a state automaton, click the Data State tab in your State Automaton View. Press the Add-Button to add a DSV.

You may give a variable name, a type of the variable and an initial value. Valid types are int, double and boolean. Invalid types are detected and an error message is given.

Defining Guards and Actions

If the component is in a state that has multiple outgoing transitions, it has to be specified which transition is used at the next step. This is done by specifying Guards of transitions. If no Guard of an outgoing transition is fulfilled, the state keeps active. If multiple outgoing transition guards would be fulfilled, this would result in a non-deterministic behavior. AutoFOCUS provides a Non-determinism analysis to detect this.

If a guard is fulfilled and the transition is fired, a defined Action is executed. There can be multiple Actions separated by ';'.

If you have created a complex transition and want to reuse it again as another transition, you may use the copy&paste buttons in the properties view of a transition. Press copy for a transition, then create a new transition somewhere and finally press paste in this new transition. All settings of the copied transition (Guards and Actions) will be inserted into the new transition.

It is also possible to define Idle actions at states. These actions are fired in every simulation step, if the state is active and no outgoing transition guard is fulfilled. For valid syntax, please look at the above example screen shot. E.g., Green() is a Enumeration Member defined in the Data Dictionary. Of course, syntax checking is also provided for guards and actions.