bool MSTLLogicControl::WAUTSwitchProcedure::isPosAtGSP(SUMOTime step, MSSimpleTrafficLightLogic *testLogic) { MSSimpleTrafficLightLogic *givenLogic = (MSSimpleTrafficLightLogic*) testLogic; size_t CycleTime = givenLogic->getDefaultCycleTime(); SUMOReal gspFrom = getGSPValue(givenLogic); ///get the position of the given signalprogramm at the actual simulationsecond size_t posFrom = givenLogic -> getPhaseIndexAtTime(step); if (gspFrom == CycleTime) { gspFrom = 0; } ///compare the position of the given programm with the GSP (GSP = "GuenstigerSchaltPunkt") if (gspFrom == posFrom) { return true; } else { return false; } }
void MSTLLogicControl::WAUTSwitchProcedure_Stretch::adaptLogic(SUMOTime step, SUMOReal position) { MSSimpleTrafficLightLogic *LogicTo = (MSSimpleTrafficLightLogic*) myTo; size_t cycleTime = LogicTo->getDefaultCycleTime(); // the position, in which the logic has to be switched unsigned int startPos = (unsigned int) position; // this is the position, where the Logic have to be after synchronisation size_t posAfterSyn = LogicTo->getPhaseIndexAtTime(step); // switch the toLogic to the startPosition // fehlt!!!! // erfolgt in cutLogic und/oder stretchLogic! // calculate the difference, that has to be equalized size_t deltaToCut = 0; if (posAfterSyn < startPos) { deltaToCut = posAfterSyn + cycleTime - startPos; } else deltaToCut = posAfterSyn - startPos; // test, wheter cutting of the Signalplan is possible size_t deltaPossible = 0; int noBereiche = getStretchBereicheNo(myTo); for (int i=0; i<noBereiche; i++) { StretchBereichDef def = getStretchBereichDef(myTo, i+1); assert(def.end >= def.begin) ; deltaPossible = deltaPossible + (size_t)(def.end - def.begin); } int stretchUmlaufAnz = (int) TplConvert<char>::_2SUMOReal(LogicTo->getParameterValue("StretchUmlaufAnz").c_str()); deltaPossible = stretchUmlaufAnz * deltaPossible; if ((deltaPossible > deltaToCut)&&(deltaToCut < (cycleTime / 2))) { cutLogic(step, startPos, deltaToCut); } else { size_t deltaToStretch = cycleTime - deltaToCut; if (deltaToStretch == cycleTime) { deltaToStretch = 0; } stretchLogic(step, startPos, deltaToStretch); } }
void MSTLLogicControl::WAUTSwitchProcedure_GSP::adaptLogic(SUMOTime step) { SUMOTime simStep = step; MSSimpleTrafficLightLogic *LogicTo = (MSSimpleTrafficLightLogic*) myTo; SUMOReal gspTo = getGSPValue(myTo); unsigned int stepTo = LogicTo->getIndexFromOffset((unsigned int) gspTo); size_t cycleTimeTo = LogicTo->getDefaultCycleTime(); // gets the actual position from the myToLogic size_t actPosTo = LogicTo->getPhaseIndexAtTime(simStep); size_t deltaToStretch= 0; if (gspTo == cycleTimeTo) { gspTo=0; } unsigned int diff = getDiffToStartOfPhase(LogicTo, (unsigned int) gspTo); if (gspTo >= actPosTo) { deltaToStretch = (size_t)(gspTo - actPosTo); } else { deltaToStretch = (size_t)(cycleTimeTo - actPosTo + gspTo); } unsigned int newdur = (unsigned int) LogicTo->getPhase(stepTo).duration - diff + deltaToStretch; LogicTo->changeStepAndDuration(myControl, simStep, stepTo, newdur); }