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 /****************************************************************************/
16 // A traffic lights logic which represents a tls in an off-mode
17 /****************************************************************************/
18 #ifndef MSOffTrafficLightLogic_h
19 #define MSOffTrafficLightLogic_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <utility>
28 #include <vector>
29 #include <bitset>
30 #include <utils/common/StdDefs.h>
31 #include "MSTLLogicControl.h"
32 #include "MSTrafficLightLogic.h"
33 
34 
35 // ===========================================================================
36 // class definitions
37 // ===========================================================================
43 public:
50  const std::string& id);
51 
52 
57  virtual void init(NLDetectorBuilder& nb);
58 
59 
62 
63 
66 
73 
74 
75 
78 
84  return 120 * DELTA_T;
85  }
86 
88 
89 
92 
97  int getPhaseNumber() const;
98 
99 
104  const Phases& getPhases() const;
105 
106 
112  const MSPhaseDefinition& getPhase(int givenstep) const;
113 
117  const std::string getLogicType() const {
118  return "offTrafficLightLogic";
119  }
121 
122 
123 
126 
131  int getCurrentPhaseIndex() const;
132 
133 
138  const MSPhaseDefinition& getCurrentPhaseDef() const;
140 
141 
142 
145 
150  SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const;
151 
152 
158  SUMOTime getOffsetFromIndex(int index) const;
159 
160 
166  int getIndexFromOffset(SUMOTime offset) const;
168 
169 
170 
173 
181  void changeStepAndDuration(MSTLLogicControl& tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration) {
182  UNUSED_PARAMETER(tlcontrol);
183  UNUSED_PARAMETER(simStep);
184  UNUSED_PARAMETER(step);
185  UNUSED_PARAMETER(stepDuration);
186  }
188 
189 
190 private:
193  void rebuildPhase();
194 
195 
196 private:
199 
200 
201 };
202 
203 
204 #endif
205 
206 /****************************************************************************/
207 
UNUSED_PARAMETER
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:31
MSOffTrafficLightLogic::getPhase
const MSPhaseDefinition & getPhase(int givenstep) const
Returns the definition of the phase from the given position within the plan.
Definition: MSOffTrafficLightLogic.cpp:107
MSOffTrafficLightLogic::~MSOffTrafficLightLogic
~MSOffTrafficLightLogic()
Destructor.
Definition: MSOffTrafficLightLogic.cpp:42
MSTLLogicControl.h
DELTA_T
SUMOTime DELTA_T
Definition: SUMOTime.cpp:36
MSOffTrafficLightLogic::getCurrentPhaseIndex
int getCurrentPhaseIndex() const
Returns the current index within the program.
Definition: MSOffTrafficLightLogic.cpp:114
MSTrafficLightLogic::Phases
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
Definition: MSTrafficLightLogic.h:61
MSOffTrafficLightLogic::getLogicType
const std::string getLogicType() const
Returns the type of the logic as a string.
Definition: MSOffTrafficLightLogic.h:117
MSOffTrafficLightLogic::getPhases
const Phases & getPhases() const
Returns the phases of this tls program.
Definition: MSOffTrafficLightLogic.cpp:101
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
MSTrafficLightLogic.h
MSOffTrafficLightLogic
A traffic lights logic which represents a tls in an off-mode.
Definition: MSOffTrafficLightLogic.h:42
MSOffTrafficLightLogic::getPhaseIndexAtTime
SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const
Returns the index of the logic at the given simulation step.
Definition: MSOffTrafficLightLogic.cpp:127
MSTrafficLightLogic
The parent class for traffic light logics.
Definition: MSTrafficLightLogic.h:55
MSOffTrafficLightLogic::myPhaseDefinition
MSTrafficLightLogic::Phases myPhaseDefinition
The phase definition (only one)
Definition: MSOffTrafficLightLogic.h:198
MSOffTrafficLightLogic::rebuildPhase
void rebuildPhase()
(Re)builds the internal phase definition
Definition: MSOffTrafficLightLogic.cpp:64
MSOffTrafficLightLogic::getIndexFromOffset
int getIndexFromOffset(SUMOTime offset) const
Returns the step (the phasenumber) of a given position of the cycle.
Definition: MSOffTrafficLightLogic.cpp:139
MSOffTrafficLightLogic::init
virtual void init(NLDetectorBuilder &nb)
Initialises the tls with information about incoming lanes.
Definition: MSOffTrafficLightLogic.cpp:50
MSOffTrafficLightLogic::adaptLinkInformationFrom
void adaptLinkInformationFrom(const MSTrafficLightLogic &logic)
Applies information about controlled links and lanes from the given logic.
Definition: MSOffTrafficLightLogic.cpp:57
MSOffTrafficLightLogic::changeStepAndDuration
void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)
Changes the current phase and her duration.
Definition: MSOffTrafficLightLogic.h:181
config.h
StdDefs.h
MSTLLogicControl
A class that stores and controls tls and switching of their programs.
Definition: MSTLLogicControl.h:59
MSPhaseDefinition
The definition of a single phase of a tls logic.
Definition: MSPhaseDefinition.h:51
MSOffTrafficLightLogic::getCurrentPhaseDef
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
Definition: MSOffTrafficLightLogic.cpp:120
MSOffTrafficLightLogic::MSOffTrafficLightLogic
MSOffTrafficLightLogic(MSTLLogicControl &tlcontrol, const std::string &id)
Constructor.
Definition: MSOffTrafficLightLogic.cpp:35
MSOffTrafficLightLogic::getOffsetFromIndex
SUMOTime getOffsetFromIndex(int index) const
Returns the position (start of a phase during a cycle) from of a given step.
Definition: MSOffTrafficLightLogic.cpp:133
NLDetectorBuilder
Builds detectors for microsim.
Definition: NLDetectorBuilder.h:55
MSOffTrafficLightLogic::getPhaseNumber
int getPhaseNumber() const
Returns the number of phases.
Definition: MSOffTrafficLightLogic.cpp:95
MSOffTrafficLightLogic::trySwitch
SUMOTime trySwitch()
Switches to the next phase.
Definition: MSOffTrafficLightLogic.h:83