Eclipse 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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // A traffic lights logic which represents a tls in an off-mode
18 /****************************************************************************/
19 #ifndef MSOffTrafficLightLogic_h
20 #define MSOffTrafficLightLogic_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <utility>
29 #include <vector>
30 #include <bitset>
31 #include <utils/common/StdDefs.h>
32 #include "MSTLLogicControl.h"
33 #include "MSTrafficLightLogic.h"
34 
35 
36 // ===========================================================================
37 // class definitions
38 // ===========================================================================
44 public:
51  const std::string& id);
52 
53 
58  virtual void init(NLDetectorBuilder& nb);
59 
60 
63 
64 
67 
74 
75 
76 
79 
85  return 120 * DELTA_T;
86  }
87 
89 
90 
93 
98  int getPhaseNumber() const;
99 
100 
105  const Phases& getPhases() const;
106 
107 
113  const MSPhaseDefinition& getPhase(int givenstep) const;
114 
118  const std::string getLogicType() const {
119  return "offTrafficLightLogic";
120  }
122 
123 
124 
127 
132  int getCurrentPhaseIndex() const;
133 
134 
139  const MSPhaseDefinition& getCurrentPhaseDef() const;
141 
142 
143 
146 
151  SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const;
152 
153 
159  SUMOTime getOffsetFromIndex(int index) const;
160 
161 
167  int getIndexFromOffset(SUMOTime offset) const;
169 
170 
171 
174 
182  void changeStepAndDuration(MSTLLogicControl& tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration) {
183  UNUSED_PARAMETER(tlcontrol);
184  UNUSED_PARAMETER(simStep);
185  UNUSED_PARAMETER(step);
186  UNUSED_PARAMETER(stepDuration);
187  }
189 
190 
191 private:
194  void rebuildPhase();
195 
196 
197 private:
200 
201 
202 };
203 
204 
205 #endif
206 
207 /****************************************************************************/
208 
MSTrafficLightLogic::Phases myPhaseDefinition
The phase definition (only one)
Builds detectors for microsim.
long long int SUMOTime
Definition: SUMOTime.h:35
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:35
void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)
Changes the current phase and her duration.
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:32
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.
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.