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 
UNUSED_PARAMETER
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:32
MSOffTrafficLightLogic::getPhase
const MSPhaseDefinition & getPhase(int givenstep) const
Returns the definition of the phase from the given position within the plan.
Definition: MSOffTrafficLightLogic.cpp:108
MSOffTrafficLightLogic::~MSOffTrafficLightLogic
~MSOffTrafficLightLogic()
Destructor.
Definition: MSOffTrafficLightLogic.cpp:43
MSTLLogicControl.h
DELTA_T
SUMOTime DELTA_T
Definition: SUMOTime.cpp:35
MSOffTrafficLightLogic::getCurrentPhaseIndex
int getCurrentPhaseIndex() const
Returns the current index within the program.
Definition: MSOffTrafficLightLogic.cpp:115
MSTrafficLightLogic::Phases
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
Definition: MSTrafficLightLogic.h:62
MSOffTrafficLightLogic::getLogicType
const std::string getLogicType() const
Returns the type of the logic as a string.
Definition: MSOffTrafficLightLogic.h:118
MSOffTrafficLightLogic::getPhases
const Phases & getPhases() const
Returns the phases of this tls program.
Definition: MSOffTrafficLightLogic.cpp:102
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
MSTrafficLightLogic.h
MSOffTrafficLightLogic
A traffic lights logic which represents a tls in an off-mode.
Definition: MSOffTrafficLightLogic.h:43
MSOffTrafficLightLogic::getPhaseIndexAtTime
SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const
Returns the index of the logic at the given simulation step.
Definition: MSOffTrafficLightLogic.cpp:128
MSTrafficLightLogic
The parent class for traffic light logics.
Definition: MSTrafficLightLogic.h:56
MSOffTrafficLightLogic::myPhaseDefinition
MSTrafficLightLogic::Phases myPhaseDefinition
The phase definition (only one)
Definition: MSOffTrafficLightLogic.h:199
MSOffTrafficLightLogic::rebuildPhase
void rebuildPhase()
(Re)builds the internal phase definition
Definition: MSOffTrafficLightLogic.cpp:65
MSOffTrafficLightLogic::getIndexFromOffset
int getIndexFromOffset(SUMOTime offset) const
Returns the step (the phasenumber) of a given position of the cycle.
Definition: MSOffTrafficLightLogic.cpp:140
MSOffTrafficLightLogic::init
virtual void init(NLDetectorBuilder &nb)
Initialises the tls with information about incoming lanes.
Definition: MSOffTrafficLightLogic.cpp:51
MSOffTrafficLightLogic::adaptLinkInformationFrom
void adaptLinkInformationFrom(const MSTrafficLightLogic &logic)
Applies information about controlled links and lanes from the given logic.
Definition: MSOffTrafficLightLogic.cpp:58
MSOffTrafficLightLogic::changeStepAndDuration
void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)
Changes the current phase and her duration.
Definition: MSOffTrafficLightLogic.h:182
config.h
StdDefs.h
MSTLLogicControl
A class that stores and controls tls and switching of their programs.
Definition: MSTLLogicControl.h:60
MSPhaseDefinition
The definition of a single phase of a tls logic.
Definition: MSPhaseDefinition.h:52
MSOffTrafficLightLogic::getCurrentPhaseDef
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
Definition: MSOffTrafficLightLogic.cpp:121
MSOffTrafficLightLogic::MSOffTrafficLightLogic
MSOffTrafficLightLogic(MSTLLogicControl &tlcontrol, const std::string &id)
Constructor.
Definition: MSOffTrafficLightLogic.cpp:36
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:134
NLDetectorBuilder
Builds detectors for microsim.
Definition: NLDetectorBuilder.h:56
MSOffTrafficLightLogic::getPhaseNumber
int getPhaseNumber() const
Returns the number of phases.
Definition: MSOffTrafficLightLogic.cpp:96
MSOffTrafficLightLogic::trySwitch
SUMOTime trySwitch()
Switches to the next phase.
Definition: MSOffTrafficLightLogic.h:84