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-2015 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>
39 #include <microsim/MSNet.h>
40 #include <utils/common/StdDefs.h>
41 #include "MSTrafficLightLogic.h"
42 #include "MSPhaseDefinition.h"
43 #include "MSTLLogicControl.h"
44 
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
54 public:
61  const std::string& id);
62 
63 
68  virtual void init(NLDetectorBuilder& nb);
69 
70 
73 
74 
77 
84 
85 
86 
89 
95  return 120 * DELTA_T;
96  }
97 
99 
100 
103 
108  unsigned int getPhaseNumber() const;
109 
110 
115  const Phases& getPhases() const;
116 
117 
123  const MSPhaseDefinition& getPhase(unsigned int givenstep) const;
124 
128  const std::string getLogicType() const {
129  return "offTrafficLightLogic";
130  }
132 
133 
134 
137 
142  unsigned int getCurrentPhaseIndex() const;
143 
144 
149  const MSPhaseDefinition& getCurrentPhaseDef() const;
151 
152 
153 
156 
161  SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const;
162 
163 
169  SUMOTime getOffsetFromIndex(unsigned int index) const;
170 
171 
177  unsigned int getIndexFromOffset(SUMOTime offset) const;
179 
180 
181 
184 
192  void changeStepAndDuration(MSTLLogicControl& tlcontrol, SUMOTime simStep, unsigned int step, SUMOTime stepDuration) {
193  UNUSED_PARAMETER(tlcontrol);
194  UNUSED_PARAMETER(simStep);
195  UNUSED_PARAMETER(step);
196  UNUSED_PARAMETER(stepDuration);
197  }
199 
200 
201 private:
204  void rebuildPhase();
205 
206 
207 private:
210 
211 
212 };
213 
214 
215 #endif
216 
217 /****************************************************************************/
218 
MSTrafficLightLogic::Phases myPhaseDefinition
The phase definition (only one)
Builds detectors for microsim.
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.
#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.
unsigned int getCurrentPhaseIndex() const
Returns the current index within the program.
int SUMOTime
Definition: SUMOTime.h:43
const Phases & getPhases() const
Returns the phases of this tls program.
The parent class for traffic light logics.
#define DELTA_T
Definition: SUMOTime.h:50
unsigned int getPhaseNumber() const
Returns the number of phases.
const MSPhaseDefinition & getPhase(unsigned int givenstep) const
Returns the definition of the phase from the given position within the plan.
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.