 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
60 myCurrentLane(nullptr),
62 myLastParameterised(nullptr) {
77 out.
writeAttr(
"xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance").
writeAttr(
"xsi:noNamespaceSchemaLocation",
"http://sumo.dlr.de/xsd/state_file.xsd");
93 for (std::vector<MSLane*>::const_iterator it = lanes.begin(); it != lanes.end(); ++it) {
94 (*it)->saveState(out);
188 const std::string laneID = attrs.
get<std::string>(
SUMO_ATTR_ID,
nullptr, ok);
191 throw ProcessError(
"Unknown lane '" + laneID +
"' in loaded state");
251 if (routingDevice !=
nullptr) {
259 if (dev->getID() == attrID) {
const std::vector< std::string > getStringVector(int attr) const
Tries to read given attribute assuming it is a string vector.
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
int getNumericalID() const
Returns the numerical id of the edge.
int parametersSet
Information for the router which parameter were set, TraCI may modify this (whe changing color)
A device that performs vehicle rerouting based on current edge speeds.
#define WRITE_WARNING(msg)
virtual void setChosenSpeedFactor(const double factor)=0
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
A single mesoscopic segment (cell)
Static storage of an output device and its base (abstract) implementation.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
bool myAmLoadingState
whether a state file is being loaded
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.
void myEndElement(int element)
Called when a closing tag occurs.
parameter associated to a certain key
void discountStateLoaded(bool removed=false)
avoid counting a vehicle twice if it was loaded from state and route input
void saveState(OutputDevice &out)
Saves the current state into the given stream.
virtual int getInt(int id) const =0
Returns the int-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.
static std::mt19937 * getEquipmentRNG()
const MSEdge & getEdge() const
Returns the edge this segment belongs to.
const int VEHPARS_FORCE_REROUTE
static std::string saveState(std::mt19937 *rng=0)
save rng state to string
MSInsertionControl & getInsertionControl()
Returns the insertion control.
const SUMOTime myOffset
offset
begin/end of the description of a single lane
Representation of a vehicle.
virtual SUMOSAXAttributes * clone() const =0
return a new deep-copy attributes object
static OptionsCont & getOptions()
Retrieves the options.
Structure representing possible vehicle parameter.
description of a vehicle type
virtual double getFloat(int id) const =0
Returns the double-value of the named (by its enum-value) attribute.
void close()
Closes the device and removes it from the dictionary.
void closeVehicle()
Ends the processing of a vehicle.
static void saveState(const std::string &file, SUMOTime step)
Saves the current state.
static int dictSize()
Returns the number of edges.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
static MSVehicleTransfer * getInstance()
Returns the instance of this object.
weights: time range begin
virtual ~MSStateHandler()
standard destructor
Parameterised * myLastParameterised
the last object that potentially carries parameters
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
std::mt19937 * getFlowRNG()
retrieve internal RNG
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
void setState(int runningVehNo, int loadedVehNo, int endedVehNo, double totalDepartureDelay, double totalTravelTime)
Sets the current state variables as loaded from the stream.
void saveState(OutputDevice &out)
Saves the current state into the given stream.
virtual MSVehicleDevice * getDevice(const std::type_info &type) const =0
Returns a device of the given type if it exists or 0.
virtual void closeVehicle()
Ends the processing of a vehicle (note: is virtual because is reimplemented in MSStateHandler)
MESegment * mySegment
segment
std::string id
The vehicle's id.
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
virtual void myEndElement(int element)
Called when a closing tag occurs.
static void dict_saveState(OutputDevice &out)
Saves all known routes into the given stream.
SUMOSAXAttributes * myAttrs
cached attrs (used when loading vehicles)
std::string time2string(SUMOTime t)
MSLane * myCurrentLane
current lane being loaded
MSStateHandler(const std::string &file, const SUMOTime offset)
standard constructor
MESegment * getNextSegment() const
Returns the following segment on the same edge (0 if it is the last).
A road/street connecting two junctions.
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 vehicle has departed (was inserted into the network)
SUMOVehicleParameter * myVehicleParameter
Parameter of the current vehicle, trip, person, container or flow.
static std::mt19937 * getRNG()
trigger: the time of the step
SUMOTime string2time(const std::string &r)
void loadState(const std::vector< std::string > &vehIDs, MSVehicleControl &vc)
Loads the state of this segment with the given parameters.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Computes a new route on vehicle insertion.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
bool writeHeader(const SumoXMLTag &rootElement)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
a flow state definition (used when saving and loading simulatino state)
static MELoop * gMesoNet
mesoscopic simulation infrastructure
virtual void loadState(const SUMOSAXAttributes &attrs, const SUMOTime offset)=0
Loads the state of this vehicle from the given description.
virtual bool hasDeparted() const =0
Returns whether this vehicle has departed.
std::vector< SUMOSAXAttributes * > myDeviceAttrs
cached device attrs (used when loading vehicles)
static void loadState(const std::string &state, std::mt19937 *rng=0)
load rng state from string
static std::mt19937 * getParsingRNG()
get parsing RNG
Parser and container for routes during their loading.
void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
bool addFlow(SUMOVehicleParameter *const pars, int index=-1)
Adds parameter for a vehicle flow for departure.
static void saveRNGs(OutputDevice &out)
save the state of random number generators
static std::mt19937 * getRNG()
The class responsible for building and deletion of vehicles.
void loadState(const SUMOSAXAttributes &attrs, const SUMOTime offset, MSVehicleControl &vc)
Loads one transfer vehicle state from the given descriptionn.
SUMOVTypeParameter * myCurrentVType
The currently parsed vehicle type.
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,...
virtual const std::vector< MSVehicleDevice * > & getDevices() const =0
Returns this vehicle's devices.
void saveState(OutputDevice &out)
Saves the current state into the given stream.
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
std::set< std::string > myVehiclesToRemove
vehicles that shall be removed when loading state
Encapsulated SAX-Attributes.
static std::mt19937 * getResponseTimeRNG()
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Abstract in-vehicle device.
void alreadyDeparted(SUMOVehicle *veh)
stops trying to emit the given vehicle (because it already departed)