SlideShare a Scribd company logo
1 of 40
Download to read offline
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 (we’ll 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
• What’s 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

More from donasiilmu

More from donasiilmu (20)

Penjelasan strukturdata
Penjelasan strukturdataPenjelasan strukturdata
Penjelasan strukturdata
 
Isi
IsiIsi
Isi
 
Dftr isi
Dftr isiDftr isi
Dftr isi
 
Pengantar
PengantarPengantar
Pengantar
 
9 materisim komputer
9 materisim komputer9 materisim komputer
9 materisim komputer
 
Interaksi manusia dan komputer
Interaksi manusia dan komputerInteraksi manusia dan komputer
Interaksi manusia dan komputer
 
Makalah jaringan-komputer2
Makalah jaringan-komputer2Makalah jaringan-komputer2
Makalah jaringan-komputer2
 
Makalah jaringan-komputer2
Makalah jaringan-komputer2Makalah jaringan-komputer2
Makalah jaringan-komputer2
 
Apsi
ApsiApsi
Apsi
 
Data flow diagram
Data flow diagramData flow diagram
Data flow diagram
 
Erd
ErdErd
Erd
 
Norma lisasi
Norma lisasiNorma lisasi
Norma lisasi
 
Pertemuan4
Pertemuan4Pertemuan4
Pertemuan4
 
Pertemuan5
Pertemuan5Pertemuan5
Pertemuan5
 
Pertemuan6
Pertemuan6Pertemuan6
Pertemuan6
 
Pertemuan7
Pertemuan7Pertemuan7
Pertemuan7
 
Pertemuan9
Pertemuan9Pertemuan9
Pertemuan9
 
Pertemuan10
Pertemuan10Pertemuan10
Pertemuan10
 
Pertemuan10
Pertemuan10Pertemuan10
Pertemuan10
 
Pertemuan11
Pertemuan11Pertemuan11
Pertemuan11
 

Recently uploaded

When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...Gary Wood
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint23600690
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi RajagopalEADTU
 
Scopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS PublicationsScopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS PublicationsISCOPE Publication
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...EADTU
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxCeline George
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFVivekanand Anglo Vedic Academy
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxAdelaideRefugio
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxneillewis46
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital ManagementMBA Assignment Experts
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...Nguyen Thanh Tu Collection
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesPooky Knightsmith
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...EduSkills OECD
 

Recently uploaded (20)

When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
Scopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS PublicationsScopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS Publications
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 

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 (we’ll 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 • What’s 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