Skip to content

Commit

Permalink
addendum refs #14789
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Apr 29, 2024
1 parent cd6ffbb commit 78e5481
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/libsumo/Vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1437,8 +1437,11 @@ Vehicle::changeTarget(const std::string& vehID, const std::string& edgeID) {
}
// change the final edge of the route and reroute
try {
veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), "traci:changeTarget",
const bool success = veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), "traci:changeTarget",
veh->getRouterTT(), onInit, false, false, destEdge);
if (!success) {
throw TraCIException("ChangeTarget failed for vehicle '" + veh->getID() + "', destination edge '" + edgeID + "' unreachable.");
}
} catch (ProcessError& e) {
throw TraCIException(e.what());
}
Expand Down
7 changes: 4 additions & 3 deletions src/microsim/MSBaseVehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ MSBaseVehicle::stopsAtEdge(const MSEdge* edge) const {
}


void
bool
MSBaseVehicle::reroute(SUMOTime t, const std::string& info, SUMOAbstractRouter<MSEdge, SUMOVehicle>& router, const bool onInit, const bool withTaz, const bool silent, const MSEdge* sink) {
// check whether to reroute
const MSEdge* source = withTaz && onInit ? MSEdge::dictionary(myParameter->fromTaz + "-source") : *getRerouteOrigin();
Expand Down Expand Up @@ -371,7 +371,7 @@ MSBaseVehicle::reroute(SUMOTime t, const std::string& info, SUMOAbstractRouter<M

// router.setHint(myCurrEdge, myRoute->end(), this, t);
if (edges.empty() && silent) {
return;
return false;
}
if (!edges.empty() && edges.front()->isTazConnector()) {
edges.erase(edges.begin());
Expand All @@ -396,12 +396,13 @@ MSBaseVehicle::reroute(SUMOTime t, const std::string& info, SUMOAbstractRouter<M
} else if (source->isTazConnector()) {
WRITE_WARNINGF(TL("Removing vehicle '%' which has no valid route."), getID());
MSNet::getInstance()->getInsertionControl().descheduleDeparture(this);
return;
return false;
}
}
setDepartAndArrivalEdge();
calculateArrivalParams(onInit);
}
return !edges.empty();
}


Expand Down
2 changes: 1 addition & 1 deletion src/microsim/MSBaseVehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ class MSBaseVehicle : public SUMOVehicle {
* @param[in] sink (optionally) a new destination edge
* @see replaceRoute
*/
void reroute(SUMOTime t, const std::string& info, SUMOAbstractRouter<MSEdge, SUMOVehicle>& router, const bool onInit = false, const bool withTaz = false, const bool silent = false, const MSEdge* sink = nullptr);
bool reroute(SUMOTime t, const std::string& info, SUMOAbstractRouter<MSEdge, SUMOVehicle>& router, const bool onInit = false, const bool withTaz = false, const bool silent = false, const MSEdge* sink = nullptr);


/** @brief Replaces the current route by the given edges
Expand Down
3 changes: 2 additions & 1 deletion src/utils/vehicle/SUMOVehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ class SUMOVehicle : public SUMOTrafficObject {
*
* @param[in] t The time for which the route is computed
* @param[in] router The router to use
* @return whether a valid route was found
* @see replaceRoute
*/
virtual void reroute(SUMOTime t, const std::string& info, SUMOAbstractRouter<MSEdge, SUMOVehicle>& router, const bool onInit = false, const bool withTaz = false, const bool silent = false, const MSEdge* sink = nullptr) = 0;
virtual bool reroute(SUMOTime t, const std::string& info, SUMOAbstractRouter<MSEdge, SUMOVehicle>& router, const bool onInit = false, const bool withTaz = false, const bool silent = false, const MSEdge* sink = nullptr) = 0;

/** @brief Validates the current or given route
* @param[out] msg Description why the route is not valid (if it is the case)
Expand Down

0 comments on commit 78e5481

Please sign in to comment.