60 myInfluencer(nullptr) {
61 if (!(*myCurrEdge)->isTazConnector()) {
63 throw ProcessError(
"Vehicle '" + pars->
id +
"' is not allowed to depart on any lane of edge '" + (*myCurrEdge)->getID() +
"'.");
67 "' is too high for the vehicle type '" + type->
getID() +
"'.");
147 if ((*myCurrEdge)->isVaporizing()) {
182 if (link !=
nullptr) {
201 if (oldLink != newLink) {
202 if (oldLink !=
nullptr) {
217 bool hadStop =
false;
219 if (stop.joinTriggered) {
220 WRITE_WARNINGF(
TL(
"Join stops are not available in meso yet (vehicle '%', segment '%')."),
228 if (stop.duration > 0) {
229 time += stop.duration;
231 if (stop.pars.until > time) {
234 time = stop.pars.until;
237 time =
MAX2(cur, stop.pars.ended);
242 stop.endBoarding = stop.pars.extension >= 0 ? time + stop.pars.extension :
SUMOTime_MAX;
247 WRITE_WARNINGF(
TL(
"Vehicle '%' has multiple stops on segment '%', time=% (stop-output will be merged)."),
252 if (taxi !=
nullptr) {
256 if (stop.triggered || stop.containerTriggered || stop.joinTriggered) {
262 if (tripinfo !=
nullptr) {
276 rem.first->notifyStopEnded();
305 time += stop.duration;
306 if (stop.pars.until > time) {
309 time = stop.pars.until;
323 bool hadStop =
false;
360 stop.triggered =
false;
361 stop.containerTriggered =
false;
367 if (stop.triggered) {
370 WRITE_WARNINGF(
TL(
"Vehicle '%' ignores triggered stop on lane '%' due to capacity constraints."),
getID(), stop.lane->getID());
371 stop.triggered =
false;
384 if (stop.containerTriggered) {
387 WRITE_WARNINGF(
TL(
"Vehicle '%' ignores container triggered stop on lane '%' due to capacity constraints."),
getID(), stop.lane->getID());
388 stop.containerTriggered =
false;
401 if (stop.joinTriggered) {
423 if (i->first == rem) {
428 if (myTraceMoveReminders) {
429 traceMoveReminder(
"notifyMove", i->first, i->second,
true);
448 if (myTraceMoveReminders) {
449 traceMoveReminder(
"notifyMove", rem->first, rem->second,
true);
455 if (isLeave && myTraceMoveReminders) {
456 traceMoveReminder(
"notifyLeave", rem->first, rem->second,
true);
462 if (myTraceMoveReminders) {
463 traceMoveReminder(
"remove", rem->first, rem->second,
false);
515 std::vector<SUMOTime> internals;
528 stop.write(out,
false);
554 throw ProcessError(
TL(
"Error: Invalid vehicles in state (may be a micro state)!"));
577 while (seg->
getIndex() != (
int)segIndex) {
#define WRITE_WARNINGF(...)
std::shared_ptr< const MSRoute > ConstMSRoutePtr
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
@ GIVEN
The speed is given.
const int VEHPARS_FORCE_REROUTE
const int STOP_STARTED_SET
@ LINKSTATE_ALLWAY_STOP
This is an uncontrolled, all-way stop link.
@ SUMO_ATTR_STATE
The state of a link.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
SUMOTime changeSegment(MEVehicle *veh, SUMOTime leaveTime, MESegment *const toSegment, MSMoveReminder::Notification reason, const bool ignoreLink=false) const
change to the next segment this handles combinations of the following cases: (ending / continuing rou...
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
bool removeLeaderCar(MEVehicle *v)
Removes the given car from the leading vehicles.
void addLeaderCar(MEVehicle *veh, MSLink *link)
Adds the given car to the leading vehicles.
A single mesoscopic segment (cell)
static const int PARKING_QUEUE
bool isOpen(const MEVehicle *veh) const
Returns whether the vehicle may use the next link.
SUMOTime getLinkPenalty(const MEVehicle *veh) const
Returns the penalty time for passing a link (if using gMesoTLSPenalty > 0 or gMesoMinorPenalty > 0)
MSLink * getLink(const MEVehicle *veh, bool tlsPenalty=false) const
Returns the link the given car will use when passing the next junction.
double getLength() const
Returns the length of the segment in meters.
const MSEdge & getEdge() const
Returns the edge this segment belongs to.
int getIndex() const
Returns the running index of the segment in the edge (0 is the most upstream).
static bool isInvalid(const MESegment *segment)
whether the given segment is 0 or encodes vaporization
MESegment * getNextSegment() const
Returns the following segment on the same edge (0 if it is the last).
double getConservativeSpeed(SUMOTime &earliestArrival) const
Returns the vehicle's estimated speed taking into account delays.
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
double getAverageSpeed() const
Returns the vehicle's estimated average speed on the segment assuming no further delays.
double getAngle() const
Returns the vehicle's direction in degrees.
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
bool replaceRoute(ConstMSRoutePtr route, const std::string &info, bool onInit=false, int offset=0, bool addRouteStops=true, bool removeStops=true, std::string *msgReturn=nullptr)
Replaces the current route by the given one.
SUMOTime myEventTime
The (planned) time of leaving the segment (cell)
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
void updateDetectorForWriting(MSMoveReminder *rem, SUMOTime currentTime, SUMOTime exitTime)
Updates a single vehicle detector if present.
MEVehicle(SUMOVehicleParameter *pars, ConstMSRoutePtr route, MSVehicleType *type, const double speedFactor)
Constructor.
BaseInfluencer & getBaseInfluencer()
Returns the velocity/lane influencer.
double getCurrentStoppingTimeSeconds() const
Returns the delay that is accrued due to option –meso-tls-penalty or –meso-minor-penalty.
bool mayProceed()
Returns whether the vehicle is allowed to pass the next junction, checks also for triggered stops.
double estimateLeaveSpeed(const MSLink *link) const
Returns the vehicle's estimated speed after driving accross the link.
void processStop()
ends the current stop and performs loading/unloading
bool hasArrived() const
Returns whether this vehicle has already arived (reached the arrivalPosition on its final edge)
bool moveRoutePointer()
Update when the vehicle enters a new edge in the move step.
SUMOTime checkStop(SUMOTime time)
Returns until when to stop at the current segment and sets the information that the stop has been rea...
void updateDetectors(SUMOTime currentTime, const bool isLeave, const MSMoveReminder::Notification reason=MSMoveReminder::NOTIFICATION_JUNCTION)
Updates all vehicle detectors.
virtual bool isIdling() const
Returns whether the vehicle is trying to re-enter the net.
SUMOTime getLastEntryTime() const
Returns the time the vehicle entered the current segment.
double getPositionOnLane() const
Get the vehicle's position along the lane.
SUMOTime myLastEntryTime
The time the vehicle entered its current segment.
BaseInfluencer * myInfluencer
An instance of a velocity/lane influencing instance; built in "getInfluencer".
void setApproaching(MSLink *link)
registers vehicle with the given link
void saveState(OutputDevice &out)
Saves the states of a vehicle.
MESegment * getSegment() const
Returns the current segment the vehicle is on.
MESegment * mySegment
The segment the vehicle is at.
int getQueIndex() const
Returns the index of the que the vehicle is in.
SUMOTime getWaitingTime() const
Returns the duration for which the vehicle was blocked.
void loadState(const SUMOSAXAttributes &attrs, const SUMOTime offset)
Loads the state of this vehicle from the given description.
virtual void setSegment(MESegment *s, int idx=0)
Sets the current segment the vehicle is at together with its que.
double getCurrentLinkPenaltySeconds() const
Returns the delay that is accrued due to option –meso-tls-penalty or –meso-minor-penalty.
SUMOTime getEventTime() const
Returns the (planned) time at which the vehicle leaves its current segment.
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
bool resumeFromStopping()
double getSpeed() const
Returns the vehicle's estimated speed assuming no delays.
double getSlope() const
Returns the slope of the road at vehicle's position in degrees.
SUMOTime myBlockTime
The time at which the vehicle was blocked on its current segment.
double getRightSideOnEdge(const MSLane *) const
Get the vehicle's lateral position on the edge of the given lane (or its current edge if lane == 0)
The base class for microscopic and mesoscopic vehicles.
MSVehicleDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists, nullptr otherwise.
std::list< MSStop > myStops
The vehicle's list of stops.
void calculateArrivalParams(bool onInit)
(Re-)Calculates the arrival position and lane from the vehicle parameters
MoveReminderCont myMoveReminders
Currently relevant move reminders.
double myDepartPos
The real depart position.
std::vector< MSVehicleDevice * > myDevices
The devices this vehicle has.
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
int getPersonNumber() const
Returns the number of persons.
MSRouteIterator myCurrEdge
Iterator to current route-edge.
bool hasDeparted() const
Returns whether this vehicle has already departed.
ConstMSRoutePtr myRoute
This vehicle's route.
SUMOTime myDeparture
The real departure time.
std::vector< SUMOVehicleParameter::Stop > myPastStops
The list of stops that the vehicle has already reached.
int getRoutePosition() const
return index of edge within route
bool myAmRegisteredAsWaiting
Whether this vehicle is registered as waiting for a person or container (for deadlock-recognition)
const SUMOVehicleParameter * myParameter
This vehicle's parameter.
virtual bool replaceRoute(ConstMSRoutePtr route, const std::string &info, bool onInit=false, int offset=0, bool addStops=true, bool removeStops=true, std::string *msgReturn=nullptr)
Replaces the current route by the given one.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
bool isStopped() const
Returns whether the vehicle is at a stop.
int myNumberReroutes
The number of reroutings.
double myArrivalPos
The position on the destination lane where the vehicle stops.
virtual void saveState(OutputDevice &out)
Saves the (common) state of a vehicle.
double myOdometer
A simple odometer to keep track of the length of the route already driven.
int getContainerNumber() const
Returns the number of containers.
A device which collects info on the vehicle trip (mainly on departure and arrival)
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks for waiting steps when the vehicle moves.
A device which collects info on the vehicle trip (mainly on departure and arrival)
void updateStopTime(const SUMOTime time)
update stopping time for meso
Abstract in-vehicle / in-person device.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
double getLength() const
return the length of the edge
void removeWaiting(const SUMOVehicle *vehicle) const
Removes a vehicle from the list of waiting vehicles.
static MELoop * gMesoNet
mesoscopic simulation infrastructure
static bool gUseStopEnded
whether the simulation should replay previous stop times
Representation of a lane in the micro simulation.
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
double getRightSideOnEdge() const
double interpolateLanePosToGeometryPos(double lanePos) const
virtual const PositionVector & getShape(bool) const
double getWidth() const
Returns the lane's width.
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
LinkState getState() const
Returns the current state of the link.
void setApproaching(const SUMOVehicle *approaching, const SUMOTime arrivalTime, const double arrivalSpeed, const double leaveSpeed, const bool setRequest, const double arrivalSpeedBraking, const SUMOTime waitingTime, double dist, double latOffset)
Sets the information about an approaching vehicle.
void removeApproaching(const SUMOVehicle *veh)
removes the vehicle from myApproachingVehicles
MSLane * getViaLaneOrLane() const
return the via lane if it exists and the lane otherwise
double getLength() const
Returns the length of this link.
Something on a lane to be noticed about vehicle movement.
Notification
Definition of a vehicle state.
@ NOTIFICATION_SEGMENT
The vehicle changes the segment (meso only)
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
@ NOTIFICATION_TELEPORT
The vehicle is being teleported.
void updateDetector(SUMOTrafficObject &veh, double entryPos, double leavePos, SUMOTime entryTime, SUMOTime currentTime, SUMOTime leaveTime, bool cleanUp)
The simulated network and simulation perfomer.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
virtual MSTransportableControl & getContainerControl()
Returns the container control.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
bool hasContainers() const
Returns whether containers are simulated.
bool hasPersons() const
Returns whether persons are simulated.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
bool triggered
whether an arriving person lets the vehicle continue
bool containerTriggered
whether an arriving container lets the vehicle continue
bool joinTriggered
whether coupling another vehicle (train) the vehicle continue
const MESegment * segment
The segment to stop at (mesosim only)
MSRouteIterator edge
The edge in the route to stop at.
const SUMOVehicleParameter::Stop pars
The stop parameter.
void stopStarted(const SUMOVehicle *veh, int numPersons, int numContainers, SUMOTime time)
void stopEnded(const SUMOVehicle *veh, const SUMOVehicleParameter::Stop &stop, const std::string &laneOrEdgeID, bool simEnd=false)
static MSStopOut * getInstance()
bool loadAnyWaiting(const MSEdge *edge, SUMOVehicle *vehicle, SUMOTime &timeToLoadNext, SUMOTime &stopDuration)
load any applicable transportables Loads any person / container that is waiting on that edge for the ...
void registerOneWaiting()
increases the count of vehicles waiting for a transport to allow recognition of person / container re...
void unregisterOneWaiting()
decreases the count of vehicles waiting for a transport to allow recognition of person / container re...
The car-following model and parameter.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
double getMaxSpeed() const
Get vehicle's (technical) maximum speed [m/s].
int getPersonCapacity() const
Get this vehicle type's person capacity.
const std::string & getID() const
Returns the name of the vehicle type.
double getLength() const
Get vehicle's length [m].
const std::string & getID() const
Returns the id.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
A point in 2D or 3D with translation and scaling methods.
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
double slopeDegreeAtOffset(double pos) const
Returns the slope at the given length.
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
Definition of vehicle stop (position and duration)
SUMOTime ended
the time at which this stop was ended
double endPos
The stopping position end.
Structure representing possible vehicle parameter.
int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
double departSpeed
(optional) The initial speed of the vehicle
std::vector< std::string > via
List of the via-edges the vehicle must visit.
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
std::string id
The vehicle's id.
bool wasSet(int what) const
Returns whether the given parameter was set.
int arrivalEdge
(optional) The final edge within the route of the vehicle