SUMO - Simulation of Urban MObility
MSOffTrafficLightLogic.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // A traffic lights logic which represents a tls in an off-mode
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef MSOffTrafficLightLogic_h
23 #define MSOffTrafficLightLogic_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <utility>
36 #include <vector>
37 #include <bitset>
38 #include <utils/common/StdDefs.h>
39 #include "MSTLLogicControl.h"
40 #include "MSTrafficLightLogic.h"
41 
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
51 public:
58  const std::string& id);
59 
60 
65  virtual void init(NLDetectorBuilder& nb);
66 
67 
70 
71 
74 
81 
82 
83 
86 
92  return 120 * DELTA_T;
93  }
94 
96 
97 
100 
105  int getPhaseNumber() const;
106 
107 
112  const Phases& getPhases() const;
113 
114 
120  const MSPhaseDefinition& getPhase(int givenstep) const;
121 
125  const std::string getLogicType() const {
126  return "offTrafficLightLogic";
127  }
129 
130 
131 
134 
139  int getCurrentPhaseIndex() const;
140 
141 
146  const MSPhaseDefinition& getCurrentPhaseDef() const;
148 
149 
150 
153 
158  SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const;
159 
160 
166  SUMOTime getOffsetFromIndex(unsigned int index) const;
167 
168 
174  unsigned int getIndexFromOffset(SUMOTime offset) const;
176 
177 
178 
181 
189  void changeStepAndDuration(MSTLLogicControl& tlcontrol, SUMOTime simStep, unsigned int step, SUMOTime stepDuration) {
190  UNUSED_PARAMETER(tlcontrol);
191  UNUSED_PARAMETER(simStep);
192  UNUSED_PARAMETER(step);
193  UNUSED_PARAMETER(stepDuration);
194  }
196 
197 
198 private:
201  void rebuildPhase();
202 
203 
204 private:
207 
208 
209 };
210 
211 
212 #endif
213 
214 /****************************************************************************/
215 
MSTrafficLightLogic::Phases myPhaseDefinition
The phase definition (only one)
Builds detectors for microsim.
long long int SUMOTime
Definition: SUMOTime.h:43
virtual void init(NLDetectorBuilder &nb)
Initialises the tls with information about incoming lanes.
void adaptLinkInformationFrom(const MSTrafficLightLogic &logic)
Applies information about controlled links and lanes from the given logic.
void rebuildPhase()
(Re)builds the internal phase definition
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
SUMOTime DELTA_T
Definition: SUMOTime.cpp:39
int getPhaseNumber() const
Returns the number of phases.
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:39
A traffic lights logic which represents a tls in an off-mode.
SUMOTime getOffsetFromIndex(unsigned int index) const
Returns the position (start of a phase during a cycle) from of a given step.
A class that stores and controls tls and switching of their programs.
MSOffTrafficLightLogic(MSTLLogicControl &tlcontrol, const std::string &id)
Constructor.
void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, unsigned int step, SUMOTime stepDuration)
Changes the current phase and her duration.
SUMOTime trySwitch()
Switches to the next phase.
const std::string getLogicType() const
Returns the type of the logic as a string.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const
Returns the index of the logic at the given simulation step.
const MSPhaseDefinition & getPhase(int givenstep) const
Returns the definition of the phase from the given position within the plan.
int getCurrentPhaseIndex() const
Returns the current index within the program.
const Phases & getPhases() const
Returns the phases of this tls program.
The parent class for traffic light logics.
The definition of a single phase of a tls logic.
unsigned int getIndexFromOffset(SUMOTime offset) const
Returns the step (the phasenumber) of a given position of the cycle.