Skip to content

Commit

Permalink
fix #15823
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Dec 1, 2024
1 parent 16174f9 commit eb0d227
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 3 deletions.
13 changes: 13 additions & 0 deletions src/guisim/GUILane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
#include <microsim/MSEdgeWeightsStorage.h>
#include <microsim/MSParkingArea.h>
#include <microsim/devices/MSDevice_Routing.h>
#include <microsim/traffic_lights/MSRailSignal.h>
#include <microsim/traffic_lights/MSDriveWay.h>
#include <mesosim/MELoop.h>
#include <mesosim/MESegment.h>
#include "GUILane.h"
Expand Down Expand Up @@ -1066,6 +1068,17 @@ GUILane::getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& view) {
if (myBidiLane != nullptr) {
ret->mkItem(TL("bidi-lane"), false, myBidiLane->getID());
}
// info for blocked departDriveWay
for (auto item : getParametersMap()) {
if (StringUtils::startsWith(item.first, "insertionBlocked:")) {
const MSDriveWay* dw = MSDriveWay::retrieveDepartDriveWay(myEdge, item.second);
if (dw != nullptr) {
ret->mkItem(("blocking " + dw->getID()).c_str(), false, toString(MSRailSignal::getBlockingVehicles(dw)));
ret->mkItem(("driveWays blocking " + dw->getID()).c_str(), false, toString(MSRailSignal::getBlockingDriveWays(dw)));
}
}
}

for (const auto& kv : myEdge->getParametersMap()) {
ret->mkItem(("edgeParam:" + kv.first).c_str(), false, kv.second);
}
Expand Down
3 changes: 2 additions & 1 deletion src/microsim/MSLane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,7 @@ MSLane::isInsertionSuccess(MSVehicle* aVehicle,
const MSDriveWay* dw = MSDriveWay::getDepartureDriveway(aVehicle);
MSEdgeVector occupied;
if (dw->foeDriveWayOccupied(false, aVehicle, occupied)) {
setParameter("insertionBlocked:" + aVehicle->getID(), dw->getID());
#ifdef DEBUG_INSERTION
if (DEBUG_COND2(aVehicle) || DEBUG_COND) {
std::cout << " foe of driveway " + dw->getID() + " has occupied edges " + toString(occupied) << "\n";
Expand Down Expand Up @@ -1333,7 +1334,7 @@ MSLane::isInsertionSuccess(MSVehicle* aVehicle,
if (isRail) {
unsetParameter("insertionConstraint:" + aVehicle->getID());
unsetParameter("insertionOrder:" + aVehicle->getID());
unsetParameter("insertionFail:" + aVehicle->getID());
unsetParameter("insertionBlocked:" + aVehicle->getID());
// rail_signal (not traffic_light) requires approach information for
// switching correctly at the start of the next simulation step
if (firstRailSignal != nullptr && firstRailSignal->getJunction()->getType() == SumoXMLNodeType::RAIL_SIGNAL) {
Expand Down
9 changes: 9 additions & 0 deletions src/microsim/traffic_lights/MSDriveWay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2038,5 +2038,14 @@ MSDriveWay::loadState(const SUMOSAXAttributes& attrs, int tag) {
}
}

const MSDriveWay*
MSDriveWay::retrieveDepartDriveWay(const MSEdge* edge, const std::string& id) {
for (MSDriveWay* dw : myDepartureDriveways[edge]) {
if (dw->getID() == id) {
return dw;
}
}
return nullptr;
}

/****************************************************************************/
2 changes: 2 additions & 0 deletions src/microsim/traffic_lights/MSDriveWay.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class MSDriveWay : public MSMoveReminder, public Named {
return myGlobalDriveWayIndex > 0;
}

static const MSDriveWay* retrieveDepartDriveWay(const MSEdge* edge, const std::string& id);

bool notifyEnter(SUMOTrafficObject& veh, Notification reason, const MSLane* enteredLane);
bool notifyLeave(SUMOTrafficObject& veh, double lastPos, Notification reason, const MSLane* enteredLane = 0);
bool notifyLeaveBack(SUMOTrafficObject& veh, Notification reason, const MSLane* leftLane);
Expand Down
33 changes: 31 additions & 2 deletions src/microsim/traffic_lights/MSRailSignal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,15 +559,30 @@ MSRailSignal::LinkInfo::reroute(SUMOVehicle* veh, const MSEdgeVector& occupied)
}
}


void
MSRailSignal::storeTraCIVehicles(int linkIndex) {
MSRailSignal::resetStored() {
myBlockingVehicles.clear();
myRivalVehicles.clear();
myPriorityVehicles.clear();
myConstraintInfo = "";
myBlockingDriveWays.clear();
myRequestedDriveWay = "";
}


void
MSRailSignal::storeTraCIVehicles(const MSDriveWay* dw) {
resetStored();
myStoreVehicles = true;
MSEdgeVector occupied;
// call for side effects
dw->foeDriveWayOccupied(true, nullptr, occupied);
myStoreVehicles = false;
}

void
MSRailSignal::storeTraCIVehicles(int linkIndex) {
resetStored();
myStoreVehicles = true;
LinkInfo& li = myLinkInfos[linkIndex];
if (li.myLink->getApproaching().size() > 0) {
Expand Down Expand Up @@ -623,6 +638,20 @@ MSRailSignal::getBlockingDriveWays(int linkIndex) {
return myBlockingDriveWays;
}


MSRailSignal::VehicleVector
MSRailSignal::getBlockingVehicles(const MSDriveWay* dw) {
storeTraCIVehicles(dw);
return myBlockingVehicles;
}


std::vector<const MSDriveWay*>
MSRailSignal::getBlockingDriveWays(const MSDriveWay* dw) {
storeTraCIVehicles(dw);
return myBlockingDriveWays;
}

const MSDriveWay&
MSRailSignal::retrieveDriveWay(int numericalID) const {
for (const LinkInfo& li : myLinkInfos) {
Expand Down
9 changes: 9 additions & 0 deletions src/microsim/traffic_lights/MSRailSignal.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ class MSRailSignal : public MSTrafficLightLogic {
/// @brief return vehicles that block the intersection/rail signal for vehicles that wish to pass the given linkIndex
VehicleVector getBlockingVehicles(int linkIndex) override;
std::string getBlockingVehicleIDs() const;
/// @brief return vehicles that block the given driveWay
static VehicleVector getBlockingVehicles(const MSDriveWay* dw);

/// @brief return vehicles that approach the intersection/rail signal and are in conflict with vehicles that wish to pass the given linkIndex
VehicleVector getRivalVehicles(int linkIndex) override;
Expand All @@ -227,6 +229,9 @@ class MSRailSignal : public MSTrafficLightLogic {
std::vector<const MSDriveWay*> getBlockingDriveWays(int linkIndex) override;
std::string getBlockingDriveWayIDs() const;

/// @brief return driveways that block the given driveWay
static std::vector<const MSDriveWay*> getBlockingDriveWays(const MSDriveWay* dw);

std::string getRequestedDriveWay(int linkIndex) override;
std::string getRequestedDriveWay() const;

Expand Down Expand Up @@ -370,6 +375,10 @@ class MSRailSignal : public MSTrafficLightLogic {
protected:
/// @brief update vehicle lists for traci calls
void storeTraCIVehicles(int linkIndex);
static void storeTraCIVehicles(const MSDriveWay* dw);

/// @brief reset temporary storage for injected conflict output
static void resetStored();

/// @name traci result storage
//@{
Expand Down

0 comments on commit eb0d227

Please sign in to comment.