Upload
others
View
9
Download
0
Embed Size (px)
Citation preview
Finite State MachinesStatecharts
Time in StatechartsStateflow
SyncCharts (Safe State Machines)
StatesTransitionsConnectorsEsterel Studio
Differences
SyncCharts differ from other implementations of Statecharts:
I Synchronous framework
I Determinism
I Compilation into backend language Esterel
I No interpretation for simulations
I No hidden behaviour
I Multiple events
I Negation of events
I No inter-level transitions
Fall 2007 EE 249 Slide 56
Finite State MachinesStatecharts
Time in StatechartsStateflow
SyncCharts (Safe State Machines)
StatesTransitionsConnectorsEsterel Studio
Simple Sequential Automaton
SyncChart:
main
Elements:I States:
I Regular state(circle)I Terminal state(doubled circle)I Hierarchic state(box with rounded edges)
I Transitions:I Arrows with labels
I Connectors:I Colored circles with single letters
Fall 2007 EE 249 Slide 57
Finite State MachinesStatecharts
Time in StatechartsStateflow
SyncCharts (Safe State Machines)
StatesTransitionsConnectorsEsterel Studio
Hierarchic Statesmain_hier
SyncCharts know four types of states:I Simple States: Carry just a label.I Graphic Macrostates: Encapsulates a
hierarchy of other states, includingfurther graphic states.
I Textual Macrostates: Containstatements of the Esterel language.They are executed on entry of thestate.
I Run Modules: Include other modules.
Transitions arenot allowed to cross the boundaries of graphicmacrostates. This is in contrast to other modelling tools.
Fall 2007 EE 249 Slide 58
Finite State MachinesStatecharts
Time in StatechartsStateflow
SyncCharts (Safe State Machines)
StatesTransitionsConnectorsEsterel Studio
Parallel States
main_parallel
I Dashed lines (horizontal or vertical)separate parallel executed states insidea graphic macrostate.
I Each segment may be segmented intofurther parallel segments, but iterativesegmentation does not introduceadditional hierarchy. All parallelsegments in a graphic macrostate areat the same level.
Fall 2007 EE 249 Slide 59
Finite State MachinesStatecharts
Time in StatechartsStateflow
SyncCharts (Safe State Machines)
StatesTransitionsConnectorsEsterel Studio
Parallel States
main_parallel
I A transition outside the graphicmacrostate with normal termination isactivated, when all parallel segmentshave reached their terminal state.
I If just one segment does not have oneor if it is not reached, then the normaltermination transition will never beactivated.
Fall 2007 EE 249 Slide 60
Finite State MachinesStatecharts
Time in StatechartsStateflow
SyncCharts (Safe State Machines)
StatesTransitionsConnectorsEsterel Studio
Modules
m
A module like this with an interface:
input I;output O;
. . . can be used as aRun Modulewiththese signal bindings:
signal S1 / I;signal S2 / O
Fall 2007 EE 249 Slide 61
Finite State MachinesStatecharts
Time in StatechartsStateflow
SyncCharts (Safe State Machines)
StatesTransitionsConnectorsEsterel Studio
Syntax of Transition Labelsmain_trans
Informal syntax of a transition label be-tween states S1 and S2, all elements areoptional:
# factor trigger {condition} / effect
Basicactivation and action:I trigger is an expression of signal presence like \A or B"I Enclosed in braces is thecondition. It is a data expression
over signal values or variables like \?A=42"I Behind a single \/" follows the \effect" as a list of emitted
signals if the transition is executed. Multiple signal names areseparated with \,".
Fall 2007 EE 249 Slide 62
Finite State MachinesStatecharts
Time in StatechartsStateflow
SyncCharts (Safe State Machines)
StatesTransitionsConnectorsEsterel Studio
Syntax of Transition Labelsmain_trans
Informal syntax of a transition label be-tween states S1 and S2, all elements areoptional:
# factor trigger {condition} / effect
Extensions:I \#" is the ag for an immediate transitionI \factor" is the (natural) number of instants a transition
must be active before it is executed. These active instantsdoes not need to be consecutive, butS1 must be active all thetime.
Fall 2007 EE 249 Slide 63
Finite State MachinesStatecharts
Time in StatechartsStateflow
SyncCharts (Safe State Machines)
StatesTransitionsConnectorsEsterel Studio
Transition Labels: Examplesmain_trans
The following label examples belong tothe transition originating atS1 and lead-ing toS2:
I A/BAfter enteringS1 the signalA is tested from the next instanton. IfA is present, thenB is emitted in the same instant andstateS2 is entered.
I /BAfter enablingS1, B is emitted in the next instant andS2 isentered.
I 3 A/The transition is executed, ifS1 is active consecutively andsignalA is present for 3 times.
Fall 2007 EE 249 Slide 64
Finite State MachinesStatecharts
Time in StatechartsStateflow
SyncCharts (Safe State Machines)
StatesTransitionsConnectorsEsterel Studio
Transition Labels: ExamplesI #A/
If S1 is entered, signal A is tested from the same instant on. IfA is present in the instant S1 is entered then state S2 isentered in the same instant.
I {?A=42}/The transition is executed, if the (valued) signal A carries thevalue 42. A does not need to be present for this test.
I A {?A=42}/This test succeeds if A is present and carries the value 42.
I A and (B or C)/Logical combination of signal presence.
I {?A=10 and (?B
Finite State MachinesStatecharts
Time in StatechartsStateflow
SyncCharts (Safe State Machines)
StatesTransitionsConnectorsEsterel Studio
Transition Priorities
main_prio
I Whenmore than one transition departs astate, an automatic (but editable) priorityordering is established.
I The transition labels are evaluatedaccording to their priority.
I The �rst label that succeeds activates itstransition.
I Low numbers mean high priority.
Fall 2007 EE 249 Slide 66
Finite State MachinesStatecharts
Time in StatechartsStateflow
SyncCharts (Safe State Machines)
StatesTransitionsConnectorsEsterel Studio
Transition Types
SyncCharts feature four different types of transitions: They aredifferentiated by a symbol at the arrow root:
main_transdiff
I Initial connector: Initial arcInitial arcs connect the initial connectors ofthe chart with the other states.
I No symbol:Weak abortWhen the trigger/condition of the transitionis enabled, then the actions of the originatingstate in the current instant are executed for alast time, then the transition action, and theentry action of the new state.In other words:The old state can \express it’s last will".
Fall 2007 EE 249 Slide 67
Finite State MachinesStatecharts
Time in StatechartsStateflow
SyncCharts (Safe State Machines)
StatesTransitionsConnectorsEsterel Studio
Transition Types
main_transdiff
I Redbullet: Strong abortThe action for the current instant of the oldstate is not executed. Only the transitionaction and the entry action of the new stateis executed.
I Green triangle:Normal terminationThis transition can be used to exit macrostates. It is activated when the macro stateterminates.
All these transition types must not be confused with \immediate"or \delayed" evaluation of the transition label (label pre�x \#").
Fall 2007 EE 249 Slide 68
Finite State MachinesStatecharts
Time in StatechartsStateflow
SyncCharts (Safe State Machines)
StatesTransitionsConnectorsEsterel Studio
Transition Types and Labels
Some transition types have restrictions on their labels:main_transdiff
I Initial arc:These are always \immediate," therefore theadditional ag \#" is not needed.
I Weak abort: No restrictions.I Strong abort: No restrictions.I Normal termination:
They support no triggers or conditionsbecause they are activated by the terminationof the originating state. The immediate agis not used either.
Fall 2007 EE 249 Slide 69
Finite State MachinesStatecharts
Time in StatechartsStateflow
SyncCharts (Safe State Machines)
StatesTransitionsConnectorsEsterel Studio
Transition Types and Priorities
The type of a transition interacts with it’s priority:
I Strong abort: Highest priority
I Weak abort: Middle priority
I Normal termination: Lowest priority
Esterel Studio enforces these rules by changing the numericalpriorities of the transitions.
Fall 2007 EE 249 Slide 70
Finite State MachinesStatecharts
Time in StatechartsStateflow
SyncCharts (Safe State Machines)
StatesTransitionsConnectorsEsterel Studio
Local Signals and Variables
main_signal
Local signals:I De�ned in the body of a
graphical macrostateI Shared between parallel threads
Local variables:I Attached to the initial
connectorI Not shared
Fall 2007 EE 249 Slide 71
Finite State MachinesStatecharts
Time in StatechartsStateflow
SyncCharts (Safe State Machines)
StatesTransitionsConnectorsEsterel Studio
ConnectorsThis (artificial) SyncChart demonstrates all four connector states:
main_conn
Initialconnector:I Activated at activation of the
macrostateI Only departing transitions permittedI All connected transitions are
\immediate"Conditionalconnector:
I All departing transitions are\immediate"
I One departing \default" transitionwithout condition must be present.
Fall 2007 EE 249 Slide 72
Finite State MachinesStatecharts
Time in StatechartsStateflow
SyncCharts (Safe State Machines)
StatesTransitionsConnectorsEsterel Studio
ConnectorsThis (artificial) SyncChart demonstrates all four connector states:
main_conn
Suspend connector:I The suspend state is always active.I Only one departing transitions is
permitted.I The transition can only hold a trigger
expression.I The \immediate" ag can be enabled
on demand.I When the transition is activated, then
the target state is (strongly)suspended.
Fall 2007 EE 249 Slide 73
Finite State MachinesStatecharts
Time in StatechartsStateflow
SyncCharts (Safe State Machines)
StatesTransitionsConnectorsEsterel Studio
ConnectorsThis (artificial) SyncChart demonstrates all four connector states:
main_conn
History connector:I This connector is directly attached to
macrostatesI Only incoming transitions can connect.I The previous state of the macrostate
is restored when it is entered througha history connector.
Fall 2007 EE 249 Slide 74
Finite State MachinesStatecharts
Time in StatechartsStateflow
SyncCharts (Safe State Machines)
StatesTransitionsConnectorsEsterel Studio
Esterel Studio
http://www.esterel-technologies.com/
Esterel Studio features:
I Graphical editor for Statechart dialect “Safe State Machines”,a. k. a. SyncCharts
I Code generator for textual EsterelI Esterel compiler for C code productionI Interface to backend in host language (C)I Graphical simulation Validation/Testing environment
Fall 2007 EE 249 Slide 75
http://www.esterel-technologies.com/
Finite State MachinesStatecharts
Time in StatechartsStateflow
SyncCharts (Safe State Machines)
StatesTransitionsConnectorsEsterel Studio
To Go FurtherI David Harel, Statecharts: A Visual Formulation for Complex
Systems, Science of Computer Programming, 8(3), June1987, pp. 231–274
I D. Harel, M, Politi, Modeling Reactive Systems withStatecharts: The STATEMATE Approach, McGraw-Hill, ISBN0-07-026205-5, 1998.
I Charles Andr, Semantics of S.S.M (Safe State Machine),Esterel Technologies Technical Report, April, 2003,http://www.esterel-technologies.com/v3/?id=50399&dwnID=48
I Home page of Esterel Technologies:http://www.esterel-technologies.com/
I Local information on Esterel-Studio and where to find furtherdocumentation:http://www.informatik.uni-kiel.de/~esterel/Fall 2007 EE 249 Slide 76
http://www.esterel-technologies.com/v3/?id=50399&dwnID=48http://www.esterel-technologies.com/v3/?id=50399&dwnID=48http://www.esterel-technologies.com/http://www.informatik.uni-kiel.de/~esterel/