Eclipse 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-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 /****************************************************************************/
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& programID,
60  const TrafficLightType logicType,
61  const Phases& phases, int step, SUMOTime delay,
62  const std::map<std::string, std::string>& parameters);
63 
64 
67 
68 
69 
73 
78  /* SUMOTime trySwitch(bool isActive);*/
79 
80 
81 
84 
89  int getPhaseNumber() const;
90 
91 
96  const Phases& getPhases() const;
97 
103  const MSPhaseDefinition& getPhase(int givenstep) const;
105 
106 
107 
110 
115  int getCurrentPhaseIndex() const;
116 
117 
122  const MSPhaseDefinition& getCurrentPhaseDef() const;
124 
125 
126 
129 
134  SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const;
135 
136 
142  SUMOTime getOffsetFromIndex(int index) const;
143 
144 
150  int getIndexFromOffset(SUMOTime offset) const;
152 
153 
154 
157 
165  void changeStepAndDuration(MSTLLogicControl& tlcontrol, SUMOTime simStep,
166  int step, SUMOTime stepDuration);
168 
171  void setPhases(const Phases& phases, int index);
173 
174 protected:
177 
179  void proceedToNextStep();
180 
182  void setStep(int step);
183 
184 private:
185 
187  void deletePhases();
188 
189 protected:
190 
192  int myStep;
193 
194 
195 
196 };
197 
198 
199 #endif
200 
201 /****************************************************************************/
202 
long long int SUMOTime
Definition: SUMOTime.h:35
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.
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.
MSPhasedTrafficLightLogic(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.
void deletePhases()
frees memory responsibilities
TrafficLightType