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 /****************************************************************************/
14 // The base class for traffic light logic with phases
15 /****************************************************************************/
16 #ifndef MSPhasedTrafficLightLogic_h
17 #define MSPhasedTrafficLightLogic_h
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include <utility>
26 #include <vector>
27 #include <bitset>
29 #include <microsim/MSNet.h>
30 #include "MSTrafficLightLogic.h"
31 #include "MSPhaseDefinition.h"
32 
33 
34 // ===========================================================================
35 // class definitions
36 // ===========================================================================
48 public:
58  const std::string& id, const std::string& programID,
59  const TrafficLightType logicType,
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 
MSNet.h
MSPhasedTrafficLightLogic::myPhases
Phases myPhases
The list of phases this logic uses.
Definition: MSPhasedTrafficLightLogic.h:175
MSPhasedTrafficLightLogic::getPhase
const MSPhaseDefinition & getPhase(int givenstep) const
Returns the definition of the phase from the given position within the plan.
Definition: MSPhasedTrafficLightLogic.cpp:117
MSPhasedTrafficLightLogic::getCurrentPhaseDef
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
Definition: MSPhasedTrafficLightLogic.cpp:131
MSTrafficLightLogic::Phases
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
Definition: MSTrafficLightLogic.h:61
MSPhasedTrafficLightLogic::getPhaseNumber
int getPhaseNumber() const
Returns the number of phases.
Definition: MSPhasedTrafficLightLogic.cpp:106
TrafficLightType
TrafficLightType
Definition: SUMOXMLDefinitions.h:1197
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
MSPhasedTrafficLightLogic::setPhases
void setPhases(const Phases &phases, int index)
Replaces the phases and set the phase index.
Definition: MSPhasedTrafficLightLogic.cpp:195
MSPhasedTrafficLightLogic::setStep
void setStep(int step)
Forces a specific step.
Definition: MSPhasedTrafficLightLogic.cpp:96
MSPhasedTrafficLightLogic::MSPhasedTrafficLightLogic
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.
Definition: MSPhasedTrafficLightLogic.cpp:37
MSTrafficLightLogic.h
MSPhasedTrafficLightLogic::proceedToNextStep
void proceedToNextStep()
Proceed to the next step.
Definition: MSPhasedTrafficLightLogic.cpp:91
MSPhasedTrafficLightLogic::getPhaseIndexAtTime
SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const
Returns the index of the logic at the given simulation step.
Definition: MSPhasedTrafficLightLogic.cpp:138
MSPhasedTrafficLightLogic::deletePhases
void deletePhases()
frees memory responsibilities
Definition: MSPhasedTrafficLightLogic.cpp:204
MSPhasedTrafficLightLogic::getPhases
const Phases & getPhases() const
Returns the phases of this tls program.
Definition: MSPhasedTrafficLightLogic.cpp:112
MSPhasedTrafficLightLogic::~MSPhasedTrafficLightLogic
~MSPhasedTrafficLightLogic()
Destructor.
Definition: MSPhasedTrafficLightLogic.cpp:49
MSTrafficLightLogic
The parent class for traffic light logics.
Definition: MSTrafficLightLogic.h:55
MSPhasedTrafficLightLogic::getCurrentPhaseIndex
int getCurrentPhaseIndex() const
Returns the current index within the program.
Definition: MSPhasedTrafficLightLogic.cpp:125
MSPhasedTrafficLightLogic::getIndexFromOffset
int getIndexFromOffset(SUMOTime offset) const
Returns the step (the phasenumber) of a given position of the cycle.
Definition: MSPhasedTrafficLightLogic.cpp:159
MSPhasedTrafficLightLogic::changeStepAndDuration
void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)
Changes the current phase and her duration.
Definition: MSPhasedTrafficLightLogic.cpp:182
MSPhasedTrafficLightLogic::getOffsetFromIndex
SUMOTime getOffsetFromIndex(int index) const
Returns the position (start of a phase during a cycle) from of a given step.
Definition: MSPhasedTrafficLightLogic.cpp:148
MSPhaseDefinition.h
MSPhasedTrafficLightLogic::myStep
int myStep
The current step.
Definition: MSPhasedTrafficLightLogic.h:191
config.h
MSTLLogicControl
A class that stores and controls tls and switching of their programs.
Definition: MSTLLogicControl.h:59
MSEventControl.h
MSPhaseDefinition
The definition of a single phase of a tls logic.
Definition: MSPhaseDefinition.h:51
MSPhasedTrafficLightLogic
A fixed traffic light logic.
Definition: MSPhasedTrafficLightLogic.h:47