Presentation is loading. Please wait.

Presentation is loading. Please wait.

Statecharts Executable Visual Languages for System Development, Fall 2010.

Similar presentations


Presentation on theme: "Statecharts Executable Visual Languages for System Development, Fall 2010."— Presentation transcript:

1 Statecharts Executable Visual Languages for System Development, Fall 2010

2 Executable Visual Languages for System Development2 This lecture The Rhapsody semantics of statecharts Rhapsody basics Examples The Rhapsody tool Basic statecharts concepts are included for reference

3 Executable Visual Languages for System Development3 Statecharts Based on finite state automata With the following additions: –Depth / Hierarchy –Orthogonality –Broadcasting –History

4 Executable Visual Languages for System Development4 Formal Language –Syntax – what is allowed –Semantic domain – what is the pool of possible meanings for elements –Semantic function – mapping from syntax to semantic domain Events label transitions between states

5 Executable Visual Languages for System Development5 Time System states are where things happen The system may be at a states for a short time, or infinitely Transitions take (theoretically) zero time States time Transitions

6 Executable Visual Languages for System Development6 Hierarchy Hierarchy is an abstraction helps deal with complex state spaces Mathematically – XOR decomposition Helps think about sub states Helps break up behavior Partial analogy may be packages, and classes considering the ability to cluster behavior

7 Executable Visual Languages for System Development7 Hierarchy 2 Clustering δ δ AB CD α β βμ γ δ E α A C μ B D δ β δ γ

8 Executable Visual Languages for System Development8 Hierarchy 3 And abstraction E α A C μ B D δ β δ γ Abstraction α A C μ B D δ β δ γ E Details

9 Executable Visual Languages for System Development9 Orthogonality An abstraction that can make behavioral descriptions far more compact Mathematically – AND Decomposition Depicts a sort of conceptual concurrency

10 Executable Visual Languages for System Development10 Orthogonality B-G α B-F B-E μ δ γ C-G αβ C-E C-F δ μ α γ w w w α Y AD B C α β [in G] E F δ γ μ G w x α α γ β α β Without it

11 Executable Visual Languages for System Development11 Broadcast Allows communication between orthogonal parts of the state space. Different from actual communication between the pieces of the system (e.g. objects)

12 Executable Visual Languages for System Development12 Broadcast Example AD H B C αβ/γβ/γ E F δ γ μ G α IJ x/α y/β Syntax: α[c]/β : trigger [condition] / action *more in semantics lecture

13 Executable Visual Languages for System Development13 History Allows remembering previous states AD K B C αβ/γβ/γ E F δ γ μ G α IJ x/α y/β H M H* - recursive history for all sub states

14 Executable Visual Languages for System Development14 Implementation We will discuss the Rhapsody implementation which is object oriented –Every object can have a statechart describing its behavior (the essence of intra-object) –In Rhapsody events are associated with an object, but can be also sent to other objects (itsOtherObj – need to specify the connection)

15 Executable Visual Languages for System Development15 Structure vs. Behavior Consider the system structure and behavior Behavior [Statecharts] Behavior [Statecharts] Structure [OMD] Structure [OMD]

16 Executable Visual Languages for System Development16 Structure vs. Behavior Structure – objects and how they are connected –E.g. Lecturer, student, laptop Behavior – what can each object do, what are its states. –E.g. Stand / Sit, Standby / On / Off The behavioral connection between the objects is not part of the statecharts language itself.

17 Executable Visual Languages for System Development17 Rhapsody Implementation Rhapsody generates code (in Java / C++ / C) for all the statecharts. This code collectively can be fully executed. During code generation, syntax errors in the statecharts are reported. It is necessary to initialize the static objects, through Rhapsody configuration menu.

18 Executable Visual Languages for System Development18 Object Model Diagram Static structure model It is necessary to have a connection to refer from one object to another Objects can have methods, attributes Each object can have a statechart

19 Executable Visual Languages for System Development19 Rhapsody Statechart Syntax Rountangle inside a Roundtangle creates hierarchy Arrow connection between states, is a change in behavior. Change a transition get a behavior change. Lets go to semantics…

20 Executable Visual Languages for System Development20 Start working with Rhapsody 1.Choose your language 2.Define object(s) in the OMD 3.Define statechart for an object 4.Set the configuration a.Initialize to have animation b.Initialize object instantiation 5.Generate code from statecharts (resolve errors) 6.Compile the code (java/c++) (resolve errors)

21 Executable Visual Languages for System Development21 Start working with Rhapsody 7.Run in animation mode 8.In animation mode you can choose an object instance and open the instance of the statechart 9.Insert an event to start the behavior.

22 Executable Visual Languages for System Development22 Small Example in Rhapsody Add class Light Add On and Off states Generate / Compile / Run Add printfs and inject events Add animation View instance statechart

23 Executable Visual Languages for System Development23 Small Example in Rhapsody

24 Executable Visual Languages for System Development24 Small Example in Rhapsody Add Orthogonality

25 Executable Visual Languages for System Development25 Statecharts Usage Useful for those with systematic perspective (perhaps less for software developers) Consider that procedural planning is not the same as Statecharts planning.

26 Executable Visual Languages for System Development26 Modeling Tips Try to think what are the states, and what are the transitions. Operations that take time are usually better in states and not on transitions. In some cases to model an interaction its useful to have an interaction object. Think what is really independent to create orthogonality. Many ways to do the same thing – condition, additional states, actions, etc.

27 Executable Visual Languages for System Development27 Home Alarm Example Elaborate example with multiple objects Includes GUI, not necessary in our projects

28 Executable Visual Languages for System Development28 Dishwasher Example Note: Rhapsody also has inheritance and abstract classes

29 Executable Visual Languages for System Development29 Technical Directions, Tips, Frequently Asked Questions on the web: sLang2011/ sLang2011/ After selecting a project to model, consult with one of the TAs, schedule meetings by michal.gordon / shahar.maoz. If you encounter problems (that cant be solved using the help, the web, your friends) ask us for help by michal.gordon / naamah.bloch. Submission date for 1 st project:


Download ppt "Statecharts Executable Visual Languages for System Development, Fall 2010."

Similar presentations


Ads by Google