Assignment 25534

The lights can be red or green, but both pairs can never be green at the same time (else the lights will cause car collisions!). Under normal processing, the lights change, via turn_red and turn_green commands, whenever the event change_lights occurs, say every 45 seconds; the changes are such that one pair is red while the other is green. When an ambulance nears the intersection, a sensor signals amb_enter road event, where road is either avenue or street depending on the location of the ambulance. The controller must then ensure that the lights on the ambulance road are green, while those on the other road are red. When the ambulance leaves the intersection area, signaled by an amb_exit event, the lights resume their normal sequencing. Draw a state machine this traffic light controller