53 myParameter(pars), myVType(vtype), myPlan(plan),
55 myNumericalID(myCurrentNumericalIndex++),
77 for (MSTransportablePlan::const_iterator i =
myPlan->begin(); i !=
myPlan->end(); ++i) {
105 const std::string& error = prior->
setArrived(net,
this, time, vehicleArrived);
119 bool accessToStop =
false;
133 if (priorStop !=
nullptr) {
143 (*myStep)->proceed(net,
this, time, prior);
154 throw ProcessError(
TL(
"Changing a transportable ID is not permitted"));
164 (*myStep)->setDeparted(now);
170 if (stage->getDeparted() >= 0) {
171 return stage->getDeparted();
190 return (*myStep)->getDirection();
205 return STEPS2TIME((*myStep)->getWaitingTime());
210 return (*myStep)->getSpeed();
228 bool durationOK =
true;
229 bool waitingTimeOK =
true;
230 bool timeLossOK =
true;
231 bool travelTimeOK =
true;
239 t = i->getTotalWaitingTime();
243 waitingTimeOK =
false;
245 t = i->getTimeLoss(
this);
251 t = i->getTravelTime();
255 travelTimeOK =
false;
263 i->tripInfoOutput(os,
this);
271 const std::string typeID = (
278 const MSStage* previous =
nullptr;
303 WRITE_WARNINGF(
TL(
"Teleporting % '%'; waited too long, from edge '%', time=%."),
307 (*myStep)->abort(
this);
322 if (stepIndex + next > (
int)
myPlan->size()) {
325 myPlan->insert(
myPlan->begin() + stepIndex + next, stage);
333 assert(
myStep + next < myPlan->end());
348 (*myStep)->abort(
this);
351 }
else if (
myPlan->front()->getDeparted() < 0) {
360 for (MSTransportablePlan::const_iterator i =
myStep; i !=
myPlan->end(); ++i) {
361 (*i)->setSpeed(speed);
380 if (trip ==
nullptr) {
389 int tripEndOffset = -1;
396 std::vector<MSStage*> stages;
400 while (tripEndOffset >= 0 && !stages.empty() && stages.back()->equals(*
getNextStage(tripEndOffset))) {
401 delete stages.back();
405 bool abortCurrent =
true;
407 if (!stages.empty() && stages.front()->isWalk() &&
getCurrentStage()->isWalk()) {
412 oldEdges.erase(oldEdges.begin(), oldEdges.begin() + routeIndex);
414 if (newEdges == oldEdges) {
415 delete stages.front();
416 stages.erase(stages.begin());
417 abortCurrent =
false;
420 if (stages.empty()) {
424 for (
int i = tripEndOffset; i >= 1; i--) {
429 for (
MSStage* stage : stages) {
474 const Position back = p +
Position(-cos(angle) * length, -sin(angle) * length);
475 centerLine.push_back(p);
476 centerLine.push_back(back);
488 assert(stageIndex < (
int)
myPlan->size());
489 assert(stageIndex >= 0);
494const std::set<SUMOTrafficObject::NumericalID>
496 std::set<SUMOTrafficObject::NumericalID> result;
497 for (
auto step =
myStep; step !=
myPlan->end(); ++step) {
498 for (
const MSEdge*
const e : (*step)->getEdges()) {
499 result.insert(e->getNumericalID());
523 std::cout <<
SIMTIME <<
" person=" <<
getID() <<
" rerouteParkingArea orig=" << orig->
getID() <<
" replacement=" << replacement->
getID() <<
"\n";
538 std::cout <<
" set ride destination\n";
548 std::cout <<
" set subsequent trip origin\n";
552 std::cout <<
" replace subsequent walk with a trip\n";
560 std::cout <<
" add subsequent walk to reach stop\n";
561 std::cout <<
" arrivalPos=" << nextStage->
getArrivalPos() <<
"\n";
570 MSStage*
const futureStage = *it;
571 MSStage*
const prevStage = *(it - 1);
581 std::cout <<
" replace later trip before ride (" << (it -
myPlan->begin()) <<
")\n";
585 std::cout <<
" replace later walk before ride (" << (it -
myPlan->begin()) <<
")\n";
589 int prevStageRelIndex = (int)(it - 1 -
myStep);
604 if (
typeid(*dev) == type) {
628 const double gp = edge->
getLanes()[0]->interpolateLanePosToGeometryPos(ep);
629 return edge->
getLanes()[0]->getShape().slopeDegreeAtOffset(gp);
635 return (*myStep)->getWaitingTime();
662 if (
myPlan->front()->getDeparted() >= 0) {
680 std::ostringstream state;
682 (*myStep)->saveState(state);
684 const MSStage* previous =
nullptr;
695 std::istringstream iss(state);
700 (*myStep)->loadState(
this, iss);
std::vector< const MSEdge * > ConstMSEdgeVector
#define WRITE_WARNINGF(...)
#define WRITE_WARNING(msg)
std::shared_ptr< const MSRoute > ConstMSRoutePtr
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
const long long int VTYPEPARS_VEHICLECLASS_SET
const std::string DEFAULT_PEDTYPE_ID
const std::string DEFAULT_CONTAINERTYPE_ID
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_PEDESTRIAN
pedestrian
const long long int VEHPARS_JUNCTIONMODEL_PARAMS_SET
const long long int VEHPARS_SPEEDFACTOR_SET
@ SUMO_ATTR_JM_IGNORE_IDS
@ SUMO_ATTR_JM_IGNORE_TYPES
@ SUMO_ATTR_STATE
The state of a link.
int gPrecision
the precision for floating point outputs
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Abstract in-vehicle / in-person device.
static void buildTransportableDevices(MSTransportable &p, std::vector< MSTransportableDevice * > &into)
Build devices for the given person, if needed.
A road/street connecting two junctions.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
virtual void removeTransportable(MSTransportable *t) const
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
Representation of a lane in the micro simulation.
MSEdge & getEdge() const
Returns the lane's edge.
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
The simulated network and simulation perfomer.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
virtual MSTransportableControl & getContainerControl()
Returns the container control.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
SUMOVehicle * getVehicle() const
Current vehicle in which the transportable is driving (or nullptr)
void setOrigin(const MSEdge *origin, MSStoppingPlace *originStop, double departPos)
change origin for parking area rerouting
const std::set< std::string > & getLines() const
MSStoppingPlace * getOriginStop() const
returns the origin stop (if any). only needed for MSStageTrip
double getArrivalPos() const
return default value for undefined arrivalPos
const MSEdge * getDestination() const
returns the destination edge
virtual const MSEdge * getFromEdge() const
MSStageTrip * getTrip() const
virtual double getArrivalPos() const
virtual MSStoppingPlace * getOriginStop() const
returns the origin stop (if any). only needed for MSStageTrip
virtual const std::string setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now, const bool vehicleArrived)
logs end of the step
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
MSStageType getStageType() const
void setArrivalPos(double arrivalPos)
void setDestination(const MSEdge *newDestination, MSStoppingPlace *newDestStop)
virtual void routeOutput(const bool isPerson, OutputDevice &os, const bool withRouteLength, const MSStage *const previous) const =0
Called on writing vehroute output.
virtual const MSEdge * getEdge() const
Returns the current edge.
ConstMSEdgeVector getEdges() const
the edges of the current stage
const std::vector< const MSEdge * > & getRoute() const
const std::vector< constMSEdge * >::iterator getRouteStep() const
const std::string reroute(const SUMOTime time, MSTransportableRouter &router, MSTransportable *const transportable, MSStage *previous, const MSEdge *origin, const MSEdge *destination, std::vector< MSStage * > &stages)
A lane area vehicles can halt at.
double getBeginLanePosition() const
Returns the begin position of this stop.
double getEndLanePosition() const
Returns the end position of this stop.
void removeTransportable(const MSTransportable *p)
Removes a transportable from this stop.
const MSLane & getLane() const
Returns the lane this stop is located at.
void registerTeleportAbortWait()
register a teleport after aborting a long wait
virtual void erase(MSTransportable *transportable)
removes a single transportable
Abstract in-person device.
const MSEdge * getFromEdge() const
Returns the departure edge.
virtual double getChosenSpeedFactor() const override
the current speed factor of the transportable (where applicable)
bool isContainer() const override
Whether it is a container.
bool replaceRoute(ConstMSRoutePtr route, const std::string &info, bool onInit=false, int offset=0, bool addStops=true, bool removeStops=true, std::string *msgReturn=nullptr) override
Replaces the current route by the given one.
virtual double getEdgePos() const
Return the position on the edge.
bool hasDeparted() const
return whether the transportable has started its plan
double getPositionOnLane() const override
Get the object's position along the lane.
static NumericalID myCurrentNumericalIndex
double getBackPositionOnLane(const MSLane *lane) const override
Get the object's back position along the given lane.
const std::set< NumericalID > getUpcomingEdgeIDs() const override
returns the numerical IDs of edges to be used (possibly of future stages)
virtual double getSpeed() const override
the current speed of the transportable
void replaceVehicleType(const MSVehicleType *type) override
Replaces the current vehicle type by the one given.
SUMOTime getDeparture() const
logs depart time of the current stage
const MSEdge * getDestination() const
Returns the current destination.
void setAbortWaiting(const SUMOTime timeout)
MSStage * getNextStage(int offset) const
Return the next (or previous) stage denoted by the offset.
void routeOutput(OutputDevice &os, const bool withRouteLength) const
Called on writing vehroute output.
void setJunctionModelParameter(const std::string &key, const std::string &value)
set individual junction model paramete (not type related)
int getNumRemainingStages() const
Return the number of remaining stages (including the current)
PositionVector getBoundingBox() const
return the bounding box of the person
virtual bool checkAccess(const MSStage *const prior, const bool waitAtStop=true)
SUMOTime abortStage(SUMOTime step)
Abort current stage (used for aborting waiting for a vehicle)
std::string getStageSummary(int stageIndex) const
return textual summary for the given stage
const MSVehicleType * myVType
This transportable's type. (mainly used for drawing related information Note sure if it is really nec...
MSStage * getCurrentStage() const
Return the current stage.
SumoRNG * getRNG() const override
returns the associated RNG
void setDeparted(SUMOTime now)
logs depart time of the current stage
void setSpeed(double speed)
set the speed for all present and future (walking) stages and modify the vType so that stages added l...
virtual bool proceed(MSNet *net, SUMOTime time, const bool vehicleArrived=false)
SUMOVehicleClass getVClass() const override
Returns the object's access class.
double getMaxSpeed() const override
Returns the maximum speed (the minimum of desired and physical maximum speed)
MSTransportablePlan::iterator myStep
the iterator over the route
MSTransportablePlan * myPlan
the plan of the transportable
void removeStage(int next, bool stayInSim=true)
removes the nth next stage
SUMOVehicle * getVehicle() const
The vehicle associated with this transportable.
bool isPerson() const override
Whether it is a person.
virtual Position getPosition() const
Return the Network coordinate of the transportable.
const SUMOVehicleParameter * myParameter
the plan of the transportable
void saveState(OutputDevice &out)
Saves the current state into the given stream.
const MSEdge * getRerouteDestination() const override
Returns the end point for reroutes (usually the last edge of the route)
MSDevice * getDevice(const std::type_info &type) const override
Returns a device of the given type if it exists or nullptr if not.
virtual ~MSTransportable()
destructor
SUMOTime getWaitingTime(const bool accumulated=false) const override
MSStageType getCurrentStageType() const
the current stage type of the transportable
int getRNGIndex() const override
returns the index of the associated RNG
void rerouteParkingArea(MSStoppingPlace *orig, MSStoppingPlace *replacement)
adapt plan when the vehicle reroutes and now stops at replacement instead of orig
std::string getObjectType()
const SUMOVehicleParameter & getParameter() const override
Returns the vehicle's parameter (including departure definition)
void loadState(const std::string &state)
Reconstructs the current state.
std::vector< MSTransportableDevice * > myDevices
The devices this transportable has.
virtual double getWaitingSeconds() const
the time this transportable spent waiting in seconds
MSTransportable(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportablePlan *plan, const bool isPerson)
constructor
const MSVehicleType & getVehicleType() const override
Returns the object's "vehicle" type.
bool reroute(SUMOTime t, const std::string &info, MSTransportableRouter &router, const bool onInit=false, const bool withTaz=false, const bool silent=false, const MSEdge *sink=nullptr)
void tripInfoOutput(OutputDevice &os) const
Called on writing tripinfo output.
virtual int getRoutingMode() const override
return routing mode (configures router choice but also handling of transient permission changes)
virtual double getAngle() const override
return the current angle of the transportable
void appendStage(MSStage *stage, int next=-1)
Appends the given stage to the current plan.
void setID(const std::string &newID) override
set the id (inherited from Named but forbidden for transportables)
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
const MSEdge * getEdge() const override
Returns the current edge.
virtual int getDirection() const
Return the movement directon on the edge.
double getSlope() const override
Returns the slope of the road at object's position in degrees.
std::vector< MSStage * > MSTransportablePlan
the structure holding the plan of a transportable
WrappingCommand< MSTransportable > * myAbortCommand
bool hasArrived() const override
return whether the person has reached the end of its plan
SUMOTime getDesiredDepart() const
Returns the desired departure time.
void removeVType(const MSVehicleType *vehType)
The car-following model and parameter.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
const std::string & getID() const
Returns the name of the vehicle type.
void setMaxSpeed(const double &maxSpeed)
Set a new value for this type's maximum speed.
bool isVehicleSpecific() const
Returns whether this type belongs to a single vehicle only (was modified)
double getLength() const
Get vehicle's length [m].
const SUMOVTypeParameter & getParameter() const
MSVehicleType * buildSingularType(const std::string &id) const
Duplicates the microsim vehicle type giving the newly created type the given id, marking it as vehicl...
const std::string & getID() const
Returns the id.
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
void lf()
writes a line feed if applicable
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void setPrecision(int precision=gPrecision)
Sets the precision or resets it to default.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
A point in 2D or 3D with translation and scaling methods.
void append(const PositionVector &v, double sameThreshold=2.0)
void move2side(double amount, double maxExtension=100)
move position vector to side using certain amount
PositionVector reverse() const
reverse position vector
Utility functions for using a global, resetable random number generator.
Representation of a vehicle, person, or container.
long long int NumericalID
bool wasSet(long long int what) const
Returns whether the given parameter was set.
virtual void removeTransportable(MSTransportable *t)=0
removes a person or container
Structure representing possible vehicle parameter.
long long int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
void write(OutputDevice &dev, const OptionsCont &oc, const SumoXMLTag altTag=SUMO_TAG_VEHICLE, const std::string &typeID="") const
Writes the parameters as a beginning element.
bool wasSet(long long int what) const
Returns whether the given parameter was set.
A wrapper for a Command function.
void deschedule()
Marks this Command as being descheduled.
TRACI_CONST int ROUTING_MODE_DEFAULT