Eclipse SUMO - Simulation of Urban MObility
MSStateHandler.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2012-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
20 // Parser and output filter for routes and vehicles state saving and loading
21 /****************************************************************************/
22 #include <config.h>
23 
24 #ifdef HAVE_VERSION_H
25 #include <version.h>
26 #endif
27 
28 #include <sstream>
41 #include <microsim/MSEdge.h>
42 #include <microsim/MSLane.h>
43 #include <microsim/MSGlobals.h>
44 #include <microsim/MSNet.h>
47 #include <microsim/MSRoute.h>
49 #include <microsim/MSDriverState.h>
50 #include "MSStateHandler.h"
51 
52 #include <mesosim/MESegment.h>
53 #include <mesosim/MELoop.h>
54 
55 
56 // ===========================================================================
57 // method definitions
58 // ===========================================================================
59 MSStateHandler::MSStateHandler(const std::string& file, const SUMOTime offset, bool onlyReadTime) :
60  MSRouteHandler(file, true),
61  myOffset(offset),
62  mySegment(nullptr),
63  myCurrentLane(nullptr),
64  myCurrentLink(nullptr),
65  myAttrs(nullptr),
66  myVCAttrs(nullptr),
67  myLastParameterised(nullptr),
68  myOnlyReadTime(onlyReadTime),
69  myRemoved(0) {
70  myAmLoadingState = true;
71  const std::vector<std::string> vehIDs = OptionsCont::getOptions().getStringVector("load-state.remove-vehicles");
72  myVehiclesToRemove.insert(vehIDs.begin(), vehIDs.end());
73 }
74 
75 
77 }
78 
79 
80 void
81 MSStateHandler::saveState(const std::string& file, SUMOTime step) {
84  out.writeAttr("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance").writeAttr("xsi:noNamespaceSchemaLocation", "http://sumo.dlr.de/xsd/state_file.xsd");
85  out.writeAttr(SUMO_ATTR_VERSION, VERSION_STRING).writeAttr(SUMO_ATTR_TIME, time2string(step)).writeAttr(SUMO_ATTR_TYPE, MSGlobals::gUseMesoSim ? "meso" : "micro");
86  if (OptionsCont::getOptions().getBool("save-state.rng")) {
87  saveRNGs(out);
88  }
92  if (OptionsCont::getOptions().getBool("save-state.transportables")) {
93  if (MSNet::getInstance()->hasPersons()) {
96  out.closeTag();
97  }
98  if (MSNet::getInstance()->hasContainers()) {
101  out.closeTag();
102  }
103  }
106  for (int i = 0; i < MSEdge::dictSize(); i++) {
107  for (MESegment* s = MSGlobals::gMesoNet->getSegmentForEdge(*MSEdge::getAllEdges()[i]); s != nullptr; s = s->getNextSegment()) {
108  s->saveState(out);
109  }
110  }
111  } else {
112  for (int i = 0; i < MSEdge::dictSize(); i++) {
113  const std::vector<MSLane*>& lanes = MSEdge::getAllEdges()[i]->getLanes();
114  for (std::vector<MSLane*>::const_iterator it = lanes.begin(); it != lanes.end(); ++it) {
115  (*it)->saveState(out);
116  }
117  }
118  }
120  out.close();
121 }
122 
123 
124 void
126  MSRouteHandler::myStartElement(element, attrs);
128  switch (element) {
129  case SUMO_TAG_SNAPSHOT: {
131  if (myOnlyReadTime) {
132  throw AbortParsing("Abort state parsing after reading time");
133  }
134  const std::string& version = attrs.getString(SUMO_ATTR_VERSION);
135  if (version != VERSION_STRING) {
136  WRITE_WARNING("State was written with sumo version " + version + " (present: " + VERSION_STRING + ")!");
137  }
138  break;
139  }
140  case SUMO_TAG_RNGSTATE: {
141  if (attrs.hasAttribute(SUMO_ATTR_DEFAULT)) {
143  }
146  }
149  }
150  if (attrs.hasAttribute(SUMO_ATTR_RNG_DEVICE)) {
152  }
155  }
158  }
161  }
162  break;
163  }
164  case SUMO_TAG_RNGLANE: {
165  const int index = attrs.getInt(SUMO_ATTR_INDEX);
166  const std::string state = attrs.getString(SUMO_ATTR_STATE);
167  MSLane::loadRNGState(index, state);
168  break;
169  }
170  case SUMO_TAG_DELAY: {
171  myVCAttrs = attrs.clone();
172  break;
173  }
174  case SUMO_TAG_FLOWSTATE: {
176  pars->id = attrs.getString(SUMO_ATTR_ID);
177  bool ok;
178  if (attrs.getOpt<bool>(SUMO_ATTR_REROUTE, nullptr, ok, false)) {
180  }
182  attrs.getInt(SUMO_ATTR_INDEX));
183  break;
184  }
185  case SUMO_TAG_VTYPE: {
187  break;
188  }
189  case SUMO_TAG_VEHICLE: {
191  myAttrs = attrs.clone();
192  break;
193  }
194  case SUMO_TAG_DEVICE: {
195  myDeviceAttrs.push_back(attrs.clone());
196  break;
197  }
200  break;
201  }
202  case SUMO_TAG_SEGMENT: {
203  const std::string& segmentID = attrs.getString(SUMO_ATTR_ID);
204  const MSEdge* const edge = MSEdge::dictionary(segmentID.substr(0, segmentID.rfind(":")));
205  int idx = StringUtils::toInt(segmentID.substr(segmentID.rfind(":") + 1));
207  while (idx-- > 0) {
209  }
210  myQueIndex = 0;
211  break;
212  }
213  case SUMO_TAG_LANE: {
214  bool ok;
215  const std::string laneID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
217  if (myCurrentLane == nullptr) {
218  throw ProcessError("Unknown lane '" + laneID + "' in loaded state.");
219  }
220  break;
221  }
223  try {
224  const std::vector<std::string>& vehIDs = attrs.getStringVector(SUMO_ATTR_VALUE);
227  } else {
228  myCurrentLane->loadState(vehIDs, MSNet::getInstance()->getVehicleControl());
229  }
230  } catch (EmptyData&) {} // attr may be empty
231  myQueIndex++;
232  break;
233  }
234  case SUMO_TAG_LINK: {
235  bool ok;
236  myCurrentLink = nullptr;
237  const std::string toLaneID = attrs.get<std::string>(SUMO_ATTR_TO, nullptr, ok);
238  for (MSLink* link : myCurrentLane->getLinkCont()) {
239  if (link->getViaLaneOrLane()->getID() == toLaneID) {
240  myCurrentLink = link;
241  }
242  }
243  if (myCurrentLink == nullptr) {
244  throw ProcessError("Unknown link from lane '" + myCurrentLane->getID() + "' to lane '" + toLaneID + "' in loaded state");
245  }
246  break;
247  }
248  case SUMO_TAG_APPROACHING: {
249  bool ok;
250  const std::string vehID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
251  const SUMOTime arrivalTime = attrs.get<SUMOTime>(SUMO_ATTR_ARRIVALTIME, nullptr, ok);
252  const double arrivalSpeed = attrs.get<double>(SUMO_ATTR_ARRIVALSPEED, nullptr, ok);
253  const double leaveSpeed = attrs.get<double>(SUMO_ATTR_DEPARTSPEED, nullptr, ok);
254  const bool setRequest = attrs.get<bool>(SUMO_ATTR_REQUEST, nullptr, ok);
255  const SUMOTime arrivalTimeBraking = attrs.get<SUMOTime>(SUMO_ATTR_ARRIVALTIMEBRAKING, nullptr, ok);
256  const double arrivalSpeedBraking = attrs.get<double>(SUMO_ATTR_ARRIVALSPEEDBRAKING, nullptr, ok);
257  const SUMOTime waitingTime = attrs.get<SUMOTime>(SUMO_ATTR_WAITINGTIME, nullptr, ok);
258  const double dist = attrs.get<double>(SUMO_ATTR_DISTANCE, nullptr, ok);
259  SUMOVehicle* veh = vc.getVehicle(vehID);
260  myCurrentLink->setApproaching(veh, arrivalTime, arrivalSpeed, leaveSpeed, setRequest, arrivalTimeBraking, arrivalSpeedBraking, waitingTime, dist);
261  if (!MSGlobals::gUseMesoSim) {
262  MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
263  microVeh->loadPreviousApproaching(myCurrentLink, setRequest, arrivalTime, arrivalSpeed, arrivalTimeBraking, arrivalSpeedBraking, dist, leaveSpeed);
264  }
265  break;
266  }
269  break;
270  }
271  case SUMO_TAG_PARAM: {
272  bool ok;
273  const std::string key = attrs.get<std::string>(SUMO_ATTR_KEY, nullptr, ok);
274  // circumventing empty string test
275  const std::string val = attrs.hasAttribute(SUMO_ATTR_VALUE) ? attrs.getString(SUMO_ATTR_VALUE) : "";
276  assert(myLastParameterised != 0);
277  if (myLastParameterised != nullptr) {
279  }
280  break;
281  }
283  if (attrs.getString(SUMO_ATTR_TYPE) == "person") {
285  }
286  if (attrs.getString(SUMO_ATTR_TYPE) == "container") {
288  }
289  break;
290  case SUMO_TAG_PERSON:
291  case SUMO_TAG_CONTAINER:
292  myAttrs = attrs.clone();
293  break;
294  default:
295  break;
296  }
297 }
298 
299 
300 void
303  switch (element) {
304  case SUMO_TAG_PERSON:
305  case SUMO_TAG_CONTAINER: {
308  tc.fixLoadCount();
309  delete myAttrs;
310  myAttrs = nullptr;
311  break;
312  }
313  case SUMO_TAG_SNAPSHOT: {
314  if (myVCAttrs == nullptr) {
315  throw ProcessError("Could not load vehicle control state");
316  }
323  if (myRemoved > 0) {
324  WRITE_MESSAGE("Removed " + toString(myRemoved) + " vehicles while loading state.");
326  }
327  break;
328  }
329  default:
330  break;
331  }
332  if (element != SUMO_TAG_PARAM && myVehicleParameter == nullptr && myCurrentVType == nullptr) {
333  myLastParameterised = nullptr;
334  }
335 }
336 
337 
338 void
340  assert(myVehicleParameter != nullptr);
342  // the vehicle was already counted in MSVehicleControl::setState
344  // make a copy because myVehicleParameter is reset in closeVehicle()
345  const std::string vehID = myVehicleParameter->id;
346  if (myVehiclesToRemove.count(vehID) == 0) {
348  SUMOVehicle* v = vc.getVehicle(vehID);
349  if (v == nullptr) {
350  throw ProcessError("Could not load vehicle '" + vehID + "' from state");
351  }
353  v->loadState(*myAttrs, myOffset);
354  if (v->hasDeparted()) {
355  // vehicle already departed: disable pre-insertion rerouting and enable regular routing behavior
356  MSDevice_Routing* routingDevice = static_cast<MSDevice_Routing*>(v->getDevice(typeid(MSDevice_Routing)));
357  if (routingDevice != nullptr) {
359  }
362  // register route for deadlock prevention (vehicleStateChanged would not be called otherwise)
364  }
365  }
366  while (!myDeviceAttrs.empty()) {
367  const std::string attrID = myDeviceAttrs.back()->getString(SUMO_ATTR_ID);
368  for (MSVehicleDevice* const dev : v->getDevices()) {
369  if (dev->getID() == attrID) {
370  dev->loadState(*myDeviceAttrs.back());
371  }
372  }
373  delete myDeviceAttrs.back();
374  myDeviceAttrs.pop_back();
375  }
376  } else {
377  delete myVehicleParameter;
378  myVehicleParameter = nullptr;
379  myRemoved++;
380  }
381  delete myAttrs;
382 }
383 
384 
385 void
390  out.writeAttr(SUMO_ATTR_RNG_INSERTIONCONTROL, RandHelper::saveState(MSNet::getInstance()->getInsertionControl().getFlowRNG()));
396  out.closeTag();
397 
398 }
399 
400 
401 /****************************************************************************/
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:278
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:276
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition: SUMOTime.cpp:45
long long int SUMOTime
Definition: SUMOTime.h:31
const int VEHPARS_FORCE_REROUTE
@ SUMO_TAG_LINK
Link information for state-saving.
@ SUMO_TAG_TRANSPORTABLES
@ SUMO_TAG_APPROACHING
Link-approaching vehicle information for state-saving.
@ SUMO_TAG_DEVICE
@ SUMO_TAG_VTYPE
description of a vehicle type
@ SUMO_TAG_RNGLANE
@ SUMO_TAG_FLOWSTATE
a flow state definition (used when saving and loading simulatino state)
@ SUMO_TAG_VEHICLE
description of a vehicle
@ SUMO_TAG_RAILSIGNAL_CONSTRAINT_TRACKER
Saved state for constraint tracker.
@ SUMO_TAG_RNGSTATE
@ SUMO_TAG_DELAY
@ SUMO_TAG_CONTAINER
@ SUMO_TAG_VIEWSETTINGS_VEHICLES
@ SUMO_TAG_SNAPSHOT
@ SUMO_TAG_LANE
begin/end of the description of a single lane
@ SUMO_TAG_SEGMENT
segment of a lane
@ SUMO_TAG_PARAM
parameter associated to a certain key
@ SUMO_TAG_PERSON
@ SUMO_TAG_VEHICLETRANSFER
@ SUMO_ATTR_NUMBER
@ SUMO_ATTR_ARRIVALSPEED
@ SUMO_ATTR_DEPART
@ SUMO_ATTR_RNG_INSERTIONCONTROL
@ SUMO_ATTR_ARRIVALTIME
@ SUMO_ATTR_WAITINGTIME
@ SUMO_ATTR_VALUE
@ SUMO_ATTR_RNG_DRIVERSTATE
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_DEFAULT
@ SUMO_ATTR_ARRIVALSPEEDBRAKING
@ SUMO_ATTR_REROUTE
@ SUMO_ATTR_RNG_DEVICE_TOC
@ SUMO_ATTR_INDEX
@ SUMO_ATTR_DEPARTSPEED
@ SUMO_ATTR_TO
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_RNG_DEVICE_BT
@ SUMO_ATTR_ARRIVALTIMEBRAKING
@ SUMO_ATTR_DISTANCE
@ SUMO_ATTR_SPEEDFACTOR
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_VERSION
@ SUMO_ATTR_ID
@ SUMO_ATTR_RNG_ROUTEHANDLER
@ SUMO_ATTR_RNG_DEVICE
@ SUMO_ATTR_REQUEST
@ SUMO_ATTR_KEY
@ SUMO_ATTR_STATE
The state of a link.
@ SUMO_ATTR_TIME
trigger: the time of the step
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
Definition: MELoop.cpp:302
A single mesoscopic segment (cell)
Definition: MESegment.h:47
MESegment * getNextSegment() const
Returns the following segment on the same edge (0 if it is the last).
Definition: MESegment.h:208
void loadState(const std::vector< std::string > &vehIDs, MSVehicleControl &vc, const SUMOTime blockTime, const int queIdx)
Loads the state of this segment with the given parameters.
Definition: MESegment.cpp:719
static std::mt19937 * getRNG()
A device that performs vehicle rerouting based on current edge speeds.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Computes a new route on vehicle insertion.
static std::mt19937 * getResponseTimeRNG()
Definition: MSDevice_ToC.h:176
static std::mt19937 * getEquipmentRNG()
Definition: MSDevice.h:88
A road/street connecting two junctions.
Definition: MSEdge.h:77
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
Definition: MSEdge.cpp:847
static int dictSize()
Returns the number of edges.
Definition: MSEdge.cpp:841
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:814
static bool gUseMesoSim
Definition: MSGlobals.h:88
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition: MSGlobals.h:94
bool addFlow(SUMOVehicleParameter *const pars, int index=-1)
Adds parameter for a vehicle flow for departure.
std::mt19937 * getFlowRNG()
retrieve internal RNG
void alreadyDeparted(SUMOVehicle *veh)
stops trying to emit the given vehicle (because it already departed)
void saveState(OutputDevice &out)
Saves the current state into the given stream.
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.h:640
static void saveRNGStates(OutputDevice &out)
save random number generator states to the given output device
Definition: MSLane.cpp:3816
static void loadRNGState(int index, const std::string &state)
load random number generator state for the given rng index
Definition: MSLane.cpp:3826
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:1908
void loadState(const std::vector< std::string > &vehIDs, MSVehicleControl &vc)
Loads the state of this segment with the given parameters.
Definition: MSLane.cpp:3137
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
@ VEHICLE_STATE_NEWROUTE
The vehicle got a new route.
Definition: MSNet.h:599
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:171
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
Definition: MSNet.h:444
virtual MSTransportableControl & getContainerControl()
Returns the container control.
Definition: MSNet.cpp:995
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:371
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:424
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:986
static void loadState(const SUMOSAXAttributes &attrs)
loads the constraint state from the given attrs
void vehicleStateChanged(const SUMOVehicle *const vehicle, MSNet::VehicleState to, const std::string &info="")
Called if a vehicle changes its state.
static MSRailSignalControl & getInstance()
Parser and container for routes during their loading.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
bool myAmLoadingState
whether a state file is being loaded
static std::mt19937 * getParsingRNG()
get parsing RNG
virtual void closeVehicle()
Ends the processing of a vehicle (note: is virtual because is reimplemented in MSStateHandler)
static void dict_saveState(OutputDevice &out)
Saves all known routes into the given stream.
Definition: MSRoute.cpp:265
SUMOSAXAttributes * myAttrs
cached attrs (used when loading vehicles or transportables)
bool myOnlyReadTime
whether the handler should abort parsing (via Exception) after parsing the time
static void saveState(const std::string &file, SUMOTime step)
Saves the current state.
MSStateHandler(const std::string &file, const SUMOTime offset, bool onlyReadTime=false)
standard constructor
int myQueIndex
que index
SUMOTime myTime
time
std::set< std::string > myVehiclesToRemove
vehicles that shall be removed when loading state
int myRemoved
vehicles that were removed when loading state
MSLink * myCurrentLink
current link being loaded
MESegment * mySegment
segment
MSLane * myCurrentLane
current lane being loaded
static void saveRNGs(OutputDevice &out)
save the state of random number generators
const SUMOTime myOffset
offset
Parameterised * myLastParameterised
the last object that potentially carries parameters
void closeVehicle()
Ends the processing of a vehicle.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
std::vector< SUMOSAXAttributes * > myDeviceAttrs
cached device attrs (used when loading vehicles)
SUMOSAXAttributes * myVCAttrs
cached attrs for delayed loading of MSVehicleControl state
void myEndElement(int element)
Called when a closing tag occurs.
virtual ~MSStateHandler()
standard destructor
void saveState(OutputDevice &out)
Saves the current tls states into the given stream.
void loadState(const std::string &state)
Reconstruct the current state.
void fixLoadCount()
decrement counter to avoid double counting transportables loaded from state
void saveState(OutputDevice &out)
Saves the current state into the given stream.
MSTransportable * get(const std::string &id) const
Returns the named transportable, if existing.
The class responsible for building and deletion of vehicles.
void setState(int runningVehNo, int loadedVehNo, int endedVehNo, double totalDepartureDelay, double totalTravelTime)
Sets the current state variables as loaded from the stream.
void discountStateRemoved(int n)
discount vehicles that were removed during state loading
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
void saveState(OutputDevice &out)
Saves the current state into the given stream.
Abstract in-vehicle device.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
void loadPreviousApproaching(MSLink *link, bool setRequest, SUMOTime arrivalTime, double arrivalSpeed, SUMOTime arrivalTimeBraking, double arrivalSpeedBraking, double dist, double leaveSpeed)
Definition: MSVehicle.cpp:6392
static MSVehicleTransfer * getInstance()
Returns the instance of this object.
void saveState(OutputDevice &out)
Saves the current state into the given stream.
void loadState(const SUMOSAXAttributes &attrs, const SUMOTime offset, MSVehicleControl &vc)
Loads one transfer vehicle state from the given descriptionn.
const std::string & getID() const
Returns the id.
Definition: Named.h:73
static std::mt19937 * getRNG()
Definition: MSDriverState.h:78
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
void close()
Closes the device and removes it from the dictionary.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:239
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
bool writeHeader(const SumoXMLTag &rootElement)
Definition: OutputDevice.h:184
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
static std::string saveState(std::mt19937 *rng=0)
save rng state to string
Definition: RandHelper.h:153
static void loadState(const std::string &state, std::mt19937 *rng=0)
load rng state from string
Definition: RandHelper.h:163
SUMOVehicleParameter * myVehicleParameter
Parameter of the current vehicle, trip, person, container or flow.
SUMOVTypeParameter * myCurrentVType
The currently parsed vehicle type.
virtual void myEndElement(int element)
Called when a closing tag occurs.
Encapsulated SAX-Attributes.
virtual int getInt(int id) const =0
Returns the int-value of the named (by its enum-value) attribute.
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.
virtual SUMOSAXAttributes * clone() const =0
return a new deep-copy attributes object
const std::vector< std::string > getStringVector(int attr) const
Tries to read given attribute assuming it is a string vector.
virtual double getFloat(int id) const =0
Returns the double-value of the named (by its enum-value) attribute.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
Representation of a vehicle.
Definition: SUMOVehicle.h:58
virtual MSVehicleDevice * getDevice(const std::type_info &type) const =0
Returns a device of the given type if it exists or 0.
virtual void setChosenSpeedFactor(const double factor)=0
virtual bool hasDeparted() const =0
Returns whether this vehicle has departed.
virtual void loadState(const SUMOSAXAttributes &attrs, const SUMOTime offset)=0
Loads the state of this vehicle from the given description.
virtual const std::vector< MSVehicleDevice * > & getDevices() const =0
Returns this vehicle's devices.
Structure representing possible vehicle parameter.
int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
std::string id
The vehicle's id.
static long long int toLong(const std::string &sData)
converts a string into the long value described by it by calling the char-type converter,...
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...