Presentation is loading. Please wait.

Presentation is loading. Please wait.

State Machines and Object Life Cycles G. Falquet, L. Nerima.

Similar presentations


Presentation on theme: "State Machines and Object Life Cycles G. Falquet, L. Nerima."— Presentation transcript:

1 State Machines and Object Life Cycles G. Falquet, L. Nerima

2 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 2 Another Modelling Dimension vDynamic view of the objects vHow objects evolve, change their state

3 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 3 State Machine vSpecify a sequence of states that an object goes through in response to events vDescribe object life cycles vCentred on one object vContains object states and state transitions vStrong theoretical background: finite state automata, Petri nets, state charts (Harel). Real-time systems.

4 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 4 State (of an object) vSituation during the life of an object vDuring this situation the object vsatisfies some condition vor performs some activity vor waits for some event vA state can have substates (finer description)

5 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 5 Example: Document in preparation submitted for comments under revision published archived

6 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 6 Event v"Noteworthy occurrence that has a location in time and space." vCan trigger a state transition (+ actions). vKinds of event: vcall (operation), vchange (something has changed in the system), vsignal (send an event to another object), vtime (timer, timeout,...)

7 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 7 A Simple State Machine for Books available borrowed borrow return transition composite or-state vA transition can be fired only if the object is in the source state and the event occurs.

8 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 8 Another State Machine for Books available borrowed borrow return returned check unavailable steal lose discard find consider as lost final state, object deleted

9 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 9 Completion transitions idle insert card selecting cancel checking completion transition vTriggered by the completion of the state's activity vNotation: no event name printing

10 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 10 Event triggered actions vA transition may execute an action vActions are atomic (assignment, send signal, create object, create link, …) vActions must be fast (≠ complex computation) choose pick date / add to selection push "on"/reset selection push "done" push "reset" / reset selection idle selected

11 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 11 Guarded transitions vGuard = additional condition on a transition vTransition fired only if guard is true vOnly one transition fired if several guards are true vGuards are queries (may not change values) waiting going up going down button pressed [selected > current] [selected < current] [selected = current]

12 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 12 Guarded completion idle insert card selecting cancel checking printing [operation allowed] [operation refused]

13 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 13 Concurrent states vAn object may be in two (or more) states at the same time. vBook: (borrowed + reserved) vBook: (borrowed + not reserved) v=> Large number of combinations vComposite concurrent states

14 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 14 Concurrent states (and states) borrowing reserving condition vBeing in state Active means being simultaneously in states condition, borrowing, reserving. Active

15 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 15 Composite concurrent states available borrowed borrow return reserved no reservation cancel reservation reserve borrowing reserving condition new good to_be_repaired decide to repair

16 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 16 Concurrent active states available borrowed borrow return reserved no reservation reserve cancel reservation initial state

17 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 17 Concurrent active states available borrowed borrow return reserved no reservation reserve cancel reservation

18 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 18 Concurrent active states available borrowed borrow return reserved no reservation reserve cancel reservation

19 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 19 Concurrent active states available borrowed borrow return reserved no reservation reserve cancel reservation

20 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 20 Concurrent active states available borrowed borrow return reserved no reservation reserve cancel reservation

21 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 21 Concurrent active states available borrowed borrow return reserved no reservation reserve cancel reservation

22 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 22 Concurrent active states available borrowed borrow return reserved no reservation reserve cancel reservation

23 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 23 Transitions on the same event A B f g C D f f h vWhat happens if A is active and f occurs ? vNon determinism in an or-state

24 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 24 In concurrent composite states available borrowed borrow return reserved no reservation reserve cancel reservation borrow

25 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 25 In concurrent composite states available borrowed borrow return reserved no reservation reserve cancel reservation borrow

26 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 26 Events triggered by other events available borrowed borrow / cancel reservation return reserved no reservation reserve cancel reservation action = signal

27 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 27 Events triggered by other events available borrowed borrow / cancel reservation return reserved no reservation reserve cancel reservation

28 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 28 Events triggered by other events available borrowed borrow / cancel reservation return reserved no reservation reserve cancel reservation

29 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 29 Complex transitions vCreate parallelism vTerminate parallelism (wait) available borrowed borrow return reserved no reservation reserve cancel reservation entered withdrawn fork join

30 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 30 Formation rules for complex transitions A vEnter all concurrent subregions vLeave all concurrent subregions

31 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 31 Default rules for complex transitions A vActivate the initial state. vLeave the active substate.

32 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 32 Structured design of state machines vComposition of and/or states (refinement) v=> no synchronisation problems (deadlocks, etc.) v=> expressiveness slightly limited and A1 A2 A or A11 A12 A13 and

33 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 33 Example ordered received entered withdrawn in use

34 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 34 Refinement available borrowed borrow return reserved no reservation reserve cancel reservation ordered received entered withdrawn in use

35 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 35 Design consideration vState machines form the highest level of abstraction in the "dynamics" dimension vState machines are not flow charts ! vdo not try to express algorithms, methods, computations, etc. with StM vStates must correspond to specific behaviour, conditions, etc. (avoid infinite modelling) vLocal dynamics: state machine of an object vGlobal dynamics: all the state machines (with signals)

36 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 36 Implementation vState machines are executable v=> implementation with a state monitor/controller v(transaction monitors, real-time systems, …) vGenerally: transformation into data structures and program code vState ---> attribute value or link. vBook:borrowed == linked to a Loan object. vReport:approved == status = 'a' vTransitions ---> execution of an operation/method.

37 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 37 State Machines and Use Cases (Douglass 2000) vCan represent all possible scenarios on a single diagram. vA scenario is a path through the state machine. vUseful to elaborate complex protocols of actor-system interaction. vrepresent actor -> system messages as triggering events and conditions vrepresent system -> actor messages as actions vPossible to execute (simulate) the state machine to check accuracy and completeness. http://iamwww.unibe.ch/CHOOSE/Events/forum2k/douglass.pdf

38 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 38 Example Interaction: The operator can enter commands to control a telescope system, subject to a number of constraints vWhen the telescope is idle, the system may be configured, maintained, or commanded to move. vThe system will not accept a command when the telescope is currently moving except stop or turn off. vWhenever the telescope is moving, monitored position is displayed in a blinking form. vWhen the telescope is stopped, the monitored position is non-blinking. vAfter configuration is complete, the user must reinitialise the system. vTelescope position is displayed on a user-defined periodic basis.

39 ISIISI June 2001 - G. Falquet, L. NerimaState Machines 39 Off On Ready entry/Blink(Off) entry/initialise Configuring do_maintenance Moving entry/Blink(On) Waiting tm(UpdateTime)/ p = getPos() display(p) move stop maintain maint_done configure reinitialise turnOn turnOff


Download ppt "State Machines and Object Life Cycles G. Falquet, L. Nerima."

Similar presentations


Ads by Google