SUMO - Simulation of Urban MObility

MSSimpleTrafficLightLogic.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // A fixed traffic light logic
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This program is free software; you can redistribute it and/or modify
00014 //   it under the terms of the GNU General Public License as published by
00015 //   the Free Software Foundation; either version 2 of the License, or
00016 //   (at your option) any later version.
00017 //
00018 /****************************************************************************/
00019 #ifndef MSSimpleTrafficLightLogic_h
00020 #define MSSimpleTrafficLightLogic_h
00021 
00022 
00023 // ===========================================================================
00024 // included modules
00025 // ===========================================================================
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031 
00032 #include <utility>
00033 #include <vector>
00034 #include <bitset>
00035 #include <microsim/MSEventControl.h>
00036 #include <microsim/MSNet.h>
00037 #include "MSTrafficLightLogic.h"
00038 #include "MSPhaseDefinition.h"
00039 
00040 
00041 // ===========================================================================
00042 // class definitions
00043 // ===========================================================================
00054 class MSSimpleTrafficLightLogic : public MSTrafficLightLogic {
00055 public:
00064     MSSimpleTrafficLightLogic(MSTLLogicControl& tlcontrol,
00065                               const std::string& id, const std::string& subid,
00066                               const Phases& phases, unsigned int step, SUMOTime delay);
00067 
00068 
00070     ~MSSimpleTrafficLightLogic();
00071 
00072 
00073 
00076 
00082     SUMOTime trySwitch(bool isActive);
00084 
00085 
00086 
00089 
00094     unsigned int getPhaseNumber() const;
00095 
00096 
00101     const Phases& getPhases() const;
00102 
00103 
00108     Phases& getPhases();
00109 
00110 
00116     const MSPhaseDefinition& getPhase(unsigned int givenstep) const;
00118 
00119 
00120 
00123 
00128     unsigned int getCurrentPhaseIndex() const;
00129 
00130 
00135     const MSPhaseDefinition& getCurrentPhaseDef() const;
00137 
00138 
00139 
00142 
00147     SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const;
00148 
00149 
00155     SUMOTime getOffsetFromIndex(unsigned int index) const;
00156 
00157 
00163     unsigned int getIndexFromOffset(SUMOTime offset) const;
00165 
00166 
00167 
00170 
00178     void changeStepAndDuration(MSTLLogicControl& tlcontrol, SUMOTime simStep,
00179                                unsigned int step, SUMOTime stepDuration);
00181 
00182 
00183 protected:
00185     Phases myPhases;
00186 
00188     unsigned int myStep;
00189 
00190 
00191 };
00192 
00193 
00194 #endif
00195 
00196 /****************************************************************************/
00197 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines