SUMO - Simulation of Urban MObility
|
A traffic lights logic which represents a tls in an off-mode. More...
#include <MSOffTrafficLightLogic.h>
Public Types | |
Structure definitions | |
typedef std::vector < MSPhaseDefinition * > | Phases |
Definition of a list of phases, being the junction logic. | |
typedef std::vector< MSLink * > | LinkVector |
Definition of the list of links that participate in this tl-light. | |
typedef std::vector< LinkVector > | LinkVectorVector |
Definition of a list that holds lists of links that do have the same attribute. | |
typedef std::vector< MSLane * > | LaneVector |
Definition of the list of links that participate in this tl-light. | |
typedef std::vector< LaneVector > | LaneVectorVector |
Definition of a list that holds lists of links that do have the same attribute. | |
Public Member Functions | |
virtual void | init (NLDetectorBuilder &nb) |
Initialises the tls with information about incoming lanes. | |
MSOffTrafficLightLogic (MSTLLogicControl &tlcontrol, const std::string &id) | |
Constructor. | |
~MSOffTrafficLightLogic () | |
Destructor. | |
Handling of controlled links | |
void | adaptLinkInformationFrom (const MSTrafficLightLogic &logic) |
Applies information about controlled links and lanes from the given logic. | |
Switching and setting current rows | |
SUMOTime | trySwitch (bool isActive) |
Switches to the next phase. | |
Static Information Retrieval | |
unsigned int | getPhaseNumber () const |
Returns the number of phases. | |
const Phases & | getPhases () const |
Returns the phases of this tls program. | |
const MSPhaseDefinition & | getPhase (unsigned int givenstep) const |
Returns the definition of the phase from the given position within the plan. | |
Dynamic Information Retrieval | |
unsigned int | getCurrentPhaseIndex () const |
Returns the current index within the program. | |
const MSPhaseDefinition & | getCurrentPhaseDef () const |
Returns the definition of the current phase. | |
Conversion between time and phase | |
SUMOTime | getPhaseIndexAtTime (SUMOTime simStep) const |
Returns the index of the logic at the given simulation step. | |
SUMOTime | getOffsetFromIndex (unsigned int index) const |
Returns the position (start of a phase during a cycle) from of a given step. | |
unsigned int | getIndexFromOffset (SUMOTime offset) const |
Returns the step (the phasenumber) of a given position of the cycle. | |
Changing phases and phase durations | |
void | changeStepAndDuration (MSTLLogicControl &tlcontrol, SUMOTime simStep, unsigned int step, SUMOTime stepDuration) |
Changes the current phase and her duration. | |
Handling of controlled links | |
void | addLink (MSLink *link, MSLane *lane, unsigned int pos) |
Adds a link on building. | |
std::map< MSLink *, LinkState > | collectLinkStates () const |
Returns the (uncontrolled) states of the controlled links. | |
void | resetLinkStates (const std::map< MSLink *, LinkState > &vals) const |
Resets the states of controlled links. | |
Switching and setting current rows | |
bool | setTrafficLightSignals (SUMOTime t) const |
Applies the current signal states to controlled links. | |
Static Information Retrieval | |
const std::string & | getID () const |
Returns this tl-logic's id. | |
const std::string & | getProgramID () const |
Returns this tl-logic's id. | |
const LaneVectorVector & | getLanes () const |
Returns the list of lists of all lanes controlled by this tls. | |
const LaneVector & | getLanesAt (unsigned int i) const |
Returns the list of lanes that are controlled by the signals at the given position. | |
const LinkVectorVector & | getLinks () const |
Returns the list of lists of all affected links. | |
const LinkVector & | getLinksAt (unsigned int i) const |
Returns the list of links that are controlled by the signals at the given position. | |
int | getLinkIndex (const MSLink *const link) const |
Returns the index of the given link. | |
Dynamic Information Retrieval | |
SUMOTime | getDefaultCycleTime () const |
Returns the cycle time (in ms) | |
SUMOTime | getNextSwitchTime () const |
Returns the assumed next switch time. | |
Changing phases and phase durations | |
void | addOverridingDuration (SUMOTime duration) |
Changes the duration of the next phase. | |
void | setCurrentDurationIncrement (SUMOTime delay) |
Delays current phase by the given delay. | |
Algorithm parameter handling | |
void | setParameter (const std::map< std::string, std::string > ¶ms) |
Inserts read parameter. | |
std::string | getParameterValue (const std::string &key) const |
Returns a named parameter. | |
Protected Attributes | |
SUMOTime | myCurrentDurationIncrement |
A value for enlarge the current duration. | |
SUMOTime | myDefaultCycleTime |
The cycle time (without changes) | |
std::string | myID |
The id of the logic. | |
LaneVectorVector | myLanes |
The list of links which do participate in this traffic light. | |
LinkVectorVector | myLinks |
The list of links which do participate in this traffic light. | |
std::vector< SUMOTime > | myOverridingTimes |
A list of duration overrides. | |
std::map< std::string, std::string > | myParameter |
Given parameter. | |
std::string | myProgramID |
SwitchCommand * | mySwitchCommand |
The current switch command. | |
Private Member Functions | |
void | rebuildPhase () |
(Re)builds the internal phase definition | |
Private Attributes | |
MSTrafficLightLogic::Phases | myPhaseDefinition |
The phase definition (only one) |
A traffic lights logic which represents a tls in an off-mode.
Definition at line 53 of file MSOffTrafficLightLogic.h.
typedef std::vector<MSLane*> MSTrafficLightLogic::LaneVector [inherited] |
Definition of the list of links that participate in this tl-light.
Definition at line 77 of file MSTrafficLightLogic.h.
typedef std::vector<LaneVector> MSTrafficLightLogic::LaneVectorVector [inherited] |
Definition of a list that holds lists of links that do have the same attribute.
Definition at line 80 of file MSTrafficLightLogic.h.
typedef std::vector<MSLink*> MSTrafficLightLogic::LinkVector [inherited] |
Definition of the list of links that participate in this tl-light.
Definition at line 71 of file MSTrafficLightLogic.h.
typedef std::vector<LinkVector> MSTrafficLightLogic::LinkVectorVector [inherited] |
Definition of a list that holds lists of links that do have the same attribute.
Definition at line 74 of file MSTrafficLightLogic.h.
typedef std::vector<MSPhaseDefinition*> MSTrafficLightLogic::Phases [inherited] |
Definition of a list of phases, being the junction logic.
Definition at line 68 of file MSTrafficLightLogic.h.
MSOffTrafficLightLogic::MSOffTrafficLightLogic | ( | MSTLLogicControl & | tlcontrol, |
const std::string & | id | ||
) |
Constructor.
[in] | tlcontrol | The tls control responsible for this tls |
[in] | id | This tls' id The sub-id is always "off". |
Definition at line 48 of file MSOffTrafficLightLogic.cpp.
References MSTrafficLightLogic::myDefaultCycleTime, and TIME2STEPS.
void MSOffTrafficLightLogic::adaptLinkInformationFrom | ( | const MSTrafficLightLogic & | logic | ) | [virtual] |
Applies information about controlled links and lanes from the given logic.
[in] | logic | The logic to use the information about controlled links/lanes from |
Reimplemented from MSTrafficLightLogic.
Definition at line 70 of file MSOffTrafficLightLogic.cpp.
References rebuildPhase().
void MSTrafficLightLogic::addLink | ( | MSLink * | link, |
MSLane * | lane, | ||
unsigned int | pos | ||
) | [inherited] |
Adds a link on building.
[in] | link | The controlled link |
[in] | lane | The lane this link starts at |
[in] | pos | The link's index (signal group) within this program |
Definition at line 125 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::getCurrentPhaseDef(), MSNet::getInstance(), MSTrafficLightLogic::myLanes, MSTrafficLightLogic::myLinks, and MSLink::setTLState().
void MSTrafficLightLogic::addOverridingDuration | ( | SUMOTime | duration | ) | [inherited] |
Changes the duration of the next phase.
[in] | duration | The new duration |
Definition at line 216 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::myOverridingTimes.
void MSOffTrafficLightLogic::changeStepAndDuration | ( | MSTLLogicControl & | tlcontrol, |
SUMOTime | simStep, | ||
unsigned int | step, | ||
SUMOTime | stepDuration | ||
) | [inline, virtual] |
Changes the current phase and her duration.
[in] | tlcontrol | The responsible traffic lights control |
[in] | simStep | The current simulation step |
[in] | step | Index of the phase to use |
[in] | stepDuration | The left duration of the phase |
Implements MSTrafficLightLogic.
Definition at line 187 of file MSOffTrafficLightLogic.h.
References UNUSED_PARAMETER.
std::map< MSLink *, LinkState > MSTrafficLightLogic::collectLinkStates | ( | ) | const [inherited] |
Returns the (uncontrolled) states of the controlled links.
Definition at line 150 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::myLinks.
const MSPhaseDefinition & MSOffTrafficLightLogic::getCurrentPhaseDef | ( | ) | const [virtual] |
Returns the definition of the current phase.
Implements MSTrafficLightLogic.
Definition at line 119 of file MSOffTrafficLightLogic.cpp.
References myPhaseDefinition.
unsigned int MSOffTrafficLightLogic::getCurrentPhaseIndex | ( | ) | const [virtual] |
Returns the current index within the program.
Implements MSTrafficLightLogic.
Definition at line 113 of file MSOffTrafficLightLogic.cpp.
SUMOTime MSTrafficLightLogic::getDefaultCycleTime | ( | ) | const [inline, inherited] |
Returns the cycle time (in ms)
Definition at line 263 of file MSTrafficLightLogic.h.
References MSTrafficLightLogic::myDefaultCycleTime.
Referenced by MSTLLogicControl::WAUTSwitchProcedure::isPosAtGSP().
const std::string& MSTrafficLightLogic::getID | ( | ) | const [inline, inherited] |
Returns this tl-logic's id.
Definition at line 170 of file MSTrafficLightLogic.h.
References MSTrafficLightLogic::myID.
Referenced by MSTLLogicControl::TLSLogicVariants::addLogic(), GUITrafficLightLogicWrapper::begin2TrackPhases(), GUINet::createTLWrapper(), Command_SaveTLSState::execute(), Command_SaveTLSSwitchStates::execute(), Command_SaveTLSSwitches::execute(), GUITrafficLightLogicWrapper::getPopUpMenu(), GUITLLogicPhasesTrackerWindow::GUITLLogicPhasesTrackerWindow(), MSTLLogicControl::isActive(), GUIViewTraffic::onGamingClick(), and GUITrafficLightLogicWrapper::switchTLSLogic().
unsigned int MSOffTrafficLightLogic::getIndexFromOffset | ( | SUMOTime | offset | ) | const [virtual] |
Returns the step (the phasenumber) of a given position of the cycle.
[in] | offset | The offset (time) for which the according phase shall be returned |
Implements MSTrafficLightLogic.
Definition at line 138 of file MSOffTrafficLightLogic.cpp.
const LaneVectorVector& MSTrafficLightLogic::getLanes | ( | ) | const [inline, inherited] |
Returns the list of lists of all lanes controlled by this tls.
Definition at line 186 of file MSTrafficLightLogic.h.
References MSTrafficLightLogic::myLanes.
Referenced by GUITrafficLightLogicWrapper::getCenteringBoundary(), and TraCIServerAPI_TLS::processGet().
const LaneVector& MSTrafficLightLogic::getLanesAt | ( | unsigned int | i | ) | const [inline, inherited] |
Returns the list of lanes that are controlled by the signals at the given position.
[in] | i | The index of the signal |
Definition at line 195 of file MSTrafficLightLogic.h.
References MSTrafficLightLogic::myLanes.
Referenced by MSAgentbasedTrafficLightLogic::collectData(), GUITrafficLightLogicWrapper::drawGL(), MSActuatedTrafficLightLogic::duration(), Command_SaveTLSSwitches::execute(), MSActuatedTrafficLightLogic::gapControl(), and GUIViewTraffic::onGamingClick().
int MSTrafficLightLogic::getLinkIndex | ( | const MSLink *const | link | ) | const [inherited] |
Returns the index of the given link.
[in] | link | The link to retrieve the index for |
Definition at line 192 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::myLinks.
Referenced by GUITrafficLightLogicWrapper::getLinkIndex().
const LinkVectorVector& MSTrafficLightLogic::getLinks | ( | ) | const [inline, inherited] |
Returns the list of lists of all affected links.
Definition at line 203 of file MSTrafficLightLogic.h.
References MSTrafficLightLogic::myLinks.
Referenced by MSTLLogicControl::TLSLogicVariants::addLogic(), GUINet::createTLWrapper(), GUITLLogicPhasesTrackerWindow::drawValues(), Command_SaveTLSSwitches::execute(), GUITLLogicPhasesTrackerWindow::GUITLLogicPhasesTrackerWindow(), TraCIServerAPI_TLS::processGet(), and rebuildPhase().
const LinkVector& MSTrafficLightLogic::getLinksAt | ( | unsigned int | i | ) | const [inline, inherited] |
Returns the list of links that are controlled by the signals at the given position.
[in] | i | The index of the signal |
Definition at line 212 of file MSTrafficLightLogic.h.
References MSTrafficLightLogic::myLinks.
SUMOTime MSTrafficLightLogic::getNextSwitchTime | ( | ) | const [inherited] |
Returns the assumed next switch time.
The time may change in case of adaptive/actuated traffic lights.
Definition at line 209 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::SwitchCommand::getNextSwitchTime(), and MSTrafficLightLogic::mySwitchCommand.
Referenced by MSTLLogicControl::WAUTSwitchProcedure::isPosAtGSP(), and TraCIServerAPI_TLS::processGet().
SUMOTime MSOffTrafficLightLogic::getOffsetFromIndex | ( | unsigned int | index | ) | const [virtual] |
Returns the position (start of a phase during a cycle) from of a given step.
[in] | index | The index of the phase to return the begin of |
Implements MSTrafficLightLogic.
Definition at line 132 of file MSOffTrafficLightLogic.cpp.
std::string MSTrafficLightLogic::getParameterValue | ( | const std::string & | key | ) | const [inherited] |
Returns a named parameter.
[in] | key | The name of the parameter |
Definition at line 237 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::myParameter.
Referenced by MSTLLogicControl::WAUTSwitchProcedure::getGSPValue(), MSTLLogicControl::WAUTSwitchProcedure_Stretch::getStretchAreaNo(), and MSTLLogicControl::WAUTSwitchProcedure_Stretch::getStretchBereichDef().
const MSPhaseDefinition & MSOffTrafficLightLogic::getPhase | ( | unsigned int | givenstep | ) | const [virtual] |
Returns the definition of the phase from the given position within the plan.
[in] | givenstep | The index of the phase within the plan |
Implements MSTrafficLightLogic.
Definition at line 106 of file MSOffTrafficLightLogic.cpp.
References myPhaseDefinition.
SUMOTime MSOffTrafficLightLogic::getPhaseIndexAtTime | ( | SUMOTime | simStep | ) | const [virtual] |
Returns the index of the logic at the given simulation step.
Implements MSTrafficLightLogic.
Definition at line 126 of file MSOffTrafficLightLogic.cpp.
unsigned int MSOffTrafficLightLogic::getPhaseNumber | ( | ) | const [virtual] |
Returns the number of phases.
Implements MSTrafficLightLogic.
Definition at line 94 of file MSOffTrafficLightLogic.cpp.
const MSOffTrafficLightLogic::Phases & MSOffTrafficLightLogic::getPhases | ( | ) | const [virtual] |
Returns the phases of this tls program.
Implements MSTrafficLightLogic.
Definition at line 100 of file MSOffTrafficLightLogic.cpp.
References myPhaseDefinition.
const std::string& MSTrafficLightLogic::getProgramID | ( | ) | const [inline, inherited] |
Returns this tl-logic's id.
Definition at line 178 of file MSTrafficLightLogic.h.
References MSTrafficLightLogic::myProgramID.
Referenced by Command_SaveTLSState::execute(), Command_SaveTLSSwitchStates::execute(), Command_SaveTLSSwitches::execute(), GUITLLogicPhasesTrackerWindow::GUITLLogicPhasesTrackerWindow(), GUIViewTraffic::onGamingClick(), and TraCIServerAPI_TLS::processGet().
void MSOffTrafficLightLogic::init | ( | NLDetectorBuilder & | nb | ) | [virtual] |
Initialises the tls with information about incoming lanes.
[in] | nb | The detector builder |
[in] | edgeContinuations | Information about edge predecessors/successors |
Reimplemented from MSTrafficLightLogic.
Definition at line 63 of file MSOffTrafficLightLogic.cpp.
References rebuildPhase().
void MSOffTrafficLightLogic::rebuildPhase | ( | ) | [private] |
(Re)builds the internal phase definition
Definition at line 77 of file MSOffTrafficLightLogic.cpp.
References MSTrafficLightLogic::getLinks(), myPhaseDefinition, and TIME2STEPS.
Referenced by adaptLinkInformationFrom(), and init().
void MSTrafficLightLogic::resetLinkStates | ( | const std::map< MSLink *, LinkState > & | vals | ) | const [inherited] |
Resets the states of controlled links.
[in] | vals | The state of controlled links to use |
Definition at line 179 of file MSTrafficLightLogic.cpp.
References MSNet::getCurrentTimeStep(), MSNet::getInstance(), and MSTrafficLightLogic::myLinks.
void MSTrafficLightLogic::setCurrentDurationIncrement | ( | SUMOTime | delay | ) | [inherited] |
Delays current phase by the given delay.
[in] | delay | The time by which the current phase shall be delayed |
Definition at line 222 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::myCurrentDurationIncrement.
void MSTrafficLightLogic::setParameter | ( | const std::map< std::string, std::string > & | params | ) | [inherited] |
Inserts read parameter.
[in] | params | The parameter to use |
Definition at line 231 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::myParameter.
Referenced by NLJunctionControlBuilder::closeTrafficLightLogic().
bool MSTrafficLightLogic::setTrafficLightSignals | ( | SUMOTime | t | ) | const [inherited] |
Applies the current signal states to controlled links.
[in] | t | The current time |
Definition at line 163 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::getCurrentPhaseDef(), MSPhaseDefinition::getState(), and MSTrafficLightLogic::myLinks.
Referenced by MSTLLogicControl::TLSLogicVariants::addLogic(), and TraCIServerAPI_TLS::processSet().
SUMOTime MSOffTrafficLightLogic::trySwitch | ( | bool | isActive | ) | [inline, virtual] |
Switches to the next phase.
[in] | isActive | Whether this program is the currently used one |
Implements MSTrafficLightLogic.
Definition at line 95 of file MSOffTrafficLightLogic.h.
References DELTA_T, and UNUSED_PARAMETER.
SUMOTime MSTrafficLightLogic::myCurrentDurationIncrement [protected, inherited] |
A value for enlarge the current duration.
Definition at line 427 of file MSTrafficLightLogic.h.
Referenced by MSTrafficLightLogic::setCurrentDurationIncrement(), and MSSimpleTrafficLightLogic::trySwitch().
SUMOTime MSTrafficLightLogic::myDefaultCycleTime [protected, inherited] |
The cycle time (without changes)
Definition at line 433 of file MSTrafficLightLogic.h.
Referenced by MSTrafficLightLogic::getDefaultCycleTime(), MSSimpleTrafficLightLogic::getIndexFromOffset(), MSSimpleTrafficLightLogic::getPhaseIndexAtTime(), MSOffTrafficLightLogic(), and MSSimpleTrafficLightLogic::MSSimpleTrafficLightLogic().
std::string MSTrafficLightLogic::myID [protected, inherited] |
The id of the logic.
Definition at line 415 of file MSTrafficLightLogic.h.
Referenced by MSTrafficLightLogic::getID(), MSActuatedTrafficLightLogic::init(), and MSAgentbasedTrafficLightLogic::init().
LaneVectorVector MSTrafficLightLogic::myLanes [protected, inherited] |
The list of links which do participate in this traffic light.
Definition at line 421 of file MSTrafficLightLogic.h.
Referenced by MSTrafficLightLogic::adaptLinkInformationFrom(), MSTrafficLightLogic::addLink(), MSTrafficLightLogic::getLanes(), MSTrafficLightLogic::getLanesAt(), MSActuatedTrafficLightLogic::init(), and MSAgentbasedTrafficLightLogic::init().
LinkVectorVector MSTrafficLightLogic::myLinks [protected, inherited] |
The list of links which do participate in this traffic light.
Definition at line 418 of file MSTrafficLightLogic.h.
Referenced by MSTrafficLightLogic::adaptLinkInformationFrom(), MSTrafficLightLogic::addLink(), MSTrafficLightLogic::collectLinkStates(), MSTrafficLightLogic::getLinkIndex(), MSTrafficLightLogic::getLinks(), MSTrafficLightLogic::getLinksAt(), MSTrafficLightLogic::resetLinkStates(), and MSTrafficLightLogic::setTrafficLightSignals().
std::vector<SUMOTime> MSTrafficLightLogic::myOverridingTimes [protected, inherited] |
A list of duration overrides.
Definition at line 424 of file MSTrafficLightLogic.h.
Referenced by MSTrafficLightLogic::addOverridingDuration(), and MSSimpleTrafficLightLogic::trySwitch().
std::map<std::string, std::string> MSTrafficLightLogic::myParameter [protected, inherited] |
Given parameter.
Definition at line 412 of file MSTrafficLightLogic.h.
Referenced by MSTrafficLightLogic::getParameterValue(), MSActuatedTrafficLightLogic::init(), MSAgentbasedTrafficLightLogic::init(), and MSTrafficLightLogic::setParameter().
The phase definition (only one)
Definition at line 204 of file MSOffTrafficLightLogic.h.
Referenced by getCurrentPhaseDef(), getPhase(), getPhases(), rebuildPhase(), and ~MSOffTrafficLightLogic().
std::string MSTrafficLightLogic::myProgramID [protected, inherited] |
Definition at line 415 of file MSTrafficLightLogic.h.
Referenced by MSTrafficLightLogic::getProgramID(), MSActuatedTrafficLightLogic::init(), and MSAgentbasedTrafficLightLogic::init().
SwitchCommand* MSTrafficLightLogic::mySwitchCommand [protected, inherited] |
The current switch command.
Definition at line 430 of file MSTrafficLightLogic.h.
Referenced by MSSimpleTrafficLightLogic::changeStepAndDuration(), MSTrafficLightLogic::getNextSwitchTime(), MSTrafficLightLogic::MSTrafficLightLogic(), and MSTrafficLightLogic::~MSTrafficLightLogic().