Presentation is loading. Please wait.

Presentation is loading. Please wait.

State Machines State diagrams SE-2030 Dr. Mark L. Hornick 1.

Similar presentations


Presentation on theme: "State Machines State diagrams SE-2030 Dr. Mark L. Hornick 1."— Presentation transcript:

1 State Machines State diagrams SE-2030 Dr. Mark L. Hornick 1

2 SE-280 Dr. Mark L. Hornick 2 The State Diagram can be a powerful aid in helping you to define the operation of a Controller State Diagrams illustrate the dynamic behavior of a system (i.e. how a Controller functions) where events (perhaps from the UI) trigger one or more actions and cause the system (Controller) to change its state.

3 A traffic light controller changes states based on events from a timer that fires at regular intervals SE-2030 Dr. Mark L. Hornick 3

4 Winter 2005/2006SE-280 Dr. Mark L. Hornick 4 A guard may be used to illustrate a condition that must be satisfied before a state transition can occur. The guard appears in brackets: [ ]

5 A State Diagram for a light bulb controlled with a toggle switch SE-2030 Dr. Mark L. Hornick 5 The event flip switch to ‘1’ triggers the action current flows and the transition to the on state. The event flip switch to ‘0’ triggers the action current stops flowing and the transition to the off state.

6 A State Diagram for a light bulb controlled with a pushbutton switch SE-2030 Dr. Mark L. Hornick 6 The same event (button pressed) triggers different actions depending upon its current state.

7 Different events may also cause transitions to the same state SE-2030 Dr. Mark L. Hornick 7 Different events may cause transitions to different states However, state transitions must be deterministic; that is, the same event cannot cause a transition from one given state to more than one subsequent state.

8 The same event can cause different states to transition to the same state SE-2030 Dr. Mark L. Hornick 8 These state transitions are still deterministic since the same event does not cause a transition from one given state to more than one subsequent state.

9 It is common for an event to result in an action, but no state transition SE-2030 Dr. Mark L. Hornick 9

10 In a complex system, different events may cause transitions to different states or to the same state SE-2030 Dr. Mark L. Hornick 10

11 Initial and Final states may be indicated as follows SE-2030 Dr. Mark L. Hornick 11 Initial and Final states are special in that once a system leaves an Initial state, it cannot return to that state, and once a system achieves a Final state, it stays in that state.

12 Demo: Describe the logic in a 2-button lamp controller via a state diagram, and implement the controller as a State Machine SE-2030 Dr. Mark L. Hornick 12


Download ppt "State Machines State diagrams SE-2030 Dr. Mark L. Hornick 1."

Similar presentations


Ads by Google