State Machines Flashcards

(21 cards)

1
Q

What is the purpose of a state machine diagram?

A

To model:
- possible states of a system/object
- transitions between states triggered by events
- behaviour in each state

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What activities can be defined within a state?

A
  • entry/Activity: runs on entering the state
  • exit/Activity: runs on exiting the state
  • do/Activity: runs while in the state
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the components of a transition?

A
  1. Event (trigger)
  2. Guard (boolean condition)
  3. Effect (actions during transition)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Internal vs External transitions

A
  • Internal: No state change (e.g. event1 triggers Activity3 in state1)
  • External: State change (e.g. event1 moves from state1 to state2)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Name 3 types of events

A
  1. Signal event (e.g. rightMouseDown)
  2. Call event (e.g. register(exam))
  3. Time event (e.g. after(5 secs))
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is an initial state?

A

A pseudo-state with:
- no incoming edges
- immediate transition to next state
- guards on outgoing edges must be mutually exclusive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Final state vs Terminate node

A

Final state: object remains here (end of lifecycle)
Terminate node: object is deleted

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How does a decision node work?

A

Splits transitions into alternative paths with guards (e.g. [x > 0])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does a parallelisation node do?

A

Splits control flow into concurrent sub-flows (1 input -> N outputs)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a synchronisation node?

A

Merges concurrent sub-flows into one (N inputs -> 1 output)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Change events vs Guards

A

Change event: continuously checked (e.g. when(x > y))
Guard: checked only when event occurs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Model a LectureHall with state Free and Occupied

A

[Free] –(occupy)–> [Occupied]
[Occupied] –(release)–> [Free]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Sketch states for exam registration

A

[Unregistered] –(register)–> [Registered]
[Registered] –(cancel)–> [Unregistered]
[Registered] –(pass)–> [Completed]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

States

A

Represents conditions or situations during the lifecycle of an object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Transitions

A

Represents the movement from one state to another, triggered by events, guards or activities

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Events

A

Triggers that cause a transition

17
Q

Guards

A

Boolean conditions that must be true from a transition to occur

18
Q

Activities

A

Actions executed when entering, exiting or during a state

19
Q

Transition syntax

A

event[guard]/effect e.g. e1[x>5]/x++

20
Q

When is a do-activity aborted?

A

When an event triggers a transition with no guard condition

21
Q

What is a time event?

A

An event like when(date=31.12.2001) that triggers at a specific time