SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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-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 // ===========================================================================
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 #ifdef CHECK_MEMORY_LEAKS
40 #include <foreign/nvwa/debug_new.h>
41 #endif // CHECK_MEMORY_LEAKS
42 
43 
44 // ===========================================================================
45 // member method definitions
46 // ===========================================================================
48  const std::string& id) :
49  MSTrafficLightLogic(tlcontrol, id, "off", 0, std::map<std::string, std::string>()) {
51 }
52 
53 
55  for (MSTrafficLightLogic::Phases::const_iterator i = myPhaseDefinition.begin(); i != myPhaseDefinition.end(); ++i) {
56  delete *i;
57  }
58 }
59 
60 
61 void
63  rebuildPhase();
64 }
65 
66 
67 // ----------- Handling of controlled links
68 void
71  rebuildPhase();
72 }
73 
74 
75 void
77  int no = (int)getLinks().size();
78  std::string state;
79  for (int i = 0; i < no; ++i) {
80  // !!! no brake mask!
81  state += 'o';
82  }
83  for (MSTrafficLightLogic::Phases::const_iterator i = myPhaseDefinition.begin(); i != myPhaseDefinition.end(); ++i) {
84  delete *i;
85  }
86  myPhaseDefinition.clear();
87  myPhaseDefinition.push_back(new MSPhaseDefinition(TIME2STEPS(120), state));
88 }
89 
90 
91 // ------------ Static Information Retrieval
92 int
94  return 0;
95 }
96 
97 
100  return myPhaseDefinition;
101 }
102 
103 
104 const MSPhaseDefinition&
106  return *myPhaseDefinition[0];
107 }
108 
109 
110 // ------------ Dynamic Information Retrieval
111 int
113  return 0;
114 }
115 
116 
117 const MSPhaseDefinition&
119  return *myPhaseDefinition[0];
120 }
121 
122 
123 // ------------ Conversion between time and phase
124 SUMOTime
126  return 0;
127 }
128 
129 
130 SUMOTime
132  return 0;
133 }
134 
135 
136 int
138  return 0;
139 }
140 
141 
142 
143 /****************************************************************************/
144 
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.
SUMOTime getOffsetFromIndex(int index) const
Returns the position (start of a phase during a cycle) from of a given step.
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.
int getPhaseNumber() const
Returns the number of phases.
#define TIME2STEPS(x)
Definition: SUMOTime.h:66
A class that stores and controls tls and switching of their programs.
MSOffTrafficLightLogic(MSTLLogicControl &tlcontrol, const std::string &id)
Constructor.
SUMOTime myDefaultCycleTime
The cycle time (without changes)
const LinkVectorVector & getLinks() const
Returns the list of lists of all affected links.
virtual void adaptLinkInformationFrom(const MSTrafficLightLogic &logic)
Applies information about controlled links and lanes from the given logic.
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.
int getIndexFromOffset(SUMOTime offset) const
Returns the step (the phasenumber) of a given position of the cycle.
The definition of a single phase of a tls logic.