Statecharts and Object Orientation Everything you always wanted to know –But were afraid to ask.

Slides:



Advertisements
Similar presentations
State Diagram 1. State diagram: Shows the behavior of one object. They describe all of the possible states that a particular object can get into and how.
Advertisements

NCKU EE RTES LAB.1 Unified Modeling Language - Events and State Machines.
Statecharts Semantics
Brief Intro to ns2: The most widely used Network Simulator COMP5416 Advanced Network Technologies Based on: Marc Greis's
 A quantum is the amount of time a thread gets to run before Windows checks.  Length: Windows 2000 / XP: 2 clock intervals Windows Server systems: 12.
1 Chapter 4 Dynamic Modeling and Analysis (Part I) Object-Oriented Technology From Diagram to Code with Visual Paradigm for UML Curtis H.K. Tsang, Clarence.
The Rhapsody in C++ Tool Training "Essential" © I-Logix v2.3 25/9/2000 Bas-1 Essential Rhapsody in C++ Section 2 Basic Level.
Unified Modeling Language Unit 4. Dynamic Modeling.
© I-Logix Rhapsody C++ V /01/2004 E1-1 Exercise 2 : Count Down.
State Machines and Object Life Cycles G. Falquet, L. Nerima.
אביב תשס " ה JCT תיכון תוכנה ד " ר ר ' גלנט / י ' לויאןכל הזכויות שמורות 1 פרק 12 אינטרקציה בין statecharts של אובייקטים שונים דוגמא : Dishwasher.
THE OBJECT-ORIENTED DESIGN WORKFLOW Statechart Diagrams.
Cognitive Metrics for the Management of Model-based Software Development Reuven Gallant, Yehuda Badihi, Hagai Sugarman Jerusalem College of Technology-Machon.
State Change Modelling. Aim: To introduce the concept and techniques for describing the changes in state that may occur to an object in its lifetime.
CS 290C: Formal Models for Web Software Lecture 2: Modeling States with Statecharts Instructor: Tevfik Bultan.
© I-Logix Rhapsody C++ V /01/2004 E1-1 Exercise 3 : Dishwasher.
The Rhapsody in C++ Tool Training "Essential" © I-Logix v2.3 25/9/2000 Int-1 Essential Rhapsody in C++ Section 3 Intermediate Level.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 10: Statecharts.
SE-565 Software System Requirements More UML Diagrams.
An Introduction to Rational Rose Real-Time
State and Sequence Diagrams Modelling dynamic information So far we have seen: Use Case Diagrams – requirements capture, interface.
CS451 Introduction to Software Engineering Behavioral Modeling.
State Machine Diagram Chapter 10. State Machine Diagram Used to describe system behavior.
Lecture 4 Finite State Machine CS6133 Software Specification and Verification.
Chapter 10 State Machine Diagrams
מידול התנהגותי 1. Today’s Session Sequence Diagrams State Machines 2.
1 Object-Oriented Modeling Using UML (2) CS 3331 Fall 2009.
Business Informatics Group Institute of Software Technology and Interactive Systems Vienna University of Technology Favoritenstraße 9-11/188-3, 1040 Vienna,
NJIT Modeling Behavior in State Chart Diagrams Chapter 29 Rafael Mello.
Behavioral diagrams Lecture p4 T120B pavasario sem.
Object-Oriented Modeling Using UML CS 3331 Section 2.3 of Jia 2003.
1 Modeling interactions and behavior Lecturer Dr. Mai Fadel.
Session 22 Modeling the Extended Features of the Statechart Written by Thomas A. Pender Published by Wiley Publishing, Inc. October 27, 2011 Presented.
Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.
Sequence diagram in UML Martin Palkovik. Sequence diagram  It is a graphic representation of system operations based on chronology - a time sequence.
Timer Timer is a device, which counts the input at regular interval (δT) using clock pulses at its input. The counts increment on each pulse and store.
Information System Design IT60105
By: David Harel & Eran Grey Presenter: Elizabeth Antony CISC 836.
1 Kyung Hee University Statecharts Spring Kyung Hee University Specifying Objects’ Behaviour  Interaction diagrams show message-passing behaviour.
Basic & Advanced Reporting in TIMSNT ** Part Three **
CS 290C: Formal Models for Web Software Lecture 2: Navigation Modeling with Statecharts Instructor: Tevfik Bultan.
Object Oriented Analysis & Design & UML (Unified Modeling Language)1 Part VI: Design Continuous Activity Diagams State Diagrams.
Copyright Flying Kiwi Productions Inc. 1 An Introduction to Object-Oriented Analysis Objects and UML in plain English. Chapter.
States.
UML: State Chart Diagrams
CS3773 Software Engineering Lecture 06 UML State Machines.
Statechart Diagrams. Creating a Statechart Diagram A Statechart diagram shows the life cycle of a single object, from the time that it is created until.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 10: Statecharts.
The Dynamic Analysis Model StateCharts Prof. Hany H. Ammar, CSEE, WVU, and Dept. of Computer Science, Faculty of Computers and Information, Cairo University.
Test Generation from UML Specifications Michael A. Gray American University Washington, DC.
® IBM Software Group © 2009 IBM Corporation Module 11: Creating State Machine Diagrams Essentials of Modeling with IBM Rational Software Architect V7.5.
Rhapsody 2003년 3월 12일 배대호.
אביב תשס " ה JCT תיכון תוכנה ד " ר ר ' גלנט / י ' לויאןכל הזכויות שמורות 1 פרק 5 תרשימי מצבים Statecharts למחלקות תגובתיות Reactive Classes הקדמה ודוגמא.
Object-Oriented Analysis and Design
State Machine Model.
State Machine Diagram.
Dynamic Modeling of Banking System Case Study - I
Object-Oriented Systems Analysis and Design Using UML
UML State Diagrams.
Finite State Machines and Statecharts
UML State machine diagram
States.
Advanced State Chart diagrams
State Diagrams.
Chapter 10 Object States and The Statechart Diagram
Finite State Machines and Statecharts
States.
UML State Diagrams.
Essential Rhapsody in C++
State-Transition Diagrams
Presentation transcript:

