Eclipse SUMO - Simulation of Urban MObility
TrafficLight.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2017-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // C++ TraCI client API implementation
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <microsim/MSLane.h>
27 #include <microsim/MSEdge.h>
28 #include <microsim/MSNet.h>
36 #include <libsumo/TraCIConstants.h>
37 #include "TrafficLight.h"
38 
39 
40 namespace libsumo {
41 // ===========================================================================
42 // static member initializations
43 // ===========================================================================
46 
47 
48 // ===========================================================================
49 // static member definitions
50 // ===========================================================================
51 std::vector<std::string>
54 }
55 
56 
57 int
59  return (int)getIDList().size();
60 }
61 
62 
63 std::string
64 TrafficLight::getRedYellowGreenState(const std::string& tlsID) {
65  return getTLS(tlsID).getActive()->getCurrentPhaseDef().getState();
66 }
67 
68 
69 std::vector<TraCILogic>
71  std::vector<TraCILogic> result;
72  const std::vector<MSTrafficLightLogic*> logics = getTLS(tlsID).getAllLogics();
73  for (MSTrafficLightLogic* logic : logics) {
74  TraCILogic l(logic->getProgramID(), (int)logic->getLogicType(), logic->getCurrentPhaseIndex());
75  l.subParameter = logic->getParametersMap();
76  for (const MSPhaseDefinition* const phase : logic->getPhases()) {
77  l.phases.emplace_back(TraCIPhase(STEPS2TIME(phase->duration), phase->getState(),
78  STEPS2TIME(phase->minDuration), STEPS2TIME(phase->maxDuration),
79  phase->getNextPhases(), phase->getName()));
80  }
81  result.emplace_back(l);
82  }
83  return result;
84 }
85 
86 
87 std::vector<std::string>
88 TrafficLight::getControlledJunctions(const std::string& tlsID) {
89  std::set<std::string> junctionIDs;
91  for (const MSTrafficLightLogic::LinkVector& llinks : links) {
92  for (const MSLink* l : llinks) {
93  junctionIDs.insert(l->getJunction()->getID());
94  }
95  }
96  return std::vector<std::string>(junctionIDs.begin(), junctionIDs.end());
97 }
98 
99 
100 std::vector<std::string>
101 TrafficLight::getControlledLanes(const std::string& tlsID) {
102  std::vector<std::string> laneIDs;
104  for (const MSTrafficLightLogic::LaneVector& llanes : lanes) {
105  for (const MSLane* l : llanes) {
106  laneIDs.push_back(l->getID());
107  }
108  }
109  return laneIDs;
110 }
111 
112 
113 std::vector<std::vector<TraCILink> >
114 TrafficLight::getControlledLinks(const std::string& tlsID) {
115  std::vector<std::vector<TraCILink> > result;
118  for (int i = 0; i < (int)lanes.size(); ++i) {
119  std::vector<TraCILink> subList;
120  const MSTrafficLightLogic::LaneVector& llanes = lanes[i];
121  const MSTrafficLightLogic::LinkVector& llinks = links[i];
122  // number of links controlled by this signal (signal i)
123  for (int j = 0; j < (int)llanes.size(); ++j) {
124  MSLink* link = llinks[j];
125  // approached non-internal lane (if any)
126  const std::string to = link->getLane() != nullptr ? link->getLane()->getID() : "";
127  // approached "via", internal lane (if any)
128  const std::string via = link->getViaLane() != nullptr ? link->getViaLane()->getID() : "";
129  subList.emplace_back(TraCILink(llanes[j]->getID(), via, to));
130  }
131  result.emplace_back(subList);
132  }
133  return result;
134 }
135 
136 
137 std::string
138 TrafficLight::getProgram(const std::string& tlsID) {
139  return getTLS(tlsID).getActive()->getProgramID();
140 }
141 
142 
143 int
144 TrafficLight::getPhase(const std::string& tlsID) {
145  return getTLS(tlsID).getActive()->getCurrentPhaseIndex();
146 }
147 
148 
149 std::string
150 TrafficLight::getPhaseName(const std::string& tlsID) {
151  return getTLS(tlsID).getActive()->getCurrentPhaseDef().getName();
152 }
153 
154 double
155 TrafficLight::getPhaseDuration(const std::string& tlsID) {
156  return STEPS2TIME(getTLS(tlsID).getActive()->getCurrentPhaseDef().duration);
157 }
158 
159 
160 double
161 TrafficLight::getNextSwitch(const std::string& tlsID) {
162  return STEPS2TIME(getTLS(tlsID).getActive()->getNextSwitchTime());
163 }
164 
165 int
166 TrafficLight::getServedPersonCount(const std::string& tlsID, int index) {
167  MSTrafficLightLogic* const active = getTLS(tlsID).getActive();
168  if (index < 0 || active->getPhaseNumber() <= index) {
169  throw TraCIException("The phase index " + toString(index) + " is not in the allowed range [0,"
170  + toString(active->getPhaseNumber() - 1) + "].");
171  }
172  // find all crossings which have a green light in that phas
173  int result = 0;
174 
175  const std::string& state = active->getPhases()[index]->getState();
176  for (int i = 0; i < (int)state.size(); i++) {
177  for (MSLink* link : active->getLinksAt(i)) {
178  if (link->getLane()->getEdge().isCrossing()) {
179  // walking forwards across
180  for (MSTransportable* person : link->getLaneBefore()->getEdge().getPersons()) {
181  if (static_cast<MSPerson*>(person)->getNextEdge() == link->getLane()->getEdge().getID()) {
182  result += 1;
183  }
184  }
185  // walking backwards across
186  MSLane* walkingAreaAcross = link->getLane()->getLinkCont().front()->getLane();
187  for (MSTransportable* person : walkingAreaAcross->getEdge().getPersons()) {
188  if (static_cast<MSPerson*>(person)->getNextEdge() == link->getLane()->getEdge().getID()) {
189  result += 1;
190  }
191  }
192  } else if (link->getLaneBefore()->getEdge().isCrossing()) {
193  // walking backwards across (in case both sides are separately controlled)
194  for (MSTransportable* person : link->getLane()->getEdge().getPersons()) {
195  if (static_cast<MSPerson*>(person)->getNextEdge() == link->getLaneBefore()->getEdge().getID()) {
196  result += 1;
197  }
198  }
199  }
200  }
201  }
202  return result;
203 }
204 
205 std::string
206 TrafficLight::getParameter(const std::string& tlsID, const std::string& paramName) {
207  return getTLS(tlsID).getActive()->getParameter(paramName, "");
208 }
209 
210 
211 void
212 TrafficLight::setRedYellowGreenState(const std::string& tlsID, const std::string& state) {
213  getTLS(tlsID).setStateInstantiatingOnline(MSNet::getInstance()->getTLSControl(), state);
214 }
215 
216 
217 void
218 TrafficLight::setPhase(const std::string& tlsID, const int index) {
219  MSTrafficLightLogic* const active = getTLS(tlsID).getActive();
220  if (index < 0 || active->getPhaseNumber() <= index) {
221  throw TraCIException("The phase index " + toString(index) + " is not in the allowed range [0,"
222  + toString(active->getPhaseNumber() - 1) + "].");
223  }
225  const SUMOTime duration = active->getPhase(index).duration;
226  active->changeStepAndDuration(MSNet::getInstance()->getTLSControl(), cTime, index, duration);
227 }
228 
229 void
230 TrafficLight::setPhaseName(const std::string& tlsID, const std::string& name) {
231  MSTrafficLightLogic* const active = getTLS(tlsID).getActive();
232  const_cast<MSPhaseDefinition&>(active->getCurrentPhaseDef()).setName(name);
233 }
234 
235 
236 void
237 TrafficLight::setProgram(const std::string& tlsID, const std::string& programID) {
238  try {
239  getTLS(tlsID).switchTo(MSNet::getInstance()->getTLSControl(), programID);
240  } catch (ProcessError& e) {
241  throw TraCIException(e.what());
242  }
243 }
244 
245 
246 void
247 TrafficLight::setPhaseDuration(const std::string& tlsID, const double phaseDuration) {
248  MSTrafficLightLogic* const active = getTLS(tlsID).getActive();
250  const int index = active->getCurrentPhaseIndex();
251  active->changeStepAndDuration(MSNet::getInstance()->getTLSControl(), cTime, index, TIME2STEPS(phaseDuration));
252 }
253 
254 
255 void
256 TrafficLight::setCompleteRedYellowGreenDefinition(const std::string& tlsID, const TraCILogic& logic) {
258  // make sure index and phaseNo are consistent
259  if (logic.currentPhaseIndex >= (int)logic.phases.size()) {
260  throw TraCIException("set program: parameter index must be less than parameter phase number.");
261  }
262  std::vector<MSPhaseDefinition*> phases;
263  for (TraCIPhase phase : logic.phases) {
264  phases.push_back(new MSPhaseDefinition(TIME2STEPS(phase.duration), phase.state, TIME2STEPS(phase.minDur), TIME2STEPS(phase.maxDur), phase.next, phase.name));
265  }
266  if (vars.getLogic(logic.programID) == nullptr) {
268  int step = logic.currentPhaseIndex;
269  const std::string basePath = "";
270  MSTrafficLightLogic* tlLogic = nullptr;
271  SUMOTime nextSwitch = 0; //MSNet::getInstance()->getCurrentTimeStep();
272  switch (logic.type) {
273  case TLTYPE_ACTUATED:
274  tlLogic = new MSActuatedTrafficLightLogic(tlc,
275  tlsID, logic.programID,
276  phases, step, nextSwitch,
277  logic.subParameter, basePath);
278  break;
279  case TLTYPE_DELAYBASED:
280  tlLogic = new MSDelayBasedTrafficLightLogic(tlc,
281  tlsID, logic.programID,
282  phases, step, nextSwitch,
283  logic.subParameter, basePath);
284  break;
285  case TLTYPE_STATIC:
286  tlLogic = new MSSimpleTrafficLightLogic(tlc,
287  tlsID, logic.programID, TLTYPE_STATIC,
288  phases, step, nextSwitch,
289  logic.subParameter);
290  break;
291  default:
292  throw TraCIException("Unsupported traffic light type '" + toString(logic.type) + "'");
293  }
294  vars.addLogic(logic.programID, tlLogic, true, true);
295  // XXX pass GUIDetectorBuilder when running with gui
297  tlLogic->init(db);
298  } else {
299  static_cast<MSSimpleTrafficLightLogic*>(vars.getLogic(logic.programID))->setPhases(phases, logic.currentPhaseIndex);
300  }
301 }
302 
303 
304 void
305 TrafficLight::setParameter(const std::string& tlsID, const std::string& paramName, const std::string& value) {
306  return getTLS(tlsID).getActive()->setParameter(paramName, value);
307 }
308 
309 
311 
312 
314 TrafficLight::getTLS(const std::string& id) {
315  if (!MSNet::getInstance()->getTLSControl().knows(id)) {
316  throw TraCIException("Traffic light '" + id + "' is not known");
317  }
318  return MSNet::getInstance()->getTLSControl().get(id);
319 }
320 
321 
322 std::shared_ptr<VariableWrapper>
324  return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
325 }
326 
327 
328 bool
329 TrafficLight::handleVariable(const std::string& objID, const int variable, VariableWrapper* wrapper) {
330  switch (variable) {
331  case TRACI_ID_LIST:
332  return wrapper->wrapStringList(objID, variable, getIDList());
333  case ID_COUNT:
334  return wrapper->wrapInt(objID, variable, getIDCount());
336  return wrapper->wrapString(objID, variable, getRedYellowGreenState(objID));
337  case TL_CONTROLLED_LANES:
338  return wrapper->wrapStringList(objID, variable, getControlledLanes(objID));
339  case TL_CURRENT_PHASE:
340  return wrapper->wrapInt(objID, variable, getPhase(objID));
341  case VAR_NAME:
342  return wrapper->wrapString(objID, variable, getPhaseName(objID));
343  case TL_CURRENT_PROGRAM:
344  return wrapper->wrapString(objID, variable, getProgram(objID));
345  case TL_PHASE_DURATION:
346  return wrapper->wrapDouble(objID, variable, getPhaseDuration(objID));
347  case TL_NEXT_SWITCH:
348  return wrapper->wrapDouble(objID, variable, getNextSwitch(objID));
350  return wrapper->wrapStringList(objID, variable, getControlledJunctions(objID));
351  default:
352  return false;
353  }
354 }
355 
356 
357 }
358 
359 
360 /****************************************************************************/
MSTrafficLightLogic::getPhases
virtual const Phases & getPhases() const =0
Returns the phases of this tls program.
MSTrafficLightLogic::getLinksAt
const LinkVector & getLinksAt(int i) const
Returns the list of links that are controlled by the signals at the given position.
Definition: MSTrafficLightLogic.h:212
libsumo::TrafficLight::getControlledLinks
static std::vector< std::vector< TraCILink > > getControlledLinks(const std::string &tlsID)
Definition: TrafficLight.cpp:114
MSEdge::getPersons
const std::set< MSTransportable * > & getPersons() const
Returns this edge's persons set.
Definition: MSEdge.h:176
MSTLLogicControl::TLSLogicVariants::addLogic
bool addLogic(const std::string &programID, MSTrafficLightLogic *logic, bool netWasLoaded, bool isNewDefault=true)
Adds a logic (program)
Definition: MSTLLogicControl.cpp:92
libsumo::TL_CURRENT_PHASE
TRACI_CONST int TL_CURRENT_PHASE
Definition: TraCIConstants.h:567
libsumo::TrafficLight::setParameter
static void setParameter(const std::string &tlsID, const std::string &paramName, const std::string &value)
Definition: TrafficLight.cpp:305
libsumo::TrafficLight::setProgram
static void setProgram(const std::string &tlsID, const std::string &programID)
Definition: TrafficLight.cpp:237
MSTLLogicControl.h
MSNet.h
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
MSPerson::getNextEdge
const std::string & getNextEdge() const
return the list of internal edges if this person is walking and the pedestrian model allows it
Definition: MSPerson.cpp:666
libsumo::VariableWrapper::wrapString
virtual bool wrapString(const std::string &objID, const int variable, const std::string &value)=0
libsumo::TrafficLight
Definition: TrafficLight.h:53
libsumo::VAR_NAME
TRACI_CONST int VAR_NAME
Definition: TraCIConstants.h:546
MSTrafficLightLogic::getProgramID
const std::string & getProgramID() const
Returns this tl-logic's id.
Definition: MSTrafficLightLogic.h:174
libsumo::VariableWrapper
Definition: Subscription.h:132
libsumo::TraCILogic::type
int type
Definition: TraCIDefs.h:246
TLTYPE_STATIC
@ TLTYPE_STATIC
Definition: SUMOXMLDefinitions.h:1198
libsumo::TL_NEXT_SWITCH
TRACI_CONST int TL_NEXT_SWITCH
Definition: TraCIConstants.h:582
MSTLLogicControl::getAllTLIds
std::vector< std::string > getAllTLIds() const
Definition: MSTLLogicControl.cpp:609
libsumo::TraCIPhase::maxDur
double maxDur
Definition: TraCIDefs.h:219
libsumo::TL_PHASE_DURATION
TRACI_CONST int TL_PHASE_DURATION
Definition: TraCIConstants.h:558
MSPerson
Definition: MSPerson.h:63
MSActuatedTrafficLightLogic.h
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
MSTrafficLightLogic::getCurrentPhaseIndex
virtual int getCurrentPhaseIndex() const =0
Returns the current index within the program.
libsumo::ContextSubscriptionResults
std::map< std::string, SubscriptionResults > ContextSubscriptionResults
Definition: TraCIDefs.h:204
libsumo::TraCILogic::currentPhaseIndex
int currentPhaseIndex
Definition: TraCIDefs.h:247
libsumo::TrafficLight::getControlledLanes
static std::vector< std::string > getControlledLanes(const std::string &tlsID)
Definition: TrafficLight.cpp:101
MSEdge.h
MSTransportable
Definition: MSTransportable.h:58
libsumo::TrafficLight::setPhase
static void setPhase(const std::string &tlsID, const int index)
Definition: TrafficLight.cpp:218
MSTLLogicControl::TLSLogicVariants::getActive
MSTrafficLightLogic * getActive() const
Definition: MSTLLogicControl.cpp:200
MSSimpleTrafficLightLogic.h
libsumo::TrafficLight::setCompleteRedYellowGreenDefinition
static void setCompleteRedYellowGreenDefinition(const std::string &tlsID, const TraCILogic &logic)
Definition: TrafficLight.cpp:256
Parameterised::getParameter
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
Definition: Parameterised.cpp:72
MSTLLogicControl::TLSLogicVariants::getLogic
MSTrafficLightLogic * getLogic(const std::string &programID) const
Definition: MSTLLogicControl.cpp:127
libsumo
Definition: Edge.cpp:29
libsumo::TrafficLight::getPhaseDuration
static double getPhaseDuration(const std::string &tlsID)
Definition: TrafficLight.cpp:155
libsumo::TrafficLight::mySubscriptionResults
static SubscriptionResults mySubscriptionResults
Definition: TrafficLight.h:93
libsumo::TrafficLight::getRedYellowGreenState
static std::string getRedYellowGreenState(const std::string &tlsID)
Definition: TrafficLight.cpp:64
libsumo::TrafficLight::setRedYellowGreenState
static void setRedYellowGreenState(const std::string &tlsID, const std::string &state)
Definition: TrafficLight.cpp:212
MSTransportable::getEdge
const MSEdge * getEdge() const
Returns the current edge.
Definition: MSTransportable.h:627
libsumo::VariableWrapper::wrapDouble
virtual bool wrapDouble(const std::string &objID, const int variable, const double value)=0
libsumo::TraCILogic
Definition: TraCIDefs.h:232
MSTrafficLightLogic::LaneVector
std::vector< MSLane * > LaneVector
Definition of the list of arrival lanes subjected to this tls.
Definition: MSTrafficLightLogic.h:70
libsumo::TrafficLight::getIDList
static std::vector< std::string > getIDList()
Definition: TrafficLight.cpp:52
MSTLLogicControl::TLSLogicVariants::getAllLogics
std::vector< MSTrafficLightLogic * > getAllLogics() const
Definition: MSTLLogicControl.cpp:183
MSPhaseDefinition::duration
SUMOTime duration
The duration of the phase.
Definition: MSPhaseDefinition.h:70
MSTrafficLightLogic::changeStepAndDuration
virtual void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)=0
Changes the current phase and her duration.
MSTLLogicControl::get
TLSLogicVariants & get(const std::string &id) const
Returns the variants of a named tls.
Definition: MSTLLogicControl.cpp:589
libsumo::TrafficLight::getIDCount
static int getIDCount()
Definition: TrafficLight.cpp:58
TraCIConstants.h
libsumo::TrafficLight::getProgram
static std::string getProgram(const std::string &tlsID)
Definition: TrafficLight.cpp:138
TIME2STEPS
#define TIME2STEPS(x)
Definition: SUMOTime.h:58
MSPhaseDefinition::getState
const std::string & getState() const
Returns the state within this phase.
Definition: MSPhaseDefinition.h:199
libsumo::TraCILogic::programID
std::string programID
Definition: TraCIDefs.h:245
libsumo::VariableWrapper::wrapStringList
virtual bool wrapStringList(const std::string &objID, const int variable, const std::vector< std::string > &value)=0
MSNet::getCurrentTimeStep
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:283
STEPS2TIME
#define STEPS2TIME(x)
Definition: SUMOTime.h:56
libsumo::TL_CONTROLLED_LANES
TRACI_CONST int TL_CONTROLLED_LANES
Definition: TraCIConstants.h:561
libsumo::TraCIPhase::state
std::string state
Definition: TraCIDefs.h:218
ProcessError
Definition: UtilExceptions.h:39
NLDetectorBuilder.h
MSSimpleTrafficLightLogic
A fixed traffic light logic.
Definition: MSSimpleTrafficLightLogic.h:54
libsumo::TrafficLight::setPhaseDuration
static void setPhaseDuration(const std::string &tlsID, const double phaseDuration)
Definition: TrafficLight.cpp:247
libsumo::TrafficLight::getControlledJunctions
static std::vector< std::string > getControlledJunctions(const std::string &tlsID)
Definition: TrafficLight.cpp:88
libsumo::TRACI_ID_LIST
TRACI_CONST int TRACI_ID_LIST
Definition: TraCIConstants.h:498
libsumo::TrafficLight::getTLS
static MSTLLogicControl::TLSLogicVariants & getTLS(const std::string &id)
Definition: TrafficLight.cpp:314
MSActuatedTrafficLightLogic
An actuated (adaptive) traffic light logic.
Definition: MSActuatedTrafficLightLogic.h:50
MSTLLogicControl::TLSLogicVariants::switchTo
void switchTo(MSTLLogicControl &tlc, const std::string &programID)
Definition: MSTLLogicControl.cpp:206
LIBSUMO_SUBSCRIPTION_IMPLEMENTATION
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
Definition: TraCIDefs.h:50
MSTrafficLightLogic
The parent class for traffic light logics.
Definition: MSTrafficLightLogic.h:55
libsumo::TraCIPhase::minDur
double minDur
Definition: TraCIDefs.h:219
MSDelayBasedTrafficLightLogic.h
TrafficLight.h
libsumo::TraCIPhase::duration
double duration
Definition: TraCIDefs.h:217
libsumo::ID_COUNT
TRACI_CONST int ID_COUNT
Definition: TraCIConstants.h:501
libsumo::TrafficLight::setPhaseName
static void setPhaseName(const std::string &tlsID, const std::string &name)
Definition: TrafficLight.cpp:230
MSTrafficLightLogic::getPhaseNumber
virtual int getPhaseNumber() const =0
Returns the number of phases.
MSLane::getLinkCont
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.cpp:2110
libsumo::TraCIPhase::next
std::vector< int > next
Definition: TraCIDefs.h:220
libsumo::TrafficLight::myContextSubscriptionResults
static ContextSubscriptionResults myContextSubscriptionResults
Definition: TrafficLight.h:94
libsumo::TraCIException
Definition: TraCIDefs.h:89
libsumo::TrafficLight::getParameter
static std::string getParameter(const std::string &tlsID, const std::string &paramName)
Definition: TrafficLight.cpp:206
libsumo::TrafficLight::makeWrapper
static LIBSUMO_SUBSCRIPTION_API std::shared_ptr< VariableWrapper > makeWrapper()
Definition: TrafficLight.cpp:323
MSPerson.h
MSTrafficLightLogic::getPhase
virtual const MSPhaseDefinition & getPhase(int givenstep) const =0
Returns the definition of the phase from the given position within the plan.
libsumo::TL_CURRENT_PROGRAM
TRACI_CONST int TL_CURRENT_PROGRAM
Definition: TraCIConstants.h:570
MSTrafficLightLogic::getLaneVectors
const LaneVectorVector & getLaneVectors() const
Returns the list of lists of all lanes controlled by this tls.
Definition: MSTrafficLightLogic.h:182
libsumo::TL_CONTROLLED_JUNCTIONS
TRACI_CONST int TL_CONTROLLED_JUNCTIONS
Definition: TraCIConstants.h:573
MSLane::getEdge
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:669
MSNet::getTLSControl
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
Definition: MSNet.h:409
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:47
libsumo::TraCILogic::phases
std::vector< TraCIPhase > phases
Definition: TraCIDefs.h:248
MSTrafficLightLogic::getLinks
const LinkVectorVector & getLinks() const
Returns the list of lists of all affected links.
Definition: MSTrafficLightLogic.h:203
libsumo::TraCIPhase
Definition: TraCIDefs.h:207
MSTLLogicControl::TLSLogicVariants::setStateInstantiatingOnline
void setStateInstantiatingOnline(MSTLLogicControl &tlc, const std::string &state)
Definition: MSTLLogicControl.cpp:155
MSNet::getInstance
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:167
libsumo::TrafficLight::handleVariable
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
Definition: TrafficLight.cpp:329
libsumo::TrafficLight::getServedPersonCount
static int getServedPersonCount(const std::string &tlsID, int index)
Definition: TrafficLight.cpp:166
TLTYPE_DELAYBASED
@ TLTYPE_DELAYBASED
Definition: SUMOXMLDefinitions.h:1202
MSTransportable.h
libsumo::TrafficLight::getPhase
static int getPhase(const std::string &tlsID)
Definition: TrafficLight.cpp:144
libsumo::VariableWrapper::wrapInt
virtual bool wrapInt(const std::string &objID, const int variable, const int value)=0
libsumo::TL_RED_YELLOW_GREEN_STATE
TRACI_CONST int TL_RED_YELLOW_GREEN_STATE
Definition: TraCIConstants.h:549
MSDelayBasedTrafficLightLogic
An actuated traffic light logic based on time delay of approaching vehicles.
Definition: MSDelayBasedTrafficLightLogic.h:46
Parameterised::setParameter
void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
Definition: Parameterised.cpp:46
MSTLLogicControl::TLSLogicVariants
Storage for all programs of a single tls.
Definition: MSTLLogicControl.h:85
MSTrafficLightLogic::LaneVectorVector
std::vector< LaneVector > LaneVectorVector
Definition of a list that holds lists of lanes that do have the same attribute.
Definition: MSTrafficLightLogic.h:73
libsumo::TraCILogic::subParameter
std::map< std::string, std::string > subParameter
Definition: TraCIDefs.h:249
config.h
MSTLLogicControl
A class that stores and controls tls and switching of their programs.
Definition: MSTLLogicControl.h:59
libsumo::TraCIPhase::name
std::string name
Definition: TraCIDefs.h:221
MSLane.h
MSPhaseDefinition
The definition of a single phase of a tls logic.
Definition: MSPhaseDefinition.h:51
MSTrafficLightLogic::init
virtual void init(NLDetectorBuilder &nb)
Initialises the tls with information about incoming lanes.
Definition: MSTrafficLightLogic.cpp:115
MSTrafficLightLogic::LinkVectorVector
std::vector< LinkVector > LinkVectorVector
Definition of a list that holds lists of links that do have the same attribute.
Definition: MSTrafficLightLogic.h:67
Named::getID
const std::string & getID() const
Returns the id.
Definition: Named.h:76
MSTrafficLightLogic::LinkVector
std::vector< MSLink * > LinkVector
Definition of the list of links that are subjected to this tls.
Definition: MSTrafficLightLogic.h:64
NLDetectorBuilder
Builds detectors for microsim.
Definition: NLDetectorBuilder.h:55
libsumo::SubscriptionResults
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
Definition: TraCIDefs.h:203
libsumo::TrafficLight::getNextSwitch
static double getNextSwitch(const std::string &tlsID)
Definition: TrafficLight.cpp:161
libsumo::TrafficLight::getCompleteRedYellowGreenDefinition
static std::vector< TraCILogic > getCompleteRedYellowGreenDefinition(const std::string &tlsID)
Definition: TrafficLight.cpp:70
MSTrafficLightLogic::getCurrentPhaseDef
virtual const MSPhaseDefinition & getCurrentPhaseDef() const =0
Returns the definition of the current phase.
TLTYPE_ACTUATED
@ TLTYPE_ACTUATED
Definition: SUMOXMLDefinitions.h:1201
libsumo::TrafficLight::getPhaseName
static std::string getPhaseName(const std::string &tlsID)
Definition: TrafficLight.cpp:150
MSPhaseDefinition::getName
const std::string & getName() const
Definition: MSPhaseDefinition.h:215