SUMO - Simulation of Urban MObility
MSSimpleTrafficLightLogic.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-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 /****************************************************************************/
19 // A fixed traffic light logic
20 /****************************************************************************/
21 #ifndef MSSimpleTrafficLightLogic_h
22 #define MSSimpleTrafficLightLogic_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #include <config.h>
29 
30 #include <utility>
31 #include <vector>
32 #include <bitset>
33 #include "MSTrafficLightLogic.h"
34 
35 
36 // ===========================================================================
37 // class declarations
38 // ===========================================================================
39 class MSNet;
40 
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
56 public:
66  const std::string& id, const std::string& subid,
67  const Phases& phases, int step, SUMOTime delay,
68  const std::map<std::string, std::string>& parameters);
69 
70 
73 
76 
81  virtual SUMOTime trySwitch();
83 
84 
85 
88 
93  int getPhaseNumber() const;
94 
95 
100  const Phases& getPhases() const;
101 
102 
107  Phases& getPhases();
108 
109 
115  const MSPhaseDefinition& getPhase(int givenstep) const;
116 
120  const std::string getLogicType() const {
121  return "simpleTrafficLightLogic";
122  }
124 
125 
126 
129 
134  int getCurrentPhaseIndex() const;
135 
136 
141  const MSPhaseDefinition& getCurrentPhaseDef() const;
143 
144 
145 
148 
153  SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const;
154 
155 
161  SUMOTime getOffsetFromIndex(int index) const;
162 
163 
169  int getIndexFromOffset(SUMOTime offset) const;
171 
172 
173 
176 
184  void changeStepAndDuration(MSTLLogicControl& tlcontrol, SUMOTime simStep,
185  int step, SUMOTime stepDuration);
186 
189  void setPhases(const Phases& phases, int index);
191 
192 
193 protected:
196 
198  int myStep;
199 
200 
201 private:
203  void deletePhases();
204 
205 };
206 
207 
208 #endif
209 
210 /****************************************************************************/
211 
long long int SUMOTime
Definition: SUMOTime.h:36
MSSimpleTrafficLightLogic(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.
void setPhases(const Phases &phases, int index)
Replaces the phases and set the phase index.
void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)
Changes the current phase and her duration.
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.
SUMOTime getOffsetFromIndex(int index) const
Returns the position (start of a phase during a cycle) from of a given step.
SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const
Returns the index of the logic at the given simulation step.
const std::string getLogicType() const
Returns the type of the logic as a string.
The simulated network and simulation perfomer.
Definition: MSNet.h:85
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
A fixed traffic light logic.
A class that stores and controls tls and switching of their programs.
int getCurrentPhaseIndex() const
Returns the current index within the program.
virtual SUMOTime trySwitch()
Switches to the next phase.
void deletePhases()
frees memory responsibilities
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
int getPhaseNumber() const
Returns the number of phases.
The parent class for traffic light logics.
const Phases & getPhases() const
Returns the phases of this tls program.
The definition of a single phase of a tls logic.
const MSPhaseDefinition & getPhase(int givenstep) const
Returns the definition of the phase from the given position within the plan.