SUMO - Simulation of Urban MObility
MSSimpleTrafficLightLogic.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-2018 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 /****************************************************************************/
19 // A fixed traffic light logic
20 /****************************************************************************/
21 #ifndef MSSimpleTrafficLightLogic_h
22 #define MSSimpleTrafficLightLogic_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #include <config.h>
29 
30 #include <utility>
31 #include <vector>
32 #include <bitset>
33 #include "MSTrafficLightLogic.h"
34 
35 
36 // ===========================================================================
37 // class declarations
38 // ===========================================================================
39 class MSNet;
40 
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
56 public:
69  const std::string& id, const std::string& programID,
70  const TrafficLightType logicType,
71  const Phases& phases, int step, SUMOTime delay,
72  const std::map<std::string, std::string>& parameters);
73 
74 
77 
80 
85  virtual SUMOTime trySwitch();
87 
88 
89 
92 
97  int getPhaseNumber() const;
98 
99 
104  const Phases& getPhases() const;
105 
106 
111  Phases& getPhases();
112 
113 
119  const MSPhaseDefinition& getPhase(int givenstep) const;
120 
124  const std::string getLogicType() const {
125  return "simpleTrafficLightLogic";
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,
189  int step, SUMOTime stepDuration);
190 
193  void setPhases(const Phases& phases, int index);
195 
196 
197 protected:
200 
202  int myStep;
203 
204 
205 private:
207  void deletePhases();
208 
209 };
210 
211 
212 #endif
213 
214 /****************************************************************************/
215 
long long int SUMOTime
Definition: SUMOTime.h:36
void setPhases(const Phases &phases, int index)
Replaces the phases and set the phase index.
void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)
Changes the current phase and her duration.
Phases myPhases
The list of phases this logic uses.
int getIndexFromOffset(SUMOTime offset) const
Returns the step (the phasenumber) of a given position of the cycle.
SUMOTime getOffsetFromIndex(int index) const
Returns the position (start of a phase during a cycle) from of a given step.
SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const
Returns the index of the logic at the given simulation step.
const std::string getLogicType() const
Returns the type of the logic as a string.
The simulated network and simulation perfomer.
Definition: MSNet.h:84
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
A fixed traffic light logic.
A class that stores and controls tls and switching of their programs.
int getCurrentPhaseIndex() const
Returns the current index within the program.
virtual SUMOTime trySwitch()
Switches to the next phase.
void deletePhases()
frees memory responsibilities
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
int getPhaseNumber() const
Returns the number of phases.
The parent class for traffic light logics.
const Phases & getPhases() const
Returns the phases of this tls program.
The definition of a single phase of a tls logic.
MSSimpleTrafficLightLogic(MSTLLogicControl &tlcontrol, const std::string &id, const std::string &programID, const TrafficLightType logicType, 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.
TrafficLightType