Eclipse SUMO - Simulation of Urban MObility
MSRailSignal.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 /****************************************************************************/
15 // A rail signal logic
16 /****************************************************************************/
17 
18 
19 // ===========================================================================
20 // included modules
21 // ===========================================================================
22 #include <config.h>
23 
24 #include <cassert>
25 #include <utility>
26 #include <vector>
27 #include <bitset>
28 #ifdef HAVE_FOX
30 #endif
33 #include <microsim/MSNet.h>
34 #include <microsim/MSEdge.h>
35 #include <microsim/MSEdgeControl.h>
36 #include <microsim/MSLane.h>
37 #include <microsim/MSLink.h>
39 #include <microsim/MSVehicle.h>
42 #include <microsim/MSLane.h>
43 
44 #include "MSTLLogicControl.h"
45 #include "MSTrafficLightLogic.h"
46 #include "MSPhaseDefinition.h"
47 #include "MSTLLogicControl.h"
48 #include "MSRailSignal.h"
49 
50 // typical block length in germany on main lines is 3-5km on branch lines up to 7km
51 // special branches that are used by one train exclusively could also be up to 20km in length
52 // minimum block size in germany is 37.5m (LZB)
53 // larger countries (USA, Russia) might see blocks beyond 20km)
54 #define MAX_BLOCK_LENGTH 20000
55 #define MAX_SIGNAL_WARNINGS 10
56 
57 //#define DEBUG_BUILD_DRIVEWAY
58 //#define DEBUG_CHECK_FLANKS
59 
60 #define DEBUG_SIGNALSTATE
61 #define DEBUG_SIGNALSTATE_PRIORITY
62 #define DEBUG_FIND_PROTECTION
63 //#define DEBUG_REROUTE
64 
65 #define DEBUG_COND DEBUG_HELPER(this)
66 #define DEBUG_COND_LINKINFO DEBUG_HELPER(myLink->getTLLogic())
67 #define DEBUG_HELPER(obj) ((obj)->isSelected())
68 //#define DEBUG_HELPER(obj) ((obj)->getID() == "w2")
69 //#define DEBUG_HELPER(obj) (true)
70 
71 // ===========================================================================
72 // static value definitions
73 // ===========================================================================
75 
76 // ===========================================================================
77 // method definitions
78 // ===========================================================================
80  const std::string& id, const std::string& programID, SUMOTime delay,
81  const std::map<std::string, std::string>& parameters) :
82  MSTrafficLightLogic(tlcontrol, id, programID, TLTYPE_RAIL_SIGNAL, delay, parameters),
83  myCurrentPhase(DELTA_T, std::string(SUMO_MAX_CONNECTIONS, 'X'), -1), // dummy phase
84  myPhaseIndex(0) {
86 }
87 
88 void
90  assert(myLanes.size() > 0);
91  for (LinkVector& links : myLinks) { //for every link index
92  if (links.size() != 1) {
93  throw ProcessError("At railSignal '" + getID() + "' found " + toString(links.size())
94  + " links controlled by index " + toString(links[0]->getTLIndex()));
95  }
96  myLinkInfos.push_back(LinkInfo(links[0]));
97  }
99  setTrafficLightSignals(MSNet::getInstance()->getCurrentTimeStep());
100 }
101 
102 
104 }
105 
106 
107 // ----------- Handling of controlled links
108 void
112 }
113 
114 
115 // ------------ Switching and setting current rows
116 SUMOTime
119  return DELTA_T;
120 }
121 
122 
123 
124 void
126 #ifdef DEBUG_SIGNALSTATE
128 #endif
129  // green by default so vehicles can be inserted at the borders of the network
130  std::string state(myLinks.size(), 'G');
131  for (LinkInfo& li : myLinkInfos) {
132  if (li.myLink->getApproaching().size() > 0) {
133  Approaching closest = getClosest(li.myLink);
134  DriveWay& driveway = li.getDriveWay(closest.first);
135  //std::cout << SIMTIME << " signal=" << getTLLinkID(li.myLink) << " veh=" << closest.first->getID() << " dw:\n";
136  //driveway.writeBlocks(*OutputDevice_COUT::getDevice());
137  MSEdgeVector occupied;
138  if (!driveway.reserve(closest, occupied)) {
139  state[li.myLink->getTLIndex()] = 'r';
140  if (occupied.size() > 0) {
141  li.reroute(const_cast<SUMOVehicle*>(closest.first), occupied);
142  }
143 #ifdef DEBUG_SIGNALSTATE
144  if (gDebugFlag4) {
145  std::cout << SIMTIME << " rsl=" << li.getID() << " veh=" << closest.first->getID() << " notReserved\n";
146  }
147 #endif
148  } else {
149  state[li.myLink->getTLIndex()] = 'G';
150 #ifdef DEBUG_SIGNALSTATE
151  if (gDebugFlag4) {
152  std::cout << SIMTIME << " rsl=" << li.getID() << " veh=" << closest.first->getID() << " reserved\n";
153  }
154 #endif
155  }
156  } else {
157  DriveWay& driveway = li.myDriveways.front();
158  if (driveway.conflictLaneOccupied() || driveway.conflictLinkApproached()) {
159 #ifdef DEBUG_SIGNALSTATE
160  if (gDebugFlag4) {
161  std::cout << SIMTIME << " rsl=" << li.getID() << " red for default driveway\n";
162  }
163 #endif
164  state[li.myLink->getTLIndex()] = 'r';
165  }
166  }
167  }
168  if (myCurrentPhase.getState() != state) {
169  myCurrentPhase.setState(state);
171  }
172 #ifdef DEBUG_SIGNALSTATE
173  gDebugFlag4 = false;
174 #endif
175 }
176 
177 
178 // ------------ Static Information Retrieval
179 int
181  return 0;
182 }
183 
186  return myPhases;
187 }
188 
189 const MSPhaseDefinition&
191  return myCurrentPhase;
192 }
193 
194 // ------------ Dynamic Information Retrieval
195 int
197  return myPhaseIndex;
198 }
199 
200 const MSPhaseDefinition&
202  return myCurrentPhase;
203 }
204 
205 // ------------ Conversion between time and phase
206 SUMOTime
208  return 0;
209 }
210 
211 SUMOTime
213  return 0;
214 }
215 
216 int
218  return 0;
219 }
220 
221 
222 void
223 MSRailSignal::addLink(MSLink* link, MSLane* lane, int pos) {
224  if (pos >= 0) {
225  MSTrafficLightLogic::addLink(link, lane, pos);
226  } // ignore uncontrolled link
227 }
228 
229 
230 std::string
232  return link->getTLLogic()->getID() + "_" + toString(link->getTLIndex());
233 }
234 
235 std::string
237  return "junction '" + link->getTLLogic()->getID() + "', link " + toString(link->getTLIndex());
238 }
239 
240 std::string
241 MSRailSignal::describeLinks(std::vector<MSLink*> links) {
242  std::string result;
243  for (MSLink* link : links) {
244  result += link->getDescription() + " ";
245  }
246  return result;
247 }
248 
251  assert(link->getApproaching().size() > 0);
252  double minDist = std::numeric_limits<double>::max();
253  auto closestIt = link->getApproaching().begin();
254  for (auto apprIt = link->getApproaching().begin(); apprIt != link->getApproaching().end(); apprIt++) {
255  if (apprIt->second.dist < minDist) {
256  minDist = apprIt->second.dist;
257  closestIt = apprIt;
258  }
259  }
260  // maybe a parallel link has a closer vehicle
261  /*
262  for (MSLink* link2 : link->getLaneBefore()->getLinkCont()) {
263  if (link2 != link) {
264  for (auto apprIt2 = link2->getApproaching().begin(); apprIt2 != link2->getApproaching().end(); apprIt2++) {
265  if (apprIt2->second.dist < minDist) {
266  minDist = apprIt2->second.dist;
267  closestIt = apprIt2;
268  }
269  }
270  }
271  }
272  */
273  return *closestIt;
274 }
275 
276 void
278  od.openTag("railSignal");
280  for (const LinkInfo& li : myLinkInfos) {
281  MSLink* link = li.myLink;
282  od.openTag("link");
286  for (const DriveWay& dw : li.myDriveways) {
287  dw.writeBlocks(od);
288  }
289  od.closeTag(); // link
290  }
291  od.closeTag(); // railSignal
292 }
293 
294 
295 bool
297  if (link->getJunction()->getType() == NODETYPE_RAIL_SIGNAL && link->getState() == LINKSTATE_TL_RED) {
298  const MSEdge* bidi = link->getLaneBefore()->getEdge().getBidiEdge();
299  if (bidi == nullptr) {
300  return false;
301  }
302  const MSRailSignal* rs = dynamic_cast<const MSRailSignal*>(link->getTLLogic());
303  if (rs != nullptr) {
304  const LinkInfo& li = rs->myLinkInfos[link->getTLIndex()];
305  for (const DriveWay& dw : li.myDriveways) {
306  //std::cout << SIMTIME <<< " hasOncomingRailTraffic link=" << getTLLinkID(link) << " dwRoute=" << toString(dw.myRoute) << " bidi=" << toString(dw.myBidi) << "\n";
307  for (MSLane* lane : dw.myBidi) {
308  if (!lane->isEmpty()) {
309  return true;
310  }
311  }
312  for (const MSLane* lane : dw.myFlank) {
313  if (!lane->isEmpty()) {
314  MSVehicle* veh = lane->getFirstAnyVehicle();
315  if (std::find(veh->getCurrentRouteEdge(), veh->getRoute().end(), bidi) != veh->getRoute().end()) {
316  return true;
317  }
318  }
319  }
320  for (MSLink* foeLink : dw.myConflictLinks) {
321  if (foeLink->getApproaching().size() != 0) {
322  Approaching closest = getClosest(foeLink);
323  const SUMOVehicle* veh = closest.first;
324  if (std::find(veh->getCurrentRouteEdge(), veh->getRoute().end(), bidi) != veh->getRoute().end()) {
325  return true;
326  }
327  }
328  }
329  }
330  }
331  }
332  return false;
333 }
334 
335 // ===========================================================================
336 // LinkInfo method definitions
337 // ===========================================================================
338 
340  myLink(link), myUniqueDriveWay(false),
341  myLastRerouteTime(-1),
342  myLastRerouteVehicle(nullptr) {
343  ConstMSEdgeVector dummyRoute;
344  dummyRoute.push_back(&link->getLane()->getEdge());
345  buildDriveWay(dummyRoute.begin(), dummyRoute.end());
346 }
347 
348 
349 std::string
351  return myLink->getTLLogic()->getID() + "_" + toString(myLink->getTLIndex());
352 }
353 
354 
357  if (myUniqueDriveWay) {
358  return myDriveways.front();
359  }
360  MSEdge* first = &myLink->getLane()->getEdge();
361  MSRouteIterator firstIt = std::find(veh->getCurrentRouteEdge(), veh->getRoute().end(), first);
362  if (firstIt == veh->getRoute().end()) {
363  WRITE_WARNING("Invalid approach information after rerouting");
364  return myDriveways.front();
365  }
366  //std::cout << SIMTIME << " veh=" << veh->getID() << " rsl=" << getID() << " dws=" << myDriveways.size() << "\n";
367  for (DriveWay& dw : myDriveways) {
368  // @todo optimize: it is sufficient to check for specific edges (after each switch)
369  auto itRoute = firstIt;
370  auto itDwRoute = dw.myRoute.begin();
371  bool match = true;
372  while (itRoute != veh->getRoute().end() && itDwRoute != dw.myRoute.end()) {
373  if (*itRoute != *itDwRoute) {
374  match = false;
375  //std::cout << " check dw=" << dw.myIndex << " match failed at vehEdge=" << (*itRoute)->getID() << " dwEdge=" << (*itDwRoute)->getID() << "\n";
376  break;
377  }
378  itRoute++;
379  itDwRoute++;
380  }
381  if (match) {
382  //std::cout << " using dw=" << dw.myIndex << "\n";
383  return dw;
384  }
385  }
386  return buildDriveWay(firstIt, veh->getRoute().end());
387 }
388 
389 
392  // collect lanes and links that are relevant for setting this signal for the current driveWay
393  // For each driveway we collect
394  // - conflictLanes (signal must be red if any conflict lane is occupied)
395  // - conflictLinks (signal must be red if any conflict link is approached by a vehicle
396  // - that cannot break in time (arrivalSpeedBraking > 0)
397  // - approached by a vehicle with higher switching priority (see #3941)
398  // These objects are construct in steps:
399  //
400  // forwardBlock
401  // - search forward recursive from outgoing lane until controlled railSignal link found
402  // -> add all found lanes to conflictLanes
403  //
404  // bidiBlock (if any forwardBlock edge edge has bidi edge)
405  // - search bidi backward recursive until first switch
406  // - from switch search backward recursive all other incoming until controlled rail signal link
407  // -> add final links to conflictLinks
408  //
409  // flanks
410  // - search backward recursive from flanking switches
411  // until controlled railSignal link or protecting switch is found
412  // -> add all found lanes to conflictLanes
413  // -> add final links to conflictLinks
414 
415  DriveWay dw((int)myDriveways.size());
416  LaneSet visited;
417  std::vector<MSLane*> before;
418  visited.insert(myLink->getLaneBefore());
419  MSLane* fromBidi = myLink->getLaneBefore()->getBidiLane();
420  if (fromBidi != nullptr) {
421  // do not extend to forward block beyond the entering track (in case of a loop)
422  visited.insert(fromBidi);
423  before.push_back(fromBidi);
424  }
425  dw.buildRoute(myLink, 0., first, end, visited);
426  dw.checkFlanks(dw.myForward, visited, true);
427  dw.checkFlanks(dw.myBidi, visited, false);
428  dw.checkFlanks(before, visited, true);
429 
430  for (MSLink* link : dw.myFlankSwitches) {
431  //std::cout << getID() << " flankSwitch=" << link->getDescription() << "\n";
432  dw.findFlankProtection(link, 0, visited, link);
433  }
434 
435 #ifdef DEBUG_BUILD_DRIVEWAY
436  if (DEBUG_COND_LINKINFO || true) {
437  std::cout << " buildDriveWay railSignal=" << getID() << " dw=" << dw.myIndex
438  << "\n route=" << toString(dw.myRoute)
439  << "\n forward=" << toString(dw.myForward)
440  << "\n bidi=" << toString(dw.myBidi)
441  << "\n protSwitch=" << describeLinks(dw.myProtectingSwitches)
442  << "\n";
443  }
444 #endif
445 
446  dw.myConflictLanes.insert(dw.myConflictLanes.end(), dw.myForward.begin(), dw.myForward.end());
447  dw.myConflictLanes.insert(dw.myConflictLanes.end(), dw.myBidi.begin(), dw.myBidi.end());
448  dw.myConflictLanes.insert(dw.myConflictLanes.end(), dw.myFlank.begin(), dw.myFlank.end());
449 
450  myDriveways.push_back(dw);
451  return myDriveways.back();
452 }
453 
454 
455 void
457  MSDevice_Routing* rDev = static_cast<MSDevice_Routing*>(veh->getDevice(typeid(MSDevice_Routing)));
459  if (rDev != nullptr &&
460  (myLastRerouteVehicle != veh
461  // reroute each vehicle only once if no periodic routing is allowed,
462  // otherwise with the specified period
463  || (rDev->getPeriod() > 0 && myLastRerouteTime + rDev->getPeriod() <= now))) {
464  myLastRerouteVehicle = veh;
465  myLastRerouteTime = now;
466 
467 #ifdef DEBUG_REROUTE
468  ConstMSEdgeVector oldRoute = veh->getRoute().getEdges();
469  if (DEBUG_COND_LINKINFO) {
470  std::cout << SIMTIME << " reroute veh=" << veh->getID() << " rs=" << getID() << " occupied=" << toString(occupied) << "\n";
471  }
472 #endif
473  MSRoutingEngine::reroute(*veh, now, "railSignal:" + getID(), false, true, occupied);
474 #ifdef DEBUG_REROUTE
475  // attention this works only if we are not parallel!
476  if (DEBUG_COND_LINKINFO) {
477  if (veh->getRoute().getEdges() != oldRoute) {
478  std::cout << " rerouting successful\n";
479  }
480  }
481 #endif
482  }
483 }
484 
485 
486 // ===========================================================================
487 // DriveWay method definitions
488 // ===========================================================================
489 
490 bool
492  if (conflictLaneOccupied()) {
493  for (MSLane* bidi : myBidi) {
494  if (!bidi->empty() && bidi->getBidiLane() != nullptr) {
495  occupied.push_back(&bidi->getBidiLane()->getEdge());
496  }
497  }
498 #ifdef DEBUG_SIGNALSTATE
499  if (gDebugFlag4) {
500  std::cout << " conflictLaneOccupied\n";
501  }
502 #endif
503  return false;
504  }
505  for (MSLink* link : myProtectingSwitches) {
506  if (!findProtection(closest, link)) {
507 #ifdef DEBUG_SIGNALSTATE
508  if (gDebugFlag4) {
509  std::cout << " no protection at switch " << link->getDescription() << "\n";
510  }
511 #endif
512  return false;
513  }
514  }
515  for (MSLink* foeLink : myConflictLinks) {
516  if (hasLinkConflict(closest, foeLink)) {
517 #ifdef DEBUG_SIGNALSTATE
518  if (gDebugFlag4) {
519  std::cout << " linkConflict with " << getTLLinkID(foeLink) << "\n";
520  }
521 #endif
522  return false;
523  }
524  }
525  myActive = closest.first;
526  return true;
527 }
528 
529 
530 bool
532  for (MSLink* foeLink : myConflictLinks) {
533  if (foeLink->getApproaching().size() > 0) {
534  return true;
535  }
536  }
537  return false;
538 }
539 
540 
541 bool
543 #ifdef DEBUG_SIGNALSTATE_PRIORITY
544  if (gDebugFlag4) {
545  std::cout << " checkLinkConflict foeLink=" << getTLLinkID(foeLink) << "\n";
546  }
547 #endif
548  if (foeLink->getApproaching().size() > 0) {
549  Approaching foe = getClosest(foeLink);
550 #ifdef DEBUG_SIGNALSTATE_PRIORITY
551  if (gDebugFlag4) {
552  std::cout << " approaching foe=" << foe.first->getID() << "\n";
553  }
554 #endif
555  const MSTrafficLightLogic* foeTLL = foeLink->getTLLogic();
556  assert(foeTLL != nullptr);
557  const MSRailSignal* constFoeRS = dynamic_cast<const MSRailSignal*>(foeTLL);
558  MSRailSignal* foeRS = const_cast<MSRailSignal*>(constFoeRS);
559  if (foeRS != nullptr) {
560  const DriveWay& foeDriveWay = foeRS->myLinkInfos[foeLink->getTLIndex()].getDriveWay(foe.first);
561  if (foeDriveWay.conflictLaneOccupied() ||
562  !overlap(foeDriveWay)) {
563 #ifdef DEBUG_SIGNALSTATE_PRIORITY
564  if (gDebugFlag4) {
565  if (foeDriveWay.conflictLaneOccupied()) {
566  std::cout << " foe blocked\n";
567  } else {
568  std::cout << " no overlap\n";
569  }
570  }
571 #endif
572  return false;
573  }
574 #ifdef DEBUG_SIGNALSTATE_PRIORITY
575  if (gDebugFlag4) {
576  std::cout
577  << " aSB=" << veh.second.arrivalSpeedBraking << " foeASB=" << foe.second.arrivalSpeedBraking
578  << " aT=" << veh.second.arrivalTime << " foeAT=" << foe.second.arrivalTime
579  << " aS=" << veh.first->getSpeed() << " foeS=" << foe.first->getSpeed()
580  << " aD=" << veh.second.dist << " foeD=" << foe.second.dist
581  << "\n";
582  }
583 #endif
584  if (foe.second.arrivalSpeedBraking == veh.second.arrivalSpeedBraking) {
585  if (foe.second.arrivalTime == veh.second.arrivalTime) {
586  if (foe.first->getSpeed() == veh.first->getSpeed()) {
587  if (foe.second.dist == veh.second.dist) {
588  return foe.first->getNumericalID() < veh.first->getNumericalID();
589  } else {
590  return foe.second.dist < veh.second.dist;
591  }
592  } else {
593  return foe.first->getSpeed() > veh.first->getSpeed();
594  }
595  } else {
596  return foe.second.arrivalTime < veh.second.arrivalTime;
597  }
598  } else {
599  return foe.second.arrivalSpeedBraking > veh.second.arrivalSpeedBraking;
600  }
601  }
602  }
603  return false;
604 }
605 
606 
607 bool
609  for (const MSLane* lane : myConflictLanes) {
610  if (!lane->isEmpty()) {
611 #ifdef DEBUG_SIGNALSTATE
612  if (gDebugFlag4) {
613  std::cout << SIMTIME << " conflictLane " << lane->getID() << " occupied\n";
614  }
615 #endif
616  return true;
617  }
618  }
619  return false;
620 }
621 
622 
623 bool
625  double flankApproachingDist = std::numeric_limits<double>::max();
626  if (link->getApproaching().size() > 0) {
627  Approaching closest = getClosest(link);
628  flankApproachingDist = closest.second.dist;
629  }
630 #ifdef DEBUG_FIND_PROTECTION
631  if (gDebugFlag4) {
632  std::cout << SIMTIME << " findProtection for link=" << link->getDescription() << " flankApproachingDist=" << flankApproachingDist << "\n";
633  }
634 #endif
635  for (MSLink* l2 : link->getLaneBefore()->getLinkCont()) {
636  if (l2->getLane() != link->getLane()) {
637 #ifdef DEBUG_FIND_PROTECTION
638  if (gDebugFlag4) {
639  std::cout << " protectionCandidate=" << l2->getDescription() << " l2Via=" << Named::getIDSecure(l2->getViaLane()) << " occupied=" << !l2->getViaLane()->isEmpty() << "\n";
640  }
641 #endif
642  if (l2->getViaLane() != nullptr && !l2->getViaLane()->isEmpty()) {
643 #ifdef DEBUG_FIND_PROTECTION
644  if (gDebugFlag4) {
645  std::cout << " protection from internal=" << l2->getViaLane()->getID() << "\n";
646  }
647 #endif
648  return true;
649  }
650  if (l2->getApproaching().size() > 0) {
651  Approaching closest2 = getClosest(l2);
652  if (closest2.second.dist < flankApproachingDist) {
653 #ifdef DEBUG_FIND_PROTECTION
654  if (gDebugFlag4) {
655  std::cout << " protection from veh=" << closest2.first->getID() << "\n";
656  }
657 #endif
658  return true;
659  }
660  }
661  }
662  }
663  if (link->getApproaching().size() == 0) {
664  return true;
665  } else {
666  // find protection further upstream
667  DriveWay tmp(-myIndex);
668  const MSLane* before = link->getLaneBefore();
669  tmp.myFlank.push_back(before);
670  LaneSet visited;
671  for (auto ili : before->getIncomingLanes()) {
672  tmp.findFlankProtection(ili.viaLink, myMaxFlankLength, visited, ili.viaLink);
673  }
674  tmp.myConflictLanes = tmp.myFlank;
675  tmp.myRoute = myRoute;
676  MSEdgeVector occupied;
677  if (gDebugFlag4) std::cout << SIMTIME << " tmpDW flank=" << toString(tmp.myFlank)
678  << " protSwitch=" << describeLinks(tmp.myProtectingSwitches) << " cLinks=" << describeLinks(tmp.myConflictLinks) << "\n";
679  return tmp.reserve(veh, occupied);
680  }
681 }
682 
683 
684 bool
686  for (const MSEdge* edge : myRoute) {
687  for (const MSEdge* edge2 : other.myRoute) {
688  if (edge->getToJunction() == edge2->getToJunction()
689  || edge->getToJunction() == edge2->getFromJunction()) {
690  // XXX might be rail_crossing with parallel tracks
691  return true;
692  }
693  }
694  }
695  return false;
696 }
697 
698 void
700  od.openTag("driveWay");
701  od.writeAttr(SUMO_ATTR_EDGES, toString(myRoute));
702  od.openTag("forward");
703  od.writeAttr(SUMO_ATTR_LANES, toString(myForward));
704  od.closeTag();
705  od.openTag("bidi");
706  od.writeAttr(SUMO_ATTR_LANES, toString(myBidi));
707  od.closeTag();
708  od.openTag("flank");
709  od.writeAttr(SUMO_ATTR_LANES, toString(myFlank));
710  od.closeTag();
711  od.openTag("conflictLinks");
712  std::vector<std::string> signals;
713  for (MSLink* link : myConflictLinks) {
714  signals.push_back(getTLLinkID(link));
715  }
716  od.writeAttr("signals", joinToString(signals, " "));
717  od.closeTag();
718  od.closeTag(); // driveWay
719 }
720 
721 
722 void
725  LaneSet& visited) {
726  bool seekForwardSignal = true;
727  bool seekBidiSwitch = true;
728  MSLane* toLane = origin->getViaLaneOrLane();
729  //std::cout << "buildRoute origin=" << getTLLinkID(origin) << " vehRoute=" << toString(ConstMSEdgeVector(next, end)) << " visited=" << joinNamedToString(visited, " ") << "\n";
730  while ((seekForwardSignal || seekBidiSwitch)) {
731  if (length > MAX_BLOCK_LENGTH) {
733  WRITE_WARNING("Block after rail signal " + getClickableTLLinkID(origin) +
734  " exceeds maximum length (stopped searching after edge '" + toLane->getEdge().getID() + "' (length=" + toString(length) + "m).");
735  }
736  myNumWarnings++;
737  // length exceeded
738  return;
739  }
740  //std::cout << " toLane=" << toLane->getID() << " visited=" << joinNamedToString(visited, " ") << "\n";
741  if (visited.count(toLane) != 0) {
742  WRITE_WARNING("Found circular block after railSignal " + getClickableTLLinkID(origin) + " (" + toString(myRoute.size()) + " edges, length " + toString(length) + ")");
743  return;
744  }
745  if (toLane->getEdge().isNormal()) {
746  myRoute.push_back(&toLane->getEdge());
747  if (next != end) {
748  next++;
749  }
750  }
751  visited.insert(toLane);
752  length += toLane->getLength();
753  MSLane* bidi = toLane->getBidiLane();
754  if (seekForwardSignal) {
755  myForward.push_back(toLane);
756  } else if (bidi == nullptr) {
757  seekBidiSwitch = false;
758  }
759  if (bidi != nullptr) {
760  myBidi.push_back(bidi);
761  visited.insert(bidi);
762  if (!seekForwardSignal) {
763  // look for switch that could protect from oncoming vehicles
764  for (const auto& ili : bidi->getIncomingLanes()) {
765  if (ili.viaLink->getDirection() == LINKDIR_TURN) {
766  continue;
767  }
768  for (MSLink* link : ili.lane->getLinkCont()) {
769  if (link->getDirection() == LINKDIR_TURN) {
770  continue;
771  }
772  if (link->getViaLaneOrLane() != bidi) {
773  // this switch is special beause it still lies on the current route
774  myProtectingSwitches.push_back(ili.viaLink);
775  return;
776  }
777  }
778  }
779  }
780  }
781  const MSLinkCont& links = toLane->getLinkCont();
782  toLane = nullptr;
783  for (MSLink* link : links) {
784  if (((next != end && &link->getLane()->getEdge() == *next) ||
785  (next == end && link->getDirection() != LINKDIR_TURN))
786  && isRailway(link->getViaLaneOrLane()->getPermissions())) {
787  toLane = link->getViaLaneOrLane();
788  if (link->getTLLogic() != nullptr) {
789  if (link->getTLLogic() == origin->getTLLogic()) {
790  WRITE_WARNING("Found circular block at railSignal " + getClickableTLLinkID(origin) + " (" + toString(myRoute.size()) + " edges, length " + toString(length) + ")");
791  return;
792  }
793  seekForwardSignal = false;
794  seekBidiSwitch = bidi != nullptr;
795  }
796  break;
797  }
798  }
799  if (toLane == nullptr) {
800  if (next != end) {
801  // no connection found, jump to next route edge
802  toLane = (*next)->getLanes()[0];
803  } else {
804  return;
805  }
806  }
807  }
808 }
809 
810 
811 void
812 MSRailSignal::DriveWay::checkFlanks(const std::vector<MSLane*>& lanes, const LaneSet& visited, bool allFoes) {
813 #ifdef DEBUG_CHECK_FLANKS
814  std::cout << " checkFlanks lanes=" << toString(lanes) << "\n visited=" << joinNamedToString(visited, " ") << " allFoes=" << allFoes << "\n";
815 #endif
816  for (MSLane* lane : lanes) {
817  if (lane->isInternal()) {
818  continue;
819  }
820  for (auto ili : lane->getIncomingLanes()) {
821  if (visited.count(ili.lane->getNormalPredecessorLane()) == 0) {
822 #ifdef DEBUG_CHECK_FLANKS
823  std::cout << " add flankSwitch junction=" << ili.viaLink->getJunction()->getID() << " index=" << ili.viaLink->getIndex() << "\n";
824 #endif
825  myFlankSwitches.push_back(ili.viaLink);
826  } else if (allFoes) {
827  // link is part of the driveway, find foes that cross the driveway without entering
828  checkCrossingFlanks(ili.viaLink, visited);
829  }
830  }
831  }
832 }
833 
834 
835 void
837 #ifdef DEBUG_CHECK_FLANKS
838  std::cout << " checkCrossingFlanks dwLink=" << dwLink->getDescription() << " visited=" << joinNamedToString(visited, " ") << "\n";
839 #endif
840  const MSJunction* junction = dwLink->getJunction();
841  const MSJunctionLogic* logic = junction->getLogic();
842  assert(logic != nullptr);
843  for (const MSEdge* in : junction->getIncoming()) {
844  if (in->isInternal()) {
845  continue;
846  }
847  for (MSLane* inLane : in->getLanes()) {
848  if (isRailway(inLane->getPermissions()) && visited.count(inLane) == 0) {
849  for (MSLink* link : inLane->getLinkCont()) {
850  if (link->getIndex() >= 0 && logic->getFoesFor(dwLink->getIndex()).test(link->getIndex())
851  && visited.count(link->getLane()) == 0) {
852 #ifdef DEBUG_CHECK_FLANKS
853  std::cout << " add crossing flankSwitch junction=" << junction->getID() << " index=" << link->getIndex() << "\n";
854 #endif
855  if (link->getViaLane() == nullptr) {
856  myFlankSwitches.push_back(link);
857  } else {
858  myFlankSwitches.push_back(link->getViaLane()->getLinkCont().front());
859  }
860  }
861  }
862  }
863  }
864  }
865 }
866 
867 void
868 MSRailSignal::DriveWay::findFlankProtection(MSLink* link, double length, LaneSet& visited, MSLink* origLink) {
869 #ifdef DEBUG_CHECK_FLANKS
870  std::cout << " findFlankProtection link=" << link->getDescription() << " length=" << length << " origLink=" << origLink->getDescription() << "\n";
871 #endif
872  if (link->getTLLogic() != nullptr) {
873  // guarded by signal
874  myConflictLinks.push_back(link);
875  } else if (length > MAX_BLOCK_LENGTH) {
876  // length exceeded
878  WRITE_WARNING("Incoming block at junction '" + origLink->getJunction()->getID() + "', link " + toString(origLink->getIndex()) + " exceeds maximum length (stopped searching after lane '" + link->getLane()->getID() + "' (length=" + toString(length) + "m).");
879  }
880  myNumWarnings++;
881  } else {
882  // find normal lane before this link
883  const MSLane* lane = link->getLaneBefore();
884  if (visited.count(lane) == 0) {
885  visited.insert(lane);
886  length += lane->getLength();
887  if (lane->isInternal()) {
888  myFlank.push_back(lane);
889  findFlankProtection(lane->getIncomingLanes().front().viaLink, length, visited, origLink);
890  } else {
891  bool foundPSwitch = false;
892  for (MSLink* l2 : lane->getLinkCont()) {
893 #ifdef DEBUG_CHECK_FLANKS
894  std::cout << " lane=" << lane->getID() << " cand=" << l2->getDescription() << "\n";
895 #endif
896  if (l2->getDirection() != LINKDIR_TURN && l2->getLane() != link->getLane()) {
897  foundPSwitch = true;
898  // found potential protection
899 #ifdef DEBUG_CHECK_FLANKS
900  std::cout << " protectingSwitch=" << l2->getDescription() << " for flank=" << link->getDescription() << "\n";
901 #endif
902  myProtectingSwitches.push_back(link);
903  }
904  }
905  if (!foundPSwitch) {
906  myFlank.push_back(lane);
907  // continue search for protection upstream recursively
908  for (auto ili : lane->getIncomingLanes()) {
909  if (ili.viaLink->getDirection() != LINKDIR_TURN) {
910  findFlankProtection(ili.viaLink, length, visited, origLink);
911  }
912  }
913  }
914  }
915  }
916  }
917  myMaxFlankLength = MAX2(myMaxFlankLength, length);
918 }
919 
920 
921 /****************************************************************************/
922 
MSRailSignal::DriveWay::myConflictLanes
std::vector< const MSLane * > myConflictLanes
the lanes that must be clear of trains before this signal can switch to green
Definition: MSRailSignal.h:255
MAX_SIGNAL_WARNINGS
#define MAX_SIGNAL_WARNINGS
Definition: MSRailSignal.cpp:55
MSTrafficLightLogic::setTrafficLightSignals
bool setTrafficLightSignals(SUMOTime t) const
Applies the current signal states to controlled links.
Definition: MSTrafficLightLogic.cpp:235
MSTrafficLightLogic::myLinks
LinkVectorVector myLinks
The list of LinkVectors; each vector contains the links that belong to the same link index.
Definition: MSTrafficLightLogic.h:417
MSTrafficLightLogic::myLanes
LaneVectorVector myLanes
The list of LaneVectors; each vector contains the incoming lanes that belong to the same link index.
Definition: MSTrafficLightLogic.h:420
MSRailSignal::getOffsetFromIndex
SUMOTime getOffsetFromIndex(int index) const
Returns the position (start of a phase during a cycle) from of a given step.
Definition: MSRailSignal.cpp:212
MSRailSignal::getIndexFromOffset
int getIndexFromOffset(SUMOTime offset) const
Returns the step (the phasenumber) of a given position of the cycle.
Definition: MSRailSignal.cpp:217
MSDevice_Routing
A device that performs vehicle rerouting based on current edge speeds.
Definition: MSDevice_Routing.h:60
MSRailSignal::DriveWay::myIndex
int myIndex
index in the list of driveways
Definition: MSRailSignal.h:230
WRITE_WARNING
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:275
MSTLLogicControl.h
MSNet.h
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
MSRailSignal::getPhaseIndexAtTime
SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const
Returns the index of the logic at the given simulation step.
Definition: MSRailSignal.cpp:207
MSRailSignal::trySwitch
SUMOTime trySwitch()
Switches to the next phase.
Definition: MSRailSignal.cpp:117
MSDevice_Routing::getPeriod
SUMOTime getPeriod() const
Definition: MSDevice_Routing.h:153
DEBUG_COND
#define DEBUG_COND
Definition: MSRailSignal.cpp:65
MSJunction
The base class for an intersection.
Definition: MSJunction.h:60
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
DELTA_T
SUMOTime DELTA_T
Definition: SUMOTime.cpp:36
MSRoute::end
MSRouteIterator end() const
Returns the end of the list of edges to pass.
Definition: MSRoute.cpp:75
MSRailSignal::DriveWay::myProtectingSwitches
std::vector< MSLink * > myProtectingSwitches
Definition: MSRailSignal.h:265
MSRouteIterator
ConstMSEdgeVector::const_iterator MSRouteIterator
Definition: MSRoute.h:57
MSRailSignal::DriveWay::buildRoute
void buildRoute(MSLink *origin, double length, MSRouteIterator next, MSRouteIterator end, LaneSet &visited)
Definition: MSRailSignal.cpp:723
MSJunctionLogic.h
MSTrafficLightLogic::Phases
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
Definition: MSTrafficLightLogic.h:61
SUMOTrafficObject::getID
virtual const std::string & getID() const =0
Get the vehicle's ID.
SUMOVehicle::getCurrentRouteEdge
virtual const ConstMSEdgeVector::const_iterator & getCurrentRouteEdge() const =0
Returns an iterator pointing to the current edge in this vehicles route.
MSRailSignal::DriveWay::hasLinkConflict
bool hasLinkConflict(const Approaching &closest, MSLink *foeLink) const
Whether the approaching vehicle is prevent from driving by another vehicle approaching the given link...
Definition: MSRailSignal.cpp:542
MSLane::isEmpty
bool isEmpty() const
Definition: MSLane.cpp:2005
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
MSRailSignal::myPhaseIndex
int myPhaseIndex
MSTrafficLightLogic requires that the phase index changes whenever signals change their state.
Definition: MSRailSignal.h:372
MSRailSignal::DriveWay::myBidi
std::vector< MSLane * > myBidi
Definition: MSRailSignal.h:248
SUMOVehicle
Representation of a vehicle.
Definition: SUMOVehicle.h:60
MSBaseVehicle::getRoute
const MSRoute & getRoute() const
Returns the current route.
Definition: MSBaseVehicle.h:115
ConstMSEdgeVector
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:75
MSRailSignal::init
void init(NLDetectorBuilder &nb)
Initialises the rail signal with information about adjacent rail signals.
Definition: MSRailSignal.cpp:89
MSRailSignal::getPhaseNumber
int getPhaseNumber() const
Returns the number of phases.
Definition: MSRailSignal.cpp:180
MSRoute::getEdges
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:120
MSTrafficLightLogic::adaptLinkInformationFrom
virtual void adaptLinkInformationFrom(const MSTrafficLightLogic &logic)
Applies information about controlled links and lanes from the given logic.
Definition: MSTrafficLightLogic.cpp:214
SUMO_ATTR_ID
@ SUMO_ATTR_ID
Definition: SUMOXMLDefinitions.h:378
MSEdge.h
MSRailSignal::getPhases
const Phases & getPhases() const
Returns the phases of this tls program.
Definition: MSRailSignal.cpp:185
TLTYPE_RAIL_SIGNAL
@ TLTYPE_RAIL_SIGNAL
Definition: SUMOXMLDefinitions.h:1199
MSRailSignal::DriveWay::overlap
bool overlap(const DriveWay &other) const
Wether this driveway overlaps with the given one.
Definition: MSRailSignal.cpp:685
MSLane::getBidiLane
MSLane * getBidiLane() const
retrieve bidirectional lane or nullptr
Definition: MSLane.cpp:3706
MSRailSignal::getTLLinkID
static std::string getTLLinkID(MSLink *link)
return logicID_linkIndex
Definition: MSRailSignal.cpp:231
MSRailSignal::DriveWay::findFlankProtection
void findFlankProtection(MSLink *link, double length, LaneSet &visited, MSLink *origLink)
find upstream protection from the given link
Definition: MSRailSignal.cpp:868
MSRailSignal::DriveWay::myFlank
std::vector< const MSLane * > myFlank
Definition: MSRailSignal.h:252
MSEdge::isNormal
bool isNormal() const
return whether this edge is an internal edge
Definition: MSEdge.h:230
MSTrafficLightLogic::addLink
virtual void addLink(MSLink *link, MSLane *lane, int pos)
Adds a link on building.
Definition: MSTrafficLightLogic.cpp:196
MSJunction::getIncoming
const ConstMSEdgeVector & getIncoming() const
Definition: MSJunction.h:101
MSLane::getIncomingLanes
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
Definition: MSLane.h:818
MSPhaseDefinition::setState
void setState(const std::string &_state)
Definition: MSPhaseDefinition.h:203
MSVehicle.h
OutputDevice::closeTag
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
Definition: OutputDevice.cpp:253
MSRailSignal::LaneSet
std::set< const MSLane *, ComparatorNumericalIdLess > LaneSet
Definition: MSRailSignal.h:211
SUMO_ATTR_TO
@ SUMO_ATTR_TO
Definition: SUMOXMLDefinitions.h:640
MSRailSignal::DriveWay::checkCrossingFlanks
void checkCrossingFlanks(MSLink *dwLink, const LaneSet &visited)
find links that cross the driveway without entering it
Definition: MSRailSignal.cpp:836
MAX2
T MAX2(T a, T b)
Definition: StdDefs.h:79
MSTrafficLightLogic.h
MSRailSignal::adaptLinkInformationFrom
void adaptLinkInformationFrom(const MSTrafficLightLogic &logic)
Applies information about controlled links and lanes from the given logic.
Definition: MSRailSignal.cpp:109
LINKDIR_TURN
@ LINKDIR_TURN
The link is a 180 degree turn.
Definition: SUMOXMLDefinitions.h:1180
SUMOVehicle::getRoute
virtual const MSRoute & getRoute() const =0
Returns the current route.
OutputDevice::writeAttr
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:255
MSRailSignal::DriveWay::conflictLinkApproached
bool conflictLinkApproached() const
Whether any of the conflict linkes have approaching vehicles.
Definition: MSRailSignal.cpp:531
MSRailSignal::getClosest
static Approaching getClosest(MSLink *link)
get the closest vehicle approaching the given link
Definition: MSRailSignal.cpp:250
MSEdge::getFromJunction
const MSJunction * getFromJunction() const
Definition: MSEdge.h:359
MSRailSignal::getClickableTLLinkID
static std::string getClickableTLLinkID(MSLink *link)
return logicID_linkIndex in a way that allows clicking in sumo-gui
Definition: MSRailSignal.cpp:236
NODETYPE_RAIL_SIGNAL
@ NODETYPE_RAIL_SIGNAL
Definition: SUMOXMLDefinitions.h:1059
MSJunctionLogic
Definition: MSJunctionLogic.h:38
SIMTIME
#define SIMTIME
Definition: SUMOTime.h:63
MSRoutingEngine::reroute
static void reroute(SUMOVehicle &vehicle, const SUMOTime currentTime, const std::string &info, const bool onInit=false, const bool silent=false, const MSEdgeVector &prohibited=MSEdgeVector())
initiate the rerouting, create router / thread pool on first use
Definition: MSRoutingEngine.cpp:269
MSRailSignal::getCurrentPhaseIndex
int getCurrentPhaseIndex() const
Returns the current index within the program.
Definition: MSRailSignal.cpp:196
MSRailSignal::describeLinks
static std::string describeLinks(std::vector< MSLink * > links)
print link descriptions
Definition: MSRailSignal.cpp:241
MSPhaseDefinition::getState
const std::string & getState() const
Returns the state within this phase.
Definition: MSPhaseDefinition.h:199
MSRailSignal::Approaching
std::pair< const SUMOVehicle *const, const MSLink::ApproachingVehicleInformation > Approaching
Definition: MSRailSignal.h:210
MSNet::getCurrentTimeStep
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:283
SUMOVehicle::getDevice
virtual MSVehicleDevice * getDevice(const std::type_info &type) const =0
Returns a device of the given type if it exists or 0.
joinNamedToString
std::string joinNamedToString(const std::set< T *, C > &ns, const T_BETWEEN &between)
Definition: ToString.h:280
MSRailSignal
A signal for rails.
Definition: MSRailSignal.h:46
SUMO_ATTR_EDGES
@ SUMO_ATTR_EDGES
the edges of a route
Definition: SUMOXMLDefinitions.h:427
MSLane::getLength
double getLength() const
Returns the lane's length.
Definition: MSLane.h:540
MSRailSignal::DriveWay::checkFlanks
void checkFlanks(const std::vector< MSLane * > &lanes, const LaneSet &visited, bool allFoes)
find switches that threathen this driveway
Definition: MSRailSignal.cpp:812
MSRailSignal::DriveWay::findProtection
bool findProtection(const Approaching &veh, MSLink *link) const
find protection for the given vehicle starting at a switch
Definition: MSRailSignal.cpp:624
MSRailSignal::writeBlocks
void writeBlocks(OutputDevice &od) const
write rail signal block output for all links and driveways
Definition: MSRailSignal.cpp:277
ProcessError
Definition: UtilExceptions.h:39
isRailway
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permission is a railway edge.
Definition: SUMOVehicleClass.cpp:363
MSRailSignal::myCurrentPhase
MSPhaseDefinition myCurrentPhase
The current phase.
Definition: MSRailSignal.h:369
MSJunction::getLogic
virtual const MSJunctionLogic * getLogic() const
Definition: MSJunction.h:134
MSRailSignal::addLink
void addLink(MSLink *link, MSLane *lane, int pos)
Adds a link on building.
Definition: MSRailSignal.cpp:223
MSRailSignal::DriveWay::myRoute
std::vector< const MSEdge * > myRoute
list of lanes for matching against train routes
Definition: MSRailSignal.h:239
MSDevice_Routing.h
MSEdge::getBidiEdge
const MSEdge * getBidiEdge() const
return opposite superposable/congruent edge, if it exist and 0 else
Definition: MSEdge.h:249
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:78
MSRailSignal::~MSRailSignal
~MSRailSignal()
Destructor.
Definition: MSRailSignal.cpp:103
FXWorkerThread.h
MSJunction::getType
SumoXMLNodeType getType() const
return the type of this Junction
Definition: MSJunction.h:126
MSTrafficLightLogic
The parent class for traffic light logics.
Definition: MSTrafficLightLogic.h:55
MSEdge::getToJunction
const MSJunction * getToJunction() const
Definition: MSEdge.h:363
MSRoutingEngine.h
MSLane::getLinkCont
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.cpp:2110
SUMO_ATTR_FROM
@ SUMO_ATTR_FROM
Definition: SUMOXMLDefinitions.h:639
SUMO_ATTR_LANES
@ SUMO_ATTR_LANES
Definition: SUMOXMLDefinitions.h:638
MSLane::getEdge
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:669
MSRailSignal::myPhases
Phases myPhases
The list of phases this logic uses.
Definition: MSRailSignal.h:366
MSEdgeControl.h
OutputDevice::openTag
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
Definition: OutputDevice.cpp:239
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:47
MSNet::getInstance
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:167
SUMO_ATTR_TLLINKINDEX
@ SUMO_ATTR_TLLINKINDEX
link: the index of the link within the traffic light
Definition: SUMOXMLDefinitions.h:686
SUMO_MAX_CONNECTIONS
#define SUMO_MAX_CONNECTIONS
the maximum number of connections across an intersection
Definition: StdDefs.h:42
gDebugFlag4
bool gDebugFlag4
Definition: StdDefs.cpp:35
MSEdgeVector
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:74
MSBaseVehicle::getCurrentRouteEdge
const MSRouteIterator & getCurrentRouteEdge() const
Returns an iterator pointing to the current edge in this vehicles route.
Definition: MSBaseVehicle.h:205
MAX_BLOCK_LENGTH
#define MAX_BLOCK_LENGTH
Definition: MSRailSignal.cpp:54
MSRailSignal::MSRailSignal
MSRailSignal(MSTLLogicControl &tlcontrol, const std::string &id, const std::string &programID, SUMOTime delay, const std::map< std::string, std::string > &parameters)
Constructor.
Definition: MSRailSignal.cpp:79
MSRailSignal::DriveWay::conflictLaneOccupied
bool conflictLaneOccupied() const
whether any of myConflictLanes is occupied
Definition: MSRailSignal.cpp:608
MSRailSignal::DriveWay::myFlankSwitches
std::vector< MSLink * > myFlankSwitches
Definition: MSRailSignal.h:259
joinToString
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:246
MSPhaseDefinition.h
MSRailSignal::hasOncomingRailTraffic
static bool hasOncomingRailTraffic(MSLink *link)
Definition: MSRailSignal.cpp:296
config.h
MSLane::getFirstAnyVehicle
MSVehicle * getFirstAnyVehicle() const
returns the first vehicle that is fully or partially on this lane
Definition: MSLane.cpp:2047
Named::getIDSecure
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
Definition: Named.h:69
MSTrafficLightLogic::myDefaultCycleTime
SUMOTime myDefaultCycleTime
The cycle time (without changes)
Definition: MSTrafficLightLogic.h:432
MSLane::isInternal
bool isInternal() const
Definition: MSLane.cpp:2010
MSRailSignal::updateCurrentPhase
void updateCurrentPhase()
returns the state of the signal that actually required
Definition: MSRailSignal.cpp:125
DEBUG_COND_LINKINFO
#define DEBUG_COND_LINKINFO
Definition: MSRailSignal.cpp:66
MSTLLogicControl
A class that stores and controls tls and switching of their programs.
Definition: MSTLLogicControl.h:59
MSRailSignal::DriveWay::reserve
bool reserve(const Approaching &closest, MSEdgeVector &occupied)
attempt reserve this driveway for the given vehicle
Definition: MSRailSignal.cpp:491
LINKSTATE_TL_RED
@ LINKSTATE_TL_RED
The link has red light (must brake)
Definition: SUMOXMLDefinitions.h:1143
OutputDevice_COUT.h
MSRailSignal::myLinkInfos
std::vector< LinkInfo > myLinkInfos
data storage for every link at this node (more than one when directly guarding a switch)
Definition: MSRailSignal.h:346
MSEventControl.h
MSLane.h
MSPhaseDefinition
The definition of a single phase of a tls logic.
Definition: MSPhaseDefinition.h:51
MSRailSignal::getCurrentPhaseDef
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
Definition: MSRailSignal.cpp:201
MSRailSignal::DriveWay::myForward
std::vector< MSLane * > myForward
Definition: MSRailSignal.h:243
MSRailSignal::DriveWay
Definition: MSRailSignal.h:220
MSRailSignal::myNumWarnings
static int myNumWarnings
Definition: MSRailSignal.h:374
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
MSRailSignal::DriveWay::writeBlocks
void writeBlocks(OutputDevice &od) const
Write block items for this driveway.
Definition: MSRailSignal.cpp:699
MSRailSignal::getPhase
const MSPhaseDefinition & getPhase(int givenstep) const
Returns the definition of the phase from the given position within the plan.
Definition: MSRailSignal.cpp:190
NLDetectorBuilder
Builds detectors for microsim.
Definition: NLDetectorBuilder.h:55
MSJunctionLogic::getFoesFor
virtual const MSLogicJunction::LinkBits & getFoesFor(int linkIndex) const
Returns the foes for the given link.
Definition: MSJunctionLogic.h:53
MSRailSignal::DriveWay::myConflictLinks
std::vector< MSLink * > myConflictLinks
Definition: MSRailSignal.h:270
MSVehicle
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:79
MSRailSignal.h