59 #ifdef CHECK_MEMORY_LEAKS
61 #endif // CHECK_MEMORY_LEAKS
68 bool addVehiclesDirectly) :
71 myAddVehiclesDirectly(addVehiclesDirectly),
72 myCurrentVTypeDistribution(0),
73 myCurrentRouteDistribution(0) {
105 const std::string fromID = attrs.
get<std::string>(
SUMO_ATTR_FROM, pid.c_str(), ok);
108 throw ProcessError(
"The from edge '" + fromID +
"' within a ride of person '" + pid +
"' is not known.");
118 throw ProcessError(
"The start edge within for person '" + pid +
"' is not known.");
120 const std::string toID = attrs.
get<std::string>(
SUMO_ATTR_TO, pid.c_str(), ok);
123 throw ProcessError(
"The to edge '" + toID +
"' within a ride of person '" + pid +
"' is not known.");
232 while (st.hasNext()) {
233 std::string vtypeID = st.next();
307 const std::string
id = vehType->
getID();
310 throw ProcessError(
"Another vehicle type (or distribution) with the id '" +
id +
"' exists.");
385 std::vector<SUMOReal> probs;
396 size_t probIndex = 0;
398 std::string routeID = st.
next();
403 const SUMOReal prob = (probs.size() > probIndex ? probs[probIndex] : 1.0);
407 if (probs.size() > 0 && probIndex != probs.size()) {
573 std::string errorSuffix;
601 if (ok && stop.
lane !=
"") {
603 WRITE_ERROR(
"The lane '" + stop.
lane +
"' for a stop is not known" + errorSuffix);
607 WRITE_ERROR(
"A stop must be placed on a bus stop or a lane" + errorSuffix);
621 WRITE_WARNING(
"Deprecated attribute 'pos' in description of stop" + errorSuffix);
627 WRITE_ERROR(
"Invalid start or end position for stop on lane '" + stop.
lane +
"'" + errorSuffix);
641 WRITE_ERROR(
"Invalid duration or end time is given for a stop on lane '" + stop.
lane +
"'" + errorSuffix);
648 WRITE_ERROR(
"Invalid bool for 'triggered' or 'parking' for stop on lane '" + stop.
lane +
"'" + errorSuffix);
654 std::set<std::string> personIDs;
661 }
else if (idx ==
"fit") {
665 if (!ok || stop.
index < 0) {
666 WRITE_ERROR(
"Invalid 'index' for stop on lane '" + stop.
lane +
"'" + errorSuffix);
The departure is person triggered.
void addStop(const SUMOSAXAttributes &attrs)
Processing of a stop.
MSRouteHandler(const std::string &file, bool addVehiclesDirectly)
standard constructor
void addWaiting(const MSEdge *const edge, SUMOVehicle *vehicle)
virtual MSPerson * buildPerson(const SUMOVehicleParameter *pars, const MSVehicleType *vtype, MSPerson::MSPersonPlan *plan) const
Builds a new person.
virtual void myEndElement(int element)
Called when a closing tag occurs.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
static void parseStringSet(const std::string &def, std::set< std::string > &into)
Splits the given string, stores it in a set.
RandomDistributor< const MSRoute * > * myCurrentRouteDistribution
The currently parsed distribution of routes (probability->route)
const std::vector< SUMOReal > & getProbs() const
Returns the probabilities assigned to the members of the distribution.
int repetitionNumber
The number of times the vehicle shall be repeatedly inserted.
MSPerson::MSPersonPlan * myActivePlan
The plan of the current person.
std::string vtypeid
The vehicle's type id.
bool parking
whether the vehicle is removed from the net while stopping
void closeVehicle()
Ends the processing of a vehicle.
static void parseVTypeEmbedded(SUMOVTypeParameter &into, int element, const SUMOSAXAttributes &attrs, bool fromVType=false)
Parses an element embedded in vtype definition.
bool myAddVehiclesDirectly
Information whether vehicles shall be directly added to the network or kept within the buffer...
SUMOTime duration
The stopping duration.
SUMOVehicleParameter * myVehicleParameter
Parameter of the current vehicle, trip, person, or flow.
static bool dictionary(std::string id, MSLane *lane)
Inserts a MSLane into the static dictionary Returns true if the key id isn't already in the dictionar...
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID)
Returns the named vehicle type or a sample from the named distribution.
bool checkStopPos(SUMOReal &startPos, SUMOReal &endPos, const SUMOReal laneLength, const SUMOReal minLength, const bool friendlyPos)
check start and end position of a stop
static bool gStateLoaded
Information whether a state has been loaded.
SUMOVTypeParameter * myCurrentVType
The currently parsed vehicle type.
void closePerson()
Ends the processing of a person.
int repetitionsDone
The number of times the vehicle was already inserted.
void openRoute(const SUMOSAXAttributes &attrs)
static SUMOReal _2SUMORealSec(const E *const data, SUMOReal def)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
const SUMOReal DEFAULT_VEH_PROB
SUMOReal myActiveRouteProbability
The id of the current route.
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...
SUMOTime until
The time at which the vehicle may continue its journey.
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
void registerLastDepart()
save last depart (only to be used if vehicle is not discarded)
std::set< std::string > awaitedPersons
IDs of persons the vehicle has to wait for until departing.
std::string myActiveRouteID
The id of the current route.
SUMOReal getEndLanePosition() const
Returns the end position of this bus stop.
SUMOReal repetitionOffset
The time offset between vehicle reinsertions.
MSEdgeVector myActiveRoute
The current route.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
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)
SUMOReal getBeginLanePosition() const
Returns the begin position of this bus stop.
The car-following model and parameter.
static OptionsCont & getOptions()
Retrieves the options.
const MSLane & getLane() const
Returns the lane this bus stop is located at.
std::vector< Stop > stops
List of the stops the vehicle will make.
SUMOTime getOptSUMOTimeReporting(int attr, const char *objectid, bool &ok, SUMOTime defaultValue, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
static unsigned int getMaxRouteDistSize()
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, const MSRoute *route, const MSVehicleType *type)
Builds a vehicle, increases the number of built vehicles.
std::string busstop
(Optional) bus stop if one is assigned to the stop
const SUMOReal DEFAULT_PERSON_SPEED
const std::string & getID() const
Returns the id.
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.
RandomDistributor< MSVehicleType * > * myCurrentVTypeDistribution
The currently parsed distribution of vehicle types (probability->vehicle type)
SUMOReal startPos
The stopping position start.
void closeRouteDistribution()
std::string routeid
The vehicle's route id.
Representation of a vehicle.
Encapsulated SAX-Attributes.
bool wasSet(int what) const
Returns whether the given parameter was set.
SUMOReal endPos
The stopping position end.
A lane area vehicles can halt at.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
void closeVehicleTypeDistribution()
bool triggered
whether an arriving person lets the vehicle continue
unsigned int getNoFollowing() const
Returns the number of edges that may be reached from this edge.
SUMOTime depart
The vehicle's departure time.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
SUMOTime string2time(const std::string &r)
std::string fromTaz
The vehicle's origin zone (district)
MSBusStop * getBusStop(const std::string &id) const
Returns the named bus stop.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
void addReference() const
increments the reference counter for the route
void registerOneWaitingForPerson()
increases the count of vehicles waiting for a person to allow recogniztion of person related deadlock...
std::string lane
The lane to stop at.
Parser for routes during their loading.
std::string myCurrentRouteDistributionID
The id of the currently parsed route distribution.
void openRouteDistribution(const SUMOSAXAttributes &attrs)
virtual void myEndElement(int element)
Called when a closing tag occurs.
SUMOReal getOverallProb() const
Return the sum of the probabilites assigned to the members.
std::vector< SUMOVehicleParameter::Stop > myActiveRouteStops
List of the stops on the parsed route.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
static void parseStop(SUMOVehicleParameter::Stop &stop, const SUMOSAXAttributes &attrs)
virtual MSPersonControl & getPersonControl()
Returns the person control.
MSInsertionControl & getInsertionControl()
Returns the insertion control.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
std::string myCurrentVTypeDistributionID
The id of the currently parsed vehicle type distribution.
Definition of vehicle stop (position and duration)
SUMOReal getDefaultProbability() const
Get the default probability of this vehicle type.
int index
at which position in the stops list
const std::string & getID() const
Returns the name of the vehicle type.
void setDeparture(SUMOTime time, MSPerson *person)
sets the arrival time for a waiting or walking person
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const std::vector< MSEdge * > &prohibited=std::vector< MSEdge * >()) const
SUMOReal departPos
(optional) The position the vehicle shall depart from
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
const MSEdge * getFollower(unsigned int n) const
Returns the n-th of the following edges.
const int VEHPARS_TAZ_SET
bool isInQuota(SUMOReal frac=-1) const
Returns the information whether the currently vehicle number shall be emitted considering that only f...
const RGBColor * myActiveRouteColor
The currently parsed route's color.
virtual void 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 ~MSRouteHandler()
standard destructor
void openVehicleTypeDistribution(const SUMOSAXAttributes &attrs)
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 class responsible for building and deletion of vehicles.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
void release() const
deletes the route if there are no further references to it
void add(SUMOReal prob, T val, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
bool checkLastDepart()
Checks whether the route file is sorted by departure time if needed.
std::string myActiveRouteRefID
The id of the route the current route references to.
Representation of a lane in the micro simulation.
std::vector< MSPersonStage * > MSPersonPlan
the structure holding the plan of a person
void closeRoute(const bool mayBeDisconnected=false)
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
void closeFlow()
Ends the processing of a flow.
std::string id
The vehicle's id.
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.