際際滷

際際滷Share a Scribd company logo
BAB X
STATE DIAGRAM
Statechart Diagram
- Bersifat dinamis
- Memperlihatkan state-state pada sistem;
  memuat state, transisi, event, serta
  aktivitas.
- Memperlihatkan sifat dinamis dari
  antarmuka, kelas, kolaborasi dan terutama
  penting pada pemodelan sistem-sistem
  yang reaktif
SYSTEMS ANALYSYS AND DESIGN METHODS 5TH Edition                           Whitten Bentley Dittman

Membuat model behavior dari objek-objek

       Setiap objek dapat dikatakan memiliki state ---
        nilai dari attributnya pada suatu saat tertentu.
       State diagram memodelkan daur hidup sebuah
        objek tunggal. Ia menggambarkan macam-
        macam state yang dimiliki sebuah objek, event
        yang mengakibatkan perubahan state selama
        waktu tertentu dan aturan-aturan yang mengatur
        transisi objek antara satu state dengan state
        lainnya.
       Perubahan terhadap state objek terjadi ketika
        ada suatu kejadian atau ketika nilai dari salah
        satu atributnya berubah. Perubahan state ini
        dipicu oleh adanya suatu event.


Irwin/McGraw-Hill                        Copyrighth@2000 The Mcgraw-Hill Companies All Right reserved
Developing Software Woth UML                  Booch Jacobson Rumbaugh




      Sebuah state diagram menunjukkan urut-urutan state
       dari sebuah objek selama masa hidupnya / lifetimenya,
       sekaligus dengan event-event yang menyebabkan
       perubahan dari state tersebut.
      Sebuah state diagram menjelaskan sebuah hypothetical
       machine (finite automaton) yang pada setiap waktu
       berada pada satu set finite state, yang terdiri dari:
      a finite, non-empty set of states;
      a finite, non-empty set of events;
      functions, yg menjelaskan transisi dari satu state ke
       state berikutnya;
      sebuah initial state;
      satu set final state.


Addison-Wesley
Developing Software Woth UML                               Booch Jacobson Rumbaugh

Soal:
      On opening the flight, the initial state leads to the NoReservation
       state. When the state is entered, the Reset operation is executed. If
       a reservation is made for this flight, the object changes to the state
       PartiallyReserved.
      The Reserve event is associated to the homonymous Reserve
       action (implemented as an operation).
      In this operation, the actual reservation takes place, and the internal
       reservation counter is updated. After termination of this action, we
       will find the object in the PartiallyReserved state.
      Each additional reservation leads to the same action. As long as a
       free seats are available, the object remains in the PartiallyReserved
       state. If only one seat left, it changes into FullyBooked state.
       Cancellation of reserved seats is carried out in a similar way. Thus,
       the state diagram describes which actions are triggered by which
       events and under which conditions these (and together with the call
       of the corresponding operations) are permitted.




Addison-Wesley
Developing Software Woth UML                                                     Booch Jacobson Rumbaugh




                                                                     cancel()
                                                                [reservedSeats>1]

                                                                                     reserve()
                                            reserve()
                  NoReservation                                                   [freeSeats>1]
                                                             PartiallyReserved
                   entry/reset()       cancel()                                               reserve()
                                   [ReservedSeats=1]                                       [freeSeats=1]

                                                                cancel()
                           cancelFlight()
                                                 close()
         openFlight()
                                                                                 FullyBooked




                                                                  close()
                                                    Closed




Addison-Wesley
Developing Software Woth UML                 Booch Jacobson Rumbaugh

  State
      Sebuah state dimiliki oleh satu buah Class dan
       merepresentasikan abstraksi atau kombinasi dari
       satu set nilai atribut yang mungkin terjadi pada
       objek tersebut dari class ini.
      Tidak setiap perubahan nilai atribut akan dianggap
       sebagai perubahan state. Hanya event tertentu
       yang sangat signifikan mengakibatkan perubahan
       behavior dari objek.
      Sebuah state oleh karena itu dapat dilihat juga
       sebagai rentang waktu (time span) antara dua
       event.
      Dua type khusus state yang ada adalah initial state
       dan final state.



