statecharts for the many statecharts for the many
play

Statecharts for the many: Statecharts for the many: Algebraic State - PowerPoint PPT Presentation

Statecharts for the many: Statecharts for the many: Algebraic State Algebraic State Transition Diagrams Transition Diagrams Marc Frappier Marc Frappier GRIL Groupe de recherche en Groupe de recherche en GRIL ing nierie du


  1. Statecharts for the many: Statecharts for the many: Algebraic State Algebraic State Transition Diagrams Transition Diagrams Marc Frappier Marc Frappier GRIL – – Groupe de recherche en Groupe de recherche en GRIL ingé énierie du logiciel nierie du logiciel ing 1

  2. Plan Plan � Statecharts and information system Statecharts and information system � specifications specifications � ASTD : Algebraic State Transition ASTD : Algebraic State Transition � Diagrams Diagrams � Semantics of ASTD Semantics of ASTD � � Conclusion Conclusion � 2

  3. Statecharts Statecharts � graphical notation graphical notation � � hierarchy + orthogonality hierarchy + orthogonality � � hierarchical states hierarchical states � � AND states (parallel) AND states (parallel) � � OR states (choice) OR states (choice) � � nice for single instance behaviour nice for single instance behaviour � � parameterized states in parameterized states in Harel Harel’ ’s s seminal paper seminal paper � (SCP 87) (SCP 87) � “ “ never never ” ” implemented or formalised implemented or formalised � 3

  4. A library in statecharts A library in statecharts 4

  5. Problems Problems � only describes behaviour of a single book only describes behaviour of a single book � � how to deal with several books? how to deal with several books? � � put n copies of put n copies of book book in parallel in parallel � � not defined in statecharts or UML not defined in statecharts or UML � � available in ROSE RT, but it is not quite what we want here available in ROSE RT, but it is not quite what we want here � � can discard an unreturned book can discard an unreturned book � � could add a guard to could add a guard to discard � discard � unnecessary complexity unnecessary complexity � � could make discard a transition from an inner state could make discard a transition from an inner state � of loan of loan � introduce coupling between introduce coupling between book and loan book and � loan 5

  6. Potential solutions Potential solutions � book knows about the structure of loan book knows about the structure of loan � � makes loan less reusable makes loan less reusable � � makes maintenance more difficult makes maintenance more difficult � book loan Acquire Lend Renew Discard Return 6

  7. 7 Adding members Adding members

  8. Problems Problems � a member can borrow several books in parallel a member can borrow several books in parallel � � can can’ ’t t “ “easily easily” ” express that in statecharts or UML express that in statecharts or UML � � State explosion State explosion � � two calls to loan two calls to loan � � one in member, one in book one in member, one in book � � they both get the they both get the lend lend event event � � OK if only one member OK if only one member � � KO if we have several members trying to borrow the same KO if we have several members trying to borrow the same � book book � could remove loan from member could remove loan from member � � must add guard to must add guard to Unregister Unregister to check for completed loan to check for completed loan � � loose visual ordering constraint loose visual ordering constraint � 8

  9. Potential solutions Potential solutions � remove loan from member remove loan from member � � loose visual ordering constraint between member loose visual ordering constraint between member � and loan and loan � replaced by a guard replaced by a guard � � need state variable need state variable � member 9

  10. The single instance view: The single instance view: A weakness of statecharts A weakness of statecharts � both statecharts and UML state machines are both statecharts and UML state machines are � designed to represent a single instance designed to represent a single instance � eg eg, controller, object of a class, etc , controller, object of a class, etc � � they offer no convenient means to express they offer no convenient means to express � relationships between multiple instances relationships between multiple instances � in practice, designers only describe the single in practice, designers only describe the single � instance behaviour instance behaviour � leave it to the implementer to figure out the multiple leave it to the implementer to figure out the multiple � instance case instance case 10

  11. A solution: Process algebra A solution: Process algebra � CCS, CSP, ACP, LOTOS, EB CCS, CSP, ACP, LOTOS, EB 3 3 , ... , ... � � algebra algebra � � operators to combine process expressions operators to combine process expressions � � sequence, choice, interleave, synchronisation, guard, ... sequence, choice, interleave, synchronisation, guard, ... � � quantification quantification � � operators are the essence of abstraction operators are the essence of abstraction � � combine small units to build large units combine small units to build large units � � operators foster abstraction by masking internal details operators foster abstraction by masking internal details � 11

  12. A Process expression for books A Process expression for books book(b : BookId ) = matches any value Acquire(b,_) Sequential composition • loan( _, b) ¯ Kleene • closure Discard(b) 12

  13. A process expression for loans A process expression for loans guard loan(mId:Member, IDbId:BookID ) = nbLoans(mId) < maxNbLoans(mId)  Lend(mId, bId) • Renew(bId) ¯ • Return(bId) 13

  14. A process expression for members A process expression for members member(m : MemberId ) = interleave quantification over all books Register(m, _, _) • ( 8 b : BookId : loan( m, b) ¯ ) • Unregister(m) 14

  15. Interleave quantification Interleave quantification 8 x : {1,2,3} : P(x) = P(1) 8 P(2) 8 P(3) 15

  16. Main process expression Main process expression main = ( 8 b : BookId : book(b) ¯ ) 7 ( 8 m : MemberId : member(m) ¯ ) Synchronisation over common actions 16

  17. Synchronisation over common Synchronisation over common actions actions a(1) • b(1) • c(1) 7 |x : T : a(x) • b(x) • c(2) quantified choice = a(1) • b(1) • STOP 17

  18. ASTD ASTD � Algebraic State Transition Diagrams Algebraic State Transition Diagrams � � ASTD = statecharts + process algebra ASTD = statecharts + process algebra � � graphical notation graphical notation � � power of abstraction power of abstraction � � statecharts become elementary process statecharts become elementary process � expressions expressions � combine them using operators combine them using operators � � formal semantics formal semantics � � operational semantics operational semantics � 18

  19. ASTD Operators ASTD Operators � � : sequence : sequence � | | : choice : choice � � |x |x : quantified choice : quantified choice � � ¯ : Kleene closure : Kleene closure �  : guard : guard : parallel composition with synchronisation on A |[ A ]| : parallel composition with synchronisation on � |[ A ]| A � � 8 interleave, interleave, 7 parallel composition parallel composition � 8 x, |[ ]| x : quantified version � ASTD call ASTD call : allows recursive calls : allows recursive calls � 19

  20. A book ASTD A book ASTD operators initial applied from state left to right final transition: can trigger only if its source final state is in a final state 20

  21. Closure applied to an ASTD Closure applied to an ASTD � ¯ means execute the ASTD an arbitrary number of times, including 0 � when the ASTD is in a final state, it can start again from its initial state � example traces are � empty trace � e1,e2,e2,...,e1,e1,e2, ... 21

  22. The closure ASTD type The closure ASTD type ( ¯ , body ) � ¯ denotes the type constructor for a closure � body is an ASTD (of any type) 22

  23. The closure state type The closure state type � ¯ 0 is the closure state type constructor � started? is a boolean value that indicates if its component has started ( ¯ 0 ,started?, s ) its first iteration � s is the state of its component 23

  24. States of a closure States of a closure function that defines the initial state of closure ASTD closure initial state � initial state initial state an ASTD � � is the initial state of its component is the initial state of its component � � final states final states � � its initial state its initial state � � final states of its component final states of its component � function that determines if 24 a state is final

  25. Final state Final state � an ASTD does not terminate when its current an ASTD does not terminate when its current � state is final state is final � a final state simply a final state simply enables enables transitions of another transitions of another � ASTD within a ASTD within a � closure closure � � sequence sequence � 25

  26. 26 A member ASTD A member ASTD

  27. 27 A loan ASTD A loan ASTD

  28. The main ASTD The main ASTD n-ary operator operands of || 28

Recommend


More recommend