""" 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): super().__init__(name, coordinates, edges=edges, node_type='TrafficLight') if phases is None: phases = [] self._right_on_red = right_on_red self._offset = offset self._phases = phases @property def right_on_red(self): """ Get if is possible to turn right when the traffic light is red :return: Boolean """ return self._right_on_red @right_on_red.setter def right_on_red(self, value): """ Get if is possible to turn right when the traffic light is red :param value: Boolean """ self._right_on_red = bool(value) @property def offset(self): """ Get program initial time offset :return: int """ return self._offset @offset.setter def offset(self, value): """ Set program initial time offset :param value: int """ self._offset = int(value) @property def phases(self) -> List[Phase]: """ Get traffic light logic phases :return: [Phase] """ return self._phases @phases.setter def phases(self, value): """ Set traffic light logic phases :param value: [Phase] """ self._phases = value