44 #include <mesosim/MESegment.h>
45 #include <mesosim/MELoop.h>
49 #ifdef CHECK_MEMORY_LEAKS
51 #endif // CHECK_MEMORY_LEAKS
62 myEdgeAndLane(0, -1) {
80 for (MESegment* s = MSGlobals::gMesoNet->getSegmentForEdge(*
MSEdge::dictionary(i)); s != 0; s = s->getNextSegment()) {
88 for (std::vector<MSLane*>::const_iterator it = lanes.begin(); it != lanes.end(); ++it) {
89 (*it)->saveState(out);
119 0, std::vector<SUMOVehicleParameter::Stop>());
128 std::vector<std::string> routeIDs;
131 for (std::vector<std::string>::const_iterator it = routeIDs.begin(); it != routeIDs.end(); ++it) {
136 dist->
add(prob, r,
false);
151 std::vector<std::string> typeIDs;
154 for (std::vector<std::string>::const_iterator it = typeIDs.begin(); it != typeIDs.end(); ++it) {
159 dist->
add(prob, t,
false);
180 throw ProcessError(
"Error: Could not build vehicle " + p->
id +
"!");
186 if (mySegment == 0) {
188 }
else if (mySegment->getNextSegment() == 0) {
189 mySegment = MSGlobals::gMesoNet->getSegmentForEdge(*
MSEdge::dictionary(mySegment->getEdge().getNumericalID() + 1));
191 mySegment = mySegment->getNextSegment();
206 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.
Structure representing possible vehicle parameter.
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.
static void releaseRoute(const MSRoute *route)
release the route (to be used as function pointer with RandomDistributor)
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.
static unsigned int getMaxRouteDistSize()
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.
bool addVType(MSVehicleType *vehType)
Adds a vehicle type.
Structure representing possible vehicle parameter.
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.
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.
void add(SUMOReal prob, T val, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.
static SUMOVTypeParameter * beginVTypeParsing(const SUMOSAXAttributes &attrs, const std::string &file)
Starts to parse a vehicle type.
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.