Addison-Wesley
Developing Software Woth UML                        Booch Jacobson Rumbaugh




      Tidak ada transisi yang menuju initial state dan tidak ada
       event yang diperbolehkan meninggalkan final state.
      Transisi dari satu state ke state berikutnya di trigger /
       dipicu oleh event. Sebuah event terdiri dari nama event
       dan sejumlah argument.
      Event dapat memicu aksi didalam state yang dilakukan
       melalui operasi tertentu.

     Ada tiga trigger yang sudah predefine:
      entry, fires automatically when entering a state
      exit, fires automatically when leaving a state
      do, fires repeatedly as long as the state is active, that is,
       not left.


Addison-Wesley
Developing Software Woth UML                                                       Booch Jacobson Rumbaugh

  Substate
      Sebuah state dapat diuraikan lebih lanjut, baik
       sekuensial ataupun paralel substate.
      Gambar dibawah ini menunjukkan sebuah sequential
       nesting. Ketika kontrak asuransi ditetapkan, sebuah
       produk dipilih (sebagai contoh, content-nya), yang terdiri
       dari beberapa produk element (Pel), seperti furniture,
       gelas, dsb. Untuk setiap produk elemen, sebuah cover
       (istilah asuransi) harus dibuat. Ilustrasi dibawah ini
       menunjukkan Create covers state dari context ini.
                                                 Create Covers
                                             covers:set=Empty set




                               PElQuantity                          Define
                                  Reset                             cover
                                                addPEl                       [isComplete]



                                                                    addPEl


Addison-Wesley
Developing Software Woth UML                                       Booch Jacobson Rumbaugh




        Gambar dibawah ini menunjukkan notasi
        dari paralel substates.

                                    substates

                                       event1
                               S3


                                                                         S4

                               S1               S2

                                    event2           event3



                                       event4                 S5




Addison-Wesley
Developing Software Woth UML               Booch Jacobson Rumbaugh

  Event dan transition

      Sebuah event adalah sebuah kejadian yang
       memiliki pengaruh khusus dalam suatu context yang
       dibicarakan, karena ia men-trigger / memicu
       perubahan state.
      Kebalikan dari state, event bukan milik satu kelas
       tertentu.
      State transition (perubahan state) biasanya dipicu
       oleh adanya event yang digambarkan dengan anak
       panah yang menghubungkan state satu dengan
       state lainnya.



Addison-Wesley
State Transition Diagram

                                                                        Add student[ count < 10 ]
                                         Add Student /
 Initialization                          Set count = 0
                                                                                       Open
do: Initialize course
                                                                               entry: Register student
                                                                                exit: Increment count

                 Cancel

                                                     Cancel                           [ count = 10 ]

                 Canceled
        do: Notify registered students
                                                                             Closed
                                                Cancel                do: Finalize course




                         Copyright 息 1997 by Rational Software Corporation
Transitions
                  event [guard] | action
       x
       x                                           y
                                                   y




                                           The action that
                                           takes place when
The event that      Conditions that        the transition is
triggers the        must be met for        taken
transition          the transition to
                    take place
Transitions
                  event [guard] | action
       x
       x                                           y
                                                   y




                                           The action that
                                           takes place when
The event that      Conditions that        the transition is
triggers the        must be met for        taken
transition          the transition to
                    take place
Events
 General Events
    Method calls: received(customer)
    Event signals: inventoryReady
                                                     created
                                                     created
 Time event
    interval expiry;                                            inventoryReady
     tm(3 days), tm(1000 ms)
    calendar/clock time; when(11:50)                    in gathering
                                                         in gathering
 Change Event:
                                                               false(hasProblems)
    Change in value of some entity;
     false(hasProblems)                          sent
                                                 sent
     true(hasProblems)                                  tm(3 days)
                                        received()



                                         is received
                                                                 in problem
