73 bool addVehiclesDirectly) :
76 myActiveContainerPlan(0),
77 myAddVehiclesDirectly(addVehiclesDirectly),
78 myCurrentVTypeDistribution(0),
79 myCurrentRouteDistribution(0),
80 myAmLoadingState(false) {
92 MSTransportable::MSTransportablePlan::iterator i;
185 to = &bs->getLane().getEdge();
190 const std::string fromID = attrs.
get<std::string>(
SUMO_ATTR_FROM, pid.c_str(), ok);
193 throw ProcessError(
"The from edge '" + fromID +
"' within a ride of person '" + pid +
"' is not known.");
203 throw ProcessError(
"The start edge for person '" + pid +
"' is not known.");
206 const std::string toID = attrs.
get<std::string>(
SUMO_ATTR_TO, pid.c_str(), ok);
209 throw ProcessError(
"The to edge '" + toID +
"' within a ride of person '" + pid +
"' is not known.");
233 double departPos = 0;
234 double arrivalPos = 0;
255 if (toID !=
"" && to == 0) {
262 const std::string
error =
"No connection found between '" + from->getID() +
"' and '" + to->getID() +
"' for person '" +
myVehicleParameter->
id +
"'.";
298 const std::string desc = attrs.
get<std::string>(
SUMO_ATTR_LINES, containerId.c_str(), ok);
311 const std::string fromID = attrs.
get<std::string>(
SUMO_ATTR_FROM, containerId.c_str(), ok);
314 throw ProcessError(
"The from edge '" + fromID +
"' within a transport of container '" + containerId +
"' is not known.");
324 throw ProcessError(
"The start edge within a transport of container '" + containerId +
"' is not known.");
326 const std::string toID = attrs.
get<std::string>(
SUMO_ATTR_TO, containerId.c_str(), ok);
329 throw ProcessError(
"The to edge '" + toID +
"' within a transport of container '" + containerId +
"' is not known.");
360 arrivalPos = cs->getEndLanePosition();
380 const std::string
error =
"No connection found between '" + from->getID() +
"' and '" + to->getID() +
"' for container '" +
myVehicleParameter->
id +
"'.";
429 while (st.hasNext()) {
430 std::string vtypeID = st.next();
515 const std::string
id = vehType->
getID();
518 throw ProcessError(
"Another vehicle type (or distribution) with the id '" +
id +
"' exists.");
543 std::string type =
"vehicle";
544 if (mayBeDisconnected) {
626 std::vector<double> probs;
639 std::string routeID = st.
next();
644 const double prob = ((int)probs.size() > probIndex ? probs[probIndex] : 1.0);
650 if (probs.size() > 0 && probIndex != (int)probs.size()) {
772 for (
int i = 1; i < quota; i++) {
795 throw ProcessError(
"Another vehicle with the id '" + veh_id +
"' exists.");
923 std::string errorSuffix;
994 if (ok && stop.
lane !=
"") {
996 WRITE_ERROR(
"The lane '" + stop.
lane +
"' for a stop is not known" + errorSuffix);
1014 WRITE_ERROR(
"A stop must be placed on a busStop, a chargingStation, a containerStop a parkingArea or a lane" + errorSuffix);
1039 WRITE_WARNING(
"Deprecated attribute 'pos' in description of stop" + errorSuffix);
1045 WRITE_ERROR(
"Invalid start or end position for stop on lane '" + stop.
lane +
"'" + errorSuffix);
1076 double& departPos,
double& arrivalPos,
MSStoppingPlace*& bs,
bool& ok) {
1077 const std::string description =
"person '" + personID +
"' walking from " + fromEdge->
getID();
1086 throw ProcessError(
"Unknown bus stop '" + bsID +
"' for " + description +
".");
1093 throw ProcessError(
"Bus stop '" + bsID +
"' is not connected to arrival edge '" + toEdge->
getID() +
"' for " + description +
".");
1100 arrivalPos = arrPos;
1102 WRITE_WARNING(
"Ignoring arrivalPos for " + description +
" because it is outside the given stop '" +
toString(SUMO_ATTR_BUS_STOP) +
"'.");
1107 throw ProcessError(
"No destination edge for " + description +
".");
The departure is person triggered.
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
bool wasSet(int what) const
Returns whether the given parameter was set.
double getLength() const
return the length of the edge
static StringBijection< SumoXMLTag > CarFollowModels
car following models
void addWaiting(const MSEdge *const edge, SUMOVehicle *vehicle)
Adds a vehicle to the list of waiting vehiclse to a given edge.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
MSEdge & getEdge() const
Returns the lane's edge.
virtual void myEndElement(int element)
Called when a closing tag occurs.
ConstMSEdgeVector myActiveRoute
The current route.
Representation of a vehicle in the micro simulation.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
const int VEHPARS_FORCE_REROUTE
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
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)
static double _2doubleSec(const E *const data, double def)
converts a 0-terminated char-type array into the double value described by it
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.
MSParkingArea * getParkingArea(const std::string &id) const
Returns the named parking area.
a flow definition (used by router)
A lane area vehicles can halt at.
bool myAddVehiclesDirectly
Information whether vehicles shall be directly added to the network or kept within the buffer...
SUMOTime duration
The stopping duration.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
SUMOVehicleParameter * myVehicleParameter
Parameter of the current vehicle, trip, person, container or flow.
The departure is container triggered.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
double repetitionProbability
The probability for emitting a vehicle per second.
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)
MSPedestrianRouterDijkstra & getPedestrianRouter(const MSEdgeVector &prohibited=MSEdgeVector()) const
double getDefaultProbability() const
Get the default probability of this vehicle type.
double myActiveRouteProbability
The probability of the current route.
MSChargingStation * getChargingStation(const std::string &id) const
Returns the named charging station.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
double getOverallProb() const
Return the sum of the probabilites assigned to the members.
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
double getEndLanePosition() const
Returns the end position of this stop.
virtual MSTransportable * buildPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan) const
Builds a new person.
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.
const std::vector< double > & getProbs() const
Returns the probabilities assigned to the members of the distribution.
void registerLastDepart()
save last depart (only to be used if vehicle is not discarded)
const double DEFAULT_VEH_PROB
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)
const std::string DEFAULT_VTYPE_ID
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)
double computeChosenSpeedDeviation(std::mt19937 *rng, const double minDev=-1.) const
Computes and returns the speed deviation.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
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.
virtual MSTransportableControl & getContainerControl()
Returns the container control.
int getQuota(double frac=-1) const
Returns the number of instances of the current vehicle that shall be emitted considering that "frac" ...
std::string busstop
(Optional) bus stop if one is assigned to the stop
const std::string & getID() const
Returns the id.
A road/street connecting two junctions.
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
RandomDistributor< MSVehicleType * > * myCurrentVTypeDistribution
The currently parsed distribution of vehicle types (probability->vehicle type)
const MSLane & getLane() const
Returns the lane this stop is located at.
MSStoppingPlace * getBusStop(const std::string &id) const
Returns the named bus stop.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void closeRouteDistribution()
std::string routeid
The vehicle's route id.
Representation of a vehicle.
double startPos
The stopping position start.
Encapsulated SAX-Attributes.
bool wasSet(int what) const
Returns whether the given parameter was set.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
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
bool hasAccess(const MSEdge *edge) const
checks whether this stop provides access to the given edge
SUMOTime depart
The vehicle's departure time.
const ConstMSEdgeVector & getEdges() const
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
SUMOTime string2time(const std::string &r)
int getNumSuccessors() const
Returns the number of edges that may be reached from this edge.
const int VEHPARS_ROUTE_SET
std::string fromTaz
The vehicle's origin zone (district)
virtual MSTransportable * buildContainer(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan) const
Builds a new container.
double endPos
The stopping position end.
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
bool compute(const E *from, const E *to, double departPos, double arrivalPos, double speed, SUMOTime msTime, const N *onlyNode, std::vector< const E * > &into, bool allEdges=false)
Builds the route between the given edges using the minimum effort at the given time The definition of...
SumoXMLTag myDefaultCFModel
the default car following model
const int VEHPARS_FROM_TAZ_SET
void registerOneWaitingForPerson()
increases the count of vehicles waiting for a person to allow recogniztion of person related deadlock...
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
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)
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 {.
void registerOneWaitingForContainer()
increases the count of vehicles waiting for a container to allow recogniztion of container related de...
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.
Structure representing possible vehicle parameter.
const double DEFAULT_PEDESTRIAN_SPEED
virtual const MSRoute & getRoute() const =0
Returns the current route.
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.
int setParameter
Information for the router which parameter were set, TraCI may modify this (whe changing color) ...
std::string myCurrentVTypeDistributionID
The id of the currently parsed vehicle type distribution.
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
MSStoppingPlace * getContainerStop(const std::string &id) const
Returns the named container stop.
const std::string & getID() const
Returns the name of the vehicle type.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
double getBeginLanePosition() const
Returns the begin position of this stop.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
T get(const std::string &str) const
const RGBColor * myActiveRouteColor
The currently parsed route's color.
double myCurrentCosts
The currently parsed route costs.
virtual ~MSRouteHandler()
standard destructor
a single trip definition (used by router)
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.
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.
void release() const
deletes the route if there are no further references to it
void parseWalkPositions(const SUMOSAXAttributes &attrs, const std::string &personID, const MSEdge *fromEdge, const MSEdge *&toEdge, double &departPos, double &arrivalPos, MSStoppingPlace *&bs, bool &ok)
@ brief parse depart- and arrival positions of a walk
bool add(T val, double prob, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.
int getNumPredecessors() const
Returns the number of edges this edge is connected to.
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)
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
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.