SUMO - Simulation of Urban MObility
|
A fixed traffic light logic. More...
#include <MSSimpleTrafficLightLogic.h>
Public Types | |
Structure definitions | |
typedef std::vector < MSPhaseDefinition * > | Phases |
Definition of a list of phases, being the junction logic. More... | |
typedef std::vector< MSLink * > | LinkVector |
Definition of the list of links that participate in this tl-light. More... | |
typedef std::vector< LinkVector > | LinkVectorVector |
Definition of a list that holds lists of links that do have the same attribute. More... | |
typedef std::vector< MSLane * > | LaneVector |
Definition of the list of links that participate in this tl-light. More... | |
typedef std::vector< LaneVector > | LaneVectorVector |
Definition of a list that holds lists of links that do have the same attribute. More... | |
typedef std::map< std::string, std::string > | ParameterMap |
Public Member Functions | |
virtual void | init (NLDetectorBuilder &nb) |
Initialises the tls with information about incoming lanes. More... | |
MSSimpleTrafficLightLogic (MSTLLogicControl &tlcontrol, const std::string &id, const std::string &subid, const Phases &phases, unsigned int step, SUMOTime delay, const ParameterMap ¶meters=ParameterMap()) | |
Constructor. More... | |
~MSSimpleTrafficLightLogic () | |
Destructor. More... | |
Switching and setting current rows | |
SUMOTime | trySwitch (bool isActive) |
Switches to the next phase. More... | |
Static Information Retrieval | |
unsigned int | getPhaseNumber () const |
Returns the number of phases. More... | |
const Phases & | getPhases () const |
Returns the phases of this tls program. More... | |
Phases & | getPhases () |
Returns the phases of this tls program. More... | |
const MSPhaseDefinition & | getPhase (unsigned int givenstep) const |
Returns the definition of the phase from the given position within the plan. More... | |
Dynamic Information Retrieval | |
unsigned int | getCurrentPhaseIndex () const |
Returns the current index within the program. More... | |
const MSPhaseDefinition & | getCurrentPhaseDef () const |
Returns the definition of the current phase. More... | |
Conversion between time and phase | |
SUMOTime | getPhaseIndexAtTime (SUMOTime simStep) const |
Returns the index of the logic at the given simulation step. More... | |
SUMOTime | getOffsetFromIndex (unsigned int index) const |
Returns the position (start of a phase during a cycle) from of a given step. More... | |
unsigned int | getIndexFromOffset (SUMOTime offset) const |
Returns the step (the phasenumber) of a given position of the cycle. More... | |
Changing phases and phase durations | |
void | changeStepAndDuration (MSTLLogicControl &tlcontrol, SUMOTime simStep, unsigned int step, SUMOTime stepDuration) |
Changes the current phase and her duration. More... | |
void | setPhases (const Phases &phases, unsigned int index) |
Replaces the phases and set the phase index. More... | |
Handling of controlled links | |
void | addLink (MSLink *link, MSLane *lane, unsigned int pos) |
Adds a link on building. More... | |
virtual void | adaptLinkInformationFrom (const MSTrafficLightLogic &logic) |
Applies information about controlled links and lanes from the given logic. More... | |
std::map< MSLink *, LinkState > | collectLinkStates () const |
Returns the (uncontrolled) states of the controlled links. More... | |
void | resetLinkStates (const std::map< MSLink *, LinkState > &vals) const |
Resets the states of controlled links. More... | |
Switching and setting current rows | |
bool | setTrafficLightSignals (SUMOTime t) const |
Applies the current signal states to controlled links. More... | |
Static Information Retrieval | |
const std::string & | getID () const |
Returns this tl-logic's id. More... | |
const std::string & | getProgramID () const |
Returns this tl-logic's id. More... | |
const LaneVectorVector & | getLanes () const |
Returns the list of lists of all lanes controlled by this tls. More... | |
const LaneVector & | getLanesAt (unsigned int i) const |
Returns the list of lanes that are controlled by the signals at the given position. More... | |
const LinkVectorVector & | getLinks () const |
Returns the list of lists of all affected links. More... | |
const LinkVector & | getLinksAt (unsigned int i) const |
Returns the list of links that are controlled by the signals at the given position. More... | |
int | getLinkIndex (const MSLink *const link) const |
Returns the index of the given link. More... | |
Dynamic Information Retrieval | |
SUMOTime | getDefaultCycleTime () const |
Returns the cycle time (in ms) More... | |
SUMOTime | getNextSwitchTime () const |
Returns the assumed next switch time. More... | |
Changing phases and phase durations | |
void | addOverridingDuration (SUMOTime duration) |
Changes the duration of the next phase. More... | |
void | setCurrentDurationIncrement (SUMOTime delay) |
Delays current phase by the given delay. More... | |
Algorithm parameter handling | |
void | setParameter (const ParameterMap ¶ms) |
Inserts read parameter. More... | |
std::string | getParameterValue (const std::string &key) const |
Returns a named parameter. More... | |
Protected Attributes | |
SUMOTime | myCurrentDurationIncrement |
A value for enlarge the current duration. More... | |
SUMOTime | myDefaultCycleTime |
The cycle time (without changes) More... | |
std::string | myID |
The id of the logic. More... | |
LaneVectorVector | myLanes |
The list of links which do participate in this traffic light. More... | |
LinkVectorVector | myLinks |
The list of links which do participate in this traffic light. More... | |
std::vector< SUMOTime > | myOverridingTimes |
A list of duration overrides. More... | |
ParameterMap | myParameter |
Given parameter. More... | |
Phases | myPhases |
The list of phases this logic uses. More... | |
std::string | myProgramID |
unsigned int | myStep |
The current step. More... | |
SwitchCommand * | mySwitchCommand |
The current switch command. More... | |
Private Member Functions | |
void | deletePhases () |
frees memory responsibilities More... | |
A fixed traffic light logic.
The implementation of a simple traffic light which only switches between it's phases and sets the lights to red in between. Some functions are called with an information about the current step. This is needed as a single logic may be used by many junctions and so the current step is stored within them, not within the logic.
Definition at line 59 of file MSSimpleTrafficLightLogic.h.
|
inherited |
Definition of the list of links that participate in this tl-light.
Definition at line 77 of file MSTrafficLightLogic.h.
|
inherited |
Definition of a list that holds lists of links that do have the same attribute.
Definition at line 80 of file MSTrafficLightLogic.h.
|
inherited |
Definition of the list of links that participate in this tl-light.
Definition at line 71 of file MSTrafficLightLogic.h.
|
inherited |
Definition of a list that holds lists of links that do have the same attribute.
Definition at line 74 of file MSTrafficLightLogic.h.
|
inherited |
Definition at line 82 of file MSTrafficLightLogic.h.
|
inherited |
Definition of a list of phases, being the junction logic.
Definition at line 68 of file MSTrafficLightLogic.h.
MSSimpleTrafficLightLogic::MSSimpleTrafficLightLogic | ( | MSTLLogicControl & | tlcontrol, |
const std::string & | id, | ||
const std::string & | subid, | ||
const Phases & | phases, | ||
unsigned int | step, | ||
SUMOTime | delay, | ||
const ParameterMap & | parameters = ParameterMap() |
||
) |
Constructor.
[in] | tlcontrol | The tls control responsible for this tls |
[in] | id | This tls' id |
[in] | subid | This tls' sub-id (program id) |
[in] | phases | Definitions of the phases |
[in] | step | The initial phase index |
[in] | delay | The time to wait before the first switch |
Definition at line 53 of file MSSimpleTrafficLightLogic.cpp.
References MSTrafficLightLogic::myDefaultCycleTime, and myPhases.
MSSimpleTrafficLightLogic::~MSSimpleTrafficLightLogic | ( | ) |
|
virtualinherited |
Applies information about controlled links and lanes from the given logic.
If we load a logic after the network has been loaded, we do not get the information about controlled links afterwards. We have to copy them from a previously loaded logic.
[in] | logic | The logic to use the information about controlled links/lanes from |
Reimplemented in MSOffTrafficLightLogic.
Definition at line 151 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::myLanes, and MSTrafficLightLogic::myLinks.
Referenced by MSOffTrafficLightLogic::adaptLinkInformationFrom(), and MSTLLogicControl::TLSLogicVariants::addLogic().
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 133 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::getCurrentPhaseDef(), MSNet::getInstance(), MSTrafficLightLogic::myLanes, MSTrafficLightLogic::myLinks, and MSLink::setTLState().
|
inherited |
Changes the duration of the next phase.
[in] | duration | The new duration |
Definition at line 224 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::myOverridingTimes.
|
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 194 of file MSSimpleTrafficLightLogic.cpp.
References MSEventControl::ADAPT_AFTER_EXECUTION, MSEventControl::addEvent(), MSTrafficLightLogic::SwitchCommand::deschedule(), MSTLLogicControl::TLSLogicVariants::executeOnSwitchActions(), MSTLLogicControl::get(), MSNet::getBeginOfTimestepEvents(), MSTrafficLightLogic::getID(), MSNet::getInstance(), myStep, MSTrafficLightLogic::mySwitchCommand, and MSTrafficLightLogic::setTrafficLightSignals().
Referenced by GUIViewTraffic::onGamingClick().
Returns the (uncontrolled) states of the controlled links.
Definition at line 158 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::myLinks.
|
private |
frees memory responsibilities
Definition at line 219 of file MSSimpleTrafficLightLogic.cpp.
References myPhases.
Referenced by setPhases(), and ~MSSimpleTrafficLightLogic().
|
virtual |
Returns the definition of the current phase.
Implements MSTrafficLightLogic.
Definition at line 136 of file MSSimpleTrafficLightLogic.cpp.
References myPhases, and myStep.
Referenced by MSAgentbasedTrafficLightLogic::collectData(), MSActuatedTrafficLightLogic::duration(), MSActuatedTrafficLightLogic::gapControl(), MSActuatedTrafficLightLogic::trySwitch(), and MSAgentbasedTrafficLightLogic::trySwitch().
|
virtual |
Returns the current index within the program.
Implements MSTrafficLightLogic.
Definition at line 130 of file MSSimpleTrafficLightLogic.cpp.
References myStep.
|
inlineinherited |
Returns the cycle time (in ms)
Definition at line 268 of file MSTrafficLightLogic.h.
References MSTrafficLightLogic::myDefaultCycleTime.
Referenced by MSTLLogicControl::WAUTSwitchProcedure::isPosAtGSP().
|
inlineinherited |
Returns this tl-logic's id.
Definition at line 175 of file MSTrafficLightLogic.h.
References MSTrafficLightLogic::myID.
Referenced by MSTLLogicControl::TLSLogicVariants::addLogic(), GUITrafficLightLogicWrapper::begin2TrackPhases(), changeStepAndDuration(), GUINet::createTLWrapper(), Command_SaveTLSState::execute(), Command_SaveTLSSwitchStates::execute(), Command_SaveTLSSwitches::execute(), GUITrafficLightLogicWrapper::getPopUpMenu(), GUITLLogicPhasesTrackerWindow::GUITLLogicPhasesTrackerWindow(), MSTLLogicControl::isActive(), GUIViewTraffic::onGamingClick(), and GUITrafficLightLogicWrapper::switchTLSLogic().
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 172 of file MSSimpleTrafficLightLogic.cpp.
References MSPhaseDefinition::duration, getPhase(), MSTrafficLightLogic::myDefaultCycleTime, and myPhases.
|
inlineinherited |
Returns the list of lists of all lanes controlled by this tls.
Definition at line 191 of file MSTrafficLightLogic.h.
References MSTrafficLightLogic::myLanes.
Referenced by GUITrafficLightLogicWrapper::getCenteringBoundary(), TraCIServerAPI_TLS::processGet(), and MSFullExport::writeTLS().
|
inlineinherited |
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 200 of file MSTrafficLightLogic.h.
References MSTrafficLightLogic::myLanes.
Referenced by MSAgentbasedTrafficLightLogic::collectData(), GUITrafficLightLogicWrapper::drawGL(), MSActuatedTrafficLightLogic::duration(), Command_SaveTLSSwitches::execute(), MSActuatedTrafficLightLogic::gapControl(), and GUIViewTraffic::onGamingClick().
Returns the index of the given link.
[in] | link | The link to retrieve the index for |
Definition at line 200 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::myLinks.
Referenced by GUITrafficLightLogicWrapper::getLinkIndex().
|
inlineinherited |
Returns the list of lists of all affected links.
Definition at line 208 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 MSOffTrafficLightLogic::rebuildPhase().
|
inlineinherited |
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 217 of file MSTrafficLightLogic.h.
References MSTrafficLightLogic::myLinks.
|
inherited |
Returns the assumed next switch time.
The time may change in case of adaptive/actuated traffic lights.
Definition at line 217 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::SwitchCommand::getNextSwitchTime(), and MSTrafficLightLogic::mySwitchCommand.
Referenced by MSTLLogicControl::WAUTSwitchProcedure::isPosAtGSP(), and TraCIServerAPI_TLS::processGet().
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 158 of file MSSimpleTrafficLightLogic.cpp.
References MSPhaseDefinition::duration, getPhase(), and myPhases.
|
inherited |
Returns a named parameter.
[in] | key | The name of the parameter |
Definition at line 245 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::myParameter.
Referenced by MSTLLogicControl::WAUTSwitchProcedure::getGSPValue(), MSTLLogicControl::WAUTSwitchProcedure_Stretch::getStretchAreaNo(), and MSTLLogicControl::WAUTSwitchProcedure_Stretch::getStretchBereichDef().
|
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 122 of file MSSimpleTrafficLightLogic.cpp.
References myPhases.
Referenced by getIndexFromOffset(), getOffsetFromIndex(), getPhaseIndexAtTime(), and GUIViewTraffic::onGamingClick().
Returns the index of the logic at the given simulation step.
Implements MSTrafficLightLogic.
Definition at line 143 of file MSSimpleTrafficLightLogic.cpp.
References MSPhaseDefinition::duration, getPhase(), MSTrafficLightLogic::myDefaultCycleTime, MSPhaseDefinition::myLastSwitch, and myStep.
|
virtual |
Returns the number of phases.
Implements MSTrafficLightLogic.
Definition at line 104 of file MSSimpleTrafficLightLogic.cpp.
References myPhases.
|
virtual |
Returns the phases of this tls program.
Implements MSTrafficLightLogic.
Definition at line 110 of file MSSimpleTrafficLightLogic.cpp.
References myPhases.
MSSimpleTrafficLightLogic::Phases & MSSimpleTrafficLightLogic::getPhases | ( | ) |
Returns the phases of this tls program.
Definition at line 116 of file MSSimpleTrafficLightLogic.cpp.
References myPhases.
|
inlineinherited |
Returns this tl-logic's id.
Definition at line 183 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().
|
virtualinherited |
Initialises the tls with information about incoming lanes.
[in] | nb | The detector builder |
[in] | edgeContinuations | Information about edge predecessors/successors |
ProcessError | If something fails on initialisation |
Reimplemented in MSAgentbasedTrafficLightLogic, MSActuatedTrafficLightLogic, and MSOffTrafficLightLogic.
Definition at line 121 of file MSTrafficLightLogic.cpp.
Referenced by NLJunctionControlBuilder::closeTrafficLightLogic().
|
inherited |
Resets the states of controlled links.
[in] | vals | The state of controlled links to use |
Definition at line 187 of file MSTrafficLightLogic.cpp.
References MSNet::getCurrentTimeStep(), MSNet::getInstance(), and MSTrafficLightLogic::myLinks.
|
inherited |
Delays current phase by the given delay.
[in] | delay | The time by which the current phase shall be delayed |
Definition at line 230 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::myCurrentDurationIncrement.
|
inherited |
Inserts read parameter.
[in] | params | The parameter to use |
Definition at line 239 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::myParameter.
Replaces the phases and set the phase index.
Definition at line 210 of file MSSimpleTrafficLightLogic.cpp.
References deletePhases(), myPhases, and myStep.
Applies the current signal states to controlled links.
[in] | t | The current time |
Definition at line 171 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::getCurrentPhaseDef(), MSPhaseDefinition::getState(), and MSTrafficLightLogic::myLinks.
Referenced by MSTLLogicControl::TLSLogicVariants::addLogic(), changeStepAndDuration(), and TraCIServerAPI_TLS::processSet().
Switches to the next phase.
[in] | isActive | Whether this program is the currently used one |
Implements MSTrafficLightLogic.
Definition at line 73 of file MSSimpleTrafficLightLogic.cpp.
References MSNet::getCurrentTimeStep(), MSNet::getInstance(), MSTrafficLightLogic::myCurrentDurationIncrement, MSTrafficLightLogic::myOverridingTimes, myPhases, and myStep.
|
protectedinherited |
A value for enlarge the current duration.
Definition at line 432 of file MSTrafficLightLogic.h.
Referenced by MSTrafficLightLogic::setCurrentDurationIncrement(), and trySwitch().
|
protectedinherited |
The cycle time (without changes)
Definition at line 438 of file MSTrafficLightLogic.h.
Referenced by MSTrafficLightLogic::getDefaultCycleTime(), getIndexFromOffset(), getPhaseIndexAtTime(), MSOffTrafficLightLogic::MSOffTrafficLightLogic(), and MSSimpleTrafficLightLogic().
|
protectedinherited |
The id of the logic.
Definition at line 420 of file MSTrafficLightLogic.h.
Referenced by MSTrafficLightLogic::getID(), MSActuatedTrafficLightLogic::init(), and MSAgentbasedTrafficLightLogic::init().
|
protectedinherited |
The list of links which do participate in this traffic light.
Definition at line 426 of file MSTrafficLightLogic.h.
Referenced by MSTrafficLightLogic::adaptLinkInformationFrom(), MSTrafficLightLogic::addLink(), MSTrafficLightLogic::getLanes(), MSTrafficLightLogic::getLanesAt(), MSActuatedTrafficLightLogic::init(), and MSAgentbasedTrafficLightLogic::init().
|
protectedinherited |
The list of links which do participate in this traffic light.
Definition at line 423 of file MSTrafficLightLogic.h.
Referenced by MSTrafficLightLogic::adaptLinkInformationFrom(), MSTrafficLightLogic::addLink(), MSTrafficLightLogic::collectLinkStates(), MSTrafficLightLogic::getLinkIndex(), MSTrafficLightLogic::getLinks(), MSTrafficLightLogic::getLinksAt(), MSTrafficLightLogic::resetLinkStates(), and MSTrafficLightLogic::setTrafficLightSignals().
|
protectedinherited |
A list of duration overrides.
Definition at line 429 of file MSTrafficLightLogic.h.
Referenced by MSTrafficLightLogic::addOverridingDuration(), and trySwitch().
|
protectedinherited |
Given parameter.
Definition at line 417 of file MSTrafficLightLogic.h.
Referenced by MSTrafficLightLogic::getParameterValue(), MSAgentbasedTrafficLightLogic::init(), and MSTrafficLightLogic::setParameter().
|
protected |
The list of phases this logic uses.
Definition at line 195 of file MSSimpleTrafficLightLogic.h.
Referenced by MSAgentbasedTrafficLightLogic::calculateDuration(), MSAgentbasedTrafficLightLogic::cutCycleTime(), deletePhases(), MSActuatedTrafficLightLogic::duration(), MSAgentbasedTrafficLightLogic::findStepOfMaxValue(), MSAgentbasedTrafficLightLogic::findStepOfMinValue(), MSActuatedTrafficLightLogic::gapControl(), getCurrentPhaseDef(), getIndexFromOffset(), getOffsetFromIndex(), getPhase(), getPhaseNumber(), getPhases(), MSAgentbasedTrafficLightLogic::init(), MSAgentbasedTrafficLightLogic::lengthenCycleTime(), MSSimpleTrafficLightLogic(), MSAgentbasedTrafficLightLogic::nextStep(), setPhases(), trySwitch(), MSActuatedTrafficLightLogic::trySwitch(), and MSAgentbasedTrafficLightLogic::trySwitch().
|
protectedinherited |
Definition at line 420 of file MSTrafficLightLogic.h.
Referenced by MSTrafficLightLogic::getProgramID(), MSActuatedTrafficLightLogic::init(), and MSAgentbasedTrafficLightLogic::init().
|
protected |
The current step.
Definition at line 198 of file MSSimpleTrafficLightLogic.h.
Referenced by MSAgentbasedTrafficLightLogic::calculateDuration(), changeStepAndDuration(), MSAgentbasedTrafficLightLogic::collectData(), MSActuatedTrafficLightLogic::duration(), MSActuatedTrafficLightLogic::gapControl(), getCurrentPhaseDef(), getCurrentPhaseIndex(), getPhaseIndexAtTime(), MSAgentbasedTrafficLightLogic::nextStep(), setPhases(), trySwitch(), MSActuatedTrafficLightLogic::trySwitch(), and MSAgentbasedTrafficLightLogic::trySwitch().
|
protectedinherited |
The current switch command.
Definition at line 435 of file MSTrafficLightLogic.h.
Referenced by changeStepAndDuration(), MSTrafficLightLogic::getNextSwitchTime(), and MSTrafficLightLogic::MSTrafficLightLogic().