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-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 /****************************************************************************/
21 // A fixed traffic light logic
22 /****************************************************************************/
23 #ifndef MSSimpleTrafficLightLogic_h
24 #define MSSimpleTrafficLightLogic_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <utility>
37 #include <vector>
38 #include <bitset>
39 #include "MSTrafficLightLogic.h"
40 
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
45 class MSNet;
46 
47 
48 // ===========================================================================
49 // class definitions
50 // ===========================================================================
62 public:
72  const std::string& id, const std::string& subid,
73  const Phases& phases, int step, SUMOTime delay,
74  const std::map<std::string, std::string>& parameters);
75 
76 
79 
82 
87  virtual SUMOTime trySwitch();
89 
90 
91 
94 
99  int getPhaseNumber() const;
100 
101 
106  const Phases& getPhases() const;
107 
108 
113  Phases& getPhases();
114 
115 
121  const MSPhaseDefinition& getPhase(int givenstep) const;
122 
126  const std::string getLogicType() const {
127  return "simpleTrafficLightLogic";
128  }
130 
131 
132 
135 
140  int getCurrentPhaseIndex() const;
141 
142 
147  const MSPhaseDefinition& getCurrentPhaseDef() const;
149 
150 
151 
154 
159  SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const;
160 
161 
167  SUMOTime getOffsetFromIndex(int index) const;
168 
169 
175  int getIndexFromOffset(SUMOTime offset) const;
177 
178 
179 
182 
190  void changeStepAndDuration(MSTLLogicControl& tlcontrol, SUMOTime simStep,
191  int step, SUMOTime stepDuration);
192 
195  void setPhases(const Phases& phases, int index);
197 
198 
199 protected:
202 
204  int myStep;
205 
206 
207 private:
209  void deletePhases();
210 
211 };
212 
213 
214 #endif
215 
216 /****************************************************************************/
217 
MSSimpleTrafficLightLogic(MSTLLogicControl &tlcontrol, const std::string &id, const std::string &subid, const Phases &phases, int step, SUMOTime delay, const std::map< std::string, std::string > &parameters)
Constructor.
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:90
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.
long long int SUMOTime
Definition: TraCIDefs.h:51
const Phases & getPhases() const
Returns the phases of this tls program.
The definition of a single phase of a tls logic.
const MSPhaseDefinition & getPhase(int givenstep) const
Returns the definition of the phase from the given position within the plan.