void MSTLLogicControl::WAUTSwitchProcedure_Stretch::adaptLogic(SUMOTime step) { SUMOTime gspTo = TIME2STEPS(getGSPValue(*myTo)); SUMOTime cycleTime = myTo->getDefaultCycleTime(); // the position, where the logic has to be after synchronisation SUMOTime posAfterSyn = myTo->getPhaseIndexAtTime(step); // calculate the difference, that has to be equalized SUMOTime deltaToCut = 0; if (posAfterSyn < gspTo) { deltaToCut = posAfterSyn + cycleTime - gspTo; } else { deltaToCut = posAfterSyn - gspTo; } // test, wheter cutting of the Signalplan is possible SUMOTime deltaPossible = 0; int areasNo = getStretchAreaNo(myTo); for (int i = 0; i < areasNo; i++) { StretchBereichDef def = getStretchBereichDef(myTo, i + 1); assert(def.end >= def.begin); deltaPossible += TIME2STEPS(def.end - def.begin); } int stretchUmlaufAnz = (int) TplConvert::_2SUMOReal(myTo->getParameterValue("StretchUmlaufAnz").c_str()); deltaPossible = stretchUmlaufAnz * deltaPossible; if ((deltaPossible > deltaToCut) && (deltaToCut < (cycleTime / 2))) { cutLogic(step, gspTo, deltaToCut); } else { SUMOTime deltaToStretch = (cycleTime - deltaToCut) % cycleTime; stretchLogic(step, gspTo, deltaToStretch); } }
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); } }