SUMO - Simulation of Urban MObility
MSOffTrafficLightLogic.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-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 /****************************************************************************/
19 // A traffic lights logic which represents a tls in an off-mode
20 /****************************************************************************/
21 #ifndef MSOffTrafficLightLogic_h
22 #define MSOffTrafficLightLogic_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <utility>
35 #include <vector>
36 #include <bitset>
37 #include <utils/common/StdDefs.h>
38 #include "MSTLLogicControl.h"
39 #include "MSTrafficLightLogic.h"
40 
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
50 public:
57  const std::string& id);
58 
59 
64  virtual void init(NLDetectorBuilder& nb);
65 
66 
69 
70 
73 
80 
81 
82 
85 
91  return 120 * DELTA_T;
92  }
93 
95 
96 
99 
104  int getPhaseNumber() const;
105 
106 
111  const Phases& getPhases() const;
112 
113 
119  const MSPhaseDefinition& getPhase(int givenstep) const;
120 
124  const std::string getLogicType() const {
125  return "offTrafficLightLogic";
126  }
128 
129 
130 
133 
138  int getCurrentPhaseIndex() const;
139 
140 
145  const MSPhaseDefinition& getCurrentPhaseDef() const;
147 
148 
149 
152 
157  SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const;
158 
159 
165  SUMOTime getOffsetFromIndex(int index) const;
166 
167 
173  int getIndexFromOffset(SUMOTime offset) const;
175 
176 
177 
180 
188  void changeStepAndDuration(MSTLLogicControl& tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration) {
189  UNUSED_PARAMETER(tlcontrol);
190  UNUSED_PARAMETER(simStep);
191  UNUSED_PARAMETER(step);
192  UNUSED_PARAMETER(stepDuration);
193  }
195 
196 
197 private:
200  void rebuildPhase();
201 
202 
203 private:
206 
207 
208 };
209 
210 
211 #endif
212 
213 /****************************************************************************/
214 
MSTrafficLightLogic::Phases myPhaseDefinition
The phase definition (only one)
Builds detectors for microsim.
virtual void init(NLDetectorBuilder &nb)
Initialises the tls with information about incoming lanes.
void adaptLinkInformationFrom(const MSTrafficLightLogic &logic)
Applies information about controlled links and lanes from the given logic.
void rebuildPhase()
(Re)builds the internal phase definition
int getIndexFromOffset(SUMOTime offset) const
Returns the step (the phasenumber) of a given position of the cycle.
SUMOTime DELTA_T
Definition: SUMOTime.cpp:39
void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)
Changes the current phase and her duration.
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:39
A traffic lights logic which represents a tls in an off-mode.
A class that stores and controls tls and switching of their programs.
int getPhaseNumber() const
Returns the number of phases.
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
MSOffTrafficLightLogic(MSTLLogicControl &tlcontrol, const std::string &id)
Constructor.
SUMOTime getOffsetFromIndex(int index) const
Returns the position (start of a phase during a cycle) from of a given step.
SUMOTime trySwitch()
Switches to the next phase.
const MSPhaseDefinition & getPhase(int givenstep) const
Returns the definition of the phase from the given position within the plan.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
int getCurrentPhaseIndex() const
Returns the current index within the program.
const std::string getLogicType() const
Returns the type of the logic as a string.
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
The definition of a single phase of a tls logic.
SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const
Returns the index of the logic at the given simulation step.