CS2002 - Week 9 - State Machine Diagrams Flashcards
(19 cards)
What is the purpose of a state machine diagram?
To model:
- possible states of a system/object
- transitions between states triggered by events
- behaviour in each state.
What activities can occur within a state?
entry/Activity: runs on entering the state
exit/Activity: runs on exiting the state
do/Activity: runs while in the state.
What are the components of a transition?
Event (trigger)
Guard (boolean condition),
Effect (actions during transition).
What is the difference between internal and external transitions?
Internal: No state change (e.g. event1 triggers Activity3 in state1)
External: State change (e.g. event1 moves from state1 to state2).
What are the types of events in a state machine?
Signal event (e.g. rightMouseDown)
Call event (e.g. register(exam))
Time event (e.g. after(5 secs)).
What characterizes an initial state?
A pseudo-state with:
- no incoming edges
- immediate transition to next state
- guards on outgoing edges must be mutually exclusive.
What is the difference between a final state and a terminate node?
Final state: object remains here (end of lifecycle).
Terminate node: object is deleted.
What is a decision node?
Splits transitions into alternative paths with guards (e.g. [x > 0]).
What is a parallelisation node?
Splits control flow into concurrent sub-flows (1 input -> N outputs).
What is a synchronisation node?
Merges concurrent sub-flows into one (N inputs -> 1 output).
What is the difference between change events and guards?
Change event: continuously checked (e.g. when(x > y)).
Guard: checked only when event occurs.
How can you model a LectureHall state machine?
[Free] -(occupy)-> [Occupied]
[Occupied] -(release)-> [Free]
What do states represent in a state machine?
Conditions or situations during the lifecycle of an object.
What do transitions represent?
The movement from one state to another, triggered by events, guards or activities.
What are events in a state machine?
Triggers that cause a transition.
What are guards in a state machine?
Boolean conditions that must be true for a transition to occur.
What are activities in a state machine?
Actions executed when entering, exiting or during a state.
When is a do-activity aborted?
When an event triggers a transition with no guard condition.
What is a time event?
An event like when(date=31.12.2001) that triggers at a specific time.