Guards (Conditions)
          gatheringFinished [all items were gathered]
                                                           sent
                                                           sent
    in gathering
    in gathering

                                                        in problem
                                                        in problem
            gatheringFinished [items are not found]



 Boolean expressions.
 Evaluated when the transition is triggered
 Types of guards:
    Simple predicate: [hasProblems], [x > 0]
    Combined predicates:
      [測hasProblems  (hasProblems  order.sum < 100]
    Guards on activities: [active(gatherItems)]
    State related (well get back to it later)
Guards - Example
bid [value < 100]

                                            bid [value >= 200]
                         Selling                                          Happy




                                 bid [(value >= 100) AND (value < 200)]




                       Unhappy



Intro | Building Blocks | Advanced
Static Conditional Branching
 A graphical shortcut for convenient
  rendering of decision trees

                  Selling                                 Happy

                     bid

                            [value >= 200]
  [value < 100]

                       [(value >= 100) & (value < 200)]


              Unhappy
Empty Transitions
 A transition can have any combination
  (including none) of the events, guards and
  actions
                                                     Empty
 When a transition does not have an event,
  Employee                                         Transition
  it is taken after all the activities were
            rest[break]  Cleaning
  ended
    Working             do: put water
                        do: put soap  doing nothing
   do: shovel   work    do: wash soap
                          do: drain

                                        work
Guards and Events
 Whats the difference between the two
  machines?
                 E1                 true(C)
      S1                   S2                  S3




                 E1                    [C]
      S1                   S2                  S3




           What happens if C changes to True
           before E1?
Actions
 An executable atomic computation
 Types of actions
    Variable assignment:

                 received() | status := received
    sent
    sent                                                      is received
                                                              is received

    Throwing a signal:


                 received() | throw(InventoryUpdate)
    sent
    sent                                                         is received
                                                                 is received
    Start, or stop activities (and concatenation of actions):


                | start(sendBill); stop(delivery); x := x+1
   sent
   sent                                                       is received
                                                              is received
Transitions - advanced
 Self-transitions: Transitions can be directed to the same
  state:                        / c=0

                             S2      E1 / c:=c+1


 Un-deterministic states  when two transitions are taken
  in the same time, one of will be taken in an un-
  deterministic fashion:
                                            E1
                                      S1            S2
                                             [C1]

                                                    S3
How does a Washing Machine Works?
            On / Off button. Start button
            (No stop button.)
            Feedback is given on the current stage
             (soaking, rinsing, draining, drying)
            Three plans:
               Regular
               Delicate (no soaking)
               Super delicate (no soaking, no drying)
            Off can be clicked only before starting, or
             after finishing
Washing Machine
                                     off



                      click(power)         click(power)



                                   idle                                                              Tm(10 mins) | light(off)



                       click(start) [plan=regular]


                                  soak
click(start) [plan=delicate
                            Do: light(soak)
    or super delicate]
                            Do: pump(in)


                                                              Tm(5 mins) [plan=super delicate] | light(off)
                              tm(30 mins)


                                  rinse                                          drain                                           dry
                                                                                                       tm(5 mins)
                           Do: light(rinse)               tm(30 mins)      Do: light(drain)         [plan=not super       Do: light(dry)
                           Do: stir()                                      Do: pump(out)                delicate]         Do: stir()
State Explosion: An Example
                           What is the off
                           button can be
                           clicked at any time?




                                What if we want to show
                                how many minutes left
                                to the end of the cycle?




          What if we want to
          come back to the
          same state we left?
Abstraction in Statechart
                       Separating Independent
Finding Common                 Regions
     Behavior




    Composite States            Parallel States
The State Explosion Problem
      Class           Class                   Class

  v1 : {t, f}     v1 : {t, f}             v1 : {t, f}
  v2 : {t, f}     v2 : {t, f}             v2 : {t, f}
  v3 : {t, f}
  ...
                  v3 : {t, f}
                  ...            ...      v3 : {t, f}
                                          ...

 Let
    n: Num of Classes
    m: Num of variables (assume equals among classes)
 Number of possible states = 2(nm)
 And...
    What if the state space of each variable > 2
    What about association between objects?
Composite States
Composite + History
                                                              off
                                                                                    click(power)



                                                     click(power)

                                                                             On


                                                          H
                                   idle                                                            Tm(10 mins) | light(off)



                       click(start) [plan=regular]


                                  soak
click(start) [plan=delicate
                            Do: light(soak)
    or super delicate]
                            Do: pump(in)


                                                         Tm(5 mins) [plan=super delicate] | light(off)
                              tm(30 mins)


                                  rinse                                     drain                                              dry
                                                                                                  tm(5 mins)
                           Do: light(rinse)          tm(30 mins)      Do: light(drain)         [plan=not super          Do: light(dry)
                           Do: stir()                                 Do: pump(out)                delicate]            Do: stir()
deep and shallow
           Shift ended | clh()
Stop
           pause
                                            Diagnosing
         return
                       H         Diagnostic1
                                 Diagnostic1        Diagnostic2
                                                    Diagnostic2
        return-full

                       H*           setup
                                    setup                Find a vein
                                                         Find a vein


clh()  clears                   Check blood
                                 Check blood
                                                     Draw Blood
                                                     Draw Blood
the history                       pressure
                                  pressure
Completion Transitions
 Triggered by a completion event
    generated automatically when an immediately nested state
      machine terminates


               Committing            completion
                                     transition (no trigger)
                   Phase1
                   Phase1



                                        Commit Done
                   Phase2
                   Phase2
Triggering Rules
 Two or more transitions may have the same event trigger
    inner transition takes precedence
    if no transition is triggered, event is discarded



                     LampFlashing
                           FlashOn
                           FlashOn
                                 on/
      on/           off/
                           FlashOff
                           FlashOff
Order of Actions: Complex Case
 Same approach as for the simple case
     S1                       S2
   exit:exS1                     entry:enS2

                                   | initS2
      S11          E/actE            S21
  exit:exS11                     entry:enS21


          Actions execution sequence:
  exS11   exS1   actE enS2    initS2    enS21
Parallel States
 Sometimes, some aspect of an entity are independent of other
  aspects
  Martial                                            employee


    single
                                                       Staff
                                                      Member
   married


                                                      Manager
   divorced
Parallel States Annotation
 Martial
   Combine multiple simultaneous                           employee

   descriptions
    single
                                                             Staff
                                                            Member
     married
                                     Martial   employee

                                single                     Manager
    divorced
                                                  Staff
                                                 Member
                               married



                               divorced          Manager


Intro | Building Blocks | Advanced
Interactions Between Parallel
                   States                                                                                                            off


                                                                                                                            click(power)
                                                                                                                                           click(power)


                                                                                  On                                                H


                  idle                                                                                                                          Spin Slow
                                                                                                                                           Do: spin(150rpm)
              click(start)                                            idle
           [Plan in Regular]
                                                                                                          Regular
                                                                             Tm(entered(rinse),15)
                            Tm(30)                                                                                                                        Exited(rinse)
     click(start) soak                                                                                                              Entered(rinse)
                            [Plan in
[Plan not in Regular]                                                                                click(plan)
                         Super Delicate]         Entered(rinse)
                                              [Plan not in Regular]                                                                                  idle
                                                                                   out
               Tm(30)
                                     Tm(30)                                                                           click(plan)
                                                            Entered(soak) Do: pump out                    Delicate
                                                                          water                                                     Entered(drain)
                                                                                                                                                          Exited(drain)
                rinse
                                                                                                     click(plan)
                                                             in
                Tm(30)
     [Plan not in Super Delicate]                                                                          Super                                Spin Fast
                                                       Do: pump in
                                                                                                          Delicate
                                                       water
                                                                                                                                           Do: spin(400rpm)
                drain


                Controller                                            Pump                                         Plan                           Rotor
Flat and Parallel Machines
 Every parallel machine can be transformed into a
  sequential machine:
          A                 D                         袖
                                      E
                   B                                                Use of
                                  粒           隆           F       Orthogonal
              留    硫
                   (in G)                         留                Regions
                   C                  G


                   袖                              隆
                                B,F
                       粒
             B,E                                          B,G

         留                                            留       硫   No Use of
                                          留                       Orthogonal
                       粒
          C,E
                                      留                   C,G      Regions
                       袖        C,F               隆
Transition Forks and Joins

  For transitions into/out of orthogonal
                                  shipping

   regions:
        Processing
        Processing Sent
                   Sent    Confirmed
                           Confirmed




          Credit Card
          Credit Card        [ok]
          verification
          verification                   Receipt Sent
                                         Receipt Sent


fork             [not ok]                         charging   Join


                            In problem
                            In problem
Bab 10 state diagram 2010
Bab 10 state diagram 2010

More Related Content

Bab 10 state diagram 2010

  • 2. Statechart Diagram - Bersifat dinamis - Memperlihatkan state-state pada sistem; memuat state, transisi, event, serta aktivitas. - Memperlihatkan sifat dinamis dari antarmuka, kelas, kolaborasi dan terutama penting pada pemodelan sistem-sistem yang reaktif
  • 3. SYSTEMS ANALYSYS AND DESIGN METHODS 5TH Edition Whitten Bentley Dittman Membuat model behavior dari objek-objek Setiap objek dapat dikatakan memiliki state --- nilai dari attributnya pada suatu saat tertentu. State diagram memodelkan daur hidup sebuah objek tunggal. Ia menggambarkan macam- macam state yang dimiliki sebuah objek, event yang mengakibatkan perubahan state selama waktu tertentu dan aturan-aturan yang mengatur transisi objek antara satu state dengan state lainnya. Perubahan terhadap state objek terjadi ketika ada suatu kejadian atau ketika nilai dari salah satu atributnya berubah. Perubahan state ini dipicu oleh adanya suatu event. Irwin/McGraw-Hill Copyrighth@2000 The Mcgraw-Hill Companies All Right reserved
  • 4. Developing Software Woth UML Booch Jacobson Rumbaugh Sebuah state diagram menunjukkan urut-urutan state dari sebuah objek selama masa hidupnya / lifetimenya, sekaligus dengan event-event yang menyebabkan perubahan dari state tersebut. Sebuah state diagram menjelaskan sebuah hypothetical machine (finite automaton) yang pada setiap waktu berada pada satu set finite state, yang terdiri dari: a finite, non-empty set of states; a finite, non-empty set of events; functions, yg menjelaskan transisi dari satu state ke state berikutnya; sebuah initial state; satu set final state. Addison-Wesley
  • 5. Developing Software Woth UML Booch Jacobson Rumbaugh Soal: On opening the flight, the initial state leads to the NoReservation state. When the state is entered, the Reset operation is executed. If a reservation is made for this flight, the object changes to the state PartiallyReserved. The Reserve event is associated to the homonymous Reserve action (implemented as an operation). In this operation, the actual reservation takes place, and the internal reservation counter is updated. After termination of this action, we will find the object in the PartiallyReserved state. Each additional reservation leads to the same action. As long as a free seats are available, the object remains in the PartiallyReserved state. If only one seat left, it changes into FullyBooked state. Cancellation of reserved seats is carried out in a similar way. Thus, the state diagram describes which actions are triggered by which events and under which conditions these (and together with the call of the corresponding operations) are permitted. Addison-Wesley
  • 6. Developing Software Woth UML Booch Jacobson Rumbaugh cancel() [reservedSeats>1] reserve() reserve() NoReservation [freeSeats>1] PartiallyReserved entry/reset() cancel() reserve() [ReservedSeats=1] [freeSeats=1] cancel() cancelFlight() close() openFlight() FullyBooked close() Closed Addison-Wesley
  • 7. Developing Software Woth UML Booch Jacobson Rumbaugh State Sebuah state dimiliki oleh satu buah Class dan merepresentasikan abstraksi atau kombinasi dari satu set nilai atribut yang mungkin terjadi pada objek tersebut dari class ini. Tidak setiap perubahan nilai atribut akan dianggap sebagai perubahan state. Hanya event tertentu yang sangat signifikan mengakibatkan perubahan behavior dari objek. Sebuah state oleh karena itu dapat dilihat juga sebagai rentang waktu (time span) antara dua event. Dua type khusus state yang ada adalah initial state dan final state. Addison-Wesley
  • 8. Developing Software Woth UML Booch Jacobson Rumbaugh Tidak ada transisi yang menuju initial state dan tidak ada event yang diperbolehkan meninggalkan final state. Transisi dari satu state ke state berikutnya di trigger / dipicu oleh event. Sebuah event terdiri dari nama event dan sejumlah argument. Event dapat memicu aksi didalam state yang dilakukan melalui operasi tertentu. Ada tiga trigger yang sudah predefine: entry, fires automatically when entering a state exit, fires automatically when leaving a state do, fires repeatedly as long as the state is active, that is, not left. Addison-Wesley
  • 9. Developing Software Woth UML Booch Jacobson Rumbaugh Substate Sebuah state dapat diuraikan lebih lanjut, baik sekuensial ataupun paralel substate. Gambar dibawah ini menunjukkan sebuah sequential nesting. Ketika kontrak asuransi ditetapkan, sebuah produk dipilih (sebagai contoh, content-nya), yang terdiri dari beberapa produk element (Pel), seperti furniture, gelas, dsb. Untuk setiap produk elemen, sebuah cover (istilah asuransi) harus dibuat. Ilustrasi dibawah ini menunjukkan Create covers state dari context ini. Create Covers covers:set=Empty set PElQuantity Define Reset cover addPEl [isComplete] addPEl Addison-Wesley
  • 10. Developing Software Woth UML Booch Jacobson Rumbaugh Gambar dibawah ini menunjukkan notasi dari paralel substates. substates event1 S3 S4 S1 S2 event2 event3 event4 S5 Addison-Wesley
  • 11. Developing Software Woth UML Booch Jacobson Rumbaugh Event dan transition Sebuah event adalah sebuah kejadian yang memiliki pengaruh khusus dalam suatu context yang dibicarakan, karena ia men-trigger / memicu perubahan state. Kebalikan dari state, event bukan milik satu kelas tertentu. State transition (perubahan state) biasanya dipicu oleh adanya event yang digambarkan dengan anak panah yang menghubungkan state satu dengan state lainnya. Addison-Wesley
  • 12. State Transition Diagram Add student[ count < 10 ] Add Student / Initialization Set count = 0 Open do: Initialize course entry: Register student exit: Increment count Cancel Cancel [ count = 10 ] Canceled do: Notify registered students Closed Cancel do: Finalize course Copyright 息 1997 by Rational Software Corporation
  • 13. Transitions event [guard] | action x x y y The action that takes place when The event that Conditions that the transition is triggers the must be met for taken transition the transition to take place
  • 14. Transitions event [guard] | action x x y y The action that takes place when The event that Conditions that the transition is triggers the must be met for taken transition the transition to take place
  • 15. Events General Events Method calls: received(customer) Event signals: inventoryReady created created Time event interval expiry; inventoryReady tm(3 days), tm(1000 ms) calendar/clock time; when(11:50) in gathering in gathering Change Event: false(hasProblems) Change in value of some entity; false(hasProblems) sent sent true(hasProblems) tm(3 days) received() is received in problem
  • 16. Guards (Conditions) gatheringFinished [all items were gathered] sent sent in gathering in gathering in problem in problem gatheringFinished [items are not found] Boolean expressions. Evaluated when the transition is triggered Types of guards: Simple predicate: [hasProblems], [x > 0] Combined predicates: [測hasProblems (hasProblems order.sum < 100] Guards on activities: [active(gatherItems)] State related (well get back to it later)
  • 17. Guards - Example bid [value < 100] bid [value >= 200] Selling Happy bid [(value >= 100) AND (value < 200)] Unhappy Intro | Building Blocks | Advanced
  • 18. Static Conditional Branching A graphical shortcut for convenient rendering of decision trees Selling Happy bid [value >= 200] [value < 100] [(value >= 100) & (value < 200)] Unhappy
  • 19. Empty Transitions A transition can have any combination (including none) of the events, guards and actions Empty When a transition does not have an event, Employee Transition it is taken after all the activities were rest[break] Cleaning ended Working do: put water do: put soap doing nothing do: shovel work do: wash soap do: drain work
  • 20. Guards and Events Whats the difference between the two machines? E1 true(C) S1 S2 S3 E1 [C] S1 S2 S3 What happens if C changes to True before E1?
  • 21. Actions An executable atomic computation Types of actions Variable assignment: received() | status := received sent sent is received is received Throwing a signal: received() | throw(InventoryUpdate) sent sent is received is received Start, or stop activities (and concatenation of actions): | start(sendBill); stop(delivery); x := x+1 sent sent is received is received
  • 22. Transitions - advanced Self-transitions: Transitions can be directed to the same state: / c=0 S2 E1 / c:=c+1 Un-deterministic states when two transitions are taken in the same time, one of will be taken in an un- deterministic fashion: E1 S1 S2 [C1] S3
  • 23. How does a Washing Machine Works? On / Off button. Start button (No stop button.) Feedback is given on the current stage (soaking, rinsing, draining, drying) Three plans: Regular Delicate (no soaking) Super delicate (no soaking, no drying) Off can be clicked only before starting, or after finishing
  • 24. Washing Machine off click(power) click(power) idle Tm(10 mins) | light(off) click(start) [plan=regular] soak click(start) [plan=delicate Do: light(soak) or super delicate] Do: pump(in) Tm(5 mins) [plan=super delicate] | light(off) tm(30 mins) rinse drain dry tm(5 mins) Do: light(rinse) tm(30 mins) Do: light(drain) [plan=not super Do: light(dry) Do: stir() Do: pump(out) delicate] Do: stir()
  • 25. State Explosion: An Example What is the off button can be clicked at any time? What if we want to show how many minutes left to the end of the cycle? What if we want to come back to the same state we left?
  • 26. Abstraction in Statechart Separating Independent Finding Common Regions Behavior Composite States Parallel States
  • 27. The State Explosion Problem Class Class Class v1 : {t, f} v1 : {t, f} v1 : {t, f} v2 : {t, f} v2 : {t, f} v2 : {t, f} v3 : {t, f} ... v3 : {t, f} ... ... v3 : {t, f} ... Let n: Num of Classes m: Num of variables (assume equals among classes) Number of possible states = 2(nm) And... What if the state space of each variable > 2 What about association between objects?
  • 29. Composite + History off click(power) click(power) On H idle Tm(10 mins) | light(off) click(start) [plan=regular] soak click(start) [plan=delicate Do: light(soak) or super delicate] Do: pump(in) Tm(5 mins) [plan=super delicate] | light(off) tm(30 mins) rinse drain dry tm(5 mins) Do: light(rinse) tm(30 mins) Do: light(drain) [plan=not super Do: light(dry) Do: stir() Do: pump(out) delicate] Do: stir()
  • 30. deep and shallow Shift ended | clh() Stop pause Diagnosing return H Diagnostic1 Diagnostic1 Diagnostic2 Diagnostic2 return-full H* setup setup Find a vein Find a vein clh() clears Check blood Check blood Draw Blood Draw Blood the history pressure pressure
  • 31. Completion Transitions Triggered by a completion event generated automatically when an immediately nested state machine terminates Committing completion transition (no trigger) Phase1 Phase1 Commit Done Phase2 Phase2
  • 32. Triggering Rules Two or more transitions may have the same event trigger inner transition takes precedence if no transition is triggered, event is discarded LampFlashing FlashOn FlashOn on/ on/ off/ FlashOff FlashOff
  • 33. Order of Actions: Complex Case Same approach as for the simple case S1 S2 exit:exS1 entry:enS2 | initS2 S11 E/actE S21 exit:exS11 entry:enS21 Actions execution sequence: exS11 exS1 actE enS2 initS2 enS21
  • 34. Parallel States Sometimes, some aspect of an entity are independent of other aspects Martial employee single Staff Member married Manager divorced
  • 35. Parallel States Annotation Martial Combine multiple simultaneous employee descriptions single Staff Member married Martial employee single Manager divorced Staff Member married divorced Manager Intro | Building Blocks | Advanced
  • 36. Interactions Between Parallel States off click(power) click(power) On H idle Spin Slow Do: spin(150rpm) click(start) idle [Plan in Regular] Regular Tm(entered(rinse),15) Tm(30) Exited(rinse) click(start) soak Entered(rinse) [Plan in [Plan not in Regular] click(plan) Super Delicate] Entered(rinse) [Plan not in Regular] idle out Tm(30) Tm(30) click(plan) Entered(soak) Do: pump out Delicate water Entered(drain) Exited(drain) rinse click(plan) in Tm(30) [Plan not in Super Delicate] Super Spin Fast Do: pump in Delicate water Do: spin(400rpm) drain Controller Pump Plan Rotor
  • 37. Flat and Parallel Machines Every parallel machine can be transformed into a sequential machine: A D 袖 E B Use of 粒 隆 F Orthogonal 留 硫 (in G) 留 Regions C G 袖 隆 B,F 粒 B,E B,G 留 留 硫 No Use of 留 Orthogonal 粒 C,E 留 C,G Regions 袖 C,F 隆
  • 38. Transition Forks and Joins For transitions into/out of orthogonal shipping regions: Processing Processing Sent Sent Confirmed Confirmed Credit Card Credit Card [ok] verification verification Receipt Sent Receipt Sent fork [not ok] charging Join In problem In problem