48 #ifdef CHECK_MEMORY_LEAKS 50 #endif // CHECK_MEMORY_LEAKS 57 std::set<std::string> MSBaseVehicle::myShallTraceMoveReminders;
66 throw ProcessError(
"getPreviousSpeed() is not available for non-MSVehicles.");
83 , myTraceMoveReminders(myShallTraceMoveReminders.count(pars->id) > 0)
92 for (std::vector< MSDevice* >::iterator dev =
myDevices.begin(); dev !=
myDevices.end(); ++dev) {
106 for (std::vector< MSDevice* >::iterator dev =
myDevices.begin(); dev !=
myDevices.end(); ++dev) {
167 assert(viaEdge != 0);
169 throw ProcessError(
"Vehicle '" +
getID() +
"' is not allowed on any lane of via edge '" + viaEdge->
getID() +
"'.");
171 stops.push_back(viaEdge);
178 router.
compute(source, *s,
this, t, edges);
183 router.
compute(source, sink,
this, t, edges);
185 edges.erase(edges.begin());
205 std::string
id =
getID();
209 if (
myRoute->
getID().find(
"!var#") != std::string::npos) {
214 int oldSize = (int)edges.size();
217 if (origin != *
myCurrEdge && edges.front() == origin) {
219 oldSize = (int)edges.size();
297 start = route->
begin();
303 msg =
"No connection between edge '" + (*e)->getID() +
"' and edge '" + (*(e + 1))->getID() +
"'.";
310 if ((*e)->prohibits(
this)) {
311 msg =
"Edge '" + (*e)->getID() +
"' prohibits.";
322 if (myTraceMoveReminders) {
323 traceMoveReminder(
"add", rem, 0,
true);
333 if (r->first == rem) {
335 if (myTraceMoveReminders) {
336 traceMoveReminder(
"remove", rem, 0,
false);
349 if (rem->first->notifyEnter(*
this, reason)) {
351 if (myTraceMoveReminders) {
352 traceMoveReminder(
"notifyEnter", rem->first, rem->second,
true);
358 if (myTraceMoveReminders) {
359 traceMoveReminder(
"notifyEnter", rem->first, rem->second,
false);
374 const SUMOReal lastLaneLength = lanes[0]->getLength();
378 WRITE_WARNING(
"Vehicle '" +
getID() +
"' will not be able to arrive at the given position!");
400 for (std::vector<MSLane*>::const_iterator l = lanes.begin(); l != lanes.end(); ++l) {
405 WRITE_WARNING(
"Vehicle '" +
getID() +
"' will not be able to arrive with the given speed!");
421 for (std::vector<MSDevice*>::const_iterator dev =
myDevices.begin(); dev !=
myDevices.end(); ++dev) {
422 if (
typeid(**dev) == type) {
444 std::string errorMsg;
445 if (!
addStop(*i, errorMsg) && !ignoreStopErrors) {
448 if (errorMsg !=
"") {
453 std::string errorMsg;
454 if (!
addStop(*i, errorMsg) && !ignoreStopErrors) {
457 if (errorMsg !=
"") {
465 MSBaseVehicle::initMoveReminderOutput(
const OptionsCont& oc) {
466 if (oc.
isSet(
"movereminder-output.vehicles")) {
467 const std::vector<std::string> vehicles = oc.
getStringVector(
"movereminder-output.vehicles");
468 myShallTraceMoveReminders.insert(vehicles.begin(), vehicles.end());
474 MSBaseVehicle::traceMoveReminder(
const std::string& type,
MSMoveReminder* rem,
SUMOReal pos,
bool keep)
const {
void removeReminder(MSMoveReminder *rem)
Removes a MoveReminder dynamically.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
const MSVehicleType * myType
This Vehicle's type.
const int VEHPARS_FORCE_REROUTE
bool hasValidRoute(std::string &msg, const MSRoute *route=0) const
Validates the current or given route.
SUMOReal myArrivalPos
The position on the destination lane where the vehicle stops.
MoveReminderCont myMoveReminders
Currently relevant move reminders.
const ConstMSEdgeVector & getEdges() const
int repetitionNumber
The number of times the vehicle shall be repeatedly inserted.
virtual SUMOReal getAcceleration() const
Returns the vehicle's acceleration.
bool hasDeparted() const
Returns whether this vehicle has already departed.
void release() const
deletes the route if there are no further references to it
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
virtual SUMOReal getPositionOnLane() const =0
Get the vehicle's position along the lane.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
SUMOReal arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
Notification
Definition of a vehicle state.
static SUMOReal rand()
Returns a random real number in [0, 1)
std::string time2string(SUMOTime t)
virtual bool 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...
const RGBColor & getColor() const
Returns the color.
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING) const
Get the allowed lanes to reach the destination-edge.
SUMOReal arrivalPos
(optional) The position the vehicle shall arrive on
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
virtual ~MSBaseVehicle()
Destructor.
const MSRoute * myRoute
This Vehicle's 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...
const MSEdge * getLastEdge() const
returns the destination edge
std::vector< const MSEdge * > ConstMSEdgeVector
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
int myArrivalLane
The destination lane where the vehicle stops.
const SUMOVehicleParameter * myParameter
This Vehicle's parameter.
const std::string & getID() const
Returns the id.
The arrival position is given.
int size() const
Returns the number of edges to pass.
int getNumberReroutes() const
Returns the number of new routes this vehicle got.
MSBaseVehicle(SUMOVehicleParameter *pars, const MSRoute *route, const MSVehicleType *type, const SUMOReal speedFactor)
Constructor.
#define WRITE_WARNING(msg)
The car-following model and parameter.
virtual void saveState(OutputDevice &out)
Saves the (common) state of a vehicle.
virtual bool addStop(const SUMOVehicleParameter::Stop &stopPar, std::string &errorMsg, SUMOTime untilOffset=0)=0
Adds a stop.
std::string toTaz
The vehicle's destination zone (district)
std::vector< Stop > stops
List of the stops the vehicle will make.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into)
Build devices for the given vehicle, if needed.
void calculateArrivalParams()
(Re-)Calculates the arrival position and lane from the vehicle parameters
A road/street connecting two junctions.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
virtual void addPerson(MSTransportable *person)
Adds a person to this vehicle.
virtual const MSEdge * getRerouteOrigin() const
Returns the starting point for reroutes (usually the current edge)
The edge is a district edge.
std::string routeid
The vehicle's route id.
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
ConstMSEdgeVector::const_iterator MSRouteIterator
int arrivalLane
(optional) The lane the vehicle shall arrive on (not used yet)
SUMOTime depart
The vehicle's departure time.
SUMOReal getMaxSpeed() const
Returns the maximum speed.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
std::vector< std::string > getStringVector(const std::string &name) const
Returns the list of string-vector-value of the named option (only for Option_String) ...
std::string fromTaz
The vehicle's origin zone (district)
virtual const ConstMSEdgeVector getStopEdges() const =0
Returns the list of still pending stop edges.
Something on a lane to be noticed about vehicle movement.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
SUMOReal getPreviousSpeed() const
Returns the vehicle's previous speed.
std::vector< std::string > via
List of the via-edges the vehicle must visit.
Abstract in-vehicle device.
SUMOReal myChosenSpeedFactor
A precomputed factor by which the driver wants to be faster than the speed limit. ...
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
void addStops(const bool ignoreStopErrors)
Adds stops to the built vehicle.
Structure representing possible vehicle parameter.
MSDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists or 0.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
virtual SUMOReal getSlope() const
Returns the slope of the road at vehicle's position.
virtual bool hasArrived() const
Returns whether this vehicle has already arived (by default this is true if the vehicle has reached i...
const std::string & getDescription() const
int setParameter
Information for the router which parameter were set.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
virtual void activateReminders(const MSMoveReminder::Notification reason)
"Activates" all current move reminder
void onDepart()
Called when the vehicle is inserted into the network.
A storage for options typed value containers)
virtual bool replaceRoute(const MSRoute *route, bool onInit=false, int offset=0)=0
Replaces the current route by the given one.
SUMOReal getMaxSpeed() const
Get vehicle's maximum speed [m/s].
const std::string & getID() const
Returns the name of the vehicle type.
bool replaceRouteEdges(ConstMSEdgeVector &edges, bool onInit=false, bool check=false)
Replaces the current route by the given edges.
The arrival lane is given.
void addReference() const
increments the reference counter for the route
int myNumberReroutes
The number of reroutings.
static SUMOTime gTimeToGridlock
virtual SUMOTime getWaitingTime() const =0
const MSEdge * succEdge(int nSuccs) const
Returns the nSuccs'th successor of edge the vehicle is currently at.
bool wasSet(int what) const
Returns whether the given parameter was set.
Static storage of an output device and its base (abstract) implementation.
bool closeTag()
Closes the most recently opened tag.
MSRouteIterator myCurrEdge
Iterator to current route-edge.
void reroute(SUMOTime t, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false)
Performs a rerouting using the given router.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
void vehicleDeparted(const SUMOVehicle &v)
Informs this control about a vehicle's departure.
SUMOReal getImpatience() const
Returns this vehicles impatience.
SUMOReal myDepartPos
The real depart position.
const std::string & getID() const
Returns the name of the vehicle.
void addReminder(MSMoveReminder *rem)
Adds a MoveReminder dynamically.
std::vector< MSDevice * > myDevices
The devices this vehicle has.
virtual void addContainer(MSTransportable *container)
Adds a container to this vehicle.
static void checkDist(const std::string &id)
Checks the distribution whether it is permanent and deletes it if not.
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the stops.
MSRouteIterator end() const
Returns the end of the list of edges to pass.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
SUMOTime myDeparture
The real departure time.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
static const SUMOTime NOT_YET_DEPARTED
std::string id
The vehicle's id.
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
The arrival position is chosen randomly.