SUMOTime MSTLLogicControl::WAUTSwitchProcedure::getDiffToStartOfPhase(MSTrafficLightLogic& logic, SUMOTime toTime) { unsigned int stepOfMyPos = logic.getIndexFromOffset(toTime); SUMOTime startOfPhase = logic.getOffsetFromIndex(stepOfMyPos); assert(toTime >= startOfPhase); return toTime - startOfPhase; }
void MSTLLogicControl::WAUTSwitchProcedure::switchToPos(SUMOTime simStep, MSTrafficLightLogic& logic, SUMOTime toTime) { unsigned int stepTo = logic.getIndexFromOffset(toTime); SUMOTime diff = getDiffToStartOfPhase(logic, toTime); const MSPhaseDefinition& phase = logic.getPhase(stepTo); SUMOTime leftDuration = phase.duration - diff; logic.changeStepAndDuration(myControl, simStep, stepTo, leftDuration); }