Eclipse SUMO - Simulation of Urban MObility
MSTLLogicControl.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-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 /****************************************************************************/
20 // A class that stores and controls tls and switching of their programs
21 /****************************************************************************/
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <vector>
28 #include <algorithm>
29 #include <cassert>
30 #include <iterator>
31 #include "MSTrafficLightLogic.h"
33 #include "MSTLLogicControl.h"
34 #include "MSOffTrafficLightLogic.h"
36 #include <microsim/MSNet.h>
38 #include <utils/common/ToString.h>
40 
41 
42 // ===========================================================================
43 // method definitions
44 // ===========================================================================
45 /* -------------------------------------------------------------------------
46  * MSTLLogicControl::TLSLogicVariants - methods
47  * ----------------------------------------------------------------------- */
49  : myCurrentProgram(nullptr) {
50 }
51 
52 
54  std::map<std::string, MSTrafficLightLogic*>::const_iterator j;
55  for (std::map<std::string, MSTrafficLightLogic*>::iterator j = myVariants.begin(); j != myVariants.end(); ++j) {
56  delete (*j).second;
57  }
58  for (std::vector<OnSwitchAction*>::iterator i = mySwitchActions.begin(); i != mySwitchActions.end(); ++i) {
59  delete *i;
60  }
61 }
62 
63 
64 bool
66  bool hadErrors = false;
67  for (std::map<std::string, MSTrafficLightLogic*>::const_iterator j = myVariants.begin(); j != myVariants.end(); ++j) {
68  const MSTrafficLightLogic::Phases& phases = (*j).second->getPhases();
69  int linkNo = (int)(*j).second->getLinks().size();
70  bool hadProgramErrors = false;
71  for (MSTrafficLightLogic::Phases::const_iterator i = phases.begin(); i != phases.end(); ++i) {
72  if ((int)(*i)->getState().length() < linkNo) {
73  hadProgramErrors = true;
74  }
75  }
76  if (hadProgramErrors) {
77  WRITE_ERROR("Mismatching phase size in tls '" + (*j).second->getID() + "', program '" + (*j).first + "'.");
78  hadErrors = true;
79  }
80  }
81  return !hadErrors;
82 }
83 
84 
85 void
87  myOriginalLinkStates = myCurrentProgram->collectLinkStates();
88 }
89 
90 
91 bool
92 MSTLLogicControl::TLSLogicVariants::addLogic(const std::string& programID,
93  MSTrafficLightLogic* logic, bool netWasLoaded, bool isNewDefault) {
94  if (myVariants.find(programID) != myVariants.end()) {
95  return false;
96  }
97  // assert the links are set
98  if (netWasLoaded) {
99  // this one has not yet its links set
100  if (myCurrentProgram == nullptr) {
101  throw ProcessError("No initial signal plan loaded for tls '" + logic->getID() + "'.");
102  }
103  logic->adaptLinkInformationFrom(*myCurrentProgram);
104  if (logic->getLinks().size() > logic->getPhase(0).getState().size()) {
105  throw ProcessError("Mismatching phase size in tls '" + logic->getID() + "', program '" + programID + "'.");
106  }
107  }
108  // add to the list of active
109  if (myVariants.size() == 0 || isNewDefault) {
110  if (myCurrentProgram != nullptr) {
111  myCurrentProgram->deactivateProgram();
112  }
113  myCurrentProgram = logic;
114  myCurrentProgram->activateProgram();
115  }
116  // add to the list of logic
117  myVariants[programID] = logic;
118  if (myVariants.size() == 1 || isNewDefault) {
119  logic->setTrafficLightSignals(MSNet::getInstance()->getCurrentTimeStep());
120  executeOnSwitchActions();
121  }
122  return true;
123 }
124 
125 
127 MSTLLogicControl::TLSLogicVariants::getLogic(const std::string& programID) const {
128  if (myVariants.find(programID) == myVariants.end()) {
129  return nullptr;
130  }
131  return myVariants.find(programID)->second;
132 }
133 
134 
137  const std::string& programID) {
138  if (myVariants.find(programID) == myVariants.end()) {
139  if (programID == "off") {
140  // build an off-tll if this switch indicates it
141  if (!addLogic("off", new MSOffTrafficLightLogic(tlc, myCurrentProgram->getID()), true, true)) {
142  // inform the user if this fails
143  throw ProcessError("Could not build an off-state for tls '" + myCurrentProgram->getID() + "'.");
144  }
145  } else {
146  // inform the user about a missing logic
147  throw ProcessError("Can not switch tls '" + myCurrentProgram->getID() + "' to program '" + programID + "';\n The program is not known.");
148  }
149  }
150  return getLogic(programID);
151 }
152 
153 
154 void
156  const std::string& state) {
157  // build only once...
158  MSTrafficLightLogic* logic = getLogic("online");
159  if (logic == nullptr) {
160  MSPhaseDefinition* phase = new MSPhaseDefinition(DELTA_T, state, -1);
161  std::vector<MSPhaseDefinition*> phases;
162  phases.push_back(phase);
163  logic = new MSSimpleTrafficLightLogic(tlc, myCurrentProgram->getID(), "online", TLTYPE_STATIC, phases, 0,
165  std::map<std::string, std::string>());
166  addLogic("online", logic, true, true);
168  } else {
169  MSPhaseDefinition nphase(DELTA_T, state, -1);
170  *(dynamic_cast<MSSimpleTrafficLightLogic*>(logic)->getPhases()[0]) = nphase;
171  switchTo(tlc, "online");
172  }
173 }
174 
175 
176 void
178  mySwitchActions.push_back(c);
179 }
180 
181 
182 std::vector<MSTrafficLightLogic*>
184  std::vector<MSTrafficLightLogic*> ret;
185  std::map<std::string, MSTrafficLightLogic*>::const_iterator i;
186  for (i = myVariants.begin(); i != myVariants.end(); ++i) {
187  ret.push_back((*i).second);
188  }
189  return ret;
190 }
191 
192 
193 bool
195  return tl == myCurrentProgram;
196 }
197 
198 
201  return myCurrentProgram;
202 }
203 
204 
205 void
207  // set the found wished sub-program as this tls' current one
208  myCurrentProgram->deactivateProgram();
209  myCurrentProgram = getLogicInstantiatingOff(tlc, programID);
210  myCurrentProgram->activateProgram();
211  myCurrentProgram->setTrafficLightSignals(MSNet::getInstance()->getCurrentTimeStep());
212  executeOnSwitchActions();
213 }
214 
215 
216 void
218  for (std::vector<OnSwitchAction*>::const_iterator i = mySwitchActions.begin(); i != mySwitchActions.end(); ++i) {
219  (*i)->execute();
220  }
221 }
222 
223 
224 void
226  for (std::map<std::string, MSTrafficLightLogic*>::iterator i = myVariants.begin(); i != myVariants.end(); ++i) {
227  (*i).second->addLink(link, lane, pos);
228  }
229 }
230 
231 void
233  for (std::map<std::string, MSTrafficLightLogic*>::iterator i = myVariants.begin(); i != myVariants.end(); ++i) {
234  (*i).second->ignoreLinkIndex(pos);
235  }
236 }
237 
238 
239 /* -------------------------------------------------------------------------
240  * method definitions for the Switching Procedures
241  * ----------------------------------------------------------------------- */
242 /* -------------------------------------------------------------------------
243  * method definitions for WAUTSwitchProcedure
244  * ----------------------------------------------------------------------- */
245 int
247  std::string val = logic.getParameter("GSP", "");
248  if (val.length() == 0) {
249  return 0;
250  }
251  return StringUtils::toInt(val);
252 }
253 
254 
255 bool
257  SUMOTime gspTime = TIME2STEPS(getGSPValue(logic)) % logic.getDefaultCycleTime();
258  SUMOTime programTime = logic.getOffsetFromIndex(logic.getCurrentPhaseIndex())
259  + (logic.getCurrentPhaseDef().duration - (logic.getNextSwitchTime() - currentTime));
260  return gspTime == programTime;
261 }
262 
263 
264 SUMOTime
266  int stepOfMyPos = logic.getIndexFromOffset(toTime);
267  SUMOTime startOfPhase = logic.getOffsetFromIndex(stepOfMyPos);
268  assert(toTime >= startOfPhase);
269  return toTime - startOfPhase;
270 }
271 
272 
273 void
275  int stepTo = logic.getIndexFromOffset(toTime);
276  SUMOTime diff = getDiffToStartOfPhase(logic, toTime);
277  const MSPhaseDefinition& phase = logic.getPhase(stepTo);
278  SUMOTime leftDuration = phase.duration - diff;
279  logic.changeStepAndDuration(myControl, simStep, stepTo, leftDuration);
280 }
281 
282 
283 
284 /* -------------------------------------------------------------------------
285  * method definitions for WAUTSwitchProcedure_JustSwitch
286  * ----------------------------------------------------------------------- */
288  MSTLLogicControl& control, WAUT& waut,
289  MSTrafficLightLogic* from, MSTrafficLightLogic* to, bool synchron)
290  : MSTLLogicControl::WAUTSwitchProcedure(control, waut, from, to, synchron) {}
291 
292 
294 
295 
296 bool
298  return true;
299 }
300 
301 
302 
303 /* -------------------------------------------------------------------------
304  * method definitions for WAUTSwitchProcedure_GSP
305  * ----------------------------------------------------------------------- */
307  MSTLLogicControl& control, WAUT& waut,
308  MSTrafficLightLogic* from, MSTrafficLightLogic* to, bool synchron)
309  : MSTLLogicControl::WAUTSwitchProcedure(control, waut, from, to, synchron) {}
310 
311 
313 
314 
315 bool
317  // switch to the next programm if the GSP is reached
318  if (isPosAtGSP(step, *myFrom)) {
319  // adapt program's state
320  if (mySwitchSynchron) {
321  adaptLogic(step);
322  } else {
323  switchToPos(step, *myTo, TIME2STEPS(getGSPValue(*myTo)));
324  }
325  // switch to destination program
326  return true;
327  }
328  // do not switch, yet
329  return false;
330 }
331 
332 
333 void
335  SUMOTime gspTo = TIME2STEPS(getGSPValue(*myTo));
336  int stepTo = myTo->getIndexFromOffset(gspTo);
337  SUMOTime cycleTimeTo = myTo->getDefaultCycleTime();
338  if (gspTo == cycleTimeTo) {
339  gspTo = 0;
340  }
341 
342  SUMOTime currentPosTo = myTo->getOffsetFromIndex(myTo->getCurrentPhaseIndex());
343  currentPosTo += (myTo->getCurrentPhaseDef().duration - (myTo->getNextSwitchTime() - step));
344  SUMOTime diff = getDiffToStartOfPhase(*myTo, gspTo);
345 
346  SUMOTime deltaToStretch = 0;
347  if (gspTo >= currentPosTo) {
348  deltaToStretch = (gspTo - currentPosTo);
349  } else {
350  deltaToStretch = (cycleTimeTo - currentPosTo + gspTo);
351  }
352  const SUMOTime newdur = myTo->getPhase(stepTo).duration - diff + deltaToStretch;
353  myTo->changeStepAndDuration(myControl, step, stepTo, newdur);
354 }
355 
356 
357 
358 /* -------------------------------------------------------------------------
359  * method definitions for WAUTSwitchProcedure_Stretch
360  * ----------------------------------------------------------------------- */
362  MSTLLogicControl& control, WAUT& waut,
363  MSTrafficLightLogic* from, MSTrafficLightLogic* to, bool synchron)
364  : MSTLLogicControl::WAUTSwitchProcedure(control, waut, from, to, synchron) {}
365 
366 
368 
369 
370 bool
372  // switch to the next programm if the GSP is reached
373  if (isPosAtGSP(step, *myFrom)) {
374  // adapt program's state
375  if (mySwitchSynchron) {
376  adaptLogic(step);
377  } else {
378  switchToPos(step, *myTo, TIME2STEPS(getGSPValue(*myTo)));
379  }
380  // switch to destination program
381  return true;
382  }
383  // do not switch, yet
384  return false;
385 }
386 
387 
388 void
390  SUMOTime gspTo = TIME2STEPS(getGSPValue(*myTo));
391  SUMOTime cycleTime = myTo->getDefaultCycleTime();
392  // the position, where the logic has to be after synchronisation
393  SUMOTime posAfterSyn = myTo->getPhaseIndexAtTime(step);
394  // calculate the difference, that has to be equalized
395  SUMOTime deltaToCut = 0;
396  if (posAfterSyn < gspTo) {
397  deltaToCut = posAfterSyn + cycleTime - gspTo;
398  } else {
399  deltaToCut = posAfterSyn - gspTo;
400  }
401  // test, wheter cutting of the Signalplan is possible
402  SUMOTime deltaPossible = 0;
403  int areasNo = getStretchAreaNo(myTo);
404  for (int i = 0; i < areasNo; i++) {
405  StretchBereichDef def = getStretchBereichDef(myTo, i + 1);
406  assert(def.end >= def.begin);
407  deltaPossible += TIME2STEPS(def.end - def.begin);
408  }
409  int stretchUmlaufAnz = (int) StringUtils::toDouble(myTo->getParameter("StretchUmlaufAnz", ""));
410  deltaPossible = stretchUmlaufAnz * deltaPossible;
411  if ((deltaPossible > deltaToCut) && (deltaToCut < (cycleTime / 2))) {
412  cutLogic(step, gspTo, deltaToCut);
413  } else {
414  SUMOTime deltaToStretch = (cycleTime - deltaToCut) % cycleTime;
415  stretchLogic(step, gspTo, deltaToStretch);
416  }
417 }
418 
419 
420 void
422  int actStep = myTo->getIndexFromOffset(startPos);
423  // switches to startPos and cuts this phase, if there is a "Bereich"
424  int areasNo = getStretchAreaNo(myTo);
425  SUMOTime toCut = 0;
426  for (int i = 0; i < areasNo; i++) {
427  StretchBereichDef def = getStretchBereichDef(myTo, i + 1);
428  const SUMOTime begin = TIME2STEPS(def.begin);
429  const SUMOTime end = TIME2STEPS(def.end);
430  int stepOfBegin = myTo->getIndexFromOffset(begin);
431  if (stepOfBegin == actStep) {
432  if (begin < startPos) {
433  toCut = end - startPos;
434  } else {
435  toCut = end - begin;
436  }
437  toCut = MIN2(allCutTime, toCut);
438  allCutTime = allCutTime - toCut;
439  }
440  }
441  SUMOTime remainingDur = myTo->getPhase(actStep).duration - getDiffToStartOfPhase(*myTo, startPos);
442  SUMOTime newDur = remainingDur - toCut;
443  myTo->changeStepAndDuration(myControl, step, actStep, newDur);
444 
445  // changes the duration of all other phases
446  int currStep = (actStep + 1) % (int)myTo->getPhases().size();
447  while (allCutTime > 0) {
448  for (int i = currStep; i < (int) myTo->getPhases().size(); i++) {
449  SUMOTime beginOfPhase = myTo->getOffsetFromIndex(i);
450  SUMOTime durOfPhase = myTo->getPhase(i).duration;
451  SUMOTime endOfPhase = beginOfPhase + durOfPhase;
452  for (int i = 0; i < areasNo; i++) {
453  StretchBereichDef def = getStretchBereichDef(myTo, i + 1);
454  SUMOTime begin = TIME2STEPS(def.begin);
455  SUMOTime end = TIME2STEPS(def.end);
456  if ((beginOfPhase <= begin) && (endOfPhase >= end)) {
457  SUMOTime maxCutOfPhase = MIN2(end - begin, allCutTime);
458  allCutTime = allCutTime - maxCutOfPhase;
459  durOfPhase = durOfPhase - maxCutOfPhase;
460  }
461  }
462  myTo->addOverridingDuration(durOfPhase);
463  }
464  currStep = 0;
465  }
466 }
467 
468 void
470  int currStep = myTo->getIndexFromOffset(startPos);
471  SUMOTime durOfPhase = myTo->getPhase(currStep).duration;
472  SUMOTime remainingStretchTime = allStretchTime;
473  SUMOTime StretchTimeOfPhase = 0;
474  int stretchUmlaufAnz = (int) StringUtils::toDouble(myTo->getParameter("StretchUmlaufAnz", ""));
475  double facSum = 0;
476  int areasNo = getStretchAreaNo(myTo);
477  for (int x = 0; x < areasNo; x++) {
478  StretchBereichDef def = getStretchBereichDef(myTo, x + 1);
479  facSum += def.fac;
480  }
481  facSum *= stretchUmlaufAnz;
482 
483  //switch to startPos and stretch this phase, if there is a end of "bereich" between startpos and end of phase
484  SUMOTime diffToStart = getDiffToStartOfPhase(*myTo, startPos);
485  for (int x = 0; x < areasNo; x++) {
486  StretchBereichDef def = getStretchBereichDef(myTo, x + 1);
487  SUMOTime end = TIME2STEPS(def.end);
488  SUMOTime endOfPhase = (startPos + durOfPhase - diffToStart);
489  if (end <= endOfPhase && end >= startPos) {
490  double fac = def.fac;
491  double actualfac = fac / facSum;
492  facSum = facSum - fac;
493  StretchTimeOfPhase = TIME2STEPS(int(STEPS2TIME(remainingStretchTime) * actualfac + 0.5));
494  remainingStretchTime = allStretchTime - StretchTimeOfPhase;
495  }
496  }
497  if (facSum == 0) {
498  WRITE_WARNING("The computed factor sum in WAUT '" + myWAUT.id + "' at time '" + toString(STEPS2TIME(step)) + "' equals zero;\n assuming an error in WAUT definition.");
499  return;
500  }
501  durOfPhase = durOfPhase - diffToStart + StretchTimeOfPhase;
502  myTo->changeStepAndDuration(myControl, step, currStep, durOfPhase);
503 
504  currStep = (currStep + 1) % (int)myTo->getPhases().size();
505  // stretch all other phases, if there is a "bereich"
506  while (remainingStretchTime > 0) {
507  for (int i = currStep; i < (int)myTo->getPhases().size() && remainingStretchTime > 0; i++) {
508  durOfPhase = myTo->getPhase(i).duration;
509  SUMOTime beginOfPhase = myTo->getOffsetFromIndex(i);
510  SUMOTime endOfPhase = beginOfPhase + durOfPhase;
511  for (int j = 0; j < areasNo && remainingStretchTime > 0; j++) {
512  StretchBereichDef def = getStretchBereichDef(myTo, j + 1);
513  SUMOTime end = TIME2STEPS(def.end);
514  double fac = def.fac;
515  if ((beginOfPhase <= end) && (endOfPhase >= end)) {
516  double actualfac = fac / facSum;
517  StretchTimeOfPhase = TIME2STEPS(int(STEPS2TIME(remainingStretchTime) * actualfac + 0.5));
518  facSum -= fac;
519  durOfPhase += StretchTimeOfPhase;
520  remainingStretchTime -= StretchTimeOfPhase;
521  }
522  }
523  myTo->addOverridingDuration(durOfPhase);
524  }
525  currStep = 0;
526  }
527 }
528 
529 int
531  int no = 0;
532  while (from->getParameter("B" + toString(no + 1) + ".begin", "") != "") {
533  no++;
534  }
535  return no;
536 }
537 
538 
541  StretchBereichDef def;
542  def.begin = StringUtils::toDouble(from->getParameter("B" + toString(index) + ".begin", ""));
543  def.end = StringUtils::toDouble(from->getParameter("B" + toString(index) + ".end", ""));
544  def.fac = StringUtils::toDouble(from->getParameter("B" + toString(index) + ".factor", ""));
545  return def;
546 }
547 
548 
549 
550 /* -------------------------------------------------------------------------
551  * method definitions for MSTLLogicControl
552  * ----------------------------------------------------------------------- */
554  : myNetWasLoaded(false) {}
555 
556 
558  // delete tls
559  for (std::map<std::string, TLSLogicVariants*>::const_iterator i = myLogics.begin(); i != myLogics.end(); ++i) {
560  delete (*i).second;
561  }
562  // delete WAUTs
563  for (std::map<std::string, WAUT*>::const_iterator i = myWAUTs.begin(); i != myWAUTs.end(); ++i) {
564  delete (*i).second;
565  }
566 }
567 
568 
569 void
571  for (std::map<std::string, TLSLogicVariants*>::const_iterator i = myLogics.begin(); i != myLogics.end(); ++i) {
572  (*i).second->getActive()->setTrafficLightSignals(t);
573  }
574 }
575 
576 
577 std::vector<MSTrafficLightLogic*>
579  std::vector<MSTrafficLightLogic*> ret;
580  std::map<std::string, TLSLogicVariants*>::const_iterator i;
581  for (i = myLogics.begin(); i != myLogics.end(); ++i) {
582  std::vector<MSTrafficLightLogic*> s = (*i).second->getAllLogics();
583  copy(s.begin(), s.end(), back_inserter(ret));
584  }
585  return ret;
586 }
587 
589 MSTLLogicControl::get(const std::string& id) const {
590  std::map<std::string, TLSLogicVariants*>::const_iterator i = myLogics.find(id);
591  if (i == myLogics.end()) {
592  throw InvalidArgument("The tls '" + id + "' is not known.");
593  }
594  return *(*i).second;
595 }
596 
597 
599 MSTLLogicControl::get(const std::string& id, const std::string& programID) const {
600  std::map<std::string, TLSLogicVariants*>::const_iterator i = myLogics.find(id);
601  if (i == myLogics.end()) {
602  return nullptr;
603  }
604  return (*i).second->getLogic(programID);
605 }
606 
607 
608 std::vector<std::string>
610  std::vector<std::string> ret;
611  for (std::map<std::string, TLSLogicVariants*>::const_iterator i = myLogics.begin(); i != myLogics.end(); ++i) {
612  ret.push_back((*i).first);
613  }
614  return ret;
615 }
616 
617 
618 bool
619 MSTLLogicControl::add(const std::string& id, const std::string& programID,
620  MSTrafficLightLogic* logic, bool newDefault) {
621  if (myLogics.find(id) == myLogics.end()) {
622  myLogics[id] = new TLSLogicVariants();
623  }
624  std::map<std::string, TLSLogicVariants*>::iterator i = myLogics.find(id);
625  TLSLogicVariants* tlmap = (*i).second;
626  return tlmap->addLogic(programID, logic, myNetWasLoaded, newDefault);
627 }
628 
629 
630 bool
631 MSTLLogicControl::knows(const std::string& id) const {
632  std::map<std::string, TLSLogicVariants*>::const_iterator i = myLogics.find(id);
633  if (i == myLogics.end()) {
634  return false;
635  }
636  return true;
637 }
638 
639 
640 bool
642  bool hadErrors = false;
643  for (std::map<std::string, TLSLogicVariants*>::iterator i = myLogics.begin(); i != myLogics.end(); ++i) {
644  hadErrors |= !(*i).second->checkOriginalTLS();
645  (*i).second->saveInitialStates();
646  }
647  myNetWasLoaded = true;
648  return !hadErrors;
649 }
650 
651 
652 bool
654  std::map<std::string, TLSLogicVariants*>::const_iterator i = myLogics.find(tl->getID());
655  if (i == myLogics.end()) {
656  return false;
657  }
658  return (*i).second->isActive(tl);
659 }
660 
661 
663 MSTLLogicControl::getActive(const std::string& id) const {
664  std::map<std::string, TLSLogicVariants*>::const_iterator i = myLogics.find(id);
665  if (i == myLogics.end()) {
666  return nullptr;
667  }
668  return (*i).second->getActive();
669 }
670 
671 
672 void
673 MSTLLogicControl::switchTo(const std::string& id, const std::string& programID) {
674  // try to get the tls program definitions
675  std::map<std::string, TLSLogicVariants*>::iterator i = myLogics.find(id);
676  // handle problems
677  if (i == myLogics.end()) {
678  throw ProcessError("Could not switch tls '" + id + "' to program '" + programID + "': No such tls exists.");
679  }
680  (*i).second->switchTo(*this, programID);
681 }
682 
683 
684 void
685 MSTLLogicControl::addWAUT(SUMOTime refTime, const std::string& id,
686  const std::string& startProg) {
687  // check whether the waut was already defined
688  if (myWAUTs.find(id) != myWAUTs.end()) {
689  // report an error if so
690  throw InvalidArgument("Waut '" + id + "' was already defined.");
691  }
692  WAUT* w = new WAUT;
693  w->id = id;
694  w->refTime = refTime;
695  w->startProg = startProg;
696  myWAUTs[id] = w;
697 }
698 
699 
700 void
701 MSTLLogicControl::addWAUTSwitch(const std::string& wautid,
702  SUMOTime when, const std::string& to) {
703  // try to get the waut
704  if (myWAUTs.find(wautid) == myWAUTs.end()) {
705  // report an error if the waut is not known
706  throw InvalidArgument("Waut '" + wautid + "' was not yet defined.");
707  }
708  // build and save the waut switch definition
709  WAUTSwitch s;
710  s.to = to;
711  s.when = (myWAUTs[wautid]->refTime + when) % 86400000;
712  myWAUTs[wautid]->switches.push_back(s);
713 }
714 
715 
716 void
717 MSTLLogicControl::addWAUTJunction(const std::string& wautid,
718  const std::string& tls,
719  const std::string& proc,
720  bool synchron) {
721  // try to get the waut
722  if (myWAUTs.find(wautid) == myWAUTs.end()) {
723  // report an error if the waut is not known
724  throw InvalidArgument("Waut '" + wautid + "' was not yet defined.");
725  }
726  // try to get the tls to switch
727  if (myLogics.find(tls) == myLogics.end()) {
728  // report an error if the tls is not known
729  throw InvalidArgument("TLS '" + tls + "' to switch in WAUT '" + wautid + "' was not yet defined.");
730  }
731  WAUTJunction j;
732  j.junction = tls;
733  j.procedure = proc;
734  j.synchron = synchron;
735  myWAUTs[wautid]->junctions.push_back(j);
736 
737  std::string initProg = myWAUTs[wautid]->startProg;
738  std::vector<WAUTSwitch>::const_iterator first = myWAUTs[wautid]->switches.end();
739  SUMOTime minExecTime = -1;
740  for (std::vector<WAUTSwitch>::const_iterator i = myWAUTs[wautid]->switches.begin(); i != myWAUTs[wautid]->switches.end(); ++i) {
741  if ((*i).when > MSNet::getInstance()->getCurrentTimeStep() && (minExecTime == -1 || (*i).when < minExecTime)) {
742  minExecTime = (*i).when;
743  first = i;
744  }
745  if (first != myWAUTs[wautid]->switches.begin()) {
746  initProg = (*(first - 1)).to;
747  }
748  }
749  // activate the first one
750  switchTo(tls, initProg);
751 }
752 
753 
754 void
755 MSTLLogicControl::closeWAUT(const std::string& wautid) {
756  // try to get the waut
757  if (myWAUTs.find(wautid) == myWAUTs.end()) {
758  // report an error if the waut is not known
759  throw InvalidArgument("Waut '" + wautid + "' was not yet defined.");
760  }
761  WAUT* w = myWAUTs.find(wautid)->second;
762  std::string initProg = myWAUTs[wautid]->startProg;
763  // get the switch to be performed as first
764  std::vector<WAUTSwitch>::const_iterator first = w->switches.end();
765  SUMOTime minExecTime = -1;
766  for (std::vector<WAUTSwitch>::const_iterator i = w->switches.begin(); i != w->switches.end(); ++i) {
767  if ((*i).when > MSNet::getInstance()->getCurrentTimeStep() && (minExecTime == -1 || (*i).when < minExecTime)) {
768  minExecTime = (*i).when;
769  first = i;
770  }
771  }
772  // activate the first one
773  if (first != w->switches.end()) {
774  std::vector<WAUTSwitch>::const_iterator mbegin = w->switches.begin();
776  new SwitchInitCommand(*this, wautid, (int)distance(mbegin, first)),
777  (*first).when);
778  }
779  /*
780  // set the current program to all junctions
781  for(std::vector<WAUTJunction>::const_iterator i=w->junctions.begin(); i!=w->junctions.end(); ++i) {
782  switchTo((*i).junction, initProg);
783  }
784  */
785 }
786 
787 
788 SUMOTime
790  const std::string& wautid = cmd.getWAUTID();
791  int& index = cmd.getIndex();
792  WAUTSwitch s = myWAUTs[wautid]->switches[index];
793  for (std::vector<WAUTJunction>::iterator i = myWAUTs[wautid]->junctions.begin(); i != myWAUTs[wautid]->junctions.end(); ++i) {
794  // get the current program and the one to instantiate
795  TLSLogicVariants* vars = myLogics.find((*i).junction)->second;
796  MSTrafficLightLogic* from = vars->getActive();
797  MSTrafficLightLogic* to = vars->getLogicInstantiatingOff(*this, s.to);
798  WAUTSwitchProcedure* proc = nullptr;
799  if ((*i).procedure == "GSP") {
800  proc = new WAUTSwitchProcedure_GSP(*this, *myWAUTs[wautid], from, to, (*i).synchron);
801  } else if ((*i).procedure == "Stretch") {
802  proc = new WAUTSwitchProcedure_Stretch(*this, *myWAUTs[wautid], from, to, (*i).synchron);
803  } else {
804  proc = new WAUTSwitchProcedure_JustSwitch(*this, *myWAUTs[wautid], from, to, (*i).synchron);
805  }
806 
808  p.junction = (*i).junction;
809  p.proc = proc;
810  p.from = from;
811  p.to = to;
812 
813  myCurrentlySwitched.push_back(p);
814  }
815  index++;
816  if (index == static_cast<int>(myWAUTs[wautid]->switches.size())) {
817  return 0;
818  }
819  return myWAUTs[wautid]->switches[index].when - MSNet::getInstance()->getCurrentTimeStep();
820 }
821 
822 
823 void
825  for (std::vector<WAUTSwitchProcess>::iterator i = myCurrentlySwitched.begin(); i != myCurrentlySwitched.end();) {
826  const WAUTSwitchProcess& proc = *i;
827  if (proc.proc->trySwitch(step)) {
828  delete proc.proc;
829  switchTo((*i).to->getID(), (*i).to->getProgramID());
830  i = myCurrentlySwitched.erase(i);
831  } else {
832  ++i;
833  }
834  }
835 }
836 
837 
838 std::pair<SUMOTime, MSPhaseDefinition>
839 MSTLLogicControl::getPhaseDef(const std::string& tlid) const {
840  MSTrafficLightLogic* tl = getActive(tlid);
841  return std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), tl->getCurrentPhaseDef());
842 }
843 
844 
845 void
847  for (std::map<std::string, TLSLogicVariants*>::const_iterator i = myLogics.begin(); i != myLogics.end(); ++i) {
848  (*i).second->addLogic("off", new MSOffTrafficLightLogic(*this, (*i).first), true, true);
849  }
850 }
851 
852 /****************************************************************************/
853 
MSTLLogicControl::getPhaseDef
std::pair< SUMOTime, MSPhaseDefinition > getPhaseDef(const std::string &tlid) const
return the complete phase definition for a named traffic lights logic
Definition: MSTLLogicControl.cpp:839
MSTLLogicControl::addWAUTSwitch
void addWAUTSwitch(const std::string &wautid, SUMOTime when, const std::string &to)
Adds a WAUT switch step to a previously built WAUT.
Definition: MSTLLogicControl.cpp:701
MSTrafficLightLogic::activateProgram
virtual void activateProgram()
called when switching programs
Definition: MSTrafficLightLogic.cpp:378
MSNet::createTLWrapper
virtual void createTLWrapper(MSTrafficLightLogic *)
creates a wrapper for the given logic (see GUINet)
Definition: MSNet.h:524
MSTLLogicControl::WAUTSwitchProcedure_GSP::trySwitch
bool trySwitch(SUMOTime step)
Determines whether a switch is possible.
Definition: MSTLLogicControl.cpp:316
MSTLLogicControl::myCurrentlySwitched
std::vector< WAUTSwitchProcess > myCurrentlySwitched
A list of currently running switching procedures.
Definition: MSTLLogicControl.h:809
MSTrafficLightLogic::setTrafficLightSignals
bool setTrafficLightSignals(SUMOTime t) const
Applies the current signal states to controlled links.
Definition: MSTrafficLightLogic.cpp:235
ToString.h
MSTLLogicControl::WAUTSwitchProcedure::getDiffToStartOfPhase
SUMOTime getDiffToStartOfPhase(MSTrafficLightLogic &logic, SUMOTime toTime)
Returns the difference between a given time and the start of the phase.
Definition: MSTLLogicControl.cpp:265
MSTLLogicControl::WAUTSwitchProcedure_Stretch::stretchLogic
void stretchLogic(SUMOTime step, SUMOTime startPos, SUMOTime allStretchTime)
Stretches the logic to synchronize.
Definition: MSTLLogicControl.cpp:469
MSTLLogicControl::WAUTSwitchProcess::junction
std::string junction
The id of the junction to switch.
Definition: MSTLLogicControl.h:795
MIN2
T MIN2(T a, T b)
Definition: StdDefs.h:73
MSTLLogicControl::TLSLogicVariants::addLogic
bool addLogic(const std::string &programID, MSTrafficLightLogic *logic, bool netWasLoaded, bool isNewDefault=true)
Adds a logic (program)
Definition: MSTLLogicControl.cpp:92
MSEventControl::addEvent
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
Definition: MSEventControl.cpp:52
WRITE_WARNING
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:275
MSTLLogicControl::isActive
bool isActive(const MSTrafficLightLogic *tl) const
Returns whether the given tls program is the currently active for his tls.
Definition: MSTLLogicControl.cpp:653
MSTLLogicControl.h
MSNet.h
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
MSTLLogicControl::WAUTJunction
Storage for a junction assigned to a WAUT.
Definition: MSTLLogicControl.h:486
MSTLLogicControl::TLSLogicVariants::~TLSLogicVariants
~TLSLogicVariants()
Destructor.
Definition: MSTLLogicControl.cpp:53
MSTLLogicControl::WAUTSwitchProcedure_GSP::WAUTSwitchProcedure_GSP
WAUTSwitchProcedure_GSP(MSTLLogicControl &control, WAUT &waut, MSTrafficLightLogic *from, MSTrafficLightLogic *to, bool synchron)
Constructor.
Definition: MSTLLogicControl.cpp:306
DELTA_T
SUMOTime DELTA_T
Definition: SUMOTime.cpp:36
MSTLLogicControl::WAUTSwitchProcedure_Stretch::adaptLogic
void adaptLogic(SUMOTime step)
Determines the destination program's changes and applies them.
Definition: MSTLLogicControl.cpp:389
MSTLLogicControl::TLSLogicVariants::checkOriginalTLS
bool checkOriginalTLS() const
Verifies traffic lights loaded from the network.
Definition: MSTLLogicControl.cpp:65
MSTLLogicControl::WAUTSwitch::when
SUMOTime when
The time the WAUT shall switch the TLS.
Definition: MSTLLogicControl.h:477
MSTLLogicControl::MSTLLogicControl
MSTLLogicControl()
Constructor.
Definition: MSTLLogicControl.cpp:553
TLTYPE_STATIC
@ TLTYPE_STATIC
Definition: SUMOXMLDefinitions.h:1198
MSTrafficLightLogic::getOffsetFromIndex
virtual SUMOTime getOffsetFromIndex(int index) const =0
Returns the position (start of a phase during a cycle) from of a given step.
StringUtils::toDouble
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
Definition: StringUtils.cpp:345
MSTLLogicControl::getAllTLIds
std::vector< std::string > getAllTLIds() const
Definition: MSTLLogicControl.cpp:609
MSOffTrafficLightLogic.h
MSTrafficLightLogic::Phases
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
Definition: MSTrafficLightLogic.h:61
MSNet::getBeginOfTimestepEvents
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
Definition: MSNet.h:429
MsgHandler.h
MSTLLogicControl::WAUTSwitchProcess::proc
WAUTSwitchProcedure * proc
The used procedure.
Definition: MSTLLogicControl.h:801
MSTLLogicControl::addWAUTJunction
void addWAUTJunction(const std::string &wautid, const std::string &tls, const std::string &proc, bool synchron)
Adds a tls to the list of tls to be switched by the named WAUT.
Definition: MSTLLogicControl.cpp:717
MSTLLogicControl::getAllLogics
std::vector< MSTrafficLightLogic * > getAllLogics() const
Returns a vector which contains all logics.
Definition: MSTLLogicControl.cpp:578
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
MSTLLogicControl::WAUTSwitchProcedure_GSP
This class switches using the GSP algorithm.
Definition: MSTLLogicControl.h:653
MSTrafficLightLogic::getCurrentPhaseIndex
virtual int getCurrentPhaseIndex() const =0
Returns the current index within the program.
MSTLLogicControl::WAUTSwitchProcedure_Stretch::getStretchBereichDef
StretchBereichDef getStretchBereichDef(MSTrafficLightLogic *from, int index) const
Returns the numbered Stretch-area for the given program.
Definition: MSTLLogicControl.cpp:540
MSTLLogicControl::WAUTSwitchProcedure::switchToPos
void switchToPos(SUMOTime simStep, MSTrafficLightLogic &logic, SUMOTime toTime)
switches the given logic directly to the given position
Definition: MSTLLogicControl.cpp:274
MSTLLogicControl::SwitchInitCommand::getIndex
int & getIndex()
Returns a reference to the index.
Definition: MSTLLogicControl.h:434
MSTLLogicControl::WAUTSwitchProcedure_JustSwitch::~WAUTSwitchProcedure_JustSwitch
~WAUTSwitchProcedure_JustSwitch()
Destructor.
Definition: MSTLLogicControl.cpp:293
MSTLLogicControl::myLogics
std::map< std::string, TLSLogicVariants * > myLogics
A map from ids to the corresponding variants.
Definition: MSTLLogicControl.h:812
MSTrafficLightLogic::adaptLinkInformationFrom
virtual void adaptLinkInformationFrom(const MSTrafficLightLogic &logic)
Applies information about controlled links and lanes from the given logic.
Definition: MSTrafficLightLogic.cpp:214
MSTLLogicControl::WAUTSwitch::to
std::string to
The program name the WAUT shall switch the TLS to.
Definition: MSTLLogicControl.h:479
MSTLLogicControl::WAUTSwitchProcedure_Stretch::StretchBereichDef::fac
double fac
The weight factor of a stretch/cut area.
Definition: MSTLLogicControl.h:757
MSTLLogicControl::setTrafficLightSignals
void setTrafficLightSignals(SUMOTime t) const
Lets all running (current) tls programs apply their current signal states to links they control.
Definition: MSTLLogicControl.cpp:570
MSTLLogicControl::add
bool add(const std::string &id, const std::string &programID, MSTrafficLightLogic *logic, bool newDefault=true)
Adds a tls program to the container.
Definition: MSTLLogicControl.cpp:619
MSTLLogicControl::WAUTSwitchProcedure_Stretch::getStretchAreaNo
int getStretchAreaNo(MSTrafficLightLogic *from) const
Returns the number of given Stretch-areas for the given program.
Definition: MSTLLogicControl.cpp:530
MSTLLogicControl::switchOffAll
void switchOffAll()
switch all logic variants to 'off'
Definition: MSTLLogicControl.cpp:846
MSTLLogicControl::knows
bool knows(const std::string &id) const
Returns the information whether the named tls is stored.
Definition: MSTLLogicControl.cpp:631
MSTLLogicControl::TLSLogicVariants::getActive
MSTrafficLightLogic * getActive() const
Definition: MSTLLogicControl.cpp:200
MSSimpleTrafficLightLogic.h
MSTLLogicControl::getActive
MSTrafficLightLogic * getActive(const std::string &id) const
Returns the active program of a named tls.
Definition: MSTLLogicControl.cpp:663
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
MSTLLogicControl::WAUTSwitchProcedure
This is the abstract base class for switching from one tls program to another.
Definition: MSTLLogicControl.h:516
MSTrafficLightLogic.h
MSTLLogicControl::WAUTSwitchProcess::from
MSTrafficLightLogic * from
The current program of the tls.
Definition: MSTLLogicControl.h:797
MSTrafficLightLogic::getIndexFromOffset
virtual int getIndexFromOffset(SUMOTime offset) const =0
Returns the step (the phasenumber) of a given position of the cycle.
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::WAUTSwitchProcedure_Stretch::WAUTSwitchProcedure_Stretch
WAUTSwitchProcedure_Stretch(MSTLLogicControl &control, WAUT &waut, MSTrafficLightLogic *from, MSTrafficLightLogic *to, bool synchron)
Constructor.
Definition: MSTLLogicControl.cpp:361
MSTLLogicControl::get
TLSLogicVariants & get(const std::string &id) const
Returns the variants of a named tls.
Definition: MSTLLogicControl.cpp:589
MSTLLogicControl::WAUTSwitch
Storage for a WAUTs switch point.
Definition: MSTLLogicControl.h:475
MSTLLogicControl::WAUTSwitchProcess
An initialised switch process.
Definition: MSTLLogicControl.h:793
MSTLLogicControl::TLSLogicVariants::addLink
void addLink(MSLink *link, MSLane *lane, int pos)
Definition: MSTLLogicControl.cpp:225
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
MSTLLogicControl::myWAUTs
std::map< std::string, WAUT * > myWAUTs
A map of ids to corresponding WAUTs.
Definition: MSTLLogicControl.h:806
MSNet::getCurrentTimeStep
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:283
STEPS2TIME
#define STEPS2TIME(x)
Definition: SUMOTime.h:56
MSTLLogicControl::myNetWasLoaded
bool myNetWasLoaded
Information whether the net was completely loaded.
Definition: MSTLLogicControl.h:815
MSTLLogicControl::addWAUT
void addWAUT(SUMOTime refTime, const std::string &id, const std::string &startProg)
Adds a WAUT definition.
Definition: MSTLLogicControl.cpp:685
MSTrafficLightLogic::getDefaultCycleTime
SUMOTime getDefaultCycleTime() const
Returns the cycle time (in ms)
Definition: MSTrafficLightLogic.h:270
ProcessError
Definition: UtilExceptions.h:39
MSOffTrafficLightLogic
A traffic lights logic which represents a tls in an off-mode.
Definition: MSOffTrafficLightLogic.h:42
MSSimpleTrafficLightLogic
A fixed traffic light logic.
Definition: MSSimpleTrafficLightLogic.h:54
MSTLLogicControl::WAUTSwitchProcedure_JustSwitch::trySwitch
bool trySwitch(SUMOTime step)
Determines whether a switch is possible.
Definition: MSTLLogicControl.cpp:297
MSTLLogicControl::TLSLogicVariants::switchTo
void switchTo(MSTLLogicControl &tlc, const std::string &programID)
Definition: MSTLLogicControl.cpp:206
MSTrafficLightLogic
The parent class for traffic light logics.
Definition: MSTrafficLightLogic.h:55
MSTLLogicControl::WAUT
A WAUT definition.
Definition: MSTLLogicControl.h:499
MSTLLogicControl::TLSLogicVariants::addSwitchCommand
void addSwitchCommand(OnSwitchAction *c)
Definition: MSTLLogicControl.cpp:177
MSTLLogicControl::TLSLogicVariants::isActive
bool isActive(const MSTrafficLightLogic *tl) const
Definition: MSTLLogicControl.cpp:194
MSTLLogicControl::initWautSwitch
SUMOTime initWautSwitch(SwitchInitCommand &cmd)
Initialises switching a WAUT.
Definition: MSTLLogicControl.cpp:789
MSTLLogicControl::WAUTSwitchProcedure_Stretch
This class switches using the Stretch algorithm.
Definition: MSTLLogicControl.h:697
MSTLLogicControl::TLSLogicVariants::getLogicInstantiatingOff
MSTrafficLightLogic * getLogicInstantiatingOff(MSTLLogicControl &tlc, const std::string &programID)
Definition: MSTLLogicControl.cpp:136
MSTLLogicControl::WAUTSwitchProcedure_Stretch::StretchBereichDef::end
double end
The end of a stretch/cut area (time, in s)
Definition: MSTLLogicControl.h:755
MSTLLogicControl::WAUT::switches
std::vector< WAUTSwitch > switches
The list of switches to be done by the WAUT.
Definition: MSTLLogicControl.h:507
MSTrafficLightLogic::getPhase
virtual const MSPhaseDefinition & getPhase(int givenstep) const =0
Returns the definition of the phase from the given position within the plan.
MSTLLogicControl::WAUT::id
std::string id
The id of the WAUT.
Definition: MSTLLogicControl.h:501
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:47
StringUtils.h
MSTrafficLightLogic::getLinks
const LinkVectorVector & getLinks() const
Returns the list of lists of all affected links.
Definition: MSTrafficLightLogic.h:203
MSTLLogicControl::WAUT::refTime
SUMOTime refTime
The reference time (offset to the switch times)
Definition: MSTLLogicControl.h:505
MSTLLogicControl::switchTo
void switchTo(const std::string &id, const std::string &programID)
Switches the named (id) tls to the named (programID) program.
Definition: MSTLLogicControl.cpp:673
StringUtils::toInt
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...
Definition: StringUtils.cpp:278
MSTLLogicControl::closeWAUT
void closeWAUT(const std::string &wautid)
Closes loading of a WAUT.
Definition: MSTLLogicControl.cpp:755
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
MSTLLogicControl::WAUTSwitchProcedure_JustSwitch::WAUTSwitchProcedure_JustSwitch
WAUTSwitchProcedure_JustSwitch(MSTLLogicControl &control, WAUT &waut, MSTrafficLightLogic *from, MSTrafficLightLogic *to, bool synchron)
Constructor.
Definition: MSTLLogicControl.cpp:287
MSTLLogicControl::WAUTSwitchProcedure::isPosAtGSP
bool isPosAtGSP(SUMOTime currentTime, const MSTrafficLightLogic &logic)
Checks, whether the position of a signal programm is at the GSP ("GuenstigerUmschaltPunkt")
Definition: MSTLLogicControl.cpp:256
MSTLLogicControl::WAUT::startProg
std::string startProg
The name of the start program.
Definition: MSTLLogicControl.h:503
MSTLLogicControl::WAUTSwitchProcedure::getGSPValue
int getGSPValue(const MSTrafficLightLogic &logic) const
Returns the GSP-value.
Definition: MSTLLogicControl.cpp:246
MSTLLogicControl::TLSLogicVariants::ignoreLinkIndex
void ignoreLinkIndex(int pos)
Definition: MSTLLogicControl.cpp:232
InvalidArgument
Definition: UtilExceptions.h:56
MSTLLogicControl::WAUTSwitchProcedure_JustSwitch
This class simply switches to the next program.
Definition: MSTLLogicControl.h:613
MSTLLogicControl::~MSTLLogicControl
~MSTLLogicControl()
Destructor.
Definition: MSTLLogicControl.cpp:557
MSTLLogicControl::WAUTJunction::synchron
bool synchron
Information whether this junction shall be switched synchron.
Definition: MSTLLogicControl.h:492
MSTLLogicControl::WAUTSwitchProcedure_GSP::~WAUTSwitchProcedure_GSP
~WAUTSwitchProcedure_GSP()
Destructor.
Definition: MSTLLogicControl.cpp:312
MSTLLogicControl::WAUTJunction::junction
std::string junction
The junction name.
Definition: MSTLLogicControl.h:488
MSTLLogicControl::TLSLogicVariants
Storage for all programs of a single tls.
Definition: MSTLLogicControl.h:85
MSTLLogicControl::SwitchInitCommand
This event-class is used to initialise a WAUT switch at a certain time.
Definition: MSTLLogicControl.h:383
MSTLLogicControl::WAUTSwitchProcess::to
MSTrafficLightLogic * to
The program to switch the tls to.
Definition: MSTLLogicControl.h:799
config.h
MSTLLogicControl::WAUTSwitchProcedure::trySwitch
virtual bool trySwitch(SUMOTime step)=0
Determines whether a switch is possible.
MSTLLogicControl::WAUTSwitchProcedure_Stretch::cutLogic
void cutLogic(SUMOTime step, SUMOTime startPos, SUMOTime allCutTime)
Cuts the logic to synchronize.
Definition: MSTLLogicControl.cpp:421
MSTLLogicControl::WAUTSwitchProcedure_GSP::adaptLogic
void adaptLogic(SUMOTime step)
Stretches the destination program's phase to which the tls was switched.
Definition: MSTLLogicControl.cpp:334
MSTLLogicControl
A class that stores and controls tls and switching of their programs.
Definition: MSTLLogicControl.h:59
MSTLLogicControl::TLSLogicVariants::executeOnSwitchActions
void executeOnSwitchActions() const
Definition: MSTLLogicControl.cpp:217
MSTrafficLightLogic::getNextSwitchTime
SUMOTime getNextSwitchTime() const
Returns the assumed next switch time.
Definition: MSTrafficLightLogic.cpp:281
MSTLLogicControl::WAUTSwitchProcedure_Stretch::trySwitch
bool trySwitch(SUMOTime step)
Determines whether a switch is possible.
Definition: MSTLLogicControl.cpp:371
MSTLLogicControl::WAUTSwitchProcedure_Stretch::StretchBereichDef
A definition of a stretch - Bereich.
Definition: MSTLLogicControl.h:751
MSEventControl.h
MSTLLogicControl::WAUTJunction::procedure
std::string procedure
The procedure to switch the junction with.
Definition: MSTLLogicControl.h:490
MSPhaseDefinition
The definition of a single phase of a tls logic.
Definition: MSPhaseDefinition.h:51
MSTLLogicControl::OnSwitchAction
Base class for things to execute if a tls switches to a new phase.
Definition: MSTLLogicControl.h:65
MSTLLogicControl::TLSLogicVariants::TLSLogicVariants
TLSLogicVariants()
Constructor.
Definition: MSTLLogicControl.cpp:48
MSTLLogicControl::TLSLogicVariants::saveInitialStates
void saveInitialStates()
Definition: MSTLLogicControl.cpp:86
MSTLLogicControl::check2Switch
void check2Switch(SUMOTime step)
Checks whether any WAUT is trying to switch a tls into another program.
Definition: MSTLLogicControl.cpp:824
MSTLLogicControl::WAUTSwitchProcedure_Stretch::~WAUTSwitchProcedure_Stretch
~WAUTSwitchProcedure_Stretch()
Destructor.
Definition: MSTLLogicControl.cpp:367
Named::getID
const std::string & getID() const
Returns the id.
Definition: Named.h:76
WRITE_ERROR
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:283
MSTLLogicControl::WAUTSwitchProcedure_Stretch::StretchBereichDef::begin
double begin
The begin of a stretch/cut area (time, in s)
Definition: MSTLLogicControl.h:753
MSTLLogicControl::SwitchInitCommand::getWAUTID
const std::string & getWAUTID() const
Returns the WAUT-id.
Definition: MSTLLogicControl.h:426
MSTLLogicControl::closeNetworkReading
bool closeNetworkReading()
Lets MSTLLogicControl know that the network has been loaded.
Definition: MSTLLogicControl.cpp:641
MSTrafficLightLogic::getCurrentPhaseDef
virtual const MSPhaseDefinition & getCurrentPhaseDef() const =0
Returns the definition of the current phase.