system_assignation/city_model_structure/transport/phase.py
Pilar 2d71136d33 Added first version of traffic classes.
Reorganized classes inside "attributes" into different folders by topic.
2021-08-06 12:28:20 -04:00

126 lines
2.4 KiB
Python

"""
Phase 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
"""
from typing import List
class Phase:
"""
Phase class
"""
def __init__(self):
self._duration = None
self._state = None
self._min_duration = None
self._max_duration = None
self._name = None
self._next = None
@property
def duration(self):
"""
Duration in seconds
:return: int
"""
return self._duration
@duration.setter
def duration(self, value):
"""
Duration setter
:param value: int
"""
self._duration = value
@property
def state(self):
"""
List of signal states
:return: []
"""
return self._state
@state.setter
def state(self, value):
"""
List of signal states setter
:param value: []
"""
self._state = value
@property
def min_duration(self):
"""
Minimum duration in seconds
:return: int
"""
if self._min_duration is None:
self._min_duration = self._duration
return self._min_duration
@min_duration.setter
def min_duration(self, value):
"""
Minimum duration setter
:param value: int
"""
self._min_duration = value
@property
def max_duration(self):
"""
Maximum duration in seconds
:return: int
"""
if self._max_duration is None:
self._max_duration = self._duration
return self._max_duration
@max_duration.setter
def max_duration(self, value):
"""
Maximum duration setter
:param value: int
"""
self._max_duration = value
@property
def name(self):
"""
Phase name
:return: str
"""
return self._name
@name.setter
def name(self, value):
"""
Phase name setter
:param value: str
"""
self._name = value
@property
def next(self) -> List[int]:
"""
The next phase in the cycle after the current.
This is useful when adding extra transition phases to a traffic light plan which are not part of every cycle.
Traffic lights of type 'actuated' can make use of a list of indices for selecting among alternative
successor phases.
:return: [int]
"""
return self._next
@next.setter
def next(self, value):
"""
Next setter
:param value: [int]
"""
self._next = value