UML state machine

The state diagram (English state diagram ) of the UML is one of the 14 types of charts this modeling language for software and other systems. It represents a finite state machine in a UML special form graphically and used to either specify the behavior of a system or the permitted use of the interface of a system.

The diagram form used in the UML is a variant of the state transition diagram. In addition to this diagram form is available in the computer science and telecommunications a number of other forms that are not fundamentally well but differ in the expressiveness.

  • 4.1 behavior state machine
  • 4.2 protocol state machine

Theoretical foundations

The pictured in UML state diagrams type of state machine is an object- based variant of Harel Statecharts taken and extended by the UML. UML state machines overcome the essential limitations of traditional finite automata with retention of their biggest advantages. The UML state diagram introduces the new concepts of hierarchically nested so far states and orthogonal regions and extends the notion of action accordingly. UML state machines have both properties of Mealy and Moore automata. They support actions that depend both on the state of the system and a triggering event, as in Mealy machines, as well as entry and exit actions, which are more status- as action-oriented, as in Moore machines.

Description

A state diagram shows an overview of the states of the state machine shown - on can take at runtime and are the basis of what events or changes in state transitions take place - for example, a single object or a ( sub) system. This describes a state diagram of a hypothetical machine ( finite automaton ), which is located at any point in a class of finite states.

The states in a state diagram (often in other forms outside of UML diagram also circles, ellipses or simple rectangles ) are represented by rectangles with rounded corners. The possible state transitions are indicated by arrows between the states. They are labeled with the events that lead to the respective state transition.

Elements

The state machine shown in a graph consisting of nodes ( engl. vertex ) and (status ) transitions ( transitions engl. ) connecting a source and a destination node. Each node is either a state (known state) or a so-called pseudo - state (known as pseudo- state).

Is a state diagram with states of a graph as nodes and state transitions as the edge. , A state is shown in the graph as a square with rounded corners and labeled with the name of the condition. If an object is in a state, all so-called internal activities can be performed on this object that are specified in this condition. In this case the representation of the state is divided into two. In the upper part of the rectangle the name of the state can be recorded. In the lower section may, inter alia, internal activities are listed, where an activity can contain multiple actions. A state models a situation in which a specific, immutable condition applies. In most cases, this invariant is only given implicitly, one wants to formulate explicitly, you can assign them as a limitation the state.

Three behavioral specifications state, for example in the form of an activity or interaction can be associated with:

  • A behavior that will be executed when the state machine enters the state (known as entry behavior )
  • A behavior that is executed when the state machine leaves the state (known as exit behavior )
  • A behavior that is performed while the state machine is in state (known doActivity )
  • A behavior that is executed when a specific event occurs. ( eng. event behavior )

In contrast to the first three conduct an actual event will be indicated in the status event behavior. ( example: mouseover / peep )

Graphically, a state is usually represented as a rectangle with rounded corners, but slightly different forms of representation are also possible, see examples in the illustration at right.

Transitions

A transition (transition ) connects a source and a destination node. The transition can be assigned to a behavioral specification that describes the behavior that is executed when the transition is executed. This behavior is called effect ( engl. effect). A guard expression (german guard) can protect the Transition: the transition can only be executed if the guard expression is true.

Internal transitions and external transitions

There are two types of state transitions, ie transitions, namely inner and outer transitions transitions. Inner transitions indicate the response to an event that an activity, but not triggering a state transition. Since there is no change of state, no entry or exit activities are carried out. entry and exit activities are modeled in the same notation, but need the key entry and exit rather than the name of the triggering event to indicate that the particular activity is performed when entering or exiting the state. Internal transitions are modeled within states. If in response to an event, a state come and go a different state, it is called an outer transition. In the course of the state transition of any exit activities of the source state and the target state entry activities are carried out. A special outer transition is self transition, in which the source state and the target state are identical. Figure shows examples of internal and external transitions.

History - state

History states are used when, after an outer transition that leads out of a complex condition to be found back again later to the same substate that was active before the occurrence of the transition. The history state remembers which substate of a complex state was last active. Performs a transition from outside to the history state, so this enabled the "old" substate and all entry activities are performed sequentially from the outside to the inside. A history state can have any number of incoming edges, but only one outgoing edge. The outgoing edge must not have any events and any conditions and has as its goal the substate that will become active if the complex state had not previously been active and therefore not a " last active substate 'exists, or if the complex state last regularly over the reach a final state was left. There are two types of history states, the flat and the deep state history History state. Each complex state may only be a maximum of a flat and have a deep history state. The shallow history state represents the state restore on the same level in the complex condition which is directly as the shallow history state itself, the deep history state, however, is the last active substate over the entire nesting noted time.

Syntax

Event (arguments) [condition ] / activity

Pseudo - states

The pseudo- state is a control element which influences the flow of a state machine. In a pseudo- state as opposed to a real state, there are no values ​​assignments.

The UML2 recognizes the following pseudo - states:

  • The starting state (known as initial)

Has no incoming transitions and exactly one outgoing transition that indicates in which state started.

  • The terminator ( engl. terminate )

Has no outgoing transitions. The object is modeled its behavior ceases to exist.

  • The union ( engl. join)

Association of the control flow of multiple parallel states

  • The fork ( fork german )

Splitting of the control rivers into several parallel states

  • The intersection ( engl. junction)
  • The decision ( engl. choice)

Nodes can arise from the several alternative transitions.

  • The entry point (English entryPoint )
  • The exit point (English exit point)

Historical states can store those internal state in a complex state of which the transition is assumed (before interruption). At a later stage can be returned to this state, transitions from the higher-level states, wherein all entry operations are carried out again.

  • The deep history (german deep history)

In the deep history state, all states over the entire nesting are stored away.

Examples of state diagrams

Behavior state machine

A behavioral state machine (german behavioral state machine ) models the behavior of a model element. The state machine in the picture to the left for example, specifies the behavior of a washing machine.

Protocol state machine

A protocol state machine (german protocol state machine ) specifies acceptable use of the behavioral features of a classifier.

In the left figure, for example, is a Web service specified, can be booked through the flights. Specifies the assigned protocol state machine, the order in which the operations of the Web service to be invoked. From the specification is clear, for example, that a flight can be booked only if it has been reserved successful or that a once booked flight can not be deleted.

662948
de