Bab 10 state diagram 2010
Upcoming SlideShare
Loading in...5
×
 

Bab 10 state diagram 2010

on

  • 1,886 views

 

Statistics

Views

Total Views
1,886
Views on SlideShare
1,885
Embed Views
1

Actions

Likes
1
Downloads
58
Comments
0

1 Embed 1

http://donasiilmu.blogspot.com 1

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Bab 10 state diagram 2010 Bab 10 state diagram 2010 Presentation Transcript

    • BAB XSTATE 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 DittmanMembuat 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 RumbaughSoal: • 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() ClosedAddison-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] addPElAddison-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 S5Addison-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 Opendo: 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 whenThe event that Conditions that the transition istriggers the must be met for takentransition the transition to take place
    • Transitions event [guard] | action x x y y The action that takes place whenThe event that Conditions that the transition istriggers the must be met for takentransition 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 - Examplebid [value < 100] bid [value >= 200] Selling Happy bid [(value >= 100) AND (value < 200)] UnhappyIntro | 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] soakclick(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 IndependentFinding 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] soakclick(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 veinclh() – clears Check blood Check blood Draw Blood Draw Bloodthe 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 ManagerIntro | 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 Sentfork [not ok] charging Join In problem In problem