68 bool addVehiclesDirectly) :
70 myActivePlan(nullptr),
71 myActiveContainerPlan(nullptr),
72 myAddVehiclesDirectly(addVehiclesDirectly),
73 myCurrentVTypeDistribution(nullptr),
74 myCurrentRouteDistribution(nullptr),
75 myAmLoadingState(false) {
85 MSTransportable::MSTransportablePlan::iterator i;
115 if (fromTaz ==
nullptr) {
134 if (toTaz ==
nullptr) {
184 to = &bs->getLane().getEdge();
189 const std::string fromID = attrs.
get<std::string>(
SUMO_ATTR_FROM, pid.c_str(), ok);
191 if (from ==
nullptr) {
192 throw ProcessError(
"The from edge '" + fromID +
"' within a ride of person '" + pid +
"' is not known.");
202 throw ProcessError(
"The start edge for person '" + pid +
"' is not known.");
205 const std::string toID = attrs.
get<std::string>(
SUMO_ATTR_TO, pid.c_str(), ok);
208 throw ProcessError(
"The to edge '" + toID +
"' within a ride of person '" + pid +
"' is not known.");
221 const std::string desc = attrs.
get<std::string>(
SUMO_ATTR_LINES, containerId.c_str(), ok);
234 const std::string fromID = attrs.
get<std::string>(
SUMO_ATTR_FROM, containerId.c_str(), ok);
236 if (from ==
nullptr) {
237 throw ProcessError(
"The from edge '" + fromID +
"' within a transport of container '" + containerId +
"' is not known.");
247 throw ProcessError(
"The start edge within a transport of container '" + containerId +
"' is not known.");
249 const std::string toID = attrs.
get<std::string>(
SUMO_ATTR_TO, containerId.c_str(), ok);
252 throw ProcessError(
"The to edge '" + toID +
"' within a transport of container '" + containerId +
"' is not known.");
283 arrivalPos = cs->getEndLanePosition();
291 if (from ==
nullptr) {
303 const std::string
error =
"No connection found between '" + from->getID() +
"' and '" + to->getID() +
"' for container '" +
myVehicleParameter->
id +
"'.";
352 while (st.hasNext()) {
353 std::string vtypeID = st.next();
355 if (type ==
nullptr) {
438 const std::string
id = vehType->
getID();
441 throw ProcessError(
"Another vehicle type (or distribution) with the id '" +
id +
"' exists.");
466 std::string type =
"vehicle";
467 if (mayBeDisconnected) {
481 if (route !=
nullptr) {
549 std::vector<double> probs;
562 std::string routeID = st.
next();
564 if (route ==
nullptr) {
567 const double prob = ((int)probs.size() > probIndex ? probs[probIndex] : 1.0);
573 if (probs.size() > 0 && probIndex != (int)probs.size()) {
611 if (route !=
nullptr) {
625 if (vtype ==
nullptr) {
642 if (route ==
nullptr) {
680 for (
int i = 1; i < quota; i++) {
702 throw ProcessError(
"Another vehicle with the id '" + veh_id +
"' exists.");
710 if (vehicle !=
nullptr) {
756 if (type ==
nullptr) {
826 std::string errorSuffix;
841 const MSEdge* edge =
nullptr;
897 if (ok && stop.
lane !=
"") {
899 WRITE_ERROR(
"The lane '" + stop.
lane +
"' for a stop is not known" + errorSuffix);
917 WRITE_ERROR(
"A stop must be placed on a busStop, a chargingStation, a containerStop a parkingArea or a lane" + errorSuffix);
942 WRITE_WARNING(
"Deprecated attribute 'pos' in description of stop" + errorSuffix);
948 WRITE_ERROR(
"Invalid start or end position for stop on lane '" + stop.
lane +
"'" + errorSuffix);
981 const std::string description =
"person '" + personID +
"' walking from " + fromEdge->
getID();
984 WRITE_WARNING(
"The attribute departPos is no longer supported for walks, please use the person attribute, the arrivalPos of the previous step or explicit stops.");
987 if (lastStage !=
nullptr) {
1000 if (bs ==
nullptr) {
1001 throw ProcessError(
"Unknown bus stop '" + bsID +
"' for " + description +
".");
1004 if (arrivalPos < 0) {
1005 throw ProcessError(
"Bus stop '" + bsID +
"' is not connected to arrival edge '" + toEdge->
getID() +
"' for " + description +
".");
1012 arrivalPos = arrPos;
1014 WRITE_WARNING(
"Ignoring arrivalPos for " + description +
" because it is outside the given stop '" +
toString(SUMO_ATTR_BUS_STOP) +
"'.");
1019 if (toEdge ==
nullptr) {
1020 throw ProcessError(
"No destination edge for " + description +
".");
1044 if (from ==
nullptr) {
1049 if (toID !=
"" && to ==
nullptr) {
1052 double departPos = 0;
1053 double arrivalPos = 0;
1060 const std::string mode = st.next();
1061 if (mode ==
"car") {
1063 }
else if (mode ==
"bicycle") {
1065 }
else if (mode ==
"public") {
1073 const std::string vtypeid = st.next();
1074 if (vehControl.
getVType(vtypeid) ==
nullptr) {
1080 if (attrs.
hasAttribute(SUMO_ATTR_SPEED) && speed <= 0) {
1087 myActivePlan->push_back(
new MSTransportable::Stage_Trip(from, to ==
nullptr ? &stoppingPlace->
getLane().
getEdge() : to, stoppingPlace, duration, modeSet, types, speed, walkFactor, departPosLat, attrs.
hasAttribute(
SUMO_ATTR_ARRIVALPOS), arrivalPos));
1109 double departPos = 0;
1110 double arrivalPos = 0;
1115 if (route ==
nullptr) {
void addStop(const SUMOSAXAttributes &attrs)
Processing of a stop.
const int VTYPEPARS_MAXSPEED_SET
const int VEHPARS_TO_TAZ_SET
MSRouteHandler(const std::string &file, bool addVehiclesDirectly)
standard constructor
double getAccessPos(const MSEdge *edge) const
the position on the given edge which is connected to this stop, -1 on failure
int getNumPredecessors() const
Returns the number of edges this edge is connected to.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
virtual void myEndElement(int element)
Called when a closing tag occurs.
MSEdge & getEdge() const
Returns the lane's edge.
ConstMSEdgeVector myActiveRoute
The current route.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
const int VEHPARS_FORCE_REROUTE
double getBeginLanePosition() const
Returns the begin position of this stop.
void parseFromViaTo(std::string element, const SUMOSAXAttributes &attrs)
Called for parsing from and to and the corresponding taz attributes.
description of a vehicle type
RandomDistributor< const MSRoute * > * myCurrentRouteDistribution
The currently parsed distribution of routes (probability->route)
std::string containerstop
(Optional) container stop if one is assigned to the stop
int repetitionNumber
The number of times the vehicle shall be repeatedly inserted.
std::string vtypeid
The vehicle's type id.
virtual void closeVehicle()
Ends the processing of a vehicle.
void release() const
deletes the route if there are no further references to it
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
a flow definition (used by router)
A lane area vehicles can halt at.
Represents a generic random distribution.
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, container or flow.
const MSEdge * getDestination() const
returns the destination edge
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
double repetitionProbability
The probability for emitting a vehicle per second.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
static bool gStateLoaded
Information whether a state has been loaded.
int parametersSet
Information for the router which parameter were set, TraCI may modify this (whe changing color) ...
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.
int getQuota(double frac=-1) const
Returns the number of instances of the current vehicle that shall be emitted considering that "frac" ...
void openRoute(const SUMOSAXAttributes &attrs)
double myActiveRouteProbability
The probability of the current route.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
double getLength() const
Returns the lane's length.
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)
const double DEFAULT_VEH_PROB
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
void addWalk(const SUMOSAXAttributes &attrs)
add a fully specified walk
const std::string & getID() const
Returns the id.
std::string myActiveRouteID
The id of the current route.
void setCosts(double costs)
Sets the costs of the route.
int myInsertStopEdgesAt
where stop edges can be inserted into the current route (-1 means no insertion)
double getLength() const
return the length of the edge
const MSJunction * getToJunction() const
const std::string DEFAULT_VTYPE_ID
The position is chosen randomly.
void parseWalkPositions(const SUMOSAXAttributes &attrs, const std::string &personID, const MSEdge *fromEdge, const MSEdge *&toEdge, double &departPos, double &arrivalPos, MSStoppingPlace *&bs, const MSTransportable::Stage *const lastStage, bool &ok)
@ brief parse depart- and arrival positions of a walk
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
virtual MSTransportable * buildContainer(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan) const
Builds a new container.
static MSVehicleType * build(SUMOVTypeParameter &from)
Builds the microsim vehicle type described by the given parameter.
static double parseWalkPos(SumoXMLAttr attr, const std::string &id, double maxPos, const std::string &val, std::mt19937 *rng=0)
parse departPos or arrivalPos for a walk
std::string parkingarea
(Optional) parking area if one is assigned to the stop
void error(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Handler for XML-errors.
#define WRITE_WARNING(msg)
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
The car-following model and parameter.
static OptionsCont & getOptions()
Retrieves the options.
std::string toTaz
The vehicle's destination zone (district)
bool wasSet(int what) const
Returns whether the given parameter was set.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
int getNumSuccessors() const
Returns the number of edges that may be reached from this edge.
void addPersonTrip(const SUMOSAXAttributes &attrs)
add a routing request for a walking or intermodal person
virtual MSTransportableControl & getContainerControl()
Returns the container control.
double getDefaultProbability() const
Get the default probability of this vehicle type.
std::string busstop
(Optional) bus stop if one is assigned to the stop
A road/street connecting two junctions.
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
double getEndLanePosition() const
Returns the end position of this stop.
RandomDistributor< MSVehicleType * > * myCurrentVTypeDistribution
The currently parsed distribution of vehicle types (probability->vehicle type)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void closeRouteDistribution()
std::string routeid
The vehicle's route id.
const std::vector< double > & getProbs() const
Returns the probabilities assigned to the members of the distribution.
Representation of a vehicle.
double startPos
The stopping position start.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
Encapsulated SAX-Attributes.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
std::string chargingStation
(Optional) charging station if one is assigned to the stop
void deleteActivePlans()
delete already created MSTransportablePlans if error occurs before handing over responsibility to a M...
void closeContainer()
Ends the processing of a container.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
void closeVehicleTypeDistribution()
const double DEFAULT_CONTAINER_TRANSHIP_SPEED
SUMOTime depart
The vehicle's departure time.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
double getArrivalPos() const
SUMOTime string2time(const std::string &r)
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
const int VEHPARS_ROUTE_SET
std::string fromTaz
The vehicle's origin zone (district)
double endPos
The stopping position end.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
vehicle is a passenger car (a "normal" car)
const int VEHPARS_FROM_TAZ_SET
MSTransportable::MSTransportablePlan * myActivePlan
The plan of the current person.
std::string lane
The lane to stop at.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, std::mt19937 *rng=0)
Returns the named vehicle type or a sample from the named distribution.
Parser for routes during their loading.
std::vector< std::string > via
List of the via-edges the vehicle must visit.
std::string myCurrentRouteDistributionID
The id of the currently parsed route distribution.
std::vector< std::string > getVector()
void openRouteDistribution(const SUMOSAXAttributes &attrs)
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
virtual void myEndElement(int element)
Called when a closing tag occurs.
double departPos
(optional) The position the vehicle shall depart from
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
static bool checkStopPos(double &startPos, double &endPos, const double laneLength, const double minLength, const bool friendlyPos)
check start and end position of a stop
std::vector< SUMOVehicleParameter::Stop > myActiveRouteStops
List of the stops on the parsed route.
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.
Structure representing possible vehicle parameter.
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 myParsingRNG
A random number generator used to choose from vtype/route distributions and computing the speed facto...
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.
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.
Definition of vehicle stop (position and duration)
bool parseStop(SUMOVehicleParameter::Stop &stop, const SUMOSAXAttributes &attrs, std::string errorSuffix, MsgHandler *const errorOutput)
parses attributes common to all stops
const std::string & getID() const
Returns the name of the vehicle type.
void addReference() const
increments the reference counter for the route
double getOverallProb() const
Return the sum of the probabilites assigned to the members.
bool wasSet(int what) const
Returns whether the given parameter was set.
const RGBColor * myActiveRouteColor
The currently parsed route's color.
double myCurrentCosts
The currently parsed route costs.
virtual MSTransportable * buildPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, std::mt19937 *rng) const
Builds a new person.
virtual ~MSRouteHandler()
standard destructor
a single trip definition (used by router)
void openVehicleTypeDistribution(const SUMOSAXAttributes &attrs)
The class responsible for building and deletion of vehicles.
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, const MSRoute *route, MSVehicleType *type, const bool ignoreStopErrors, const bool fromRouteFile=true)
Builds a vehicle, increases the number of built vehicles.
const MSLane & getLane() const
Returns the lane this stop is located at.
static double toDoubleSecure(const std::string &sData, const double def)
converts a string into the integer value described by it
SUMOTime computeRandomDepartOffset() const
compute (optional) random offset to the departure time
bool add(T val, double prob, 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.
static void parseEdgesList(const std::string &desc, ConstMSEdgeVector &into, const std::string &rid)
Parses the given string assuming it contains a list of edge ids divided by spaces.
void closeRoute(const bool mayBeDisconnected=false)
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
void closeFlow()
Ends the processing of a flow.
MSTransportable::MSTransportablePlan * myActiveContainerPlan
The plan of the current container.
std::string id
The vehicle's id.
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.