PLC Pedestrian Traffic Light
PLC Pedestrian Traffic Light
PLC Pedestrian Traffic Light
Allow Street Crossing Pedestrian to cross the street when traffic so permits Pedestrian to cross the street safely and quickly. Car drivers to pass through without offense to traffic regulation
Pedestrian presses the button to make the request to cross the street. The traffic lights will respond accordingly to coordinate traffic for crossing
Pedestrian side showed a Red traffic light. Traffic lights went through sequence as described below.
Actor Intention
[1] Pedestrian wishes to cross but sees a Red light; presses the button.
:Control
check_timer()
:Timer
[2] If the traffic lights for cars have not shown Green for more than 100 seconds, wait until then.
buttonPressed( )
[3] Turn the traffic lights for cars from Green to Yellow while the pedestrian side traffic lights remain Red. Keep the pattern for 5 seconds. [4] Turn the traffic lights for cars from Yellow to Red while the pedestrian side traffic lights turn from Red to Green. Keep the pattern for the pedestrians to cross the street, for 25 seconds. [5] Seeing Green, pedestrian(s) cross the street while the cars are stopped.
YellowRed
check_timer()
o ff()
alarm() turn_red()
RedGreen
set_alarm(25) check_timer() alarm()
on()
RedRed
[6] While the traffic lights for cars remain Red, turn the pedestrian side traffic lights to Red to stop the pedestrians. Hold for 10 seconds. [7] Turn the traffic lights for cars from Red to Green to allow cars to pass through.
check_timer()
off()
alarm()
GreenRed
set_alarm(100)
turn_green()
off()
on()
Reading
Reference book: The Unified Modeling Language User Guide Booch, Rumbaugh, Jacobson. Chapter 19 Activity Diagrams Chapters 24 Statechart Diagrams more comprehensive.
Reading
Textbook: Applying UML and Patterns: an introduction to OOAD and the UP (2 nd edition) C. Larman Chapter 29 Statechart Diagram Chapter 38 Activity Diagram (last section) not sufficiently in depth
Topics
Statechart Diagrams Activity Diagrams
Modeling Behavior
Modeling a technique for both analysis and design: State Diagram (aka: Statechart Diagram) Activity Diagram To model the behavior of Use Case Class
State Diagram
also called: Statechart Diagram so called after David Harels Statechart
Harel, D. Statecharts: A visual formalism for complex systems. Science of computing programming, Vol.8, 1987.
State Diagram
To model behavior, we recognize the following: event An event is a significant or noteworthy occurrence. EG: A switch is thrown. state A state is the condition of an object (or a system) at a moment in time (the period between events). EG: The light is on. transition A transition is a relationship between two states, indicating when the object (or system) moves from one state to another, and what happens. EG: The light is turned on (it was off).
State Diagram:
of a light with on/off switch
An event: switch(on)
init( )
switch(open)
ON
switch(close)
OFF
state: ON
state: OFF
An event: switch(off)
event [guard] action event: event with arguments [guard]: logical condition(s) to test action: action to take upon state transition Example: button(pressed) [over 100s] setTimerAlarm(10s).
Dispatching Delivery
Arc label with event, guard condition, and two action items.
Order Dispatched
Arc label with one event and one guard condition, no action.
Arc label with one event, no guard condition, one action item.
Dispatching Delivery
Order Dispatched
Dispatching Delivery
Order Dispatched
cancelled(orderNum)
Order Cancelled
Dispatching Delivery
Order Dispatched
cancelled(orderNum)
Order Cancelled
Super State:
facilitates a simplified view
Active Processing
Active Processing
[ALL checked && ALL available]
Dispatching Delivery
[ALL checked && Some not available] dispatched(orderNum) notifyAccounting(orderNum) arrived(item, quantity) [NOT all available]
cancelled(orderNum)
Order Dispatched
dispatched(orderNum) notifyAccounting(orderNum)
Order Cancelled
cancelled(orderNum)
Order Cancelled
Order Dispatched
Assignment 6
Given description of behavior. Draw state diagram for the traffic light system, using super states active, idle. Draw state diagram for the controller, not using any super states. Two diagrams would look quite similar! Hand drawn diagram OK if legible. Tools: Visio, Power Point, Word
Topics
Activity Diagram
Purpose Association with what? class/operation/use case Activity and Transition Condition and branches Synchronization Compound Activity Swim lanes (activities in responsibility domains) Send and Receive signals Object flow and transition labels
Topics
Statechart Diagrams Activity Diagrams
Activity Diagram
Purpose to model concurrent events and processing. Per Use Case: activities in the system Per Class: sequence of internal operations
Transition: done with one step, moving into the next. Send Order
[ condition ]
[ else ]
Merge: one out-going transition, multiple in-coming ones, no label necessary only one in-coming transition should take place.
Join: one out -going transition, multiple in-coming ones, waits until all in-coming transitions are there to take place, for synchronization.
Swim Lanes
Show activities of different objects in the process.