310 likes | 465 Views
The STATEMATE Semantics of Statecharts. David Harel and Amnon Naamad 1996. Jolan Farkas. Overview. Introduction Basic concepts of semantics Hierarchy of states Orthogonality of states Transitions History Other issues. Statecharts. STATEMATE. No consensus about semantics
E N D
The STATEMATE Semantics of Statecharts David Harel and Amnon Naamad 1996. Jolan Farkas
Overview • Introduction • Basic concepts of semantics • Hierarchy of states • Orthogonality of states • Transitions • History • Other issues Statecharts
STATEMATE • 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
Commercial Tool • Real-life complex systems • Support of different styles of modeling • Simple and intuitive • VHDL adopted the same approach Statecharts - STATEMATE
Topics • 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
The 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
A1 S1 A11 S11 S112 A112 A111 A1123 A13 A12 A131 S13 Structure of Activity Hierarchy Activity Control activity Statecharts - Basics
A F E B D C The Basics …cont’d • State hierarchy • OR: substances in exclusive OR relation • AND: orthogonal components related by AND • BASIC: at the hierarchy bottom Statecharts - Basics
The Basics …cont’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
A A B t1 B C D t1 C ev/act SR: ev/act The Basics …cont’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
The Basics …cont’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
The Basics …cont’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
Principles • 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
Principles …cont’d • Less trivial situations • Enabled conflicting transitions in the same step • Transition crosses boundary of nested states (exited/entered states ?) Statecharts - Principles
Basic 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
S A B C D B1 C1 D1 E B2 C2 D2 Basic system reactions • Basic configuration • maxl set of basic states that the system can be in simultaneously Full: {S, A, B, C, D} Basic: {B1, C1, D1} Full: {S, E} Basic: {E} Statecharts – Basic system reactions
S t1:ev/act A B Basic system reactions • 4 operation types • Transitions • Static reactions • Entering actions • Exiting actions • ev occurs • t1 enabled • Execute act • exited(A), entered(B) generated, sensed in next step (SR’s) • in(A)=false, in(B)=true • Actions on exit(A), enter(B) executed • All enabled SR’s of S • Within/throughout: deactivated in A, activated in B Statecharts – Basic system reactions
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 Statecharts – Compound transitions
S B t3 ![C2] C H t1:e A [C2] t2:[C1] B1 B2 Dealing with History • Two kinds of History connectors • H: target is one substate of S • H*: target is basic configuration relative to S ! Statecharts – Dealing with History
Scope of Transitions • 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 Statecharts – Dealing with History
S A W C B U H t2 B1 C1 Z V R C2 B2 t1 Scope of Transitions • Scope of tr • The lowest OR state in the state hierarchy • Common ancestor of all sources and targets of tr S W t2 t1 Statecharts – Dealing with History
S U t1 t2 t4 A D t3 C B Conflicting Transitions • Two CTs are in conflict if their scopes cannot be orthogonal or exclusive • Nondeterminism vs. priority t1 vs. t2 t4 vs. {t1, t2, t3} Statecharts – Dealing with History
Racing Conditions • 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 Statecharts – Dealing with History
S t1: e / f t2: f / X:=5 A C G t3: f t4: / Y:=X+1 F B D E Racing Conditions • Race situation Statecharts – Dealing with History
Two Models of Time • 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 Statecharts – Dealing with History
Combinational Assignments • Associated with the entire chart • Continuous function • Recomputed immediately after any parameter change • Possible loops A := 5 when B = 3 else 10 B := 3 when A > 5 else 4 • The event changed(var) generated only when it has a new value at the end of CA execution Statecharts – Dealing with History
S B t1 C E F t2 D t3 Priority of Transitions • 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 Statecharts – Dealing with History
Priority of Transitions • Priority number • The first different segment is definitive (5) (8) (6) S T1 (5) (5) T2 (7) T5 (6) (8) T3 (40) (8) T4 T6 Statecharts – Dealing with History