CHAPTER 4. CODING PROCESS
22
• Sotl-request control
• Sotl-phase control
• Sotl-platoon control
Marching control is a simple method. All intersections will have green lights
in the same direction. Intersections have a phase which counts time steps. When
the phase reaches a period value p, the phase is reset to zero. When phi has the
value 0, red lights turn green after the clearence time has passed, and green lights
turn red. “Marching” intersections have equal phases.
In our simulation we have roads with traffic in both directions. We need a more
complex solution for the traffic lights. The traffic lights have te be green in the
following sequence.
• the lights on the primary lanes turning left
• the lights on the primary lanes going straight on and turning right
• the lights on the lanes crossing primary road turning left
• the lights on the lanes crossing primary road going straight on and turning
right
This control method is implemented in MorevtsMarchingTLC. This class is a
sublcass of TLController. The method decideTLS implements the actual algo-
rithm. The variable phase is added in TrafficLight with its accessors getP hase,
setP hase and incrP hase. This wil be used as a counter when the traffic lights
have to switch.
For this method we need a global counter. curCycle of SimModel would be good,
but it is not accessible by a T LC ontroller. curC ycle is added in T LController
which has the same value as the curC ycle of S imM odel. The curC ycle of the
T LController is updated by S imM odel.
decideT Ls decides which traffic lights should turn green, and which should turn