SUMO - Simulation of Urban MObility
MSOffTrafficLightLogic.cpp
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-2017 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 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 #include <utility>
32 #include <vector>
33 #include <bitset>
34 #include <sstream>
36 #include "MSTrafficLightLogic.h"
37 #include "MSOffTrafficLightLogic.h"
38 
39 
40 // ===========================================================================
41 // member method definitions
42 // ===========================================================================
44  const std::string& id) :
45  MSTrafficLightLogic(tlcontrol, id, "off", 0, std::map<std::string, std::string>()) {
47 }
48 
49 
51  for (MSTrafficLightLogic::Phases::const_iterator i = myPhaseDefinition.begin(); i != myPhaseDefinition.end(); ++i) {
52  delete *i;
53  }
54 }
55 
56 
57 void
59  rebuildPhase();
60 }
61 
62 
63 // ----------- Handling of controlled links
64 void
67  rebuildPhase();
68 }
69 
70 
71 void
73  int no = (int)getLinks().size();
74  std::string state;
75  for (int i = 0; i < no; ++i) {
76  // !!! no brake mask!
77  state += 'o';
78  }
79  for (MSTrafficLightLogic::Phases::const_iterator i = myPhaseDefinition.begin(); i != myPhaseDefinition.end(); ++i) {
80  delete *i;
81  }
82  myPhaseDefinition.clear();
83  myPhaseDefinition.push_back(new MSPhaseDefinition(TIME2STEPS(120), state));
84 }
85 
86 
87 // ------------ Static Information Retrieval
88 int
90  return 0;
91 }
92 
93 
96  return myPhaseDefinition;
97 }
98 
99 
100 const MSPhaseDefinition&
102  return *myPhaseDefinition[0];
103 }
104 
105 
106 // ------------ Dynamic Information Retrieval
107 int
109  return 0;
110 }
111 
112 
113 const MSPhaseDefinition&
115  return *myPhaseDefinition[0];
116 }
117 
118 
119 // ------------ Conversion between time and phase
120 SUMOTime
122  return 0;
123 }
124 
125 
126 SUMOTime
128  return 0;
129 }
130 
131 
132 int
134  return 0;
135 }
136 
137 
138 
139 /****************************************************************************/
140 
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:52
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.