software design modelling and analysis in uml
play

Software Design, Modelling and Analysis in UML Lecture 16: - PowerPoint PPT Presentation

Software Design, Modelling and Analysis in UML Lecture 16: Hierarchical State Machines I 2014-01-15 16 2014-01-15 main Prof. Dr. Andreas Podelski, Dr. Bernd Westphal Albert-Ludwigs-Universit at Freiburg, Germany Contents


  1. Software Design, Modelling and Analysis in UML Lecture 16: Hierarchical State Machines I 2014-01-15 – 16 – 2014-01-15 – main – Prof. Dr. Andreas Podelski, Dr. Bernd Westphal Albert-Ludwigs-Universit¨ at Freiburg, Germany

  2. Contents & Goals Last Lecture: • Putting it all together: UML model semantics (so far) • Rhapsody demo, code generation This Lecture: • Educational Objectives: Capabilities for following tasks/questions. • What does this State Machine mean? What happens if I inject this event? • Can you please model the following behaviour. • What does this hierarchical State Machine mean? What may happen if I inject this event? • What is: AND-State, OR-State, pseudo-state, entry/exit/do, final state, . . . • Content: – 16 – 2014-01-15 – Sprelim – • State Machines and OCL • Hierarchical State Machines Syntax • Initial and Final State • Composite State Semantics • The Rest 2 /59

  3. State Machines and OCL – 16 – 2014-01-15 – main – 3 /59

  4. • Let M = ( C D , S M , O D ) be a UML model. • We call M consistent iff, for each OCL constraint expr ∈ Inv ( C D ) , OCL Constraints and Behaviour Note : we could define Inv ( S M ) similar to Inv ( C D ) . σ | = expr for each “reasonable point” ( σ, ε ) of computations of M . (Cf. exercises and tutorial for discussion of “reasonable point”.) S M doesn’t exist yet, then M = ( C D , ∅ , O D ) S M such that M ′ = ( C D , S M , O D ) is consistent. Pragmatics : • In UML-as-blueprint mode , if S M is given, then constraints are also considered when choos- is typically asking the developer to provide S M never move to inconsistent configurations. – 16 – 2014-01-15 – Sstmocl – If the developer makes a mistake, then M ′ is inconsistent. • Not common : if ing transitions in the RTC-algorithm. In other words: even in presence of mis- takes, the 4 /59

  5. Hierarchical State Machines – 16 – 2014-01-15 – main – 5 /59

  6. UML State-Machines: What do we have to cover? PA Client [ true ] / [St¨ orrle, 2005] [ausstehendeAufrufe = ausstehendeAufrufe @pre + 1 ] anmelden()/ Die Zustandsübergänge von abgemeldet angemeldet Protokoll-Zustandsautomaten abmelden()/ Wenn der Endzustand eines verfügen über eine Zustandsautomaten erreicht Vorbedingung , einen [ ausstehendeAufrufe>1 ] wird, wird die Region beendet, Auslöser und eine empfangeErgebnisse(nr, parameter) / in der der Endzustand liegt. Nachbedingung (alle [ausstehendeAufrufe = ausstehendeAufrufe @pre - 1] optional) – jedoch nicht über einen Effekt. Protokollzustandsautomaten beschreiben Ein Eintrittspunkt definiert, dass ein komplexer das Verhalten von Softwaresystemen, Reguläre Beendigung löst ein Zustand an einer anderen Stelle betreten wird, als Nutzfällen oder technischen Geräten. completion -Ereignis aus. durch den Anfangszustand definiert ist. ZA Boarding when(Drehkreuzsensor=”drehen”) Ein komplexer Zustand mit / Drehkreuz blockieren Ein Zustand löst von sich aus einer Region. Bordkarte einlesen bestimmte Ereignisse aus: Passagier überprüfen Bordkarte akzeptieren Validität - entry beim Betreten; entry/Suchanfrage starten entry/Karte auswerfen überprüfen do/Anzeigelämpchen blinkt do/Drehkreuz freigeben - do während des [ valide ] Aufenthaltes; Der Anfangszustand markiert Ergebnis der Such- - completion beim Erreichen timeout den voreingestellten Startpunkt Passagier-ID after(10s) anfrage liegt vor des Endzustandes einer von „ Boarding “ bzw. „ Bordkarte after(10s) auslesen / Drehkreuz blockieren Unter-Zustandsmaschine einlesen “ . /timeout [ Passagier - exit beim Verlassen. angemeldet ] Passagier Bordkarte identifizieren aussetzen Das Zeitereignis after(10s) löst Diese und andere Ereignisse [ Passagier zurückweisen einen Abbruch von „ Bordkarte können als Auslöser für warten nicht wieder einlesen “ aus. Aktivitäten herangezogen H angemeldet ] aufnehmen werden. Der Gedächtniszustand sorgt Der Austrittspunkt erlaubt es, von Ein Zustand kann eine oder dafür, dass nach dem Wieder- einem definierten inneren Zustand mehrere Regionen enthalten, aufnehmen der gleiche Zustand aus den Oberzustand zu verlassen. wie vor dem Aussetzen einge- die wiederum Zustands- nommen wird. automaten enthalten können. Wenn ein Zustand mehrere Regionen enthält, werden – 16 – 2014-01-15 – Shiersyn – ZA Kartenleser ZA Boardingautomat (HW) diese in verschiedenen Abteilen angezeigt, die durch Auch Zeit- und Änderungs- drehkreuz gestrichelte Linien ereignisse können Zustands- leer voneinander getrennt sind. übergänge auslösen: an/ gesperrt Regionen können benannt werden. Alle Regionen - after definiert das when(k=1)/ when(k=0)/ “Drehkreuz “Drehkreuz werden parallel zueinander “Karte liegt an” Verstreichen eines Intervalls; blockieren” freigeben” abgearbeitet. “Karte zurückweisen” - when definiert einen / setze(s,1) / setze(s,0) / setze(f,-1) Zustandswechsel. bereit Wenn ein Regionsend- freigegeben zustand erreicht wird, wird der Zustände und zeitlicher “Karte laden” / “Karte auswerfen” gesamte komplexe Zustand when(d>0) / Bezugsrahmen werden über setze(f,1) / setze(f,1) beendet, also auch alle “Kreuz dreht sich” den umgebenden Classifier parallelen Regionen. aus/ definiert, hier die Werte der belegt K a r t e n l e s e r Ein verfeinerter Zustand Ports, siehe das Montage- “Karte auslesen” / when(k=0) / setze(f,0) verweist auf einen Zustands- diagramm „ Abfertigung “ links inhalt = i 6 /59 automaten (angedeutet von oben. dem Symbol unten links), der

  7. The Full Story UML distinguishes the following kinds of states : example example pseudo-state s 1 • initial entry / act entry 1 do / act do (shallow) history H 1 simple state exit / act exit 1 E 1 / act E 1 deep history H ∗ . . . E n / act E n fork/join , final state junction, choice , composite state • s s 1 entry point OR – 16 – 2014-01-15 – Shiersyn – s 2 s 3 exit point s terminate s 1 s 2 s 3 AND s ′ s ′ s ′ submachine state S : s 1 2 3 7 /59

  8. E S S Representing All Kinds of States s 0 ∈ S, → ⊆ S × ( E ∪ { } ) × Expr S × S S × Act • Until now : ( S, s 0 , → ) , – 16 – 2014-01-15 – Shiersyn – 8 /59

  9. Representing All Kinds of States s 0 ∈ S, → ⊆ S × ( E ∪ { } ) × Expr S × S S × Act • Until now : ( S, s 0 , → ) , • From now on : ( hierarchical ) state machines ( S, kind , region , → , ψ, annot ) where • S ⊇ { top } is a finite set of states (as before) , • kind : S → { st , init , fin , shist , dhist , fork , join , junc , choi , ent , exi , term } is a function which labels states with their kind , (new) • region : S → 2 2 S is a function which characterises the regions of a state, • annot : ( → ) → ( E ∪ { } ) × Expr S provides an annotation for S × Act (new) • → is a set of transitions, (changed) – 16 – 2014-01-15 – Shiersyn – • ψ : ( → ) → 2 S × 2 S is an incidence function , and (new) each transition. (new) ( s 0 is then redundant — replaced by proper state (!) of kind ‘ init ’.) 8 /59

  10. From UML to Hierarchical State Machines: By Example ( S, kind , region , → , ψ, annot ) example ∈ S kind region simple state s s ∅ st final state q ∅ fin composite state s s 1 {{ s 1 , s 2 , s 3 }} OR , s st s 2 s 3 region s {{ s 1 , s ′ 1 } , { s 2 , s ′ 2 } , AND s 1 s 2 s 3 s st { s 3 , s ′ 3 }} – 16 – 2014-01-15 – Shiersyn – s ′ s ′ s ′ 1 2 3 submachine state (later) - - - • , . . . ∅ pseudo-state q init , . . . � �� � ( s, kind ( s )) for short 9 /59

  11. From UML to Hierarchical State Machines: By Example DON’T! DON’T! [ gd ] / act tr • annot s ... translates to ( S, kind , region , → , ψ, annot ) = ( { ( top , st ) , ( s 1 , init ) , ( s, st ) , ( s 2 , fin ) } , � �� � S, kind { top �→ {{ s 1 , s, s 2 }} , s 1 �→ ∅ , s �→ ∅ , s 2 �→ ∅} , � �� � region – 16 – 2014-01-15 – Shiersyn – { t 1 , t 2 } { t 1 �→ ( { s 1 } , { s } ) , t 2 �→ ( { s } , { s 2 } ) } , , � �� � � �� � ψ → { t 1 �→ ( tr , gd , act ) , t 2 �→ annot } ) � �� � annot 10 /59

  12. Well-Formedness: Regions (follows from diagram) region ⊆ 2 S , S i ⊆ S ∈ S child ⊆ S kind simple state s ∅ ∅ st ∅ ∅ final state s fin composite state s { S 1 , . . . , S n } , n ≥ 1 S 1 ∪ · · · ∪ S n st pseudo-state s init , . . . ∅ ∅ { S 1 } implicit top state S 1 top st • Each state (except for top ) lies in exactly one region, • States s ∈ S with kind ( s ) = st may comprise regions. • No region: simple state. • One region: OR-state. – 16 – 2014-01-15 – Shiersyn – • Two or more regions: AND-state. • Final and pseudo states don’t comprise regions. • The region function induces a child function. 11 /59

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend