47 #ifdef CHECK_MEMORY_LEAKS
49 #endif // CHECK_MEMORY_LEAKS
63 : myDestination(destination), myDeparted(-1), myArrived(-1), myType(type) {}
122 myDepartPos(departPos), myArrivalPos(arrivalPos), myDestinationBusStop(toBS),
128 if (walkingTime > 0) {
130 for (std::vector<const MSEdge*>::const_iterator i = route.begin(); i != route.end(); ++i) {
131 length += (*i)->getLength();
151 return myRoute.front();
158 return myCurrentBeginPos + myCurrentLength / myCurrentDuration * off;
166 return getEdgePosition(e, myCurrentBeginPos + myCurrentLength / myCurrentDuration * off,
SIDEWALK_OFFSET);
174 return getEdgeAngle(e, myCurrentBeginPos + myCurrentLength / myCurrentDuration * off) + 90;
182 myRouteStep = myRoute.begin();
183 myLastEntryTime = now;
184 if (myWalkingTime == 0) {
185 if (!person->
proceed(net, now)) {
194 ((
MSEdge*) *myRouteStep)->addPerson(person);
196 ? computeWalkingTime(*myRouteStep, myDepartPos, myArrivalPos, myDestinationBusStop)
197 : computeWalkingTime(*myRouteStep, myDepartPos, -1, 0);
206 }
else if (toPos < 0) {
207 toPos = e->
getLanes()[0]->getLength();
212 myCurrentBeginPos = fromPos;
213 myCurrentLength = toPos - fromPos;
214 assert(myCurrentLength >= 0);
215 myCurrentDuration =
MAX2(myCurrentLength, (
SUMOReal)1.0) / mySpeed;
228 if (myWalkingTime > 0) {
230 }
else if (mySpeed > 0) {
240 .
writeAttr(
"agent", p.
getID()).writeAttr(
"link", myRoute.front()->getID()).closeTag();
247 .
writeAttr(
"agent", p.
getID()).writeAttr(
"link", myRoute.back()->getID()).closeTag();
253 ((
MSEdge*) *myRouteStep)->removePerson(person);
254 if (myRouteStep == myRoute.end() - 1) {
256 if (myDestinationBusStop != 0) {
257 myDestinationBusStop->addPerson(person);
265 myRouteStep == myRoute.end() - 1
266 ? computeWalkingTime(*myRouteStep, 0, myArrivalPos, myDestinationBusStop)
267 : computeWalkingTime(*myRouteStep, 0, -1, 0);
268 ((
MSEdge*) *myRouteStep)->addPerson(person);
269 myLastEntryTime = currentTime;
280 MSBusStop* toBS,
const std::vector<std::string>& lines)
282 myVehicle(0), myDestinationBusStop(toBS) {}
290 if (myVehicle != 0) {
291 return myVehicle->getEdge();
293 return myWaitingEdge;
299 return myWaitingEdge;
305 if (myVehicle != 0) {
315 if (myVehicle != 0) {
317 return myVehicle->getEdge()->getLanes()[0]->getShape().positionAtOffset(myVehicle->getPositionOnLane());
325 if (myVehicle != 0) {
333 return getEdgeAngle(myWaitingEdge, myWaitingPos);
341 myWaitingEdge = previousEdge;
343 myWaitingSince = now;
345 if (myVehicle != 0 && myVehicle->getParameter().departProcedure ==
DEPART_TRIGGERED) {
347 myVehicle->addPerson(person);
360 return myLines.count(line) > 0;
366 return myVehicle == 0;
414 myWaitingDuration(duration),
415 myWaitingUntil(until),
428 return &myDestination;
434 return &myDestination;
446 return myWaitingUntil;
458 return getEdgeAngle(&myDestination, myStartPos) + 45;
466 const SUMOTime until =
MAX3(now, now + myWaitingDuration, myWaitingUntil);
480 if (myWaitingDuration >= 0) {
483 if (myWaitingUntil >= 0) {
515 for (MSPersonPlan::const_iterator i =
myPlan->begin(); i !=
myPlan->end(); ++i) {
532 SUMOReal atPos = (*myStep)->getEdgePos(time);
534 (*myStep)->setArrived(time);
540 Position pos = (*myStep)->getPosition(time);
543 (*myStep)->proceed(net,
this, time, arrivedAt, atPos);
565 (*myStep)->setDeparted(now);
571 for (MSPersonPlan::const_iterator i =
myPlan->begin(); i !=
myPlan->end(); ++i) {
572 (*i)->tripInfoOutput(os);
579 MSPersonPlan::const_iterator i =
myPlan->begin();
583 for (; i !=
myPlan->end(); ++i) {
584 (*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.