45 #include <mesosim/MESegment.h>
46 #include <mesosim/MELoop.h>
50 #ifdef CHECK_MEMORY_LEAKS
52 #endif // CHECK_MEMORY_LEAKS
82 for (MESegment* s = MSGlobals::gMesoNet->getSegmentForEdge(*
MSEdge::dictionary(i)); s != 0; s = s->getNextSegment()) {
90 for (std::vector<MSLane*>::const_iterator it = lanes.begin(); it != lanes.end(); ++it) {
91 (*it)->saveState(out);
121 0, std::vector<SUMOVehicleParameter::Stop>());
130 std::vector<std::string> routeIDs;
133 for (std::vector<std::string>::const_iterator it = routeIDs.begin(); it != routeIDs.end(); ++it) {
138 dist->
add(prob, r,
false);
153 std::vector<std::string> typeIDs;
156 for (std::vector<std::string>::const_iterator it = typeIDs.begin(); it != typeIDs.end(); ++it) {
161 dist->
add(prob, t,
false);
182 throw ProcessError(
"Error: Could not build vehicle " + p->
id +
"!");
184 if (!v->hasDeparted()) {
192 if (mySegment == 0) {
194 }
else if (mySegment->getNextSegment() == 0) {
195 mySegment = MSGlobals::gMesoNet->getSegmentForEdge(*
MSEdge::dictionary(mySegment->getEdge().getNumericalID() + 1));
197 mySegment = mySegment->getNextSegment();
212 std::vector<std::string> vehIDs;
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
bool addVTypeDistribution(const std::string &id, RandomDistributor< MSVehicleType * > *vehTypeDistribution)
Adds a vehicle type distribution.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
std::string vtypeid
The vehicle's type id.
static void parseVTypeEmbedded(SUMOVTypeParameter &into, int element, const SUMOSAXAttributes &attrs, bool fromVType=false)
Parses an element embedded in vtype definition.
bool add(SUMOReal prob, T val, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID)
Returns the named vehicle type or a sample from the named distribution.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
std::pair< int, int > myEdgeAndLane
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...
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
SAX-handler base for SUMO-files.
SUMOVTypeParameter * myCurrentVType
The currently parsed vehicle type.
static MSVehicleType * build(SUMOVTypeParameter &from)
Builds the microsim vehicle type described by the given parameter.
#define WRITE_WARNING(msg)
The car-following model and parameter.
static void dict_saveState(OutputDevice &out)
Saves all known routes into the given stream.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, const MSRoute *route, const MSVehicleType *type)
Builds a vehicle, increases the number of built vehicles.
bool writeHeader(const SumoXMLTag &rootElement)
A road/street connecting two junctions.
static void parseEdgesList(const std::string &desc, std::vector< const MSEdge * > &into, const std::string &rid)
Parses the given string assuming it contains a list of edge ids divided by spaces.
static void parseStringVector(const std::string &def, std::vector< std::string > &into)
Splits the given string.
const std::string & getFileName() const
returns the current file name
MSStateHandler(const std::string &file, const SUMOTime offset)
standard constructor
void setState(int runningVehNo, int endedVehNo, SUMOReal totalDepartureDelay, SUMOReal totalTravelTime)
Sets the current state variables as loaded from the stream.
std::string routeid
The vehicle's route id.
Representation of a vehicle.
Encapsulated SAX-Attributes.
std::vector< const MSEdge * > MSEdgeVector
virtual SUMOReal getFloat(int id) const =0
Returns the SUMOReal-value of the named (by its enum-value) attribute.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
SUMOTime depart
The vehicle's departure time.
void saveState(OutputDevice &out)
Saves the current state into the given stream.
void addReference() const
increments the reference counter for the route
bool addVType(MSVehicleType *vehType)
Adds a vehicle type.
Structure representing possible vehicle parameter.
MSInsertionControl & getInsertionControl()
Returns the insertion control.
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
virtual ~MSStateHandler()
standard destructor
void myEndElement(int element)
Called when a closing tag occurs.
static size_t dictSize()
Returns the number of edges.
virtual int getInt(int id) const =0
Returns the int-value of the named (by its enum-value) attribute.
virtual bool getBool(int id) const =0
Returns the bool-value of the named (by its enum-value) attribute.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
Static storage of an output device and its base (abstract) implementation.
static const bool gUseMesoSim
The class responsible for building and deletion of vehicles.
static SUMOVTypeParameter * beginVTypeParsing(const SUMOSAXAttributes &attrs, const std::string &file)
Starts to parse a vehicle type.
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
virtual void loadState(const SUMOSAXAttributes &attrs, const SUMOTime offset)=0
Loads the state of this vehicle from the given description.
static void saveState(const std::string &file, SUMOTime step)
Saves the current state.
std::string id
The vehicle's id.
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.