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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // The base class for traffic light logic with phases
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
23 #include <utility>
24 #include <vector>
25 #include <bitset>
27 #include <microsim/MSNet.h>
28 #include "MSTrafficLightLogic.h"
29 #include "MSPhaseDefinition.h"
30 
31 
32 // ===========================================================================
33 // class definitions
34 // ===========================================================================
46 public:
56  const std::string& id, const std::string& programID,
57  const TrafficLightType logicType,
58  const Phases& phases, int step, SUMOTime delay,
59  const std::map<std::string, std::string>& parameters);
60 
61 
64 
65 
66 
70 
75  /* SUMOTime trySwitch(bool isActive);*/
76 
77 
78 
81 
86  int getPhaseNumber() const;
87 
88 
93  const Phases& getPhases() const;
94 
100  const MSPhaseDefinition& getPhase(int givenstep) const;
102 
103 
104 
107 
112  int getCurrentPhaseIndex() const;
113 
114 
119  const MSPhaseDefinition& getCurrentPhaseDef() const;
121 
122 
123 
126 
131  SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const;
132 
133 
139  SUMOTime getOffsetFromIndex(int index) const;
140 
141 
147  int getIndexFromOffset(SUMOTime offset) const;
149 
150 
151 
154 
162  void changeStepAndDuration(MSTLLogicControl& tlcontrol, SUMOTime simStep,
163  int step, SUMOTime stepDuration);
165 
168  void setPhases(const Phases& phases, int index);
170 
171 protected:
174 
176  void proceedToNextStep();
177 
179  void setStep(int step);
180 
181 private:
182 
184  void deletePhases();
185 
186 protected:
187 
189  int myStep;
190 
191 
192 
193 };
long long int SUMOTime
Definition: SUMOTime.h:31
TrafficLightType
The definition of a single phase of a tls logic.
A fixed traffic light logic.
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.
void proceedToNextStep()
Proceed to the next step.
void deletePhases()
frees memory responsibilities
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 setPhases(const Phases &phases, int index)
Replaces the phases and set the phase index.
const Phases & getPhases() const
Returns the phases of this tls program.
int getCurrentPhaseIndex() const
Returns the current index within the program.
SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const
Returns the index of the logic at the given simulation step.
SUMOTime getOffsetFromIndex(int index) const
Returns the position (start of a phase during a cycle) from of a given step.
int getPhaseNumber() const
Returns the number of phases.
const MSPhaseDefinition & getPhase(int givenstep) const
Returns the definition of the phase from the given position within the plan.
void setStep(int step)
Forces a specific step.
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)
Changes the current phase and her duration.
A class that stores and controls tls and switching of their programs.
The parent class for traffic light logics.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.