44 #ifdef CHECK_MEMORY_LEAKS
46 #endif // CHECK_MEMORY_LEAKS
57 : myTLControl(tlcontrol), myTLLogic(tlLogic),
58 myAssumedNextSwitch(nextSwitch), myAmValid(true) {}
72 bool isActive = myTLControl.isActive(myTLLogic);
73 size_t step1 = myTLLogic->getCurrentPhaseIndex();
74 SUMOTime next = myTLLogic->trySwitch(isActive);
75 size_t step2 = myTLLogic->getCurrentPhaseIndex();
81 myTLLogic->setTrafficLightSignals(t);
86 myAssumedNextSwitch += next;
93 if (tlLogic == myTLLogic) {
95 myAssumedNextSwitch = -1;
104 const std::string& programID,
SUMOTime delay,
const std::map<std::string, std::string>& parameters) :
131 while (
myLinks.size() <= pos) {
137 while (
myLanes.size() <= pos) {
152 std::map<MSLink*, LinkState>
154 std::map<MSLink*, LinkState> ret;
155 for (LinkVectorVector::const_iterator i1 =
myLinks.begin(); i1 !=
myLinks.end(); ++i1) {
157 for (LinkVector::const_iterator i2 = l.begin(); i2 != l.end(); ++i2) {
158 ret[*i2] = (*i2)->getState();
170 for (
size_t i = 0; i <
myLinks.size(); i++) {
173 for (LinkVector::const_iterator j = currGroup.begin(); j != currGroup.end(); j++) {
174 (*j)->setTLState(ls, t);
183 for (LinkVectorVector::const_iterator i1 =
myLinks.begin(); i1 !=
myLinks.end(); ++i1) {
185 for (LinkVector::const_iterator i2 = l.begin(); i2 != l.end(); ++i2) {
186 assert(vals.find(*i2) != vals.end());
197 for (LinkVectorVector::const_iterator i1 =
myLinks.begin(); i1 !=
myLinks.end(); ++i1, ++index) {
199 for (LinkVector::const_iterator i2 = l.begin(); i2 != l.end(); ++i2) {
SUMOTime myCurrentDurationIncrement
A value for enlarge the current duration.
void resetLinkStates(const std::map< MSLink *, LinkState > &vals) const
Resets the states of controlled links.
virtual const MSPhaseDefinition & getCurrentPhaseDef() const =0
Returns the definition of the current phase.
Builds detectors for microsim.
const std::string & getState() const
Returns the state within this phase.
bool setTrafficLightSignals(SUMOTime t) const
Applies the current signal states to controlled links.
Storage for all programs of a single tls.
std::vector< SUMOTime > myOverridingTimes
A list of duration overrides.
int getLinkIndex(const MSLink *const link) const
Returns the index of the given link.
SwitchCommand(MSTLLogicControl &tlcontrol, MSTrafficLightLogic *tlLogic, SUMOTime nextSwitch)
Constructor.
std::string myProgramID
The id of the logic.
void setTLState(LinkState state, SUMOTime t)
Sets the current tl-state.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSTrafficLightLogic(MSTLLogicControl &tlcontrol, const std::string &id, const std::string &programID, SUMOTime delay, const std::map< std::string, std::string > ¶meters)
Constructor.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step (in s)
LaneVectorVector myLanes
The list of links which do participate in this traffic light.
virtual ~MSTrafficLightLogic()
Destructor.
SUMOTime getNextSwitchTime() const
Returns the assumed next switch time.
A class that stores and controls tls and switching of their programs.
void deschedule(MSTrafficLightLogic *tlLogic)
Marks this swicth as invalid (if the phase duration has changed, f.e.)
Class realising the switch between the traffic light phases.
~SwitchCommand()
Destructor.
SUMOTime myDefaultCycleTime
The cycle time (without changes)
virtual void init(NLDetectorBuilder &nb)
Initialises the tls with information about incoming lanes.
virtual void adaptLinkInformationFrom(const MSTrafficLightLogic &logic)
Applies information about controlled links and lanes from the given logic.
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
An upper class for objects with additional parameters.
virtual SUMOTime addEvent(Command *operation, SUMOTime execTimeStep, AdaptType type)
Adds an Event.
void setCurrentDurationIncrement(SUMOTime delay)
Delays current phase by the given delay.
Base class for objects which have an id.
std::vector< MSLink * > LinkVector
Definition of the list of links that participate in this tl-light.
SUMOTime getNextSwitchTime() const
Returns the assumed next switch time.
void addOverridingDuration(SUMOTime duration)
Changes the duration of the next phase.
LinkVectorVector myLinks
The list of links which do participate in this traffic light.
std::vector< MSLane * > LaneVector
Definition of the list of links that participate in this tl-light.
void executeOnSwitchActions() const
SwitchCommand * mySwitchCommand
The current switch command.
The parent class for traffic light logics.
void addLink(MSLink *link, MSLane *lane, unsigned int pos)
Adds a link on building.
MSEventControl & getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
Representation of a lane in the micro simulation.
std::map< MSLink *, LinkState > collectLinkStates() const
Returns the (uncontrolled) states of the controlled links.
SUMOTime execute(SUMOTime currentTime)
Executes the regarded junction's "trySwitch"- method.