Statecharts and Object Orientation Everything you always wanted to know –But were afraid to ask

Transitions Default Transition –No events or conditions –Can have actions Regular transition –Event[condition]/action –tm() is an event Null transition –[condition]

Default Transition

Regular Transition

What happens when evGo is taken? Condition is evaluated –Is ready true? If condition is true, actions on exit from state active are executed –In this case there aren’t any object exits state “active” actions on transition are executed – /doit() object enters state “idle” Object executes action on entry to state “idle” –In this case there aren’t any

timeout object enters state “rinsing” timer is set: set tm(1000) tm(1000) occurs 1000 ms later

Null Transition isRinsed() is a guard on null transition isRinsed() is evaluated every time object takes event

Timeout with Null Transition isRinsed() is a guard on null transition Boolean isRinsed() {return(0==rinseTime);} isRinsed() is evaluated every time tm(1000) occurs If “rinsing” is entered for the first time at 0000, at what time(s) is isRinsed() invoked?

Timeout with guarding Condition If “rinsing” is entered for the first time at 0000, at what time(s) is isRinsed() invoked?

What happens in a state?

Or-states (1)

Or-states (2)-transition from superStates Object is in state “pulsing” Object takes event “evJetOff” What happens?

Or-states (3)-transition to superStates Object is in state “idle” Object takes event “evX” What happens?

Or-states (4)-transition to history Object is in state “rinsing” Object takes event “evOpen” What happens? Object takes event “evClose” What happens?

and-states(1) event generated in one state, used in another What is the default state of the object? If startBehavior finished at 0000, what happens between 0000 and 7000?

and-states(2) what is default state?

Events sent between objects Dishwasher Tank Dishwasher takes event evStart. What happens?

Tracer Commands output –output mytrace.txt timestamp –OMTracer (0:00:00.000) go –Run go idle – takes next event in queue – if no event in queue, but there is a scheduled timeout, advances clock and takes timeout event

Tracer Messages (1) Invoked –Dishwasher[0] Invoked isInNeedOfService() Returned –Dishwasher[0]->isInNeedOfService() Returned set tm() –Dishwasher[0] set tm(10000) at ROOT.active.running.doorClosed.rinsing Sent Event –Dishwasher[0] Sent to AcmeTank[0] Event evTankFill() Received Event –AcmeTank[0] Received from Dishwasher[0] Event evTankFill() Note: object can send event to itself –AcmeTank[0] Sent to itself Event tm(4000) at ROOT.filling – AcmeTank[0] Received from itself Event tm(4000) at ROOT.filling Object entered state –Dishwasher[0] Entered State ROOT.active Object exited state –Dishwasher[0] Exited State ROOT.active.mode.normalMode

