SlideShare ist ein Scribd-Unternehmen logo
1 von 40
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Mehr von donasiilmu

Mehr von 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
 

Kürzlich hochgeladen

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdfssuserdda66b
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 

Kürzlich hochgeladen (20)

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 

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