SUMO - Simulation of Urban MObility
MSSimpleTrafficLightLogic.h
Go to the documentation of this file.
1 /****************************************************************************/
11 // A fixed traffic light logic
12 /****************************************************************************/
13 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
14 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
15 /****************************************************************************/
16 //
17 // This file is part of SUMO.
18 // SUMO is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 /****************************************************************************/
24 #ifndef MSSimpleTrafficLightLogic_h
25 #define MSSimpleTrafficLightLogic_h
26 
27 
28 // ===========================================================================
29 // included modules
30 // ===========================================================================
31 #ifdef _MSC_VER
32 #include <windows_config.h>
33 #else
34 #include <config.h>
35 #endif
36 
37 #include <utility>
38 #include <vector>
39 #include <bitset>
41 #include <microsim/MSNet.h>
42 #include "MSTrafficLightLogic.h"
43 #include "MSPhaseDefinition.h"
44 
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
60 public:
70  const std::string& id, const std::string& subid,
71  const Phases& phases, unsigned int step, SUMOTime delay,
72  const std::map<std::string, std::string>& parameters);
73 
74 
77 
78 
79 
82 
89 
90 
91 
94 
99  unsigned int getPhaseNumber() const;
100 
101 
106  const Phases& getPhases() const;
107 
108 
113  Phases& getPhases();
114 
115 
121  const MSPhaseDefinition& getPhase(unsigned int givenstep) const;
122 
126  const std::string getLogicType() const {
127  return "simpleTrafficLightLogic";
128  }
130 
131 
132 
135 
140  unsigned int getCurrentPhaseIndex() const;
141 
142 
147  const MSPhaseDefinition& getCurrentPhaseDef() const;
149 
150 
151 
154 
159  SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const;
160 
161 
167  SUMOTime getOffsetFromIndex(unsigned int index) const;
168 
169 
175  unsigned int getIndexFromOffset(SUMOTime offset) const;
177 
178 
179 
182 
190  void changeStepAndDuration(MSTLLogicControl& tlcontrol, SUMOTime simStep,
191  unsigned int step, SUMOTime stepDuration);
192 
195  void setPhases(const Phases& phases, unsigned int index);
197 
198 
199 protected:
202 
204  unsigned int myStep;
205 
206 
207 private:
209  void deletePhases();
210 
211 };
212 
213 
214 #endif
215 
216 /****************************************************************************/
217 
void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, unsigned int step, SUMOTime stepDuration)
Changes the current phase and her duration.
unsigned int getPhaseNumber() const
Returns the number of phases.
unsigned int getIndexFromOffset(SUMOTime offset) const
Returns the step (the phasenumber) of a given position of the cycle.
unsigned int myStep
The current step.
const Phases & getPhases() const
Returns the phases of this tls program.
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.
A fixed traffic light logic.
A class that stores and controls tls and switching of their programs.
SUMOTime trySwitch()
Switches to the next phase.
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
const MSPhaseDefinition & getPhase(unsigned int givenstep) const
Returns the definition of the phase from the given position within the plan.
void deletePhases()
frees memory responsibilities
MSSimpleTrafficLightLogic(MSTLLogicControl &tlcontrol, const std::string &id, const std::string &subid, const Phases &phases, unsigned int step, SUMOTime delay, const std::map< std::string, std::string > &parameters)
Constructor.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
unsigned int getCurrentPhaseIndex() const
Returns the current index within the program.
int SUMOTime
Definition: SUMOTime.h:43
The parent class for traffic light logics.
void setPhases(const Phases &phases, unsigned int index)
Replaces the phases and set the phase index.
SUMOTime getOffsetFromIndex(unsigned int index) const
Returns the position (start of a phase during a cycle) from of a given step.
The definition of a single phase of a tls logic.
const std::string getLogicType() const
Returns the type of the logic as a string.