Post on 25-Feb-2016
description
The STATEMATE The STATEMATE Semantics of StatechartsSemantics of Statecharts
David Harel and Amnon Naamad
1996.
Jolan FarkasJolan Farkas
04/22/23CS 367 2/32
OverviewOverview
Introduction Basic concepts of semantics
– Hierarchy of states– Orthogonality of states– Transitions– History
Other issues
Statecharts
04/22/23CS 367 3/32
STATEMATESTATEMATE
No consensus about semantics Clarity, simplicity, intuitive Unofficial language => no official semantics Main difference between Harel’s (87) and P&S (91)
– Changes occurring in a given step take effect in the current step or in the next one
– STATEMATE implements the latter approach
Statecharts - STATEMATE
04/22/23CS 367 4/32
Commercial ToolCommercial Tool
Real-life complex systems Support of different styles of modeling Simple and intuitive VHDL adopted the same approach
Statecharts - STATEMATE
04/22/23CS 367 5/32
TopicsTopics
Statechart notions– Hierarchy of states– Orthogonality– History connector
Not unique to statecharts– Combinational assignments– Priority of transitions– Generic charts– Multi-value logic– Queues
i-Logic documents
Statecharts - Topics
04/22/23CS 367 6/32
The BasicsThe Basics
04/22/23CS 367 7/32
The BasicsThe Basics
Model of reactive systems Backbone: activity-chart
– Hierarchical dataflow diagram– Functional capabilities of the system– Dynamically noncommitting
Behavioral aspect: control activities– One for each activity– Controls the dynamics of subactivities and their dataflow
Statecharts - Basics
04/22/23CS 367 8/32
Structure of Activity HierarchyStructure of Activity Hierarchy
A1S1
A11S11
A112 S112
A1123A111
A12A13
A131S13
Activity
Control activity
Statecharts - Basics
04/22/23CS 367 9/32
The Basics …The Basics …cont’dcont’d
State hierarchy– OR: substances in exclusive OR relation– AND: orthogonal components related by AND– BASIC: at the hierarchy bottom
Statecharts - Basics
A
B
C
D
E F
04/22/23CS 367 10/32
The Basics …The Basics …cont’dcont’d
Transition labeling: e[c]/a– e: event, triggers the transition– c: condition, guards transition from being taken– a: action carried out if and when transition is taken
Actions associated with the entrance to or exit from a state S– Entrance to: on transition leading to S– Exit from: on transition exiting from S
Statecharts - Basics
04/22/23CS 367 11/32
The Basics …The Basics …cont’dcont’d
Static reactions– Same format: e[c]/a– Carried out as long as the system is in the given state
• Transition in virtual susbtate VS• VS is orthogonal to all substates and SR’s
Statecharts - Basics
A
B C
SR: ev/act
t1
A
B
C
Dt1
ev/act
=
04/22/23CS 367 12/32
The Basics …The Basics …cont’dcont’d
Throughout vs. within– Throughout: active upon entering, stops upon leaving– Within: active when system is in S, stops when exiting
Schedule– sc!(a, d): d time units later
Timeout– tm(e, d): d time units after e
Statecharts - Basics
04/22/23CS 367 13/32
The Basics …The Basics …cont’dcont’d
Behavior– Described by possible runs: series of statuses
• Initial status: first snapshot• Each subsequent: by executing a step
– Status: detailed internal information– Step: status change on external stimuli and internal changes
Statecharts - Basics
04/22/23CS 367 14/32
PrinciplesPrinciples
Reactions and changes sensed after step-completion Events: live for step-duration, not remembered Decisions based on situation at the beginning of the step A maximal subset of non-conflicting transitions and SR’s
is always executed Execution of a step takes zero time
Statecharts - Principles
04/22/23CS 367 15/32
Principles …Principles …cont’dcont’d
Less trivial situations– Enabled conflicting transitions in the same step– Transition crosses boundary of nested states
(exited/entered states ?)
Statecharts - Principles
04/22/23CS 367 16/32
Basic System ReactionsBasic System Reactions
04/22/23CS 367 17/32
Basic system reactionsBasic system reactions
Configuration: C is the maxl set of states that the system can be in simultaneously– C contains R– If C contains an OR state O, it contains exactly 1 substate of O– If C contains an AND state A, it contains all substates of A– The only states in C are those required above.– Closed upwards, sufficient to know its basic states
Statecharts – Basic system reactions
04/22/23CS 367 18/32
Basic system reactionsBasic system reactions
Basic configuration– maxl set of basic states that the system can be in simultaneously
Statecharts – Basic system reactions
S
EB1
B2
C1
C2
D1
D2
B C DA
Full: {S, A, B, C, D}Basic: {B1, C1, D1}
Full: {S, E}Basic: {E}
04/22/23CS 367 19/32
Basic system reactionsBasic system reactions
4 operation types– Transitions– Static reactions– Entering actions– Exiting actions
Statecharts – Basic system reactions
BA
S
t1:ev/act
1. ev occurs2. t1 enabled3. Execute act4. exited(A), entered(B)
generated, sensed in next step (SR’s)
5. in(A)=false, in(B)=true6. Actions on exit(A),
enter(B) executed7. All enabled SR’s of S8. Within/throughout:
deactivated in A, activated in B
04/22/23CS 367 20/32
Compound TransitionsCompound Transitions
Statecharts – Compound transitions
Execution of a step must always lead to a legal configuration
Actual transition: a set of separate transitions Basic compound transition (CT)
– Maxm chain of transition segments executable as single transition– Joint and fork are AND connectors– Condition, selection, and junction are OR connectors– Initial, continuation and full CT
04/22/23CS 367 21/32
Dealing with HistoryDealing with History
Statecharts – Dealing with History
Two kinds of History connectors– H: target is one substate of S– H*: target is basic configuration relative to S
H
B2 B1
B S
At1:eC
t2:[C1][C2]
t3 ![C2]!
04/22/23CS 367 22/32
Scope of TransitionsScope of Transitions
Statecharts – Dealing with History
Full CT– Source contains states only (no connectors)– Target contains basic states and termination connectors only– Every two source and every two target states are mutually
orthogonal– Target set is maximal– Enabled, if at beginning of the step system is in all of its source
states and its trigger is true
04/22/23CS 367 23/32
Scope of TransitionsScope of Transitions
Statecharts – Dealing with History
Scope of tr– The lowest OR state in the state hierarchy– Common ancestor of all sources and targets of tr
H
V R
UW
Zt2
SAB
B1
B2
C1
C2
C
t1
SW
t1
t2
04/22/23CS 367 24/32
Conflicting TransitionsConflicting Transitions
Statecharts – Dealing with History
Two CTs are in conflict if their scopes cannot be orthogonal or exclusive– Nondeterminism vs. priority
B C
U S
D
At1t2
t3
t4 t1 vs. t2t4 vs. {t1, t2, t3}
04/22/23CS 367 25/32
Racing ConditionsRacing Conditions
Statecharts – Dealing with History
Racing condition: one action changes, others use the value of some variable in the same step– Ex.: X := X+1, Y := X*5
Working with supersteps => between transitions or actions
Race situation: Different (but still legal) execution orders of enabled transitions provide different results
04/22/23CS 367 26/32
Racing ConditionsRacing Conditions
Statecharts – Dealing with History
Race situation
E F
S
G
At1: e / f
t2: f / X:=5
t3: f t4: / Y:=X+1
B
C D
04/22/23CS 367 27/32
Two Models of TimeTwo Models of Time
Statecharts – Dealing with History
Synchronous time model– A single step every time unit– Highly synchronous systems
Asynchronous time model– The system reacts whenever an external change occurs– Several external changes simultaneously– Superstep: Several steps in a single point in time
Steps take zero time
04/22/23CS 367 28/32
New IssuesNew Issues
04/22/23CS 367 29/32
Combinational AssignmentsCombinational Assignments
Statecharts – Dealing with History
Associated with the entire chart Continuous function
– Recomputed immediately after any parameter change– Possible loops
A := 5 when B = 3 else 10B := 3 when A > 5 else 4
– The event changed(var) generated only when it has a new value at the end of CA execution
04/22/23CS 367 30/32
Priority of TransitionsPriority of Transitions
Statecharts – Dealing with History
Two aspects– Structural priority of a compound transition– Priority number of a transition segment
Structural priority determinant– Based on the source(s)
and target(s) of CT C
D
BS
Et1
Ft3
t2
04/22/23CS 367 31/32
Priority of TransitionsPriority of Transitions
Statecharts – Dealing with History
Priority number– The first different segment is definitive
S T1
T2
T3
T4
T5
T6
(5)
(5) (5)
(6)
(6)
(7)
(8)
(8)
(8)(40)