SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MSRouteHandler.cpp
Go to the documentation of this file.
1 /****************************************************************************/
10 // Parser and container for routes during their loading
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <string>
35 #include <map>
36 #include <vector>
37 #include <microsim/MSRoute.h>
38 #include <microsim/MSEdge.h>
39 #include <microsim/MSJunction.h>
40 #include <microsim/MSVehicleType.h>
41 #include <microsim/MSVehicle.h>
44 #include <microsim/MSLane.h>
45 #include "MSRouteHandler.h"
46 #include "MSPersonControl.h"
47 #include "MSContainerControl.h"
55 #include "MSNet.h"
56 
58 //#include <microsim/trigger/MSContainerStop.h>
59 #include <microsim/MSGlobals.h>
61 
62 #ifdef CHECK_MEMORY_LEAKS
63 #include <foreign/nvwa/debug_new.h>
64 #endif // CHECK_MEMORY_LEAKS
65 
66 
67 // ===========================================================================
68 // static members
69 // ===========================================================================
71 
72 
73 // ===========================================================================
74 // method definitions
75 // ===========================================================================
76 MSRouteHandler::MSRouteHandler(const std::string& file,
77  bool addVehiclesDirectly) :
78  SUMORouteHandler(file),
79  myActivePlan(0),
80  myActiveContainerPlan(0),
81  myAddVehiclesDirectly(addVehiclesDirectly),
82  myCurrentVTypeDistribution(0),
83  myCurrentRouteDistribution(0) {
84  myActiveRoute.reserve(100);
85 }
86 
87 
89 }
90 
91 
92 void
93 MSRouteHandler::parseFromViaTo(std::string element,
94  const SUMOSAXAttributes& attrs) {
95  myActiveRoute.clear();
96  bool useTaz = OptionsCont::getOptions().getBool("with-taz");
98  WRITE_WARNING("Taz usage was requested but no taz present in " + element + " '" + myVehicleParameter->id + "'!");
99  useTaz = false;
100  }
101  bool ok = true;
103  const MSEdge* fromTaz = MSEdge::dictionary(myVehicleParameter->fromTaz + "-source");
104  if (fromTaz == 0) {
105  throw ProcessError("Source taz '" + myVehicleParameter->fromTaz + "' not known for " + element + " '" + myVehicleParameter->id + "'!");
106  } else if (fromTaz->getNumSuccessors() == 0) {
107  throw ProcessError("Source taz '" + myVehicleParameter->fromTaz + "' has no outgoing edges for " + element + " '" + myVehicleParameter->id + "'!");
108  } else {
109  myActiveRoute.push_back(fromTaz);
110  }
111  } else {
112  MSEdge::parseEdgesList(attrs.getOpt<std::string>(SUMO_ATTR_FROM, myVehicleParameter->id.c_str(), ok, "", true),
113  myActiveRoute, "for " + element + " '" + myVehicleParameter->id + "'");
114  }
115  if (!attrs.hasAttribute(SUMO_ATTR_VIA) && !attrs.hasAttribute(SUMO_ATTR_ROUTE)) {
116  myInsertStopEdgesAt = (int)myActiveRoute.size();
117  }
118  MSEdge::parseEdgesList(attrs.getOpt<std::string>(SUMO_ATTR_VIA, myVehicleParameter->id.c_str(), ok, "", true),
119  myActiveRoute, "for " + element + " '" + myVehicleParameter->id + "'");
121  const MSEdge* toTaz = MSEdge::dictionary(myVehicleParameter->toTaz + "-sink");
122  if (toTaz == 0) {
123  throw ProcessError("Sink taz '" + myVehicleParameter->toTaz + "' not known for " + element + " '" + myVehicleParameter->id + "'!");
124  } else if (toTaz->getNumPredecessors() == 0) {
125  throw ProcessError("Sink taz '" + myVehicleParameter->toTaz + "' has no incoming edges for " + element + " '" + myVehicleParameter->id + "'!");
126  } else {
127  myActiveRoute.push_back(toTaz);
128  }
129  } else {
130  MSEdge::parseEdgesList(attrs.getOpt<std::string>(SUMO_ATTR_TO, myVehicleParameter->id.c_str(), ok, "", true),
131  myActiveRoute, "for " + element + " '" + myVehicleParameter->id + "'");
132  }
134  if (myVehicleParameter->routeid == "") {
136  }
137 }
138 
139 
140 void
142  const SUMOSAXAttributes& attrs) {
143  SUMORouteHandler::myStartElement(element, attrs);
144  switch (element) {
145  case SUMO_TAG_PERSON:
147  break;
148  case SUMO_TAG_CONTAINER:
150  break;
151  case SUMO_TAG_RIDE: {
152  const std::string pid = myVehicleParameter->id;
153  bool ok = true;
154  MSEdge* from = 0;
155  const std::string desc = attrs.get<std::string>(SUMO_ATTR_LINES, pid.c_str(), ok);
156  StringTokenizer st(desc);
157  std::string bsID = attrs.getOpt<std::string>(SUMO_ATTR_BUS_STOP, 0, ok, "");
158  MSBusStop* bs = 0;
159  if (bsID != "") {
160  bs = MSNet::getInstance()->getBusStop(bsID);
161  if (bs == 0) {
162  throw ProcessError("Unknown bus stop '" + bsID + "' for person '" + myVehicleParameter->id + "'.");
163  }
164  }
165  if (attrs.hasAttribute(SUMO_ATTR_FROM)) {
166  const std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, pid.c_str(), ok);
167  from = MSEdge::dictionary(fromID);
168  if (from == 0) {
169  throw ProcessError("The from edge '" + fromID + "' within a ride of person '" + pid + "' is not known.");
170  }
171  if (!myActivePlan->empty() && &myActivePlan->back()->getDestination() != from) {
172  throw ProcessError("Disconnected plan for person '" + myVehicleParameter->id + "' (" + fromID + "!=" + myActivePlan->back()->getDestination().getID() + ").");
173  }
174  if (myActivePlan->empty()) {
176  *from, -1, myVehicleParameter->depart, myVehicleParameter->departPos, "start"));
177  }
178  } else if (myActivePlan->empty()) {
179  throw ProcessError("The start edge within for person '" + pid + "' is not known.");
180  }
181  const std::string toID = attrs.get<std::string>(SUMO_ATTR_TO, pid.c_str(), ok);
182  MSEdge* to = MSEdge::dictionary(toID);
183  if (to == 0) {
184  throw ProcessError("The to edge '" + toID + "' within a ride of person '" + pid + "' is not known.");
185  }
186  myActivePlan->push_back(new MSPerson::MSPersonStage_Driving(*to, bs, st.getVector()));
187  break;
188  }
189  case SUMO_TAG_WALK: {
190  myActiveRoute.clear();
191  bool ok = true;
192  SUMOReal departPos = attrs.getOpt<SUMOReal>(SUMO_ATTR_DEPARTPOS, myVehicleParameter->id.c_str(), ok, 0);
193  SUMOReal arrivalPos = attrs.getOpt<SUMOReal>(SUMO_ATTR_ARRIVALPOS, myVehicleParameter->id.c_str(), ok, -NUMERICAL_EPS);
194  const SUMOTime duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, 0, ok, -1);
195  if (attrs.hasAttribute(SUMO_ATTR_DURATION) && duration <= 0) {
196  throw ProcessError("Non-positive walking duration for '" + myVehicleParameter->id + "'.");
197  }
200  // need to check for explicitly set speed since we might have // DEFAULT_VEHTYPE
201  if (vtype != 0 && vtype->wasSet(VTYPEPARS_MAXSPEED_SET)) {
202  speed = vtype->getMaxSpeed();
203  }
204  speed = attrs.getOpt<SUMOReal>(SUMO_ATTR_SPEED, 0, ok, speed);
205  if (speed <= 0) {
206  throw ProcessError("Non-positive walking speed for '" + myVehicleParameter->id + "'.");
207  }
208  std::string bsID = attrs.getOpt<std::string>(SUMO_ATTR_BUS_STOP, 0, ok, "");
209  MSBusStop* bs = 0;
210  if (bsID != "") {
211  bs = MSNet::getInstance()->getBusStop(bsID);
212  if (bs == 0) {
213  throw ProcessError("Unknown bus stop '" + bsID + "' for person '" + myVehicleParameter->id + "'.");
214  }
215  arrivalPos = bs->getEndLanePosition();
216  }
217  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
219  } else {
220  if (attrs.hasAttribute(SUMO_ATTR_FROM) && attrs.hasAttribute(SUMO_ATTR_TO)) {
221  const std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, myVehicleParameter->id.c_str(), ok);
222  MSEdge* from = MSEdge::dictionary(fromID);
223  if (from == 0) {
224  throw ProcessError("The from edge '" + fromID + "' within a walk of person '" + myVehicleParameter->id + "' is not known.");
225  }
226  const std::string toID = attrs.get<std::string>(SUMO_ATTR_TO, myVehicleParameter->id.c_str(), ok);
227  MSEdge* to = MSEdge::dictionary(toID);
228  if (to == 0) {
229  throw ProcessError("The to edge '" + toID + "' within a walk of person '" + myVehicleParameter->id + "' is not known.");
230  }
232  SUMOVehicleParameter::interpretEdgePos(departPos, from->getLength(), SUMO_ATTR_DEPARTPOS, "person walking from " + from->getID()),
233  SUMOVehicleParameter::interpretEdgePos(arrivalPos, to->getLength(), SUMO_ATTR_ARRIVALPOS, "person walking to " + to->getID()),
234  speed, 0, 0, myActiveRoute);
235  if (myActiveRoute.empty()) {
236  const std::string error = "No connection found between '" + from->getID() + "' and '" + to->getID() + "' for person '" + myVehicleParameter->id + "'.";
237  if (OptionsCont::getOptions().getBool("ignore-route-errors")) {
238  myActiveRoute.push_back(from);
239  myActiveRoute.push_back(to); // pedestrian will teleport
240  //WRITE_WARNING(error);
241  } else {
242  WRITE_ERROR(error);
243  }
244  }
245  //std::cout << myVehicleParameter->id << " edges=" << toString(myActiveRoute) << "\n";
246  }
247  }
248  if (myActiveRoute.empty()) {
249  throw ProcessError("No edges to walk for person '" + myVehicleParameter->id + "'.");
250  }
251  if (!myActivePlan->empty() && &myActivePlan->back()->getDestination() != myActiveRoute.front()) {
252  throw ProcessError("Disconnected plan for person '" + myVehicleParameter->id + "' (" + myActiveRoute.front()->getID() + "!=" + myActivePlan->back()->getDestination().getID() + ").");
253  }
254  if (myActivePlan->empty()) {
256  *myActiveRoute.front(), -1, myVehicleParameter->depart, departPos, "start"));
257  }
258  myActivePlan->push_back(new MSPerson::MSPersonStage_Walking(myActiveRoute, bs, duration, speed, departPos, arrivalPos));
259  myActiveRoute.clear();
260  break;
261  }
262  case SUMO_TAG_TRANSPORT: {
263  const std::string containerId = myVehicleParameter->id;
264  bool ok = true;
265  MSEdge* from = 0;
266  const std::string desc = attrs.get<std::string>(SUMO_ATTR_LINES, containerId.c_str(), ok);
267  StringTokenizer st(desc);
268  std::string csID = attrs.getOpt<std::string>(SUMO_ATTR_CONTAINER_STOP, 0, ok, "");
269  MSContainerStop* cs = 0;
270  if (csID != "") {
271  cs = MSNet::getInstance()->getContainerStop(csID);
272  if (cs == 0) {
273  throw ProcessError("Unknown container stop '" + csID + "' for container '" + myVehicleParameter->id + "'.");
274  }
275  }
276  if (attrs.hasAttribute(SUMO_ATTR_FROM)) {
277  const std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, containerId.c_str(), ok);
278  from = MSEdge::dictionary(fromID);
279  if (from == 0) {
280  throw ProcessError("The from edge '" + fromID + "' within a transport of container '" + containerId + "' is not known.");
281  }
282  if (!myActiveContainerPlan->empty() && &myActiveContainerPlan->back()->getDestination() != from) {
283  throw ProcessError("Disconnected plan for container '" + myVehicleParameter->id + "' (" + fromID + "!=" + myActiveContainerPlan->back()->getDestination().getID() + ").");
284  }
285  if (myActiveContainerPlan->empty()) {
287  *from, -1, myVehicleParameter->depart, myVehicleParameter->departPos, "start"));
288  }
289  } else if (myActiveContainerPlan->empty()) {
290  throw ProcessError("The start edge within a transport of container '" + containerId + "' is not known.");
291  }
292  const std::string toID = attrs.get<std::string>(SUMO_ATTR_TO, containerId.c_str(), ok);
293  MSEdge* to = MSEdge::dictionary(toID);
294  if (to == 0) {
295  throw ProcessError("The to edge '" + toID + "' within a transport of container '" + containerId + "' is not known.");
296  }
297  myActiveContainerPlan->push_back(new MSContainer::MSContainerStage_Driving(*to, cs, st.getVector()));
298  break;
299  }
300  case SUMO_TAG_TRANSHIP: {
301  myActiveRoute.clear();
302  bool ok = true;
303  SUMOReal departPos = attrs.getOpt<SUMOReal>(SUMO_ATTR_DEPARTPOS, myVehicleParameter->id.c_str(), ok, 0);
304  SUMOReal arrivalPos = attrs.getOpt<SUMOReal>(SUMO_ATTR_ARRIVALPOS, myVehicleParameter->id.c_str(), ok, -NUMERICAL_EPS);
307  // need to check for explicitly set speed since we might have // DEFAULT_VEHTYPE
308  if (vtype != 0 && vtype->wasSet(VTYPEPARS_MAXSPEED_SET)) {
309  speed = vtype->getMaxSpeed();
310  }
311  speed = attrs.getOpt<SUMOReal>(SUMO_ATTR_SPEED, 0, ok, speed);
312  if (speed <= 0) {
313  throw ProcessError("Non-positive tranship speed for container '" + myVehicleParameter->id + "'.");
314  }
315  std::string csID = attrs.getOpt<std::string>(SUMO_ATTR_CONTAINER_STOP, 0, ok, "");
316  MSContainerStop* cs = 0;
317  if (csID != "") {
318  cs = MSNet::getInstance()->getContainerStop(csID);
319  if (cs == 0) {
320  throw ProcessError("Unknown container stop '" + csID + "' for container '" + myVehicleParameter->id + "'.");
321  }
322  arrivalPos = cs->getEndLanePosition();
323  }
324  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
326  } else {
327  if (attrs.hasAttribute(SUMO_ATTR_FROM) && attrs.hasAttribute(SUMO_ATTR_TO)) {
328  const std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, myVehicleParameter->id.c_str(), ok);
329  MSEdge* from = MSEdge::dictionary(fromID);
330  if (from == 0) {
331  throw ProcessError("The from edge '" + fromID + "' within a tranship of container '" + myVehicleParameter->id + "' is not known.");
332  }
333  const std::string toID = attrs.get<std::string>(SUMO_ATTR_TO, myVehicleParameter->id.c_str(), ok);
334  MSEdge* to = MSEdge::dictionary(toID);
335  if (to == 0) {
336  throw ProcessError("The to edge '" + toID + "' within a tranship of container '" + myVehicleParameter->id + "' is not known.");
337  }
338  //the route of the container's tranship stage consists only of the 'from' and the 'to' edge
339  myActiveRoute.push_back(from);
340  myActiveRoute.push_back(to);
341  if (myActiveRoute.empty()) {
342  const std::string error = "No connection found between '" + from->getID() + "' and '" + to->getID() + "' for container '" + myVehicleParameter->id + "'.";
343  if (OptionsCont::getOptions().getBool("ignore-route-errors")) {
344  myActiveRoute.push_back(from);
345  } else {
346  WRITE_ERROR(error);
347  }
348  }
349  }
350  }
351  if (myActiveRoute.empty()) {
352  throw ProcessError("No edges to tranship container '" + myVehicleParameter->id + "'.");
353  }
354  if (!myActiveContainerPlan->empty() && &myActiveContainerPlan->back()->getDestination() != myActiveRoute.front()) {
355  throw ProcessError("Disconnected plan for container '" + myVehicleParameter->id + "' (" + myActiveRoute.front()->getID() + "!=" + myActiveContainerPlan->back()->getDestination().getID() + ").");
356  }
357  if (myActiveContainerPlan->empty()) {
359  *myActiveRoute.front(), -1, myVehicleParameter->depart, departPos, "start"));
360  }
361  myActiveContainerPlan->push_back(new MSContainer::MSContainerStage_Tranship(myActiveRoute, cs, speed, departPos, arrivalPos));
362  myActiveRoute.clear();
363  break;
364  }
365  case SUMO_TAG_FLOW:
366  parseFromViaTo("flow", attrs);
367  break;
368  case SUMO_TAG_TRIP:
369  parseFromViaTo("trip", attrs);
370  break;
371  default:
372  break;
373  }
374  // parse embedded vtype information
375  if (myCurrentVType != 0 && element != SUMO_TAG_VTYPE && element != SUMO_TAG_PARAM) {
377  return;
378  }
379 }
380 
381 
382 void
384  bool ok = true;
385  myCurrentVTypeDistributionID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
386  if (ok) {
388  if (attrs.hasAttribute(SUMO_ATTR_VTYPES)) {
389  const std::string vTypes = attrs.get<std::string>(SUMO_ATTR_VTYPES, myCurrentVTypeDistributionID.c_str(), ok);
390  StringTokenizer st(vTypes);
391  while (st.hasNext()) {
392  std::string vtypeID = st.next();
394  if (type == 0) {
395  throw ProcessError("Unknown vtype '" + vtypeID + "' in distribution '" + myCurrentVTypeDistributionID + "'.");
396  }
398  }
399  }
400  }
401 }
402 
403 
404 void
406  if (myCurrentVTypeDistribution != 0) {
407  if (MSGlobals::gStateLoaded && MSNet::getInstance()->getVehicleControl().hasVTypeDistribution(myCurrentVTypeDistributionID)) {
409  return;
410  }
413  throw ProcessError("Vehicle type distribution '" + myCurrentVTypeDistributionID + "' is empty.");
414  }
415  if (!MSNet::getInstance()->getVehicleControl().addVTypeDistribution(myCurrentVTypeDistributionID, myCurrentVTypeDistribution)) {
417  throw ProcessError("Another vehicle type (or distribution) with the id '" + myCurrentVTypeDistributionID + "' exists.");
418  }
420  }
421 }
422 
423 
424 void
426  myActiveRoute.clear();
427  myInsertStopEdgesAt = -1;
428  // check whether the id is really necessary
429  std::string rid;
430  if (myCurrentRouteDistribution != 0) {
432  rid = "distribution '" + myCurrentRouteDistributionID + "'";
433  } else if (myVehicleParameter != 0) {
434  // ok, a vehicle is wrapping the route,
435  // we may use this vehicle's id as default
436  myActiveRouteID = "!" + myVehicleParameter->id; // !!! document this
437  if (attrs.hasAttribute(SUMO_ATTR_ID)) {
438  WRITE_WARNING("Ids of internal routes are ignored (vehicle '" + myVehicleParameter->id + "').");
439  }
440  } else {
441  bool ok = true;
442  myActiveRouteID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok, false);
443  if (!ok) {
444  return;
445  }
446  rid = "'" + myActiveRouteID + "'";
447  }
448  if (myVehicleParameter != 0) { // have to do this here for nested route distributions
449  rid = "for vehicle '" + myVehicleParameter->id + "'";
450  }
451  bool ok = true;
452  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
453  MSEdge::parseEdgesList(attrs.get<std::string>(SUMO_ATTR_EDGES, myActiveRouteID.c_str(), ok), myActiveRoute, rid);
454  }
455  myActiveRouteRefID = attrs.getOpt<std::string>(SUMO_ATTR_REFID, myActiveRouteID.c_str(), ok, "");
457  WRITE_ERROR("Invalid reference to route '" + myActiveRouteRefID + "' in route " + rid + ".");
458  }
461  myCurrentCosts = attrs.getOpt<SUMOReal>(SUMO_ATTR_COST, myActiveRouteID.c_str(), ok, -1);
462  if (ok && myCurrentCosts != -1 && myCurrentCosts < 0) {
463  WRITE_ERROR("Invalid cost for route '" + myActiveRouteID + "'.");
464  }
465 }
466 
467 
468 void
471  switch (element) {
472  case SUMO_TAG_VTYPE: {
474  delete myCurrentVType;
475  myCurrentVType = 0;
476  if (!MSNet::getInstance()->getVehicleControl().addVType(vehType)) {
477  const std::string id = vehType->getID();
478  delete vehType;
480  throw ProcessError("Another vehicle type (or distribution) with the id '" + id + "' exists.");
481  }
482  } else {
483  if (myCurrentVTypeDistribution != 0) {
485  }
486  }
487  }
488  break;
489  case SUMO_TAG_TRIP:
491  closeRoute(true);
492  closeVehicle();
493  delete myVehicleParameter;
494  myVehicleParameter = 0;
495  myInsertStopEdgesAt = -1;
496  break;
497  default:
498  break;
499  }
500 }
501 
502 
503 void
504 MSRouteHandler::closeRoute(const bool mayBeDisconnected) {
505  std::string type = "vehicle";
506  if (mayBeDisconnected) {
508  type = "flow";
509  } else {
510  type = "trip";
511  }
512  }
513  if (myActiveRoute.size() == 0) {
514  delete myActiveRouteColor;
515  myActiveRouteColor = 0;
518  if (route != 0) {
520  route->addReference();
521  }
522  }
523  myActiveRouteID = "";
524  myActiveRouteRefID = "";
525  return;
526  }
527  if (myVehicleParameter != 0) {
528  throw ProcessError("The route for " + type + " '" + myVehicleParameter->id + "' has no edges.");
529  } else {
530  throw ProcessError("Route '" + myActiveRouteID + "' has no edges.");
531  }
532  }
533  if (myActiveRoute.size() == 1 && myActiveRoute.front()->getPurpose() == MSEdge::EDGEFUNCTION_DISTRICT) {
534  throw ProcessError("The routing information for " + type + " '" + myVehicleParameter->id + "' is insufficient.");
535  }
539  route->setCosts(myCurrentCosts);
540  myActiveRoute.clear();
541  if (!MSRoute::dictionary(myActiveRouteID, route)) {
542  delete route;
544  if (myVehicleParameter != 0) {
545  if (MSNet::getInstance()->getVehicleControl().getVehicle(myVehicleParameter->id) == 0) {
546  throw ProcessError("Another route for " + type + " '" + myVehicleParameter->id + "' exists.");
547  } else {
548  throw ProcessError("A vehicle with id '" + myVehicleParameter->id + "' already exists.");
549  }
550  } else {
551  throw ProcessError("Another route (or distribution) with the id '" + myActiveRouteID + "' exists.");
552  }
553  }
554  } else {
555  if (myCurrentRouteDistribution != 0) {
557  route->addReference();
558  }
559  }
560  }
561  myActiveRouteID = "";
562  myActiveRouteColor = 0;
563  myActiveRouteStops.clear();
564 }
565 
566 
567 void
569  // check whether the id is really necessary
570  bool ok = true;
571  if (myVehicleParameter != 0) {
572  // ok, a vehicle is wrapping the route,
573  // we may use this vehicle's id as default
574  myCurrentRouteDistributionID = "!" + myVehicleParameter->id; // !!! document this
575  } else {
576  myCurrentRouteDistributionID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
577  if (!ok) {
578  return;
579  }
580  }
582  std::vector<SUMOReal> probs;
583  if (attrs.hasAttribute(SUMO_ATTR_PROBS)) {
584  bool ok = true;
585  StringTokenizer st(attrs.get<std::string>(SUMO_ATTR_PROBS, myCurrentRouteDistributionID.c_str(), ok));
586  while (st.hasNext()) {
587  probs.push_back(TplConvert::_2SUMORealSec(st.next().c_str(), 1.0));
588  }
589  }
590  if (attrs.hasAttribute(SUMO_ATTR_ROUTES)) {
591  bool ok = true;
592  StringTokenizer st(attrs.get<std::string>(SUMO_ATTR_ROUTES, myCurrentRouteDistributionID.c_str(), ok));
593  size_t probIndex = 0;
594  while (st.hasNext()) {
595  std::string routeID = st.next();
596  const MSRoute* route = MSRoute::dictionary(routeID, &myParsingRNG);
597  if (route == 0) {
598  throw ProcessError("Unknown route '" + routeID + "' in distribution '" + myCurrentRouteDistributionID + "'.");
599  }
600  const SUMOReal prob = (probs.size() > probIndex ? probs[probIndex] : 1.0);
601  if (myCurrentRouteDistribution->add(prob, route, false)) {
602  route->addReference();
603  }
604  probIndex++;
605  }
606  if (probs.size() > 0 && probIndex != probs.size()) {
607  WRITE_WARNING("Got " + toString(probs.size()) + " probabilities for " + toString(probIndex) +
608  " routes in routeDistribution '" + myCurrentRouteDistributionID + "'");
609  }
610  }
611 }
612 
613 
614 void
616  if (myCurrentRouteDistribution != 0) {
617  const bool haveSameID = MSRoute::dictionary(myCurrentRouteDistributionID, &myParsingRNG) != 0;
618  if (MSGlobals::gStateLoaded && haveSameID) {
620  return;
621  }
622  if (haveSameID) {
624  throw ProcessError("Another route (or distribution) with the id '" + myCurrentRouteDistributionID + "' exists.");
625  }
628  throw ProcessError("Route distribution '" + myCurrentRouteDistributionID + "' is empty.");
629  }
632  }
633 }
634 
635 
636 void
638  // get nested route
642  // let's check whether this vehicle had to depart before the simulation starts
644  if (route != 0) {
645  route->addReference();
646  route->release();
647  }
648  return;
649  }
650  }
651  // get the vehicle's type
652  MSVehicleType* vtype = 0;
653  if (myVehicleParameter->vtypeid != "") {
654  vtype = vehControl.getVType(myVehicleParameter->vtypeid, &myParsingRNG);
655  if (vtype == 0) {
656  throw ProcessError("The vehicle type '" + myVehicleParameter->vtypeid + "' for vehicle '" + myVehicleParameter->id + "' is not known.");
657  }
658  } else {
659  // there should be one (at least the default one)
660  vtype = vehControl.getVType(DEFAULT_VTYPE_ID, &myParsingRNG);
661  }
662  if (route == 0) {
663  // if there is no nested route, try via the (hopefully) given route-id
665  }
666  if (route == 0) {
667  // nothing found? -> error
668  if (myVehicleParameter->routeid != "") {
669  throw ProcessError("The route '" + myVehicleParameter->routeid + "' for vehicle '" + myVehicleParameter->id + "' is not known.");
670  } else {
671  throw ProcessError("Vehicle '" + myVehicleParameter->id + "' has no route.");
672  }
673  }
674  myActiveRouteID = "";
675 
676  // try to build the vehicle
677  SUMOVehicle* vehicle = 0;
678  if (vehControl.getVehicle(myVehicleParameter->id) == 0) {
679  const bool ignoreRouteErrors = OptionsCont::getOptions().getBool("ignore-route-errors");
680  try {
681  vehicle = vehControl.buildVehicle(myVehicleParameter, route, vtype, ignoreRouteErrors);
682  } catch (const ProcessError& e) {
683  if (ignoreRouteErrors) {
684  WRITE_WARNING(e.what());
685  vehControl.deleteVehicle(0, true);
686  myVehicleParameter = 0;
687  vehicle = 0;
688  return;
689  } else {
690  throw e;
691  }
692  }
693  // maybe we do not want this vehicle to be inserted due to scaling
694  unsigned int quota = vehControl.getQuota();
695  if (quota > 0) {
696  vehControl.addVehicle(myVehicleParameter->id, vehicle);
698  const MSEdge* const firstEdge = vehicle->getRoute().getEdges()[0];
699  static_cast<MSVehicle*>(vehicle)->setTentativeLaneAndPosition(firstEdge->getLanes()[0], myVehicleParameter->departPos);
700  vehControl.addWaiting(*route->begin(), vehicle);
701  vehControl.registerOneWaitingForPerson();
703  const MSEdge* const firstEdge = vehicle->getRoute().getEdges()[0];
704  static_cast<MSVehicle*>(vehicle)->setTentativeLaneAndPosition(firstEdge->getLanes()[0], myVehicleParameter->departPos);
705  vehControl.addWaiting(*route->begin(), vehicle);
706  vehControl.registerOneWaitingForContainer();
707  } else {
708  // !!! no scaling for triggered vehicles yet
709  for (unsigned int i = 1; i < quota; i++) {
712  newPars->id = myVehicleParameter->id + "." + toString(i);
713  vehicle = vehControl.buildVehicle(newPars, route, vtype, OptionsCont::getOptions().getBool("ignore-route-errors"));
714  vehControl.addVehicle(newPars->id, vehicle);
715  }
716  }
718  myVehicleParameter = 0;
719  } else {
720  vehControl.deleteVehicle(vehicle, true);
721  myVehicleParameter = 0;
722  vehicle = 0;
723  }
724  } else {
725  // strange: another vehicle with the same id already exists
727  // and was not loaded while loading a simulation state
728  // -> error
729  throw ProcessError("Another vehicle with the id '" + myVehicleParameter->id + "' exists.");
730  } else {
731  // ok, it seems to be loaded previously while loading a simulation state
732  vehicle = 0;
733  }
734  }
735  // check whether the vehicle shall be added directly to the network or
736  // shall stay in the internal buffer
737  if (vehicle != 0) {
738  if (vehicle->getParameter().departProcedure == DEPART_GIVEN) {
740  }
741  }
742 }
743 
744 
745 void
747  if (myActivePlan->size() == 0) {
748  throw ProcessError("Person '" + myVehicleParameter->id + "' has no plan.");
749  }
751  if (type == 0) {
752  throw ProcessError("The type '" + myVehicleParameter->vtypeid + "' for person '" + myVehicleParameter->id + "' is not known.");
753  }
755  // @todo: consider myScale?
757  if (MSNet::getInstance()->getPersonControl().add(myVehicleParameter->id, person)) {
760  } else {
761  ProcessError error("Another person with the id '" + myVehicleParameter->id + "' exists.");
762  delete person;
763  throw error;
764  }
765  } else {
766  // warning already given
767  delete person;
768  }
769  myVehicleParameter = 0;
770  myActivePlan = 0;
771 }
772 
773 void
775  if (myActiveContainerPlan->size() == 0) {
776  throw ProcessError("Container '" + myVehicleParameter->id + "' has no plan.");
777  }
779  if (type == 0) {
780  throw ProcessError("The type '" + myVehicleParameter->vtypeid + "' for container '" + myVehicleParameter->id + "' is not known.");
781  }
783  // @todo: consider myScale?
785  if (MSNet::getInstance()->getContainerControl().add(myVehicleParameter->id, container)) {
788  } else {
789  ProcessError error("Another container with the id '" + myVehicleParameter->id + "' exists.");
790  delete container;
791  throw error;
792  }
793  } else {
794  // warning already given
795  delete container;
796  }
797  myVehicleParameter = 0;
799 }
800 
801 void
804  return;
805  }
806  // let's check whether vehicles had to depart before the simulation starts
809  const SUMOTime offsetToBegin = string2time(OptionsCont::getOptions().getString("begin")) - myVehicleParameter->depart;
813  return;
814  }
815  }
816  }
817  if (MSNet::getInstance()->getVehicleControl().getVType(myVehicleParameter->vtypeid, &myParsingRNG) == 0) {
818  throw ProcessError("The vehicle type '" + myVehicleParameter->vtypeid + "' for flow '" + myVehicleParameter->id + "' is not known.");
819  }
822  closeRoute(true);
823  }
825  throw ProcessError("The route '" + myVehicleParameter->routeid + "' for flow '" + myVehicleParameter->id + "' is not known.");
826  }
827  myActiveRouteID = "";
828 
829  // check whether the vehicle shall be added directly to the network or
830  // shall stay in the internal buffer
832  if (MSNet::getInstance()->getInsertionControl().add(myVehicleParameter)) {
834  } else {
835  throw ProcessError("Another flow with the id '" + myVehicleParameter->id + "' exists.");
836  }
837  }
838  myVehicleParameter = 0;
839  myInsertStopEdgesAt = -1;
840 }
841 
842 
843 void
845  std::string errorSuffix;
846  if (myActivePlan != 0) {
847  errorSuffix = " in person '" + myVehicleParameter->id + "'.";
848  } else if (myVehicleParameter != 0) {
849  errorSuffix = " in vehicle '" + myVehicleParameter->id + "'.";
850  } else if (myActiveContainerPlan != 0) {
851  errorSuffix = " in container '" + myVehicleParameter->id + "'.";
852  } else {
853  errorSuffix = " in route '" + myActiveRouteID + "'.";
854  }
856  bool ok = parseStop(stop, attrs, errorSuffix, MsgHandler::getErrorInstance());
857  if (!ok) {
858  return;
859  }
860  MSEdge* edge = 0;
861  // try to parse the assigned bus stop
862  if (stop.busstop != "") {
863  // ok, we have obviously a bus stop
865  if (bs == 0) {
866  WRITE_ERROR("The bus stop '" + stop.busstop + "' is not known" + errorSuffix);
867  return;
868  }
869  const MSLane& l = bs->getLane();
870  stop.lane = l.getID();
871  stop.endPos = bs->getEndLanePosition();
872  stop.startPos = bs->getBeginLanePosition();
873  edge = &l.getEdge();
874  } //try to parse the assigned container stop
875  else if (stop.containerstop != "") {
876  // ok, we have obviously a container stop
878  if (cs == 0) {
879  WRITE_ERROR("The container stop '" + stop.containerstop + "' is not known" + errorSuffix);
880  return;
881  }
882  const MSLane& l = cs->getLane();
883  stop.lane = l.getID();
884  stop.endPos = cs->getEndLanePosition();
885  stop.startPos = cs->getBeginLanePosition();
886  edge = &l.getEdge();
887  } else {
888  // no, the lane and the position should be given
889  // get the lane
890  stop.lane = attrs.getOpt<std::string>(SUMO_ATTR_LANE, 0, ok, "");
891  if (ok && stop.lane != "") {
892  if (MSLane::dictionary(stop.lane) == 0) {
893  WRITE_ERROR("The lane '" + stop.lane + "' for a stop is not known" + errorSuffix);
894  return;
895  }
896  } else {
897  WRITE_ERROR("A stop must be placed on a bus stop, a container stop or a lane" + errorSuffix);
898  return;
899  }
900  edge = &MSLane::dictionary(stop.lane)->getEdge();
901  if (myActivePlan &&
902  !myActivePlan->empty() &&
903  &myActivePlan->back()->getDestination() != edge) {
904  throw ProcessError("Disconnected plan for person '" + myVehicleParameter->id + "' (" + edge->getID() + "!=" + myActivePlan->back()->getDestination().getID() + ").");
905  }
906  if (myActivePlan && myActivePlan->empty()) {
908  *edge, -1, myVehicleParameter->depart, myVehicleParameter->departPos, "start"));
909  }
910  if (myActiveContainerPlan &&
911  !myActiveContainerPlan->empty() &&
912  &myActiveContainerPlan->back()->getDestination() != &MSLane::dictionary(stop.lane)->getEdge()) {
913  throw ProcessError("Disconnected plan for container '" + myVehicleParameter->id + "' (" + MSLane::dictionary(stop.lane)->getEdge().getID() + "!=" + myActiveContainerPlan->back()->getDestination().getID() + ").");
914  }
917  MSLane::dictionary(stop.lane)->getEdge(), -1, myVehicleParameter->depart, myVehicleParameter->departPos, "start"));
918  }
919  stop.endPos = attrs.getOpt<SUMOReal>(SUMO_ATTR_ENDPOS, 0, ok, MSLane::dictionary(stop.lane)->getLength());
920  if (attrs.hasAttribute(SUMO_ATTR_POSITION)) {
921  WRITE_WARNING("Deprecated attribute 'pos' in description of stop" + errorSuffix);
922  stop.endPos = attrs.getOpt<SUMOReal>(SUMO_ATTR_POSITION, 0, ok, stop.endPos);
923  }
924  stop.startPos = attrs.getOpt<SUMOReal>(SUMO_ATTR_STARTPOS, 0, ok, MAX2((SUMOReal)0., stop.endPos - 2 * POSITION_EPS));
925  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, 0, ok, false);
926  if (!ok || !checkStopPos(stop.startPos, stop.endPos, MSLane::dictionary(stop.lane)->getLength(), POSITION_EPS, friendlyPos)) {
927  WRITE_ERROR("Invalid start or end position for stop on lane '" + stop.lane + "'" + errorSuffix);
928  return;
929  }
930  }
931  if (myActivePlan != 0) {
932  std::string actType = attrs.getOpt<std::string>(SUMO_ATTR_ACTTYPE, 0, ok, "waiting");
934  MSLane::dictionary(stop.lane)->getEdge(), stop.duration, stop.until, stop.startPos, actType));
935  } else if (myActiveContainerPlan != 0) {
936  std::string actType = attrs.getOpt<std::string>(SUMO_ATTR_ACTTYPE, 0, ok, "waiting");
938  MSLane::dictionary(stop.lane)->getEdge(), stop.duration, stop.until, stop.startPos, actType));
939  } else if (myVehicleParameter != 0) {
940  myVehicleParameter->stops.push_back(stop);
941  } else {
942  myActiveRouteStops.push_back(stop);
943  }
944  if (myInsertStopEdgesAt >= 0) {
945  myActiveRoute.insert(myActiveRoute.begin() + myInsertStopEdgesAt, edge);
947  }
948 }
949 
950 
951 /****************************************************************************/
The departure is person triggered.
void addStop(const SUMOSAXAttributes &attrs)
Processing of a stop.
const int VTYPEPARS_MAXSPEED_SET
const int VEHPARS_TO_TAZ_SET
MSRouteHandler(const std::string &file, bool addVehiclesDirectly)
standard constructor
bool wasSet(int what) const
Returns whether the given parameter was set.
Definition: MSVehicleType.h:91
SUMOReal repetitionProbability
The probability for emitting a vehicle per second.
void addWaiting(const MSEdge *const edge, SUMOVehicle *vehicle)
Adds a vehicle to the list of waiting vehiclse to a given edge.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition: MsgHandler.cpp:80
SUMOReal myCurrentCosts
The currently parsed route costs.
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:455
virtual MSPerson * buildPerson(const SUMOVehicleParameter *pars, const MSVehicleType *vtype, MSPerson::MSPersonPlan *plan) const
Builds a new person.
virtual void myEndElement(int element)
Called when a closing tag occurs.
ConstMSEdgeVector myActiveRoute
The current route.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
SUMOReal getMaxSpeed() const
Get vehicle's maximum speed [m/s].
const int VEHPARS_FORCE_REROUTE
const SUMOReal DEFAULT_CONTAINER_TRANSHIP_SPEED
void parseFromViaTo(std::string element, const SUMOSAXAttributes &attrs)
Called for parsing from and to and the corresponding taz attributes.
const MSLane & getLane() const
Returns the lane this container stop is located at.
A lane area vehicles can halt at and load and unload containers.
RandomDistributor< const MSRoute * > * myCurrentRouteDistribution
The currently parsed distribution of routes (probability->route)
const std::vector< SUMOReal > & getProbs() const
Returns the probabilities assigned to the members of the distribution.
The time is given.
std::string next()
std::string containerstop
(Optional) container stop if one is assigned to the stop
int repetitionNumber
The number of times the vehicle shall be repeatedly inserted.
MSPerson::MSPersonPlan * myActivePlan
The plan of the current person.
std::string vtypeid
The vehicle's type id.
void closeVehicle()
Ends the processing of a vehicle.
static MTRand myParsingRNG
A random number generator used to choose from vtype/route distributions and computing the speed facto...
static void parseVTypeEmbedded(SUMOVTypeParameter &into, int element, const SUMOSAXAttributes &attrs, bool fromVType=false)
Parses an element embedded in vtype definition.
SUMOReal getEndLanePosition() const
Returns the end position of this container stop.
virtual const MSRoute & getRoute() const =0
Returns the current route.
bool myAddVehiclesDirectly
Information whether vehicles shall be directly added to the network or kept within the buffer...
SUMOTime duration
The stopping duration.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:186
SUMOVehicleParameter * myVehicleParameter
Parameter of the current vehicle, trip, person, container or flow.
The departure is container triggered.
unsigned int getNumPredecessors() const
Returns the number of edges this edge is connected to.
Definition: MSEdge.h:331
SUMOReal getBeginLanePosition() const
Returns the begin position of this container stop.
bool add(SUMOReal prob, T val, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static bool checkStopPos(SUMOReal &startPos, SUMOReal &endPos, const SUMOReal laneLength, const SUMOReal minLength, const bool friendlyPos)
check start and end position of a stop
static bool gStateLoaded
Information whether a state has been loaded.
Definition: MSGlobals.h:86
SUMOVTypeParameter * myCurrentVType
The currently parsed vehicle type.
void closePerson()
Ends the processing of a person.
int repetitionsDone
The number of times the vehicle was already inserted.
const SUMOReal DEFAULT_PEDESTRIAN_SPEED
void openRoute(const SUMOSAXAttributes &attrs)
MSPedestrianRouterDijkstra & getPedestrianRouter(const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:828
static SUMOReal _2SUMORealSec(const E *const data, SUMOReal def)
Definition: TplConvert.h:336
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:159
T MAX2(T a, T b)
Definition: StdDefs.h:74
void setCosts(SUMOReal costs)
Sets the costs of the route.
Definition: MSRoute.h:170
const SUMOReal DEFAULT_VEH_PROB
SUMOReal myActiveRouteProbability
The probability of the current route.
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary...
Definition: MSEdge.cpp:531
MSContainerStop * getContainerStop(const std::string &id) const
Returns the named container stop.
Definition: MSNet.cpp:772
SUMOTime until
The time at which the vehicle may continue its journey.
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
void registerLastDepart()
save last depart (only to be used if vehicle is not discarded)
std::string myActiveRouteID
The id of the current route.
SUMOReal getEndLanePosition() const
Returns the end position of this bus stop.
Definition: MSBusStop.cpp:72
int myInsertStopEdgesAt
where stop edges can be inserted into the current route (-1 means no insertion)
SUMOReal repetitionOffset
The time offset between vehicle reinsertions.
const std::string DEFAULT_VTYPE_ID
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
static MSVehicleType * build(SUMOVTypeParameter &from)
Builds the microsim vehicle type described by the given parameter.
void error(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Handler for XML-errors.
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
SUMOReal getBeginLanePosition() const
Returns the begin position of this bus stop.
Definition: MSBusStop.cpp:66
The car-following model and parameter.
Definition: MSVehicleType.h:74
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:67
std::string toTaz
The vehicle's destination zone (district)
const MSLane & getLane() const
Returns the lane this bus stop is located at.
Definition: MSBusStop.cpp:60
std::vector< Stop > stops
List of the stops the vehicle will make.
SUMOTime getOptSUMOTimeReporting(int attr, const char *objectid, bool &ok, SUMOTime defaultValue, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
static SUMOReal interpretEdgePos(SUMOReal pos, SUMOReal maximumValue, SumoXMLAttr attr, const std::string &id)
Interprets negative edge positions and fits them onto a given edge.
std::string busstop
(Optional) bus stop if one is assigned to the stop
const std::string & getID() const
Returns the id.
Definition: Named.h:60
A road/street connecting two junctions.
Definition: MSEdge.h:81
void compute(const E *from, const E *to, SUMOReal departPos, SUMOReal arrivalPos, SUMOReal speed, SUMOTime msTime, const N *onlyNode, std::vector< const E * > &into, bool allEdges=false)
Builds the route between the given edges using the minimum effort at the given time The definition of...
RandomDistributor< MSVehicleType * > * myCurrentVTypeDistribution
The currently parsed distribution of vehicle types (probability->vehicle type)
SUMOReal startPos
The stopping position start.
The edge is a district edge.
Definition: MSEdge.h:100
the edges of a route
void closeRouteDistribution()
std::string routeid
The vehicle's route id.
Representation of a vehicle.
Definition: SUMOVehicle.h:65
Encapsulated SAX-Attributes.
bool wasSet(int what) const
Returns whether the given parameter was set.
SUMOReal endPos
The stopping position end.
A lane area vehicles can halt at.
Definition: MSBusStop.h:64
virtual MSContainerControl & getContainerControl()
Returns the container control.
Definition: MSNet.cpp:666
void closeContainer()
Ends the processing of a container.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:288
void closeVehicleTypeDistribution()
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, const MSRoute *route, const MSVehicleType *type, const bool ignoreStopErrors, const bool fromRouteFile=true)
Builds a vehicle, increases the number of built vehicles.
SUMOTime depart
The vehicle's departure time.
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:124
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
SUMOTime string2time(const std::string &r)
Definition: SUMOTime.cpp:48
#define POSITION_EPS
Definition: config.h:189
std::string fromTaz
The vehicle's origin zone (district)
MSBusStop * getBusStop(const std::string &id) const
Returns the named bus stop.
Definition: MSNet.cpp:748
MSContainer::MSContainerPlan * myActiveContainerPlan
The plan of the current container.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:53
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
void addReference() const
increments the reference counter for the route
Definition: MSRoute.cpp:100
const int VEHPARS_FROM_TAZ_SET
void registerOneWaitingForPerson()
increases the count of vehicles waiting for a person to allow recogniztion of person related deadlock...
std::vector< MSContainerStage * > MSContainerPlan
the structure holding the plan of a container
Definition: MSContainer.h:553
std::string lane
The lane to stop at.
Parser for routes during their loading.
std::string myCurrentRouteDistributionID
The id of the currently parsed route distribution.
void openRouteDistribution(const SUMOSAXAttributes &attrs)
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:205
virtual void myEndElement(int element)
Called when a closing tag occurs.
SUMOReal getOverallProb() const
Return the sum of the probabilites assigned to the members.
virtual MSContainer * buildContainer(const SUMOVehicleParameter *pars, const MSVehicleType *vtype, MSContainer::MSContainerPlan *plan) const
Builds a new container.
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:852
void registerOneWaitingForContainer()
increases the count of vehicles waiting for a container to allow recogniztion of container related de...
std::vector< SUMOVehicleParameter::Stop > myActiveRouteStops
List of the stops on the parsed route.
Structure representing possible vehicle parameter.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
virtual MSPersonControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:658
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:329
int setParameter
Information for the router which parameter were set.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
void setDeparture(SUMOTime time, MSContainer *container)
sets the arrival time for a waiting container
std::string myCurrentVTypeDistributionID
The id of the currently parsed vehicle type distribution.
Definition of vehicle stop (position and duration)
bool parseStop(SUMOVehicleParameter::Stop &stop, const SUMOSAXAttributes &attrs, std::string errorSuffix, MsgHandler *const errorOutput)
parses attributes common to all stops
SUMOReal getDefaultProbability() const
Get the default probability of this vehicle type.
const std::string & getID() const
Returns the name of the vehicle type.
void setDeparture(SUMOTime time, MSPerson *person)
sets the arrival time for a waiting or walking person
int SUMOTime
Definition: SUMOTime.h:43
SUMOReal departPos
(optional) The position the vehicle shall depart from
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
const RGBColor * myActiveRouteColor
The currently parsed route's color.
#define SUMOReal
Definition: config.h:218
unsigned int getNumSuccessors() const
Returns the number of edges that may be reached from this edge.
Definition: MSEdge.h:308
#define NUMERICAL_EPS
Definition: config.h:162
virtual ~MSRouteHandler()
standard destructor
void openVehicleTypeDistribution(const SUMOSAXAttributes &attrs)
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue, bool report=true) const
Tries to read given attribute assuming it is an int.
The class responsible for building and deletion of vehicles.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
void release() const
deletes the route if there are no further references to it
Definition: MSRoute.cpp:106
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, MTRand *rng=0)
Returns the named vehicle type or a sample from the named distribution.
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
bool checkLastDepart()
Checks whether the route file is sorted by departure time if needed.
std::string myActiveRouteRefID
The id of the route the current route references to.
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
std::vector< MSPersonStage * > MSPersonPlan
the structure holding the plan of a person
Definition: MSPerson.h:514
A color information.
static void parseEdgesList(const std::string &desc, ConstMSEdgeVector &into, const std::string &rid)
Parses the given string assuming it contains a list of edge ids divided by spaces.
Definition: MSEdge.cpp:594
void closeRoute(const bool mayBeDisconnected=false)
unsigned int getQuota(SUMOReal frac=-1) const
Returns the number of instances of the current vehicle that shall be emitted considering that "frac" ...
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:75
void closeFlow()
Ends the processing of a flow.
std::string id
The vehicle's id.
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
Definition: MSRoute.cpp:116