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-sim.org/
12 // Copyright (C) 2001-2014 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  SUMOTime trySwitch(bool isActive) {
96  UNUSED_PARAMETER(isActive);
97  return 120 * DELTA_T;
98  }
99 
101 
102 
105 
110  unsigned int getPhaseNumber() const;
111 
112 
117  const Phases& getPhases() const;
118 
119 
125  const MSPhaseDefinition& getPhase(unsigned int givenstep) const;
127 
128 
129 
132 
137  unsigned int getCurrentPhaseIndex() const;
138 
139 
144  const MSPhaseDefinition& getCurrentPhaseDef() const;
146 
147 
148 
151 
156  SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const;
157 
158 
164  SUMOTime getOffsetFromIndex(unsigned int index) const;
165 
166 
172  unsigned int getIndexFromOffset(SUMOTime offset) const;
174 
175 
176 
179 
187  void changeStepAndDuration(MSTLLogicControl& tlcontrol, SUMOTime simStep, unsigned int step, SUMOTime stepDuration) {
188  UNUSED_PARAMETER(tlcontrol);
189  UNUSED_PARAMETER(simStep);
190  UNUSED_PARAMETER(step);
191  UNUSED_PARAMETER(stepDuration);
192  }
194 
195 
196 private:
199  void rebuildPhase();
200 
201 
202 private:
205 
206 
207 };
208 
209 
210 #endif
211 
212 /****************************************************************************/
213 
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.
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.
SUMOTime trySwitch(bool isActive)
Switches to the next phase.
#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.