50 myActivePlan(nullptr),
51 myActiveContainerPlan(nullptr),
52 myAddVehiclesDirectly(addVehiclesDirectly),
53 myCurrentVTypeDistribution(nullptr),
54 myCurrentRouteDistribution(nullptr),
55 myAmLoadingState(false) {
65 MSTransportable::MSTransportablePlan::iterator i;
95 if (fromTaz ==
nullptr) {
114 if (toTaz ==
nullptr) {
165 to = &bs->getLane().getEdge();
170 const std::string fromID = attrs.
get<std::string>(
SUMO_ATTR_FROM, pid.c_str(), ok);
172 if (from ==
nullptr) {
173 throw ProcessError(
"The from edge '" + fromID +
"' within a ride of person '" + pid +
"' is not known.");
183 throw ProcessError(
"The start edge for person '" + pid +
"' is not known.");
186 const std::string toID = attrs.
get<std::string>(
SUMO_ATTR_TO, pid.c_str(), ok);
189 throw ProcessError(
"The to edge '" + toID +
"' within a ride of person '" + pid +
"' is not known.");
202 const std::string desc = attrs.
get<std::string>(
SUMO_ATTR_LINES, containerId.c_str(), ok);
215 const std::string fromID = attrs.
get<std::string>(
SUMO_ATTR_FROM, containerId.c_str(), ok);
217 if (from ==
nullptr) {
218 throw ProcessError(
"The from edge '" + fromID +
"' within a transport of container '" + containerId +
"' is not known.");
228 throw ProcessError(
"The start edge within a transport of container '" + containerId +
"' is not known.");
230 const std::string toID = attrs.
get<std::string>(
SUMO_ATTR_TO, containerId.c_str(), ok);
233 throw ProcessError(
"The to edge '" + toID +
"' within a transport of container '" + containerId +
"' is not known.");
264 arrivalPos = cs->getEndLanePosition();
272 if (from ==
nullptr) {
284 const std::string
error =
"No connection found between '" + from->getID() +
"' and '" + to->getID() +
"' for container '" +
myVehicleParameter->
id +
"'.";
333 while (st.hasNext()) {
334 std::string vtypeID = st.next();
336 if (type ==
nullptr) {
424 std::string type =
"vehicle";
425 if (mayBeDisconnected) {
439 if (route !=
nullptr) {
507 std::vector<double> probs;
520 std::string routeID = st.
next();
522 if (route ==
nullptr) {
525 const double prob = ((int)probs.size() > probIndex ? probs[probIndex] : 1.0);
531 if (probs.size() > 0 && probIndex != (int)probs.size()) {
569 if (route !=
nullptr) {
583 if (vtype ==
nullptr) {
600 if (route ==
nullptr) {
638 for (
int i = 1; i < quota; i++) {
660 throw ProcessError(
"Another vehicle with the id '" + veh_id +
"' exists.");
668 if (vehicle !=
nullptr) {
763 copyPlan->push_back(s->clone());
765 myActivePlan = copyPlan;
781 const std::string
id = vehType->
getID();
784 throw ProcessError(
"Another vehicle type (or distribution) with the id '" +
id +
"' exists.");
800 if (type ==
nullptr) {
878 std::string errorSuffix;
893 const MSEdge* edge =
nullptr;
954 if (ok && stop.
lane !=
"") {
956 WRITE_ERROR(
"The lane '" + stop.
lane +
"' for a stop is not known" + errorSuffix);
974 WRITE_ERROR(
"A stop must be placed on a busStop, a chargingStation, a containerStop a parkingArea or a lane" + errorSuffix);
981 WRITE_WARNING(
"Deprecated attribute 'pos' in description of stop" + errorSuffix);
987 WRITE_ERROR(
"Invalid start or end position for stop on lane '" + stop.
lane +
"'" + errorSuffix);
998 }
else if (
myActivePlan->back()->getDestination() != edge) {
1004 const double prevAr =
myActivePlan->back()->getArrivalPos();
1007 +
"' (stop range " +
toString(start) +
"-" +
toString(end) +
" does not cover previous arrival position " +
toString(prevAr) + +
").");
1049 const std::string description =
"person '" + personID +
"' walking from " + fromEdge->
getID();
1052 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.");
1055 if (lastStage !=
nullptr) {
1068 if (bs ==
nullptr) {
1069 throw ProcessError(
"Unknown bus stop '" + bsID +
"' for " + description +
".");
1072 if (arrivalPos < 0) {
1073 throw ProcessError(
"Bus stop '" + bsID +
"' is not connected to arrival edge '" + toEdge->
getID() +
"' for " + description +
".");
1080 arrivalPos = arrPos;
1082 WRITE_WARNING(
"Ignoring arrivalPos for " + description +
" because it is outside the given stop '" +
toString(SUMO_ATTR_BUS_STOP) +
"'.");
1087 if (toEdge ==
nullptr) {
1088 throw ProcessError(
"No destination edge for " + description +
".");
1112 if (from ==
nullptr) {
1117 if (toID !=
"" && to ==
nullptr) {
1120 double departPos = 0;
1121 double arrivalPos = 0;
1127 std::string errorMsg;
1134 const std::string vtypeid = st.next();
1135 if (vehControl.
getVType(vtypeid) ==
nullptr) {
1141 if (attrs.
hasAttribute(SUMO_ATTR_SPEED) && speed <= 0) {
1156 myActivePlan->push_back(
new MSTransportable::Stage_Trip(from, fromStop, to ==
nullptr ? &stoppingPlace->
getLane().
getEdge() : to, stoppingPlace, duration, modeSet, types, speed, walkFactor, departPosLat, attrs.
hasAttribute(
SUMO_ATTR_ARRIVALPOS), arrivalPos));
1178 double departPos = 0;
1179 double arrivalPos = 0;
1184 if (route ==
nullptr) {
static double parseWalkPos(SumoXMLAttr attr, const bool hardFail, const std::string &id, double maxPos, const std::string &val, std::mt19937 *rng=0)
parse departPos or arrivalPos for a walk
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
SUMOTime repetitionEnd
The time at which the flow ends (only needed when using repetitionProbability)
double getAccessPos(const MSEdge *edge) const
the position on the given edge which is connected to this stop, -1 on failure
void openTrip(const SUMOSAXAttributes &attrs)
opens a trip for reading
int getNumPredecessors() const
Returns the number of edges this edge is connected to.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
const double MIN_STOP_LENGTH
MSEdge & getEdge() const
Returns the lane's edge.
ConstMSEdgeVector myActiveRoute
The current route.
std::string lane
The lane to stop at.
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.
RandomDistributor< const MSRoute * > * myCurrentRouteDistribution
The currently parsed distribution of routes (probability->route)
std::string next()
returns the next substring when it exists. Otherwise the behaviour is undefined
std::string vtypeid
The vehicle's type id.
virtual void closeVehicle()
Ends the processing of a vehicle (note: is virtual because is reimplemented in MSStateHandler) ...
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 definitio nusing a from-to edges instead of a route (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...
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
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, std::mt19937 *rng=nullptr)
Returns the named vehicle type or a sample from the named distribution.
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)
opens a route for reading
double myActiveRouteProbability
The probability of the current route.
std::string busstop
(Optional) bus stop if one is assigned to the stop
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...
void addTransport(const SUMOSAXAttributes &attrs)
Processing of a transport.
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.
bool hasNext()
returns the information whether further substrings exist
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)
std::string parkingarea
(Optional) parking area if one is assigned to the stop
double getLength() const
return the length of the edge
const MSJunction * getToJunction() const
const std::string DEFAULT_VTYPE_ID
void addPerson(const SUMOSAXAttributes &attrs)
Processing of a person.
The position is chosen randomly.
void closeTrip()
Ends the processing of a trip.
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.
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.
void addRide(const SUMOSAXAttributes &attrs)
Processing of a ride.
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.
static double interpretEdgePos(double pos, double maximumValue, SumoXMLAttr attr, const std::string &id)
Interprets negative edge positions and fits them onto a given edge.
double getDefaultProbability() const
Get the default probability of this vehicle type.
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()
closes (ends) the building of a distribution
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.
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.
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()
closes (ends) the building of a distribution
void addTranship(const SUMOSAXAttributes &attrs)
Processing of a tranship.
SUMOTime until
The time at which the vehicle may continue its journey.
const double DEFAULT_CONTAINER_TRANSHIP_SPEED
void closePersonFlow()
Ends the processing of a personFlow.
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)
void closeVType()
Ends the processing of a vehicle type.
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.
Definition of vehicle stop (position and duration)
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()
return vector of strings
void openRouteDistribution(const SUMOSAXAttributes &attrs)
opens a route distribution for reading
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
double departPos
(optional) The position the vehicle shall depart from
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
double startPos
The stopping position start.
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;.
void addContainer(const SUMOSAXAttributes &attrs)
Processing of a container.
static bool parsePersonModes(const std::string &modes, const std::string &element, const std::string &id, SVCPermissions &modeSet, std::string &error)
Validates a given person modes value.
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.
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.
const bool myHardFail
flag to enable or disable hard fails
virtual ~MSRouteHandler()
standard destructor
a single trip definition (used by router)
void openVehicleTypeDistribution(const SUMOSAXAttributes &attrs)
opens a type distribution for reading
std::string chargingStation
(Optional) charging station if one is assigned to the stop
std::string containerstop
(Optional) container stop if one is assigned to the stop
The class responsible for building and deletion of vehicles.
const int VEHPARS_DEPARTPOS_SET
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.
SUMOTime duration
The stopping duration.
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 openFlow(const SUMOSAXAttributes &attrs)
opens a flow for reading
void closeRoute(const bool mayBeDisconnected=false)
closes (ends) the building of a route.
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.
void addFlowPerson(SUMOTime depart, MSVehicleType *type, const std::string &baseID, int i)
delete already created MSTransportablePlans if error occurs before handing over responsibility to a M...
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.