Skip to content

Commit

Permalink
Fixes traci tests failures
Browse files Browse the repository at this point in the history
Signed-off-by: Max <mcschrader@crimson.ua.edu>
  • Loading branch information
mschrader15 authored and namdre committed Mar 1, 2024
1 parent c6a85c0 commit 7b9a10d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/microsim/traffic_lights/NEMAController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,6 @@ NEMALogic::validate_timing() {

void
NEMALogic::setNewSplits(std::vector<double> newSplits) {
// TODO: What is the difference between splits and max greens?
assert(newSplits.size() == 8);
for (auto& p : myPhaseObjs) {
if (newSplits[p->phaseName - 1] > 0) {
Expand Down Expand Up @@ -852,13 +851,13 @@ NEMALogic::calculateForceOffs170() {
SUMOTime runningTime = 0;
// loop through the phases for ring 0 and then 1
for (auto& p : getPhasesByRing(i)) {
runningTime += p->maxDuration + p->getTransitionTime(this);
runningTime += p->maxDuration + p->getTransitionTimeStateless();
// in 170, the cycle "starts" when the coordinated phase goes to yellow.
// See https://ops.fhwa.dot.gov/publications/fhwahop08024/chapter6.html
if (p->coordinatePhase) {
zeroTime[i] = runningTime;
}
p->forceOffTime = runningTime - p->getTransitionTime(this);
p->forceOffTime = runningTime - p->getTransitionTimeStateless();
p->greatestStartTime = p->forceOffTime - p->minDuration;
}
}
Expand Down Expand Up @@ -1497,7 +1496,7 @@ NEMAPhase::getTransitionTime(NEMALogic* controller) {
}
if (!transitionActive) {
// if a transition is not active, the transition is just yellow + red time
return (yellow + red);
return getTransitionTimeStateless();
}
// if a transition is active, then return the time left in the transition
return MAX2(TIME2STEPS(0), ((yellow + red) - (controller->getCurrentTime() - myLastEnd)));
Expand Down
13 changes: 12 additions & 1 deletion src/microsim/traffic_lights/NEMAController.h
Original file line number Diff line number Diff line change
Expand Up @@ -720,13 +720,23 @@ class NEMAPhase {
bool readyToSwitch;

/**
* @brief Get the Transition Time
* @brief Get the Transition Time give the current simulation time and phase state
*
* @param controller
* @return SUMOTime
*/
SUMOTime getTransitionTime(NEMALogic* controller);

/**
* @brief Get the Transition time given
*
* @param controller
* @return SUMOTime
*/
inline SUMOTime getTransitionTimeStateless(void) {
return yellow + red;
}

/// @brief get the prior phase
inline PhasePtr getSequentialPriorPhase(void) {
return sequentialPriorPhase;
Expand Down Expand Up @@ -783,6 +793,7 @@ class NEMAPhase {
inline void cleanupExit(void) {
transitionActive = false;
readyToSwitch = false;
myLightState = LightState::Red;
}

/// @brief simple internal check to see if done okay to transition
Expand Down

0 comments on commit 7b9a10d

Please sign in to comment.