hub/city_model_structure/transport/phase.py

129 lines
2.7 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):
"""
Get phase duration in seconds
:return: int
"""
return self._duration
@duration.setter
def duration(self, value):
"""
Set phase duration in seconds
:param value: int
"""
self._duration = value
@property
def state(self):
"""
Get the list of signal states
:return: [str]
"""
return self._state
@state.setter
def state(self, value):
"""
Set the list of signal states
:param value: [str]
"""
self._state = value
@property
def min_duration(self):
"""
Get phase 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):
"""
Set phase minimum duration in seconds
:param value: int
"""
self._min_duration = value
@property
def max_duration(self):
"""
Get phase 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):
"""
Set phase maximum duration in seconds
:param value: int
"""
self._max_duration = value
@property
def name(self):
"""
Get phase name
:return: str
"""
return self._name
@name.setter
def name(self, value):
"""
Set phase name
:param value: str
"""
self._name = value
@property
def next(self) -> List[int]:
"""
Get 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):
"""
Get 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.
:param value: [int]
"""
self._next = value