hub/city_model_structure/transport/traffic_light.py

71 lines
1.7 KiB
Python
Raw Normal View History

2021-08-17 12:52:48 -04:00
"""
Traffic light module
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
Contributor Milad milad.aghamohamadnia@concordia.ca
Contributor Guille guille.gutierrezmorote@concordia.ca
"""
from typing import List
from city_model_structure.transport.phase import Phase
from city_model_structure.transport.traffic_node import TrafficNode
class TrafficLight(TrafficNode):
"""
Traffic light class
"""
def __init__(self, name, coordinates, offset, phases=None, edges=None, right_on_red=False):
2021-08-17 13:30:51 -04:00
super().__init__(name, coordinates, edges=edges, node_type='TrafficLight')
2021-08-17 12:52:48 -04:00
if phases is None:
phases = []
self._right_on_red = right_on_red
self._offset = offset
self._phases = phases
@property
def right_on_red(self):
"""
Return if is possible to turn right if the traffic light is red
"""
2021-08-17 12:52:48 -04:00
return self._right_on_red
@right_on_red.setter
def right_on_red(self, value):
"""
Set if is possible to turn right if the traffic light is red
"""
2021-08-17 12:52:48 -04:00
self._right_on_red = value
@property
def offset(self):
"""
The initial time offset of the program
:return: int
"""
return self._offset
@offset.setter
def offset(self, value):
"""
The initial time offset of the program setter
:param value: int
"""
self._offset = value
@property
def phases(self) -> List[Phase]:
"""
Phases of the traffic light logic
:return: [Phase]
"""
return self._phases
@phases.setter
def phases(self, value):
"""
Phases setter
:param value: [Phase]
"""
self._phases = value