# APS Week3 Group logic 1 75 1.Start 2.Declare time, prevState, Green=40 sec, Amber=15 sec, Red=40 sec 3.Time start from 0 4.Green 0 < time <= 40? a) Yes: stay in Green, prevState == go No: go to #5 5.Amber 40 < time <= 55? a) Yes: stay in Amber, prevState == go No: go to #6 b) If interrupt: go to #8 6.Red 55 < time <= 95? a) Yes: stay in Red, prevState == stop No: go to #7 b) If interrupt: go to #8 7.Over 95 < time? a)Yes: go back #3 No: go to #4 b) If Interrupt: go to #8 8. Perfom Interrupt Protocol, go to #3 9. End logic2 1. Start 2. Declare variables: 2.1 Green = 45 sec. 2.2 Amber = 10 sec. 2.3 Total duration = 90 sec. 2.4 Red = Total duration - Green - Amber = 35 sec. 2.5 Red Countdown = Red - 25 sec. = 10 sec. 3. Define initial state: All single lights [off] 4. Startup: The system sends an order [on] 5. If Green Startup first: Get an order 5.1 Duration of the green light [45 sec.] 5.2 Time is over: Go to #6 6. Amber Startup: Get an order 6.1 Duration of the amber light [10 sec.] 6.2 Time is over: Go to #6 7. Red Startup: Get an order 7.1 Duration of the red light [35 sec.] 7.11 Show Red Countdown [10 sec.] 7.2 Time is over: Repeat #5 logic 3 1. Start 2. declaired variable red light = green + amber = 70 sec 3. red light > 10 ? 3.1 Yes : go to #4 3.2 No : go to #6 4. Is there any situation ? 4.1 Yes : go to #5 4.2 No : go to #6 5. walk button? car sensor? 5.1 walk button : red light turn to 10 sec, go to #6 5.2 car sensor? : red light turn to 10 sec, go to #6 6. the red light keep reducing one sec 7. the red light = 0 8. start the green light 9. End [Group] Define the 4-light 5-state system that supports the advanced left turn light, request to walk, car sensor, and interrupt features. 1. Start 2. Declared variables Solid Green + Advanced Left Green Arrow = 15 sec, Solid Green + Advanced Left Amber Arrow = 5 sec, Solid Green + Advanced Left Arrow (off) = 45 sec, Solid Amber = 10 sec, Solid Red light = 75 sec 3. Define initial state: preveState [off] 4. Startup: The system sends an order [on] 5. Solid Green + Advanced Left Green Arrow Startup first: Get an order 5.1 Stay in Solid Green + Advanced Left Green Arrow [15 sec.] 5.2 Time is over: Go to #6 5.3 If interrupt: 5.3.1 Yes :Perfom Interrupt Protocol, go to #4 5.3.2 No :go to #6 6. Solid Green + Advanced Left Amber Arrow Startup: Get an order 6.1 Stay in Solid Green + Advanced Left Amber Arrow [5 sec.] 6.2 Time is over: Go to #7 6.3 If interrupt: 6.3.1 Yes :Perfom Interrupt Protocol, go to #4 6.3.2 No :go to #7 7. Solid Green + Advanced Left Arrow (off) 7.1 Stay in Green + Advanced Left Arrow (off) [45 sec.] 7.2 Time is over: Go to #8 7.3 If interrupt: 7.3.1 Yes :Perfom Interrupt Protocol, go to #4 7.3.2 No :go to #8 8. Solid Amber 8.1 Stay in Solid Amber [10 sec.] 8.2 Time is over: Go to #9 8.3 If interrupt: 8.3.1 Yes :Perfom Interrupt Protocol, go to #4 8.3.2 No :go to #9 9. Solid Red 9.1 Stay in Solid Red [75 sec.] 9.2 If interrupt: 9.2.1 Yes :Perfom Interrupt Protocol, go to #4 9.2.2 No :go to #10 10. Red light > 10 ? 10.1 Yes : go to #11 10.2 No : go to #13 11. Is there any situation ? 11.1 Yes : go to #12 11.2 No : go to #13 12. Walk button? 12.1 Yes : red light turn to 10 sec, go to #13 12.2 No :go to #14 13. car sensor? 13.1 Yes : red light turn to 10 sec, go to #13 13.2 No :go to #14 14. The red light keep reducing [1 sec.] 15. Time is over: Repeat #4 16. End