SUMO - Simulation of Urban MObility
MSPhasedTrafficLightLogic.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2010-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 /****************************************************************************/
15 // The base class for traffic light logic with phases
16 /****************************************************************************/
17 #ifndef MSPhasedTrafficLightLogic_h
18 #define MSPhasedTrafficLightLogic_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <utility>
27 #include <vector>
28 #include <bitset>
30 #include <microsim/MSNet.h>
31 #include "MSTrafficLightLogic.h"
32 #include "MSPhaseDefinition.h"
33 
34 
35 // ===========================================================================
36 // class definitions
37 // ===========================================================================
49 public:
59  const std::string& id, const std::string& subid,
60  const Phases& phases, int step, SUMOTime delay,
61  const std::map<std::string, std::string>& parameters);
62 
63 
66 
67 
68 
72 
77  /* SUMOTime trySwitch(bool isActive);*/
78 
79 
80 
83 
88  int getPhaseNumber() const;
89 
90 
95  const Phases& getPhases() const;
96 
102  const MSPhaseDefinition& getPhase(int givenstep) const;
104 
105 
106 
109 
114  int getCurrentPhaseIndex() const;
115 
116 
121  const MSPhaseDefinition& getCurrentPhaseDef() const;
123 
124 
125 
128 
133  SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const;
134 
135 
141  SUMOTime getOffsetFromIndex(int index) const;
142 
143 
149  int getIndexFromOffset(SUMOTime offset) const;
151 
152 
153 
156 
164  void changeStepAndDuration(MSTLLogicControl& tlcontrol, SUMOTime simStep,
165  int step, SUMOTime stepDuration);
167 
170  void setPhases(const Phases& phases, int index);
172 
173 protected:
176 
178  void proceedToNextStep();
179 
181  void setStep(int step);
182 
183 private:
184 
186  void deletePhases();
187 
188 protected:
189 
191  int myStep;
192 
193 
194 
195 };
196 
197 
198 #endif
199 
200 /****************************************************************************/
201 
long long int SUMOTime
Definition: SUMOTime.h:36
SUMOTime getOffsetFromIndex(int index) const
Returns the position (start of a phase during a cycle) from of a given step.
void setPhases(const Phases &phases, int index)
Replaces the phases and set the phase index.
MSPhasedTrafficLightLogic(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.
const MSPhaseDefinition & getPhase(int givenstep) const
Returns the definition of the phase from the given position within the plan.
int getPhaseNumber() const
Returns the number of phases.
int getIndexFromOffset(SUMOTime offset) const
Returns the step (the phasenumber) of a given position of the cycle.
void proceedToNextStep()
Proceed to the next step.
A class that stores and controls tls and switching of their programs.
Phases myPhases
The list of phases this logic uses.
SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const
Returns the index of the logic at the given simulation step.
void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)
Changes the current phase and her duration.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
int getCurrentPhaseIndex() const
Returns the current index within the program.
const Phases & getPhases() const
Returns the phases of this tls program.
The parent class for traffic light logics.
A fixed traffic light logic.
The definition of a single phase of a tls logic.
void setStep(int step)
Forces a specific step.
void deletePhases()
frees memory responsibilities