MSTLLogicControl::WAUTSwitchProcedure_GSP Class Reference

#include <MSTLLogicControl.h>

Inheritance diagram for MSTLLogicControl::WAUTSwitchProcedure_GSP:

MSTLLogicControl::WAUTSwitchProcedure

Detailed Description

This class switches using the GSP algorithm.

Definition at line 553 of file MSTLLogicControl.h.


Public Member Functions

void adaptLogic (SUMOTime step)
unsigned int getDiffToStartOfPhase (MSSimpleTrafficLightLogic *givenLogic, unsigned int pos)
 Returns the difference between an given position and the start of the phase.
bool isPosAtGSP (SUMOTime step, MSSimpleTrafficLightLogic *testLogic)
void switchToPos (SUMOTime simStep, MSSimpleTrafficLightLogic *givenLogic, unsigned int toPos)
bool trySwitch (SUMOTime step)
 Determines whether a switch is possible.
 WAUTSwitchProcedure_GSP (MSTLLogicControl &control, WAUT &waut, MSTrafficLightLogic *from, MSTrafficLightLogic *to, bool synchron)
 Constructor.
 ~WAUTSwitchProcedure_GSP ()
 Destructor.

Protected Member Functions

SUMOReal getGSPValue (MSTrafficLightLogic *from) const
 Returns the GSP-value which should be within the tls program definition.

Protected Attributes

MSTLLogicControlmyControl
 The control the logic belongs to.
MSTrafficLightLogicmyFrom
 The current program of the tls to switch.
bool mySwitchSynchron
 Information whether to switch synchron (?).
MSTrafficLightLogicmyTo
 The program to switch the tls to.
WAUTmyWAUT
 The WAUT responsible for switching.

Private Member Functions

WAUTSwitchProcedure_GSPoperator= (const WAUTSwitchProcedure_GSP &)
 Invalidated assignment operator.
 WAUTSwitchProcedure_GSP (const WAUTSwitchProcedure_GSP &)
 Invalidated copy constructor.

Constructor & Destructor Documentation

MSTLLogicControl::WAUTSwitchProcedure_GSP::WAUTSwitchProcedure_GSP ( MSTLLogicControl control,
WAUT waut,
MSTrafficLightLogic from,
MSTrafficLightLogic to,
bool  synchron 
)

Constructor.

Definition at line 300 of file MSTLLogicControl.cpp.

00303         : MSTLLogicControl::WAUTSwitchProcedure(control, waut, from, to, synchron) {}

MSTLLogicControl::WAUTSwitchProcedure_GSP::~WAUTSwitchProcedure_GSP (  ) 

Destructor.

Definition at line 306 of file MSTLLogicControl.cpp.

00306 {}

MSTLLogicControl::WAUTSwitchProcedure_GSP::WAUTSwitchProcedure_GSP ( const WAUTSwitchProcedure_GSP  )  [private]

Invalidated copy constructor.


Member Function Documentation

void MSTLLogicControl::WAUTSwitchProcedure_GSP::adaptLogic ( SUMOTime  step  ) 

Definition at line 329 of file MSTLLogicControl.cpp.

References MSSimpleTrafficLightLogic::changeStepAndDuration(), MSPhaseDefinition::duration, MSTrafficLightLogic::getDefaultCycleTime(), MSTLLogicControl::WAUTSwitchProcedure::getDiffToStartOfPhase(), MSTLLogicControl::WAUTSwitchProcedure::getGSPValue(), MSSimpleTrafficLightLogic::getIndexFromOffset(), MSSimpleTrafficLightLogic::getPhase(), MSSimpleTrafficLightLogic::getPhaseIndexAtTime(), MSTLLogicControl::WAUTSwitchProcedure::myControl, MSTLLogicControl::WAUTSwitchProcedure::myTo, and SUMOReal.

Referenced by trySwitch().

