02291: System Integration UML State Machines Hubert Baumeister - - PowerPoint PPT Presentation
02291: System Integration UML State Machines Hubert Baumeister - - PowerPoint PPT Presentation
02291: System Integration UML State Machines Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2020 UML diagrams Wikipedia Example Task: Implement a control panel for a safe in a dungeon The safe
UML diagrams
Wikipedia
Example
◮ Task: Implement a control panel for a safe in a dungeon ◮ The safe should be visible only when a candle has been removed ◮ The safe door opens only when the key is turned after the candle has been replaced again ◮ If the key is turned without replacing the candle, a killer rabbit is released
Safe
- pen : bool
- pen
close SecurePanelController doorClosed : bool candleIn : bool candleRemoved() keyTurned() closeSafe()
- revealLock()
- releaseKillerRabbit()
Example
Example Execution (Secret Panel Controller)
Example Execution (Safe)
Example Execution (Secret Panel Controler)
Example Execution (Safe)
Example Execution (Secret Panel Controler)
States 1
States 2
Transitions
state state trigger [guard] / effect
UML User Manual 2nd edition
state state
- peration [guard] / action1; action2; ...
Example Transition
Open Lock SecretPanelController doorClosed : bool candleIn : bool ... candleRemoved() keyTurned() ...
- releaseKillerRabbit()
... Transition of the LSM for the SecretPanelController Transition of the LSM for the Safe Safe
- pen : boolean
- pen()
close() Open Closed close turnKey [candleIn] / safe.open() safe 1
- pen
How to use State Machines
◮ In general:
◮ Focus on states and how a system reacts to events ◮ e.g. modal user interfaces ◮ e.g. hardware controller
◮ Model the life of an object
→ Life cycle state machine (LSM) → From the creation of the object to its destruction → Methods are events
◮ Model the allowed interaction between components
◮ Communication protocols → Protocol state machines (PSM)
Life cycle state machines
Safe
- pen : bool
- pen
close SecurePanelController doorClosed : bool candleIn : bool candleRemoved() keyTurned() closeSafe()
- revealLock()
- releaseKillerRabbit()
Open Lock Wait candleRemoved[doorClosed]/this.revealLock closeSafe/safe.close() keyTurned[candleIn]/safe.open()
- pen
closed
- pen
close