 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
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());
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;
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) {
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) {
The car-following model and parameter.
const MSLane & getLane() const
Returns the lane this stop is located at.
bool add(T val, double prob, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.
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.
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
const std::string & getID() const
Returns the name of the vehicle type.
bool wasSet(int what) const
Returns whether the given parameter was set.
int getNumPredecessors() const
Returns the number of edges this edge is connected to.
A lane area vehicles can halt at.
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.
int parametersSet
Information for the router which parameter were set, TraCI may modify this (whe changing color)
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
#define WRITE_WARNING(msg)
Representation of a lane in the micro simulation.
std::string lane
The lane to stop at.
void closeContainer()
Ends the processing of a container.
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.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
double getEndLanePosition() const
Returns the end position of this stop.
bool parseStop(SUMOVehicleParameter::Stop &stop, const SUMOSAXAttributes &attrs, std::string errorSuffix, MsgHandler *const errorOutput)
parses attributes common to all stops
bool myAmLoadingState
whether a state file is being loaded
std::string myCurrentVTypeDistributionID
The id of the currently parsed vehicle type distribution.
bool hasNext()
returns the information whether further substrings exist
static bool gStateLoaded
Information whether a state has been loaded.
void closeTrip()
Ends the processing of a trip.
virtual MSTransportableControl & getContainerControl()
Returns the container 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 vtypeid
The vehicle's type id.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
const int VEHPARS_FORCE_REROUTE
MSTransportable::MSTransportablePlan * myActiveContainerPlan
The plan of the current container.
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
void addPerson(const SUMOSAXAttributes &attrs)
Processing of a person.
double getBeginLanePosition() const
Returns the begin position of this stop.
std::string busstop
(Optional) bus stop if one is assigned to the stop
MSInsertionControl & getInsertionControl()
Returns the insertion control.
virtual ~MSRouteHandler()
standard destructor
void openVehicleTypeDistribution(const SUMOSAXAttributes &attrs)
opens a type distribution for reading
static double toDoubleSecure(const std::string &sData, const double def)
converts a string into the integer value described by it
void openRoute(const SUMOSAXAttributes &attrs)
opens a route for reading
void parseFromViaTo(std::string element, const SUMOSAXAttributes &attrs)
Called for parsing from and to and the corresponding taz attributes.
Representation of a vehicle.
void addRide(const SUMOSAXAttributes &attrs)
Processing of a ride.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static OptionsCont & getOptions()
Retrieves the options.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
void setCosts(double costs)
Sets the costs of the route.
std::string next()
returns the next substring when it exists. Otherwise the behaviour is undefined
void openTrip(const SUMOSAXAttributes &attrs)
opens a trip for reading
std::string parkingarea
(Optional) parking area if one is assigned to the stop
Structure representing possible vehicle parameter.
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.
void closeVType()
Ends the processing of a vehicle type.
void closeRoute(const bool mayBeDisconnected=false)
closes (ends) the building of a route.
void openRouteDistribution(const SUMOSAXAttributes &attrs)
opens a route distribution for reading
double getLength() const
return the length of the edge
const bool myHardFail
flag to enable or disable hard fails
void addContainer(const SUMOSAXAttributes &attrs)
Processing of a container.
const MSEdge * getDestination() const
returns the destination edge
std::vector< SUMOVehicleParameter::Stop > myActiveRouteStops
List of the stops on the parsed route.
static bool checkStopPos(double &startPos, double &endPos, const double laneLength, const double minLength, const bool friendlyPos)
check start and end position of a stop
const int VEHPARS_ROUTE_SET
SUMOTime computeRandomDepartOffset() const
compute (optional) random offset to the departure time
const double DEFAULT_CONTAINER_TRANSHIP_SPEED
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.
std::string myActiveRouteRefID
The id of the route the current route references to.
void closePersonFlow()
Ends the processing of a personFlow.
bool checkLastDepart()
Checks whether the route file is sorted by departure time if needed.
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
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.
a flow definitio nusing a from-to edges instead of a route (used by router)
static std::mt19937 myParsingRNG
A random number generator used to choose from vtype/route distributions and computing the speed facto...
ConstMSEdgeVector myActiveRoute
The current route.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
void deleteActivePlans()
delete already created MSTransportablePlans if error occurs before handing over responsibility to a M...
void addTranship(const SUMOSAXAttributes &attrs)
Processing of a tranship.
SUMOTime until
The time at which the vehicle may continue its journey.
const std::string DEFAULT_VTYPE_ID
const RGBColor * myActiveRouteColor
The currently parsed route's color.
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 MSTransportable * buildPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, std::mt19937 *rng) const
Builds a new person.
virtual void closeVehicle()
Ends the processing of a vehicle (note: is virtual because is reimplemented in MSStateHandler)
double myCurrentCosts
The currently parsed route costs.
vehicle is a passenger car (a "normal" car)
RandomDistributor< const MSRoute * > * myCurrentRouteDistribution
The currently parsed distribution of routes (probability->route)
std::string id
The vehicle's id.
double getLength() const
Returns the lane's length.
void closeRouteDistribution()
closes (ends) the building of a distribution
double repetitionProbability
The probability for emitting a vehicle per second.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
std::string fromTaz
The vehicle's origin zone (district)
void closeVehicleTypeDistribution()
closes (ends) the building of a distribution
RandomDistributor< MSVehicleType * > * myCurrentVTypeDistribution
The currently parsed distribution of vehicle types (probability->vehicle type)
int repetitionsDone
The number of times the vehicle was already inserted.
A road/street connecting two junctions.
double endPos
The stopping position end.
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
const MSJunction * getToJunction() const
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 position is chosen randomly.
double myActiveRouteProbability
The probability of the current route.
const std::vector< double > & getProbs() const
Returns the probabilities assigned to the members of the distribution.
int getQuota(double frac=-1) const
Returns the number of instances of the current vehicle that shall be emitted considering that "frac" ...
std::string routeid
The vehicle's route id.
SUMOVehicleParameter * myVehicleParameter
Parameter of the current vehicle, trip, person, container or flow.
SUMOTime string2time(const std::string &r)
std::string myCurrentRouteDistributionID
The id of the currently parsed route distribution.
MSRouteHandler(const std::string &file, bool addVehiclesDirectly)
standard constructor
double getArrivalPos() const
double startPos
The stopping position start.
void registerLastDepart()
save last depart (only to be used if vehicle is not discarded)
MSEdge & getEdge() const
Returns the lane's edge.
SUMOTime repetitionEnd
The time at which the flow ends (only needed when using repetitionProbability)
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
void closePerson()
Ends the processing of a person.
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
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 & getPersonControl()
Returns the person control.
std::vector< std::string > via
List of the via-edges the vehicle must visit.
static MSVehicleType * build(SUMOVTypeParameter &from)
Builds the microsim vehicle type described by the given parameter.
const int VEHPARS_DEPARTPOS_SET
bool wasSet(int what) const
Returns whether the given parameter was set.
const int VEHPARS_FROM_TAZ_SET
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...
double getAccessPos(const MSEdge *edge) const
the position on the given edge which is connected to this stop, -1 on failure
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 addPersonTrip(const SUMOSAXAttributes &attrs)
add a routing request for a walking or intermodal person
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
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
bool myAddVehiclesDirectly
Information whether vehicles shall be directly added to the network or kept within the buffer.
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
const int VEHPARS_TO_TAZ_SET
void error(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Handler for XML-errors.
Parser for routes during their loading.
int getNumSuccessors() const
Returns the number of edges that may be reached from this edge.
std::vector< std::string > getVector()
return vector of strings
void addWalk(const SUMOSAXAttributes &attrs)
add a fully specified walk
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
The class responsible for building and deletion of vehicles.
void closeFlow()
Ends the processing of a flow.
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
SUMOVTypeParameter * myCurrentVType
The currently parsed vehicle type.
std::string toTaz
The vehicle's destination zone (district)
void addTransport(const SUMOSAXAttributes &attrs)
Processing of a transport.
void addReference() const
increments the reference counter for the route
virtual MSTransportable * buildContainer(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan) const
Builds a new container.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
SUMOTime duration
The stopping duration.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
void openFlow(const SUMOSAXAttributes &attrs)
opens a flow for reading
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
double getOverallProb() const
Return the sum of the probabilites assigned to the members.
double getDefaultProbability() const
Get the default probability of this vehicle type.
Encapsulated SAX-Attributes.
std::string chargingStation
(Optional) charging station if one is assigned to the stop
const std::string & getID() const
Returns the id.
const double DEFAULT_VEH_PROB
std::string containerstop
(Optional) container stop if one is assigned to the stop
const double MIN_STOP_LENGTH
std::string myActiveRouteID
The id of the current route.
void addStop(const SUMOSAXAttributes &attrs)
Processing of a stop.
const int VTYPEPARS_MAXSPEED_SET
int myInsertStopEdgesAt
where stop edges can be inserted into the current route (-1 means no insertion)
static double interpretEdgePos(double pos, double maximumValue, SumoXMLAttr attr, const std::string &id)
Interprets negative edge positions and fits them onto a given edge.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
double departPos
(optional) The position the vehicle shall depart from
a single trip definition (used by router)
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
Definition of vehicle stop (position and duration)