SUMO - Simulation of Urban MObility
MSPhasedTrafficLightLogic.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2010-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // The base class for traffic light logic with phases
18 /****************************************************************************/
19 #ifndef MSPhasedTrafficLightLogic_h
20 #define MSPhasedTrafficLightLogic_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <utility>
33 #include <vector>
34 #include <bitset>
36 #include <microsim/MSNet.h>
37 #include "MSTrafficLightLogic.h"
38 #include "MSPhaseDefinition.h"
39 
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
55 public:
65  const std::string& id, const std::string& subid,
66  const Phases& phases, int step, SUMOTime delay,
67  const std::map<std::string, std::string>& parameters);
68 
69 
72 
73 
74 
78 
83  /* SUMOTime trySwitch(bool isActive) throw();*/
84 
85 
86 
89 
94  int getPhaseNumber() const;
95 
96 
101  const Phases& getPhases() const;
102 
108  const MSPhaseDefinition& getPhase(int givenstep) const;
110 
111 
112 
115 
120  int getCurrentPhaseIndex() const;
121 
122 
127  const MSPhaseDefinition& getCurrentPhaseDef() const;
129 
130 
131 
134 
139  SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const;
140 
141 
147  SUMOTime getOffsetFromIndex(int index) const;
148 
149 
155  int getIndexFromOffset(SUMOTime offset) const;
157 
158 
159 
162 
170  void changeStepAndDuration(MSTLLogicControl& tlcontrol, SUMOTime simStep,
171  int step, SUMOTime stepDuration);
173 
176  void setPhases(const Phases& phases, int index);
178 
179 protected:
182 
184  void proceedToNextStep();
185 
187  void setStep(int step);
188 
189 private:
190 
192  void deletePhases();
193 
194 protected:
195 
197  int myStep;
198 
199 
200 
201 };
202 
203 
204 #endif
205 
206 /****************************************************************************/
207 
SUMOTime getOffsetFromIndex(int index) const
Returns the position (start of a phase during a cycle) from of a given step.
void setPhases(const Phases &phases, int index)
Replaces the phases and set the phase index.
MSPhasedTrafficLightLogic(MSTLLogicControl &tlcontrol, const std::string &id, const std::string &subid, const Phases &phases, int step, SUMOTime delay, const std::map< std::string, std::string > &parameters)
Constructor.
const MSPhaseDefinition & getPhase(int givenstep) const
Returns the definition of the phase from the given position within the plan.
int getPhaseNumber() const
Returns the number of phases.
int getIndexFromOffset(SUMOTime offset) const
Returns the step (the phasenumber) of a given position of the cycle.
void proceedToNextStep()
Proceed to the next step.
A class that stores and controls tls and switching of their programs.
Phases myPhases
The list of phases this logic uses.
SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const
Returns the index of the logic at the given simulation step.
void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)
Changes the current phase and her duration.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
int getCurrentPhaseIndex() const
Returns the current index within the program.
const Phases & getPhases() const
Returns the phases of this tls program.
The parent class for traffic light logics.
long long int SUMOTime
Definition: TraCIDefs.h:51
A fixed traffic light logic.
The definition of a single phase of a tls logic.
void setStep(int step)
Forces a specific step.
void deletePhases()
frees memory responsibilities