Tracer Messages (2) object cancelled timeout –AcmeJet[0] cancelled tm(1000) at ROOT.running.pulsing.left –When does this occur? Object modified Attribute values –Dishwasher[0] Modified Attribute Values dryTime3000 washTime8000 cycles1 rinseTime10000

Start Behavior (1) Object enters root state –Display[0] enters ROOT Object enters each sub-state –Display[0] enters ROOT.active For each state entered, object executes entry actions (if there are any) Object executes actions on default transition (if there are any)

Start Behavior (2) If the initial state has an exit transition triggered by timeout: –Object does set tm() when state entered If there is a state with a null transition: –Object sends OMStartBehaviorEvent –After StartBehavior finishes, object receives OMStartBehaviorEvent, and evaluates the condition on the null transition.

StartBehavior-countdown OMTracer (0:00:00.000) main() Invoked Display[0]->Start Behavior OMTracer (0:00:00.000) Display[0] Entered State ROOT OMTracer (0:00:00.000) Display[0] Invoked print(string = started) OMTracer (0:00:00.000) Display[0]->print(string = started) Returned OMTracer (0:00:00.000) Display[0] Entered State ROOT.active OMTracer (0:00:00.000) Display[0] set tm(200) at ROOT.active OMTracer (0:00:00.000) Display[0]->Start Behavior Returned

StartBehavior-dishwasher OMTracer (0:00:00.000) main() Invoked Dishwasher[0]->Start Behavior OMTracer (0:00:00.000) Dishwasher[0] Entered State ROOT OMTracer (0:00:00.000) Dishwasher[0] Entered State ROOT.active OMTracer (0:00:00.000) Dishwasher[0] Entered State ROOT.active.running OMTracer (0:00:00.000) Dishwasher[0] Entered State ROOT.active.running.doorClosed OMTracer (0:00:00.000) Dishwasher[0] Entered State ROOT.active.running.doorClosed.off OMTracer (0:00:00.100) Dishwasher[0] Entered State ROOT.active.mode OMTracer (0:00:00.100) Dishwasher[0] Entered State ROOT.active.mode.normalMode OMTracer (0:00:00.100) Dishwasher[0] Entered State ROOT.active.maintenance OMTracer (0:00:00.100) Dishwasher[0] Entered State ROOT.active.maintenance.maintenanceOk OMTracer (0:00:00.100) Dishwasher[0] Sent to itself Event OMStartBehaviorEvent OMTracer (0:00:00.100) Dishwasher[0]->Start Behavior Returned OMTracer (0:00:00.100) Dishwasher[0] Modified Attribute Values modeRinseTime10000 modeWashTime20000 modeDryTime5000

After Start Behavior returns-dishwasher takes OMStartBehavior Event (0:00:00.100) Dishwasher[0] Received from itself Event OMStartBehaviorEvent (0:00:00.100) main() Invoked Dishwasher[0]->Take Event OMStartBehaviorEvent() (0:00:00.100) Dishwasher[0] Invoked isInNeedOfService() (0:00:00.100) Dishwasher[0]->isInNeedOfService() Returned (0:00:00.100) Dishwasher[0]->Take Event OMStartBehaviorEvent() Returned

Take event-countdown

Take event-countdown(1) first cycle Please enter OMTracer Command>> go idle OMTracer (0:00:00.200) Display[0] Sent to itself Event tm(200) at ROOT.active OMTracer (0:00:00.200) Display[0] Received from itself Event tm(200) at ROOT.active OMTracer (0:00:00.200) main() Invoked Display[0]->Take Event Timeout OMTracer (0:00:00.200) Display[0] Invoked isDone() OMTracer (0:00:00.200) Display[0]->isDone() Returned OMTracer (0:00:00.200) Display[0] Exited State ROOT.active OMTracer (0:00:00.200) Display[0] Invoked print(n = 1) OMTracer (0:00:00.200) Display[0]->print(n = 1) Returned OMTracer (0:00:00.200) Display[0] Entered State ROOT.active OMTracer (0:00:00.200) Display[0] set tm(200) at ROOT.active OMTracer (0:00:00.200) Display[0]->Take Event Timeout Returned Executable is Idle

