0% found this document useful (0 votes)
35 views13 pages

Uml 2 State Machine Diagrams

The vending machine can be in one of five states - Idle, Selection, Payment, Dispensing, or Refund - and transitions between states based on user input or payment status, initially starting in the Idle state and returning to Idle after completing a transaction. It also has a Maintenance state that it can enter if a technical issue occurs. Transitions have conditions to ensure proper handling of user selections, payments, refunds and maintenance.

Uploaded by

farhan khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views13 pages

Uml 2 State Machine Diagrams

The vending machine can be in one of five states - Idle, Selection, Payment, Dispensing, or Refund - and transitions between states based on user input or payment status, initially starting in the Idle state and returning to Idle after completing a transaction. It also has a Maintenance state that it can enter if a technical issue occurs. Transitions have conditions to ensure proper handling of user selections, payments, refunds and maintenance.

Uploaded by

farhan khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 13

UML State Machine Diagrams

State Machine Diagrams


• A state machine diagram models the • The door can be in one of three states:
behavior of a single object, specifying the "Opened", "Closed" or "Locked". It can
sequence of events that an object goes respond to the events Open, Close, Lock
through during its lifetime in response to and Unlock. Notice that not all events are
events. As an example, the following valid in all states; for example, if a door is
state machine diagram shows the states opened, you cannot lock it until you close
that a door goes through during its it. Also notice that a state transition can
lifetime. have a guard condition attached: if the
door is Opened, it can only respond to the
Close event if the condition
• doorWay->isEmpty is fulfilled. The syntax
and conventions used in state machine
diagrams will be discussed in full in the
following sections.
State Machine Diagrams
• States - A state is denoted by a round-cornered rectangle with the name
of the state written inside it.

• Initial and Final States - The initial state is denoted by a filled black circle
and may be labeled with a name. The final state is denoted by a circle
with a dot inside and may also be labeled with a name.
State Machine Diagrams
• Transitions - Transitions from one state to the next are denoted by lines
with arrowheads. A transition may have a trigger, a guard and an effect,
as below.
• Self-Transitions - A state can have a transition that returns to itself, as in
the following diagram. This is most useful when an effect is associated
with the transition.

• "Trigger" is the cause of the transition, which could be a signal, an event,


a change in some condition, or the passage of time. "Guard" is a condition
which must be true in order for the trigger to cause the transition. "Effect"
is an action which will be invoked directly on the object that owns the
state machine as a result of the transition.
State Machine Diagrams
• State Actions - In the transition example above, an effect was associated
with the transition. If the target state had many transitions arriving at it,
and each transition had the same effect associated with it, it would be
better to associate the effect with the target state rather than the
transitions. This can be done by defining an entry action for the state. The
diagram below shows a state with an entry action and an exit action.

• It is also possible to define actions that occur on events, or actions that


always occur. It is possible to define any number of actions of each type.
State Machine Diagrams
• Compound States - A state machine diagram may include sub-machine
diagrams, as in the example below.

Alternative way to
show the same
information
•The ∞ symbol indicates that details of the Check PIN
sub-machine are shown in a separate diagram.
State Machine Diagrams
• Entry Point - Sometimes you won’t want to enter a sub-machine at the
normal initial state. For example, in the following sub-machine it would be
normal to begin in the "Initializing" state, but if for some reason it wasn’t
necessary to perform the initialization, it would be possible to begin in the
"Ready" state by transitioning to the named entry point.

• Exit Point - In a similar manner to entry points, it is possible to have


named alternative exit points. The following diagram gives an example
where the state executed after the main processing state depends on
which route is used to transition out of the state.
State Machine Diagrams
• Choice Pseudo-State - A choice pseudo-state is shown as a diamond with
one transition arriving and two or more transitions leaving. The following
diagram shows that whichever state is arrived at, after the choice pseudo-
state, is dependent on the message format selected during execution of
the previous state.
State Machine Diagrams
• Junction Pseudo-State - Junction pseudo-states are used to chain together
multiple transitions. A single junction can have one or more incoming, and one
or more outgoing, transitions; a guard can be applied to each transition.
Junctions are semantic-free. A junction which splits an incoming transition into
multiple outgoing transitions realizes a static conditional branch, as opposed
to a choice pseudo-state which realizes a dynamic conditional branch.
State Machine Diagrams
• Terminate Pseudo-State - Entering a terminate pseudo-state indicates
that the lifeline of the state machine has ended. A terminate pseudo-state
is notated as a cross.

• History States - A history state is used to remember the previous state of


a state machine when it was interrupted. The following diagram illustrates
the use of history states. The example is a state machine belonging to a
washing machine.
State Machine Diagrams
• Concurrent Regions - A state may be divided into regions containing sub-
states that exist and execute concurrently. The example below shows that
within the state "Applying Brakes", the front and rear brakes will be
operating simultaneously and independently. Notice the use of fork and
join pseudo-states, rather than choice and merge pseudo-states. These
symbols are used to synchronize the concurrent threads.
Scenario
Scenario requirements for a state machine diagram for a
vending machine entail outlining the various states, events,
transitions, and constraints involved in its operation. Initially, the
machine is in an idle state, waiting for user interaction. Upon a
user selecting an item, the machine transitions to the selection
state. Subsequently, when the user inserts money, it moves to
the payment state. If the transaction succeeds, the machine
enters the dispensing state and dispenses the item; otherwise, it
transitions to the refund state if the transaction fails. After
dispensing or refunding, the machine returns to the idle state.
Additionally, it can transition to a maintenance state if technical
issues arise. Constraints ensure proper handling of transactions,
refund requests, and maintenance procedures, maintaining the
machine's functionality and reliability throughout its operation
Scenario
Picture yourself amidst the bustling terminal of an airport, eyeing the
vending machine for a quick energy boost before your flight. The
machine begins in its idle state, patiently awaiting your selection. As you
choose your snack, it transitions smoothly to the selection state, ready
to fulfill your craving. Upon inserting your payment, it shifts seamlessly
to the payment state, processing your transaction with efficiency. If your
payment is successful, it cheerfully moves to the dispensing state,
delivering your treat with a satisfying whirr. However, should an issue
arise, like a crumpled bill or a glitch, it gracefully switches to the refund
state, returning your money promptly with a reassuring beep. Once your
snack is dispensed or your refund processed, the machine returns to its
idle state, prepared to assist the next traveler. In the unlikely event of a
technical glitch, it calmly enters the maintenance state, ensuring smooth
operation for future passengers. This scenario paints the vending
machine as a reliable ally, simplifying your airport experience with its
intuitive process flow and friendly functionality.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy