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 
MSNet.h
MSPhasedTrafficLightLogic::myPhases
Phases myPhases
The list of phases this logic uses.
Definition: MSPhasedTrafficLightLogic.h:176
MSPhasedTrafficLightLogic::getPhase
const MSPhaseDefinition & getPhase(int givenstep) const
Returns the definition of the phase from the given position within the plan.
Definition: MSPhasedTrafficLightLogic.cpp:118
MSPhasedTrafficLightLogic::getCurrentPhaseDef
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
Definition: MSPhasedTrafficLightLogic.cpp:132
MSTrafficLightLogic::Phases
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
Definition: MSTrafficLightLogic.h:62
MSPhasedTrafficLightLogic::getPhaseNumber
int getPhaseNumber() const
Returns the number of phases.
Definition: MSPhasedTrafficLightLogic.cpp:107
TrafficLightType
TrafficLightType
Definition: SUMOXMLDefinitions.h:1192
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
MSPhasedTrafficLightLogic::setPhases
void setPhases(const Phases &phases, int index)
Replaces the phases and set the phase index.
Definition: MSPhasedTrafficLightLogic.cpp:196
MSPhasedTrafficLightLogic::setStep
void setStep(int step)
Forces a specific step.
Definition: MSPhasedTrafficLightLogic.cpp:97
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:38
MSTrafficLightLogic.h
MSPhasedTrafficLightLogic::proceedToNextStep
void proceedToNextStep()
Proceed to the next step.
Definition: MSPhasedTrafficLightLogic.cpp:92
MSPhasedTrafficLightLogic::getPhaseIndexAtTime
SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const
Returns the index of the logic at the given simulation step.
Definition: MSPhasedTrafficLightLogic.cpp:139
MSPhasedTrafficLightLogic::deletePhases
void deletePhases()
frees memory responsibilities
Definition: MSPhasedTrafficLightLogic.cpp:205
MSPhasedTrafficLightLogic::getPhases
const Phases & getPhases() const
Returns the phases of this tls program.
Definition: MSPhasedTrafficLightLogic.cpp:113
MSPhasedTrafficLightLogic::~MSPhasedTrafficLightLogic
~MSPhasedTrafficLightLogic()
Destructor.
Definition: MSPhasedTrafficLightLogic.cpp:50
MSTrafficLightLogic
The parent class for traffic light logics.
Definition: MSTrafficLightLogic.h:56
MSPhasedTrafficLightLogic::getCurrentPhaseIndex
int getCurrentPhaseIndex() const
Returns the current index within the program.
Definition: MSPhasedTrafficLightLogic.cpp:126
MSPhasedTrafficLightLogic::getIndexFromOffset
int getIndexFromOffset(SUMOTime offset) const
Returns the step (the phasenumber) of a given position of the cycle.
Definition: MSPhasedTrafficLightLogic.cpp:160
MSPhasedTrafficLightLogic::changeStepAndDuration
void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)
Changes the current phase and her duration.
Definition: MSPhasedTrafficLightLogic.cpp:183
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:149
MSPhaseDefinition.h
MSPhasedTrafficLightLogic::myStep
int myStep
The current step.
Definition: MSPhasedTrafficLightLogic.h:192
config.h
MSTLLogicControl
A class that stores and controls tls and switching of their programs.
Definition: MSTLLogicControl.h:60
MSEventControl.h
MSPhaseDefinition
The definition of a single phase of a tls logic.
Definition: MSPhaseDefinition.h:52
MSPhasedTrafficLightLogic
A fixed traffic light logic.
Definition: MSPhasedTrafficLightLogic.h:48