Take event-countdown(2) termination Please enter OMTracer Command>> go idle OMTracer (0:00:00.400) Display[0] Sent to itself Event tm(200) at ROOT.active OMTracer (0:00:00.400) Display[0] Received from itself Event tm(200) at ROOT.active OMTracer (0:00:00.400) main() Invoked Display[0]->Take Event Timeout OMTracer (0:00:00.400) Display[0] Invoked isDone() OMTracer (0:00:00.400) Display[0]->isDone() Returned OMTracer (0:00:00.400) Display[0] Exited State ROOT.active OMTracer (0:00:00.400) Display[0] Invoked print(n = 0) OMTracer (0:00:00.400) Display[0]->print(n = 0) Returned OMTracer (0:00:00.400) Display[0] Invoked print(string = Done) OMTracer (0:00:00.400) Display[0]->print(string = Done) Returned OMTracer (0:00:00.400) Display[0] Reached Termination State OMTracer (0:00:00.400) Display[0]->Take Event Timeout Returned OMTracer (0:00:00.400) main() Invoked Display[0]->~Display() OMTracer (0:00:00.400) Display[0]->~Display() Returned OMTracer (0:00:00.400) Instance Display[0] of class Display deleted by main() Executable is Idle

Take event-dishwasher Dishwasher takes evStart

Take event-dishwasher(1) Dishwasher takes evStart Please enter OMTracer Command>> go idle OMTracer (0:00:00.100) Sent to Dishwasher[0] Event evStart() OMTracer (0:00:00.100) Dishwasher[0] Received from Event evStart() Executable is Idle OMTracer (0:00:00.100) main() Invoked Dishwasher[0]->Take Event evStart() OMTracer (0:00:00.100) Dishwasher[0] Exited State ROOT.active.running.doorClosed.off Please enter OMTracer Command>> go idle OMTracer (0:00:00.100) Dishwasher[0] Invoked setup() OMTracer (0:00:00.100) Dishwasher[0]->setup() Returned OMTracer (0:00:00.100) Dishwasher[0] Modified Attribute Values dryTime3000 washTime 8000 cycles 1 rinseTime10000 OMTracer (0:00:00.100) Dishwasher[0] Entered State ROOT.active.running.doorClosed.filling OMTracer (0:00:00.100) Dishwasher[0] Sent to AcmeTank[0] Event evTankFill() OMTracer (0:00:00.100) Dishwasher[0] Invoked isInNeedOfService() OMTracer (0:00:00.100) Dishwasher[0]->isInNeedOfService() Returned OMTracer (0:00:00.100) Dishwasher[0]->Take Event evStart() Returned

Take event-dishwasher(2) Dishwasher takes evStart OMTracer (0:00:00.100) AcmeTank[0] Received from Dishwasher[0] Event evTankFill() OMTracer (0:00:00.200) main() Invoked AcmeTank[0]->Take Event evTankFill() OMTracer (0:00:00.200) AcmeTank[0] Exited State ROOT.empty OMTracer (0:00:00.200) AcmeTank[0] Entered State ROOT.filling OMTracer (0:00:00.200) AcmeTank[0] set tm(4000) at ROOT.filling OMTracer (0:00:00.200) AcmeTank[0]->Take Event evTankFill() Returned Executable is Idle Please enter OMTracer Command>> go idle OMTracer (0:00:04.200) AcmeTank[0] Sent to itself Event tm(4000) at ROOT.filling OMTracer (0:00:04.200) AcmeTank[0] Received from itself Event tm(4000) at ROOT.filling OMTracer (0:00:04.200) main() Invoked AcmeTank[0]->Take Event Timeout OMTracer (0:00:04.200) AcmeTank[0] Exited State ROOT.filling OMTracer (0:00:04.200) AcmeTank[0] Sent to Dishwasher[0] Event evFull() OMTracer (0:00:04.300) Dishwasher[0] Received from AcmeTank[0] Event evFull() OMTracer (0:00:04.300) main() Invoked Dishwasher[0]->Take Event evFull() OMTracer (0:00:04.300) Dishwasher[0] Exited State ROOT.active.running.doorClosed.filling OMTracer (0:00:04.300) Dishwasher[0] Entered State ROOT.active.running.doorClosed.rinsing

Sequence Diagrams System Line (for main) Instance lines (for each object) Time goes from top to bottom Events- slanted line between objects Operations- horizontal line between objects object can send to itself –Events, operations, timeouts

countdown

Sequence Diagram-countdown

Dishwasher

Sequence Diagram-dishwasher(1)

Sequence Diagram-dishwasher(2)