49 #ifdef CHECK_MEMORY_LEAKS
51 #endif // CHECK_MEMORY_LEAKS
63 MSTransportable::
Stage(*route.back(), MOVING_WITHOUT_VEHICLE), myWalkingTime(walkingTime), myRoute(route),
64 myCurrentInternalEdge(0),
65 myDepartPos(departPos), myArrivalPos(arrivalPos), myDestinationBusStop(toBS),
67 myPedestrianState(0) {
72 if (walkingTime > 0) {
84 if (myCurrentInternalEdge != 0) {
85 return myCurrentInternalEdge;
94 return myRoute.front();
100 return myPedestrianState->getEdgePos(*
this, now);
106 return myPedestrianState->getPosition(*
this, now);
112 return myPedestrianState->getAngle(*
this, now);
118 return myPedestrianState->getWaitingTime(*
this, now);
124 return myPedestrianState->getSpeed(*
this);
132 myRouteStep = myRoute.begin();
133 if (myWalkingTime == 0) {
134 if (!person->
proceed(net, now)) {
142 if (myWalkingTime > 0) {
143 mySpeed = computeAverageSpeed();
147 (*myRouteStep)->addPerson(person);
154 for (ConstMSEdgeVector::const_iterator i = myRoute.begin(); i != myRoute.end(); ++i) {
155 length += (*i)->getLength();
157 length -= myDepartPos;
158 length -= myRoute.back()->getLength() - myArrivalPos;
159 return length /
STEPS2TIME(myWalkingTime + 1);
172 if (myWalkingTime > 0) {
174 }
else if (mySpeed > 0) {
184 .
writeAttr(
"agent", p.
getID()).writeAttr(
"link", myRoute.front()->getID()).closeTag();
191 .
writeAttr(
"agent", p.
getID()).writeAttr(
"link", myRoute.back()->getID()).closeTag();
199 if (myRouteStep == myRoute.end() - 1) {
201 if (myDestinationBusStop != 0) {
202 myDestinationBusStop->addTransportable(person);
210 if (nextInternal == 0) {
212 myCurrentInternalEdge = 0;
214 myCurrentInternalEdge = nextInternal;
229 myVehicle(0), myDestinationBusStop(toBS) {}
237 if (myVehicle != 0) {
238 return myVehicle->getEdge();
240 return myWaitingEdge;
246 return myWaitingEdge;
252 if (myVehicle != 0) {
262 if (myVehicle != 0) {
264 return myVehicle->getEdge()->getLanes()[0]->getShape().positionAtOffset(myVehicle->getPositionOnLane());
272 if (myVehicle != 0) {
280 return getEdgeAngle(myWaitingEdge, myWaitingPos) + 90;
288 myWaitingEdge = previousEdge;
290 myWaitingSince = now;
293 myVehicle = availableVehicle;
295 myVehicle->addPerson(person);
308 return myLines.count(line) > 0;
314 return myVehicle == 0;
326 return myVehicle == 0 ? 0 : myVehicle->getSpeed();
368 myWaitingDuration(duration),
369 myWaitingUntil(until),
382 return &myDestination;
388 return &myDestination;
400 return myWaitingUntil;
412 return getEdgeAngle(&myDestination, myStartPos) - 90;
420 myWaitingStart = now;
421 const SUMOTime until =
MAX3(now, now + myWaitingDuration, myWaitingUntil);
435 if (myWaitingDuration >= 0) {
438 if (myWaitingUntil >= 0) {
461 return now - myWaitingStart;
488 SUMOReal atPos = (*myStep)->getEdgePos(time);
490 (*myStep)->setArrived(time);
498 (*myStep)->proceed(net,
this, time, arrivedAt, atPos);
514 MSTransportable::MSTransportablePlan::const_iterator i =
myPlan->begin();
518 for (; i !=
myPlan->end(); ++i) {
519 (*i)->routeOutput(os);
527 assert(walkingStage != 0);
530 return nextEdge->
getID();
The departure is person triggered.
virtual const MSEdge * getNextEdge(const MSPerson::MSPersonStage_Walking &stage) const =0
return the list of internal edges if the pedestrian is on an intersection
SUMOTime getUntil() const
SUMOReal getAngle(SUMOTime now) const
returns the angle of the transportable
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Representation of a vehicle in the micro simulation.
const MSEdge * getFromEdge() const
virtual ~MSPerson()
destructor
SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
virtual void erase(MSTransportable *person)
removes a single person
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
SUMOReal getSpeed() const
the speed of the transportable
A lane area vehicles can halt at.
bool isWaiting4Vehicle() const
Whether the container waits for a vehicle.
const MSEdge * getEdge() const
Returns the current edge.
Position getPosition(SUMOTime now) const
returns the position of the transportable
virtual void tripInfoOutput(OutputDevice &os) const
Called on writing tripinfo output.
std::string time2string(SUMOTime t)
bool isWaiting4Vehicle() const
Whether the person waits for a vehicle.
SUMOReal getEdgePos(SUMOTime now) const
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
virtual void routeOutput(OutputDevice &os) const
Called on writing vehroute output.
const std::string & getID() const
returns the id of the transportable
SUMOVehicle * getWaitingVehicle(const MSEdge *const edge, const std::set< std::string > &lines, const SUMOReal position, const std::string ridingID)
void removeWaiting(const MSEdge *const edge, SUMOVehicle *vehicle)
Removes a vehicle from the list of waiting vehicles to a given edge.
void setWalking(MSTransportable *p)
std::vector< const MSEdge * > ConstMSEdgeVector
virtual bool proceed(MSNet *net, SUMOTime time)=0
MSTransportablePlan::iterator myStep
the iterator over the route
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
virtual void tripInfoOutput(OutputDevice &os) const
Called on writing tripinfo output.
The simulated network and simulation perfomer.
The car-following model and parameter.
SUMOReal getEdgePos(SUMOTime now) const
void setWaitEnd(SUMOTime time, MSTransportable *person)
sets the arrival time for a waiting or walking person
SUMOTime getDesiredDepart() const
Returns the desired departure time.
const MSEdge * getEdge() const
Returns the current edge.
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, MSEdge *previousEdge, const SUMOReal at)
proceeds to the next step
virtual PedestrianState * add(MSPerson *person, MSPerson::MSPersonStage_Walking *stage, SUMOTime now)=0
register the given person as a pedestrian
static SUMOReal interpretEdgePos(SUMOReal pos, SUMOReal maximumValue, SumoXMLAttr attr, const std::string &id)
Interprets negative edge positions and fits them onto a given edge.
ConstMSEdgeVector myRoute
The route of the person.
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 container
void routeOutput(OutputDevice &os) const
Called on writing vehroute output.
SUMOReal getLength() const
return the length of the edge
virtual void removePerson(MSTransportable *p) const
bool moveToNextEdge(MSPerson *person, SUMOTime currentTime, MSEdge *nextInternal=0)
move forward and return whether the person arrived
SUMOReal getEdgePos(SUMOTime now) const
const MSEdge * getEdge() const
Returns the current edge.
PedestrianState * getPedestrianState() const
virtual void addPerson(MSTransportable *p) const
Representation of a vehicle.
static MSPModel * getModel()
A point in 2D or 3D with translation and scaling methods.
SUMOReal getAngle(SUMOTime now) const
returns the angle of the transportable
SUMOReal getSpeed() const
the speed of the transportable
SUMOReal computeAverageSpeed() const
StageType getCurrentStageType() const
the current stage type of the container
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
~MSPersonStage_Driving()
destructor
Position getPosition(SUMOTime now) const
returns the position of the transportable
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
virtual void routeOutput(OutputDevice &os) const
Called on writing vehroute output.
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, MSEdge *previousEdge, const SUMOReal at)
proceeds to the next step
const MSEdge * getFromEdge() const
MSPersonStage_Driving(const MSEdge &destination, MSStoppingPlace *toBS, const std::vector< std::string > &lines)
constructor
SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
bool isWaitingFor(const std::string &line) const
Whether the person waits for a vehicle of the line specified.
MSPersonStage_Waiting(const MSEdge &destination, SUMOTime duration, SUMOTime until, SUMOReal pos, const std::string &actType)
constructor
void unregisterOneWaitingForPerson()
decreases the count of vehicles waiting for a person to allow recogniztion of person related deadlock...
const MSEdge & getDestination() const
Returns the current destination.
void unsetWalking(MSTransportable *p)
static std::string emptyString
An empty string.
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
SUMOReal getAngle(SUMOTime now) const
returns the angle of the transportable
const MSEdge * getFromEdge() const
Returns the departure edge.
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
void addWaiting(const MSEdge *edge, MSTransportable *person)
adds a person to the list of persons waiting for a vehicle on the specified edge
const MSEdge * getEdge() const
Returns the current edge.
static const SUMOReal SIDEWALK_OFFSET
the offset for computing person positions when walking on edges without a sidewalk ...
Structure representing possible vehicle parameter.
virtual void routeOutput(OutputDevice &os) const
Called on writing vehroute output.
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
virtual MSPersonControl & getPersonControl()
Returns the person control.
MSInsertionControl & getInsertionControl()
Returns the insertion control.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
~MSPersonStage_Walking()
destructor
~MSPersonStage_Waiting()
destructor
const std::string & getNextEdge() const
return the list of internal edges if this person is walking and the pedestrian model allows it ...
Position getPosition(SUMOTime now) const
returns the position of the transportable
std::string getStageDescription() const
return string representation of the current stage
bool proceed(MSNet *net, SUMOTime time)
MSPersonStage_Walking(const ConstMSEdgeVector &route, MSStoppingPlace *toBS, SUMOTime walkingTime, SUMOReal speed, SUMOReal departPos, SUMOReal arrivalPos)
constructor
SUMOTime getWaitingTime(SUMOTime now) const
time spent waiting for a ride
const MSEdge * getFromEdge() const
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=OUTPUT_ACCURACY)
MSPerson(const SUMOVehicleParameter *pars, const MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan)
constructor
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
Static storage of an output device and its base (abstract) implementation.
bool closeTag()
Closes the most recently opened tag.
MSTransportablePlan * myPlan
the plan of the container
SUMOReal myDepartPos
A vector of computed times an edge is reached.
SUMOReal getSpeed() const
the speed of the transportable
const MSEdge & myDestination
the next edge to reach by getting transported
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, MSEdge *previousEdge, const SUMOReal at)
proceeds to the next step
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
virtual void tripInfoOutput(OutputDevice &os) const
Called on writing tripinfo output.
SUMOReal getAngle() const
Returns the vehicle's direction in degrees.