SUMO - Simulation of Urban MObility
MSBaseVehicle.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // A base class for vehicle implementations
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <iostream>
34 #include <cassert>
35 #include <utils/common/StdDefs.h>
39 #include "MSGlobals.h"
40 #include "MSTransportable.h"
41 #include "MSVehicleControl.h"
42 #include "MSVehicleType.h"
43 #include "MSEdge.h"
44 #include "MSLane.h"
45 #include "MSMoveReminder.h"
46 #include "MSBaseVehicle.h"
47 #include "MSNet.h"
48 #include "devices/MSDevice.h"
50 #include "MSInsertionControl.h"
51 
52 // ===========================================================================
53 // static members
54 // ===========================================================================
56 #ifdef _DEBUG
57 std::set<std::string> MSBaseVehicle::myShallTraceMoveReminders;
58 #endif
59 
60 // ===========================================================================
61 // method definitions
62 // ===========================================================================
63 
64 double
66  throw ProcessError("getPreviousSpeed() is not available for non-MSVehicles.");
67 }
68 
69 
71  MSVehicleType* type, const double speedFactor) :
72  myParameter(pars),
73  myRoute(route),
74  myType(type),
75  myCurrEdge(route->begin()),
76  myChosenSpeedFactor(speedFactor),
77  myMoveReminders(0),
79  myDepartPos(-1),
80  myArrivalPos(-1),
81  myArrivalLane(-1),
83 #ifdef _DEBUG
84  , myTraceMoveReminders(myShallTraceMoveReminders.count(pars->id) > 0)
85 #endif
86 {
87  if ((*myRoute->begin())->isTazConnector() || myRoute->getLastEdge()->isTazConnector()) {
89  }
90  // init devices
92  //
93  for (std::vector< MSDevice* >::iterator dev = myDevices.begin(); dev != myDevices.end(); ++dev) {
94  myMoveReminders.push_back(std::make_pair(*dev, 0.));
95  }
97  if (!pars->wasSet(VEHPARS_FORCE_REROUTE)) {
100  std::string msg;
101  if (!hasValidRoute(msg)) {
102  throw ProcessError("Vehicle '" + pars->id + "' has no valid route. " + msg);
103  }
104  }
105  }
106 }
107 
108 
110  myRoute->release();
111  if (myParameter->repetitionNumber == 0) {
113  }
114  for (std::vector< MSDevice* >::iterator dev = myDevices.begin(); dev != myDevices.end(); ++dev) {
115  delete *dev;
116  }
117  delete myParameter;
118 }
119 
120 
121 const std::string&
123  return myParameter->id;
124 }
125 
126 
129  return *myParameter;
130 }
131 
132 
133 double
135  return myType->getMaxSpeed();
136 }
137 
138 
139 const MSEdge*
140 MSBaseVehicle::succEdge(int nSuccs) const {
141  if (myCurrEdge + nSuccs < myRoute->end() && std::distance(myCurrEdge, myRoute->begin()) <= nSuccs) {
142  return *(myCurrEdge + nSuccs);
143  } else {
144  return 0;
145  }
146 }
147 
148 
149 const MSEdge*
151  return *myCurrEdge;
152 }
153 
154 
155 void
156 MSBaseVehicle::reroute(SUMOTime t, SUMOAbstractRouter<MSEdge, SUMOVehicle>& router, const bool onInit, const bool withTaz) {
157  // check whether to reroute
158  const MSEdge* source = withTaz && onInit ? MSEdge::dictionary(myParameter->fromTaz + "-source") : getRerouteOrigin();
159  if (source == 0) {
160  source = getRerouteOrigin();
161  }
162  const MSEdge* sink = withTaz ? MSEdge::dictionary(myParameter->toTaz + "-sink") : myRoute->getLastEdge();
163  if (sink == 0) {
164  sink = myRoute->getLastEdge();
165  }
166  ConstMSEdgeVector edges;
167  ConstMSEdgeVector stops;
168  if (myParameter->via.size() == 0) {
169  stops = getStopEdges();
170  } else {
171  // via takes precedence over stop edges
172  // XXX check for inconsistencies #2275
173  for (std::vector<std::string>::const_iterator it = myParameter->via.begin(); it != myParameter->via.end(); ++it) {
174  MSEdge* viaEdge = MSEdge::dictionary(*it);
175  assert(viaEdge != 0);
176  if (viaEdge->allowedLanes(getVClass()) == 0) {
177  throw ProcessError("Vehicle '" + getID() + "' is not allowed on any lane of via edge '" + viaEdge->getID() + "'.");
178  }
179  stops.push_back(viaEdge);
180  }
181  }
182 
183  for (MSRouteIterator s = stops.begin(); s != stops.end(); ++s) {
184  if (*s != source) {
185  // !!! need to adapt t here
186  ConstMSEdgeVector into;
187  router.compute(source, *s, this, t, into);
188  if (into.size() > 0) {
189  into.pop_back();
190  edges.insert(edges.end(), into.begin(), into.end());
191  } else {
192  std::string error = "Vehicle '" + getID() + "' has no valid route from edge '" + source->getID() + "' to stop edge '" + (*s)->getID() + "'.";
194  throw ProcessError(error);
195  } else {
196  WRITE_WARNING(error);
197  }
198  }
199  source = *s;
200  }
201  }
202  router.compute(source, sink, this, t, edges);
203  if (!edges.empty() && edges.front()->isTazConnector()) {
204  edges.erase(edges.begin());
205  }
206  if (!edges.empty() && edges.back()->isTazConnector()) {
207  edges.pop_back();
208  }
209  replaceRouteEdges(edges, onInit);
210  // this must be called even if the route could not be replaced
211  if (onInit) {
212  if (edges.empty()) {
214  throw ProcessError("Vehicle '" + getID() + "' has no valid route.");
215  } else if (source->isTazConnector()) {
216  WRITE_WARNING("Removing vehicle '" + getID() + "' which has no valid route.");
218  return;
219  }
220  }
222  }
223 }
224 
225 
226 bool
227 MSBaseVehicle::replaceRouteEdges(ConstMSEdgeVector& edges, bool onInit, bool check, bool addStops) {
228  if (edges.empty()) {
229  WRITE_WARNING("No route for vehicle '" + getID() + "' found.");
230  return false;
231  }
232  // build a new id, first
233  std::string id = getID();
234  if (id[0] != '!') {
235  id = "!" + id;
236  }
237  if (myRoute->getID().find("!var#") != std::string::npos) {
238  id = myRoute->getID().substr(0, myRoute->getID().rfind("!var#") + 5) + toString(getNumberReroutes() + 1);
239  } else {
240  id = id + "!var#1";
241  }
242  int oldSize = (int)edges.size();
243  if (!onInit) {
244  const MSEdge* const origin = getRerouteOrigin();
245  if (origin != *myCurrEdge && edges.front() == origin) {
246  edges.insert(edges.begin(), *myCurrEdge);
247  oldSize = (int)edges.size();
248  }
249  edges.insert(edges.begin(), myRoute->begin(), myCurrEdge);
250  }
251  if (edges == myRoute->getEdges()) {
252  return true;
253  }
254  const RGBColor& c = myRoute->getColor();
255  MSRoute* newRoute = new MSRoute(id, edges, false, &c == &RGBColor::DEFAULT_COLOR ? 0 : new RGBColor(c), myRoute->getStops());
256  if (!MSRoute::dictionary(id, newRoute)) {
257  delete newRoute;
258  return false;
259  }
260 
261  std::string msg;
262  if (check && !hasValidRoute(msg, newRoute)) {
263  WRITE_WARNING("Invalid route replacement for vehicle '" + getID() + "'. " + msg);
265  newRoute->addReference();
266  newRoute->release();
267  return false;
268  }
269  }
270  if (!replaceRoute(newRoute, onInit, (int)edges.size() - oldSize, addStops)) {
271  newRoute->addReference();
272  newRoute->release();
273  return false;
274  }
275  return true;
276 }
277 
278 
279 double
281  return 0;
282 }
283 
284 
285 double
287  return 0;
288 }
289 
290 
291 void
296 }
297 
298 
299 bool
301  return myDeparture != NOT_YET_DEPARTED;
302 }
303 
304 
305 bool
307  return succEdge(1) == 0;
308 }
309 
310 void
312  throw ProcessError("Person '" + person->getID() + "' cannot ride in vehicle '" + getID() + "' in the mesoscopic simulation.");
313 }
314 
315 void
317  throw ProcessError("Container '" + container->getID() + "' cannot ride in vehicle '" + getID() + "' in the mesoscopic simulation.");
318 }
319 
320 bool
321 MSBaseVehicle::hasValidRoute(std::string& msg, const MSRoute* route) const {
322  MSRouteIterator start = myCurrEdge;
323  if (route == 0) {
324  route = myRoute;
325  } else {
326  start = route->begin();
327  }
328  MSRouteIterator last = route->end() - 1;
329  // check connectivity, first
330  for (MSRouteIterator e = start; e != last; ++e) {
331  if ((*e)->allowedLanes(**(e + 1), myType->getVehicleClass()) == 0) {
332  msg = "No connection between edge '" + (*e)->getID() + "' and edge '" + (*(e + 1))->getID() + "'.";
333  return false;
334  }
335  }
336  last = route->end();
337  // check usable lanes, then
338  for (MSRouteIterator e = start; e != last; ++e) {
339  if ((*e)->prohibits(this)) {
340  msg = "Edge '" + (*e)->getID() + "' prohibits.";
341  return false;
342  }
343  }
344  return true;
345 }
346 
347 
348 void
350 #ifdef _DEBUG
351  if (myTraceMoveReminders) {
352  traceMoveReminder("add", rem, 0, true);
353  }
354 #endif
355  myMoveReminders.push_back(std::make_pair(rem, 0.));
356 }
357 
358 
359 void
361  for (MoveReminderCont::iterator r = myMoveReminders.begin(); r != myMoveReminders.end(); ++r) {
362  if (r->first == rem) {
363 #ifdef _DEBUG
364  if (myTraceMoveReminders) {
365  traceMoveReminder("remove", rem, 0, false);
366  }
367 #endif
368  myMoveReminders.erase(r);
369  return;
370  }
371  }
372 }
373 
374 
375 void
377  for (MoveReminderCont::iterator rem = myMoveReminders.begin(); rem != myMoveReminders.end();) {
378  if (rem->first->notifyEnter(*this, reason, enteredLane)) {
379 #ifdef _DEBUG
380  if (myTraceMoveReminders) {
381  traceMoveReminder("notifyEnter", rem->first, rem->second, true);
382  }
383 #endif
384  ++rem;
385  } else {
386 #ifdef _DEBUG
387  if (myTraceMoveReminders) {
388  traceMoveReminder("notifyEnter", rem->first, rem->second, false);
389  }
390 #endif
391  rem = myMoveReminders.erase(rem);
392  }
393  }
394 }
395 
396 
397 void
399  if (myRoute->getLastEdge()->isTazConnector()) {
400  return;
401  }
402  const std::vector<MSLane*>& lanes = myRoute->getLastEdge()->getLanes();
403  const double lastLaneLength = lanes[0]->getLength();
404  switch (myParameter->arrivalPosProcedure) {
405  case ARRIVAL_POS_GIVEN:
406  if (fabs(myParameter->arrivalPos) > lastLaneLength) {
407  WRITE_WARNING("Vehicle '" + getID() + "' will not be able to arrive at the given position!");
408  }
409  // Maybe we should warn the user about invalid inputs!
410  myArrivalPos = MIN2(myParameter->arrivalPos, lastLaneLength);
411  if (myArrivalPos < 0) {
412  myArrivalPos = MAX2(myArrivalPos + lastLaneLength, 0.);
413  }
414  break;
415  case ARRIVAL_POS_RANDOM:
416  myArrivalPos = RandHelper::rand(0., lastLaneLength);
417  break;
418  default:
419  myArrivalPos = lastLaneLength;
420  break;
421  }
423  if (myParameter->arrivalLane >= (int)lanes.size() || !lanes[myParameter->arrivalLane]->allowsVehicleClass(myType->getVehicleClass())) {
424  WRITE_WARNING("Vehicle '" + getID() + "' will not be able to arrive at the given lane '" + myRoute->getLastEdge()->getID() + "_" + toString(myParameter->arrivalLane) + "'!");
425  }
426  myArrivalLane = MIN2(myParameter->arrivalLane, (int)(lanes.size() - 1));
427  }
429  for (std::vector<MSLane*>::const_iterator l = lanes.begin(); l != lanes.end(); ++l) {
430  if (myParameter->arrivalSpeed <= (*l)->getVehicleMaxSpeed(this)) {
431  return;
432  }
433  }
434  WRITE_WARNING("Vehicle '" + getID() + "' will not be able to arrive with the given speed!");
435  }
436 }
437 
438 
439 double
441  return MAX2(0., MIN2(1., getVehicleType().getImpatience() +
443 }
444 
445 
446 MSDevice*
447 MSBaseVehicle::getDevice(const std::type_info& type) const {
448  for (std::vector<MSDevice*>::const_iterator dev = myDevices.begin(); dev != myDevices.end(); ++dev) {
449  if (typeid(**dev) == type) {
450  return *dev;
451  }
452  }
453  return 0;
454 }
455 
456 
457 void
459  // this saves lots of departParameters which are only needed for vehicles that did not yet depart
460  // the parameters may hold the name of a vTypeDistribution but we are interested in the actual type
462  // params and stops must be written in child classes since they may wish to add additional attributes first
465  out.writeAttr(SUMO_ATTR_REROUTE, true);
466  }
467  // here starts the vehicle internal part (see loading)
468  // @note: remember to close the vehicle tag when calling this in a subclass!
469 }
470 
471 
472 void
473 MSBaseVehicle::addStops(const bool ignoreStopErrors) {
474  for (std::vector<SUMOVehicleParameter::Stop>::const_iterator i = myParameter->stops.begin(); i != myParameter->stops.end(); ++i) {
475  std::string errorMsg;
476  if (!addStop(*i, errorMsg) && !ignoreStopErrors) {
477  throw ProcessError(errorMsg);
478  }
479  if (errorMsg != "") {
480  WRITE_WARNING(errorMsg);
481  }
482  }
483  for (std::vector<SUMOVehicleParameter::Stop>::const_iterator i = myRoute->getStops().begin(); i != myRoute->getStops().end(); ++i) {
484  std::string errorMsg;
485  if (!addStop(*i, errorMsg) && !ignoreStopErrors) {
486  throw ProcessError(errorMsg);
487  }
488  if (errorMsg != "") {
489  WRITE_WARNING(errorMsg);
490  }
491  }
492 }
493 
494 
495 bool
496 MSBaseVehicle::hasDevice(const std::string& deviceName) const {
497  for (std::vector<MSDevice* >::const_iterator dev = myDevices.begin(); dev != myDevices.end(); ++dev) {
498  if ((*dev)->deviceName() == deviceName) {
499  return true;
500  }
501  }
502  return false;
503 }
504 
505 
506 void
507 MSBaseVehicle::createDevice(const std::string& deviceName) {
508  if (!hasDevice(deviceName)) {
509  if (deviceName == "rerouting") {
510  ((SUMOVehicleParameter*)myParameter)->addParameter("has." + deviceName + ".device", "true");
512  if (hasDeparted()) {
513  // vehicle already departed: disable pre-insertion rerouting and enable regular routing behavior
514  MSDevice_Routing* routingDevice = static_cast<MSDevice_Routing*>(getDevice(typeid(MSDevice_Routing)));
515  assert(routingDevice != 0);
516  routingDevice->notifyEnter(*this, MSMoveReminder::NOTIFICATION_DEPARTED);
517  }
518  } else {
519  throw InvalidArgument("Creating device of type '" + deviceName + "' is not supported");
520  }
521  }
522 }
523 
524 
525 std::string
526 MSBaseVehicle::getDeviceParameter(const std::string& deviceName, const std::string& key) const {
527  for (std::vector<MSDevice* >::const_iterator dev = myDevices.begin(); dev != myDevices.end(); ++dev) {
528  if ((*dev)->deviceName() == deviceName) {
529  return (*dev)->getParameter(key);
530  }
531  }
532  throw InvalidArgument("No device of type '" + deviceName + "' exists");
533 }
534 
535 
536 void
537 MSBaseVehicle::setDeviceParameter(const std::string& deviceName, const std::string& key, const std::string& value) {
538  for (std::vector<MSDevice* >::iterator dev = myDevices.begin(); dev != myDevices.end(); ++dev) {
539  if ((*dev)->deviceName() == deviceName) {
540  (*dev)->setParameter(key, value);
541  return;
542  }
543  }
544  throw InvalidArgument("No device of type '" + deviceName + "' exists");
545 }
546 
547 
548 void
550  if (myType->isVehicleSpecific()) {
552  }
553  myType = type;
554 }
555 
556 
559  if (myType->isVehicleSpecific()) {
560  return *myType;
561  }
562  MSVehicleType* type = myType->buildSingularType(myType->getID() + "@" + getID());
563  replaceVehicleType(type);
564  return *type;
565 }
566 
567 
568 #ifdef _DEBUG
569 void
570 MSBaseVehicle::initMoveReminderOutput(const OptionsCont& oc) {
571  if (oc.isSet("movereminder-output.vehicles")) {
572  const std::vector<std::string> vehicles = oc.getStringVector("movereminder-output.vehicles");
573  myShallTraceMoveReminders.insert(vehicles.begin(), vehicles.end());
574  }
575 }
576 
577 
578 void
579 MSBaseVehicle::traceMoveReminder(const std::string& type, MSMoveReminder* rem, double pos, bool keep) const {
580  OutputDevice& od = OutputDevice::getDeviceByOption("movereminder-output");
581  od.openTag("movereminder");
582  od.writeAttr(SUMO_ATTR_TIME, STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()));
583  od.writeAttr("veh", getID());
585  od.writeAttr("type", type);
586  od.writeAttr("pos", toString(pos));
587  od.writeAttr("keep", toString(keep));
588  od.closeTag();
589 }
590 #endif
591 
592 /****************************************************************************/
593 
virtual bool addStop(const SUMOVehicleParameter::Stop &stopPar, std::string &errorMsg, SUMOTime untilOffset=0, bool collision=false, ConstMSEdgeVector::const_iterator *searchStart=0)=0
Adds a stop.
void removeReminder(MSMoveReminder *rem)
Removes a MoveReminder dynamically.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:261
std::vector< std::string > getStringVector(const std::string &name) const
Returns the list of string-vector-value of the named option (only for Option_String) ...
void write(OutputDevice &dev, const OptionsCont &oc, const SumoXMLTag tag=SUMO_TAG_VEHICLE, const std::string &typeID="") const
Writes the parameters as a beginning element.
MSDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists or 0.
virtual bool replaceRoute(const MSRoute *route, bool onInit=false, int offset=0, bool addStops=true)=0
Replaces the current route by the given one.
const int VEHPARS_FORCE_REROUTE
SUMOVehicleClass getVehicleClass() const
Get this vehicle type&#39;s vehicle class.
void descheduleDeparture(SUMOVehicle *veh)
stops trying to emit the given vehicle (and delete it)
const std::string & getDescription() const
MoveReminderCont myMoveReminders
Currently relevant move reminders.
double getMaxSpeed() const
Returns the maximum speed.
int repetitionNumber
The number of times the vehicle shall be repeatedly inserted.
virtual SUMOTime getWaitingTime() const =0
void setDeviceParameter(const std::string &deviceName, const std::string &key, const std::string &value)
try to set the given parameter from any of the vehicles devices, raise InvalidArgument if no device p...
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:168
virtual double getAcceleration() const
Returns the vehicle&#39;s acceleration.
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
bool isTazConnector() const
Definition: MSEdge.h:253
SUMOVehicleClass getVClass() const
Returns the vehicle&#39;s access class.
The speed is given.
virtual double getSlope() const
Returns the slope of the road at vehicle&#39;s position.
const MSEdge * getLastEdge() const
returns the destination edge
Definition: MSRoute.cpp:92
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:65
double myArrivalPos
The position on the destination lane where the vehicle stops.
Notification
Definition of a vehicle state.
A device that performs vehicle rerouting based on current edge speeds.
int getNumberReroutes() const
Returns the number of new routes this vehicle got.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice * > &into)
Build devices for the given vehicle, if needed.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:169
T MAX2(T a, T b)
Definition: StdDefs.h:74
double getMaxSpeed() const
Get vehicle&#39;s maximum speed [m/s].
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E * > &into)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
virtual ~MSBaseVehicle()
Destructor.
virtual double getPositionOnLane() const =0
Get the vehicle&#39;s position along the lane.
MSBaseVehicle(SUMOVehicleParameter *pars, const MSRoute *route, MSVehicleType *type, const double speedFactor)
Constructor.
const MSRoute * myRoute
This vehicle&#39;s route.
const std::string & getID() const
returns the id of the transportable
bool hasDeparted() const
Returns whether this vehicle has already departed.
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn&#39;t already in the dictionary...
Definition: MSEdge.cpp:745
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:79
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle&#39;s end speed shall be chosen.
int myArrivalLane
The destination lane where the vehicle stops.
const SUMOVehicleParameter * myParameter
This vehicle&#39;s parameter.
The arrival position is given.
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the stops.
Definition: MSRoute.cpp:356
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:252
bool hasValidRoute(std::string &msg, const MSRoute *route=0) const
Validates the current or given route.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice * > &into)
Build devices for the given vehicle, if needed.
Definition: MSDevice.cpp:82
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
bool replaceRouteEdges(ConstMSEdgeVector &edges, bool onInit=false, bool check=false, bool addStops=true)
Replaces the current route by the given edges.
The car-following model and parameter.
Definition: MSVehicleType.h:73
virtual void saveState(OutputDevice &out)
Saves the (common) state of a vehicle.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:65
std::string toTaz
The vehicle&#39;s destination zone (district)
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
void calculateArrivalParams()
(Re-)Calculates the arrival position and lane from the vehicle parameters
double getImpatience() const
Returns this vehicles impatience.
std::string getDeviceParameter(const std::string &deviceName, const std::string &key) const
try to retrieve the given parameter from any of the vehicles devices, raise InvalidArgument if no dev...
const std::string & getID() const
Returns the id.
Definition: Named.h:66
A road/street connecting two junctions.
Definition: MSEdge.h:81
static SUMOTime gTimeToImpatience
Definition: MSGlobals.h:73
virtual void addPerson(MSTransportable *person)
Adds a person to this vehicle.
double myDepartPos
The real depart position.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
void createDevice(const std::string &deviceName)
create device of the given type
std::string routeid
The vehicle&#39;s route id.
static bool gCheckRoutes
Definition: MSGlobals.h:86
bool wasSet(int what) const
Returns whether the given parameter was set.
#define SUMOTime_MAX
Definition: TraCIDefs.h:53
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
Definition: RGBColor.h:192
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:305
int size() const
Returns the number of edges to pass.
Definition: MSRoute.cpp:86
ConstMSEdgeVector::const_iterator MSRouteIterator
Definition: MSRoute.h:65
void removeVType(const MSVehicleType *vehType)
int arrivalLane
(optional) The lane the vehicle shall arrive on (not used yet)
#define STEPS2TIME(x)
Definition: SUMOTime.h:65
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:128
T MIN2(T a, T b)
Definition: StdDefs.h:68
std::string fromTaz
The vehicle&#39;s origin zone (district)
Something on a lane to be noticed about vehicle movement.
bool isVehicleSpecific() const
Returns whether this type belongs to a single vehicle only (was modified)
void addReference() const
increments the reference counter for the route
Definition: MSRoute.cpp:99
double arrivalPos
(optional) The position the vehicle shall arrive on
std::vector< std::string > via
List of the via-edges the vehicle must visit.
Abstract in-vehicle device.
Definition: MSDevice.h:71
trigger: the time of the step
The vehicle has departed (was inserted into the network)
void addStops(const bool ignoreStopErrors)
Adds stops to the built vehicle.
Structure representing possible vehicle parameter.
const MSEdge * succEdge(int nSuccs) const
Returns the nSuccs&#39;th successor of edge the vehicle is currently at.
MSRouteIterator end() const
Returns the end of the list of edges to pass.
Definition: MSRoute.cpp:80
double getPreviousSpeed() const
Returns the vehicle&#39;s previous speed.
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:358
MSVehicleType * myType
This vehicle&#39;s type.
int setParameter
Information for the router which parameter were set, TraCI may modify this (whe changing color) ...
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING) const
Get the allowed lanes to reach the destination-edge.
Definition: MSEdge.cpp:296
void onDepart()
Called when the vehicle is inserted into the network.
A storage for options typed value containers)
Definition: OptionsCont.h:99
bool hasDevice(const std::string &deviceName) const
check whether the vehicle is equiped with a device of the given type
virtual void activateReminders(const MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
"Activates" all current move reminder
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
virtual bool hasArrived() const
Returns whether this vehicle has already arived (by default this is true if the vehicle has reached i...
virtual const MSEdge * getRerouteOrigin() const
Returns the starting point for reroutes (usually the current edge)
The arrival lane is given.
const std::string & getID() const
Returns the name of the vehicle type.
int myNumberReroutes
The number of reroutings.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle&#39;s parameter (including departure definition)
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Computes a new route on vehicle insertion.
virtual const ConstMSEdgeVector getStopEdges() const =0
Returns the list of still pending stop edges.
MSVehicleType * buildSingularType(const std::string &id) const
Duplicates the microsim vehicle type giving the newly created type the given id, marking it as vehicl...
description of a vehicle
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
const RGBColor & getColor() const
Returns the color.
Definition: MSRoute.cpp:347
bool closeTag()
Closes the most recently opened tag.
long long int SUMOTime
Definition: TraCIDefs.h:52
MSRouteIterator myCurrEdge
Iterator to current route-edge.
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
void reroute(SUMOTime t, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false)
Performs a rerouting using the given router.
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
void vehicleDeparted(const SUMOVehicle &v)
Informs this control about a vehicle&#39;s departure.
void release() const
deletes the route if there are no further references to it
Definition: MSRoute.cpp:105
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
void addReminder(MSMoveReminder *rem)
Adds a MoveReminder dynamically.
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
std::vector< MSDevice * > myDevices
The devices this vehicle has.
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
virtual void addContainer(MSTransportable *container)
Adds a container to this vehicle.
static void checkDist(const std::string &id)
Checks the distribution whether it is permanent and deletes it if not.
Definition: MSRoute.cpp:190
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
SUMOTime myDeparture
The real departure time.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:74
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
static const SUMOTime NOT_YET_DEPARTED
std::string id
The vehicle&#39;s id.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
const std::string & getID() const
Returns the name of the vehicle.
double myChosenSpeedFactor
A precomputed factor by which the driver wants to be faster than the speed limit. ...
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
Definition: MSRoute.cpp:118
The arrival position is chosen randomly.