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-2017 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>
40 #include "MSTrafficLightLogic.h"
41 
42 
43 // ===========================================================================
44 // class declarations
45 // ===========================================================================
46 class MSNet;
47 
48 
49 // ===========================================================================
50 // class definitions
51 // ===========================================================================
63 public:
73  const std::string& id, const std::string& subid,
74  const Phases& phases, int step, SUMOTime delay,
75  const std::map<std::string, std::string>& parameters);
76 
77 
80 
83 
88  virtual SUMOTime trySwitch();
90 
91 
92 
95 
100  int getPhaseNumber() const;
101 
102 
107  const Phases& getPhases() const;
108 
109 
114  Phases& getPhases();
115 
116 
122  const MSPhaseDefinition& getPhase(int givenstep) const;
123 
127  const std::string getLogicType() const {
128  return "simpleTrafficLightLogic";
129  }
131 
132 
133 
136 
141  int getCurrentPhaseIndex() const;
142 
143 
148  const MSPhaseDefinition& getCurrentPhaseDef() const;
150 
151 
152 
155 
160  SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const;
161 
162 
168  SUMOTime getOffsetFromIndex(int index) const;
169 
170 
176  int getIndexFromOffset(SUMOTime offset) const;
178 
179 
180 
183 
191  void changeStepAndDuration(MSTLLogicControl& tlcontrol, SUMOTime simStep,
192  int step, SUMOTime stepDuration);
193 
196  void setPhases(const Phases& phases, int index);
198 
199 
200 protected:
203 
205  int myStep;
206 
207 
208 private:
210  void deletePhases();
211 
212 };
213 
214 
215 #endif
216 
217 /****************************************************************************/
218 
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:94
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.
long long int SUMOTime
Definition: TraCIDefs.h:52
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.