Skip to content

Commit

Permalink
extended simulation refs #3948
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Mar 28, 2018
1 parent 0b3e236 commit 5050fba
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 10 deletions.
7 changes: 5 additions & 2 deletions src/microsim/MSRouteHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,9 @@ MSRouteHandler::myStartElement(int element,
throw ProcessError("The to edge '" + toID + "' within a ride of person '" + pid + "' is not known.");
}
}
myActivePlan->push_back(new MSPerson::MSPersonStage_Driving(*to, bs, arrivalPos, st.getVector()));
const std::string intendedVeh = attrs.getOpt<std::string>(SUMO_ATTR_INTENDED, 0, ok, "");
const SUMOTime intendedDepart = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DEPART, 0, ok, -1);
myActivePlan->push_back(new MSPerson::MSPersonStage_Driving(*to, bs, arrivalPos, st.getVector(), intendedVeh, intendedDepart));
break;
}
case SUMO_TAG_TRANSPORT:
Expand Down Expand Up @@ -1157,7 +1159,8 @@ MSRouteHandler::addPersonTrip(const SUMOSAXAttributes& attrs) {
vehControl.addVehicle(vehPar->id, vehicle);
carUsed = true;
} else {
myActivePlan->push_back(new MSPerson::MSPersonStage_Driving(*it->edges.back(), bs, localArrivalPos, std::vector<std::string>({ it->line })));
myActivePlan->push_back(new MSPerson::MSPersonStage_Driving(
*it->edges.back(), bs, localArrivalPos, std::vector<std::string>({ it->line }), it->intended, TIME2STEPS(it->depart)));
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/microsim/MSTransportable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,17 @@ MSTransportable::Stage_Waiting::getStageSummary() const {
* MSTransportable::Stage_Driving - methods
* ----------------------------------------------------------------------- */
MSTransportable::Stage_Driving::Stage_Driving(const MSEdge& destination,
MSStoppingPlace* toStop, const double arrivalPos, const std::vector<std::string>& lines) :
MSStoppingPlace* toStop, const double arrivalPos, const std::vector<std::string>& lines,
const std::string& intendedVeh, SUMOTime intendedDepart) :
MSTransportable::Stage(destination, toStop, arrivalPos, DRIVING),
myLines(lines.begin(), lines.end()),
myVehicle(0),
myVehicleID("NULL"),
myVehicleDistance(-1.),
myStopWaitPos(Position::INVALID) {}
myStopWaitPos(Position::INVALID),
myIntendedVehicleID(intendedVeh),
myIntendedDepart(intendedDepart)
{}


MSTransportable::Stage_Driving::~Stage_Driving() {}
Expand Down
7 changes: 6 additions & 1 deletion src/microsim/MSTransportable.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ class MSTransportable {
public:
/// constructor
Stage_Driving(const MSEdge& destination, MSStoppingPlace* toStop,
const double arrivalPos, const std::vector<std::string>& lines);
const double arrivalPos, const std::vector<std::string>& lines,
const std::string& intendedVeh = "", SUMOTime intendedDepart = -1);

/// destructor
virtual ~Stage_Driving();
Expand Down Expand Up @@ -368,6 +369,7 @@ class MSTransportable {
/// @brief cached vehicle data for output after the vehicle has been removed
std::string myVehicleID;
std::string myVehicleLine;

SUMOVehicleClass myVehicleVClass;
double myVehicleDistance;

Expand All @@ -377,6 +379,9 @@ class MSTransportable {
const MSEdge* myWaitingEdge;
Position myStopWaitPos;

std::string myIntendedVehicleID;
SUMOTime myIntendedDepart;

private:
/// @brief Invalidated copy constructor.
Stage_Driving(const Stage_Driving&);
Expand Down
20 changes: 16 additions & 4 deletions src/microsim/pedestrians/MSPerson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,13 @@ MSPerson::MSPersonStage_Walking::getStageSummary() const {
* MSPerson::MSPersonStage_Driving - methods
* ----------------------------------------------------------------------- */
MSPerson::MSPersonStage_Driving::MSPersonStage_Driving(const MSEdge& destination,
MSStoppingPlace* toStop, const double arrivalPos, const std::vector<std::string>& lines) :
MSStoppingPlace* toStop, const double arrivalPos, const std::vector<std::string>& lines,
const std::string& intendedVeh, SUMOTime intendedDepart) :
MSTransportable::Stage_Driving(destination, toStop,
SUMOVehicleParameter::interpretEdgePos(
arrivalPos, destination.getLength(), SUMO_ATTR_ARRIVALPOS, "person riding to " + destination.getID()),
lines) {
lines,
intendedVeh, intendedDepart) {
}


Expand Down Expand Up @@ -375,8 +377,11 @@ MSPerson::MSPersonStage_Driving::getStageSummary() const {
const std::string dest = (getDestinationStop() == 0 ?
" edge '" + getDestination().getID() + "'" :
" stop '" + getDestinationStop()->getID() + "'");
const std::string intended = myIntendedVehicleID != "" ?
" (vehicle " + myIntendedVehicleID + " at time " + time2string(myIntendedDepart) + ")" :
"";
return isWaiting4Vehicle() ?
"waiting for " + joinToString(myLines, ",") + " then drive to " + dest:
"waiting for " + joinToString(myLines, ",") + intended + " then drive to " + dest:
"driving to " + dest;
}

Expand All @@ -403,7 +408,14 @@ MSPerson::MSPersonStage_Driving::routeOutput(OutputDevice& os) const {
if (myDestinationStop != 0) {
os.writeAttr(SUMO_ATTR_BUS_STOP, myDestinationStop->getID());
}
os.writeAttr(SUMO_ATTR_LINES, myLines).closeTag();
os.writeAttr(SUMO_ATTR_LINES, myLines);
if (myIntendedVehicleID != "") {
os.writeAttr(SUMO_ATTR_INTENDED, myIntendedVehicleID);
}
if (myIntendedDepart >= 0) {
os.writeAttr(SUMO_ATTR_DEPART, time2string(myIntendedDepart));
}
os.closeTag();
}


Expand Down
3 changes: 2 additions & 1 deletion src/microsim/pedestrians/MSPerson.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ class MSPerson : public MSTransportable {
public:
/// constructor
MSPersonStage_Driving(const MSEdge& destination, MSStoppingPlace* toStop,
const double arrivalPos, const std::vector<std::string>& lines);
const double arrivalPos, const std::vector<std::string>& lines,
const std::string& intendedVeh = "", SUMOTime intendedDepart = -1);

/// destructor
~MSPersonStage_Driving();
Expand Down

0 comments on commit 5050fba

Please sign in to comment.