SUMO - Simulation of Urban MObility
MSSimpleTrafficLightLogic.h
Go to the documentation of this file.
00001 /****************************************************************************/
00011 // A fixed traffic light logic
00012 /****************************************************************************/
00013 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00014 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00015 /****************************************************************************/
00016 //
00017 //   This file is part of SUMO.
00018 //   SUMO is free software: you can redistribute it and/or modify
00019 //   it under the terms of the GNU General Public License as published by
00020 //   the Free Software Foundation, either version 3 of the License, or
00021 //   (at your option) any later version.
00022 //
00023 /****************************************************************************/
00024 #ifndef MSSimpleTrafficLightLogic_h
00025 #define MSSimpleTrafficLightLogic_h
00026 
00027 
00028 // ===========================================================================
00029 // included modules
00030 // ===========================================================================
00031 #ifdef _MSC_VER
00032 #include <windows_config.h>
00033 #else
00034 #include <config.h>
00035 #endif
00036 
00037 #include <utility>
00038 #include <vector>
00039 #include <bitset>
00040 #include <microsim/MSEventControl.h>
00041 #include <microsim/MSNet.h>
00042 #include "MSTrafficLightLogic.h"
00043 #include "MSPhaseDefinition.h"
00044 
00045 
00046 // ===========================================================================
00047 // class definitions
00048 // ===========================================================================
00059 class MSSimpleTrafficLightLogic : public MSTrafficLightLogic {
00060 public:
00069     MSSimpleTrafficLightLogic(MSTLLogicControl& tlcontrol,
00070                               const std::string& id, const std::string& subid,
00071                               const Phases& phases, unsigned int step, SUMOTime delay);
00072 
00073 
00075     ~MSSimpleTrafficLightLogic();
00076 
00077 
00078 
00081 
00087     SUMOTime trySwitch(bool isActive);
00089 
00090 
00091 
00094 
00099     unsigned int getPhaseNumber() const;
00100 
00101 
00106     const Phases& getPhases() const;
00107 
00108 
00113     Phases& getPhases();
00114 
00115 
00121     const MSPhaseDefinition& getPhase(unsigned int givenstep) const;
00123 
00124 
00125 
00128 
00133     unsigned int getCurrentPhaseIndex() const;
00134 
00135 
00140     const MSPhaseDefinition& getCurrentPhaseDef() const;
00142 
00143 
00144 
00147 
00152     SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const;
00153 
00154 
00160     SUMOTime getOffsetFromIndex(unsigned int index) const;
00161 
00162 
00168     unsigned int getIndexFromOffset(SUMOTime offset) const;
00170 
00171 
00172 
00175 
00183     void changeStepAndDuration(MSTLLogicControl& tlcontrol, SUMOTime simStep,
00184                                unsigned int step, SUMOTime stepDuration);
00185 
00188     void setPhases(const Phases& phases, unsigned int index);
00190 
00191 
00192 protected:
00194     Phases myPhases;
00195 
00197     unsigned int myStep;
00198 
00199 
00200 private:
00202     void deletePhases();
00203 
00204 };
00205 
00206 
00207 #endif
00208 
00209 /****************************************************************************/
00210 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines