SUMO - Simulation of Urban MObility
MSOffTrafficLightLogic.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // A traffic lights logic which represents a tls in an off-mode
20 /****************************************************************************/
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #ifdef _MSC_VER
25 #include <windows_config.h>
26 #else
27 #include <config.h>
28 #endif
29 
30 #include <utility>
31 #include <vector>
32 #include <bitset>
33 #include <sstream>
35 #include "MSTrafficLightLogic.h"
36 #include "MSOffTrafficLightLogic.h"
37 
38 
39 // ===========================================================================
40 // member method definitions
41 // ===========================================================================
43  const std::string& id) :
44  MSTrafficLightLogic(tlcontrol, id, "off", 0, std::map<std::string, std::string>()) {
46 }
47 
48 
50  for (MSTrafficLightLogic::Phases::const_iterator i = myPhaseDefinition.begin(); i != myPhaseDefinition.end(); ++i) {
51  delete *i;
52  }
53 }
54 
55 
56 void
58  rebuildPhase();
59 }
60 
61 
62 // ----------- Handling of controlled links
63 void
66  rebuildPhase();
67 }
68 
69 
70 void
72  int no = (int)getLinks().size();
73  std::string state;
74  for (int i = 0; i < no; ++i) {
75  // !!! no brake mask!
76  state += 'o';
77  }
78  for (MSTrafficLightLogic::Phases::const_iterator i = myPhaseDefinition.begin(); i != myPhaseDefinition.end(); ++i) {
79  delete *i;
80  }
81  myPhaseDefinition.clear();
82  myPhaseDefinition.push_back(new MSPhaseDefinition(TIME2STEPS(120), state));
83 }
84 
85 
86 // ------------ Static Information Retrieval
87 int
89  return 0;
90 }
91 
92 
95  return myPhaseDefinition;
96 }
97 
98 
99 const MSPhaseDefinition&
101  return *myPhaseDefinition[0];
102 }
103 
104 
105 // ------------ Dynamic Information Retrieval
106 int
108  return 0;
109 }
110 
111 
112 const MSPhaseDefinition&
114  return *myPhaseDefinition[0];
115 }
116 
117 
118 // ------------ Conversion between time and phase
119 SUMOTime
121  return 0;
122 }
123 
124 
125 SUMOTime
127  return 0;
128 }
129 
130 
131 int
133  return 0;
134 }
135 
136 
137 
138 /****************************************************************************/
139 
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
int getIndexFromOffset(SUMOTime offset) const
Returns the step (the phasenumber) of a given position of the cycle.
#define TIME2STEPS(x)
Definition: SUMOTime.h:66
const LinkVectorVector & getLinks() const
Returns the list of lists of all affected links.
A class that stores and controls tls and switching of their programs.
int getPhaseNumber() const
Returns the number of phases.
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
MSOffTrafficLightLogic(MSTLLogicControl &tlcontrol, const std::string &id)
Constructor.
SUMOTime myDefaultCycleTime
The cycle time (without changes)
SUMOTime getOffsetFromIndex(int index) const
Returns the position (start of a phase during a cycle) from of a given step.
virtual void adaptLinkInformationFrom(const MSTrafficLightLogic &logic)
Applies information about controlled links and lanes from the given logic.
const MSPhaseDefinition & getPhase(int givenstep) const
Returns the definition of the phase from the given position within the plan.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
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.
long long int SUMOTime
Definition: TraCIDefs.h:51
The definition of a single phase of a tls logic.
SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const
Returns the index of the logic at the given simulation step.