47 #ifdef CHECK_MEMORY_LEAKS
49 #endif // CHECK_MEMORY_LEAKS
63 : myDestination(destination), myDeparted(-1), myArrived(-1), myType(type) {}
121 myDepartPos(departPos), myArrivalPos(arrivalPos), myDestinationBusStop(toBS),
127 if (walkingTime > 0) {
129 for (std::vector<const MSEdge*>::const_iterator i = route.begin(); i != route.end(); ++i) {
130 length += (*i)->getLength();
150 return myRoute.front();
157 return myCurrentBeginPos + myCurrentLength / myCurrentDuration * off;
165 return getEdgePosition(e, myCurrentBeginPos + myCurrentLength / myCurrentDuration * off,
SIDEWALK_OFFSET);
173 return getEdgeAngle(e, myCurrentBeginPos + myCurrentLength / myCurrentDuration * off) + 90;
181 myRouteStep = myRoute.begin();
182 myLastEntryTime = now;
183 if (myWalkingTime == 0) {
184 if (!person->
proceed(net, now)) {
193 ((
MSEdge*) *myRouteStep)->addPerson(person);
195 ? computeWalkingTime(*myRouteStep, myDepartPos, myArrivalPos, myDestinationBusStop)
196 : computeWalkingTime(*myRouteStep, myDepartPos, -1, 0);
205 }
else if (toPos < 0) {
206 toPos = e->
getLanes()[0]->getLength();
211 myCurrentBeginPos = fromPos;
212 myCurrentLength = toPos - fromPos;
213 assert(myCurrentLength >= 0);
214 myCurrentDuration =
MAX2(myCurrentLength, (
SUMOReal)1.0) / mySpeed;
229 if (myWalkingTime > 0) {
231 }
else if (mySpeed > 0) {
242 "\" type=\"departure" <<
243 "\" agent=\"" << p.
getID() <<
244 "\" link=\"" << myRoute.front()->getID() <<
253 "\" type=\"arrival" <<
254 "\" agent=\"" << p.
getID() <<
255 "\" link=\"" << myRoute.back()->getID() <<
262 ((
MSEdge*) *myRouteStep)->removePerson(person);
263 if (myRouteStep == myRoute.end() - 1) {
265 if (myDestinationBusStop != 0) {
266 myDestinationBusStop->addPerson(person);
274 myRouteStep == myRoute.end() - 1
275 ? computeWalkingTime(*myRouteStep, 0, myArrivalPos, myDestinationBusStop)
276 : computeWalkingTime(*myRouteStep, 0, -1, 0);
277 ((
MSEdge*) *myRouteStep)->addPerson(person);
278 myLastEntryTime = currentTime;
289 MSBusStop* toBS,
const std::vector<std::string>& lines)
291 myVehicle(0), myDestinationBusStop(toBS) {}
299 if (myVehicle != 0) {
300 return myVehicle->getEdge();
302 return myWaitingEdge;
308 return myWaitingEdge;
314 if (myVehicle != 0) {
324 if (myVehicle != 0) {
326 return myVehicle->getEdge()->getLanes()[0]->getShape().positionAtOffset(myVehicle->getPositionOnLane());
334 if (myVehicle != 0) {
342 return getEdgeAngle(myWaitingEdge, myWaitingPos);
350 myWaitingEdge = previousEdge;
352 myWaitingSince = now;
354 if (myVehicle != 0 && myVehicle->getParameter().departProcedure ==
DEPART_TRIGGERED) {
356 myVehicle->addPerson(person);
369 return myLines.count(line) > 0;
375 return myVehicle == 0;
411 "\" type=\"arrival" <<
412 "\" agent=\"" << p.
getID() <<
422 "\" type=\"arrival" <<
423 "\" agent=\"" << p.
getID() <<
435 myWaitingDuration(duration),
436 myWaitingUntil(until),
449 return &myDestination;
455 return &myDestination;
467 return myWaitingUntil;
479 return getEdgeAngle(&myDestination, myStartPos) + 45;
487 const SUMOTime until =
MAX3(now, now + myWaitingDuration, myWaitingUntil);
503 if (myWaitingDuration >= 0) {
506 if (myWaitingUntil >= 0) {
517 "\" type=\"actstart " << myActType <<
518 "\" agent=\"" << p.
getID() <<
528 "\" type=\"actend " << myActType <<
529 "\" agent=\"" << p.
getID() <<
544 for (MSPersonPlan::const_iterator i =
myPlan->begin(); i !=
myPlan->end(); ++i) {
561 SUMOReal atPos = (*myStep)->getEdgePos(time);
563 (*myStep)->setArrived(time);
569 Position pos = (*myStep)->getPosition(time);
572 (*myStep)->proceed(net,
this, time, arrivedAt, atPos);
594 (*myStep)->setDeparted(now);
600 for (MSPersonPlan::const_iterator i =
myPlan->begin(); i !=
myPlan->end(); ++i) {
601 (*i)->tripInfoOutput(os);
608 MSPersonPlan::const_iterator i =
myPlan->begin();
612 for (; i !=
myPlan->end(); ++i) {
613 (*i)->routeOutput(os);
The departure is person triggered.
SUMOTime getUntil() const
SUMOReal getAngle(SUMOTime now) const
const std::string & getID() const
returns the person id
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
virtual void beginEventOutput(const MSPerson &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
Representation of a vehicle in the micro simulation.
const MSEdge * getFromEdge() const
SUMOTime getDesiredDepart() const
Returns the desired departure time.
virtual ~MSPerson()
destructor
const SUMOVehicleParameter * myParameter
the plan of the person
const MSEdge & getDestination() const
returns the destination edge
Position positionAtOffset(SUMOReal pos) const
Returns the position at the given length.
const MSEdge * getEdge(SUMOTime now) const
Returns the current edge.
void setDeparted(SUMOTime now)
logs end of the step
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
MSPersonStage(const MSEdge &destination, StageType type)
constructor
bool isWaiting4Vehicle() const
Whether the person waits for a vehicle.
std::vector< const MSEdge * > myRoute
The route of the person.
const MSEdge * getFromEdge() const
Returns the departure edge.
static const SUMOReal SIDEWALK_OFFSET
the offset for computing person positions when walking
virtual bool isWaitingFor(const std::string &line) const
Whether the person waits for a vehicle of the line specified.
virtual void beginEventOutput(const MSPerson &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
void setDeparted(SUMOTime now)
logs end of the step
Position getPosition(SUMOTime now) const
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 MSVehicleType * myVType
This Persons's type. (mainly used for drawing related information.
void removeWaiting(const MSEdge *const edge, SUMOVehicle *vehicle)
SUMOReal getEndLanePosition() const
Returns the end position of this bus stop.
const MSEdge * getEdge(SUMOTime now) const
Returns the current edge.
SUMOReal getEdgeAngle(const MSEdge *e, SUMOReal at) const
virtual void tripInfoOutput(OutputDevice &os) const
Called on writing tripinfo output.
virtual void proceed(MSNet *net, MSPerson *person, SUMOTime now, MSEdge *previousEdge, const SUMOReal at)
proceeds to the next step
The simulated network and simulation perfomer.
The car-following model and parameter.
SUMOReal getEdgePos(SUMOTime now) const
const MSEdge & getDestination() const
Returns the current destination.
MSPersonStage_Walking(const std::vector< const MSEdge * > &route, MSBusStop *toBS, SUMOTime walkingTime, SUMOReal speed, SUMOReal departPos, SUMOReal arrivalPos)
constructor
static SUMOReal interpretEdgePos(SUMOReal pos, SUMOReal maximumValue, SumoXMLAttr attr, const std::string &id)
Interprets negative edge positions and fits them onto a given edge.
SUMOVehicle * getWaitingVehicle(const MSEdge *const edge, const std::set< std::string > &lines)
const std::string & getID() const
Returns the id.
A road/street connecting two junctions.
Position getEdgePosition(const MSEdge *e, SUMOReal at, SUMOReal offset) const
get position on edge e at length at with orthogonal offset
MSPersonPlan * myPlan
the plan of the person
void routeOutput(OutputDevice &os) const
Called on writing vehroute output.
SUMOReal getLength() const
return the length of the edge
SUMOTime moveToNextEdge(MSPerson *person, SUMOTime currentTime)
SUMOReal getEdgePos(SUMOTime now) const
A point in 2D or 3D with translation and scaling methods.
SUMOReal getAngle(SUMOTime now) const
A lane area vehicles can halt at.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
void addWaiting(const MSEdge *edge, MSPerson *person)
adds a person to the list of persons waiting for a vehicle on the specified edge
~MSPersonStage_Driving()
destructor
virtual void endEventOutput(const MSPerson &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
SUMOTime depart
The vehicle's departure time.
Position getPosition(SUMOTime now) const
virtual void proceed(MSNet *net, MSPerson *person, SUMOTime now, MSEdge *previousEdge, const SUMOReal at)
proceeds to the next step
virtual void routeOutput(OutputDevice &os) const
Called on writing vehroute output.
virtual void removePerson(MSPerson *p) const
const MSEdge * getFromEdge() const
void setWaitEnd(SUMOTime time, MSPerson *person)
sets the arrival time for a waiting or walking person
const MSEdge * getEdge(SUMOTime now) const
Returns the current edge.
virtual void addPerson(MSPerson *p) const
void unsetWalking(MSPerson *p)
virtual SUMOTime addEvent(Command *operation, SUMOTime execTimeStep, AdaptType type)
Adds an Event.
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...
std::string getStageTypeName() const
return string representation of the current stage
SUMOReal getAngle(SUMOTime now) const
MSPerson(const SUMOVehicleParameter *pars, const MSVehicleType *vtype, MSPersonPlan *plan)
constructor
SUMOReal rotationDegreeAtOffset(SUMOReal pos) const
Returns the rotation at the given length.
virtual void beginEventOutput(const MSPerson &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
void computeWalkingTime(const MSEdge *const e, SUMOReal fromPos, SUMOReal toPos, MSBusStop *bs)
Structure representing possible vehicle parameter.
virtual void routeOutput(OutputDevice &os) const
Called on writing vehroute output.
virtual void endEventOutput(const MSPerson &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
void tripInfoOutput(OutputDevice &os) const
Called on writing tripinfo output.
virtual MSPersonControl & getPersonControl()
Returns the person control.
MSInsertionControl & getInsertionControl()
Returns the insertion control.
void setWalking(MSPerson *p)
MSPersonPlan::iterator myStep
the iterator over the route
SUMOReal interpolateLanePosToGeometryPos(SUMOReal lanePos) const
~MSPersonStage_Walking()
destructor
~MSPersonStage_Waiting()
destructor
Position getPosition(SUMOTime now) const
const MSEdge * getEdge(SUMOTime now) const
Returns the current edge.
SUMOTime timeWaiting4Vehicle(SUMOTime now) const
time spent waiting for a ride
bool proceed(MSNet *net, SUMOTime time)
MSPersonStage_Driving(const MSEdge &destination, MSBusStop *toBS, const std::vector< std::string > &lines)
constructor
virtual void endEventOutput(const MSPerson &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
const MSEdge * getFromEdge() const
const PositionVector & getShape() const
Returns this lane's shape.
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=OUTPUT_ACCURACY)
void move2side(SUMOReal amount)
Patch the time in a way that it is at least as high as the simulation begin time. ...
Static storage of an output device and its base (abstract) implementation.
bool closeTag()
Closes the most recently opened tag.
virtual void proceed(MSNet *net, MSPerson *person, SUMOTime now, MSEdge *previousEdge, const SUMOReal at)
proceeds to the next step
const MSEdge & myDestination
the next edge to reach (either by walking or driving)
virtual ~MSPersonStage()
destructor
MSEventControl & getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
SUMOReal myDepartPos
A vector of computed times an edge is reached.
void setArrived(SUMOTime now)
logs end of the step
virtual void erase(MSPerson *person)
removes a single person
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
Representation of a lane in the micro simulation.
std::vector< MSPersonStage * > MSPersonPlan
the structure holding the plan of a person
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
virtual void tripInfoOutput(OutputDevice &os) const
Called on writing tripinfo output.
std::string id
The vehicle's id.
SUMOReal getAngle() const
Returns the vehicle's direction in degrees.