UML State machine Diagram

Source: Internet
Author: User

State machine Diagram

The state machine diagram models the behavior of a single object, indicating the order in which the object executes related events throughout its life cycle, in response to different events.

??

As an example, the following state machine diagram shows how the gate works throughout its life cycle.

The door can be in one of three states: "Opened" Open, "Closed" off, or "Locked" lock status. It responds to the event individually: "Open" opens, "close" closes, "lock" Locks and "Unlock" unlocks. Note: Not all events are valid in all States. such as: When a door is opened, it is impossible to lock, unless you close the door. Also, state transitions may have additional guardianship conditions: assuming that the door is open, if "doorway->isempty" (The door is empty) is satisfied, then it can only respond to the closing event. The syntax and conventions used by the state machine diagram are discussed in the following sections.

State

The state is represented as a rounded rectangle, and the state name is written inside.

Start and end states

The initial state is represented as a solid black ring, and the name can be labeled. The end state is indicated as a center with a black dot ring, or it can be labeled with a name.

Transfer

Transitions from one state to the next state are represented as solid lines with arrows. The transfer can have a "Trigger" trigger, a "Guard" guardianship condition and a "effect" effect. As shown below:

The "Trigger" trigger is the cause of the transfer, which can be a signal under a condition, an event, a change, or a time path. "Guard" guardianship is a condition and must be true in order to allow the trigger to cause a transfer. The effect "Effect" is an action that acts directly on an object that has a state machine as the result of the transfer.

Status activity

In the state transition example above, an effect is associated with the transition. If the target state has multiple transfers arriving, and each transfer has the same effect associated with it, it is better to associate the effect with the target State, not the transfer. You can do this by defining the initial action for this state. Shows a state with entry action and exit action.

You can define an action that occurs on an event, or an action that occurs all the time. Each type of action can be defined in any number of ways.

Self-transfer

A State may have a transition back to itself, such as. The effect is very helpful in associating with the transfer.

Composite state

A state machine diagram can have a sub-state machine diagram, as shown in:

You can choose to display the same information in different ways, as shown in:

The sub-state machine diagram for the "Check PIN" in the previous version shows up in a separate diagram.

Entry point

Sometimes, you do not want to enter the sub-state machine in the normal initial state. For example, the following sub-state machine, which usually starts with the "initialize" state, but if for some reason it does not have to perform initialization, it may be transferred to the specified entry point to start from the "Ready" state.

Shows the previous layer of the state machine.

Exit point

There is a similar way to the entry point, and it may also specify an optional exit point. Given the execution of the primary processing state, the direction of execution of the state will depend on the path used when the state is transferred.

Select Pseudo State

Select pseudo state to be shown as a diamond with one transfer input, two or more outputs. Displays the whereabouts of the selected pseudo-state regardless of which state is reached, depending on the message format selected when executing in the pseudo state.

Connection pseudo State

The connection pseudo state is used to link multiple state transitions together. A single connection pseudo state can have one or more inputs and one or more outputs, the guardianship may be applied to each transfer, and the connection is without semantics. A connection can divide an input transfer into multiple output transitions to implement a static branch. In contrast, the pseudo-state is selected to implement a dynamic conditional branch.

Terminating pseudo-state

Entering the terminating pseudo state means that the state machine lifeline has been terminated. The terminating pseudo-state is represented as a fork number.

Historical state

The history state is used when a state machine is interrupted, before the state machine is restored. The following illustration illustrates the use of historical states. This example is about the state machine of the washing machine.

In this state machine, when the laundry is running, it will follow "washing" to rinsing "to" Spinning ". If the power is cut off, the washing machine will stop running and enter the "Power Off" state. When the power is restored, the running state is entered at the "history" symbol, indicating that it will recover from the location where it was last left.

Concurrency Zone

A state can be divided into several different zones, which contain both existing and executed sub-states. The following example shows the status "applying brakes", "front brake" and "rear brakes" will operate independently at the same time. Note that forking and binding pseudo states are used instead of selecting and merging pseudo states. These symbols are used to synchronize concurrent threads.

UML State machine Diagram

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.