statechart diagrams state machines overview change summary –core constructs –notation examples...
TRANSCRIPT
![Page 1: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/1.jpg)
StateChart Diagrams
![Page 2: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/2.jpg)
State Machines
• Overview
• Change summary– core constructs– notation
• Examples
• Backward compatibility
• User benefits
• Issues
![Page 3: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/3.jpg)
Overview
• State machines specify discrete behavior by mapping received events into sets of states. They may specify detailed behaviors of classes or constrain operational sequences of ports or interfaces.
• The core constructs in statemachines include:– States, Regions, Transitions, Events
• Notated using state machine diagrams• Typical applications of statemachines include:
– object lifecycle• states an “order” object might be in
– event-driven behaviors of embedded controllers – UI controllers– valid Sequences of calls via interfaces or ports
![Page 4: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/4.jpg)
Change Summaryfor UML 2.0
• New core constructs added:– entry/exit points on submachines– state machine specialization/redefinition– state machine Termination– protocol state machines
• transitions pre/post conditions• protocol conformance
• UML 1.4 core constructs updated:– metamodel refactoring
• Notational enhancements– action blocks– state lists
![Page 5: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/5.jpg)
Entry/Exit Points: Usage
VerifyCard
OutOfService
acceptCard
ReleaseCardVerifyTransaction
outOfService
releaseCard
ATM
ReadAmount :ReadAmountSM
aborted
usage of exit point
usage of entry point
rejectTransaction
again
invoked submachine
![Page 6: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/6.jpg)
Entry/Exit Points: Definition
ReadAmountSM
selectAmount
EnterAmount
ok
abort
aborted
amount
otherAmount
abort
again
definition of exit point
definition of entry point
![Page 7: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/7.jpg)
Specialization
• Redefinition as part of class specialization
ATM
acceptCard()outOfService()amount()
BehaviourStatemachine
FlexibleATM
otherAmount()rejectTransaction()
Behaviour
Statemachine
<<Redefine>>
![Page 8: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/8.jpg)
State Machine Redefinition
• State machine of ATM to be redefined
VerifyCard
ReadAmount
selectAmount
acceptCard
ReleaseCardVerifyTransaction
selectAmount
amount
outOfService
releaseCard
OutOfService
ATM
{final}
{final}
{final}
{final}
![Page 9: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/9.jpg)
State Machine Redefinition
• FlexibleATM redefines ATM
VerifyCard
ReadAmount
selectAmount
acceptCard
ReleaseCardVerifyTransaction
selectAmount
amount
outOfService
releaseCard
OutOfService
FlexibleATM
{final}
{final}
{final}
{final}
ATM {extended}
EnterAmountok
otherAmount
rejectTransaction
{extended}
![Page 10: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/10.jpg)
State Machine Redefinition
• FlexibleATM Statemachine• States and transitions can be
added
• States and state machines can be extended
• Regions can be added, and regions can be extended
• Transitions can be replaced or extended– Actions can be replaced
– Guards can be replaced
• Submachines can be replaced
ReadAmount
SelectAmount
VerifyTransaction
EnterAmountEnterAmount
ok
otherAmount
rejectTransaction
FlexibleATM ATM
{extended}
{extended}
![Page 11: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/11.jpg)
State Machine Specialization
• Independent state machine specialization– not as part of class specialization
– facilitates reuse of behaviours
<<statemachine>>ATMsm
<<statemachine>>FlexibleATMsm
ATMmachines
![Page 12: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/12.jpg)
Protocol State Machines
onGround checked
flying
check()
[cleared for take off] takeOff()/[landing rear is retracted]
land()
postcondition instead of action
Equivalent to pre and post conditions added to the related operations:
takeOff()Pre
-in state "checked"-cleared for take off
Post-landing rear is retracted-in state "flying"
![Page 13: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/13.jpg)
Example: Notation Enhancements
• Transition notation • State lists
Idle
Req(Id)
MinorReq=Id; MajorReq=Id;
[ID<=10] [ID>10]
Minor(Id) Major(Id)
Busy
alternativechoice
sequence ofactions
VerifyCard,ReleaseCard
Is a notational shorthand for
logCardLogged
VerifyCard
ReleaseCard
logCardLogged
![Page 14: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/14.jpg)
Statesexample Library Title
![Page 15: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/15.jpg)
Backward Compatibility
• In general all UML 1.4 state machine concepts are preserved in the 2.0 proposal
• Submachines: stub-states replaced by connection points
• Specialization (only a note in UML 1.4) now specified
• Protocol state machines now specified as a separate compliance point
![Page 16: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/16.jpg)
User Benefits
• Entry/Exit Points – reuse via encapsulation of statemachine control
interfaces– scalability
• Specialization– reuse, refinement
• Protocol State Machines– usage of stat emachines at higher level of
abstraction
![Page 17: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/17.jpg)
What Does a Statechart Depict?
![Page 18: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/18.jpg)
Classifier of a State Machine
• The modeling element which is described by the state machine
• Usually a class
![Page 19: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/19.jpg)
State MachinesTerms and Concepts
• State machine is a behavior that specifies the sequences of states an object goes through during its lifetime
• State
• Event
• Transition
![Page 20: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/20.jpg)
State Transition Diagrams
• Show a state machine. • Emphasize the event-ordered behavior of an
object.• Model the changes in an object in response to the
environment.• Document the following:
– Causes of change– Alterations in behavior based on the object’s current
condition
![Page 21: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/21.jpg)
StateCharts vs. Sequence & Collaboration Diagrams
• Sequence&Collaboration diagrams show how information passes through the objects of a system over time.
• State Transition diagrams show how one object changes over time,– given that methods are invoked on it by
other objects.
• Changing the statechart states doesn’t influence the Class structure, i.e. Internal affair
![Page 22: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/22.jpg)
States
• All objects have a “state.” The current state of any object is dictated by the values stored in its attributes.
• Initial
• final
![Page 23: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/23.jpg)
States
• A period of time in the life of an object during which it– Satisfies some condition,
and/or– Performs some activity, and/or– Waits for some events
• Some special states– Start state
• At most one
– Final state• Can appear many times; all
have the same meaning - namely, the classifier ceases to exist
![Page 24: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/24.jpg)
States
![Page 25: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/25.jpg)
Transitions
• Event Trigger
• Guard Condition
• Action– entry, exit, activity
![Page 26: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/26.jpg)
Transitions and Events
• Example: statechart for Patient class
• A transition without an explicit event label is called trigerless
• When source state is complete, transition occurs
![Page 27: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/27.jpg)
Events
• An “event” is the stimulus
that prompts an object to make the transition from one state to another.
• Events take the form of a method call.
![Page 28: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/28.jpg)
Events
• Trigger transitions• May represent the receipt of a message:
– Between system and actors– Among objects– From an object to itself
• Several kinds of events– Signals– Calls– Passage of time, for example:
• after(2 sec)
– Change in state, for example:• when(quantity < 10)• when(date = Y2K)
![Page 29: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/29.jpg)
Deferring Events EDo:
UG-ban utananezni
EDo:
UG-ban utananezni
![Page 30: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/30.jpg)
Internal Actions/Activities
![Page 31: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/31.jpg)
Transition Details
• Guard Condition• Action
![Page 32: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/32.jpg)
Self- & Internal- Transitions
![Page 33: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/33.jpg)
Actions
• Triggered by an event
• An executable, atomic computation
• Noninterruptible, runs to completion
• Usually the invocation of an operation (a call)– to the state machine classifier– to objects linked to the classifier
![Page 34: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/34.jpg)
Actions vs. Events
![Page 35: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/35.jpg)
Composite StatesEDo:
We don’t go deeper now
EDo:
We don’t go deeper now
![Page 36: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/36.jpg)
Sending Messages:Textual Notation
![Page 37: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/37.jpg)
Sending Messages:Graphical Notation
• Syntax: a <<send>> dependency drawn from a transition to a class box: the dependency is labeled with the message
![Page 38: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/38.jpg)
SuperStates
• when you have many states that respond to some of the same events in the same way
![Page 39: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/39.jpg)
Overriding superstate transitions
![Page 40: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/40.jpg)
Hierarchical invocation of Entry and Exit actions
![Page 41: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/41.jpg)
Simple Login State Machine
![Page 42: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/42.jpg)
Real world example
![Page 43: StateChart Diagrams State Machines Overview Change summary –core constructs –notation Examples Backward compatibility User benefits Issues](https://reader036.vdocuments.site/reader036/viewer/2022081602/551a867355034643688b5919/html5/thumbnails/43.jpg)
That’s it for today