00329                                                                  {
00330     SUMOTime simStep = step;
00331     MSSimpleTrafficLightLogic *LogicTo = (MSSimpleTrafficLightLogic*) myTo;
00332     SUMOReal gspTo = getGSPValue(myTo);
00333     unsigned int stepTo = LogicTo->getIndexFromOffset((unsigned int) gspTo);
00334     size_t cycleTimeTo = LogicTo->getDefaultCycleTime();
00335     // gets the actual position from the myToLogic
00336     size_t actPosTo = LogicTo->getPhaseIndexAtTime(simStep);
00337     size_t deltaToStretch= 0;
00338     if (gspTo == cycleTimeTo) {
00339         gspTo=0;
00340     }
00341     unsigned int diff = getDiffToStartOfPhase(LogicTo, (unsigned int) gspTo);
00342     if (gspTo >= actPosTo) {
00343         deltaToStretch = (size_t)(gspTo - actPosTo);
00344     } else {
00345         deltaToStretch = (size_t)(cycleTimeTo - actPosTo + gspTo);
00346     }
00347     unsigned int newdur = (unsigned int) LogicTo->getPhase(stepTo).duration - diff + deltaToStretch;
00348     LogicTo->changeStepAndDuration(myControl, simStep, stepTo, newdur);
00349 }

unsigned int MSTLLogicControl::WAUTSwitchProcedure::getDiffToStartOfPhase ( MSSimpleTrafficLightLogic givenLogic,
unsigned int  pos 
) [inherited]

Returns the difference between an given position and the start of the phase.

Definition at line 253 of file MSTLLogicControl.cpp.

References MSPhaseDefinition::duration, MSSimpleTrafficLightLogic::getIndexFromOffset(), MSSimpleTrafficLightLogic::getOffsetFromIndex(), and MSSimpleTrafficLightLogic::getPhase().

Referenced by adaptLogic(), MSTLLogicControl::WAUTSwitchProcedure_Stretch::cutLogic(), MSTLLogicControl::WAUTSwitchProcedure_Stretch::stretchLogic(), and MSTLLogicControl::WAUTSwitchProcedure::switchToPos().

00253                                                                                                                   {
00254     MSSimpleTrafficLightLogic *myLogic = givenLogic;
00255     unsigned int myPos = pos;
00256     unsigned int stepOfMyPos = myLogic->getIndexFromOffset(myPos);
00257     unsigned int startOfPhase = myLogic->getOffsetFromIndex(stepOfMyPos);
00258     MSPhaseDefinition myPhase = myLogic->getPhase(stepOfMyPos);
00259     unsigned int durOfPhase = (unsigned int)myPhase.duration;
00260 
00261     assert(myPos >= startOfPhase);
00262     unsigned int diff = myPos - startOfPhase;
00263     assert(diff <= durOfPhase);
00264     return diff;
00265 }

SUMOReal MSTLLogicControl::WAUTSwitchProcedure::getGSPValue ( MSTrafficLightLogic from  )  const [protected, inherited]

Returns the GSP-value which should be within the tls program definition.

Definition at line 223 of file MSTLLogicControl.cpp.

References TplConvert< E >::_2SUMOReal(), and MSTrafficLightLogic::getParameterValue().

Referenced by adaptLogic(), MSTLLogicControl::WAUTSwitchProcedure::isPosAtGSP(), MSTLLogicControl::WAUTSwitchProcedure_Stretch::trySwitch(), and trySwitch().

00223                                                                                 {
00224     std::string val = from->getParameterValue("GSP");
00225     if (val.length()==0) {
00226         return -1;
00227     }
00228     return TplConvert<char>::_2SUMOReal(val.c_str());
00229 }

bool MSTLLogicControl::WAUTSwitchProcedure::isPosAtGSP ( SUMOTime  step,
MSSimpleTrafficLightLogic testLogic 
) [inherited]

get the position of the given signalprogramm at the actual simulationsecond

compare the position of the given programm with the GSP (GSP = "GuenstigerSchaltPunkt")

Definition at line 233 of file MSTLLogicControl.cpp.

References MSTrafficLightLogic::getDefaultCycleTime(), MSTLLogicControl::WAUTSwitchProcedure::getGSPValue(), and SUMOReal.

Referenced by MSTLLogicControl::WAUTSwitchProcedure_Stretch::trySwitch(), and trySwitch().

