Skip to content

Commit

Permalink
now indicating jammed detectors (orange,crossed-out). refs #5212
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed May 4, 2022
1 parent 61ceb50 commit 089f7b0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/guisim/GUIInductLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,17 @@ GUIInductLoop::MyWrapper::drawGL(const GUIVisualizationSettings& s) const {
glColor3d(1, 1, 1);
} else {
GLHelper::setColor(*mySpecialColor);
if (width * exaggeration > 1 && *mySpecialColor == RGBColor::ORANGE) {
// jammed actuated-tls detector, draw crossed-out:
glBegin(GL_LINES);
glVertex2d(-1.0, 2);
glVertex2d(1.0, -2);
glEnd();
glBegin(GL_LINES);
glVertex2d(-1.0, -2);
glVertex2d(1.0, 2);
glEnd();
}
}

// outline
Expand Down
17 changes: 15 additions & 2 deletions src/microsim/traffic_lights/MSActuatedTrafficLightLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,11 @@ MSActuatedTrafficLightLogic::trySwitch() {
if ((myShowDetectors || multiTarget) && getCurrentPhaseDef().isGreenPhase()) {
for (InductLoopInfo* loopInfo : myInductLoopsForPhase[myStep]) {
//std::cout << SIMTIME << " p=" << myStep << " loopinfo=" << loopInfo->loop->getID() << " set lastGreen=" << STEPS2TIME(now) << "\n";
loopInfo->loop->setSpecialColor(&RGBColor::GREEN);
if (loopInfo->isJammed()) {
loopInfo->loop->setSpecialColor(&RGBColor::ORANGE);
} else {
loopInfo->loop->setSpecialColor(&RGBColor::GREEN);
}
loopInfo->lastGreenTime = now;
}
}
Expand Down Expand Up @@ -794,7 +798,11 @@ MSActuatedTrafficLightLogic::gapControl() {
// now the gapcontrol starts
for (InductLoopInfo* loopInfo : myInductLoopsForPhase[myStep]) {
MSInductLoop* loop = loopInfo->loop;
loop->setSpecialColor(&RGBColor::GREEN);
if (loopInfo->isJammed()) {
loopInfo->loop->setSpecialColor(&RGBColor::ORANGE);
} else {
loopInfo->loop->setSpecialColor(&RGBColor::GREEN);
}
const double actualGap = loop->getTimeSinceLastDetection();
if (actualGap < loopInfo->maxGap && !loopInfo->isJammed() ) {
result = MIN2(result, actualGap);
Expand Down Expand Up @@ -1309,6 +1317,7 @@ MSActuatedTrafficLightLogic::setParameter(const std::string& key, const std::str
for (InductLoopInfo& loopInfo : myInductLoops) {
if (loopInfo.lane->getID() == laneID) {
loopInfo.maxGap = StringUtils::toDouble(value);
Parameterised::setParameter(key, value);
return;
}
}
Expand All @@ -1325,13 +1334,17 @@ MSActuatedTrafficLightLogic::setParameter(const std::string& key, const std::str
for (InductLoopInfo& loopInfo : myInductLoops) {
if (loopInfo.lane->getID() == laneID) {
loopInfo.jamThreshold = StringUtils::toDouble(value);
Parameterised::setParameter(key, value);
return;
}
}
throw InvalidArgument("Invalid lane '" + laneID + "' in key '" + key + "' for actuated traffic light '" + getID() + "'");
} else if (key == "show-detectors") {
myShowDetectors = StringUtils::toBool(value);
Parameterised::setParameter(key, value);
for (InductLoopInfo& loopInfo : myInductLoops) {
loopInfo.loop->setVisible(myShowDetectors);
}
} else if (key == "inactive-threshold") {
myInactiveThreshold = string2time(value);
Parameterised::setParameter(key, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@

<tlLogic id="C" type="actuated" programID="0" offset="0">
<param key="jam-threshold:SC_0" value="5"/>
<param key="show-detectors" value="true"/>
</tlLogic>
</additional>

0 comments on commit 089f7b0

Please sign in to comment.