Skip to content

Commit

Permalink
some mesoscopic movereminder refactoring #14208
Browse files Browse the repository at this point in the history
  • Loading branch information
behrisch committed Jan 5, 2024
1 parent 248a0d5 commit c6fba76
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 23 deletions.
1 change: 1 addition & 0 deletions src/microsim/transportables/MSPModel_NonInteracting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ MSPModel_NonInteracting::MoveToNextEdge::execute(SUMOTime currentTime) {
myModel->registerArrived();
return 0;
}
myParent.activateEntryReminders(myTransportable);
return static_cast<PState*>(myParent.getState())->computeDuration(old, myParent, currentTime);
}

Expand Down
20 changes: 6 additions & 14 deletions src/microsim/transportables/MSPerson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,7 @@ MSPerson::MSPersonStage_Walking::proceed(MSNet* net, MSTransportable* person, SU
}
if (previous->getStageType() != MSStageType::WALKING || previous->getEdge() != getEdge()) {
// we only need new move reminders if we are walking a different edge (else it is probably a rerouting)
const MSLane* const lane = getSidewalk<MSEdge, MSLane>(getEdge());
if (lane != nullptr) {
for (MSMoveReminder* rem : lane->getMoveReminders()) {
if (rem->notifyEnter(*person, MSMoveReminder::NOTIFICATION_DEPARTED, lane)) {
myMoveReminders.push_back(rem);
}
}
}
activateEntryReminders(person, true);
}
if (OptionsCont::getOptions().getBool("vehroute-output.exit-times")) {
myExitTimes = new std::vector<SUMOTime>();
Expand Down Expand Up @@ -394,20 +387,19 @@ MSPerson::MSPersonStage_Walking::moveToNextEdge(MSTransportable* person, SUMOTim
void
MSPerson::MSPersonStage_Walking::activateLeaveReminders(MSTransportable* person, const MSLane* lane, double lastPos, SUMOTime t, bool arrived) {
MSMoveReminder::Notification notification = arrived ? MSMoveReminder::NOTIFICATION_ARRIVED : MSMoveReminder::NOTIFICATION_JUNCTION;
for (MSMoveReminder* rem : myMoveReminders) {
for (MSMoveReminder* const rem : myMoveReminders) {
rem->updateDetector(*person, 0.0, lane->getLength(), myLastEdgeEntryTime, t, t, true);
rem->notifyLeave(*person, lastPos, notification);
}
}


void
MSPerson::MSPersonStage_Walking::activateEntryReminders(MSTransportable* person) {
const MSLane* nextLane = getSidewalk<MSEdge, MSLane>(getEdge());
MSPerson::MSPersonStage_Walking::activateEntryReminders(MSTransportable* person, const bool isDepart) {
const MSLane* const nextLane = getSidewalk<MSEdge, MSLane>(getEdge());
if (nextLane != nullptr) {
for (MSMoveReminder* rem : nextLane->getMoveReminders()) {
if (rem->notifyEnter(*person, MSMoveReminder::NOTIFICATION_JUNCTION, nextLane)) {
;
for (MSMoveReminder* const rem : nextLane->getMoveReminders()) {
if (rem->notifyEnter(*person, isDepart ? MSMoveReminder::NOTIFICATION_DEPARTED : MSMoveReminder::NOTIFICATION_JUNCTION, nextLane)) {
myMoveReminders.push_back(rem);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/microsim/transportables/MSPerson.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class MSPerson : public MSTransportable {
/// @brief move forward and return whether the person arrived
bool moveToNextEdge(MSTransportable* person, SUMOTime currentTime, int prevDir, MSEdge* nextInternal = nullptr);

void activateEntryReminders(MSTransportable* person);
void activateEntryReminders(MSTransportable* person, const bool isDepart=false);

void activateLeaveReminders(MSTransportable* person, const MSLane* lane, double lastPos, SUMOTime t, bool arrived);

Expand Down
6 changes: 5 additions & 1 deletion src/microsim/transportables/MSStageMoving.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ class MSStageMoving : public MSStage {
/// @brief move forward and return whether the transportable arrived
virtual bool moveToNextEdge(MSTransportable* transportable, SUMOTime currentTime, int prevDir, MSEdge* nextInternal = 0) = 0;

virtual void activateEntryReminders(MSTransportable* /*person*/) { }
/// @brief add the move reminders for the current lane on entry
virtual void activateEntryReminders(MSTransportable* person, const bool isDepart=false) {
UNUSED_PARAMETER(person);
UNUSED_PARAMETER(isDepart);
}

/// @brief place transportable on a previously passed edge
virtual void setRouteIndex(MSTransportable* const transportable, int routeOffset);
Expand Down
11 changes: 4 additions & 7 deletions src/microsim/trigger/MSTriggeredRerouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,12 @@ MSTriggeredRerouter::MSTriggeredRerouter(const std::string& id,
myHaveParkProbs(false) {
myInstances[id] = this;
// build actors
for (MSEdgeVector::const_iterator j = edges.begin(); j != edges.end(); ++j) {
for (const MSEdge* const e : edges) {
if (MSGlobals::gUseMesoSim) {
MESegment* s = MSGlobals::gMesoNet->getSegmentForEdge(**j);
s->addDetector(this);
continue;
MSGlobals::gMesoNet->getSegmentForEdge(*e)->addDetector(this);
}
const std::vector<MSLane*>& destLanes = (*j)->getLanes();
for (std::vector<MSLane*>::const_iterator i = destLanes.begin(); i != destLanes.end(); ++i) {
(*i)->addMoveReminder(this);
for (MSLane* const lane : e->getLanes()) {
lane->addMoveReminder(this);
}
}
if (off) {
Expand Down

0 comments on commit c6fba76

Please sign in to comment.