SUMO - Simulation of Urban MObility
MSPhasedTrafficLightLogic.h
Go to the documentation of this file.
1 /****************************************************************************/
7 // The base class for traffic light logic with phases
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright 2001-2009 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 #ifndef MSPhasedTrafficLightLogic_h
21 #define MSPhasedTrafficLightLogic_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <utility>
34 #include <vector>
35 #include <bitset>
37 #include <microsim/MSNet.h>
38 #include "MSTrafficLightLogic.h"
39 #include "MSPhaseDefinition.h"
40 
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
56 public:
66  const std::string& id, const std::string& subid,
67  const Phases& phases, unsigned int step, SUMOTime delay,
68  const std::map<std::string, std::string>& parameters);
69 
70 
73 
74 
75 
79 
84  /* SUMOTime trySwitch(bool isActive) throw();*/
85 
86 
87 
90 
95  int getPhaseNumber() const;
96 
97 
102  const Phases& getPhases() const;
103 
109  const MSPhaseDefinition& getPhase(int givenstep) const;
111 
112 
113 
116 
121  int getCurrentPhaseIndex() const;
122 
123 
128  const MSPhaseDefinition& getCurrentPhaseDef() const;
130 
131 
132 
135 
140  SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const;
141 
142 
148  SUMOTime getOffsetFromIndex(unsigned int index) const;
149 
150 
156  unsigned int getIndexFromOffset(SUMOTime offset) const;
158 
159 
160 
163 
171  void changeStepAndDuration(MSTLLogicControl& tlcontrol, SUMOTime simStep,
172  unsigned int step, SUMOTime stepDuration);
174 
177  void setPhases(const Phases& phases, int index);
179 
180 protected:
183 
185  void proceedToNextStep();
186 
188  void setStep(int step);
189 
190 private:
191 
193  void deletePhases();
194 
195 protected:
196 
198  int myStep;
199 
200 
201 
202 };
203 
204 
205 #endif
206 
207 /****************************************************************************/
208 
long long int SUMOTime
Definition: SUMOTime.h:43
MSPhasedTrafficLightLogic(MSTLLogicControl &tlcontrol, const std::string &id, const std::string &subid, const Phases &phases, unsigned int step, SUMOTime delay, const std::map< std::string, std::string > &parameters)
Constructor.
void setPhases(const Phases &phases, int index)
Replaces the phases and set the phase index.
int getPhaseNumber() const
Returns the number of phases.
void proceedToNextStep()
Proceed to the next step.
A class that stores and controls tls and switching of their programs.
int getCurrentPhaseIndex() const
Returns the current index within the program.
Phases myPhases
The list of phases this logic uses.
const MSPhaseDefinition & getPhase(int givenstep) const
Returns the definition of the phase from the given position within the plan.
SUMOTime getOffsetFromIndex(unsigned int index) const
Returns the position (start of a phase during a cycle) from of a given step.
SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const
Returns the index of the logic at the given simulation step.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
unsigned int getIndexFromOffset(SUMOTime offset) const
Returns the step (the phasenumber) of a given position of the cycle.
const Phases & getPhases() const
Returns the phases of this tls program.
The parent class for traffic light logics.
A fixed traffic light logic.
The definition of a single phase of a tls logic.
void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, unsigned int step, SUMOTime stepDuration)
Changes the current phase and her duration.
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
void setStep(int step)
Forces a specific step.
void deletePhases()
frees memory responsibilities