Lecture 7: State Machines Flashcards
What is a state machine?
- Models the behaviour of an entity
- Specifies the state changes which an object performs triggered by states, events or transitions received by objects
How many state machines for an enity?
- Contains a single state machine for a single entity
- Specifies: the reaction from events
- The action from states
What is the Moore state machine?
- Moore machine uses **entry actions only **
- Output is produced when the state changes
What is a Mearly state machine?
• Mealy machine uses input actions only
- Output is produced based on the input state
What are the two different kinds of state machines?
• Behavioural – Defines the behaviour of a model element (the instance)
• Protocol - Model the protocol of a classifier
- Don’t have actions
What are the states of an object determind by?
- The values of its attributes
- The relationship to other objects
- The activities it is performing
What are the three elements of state machines?
- State
- Event
- Transition
What is a state?
a condition during the life of an object during which it satisfies some condition to perform an activity or wait for an event “Roundtangles”
What is an event?
An occurance that happens in a space and time
“Are written over the transition that they trigger”
What is a transition?
Is the movement from one state to another triggering an event
“Paths/link”
What are the four types of events?
- Call event
- Signal event
- Change event
- Time event
What does call event do?
Triggered by a synchronous operation call
What does a signal event do?
specifies communication of send request instances between objects.
Asynchronously between objects
- Receipt of a signalA signal is a classifier which
What does a change event do?
The constraint is a Boolean expression on the attributes of the objects either true/false is fullfilled
What does a time event do?
Time events occur when a time expression becomes true using the two key words: after and when
- *After**: after time period
- *When**: Some time condition becomes true
Specifies a particular time at which the event is triggered
The events can be appear what?
- Can appear synchronously/asynchronously
- Cause transitions between states
What does synchronously do?
Synchronous calls, which are associated with an operation, have a send and receive message
- Call event triggered by call
- Exception even triggered by an object
What does asynchronously do (list the events)?
When a signal is interrupted by a error condition and there are no operation with the signal
• Signal event: signal sent by an object
- Change event: triggered by side effects on object attributes
- Time event: triggered by Boolean guard over time
What is the syntax for transisiton?
- Event: triggers transition
- Guard condition: Boolean condition must be true before the transition occurs
- Junction pseudo code: Transition merges in a branch
- Choice pseudo-state: ~flows through the state according to its conditions
What are the two special actions?
Entry and Exit
When the transition has no event what’s the condition?
If transition has no event - automatic transition if the guard condition or precondition is true.