00233                                                                                                    {
00234     MSSimpleTrafficLightLogic *givenLogic = (MSSimpleTrafficLightLogic*) testLogic;
00235     size_t CycleTime = givenLogic->getDefaultCycleTime();
00236     SUMOReal gspFrom = getGSPValue(givenLogic);
00238     size_t posFrom = givenLogic -> getPhaseIndexAtTime(step);
00239 
00240     if (gspFrom == CycleTime)   {
00241         gspFrom = 0;
00242     }
00244     if (gspFrom == posFrom) {
00245         return true;
00246     } else {
00247         return false;
00248     }
00249 }

WAUTSwitchProcedure_GSP& MSTLLogicControl::WAUTSwitchProcedure_GSP::operator= ( const WAUTSwitchProcedure_GSP  )  [private]

Invalidated assignment operator.

void MSTLLogicControl::WAUTSwitchProcedure::switchToPos ( SUMOTime  simStep,
MSSimpleTrafficLightLogic givenLogic,
unsigned int  toPos 
) [inherited]

Definition at line 269 of file MSTLLogicControl.cpp.

References MSSimpleTrafficLightLogic::changeStepAndDuration(), MSPhaseDefinition::duration, MSTLLogicControl::WAUTSwitchProcedure::getDiffToStartOfPhase(), MSSimpleTrafficLightLogic::getIndexFromOffset(), MSSimpleTrafficLightLogic::getPhase(), and MSTLLogicControl::WAUTSwitchProcedure::myControl.

Referenced by MSTLLogicControl::WAUTSwitchProcedure_Stretch::trySwitch(), and trySwitch().

00269                                                                                                                           {
00270     MSSimpleTrafficLightLogic *myLogic = givenLogic;
00271     unsigned int posTo = pos;
00272     unsigned int stepTo = myLogic->getIndexFromOffset(posTo);
00273     unsigned int diff = getDiffToStartOfPhase(myLogic, posTo);
00274     MSPhaseDefinition myPhase = myLogic->getPhase(stepTo);
00275     unsigned int dur = (unsigned int)myPhase.duration - diff;
00276     myLogic->changeStepAndDuration(myControl ,simStep, stepTo, dur);
00277 }

bool MSTLLogicControl::WAUTSwitchProcedure_GSP::trySwitch ( SUMOTime  step  )  [virtual]

Determines whether a switch is possible.

switch to the next programm if the GSP is reached

Implements MSTLLogicControl::WAUTSwitchProcedure.

Definition at line 310 of file MSTLLogicControl.cpp.

References adaptLogic(), MSTLLogicControl::WAUTSwitchProcedure::getGSPValue(), MSTLLogicControl::WAUTSwitchProcedure::isPosAtGSP(), MSTLLogicControl::WAUTSwitchProcedure::myFrom, MSTLLogicControl::WAUTSwitchProcedure::mySwitchSynchron, MSTLLogicControl::WAUTSwitchProcedure::myTo, SUMOReal, and MSTLLogicControl::WAUTSwitchProcedure::switchToPos().

00310                                                                 {
00311     MSSimpleTrafficLightLogic *LogicFrom = (MSSimpleTrafficLightLogic*) myFrom;
00312     MSSimpleTrafficLightLogic *LogicTo = (MSSimpleTrafficLightLogic*) myTo;
00313     SUMOReal posTo = 0;
00315     if (isPosAtGSP(step, LogicFrom)==true) {
00316         posTo = getGSPValue(myTo);
00317         if (mySwitchSynchron) {
00318             adaptLogic(step);
00319         } else {
00320             switchToPos(step, LogicTo, (unsigned int) posTo);
00321         }
00322         return true;
00323     }
00324     return false;
00325 }


Field Documentation

The current program of the tls to switch.

Definition at line 492 of file MSTLLogicControl.h.

Referenced by MSTLLogicControl::WAUTSwitchProcedure_Stretch::trySwitch(), and trySwitch().

Information whether to switch synchron (?).

Definition at line 498 of file MSTLLogicControl.h.

Referenced by MSTLLogicControl::WAUTSwitchProcedure_Stretch::trySwitch(), and trySwitch().

The WAUT responsible for switching.

Definition at line 501 of file MSTLLogicControl.h.


The documentation for this class was generated from the following files:

Generated on Wed May 5 00:06:49 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6