SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NBTrafficLightDefinition.h
Go to the documentation of this file.
1 /****************************************************************************/
8 // The base class for traffic light logic definitions
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
11 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 #ifndef NBTrafficLightDefinition_h
22 #define NBTrafficLightDefinition_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <vector>
35 #include <string>
36 #include <bitset>
37 #include <utility>
38 #include <set>
39 #include <utils/common/Named.h>
41 #include <utils/common/SUMOTime.h>
43 #include "NBCont.h"
44 #include "NBConnection.h"
45 #include "NBConnectionDefs.h"
47 
48 
49 // ===========================================================================
50 // class declarations
51 // ===========================================================================
52 class NBNode;
53 class OptionsCont;
55 
56 
57 // ===========================================================================
58 // class definitions
59 // ===========================================================================
73 public:
74 
75  static const std::string DefaultProgramID;
76 
81  enum TLColor {
92  };
93 
94 
99  NBTrafficLightDefinition(const std::string& id,
100  const std::vector<NBNode*> &junctions,
101  const std::string& programID) ;
102 
103 
108  NBTrafficLightDefinition(const std::string& id,
109  NBNode* junction,
110  const std::string& programID) ;
111 
112 
116  NBTrafficLightDefinition(const std::string& id, const std::string& programID) ;
117 
118 
120  virtual ~NBTrafficLightDefinition() ;
121 
122 
133 
134 
135 
138 
142  virtual void addNode(NBNode* node);
143 
144 
148  virtual void removeNode(NBNode* node);
149 
150 
154  const std::vector<NBNode*> &getNodes() const {
155  return myControlledNodes;
156  }
158 
159 
170  bool mustBrake(const NBEdge* const from, const NBEdge* const to) const ;
171 
172 
180  bool mustBrake(const NBConnection& possProhibited,
181  const NBConnection& possProhibitor,
182  bool regardNonSignalisedLowerPriority) const ;
183 
193  bool mustBrake(const NBEdge* const possProhibitedFrom, const NBEdge* const possProhibitedTo,
194  const NBEdge* const possProhibitorFrom, const NBEdge* const possProhibitorTo,
195  bool regardNonSignalisedLowerPriority) const ;
196 
197 
207  bool forbids(const NBEdge* const possProhibitorFrom, const NBEdge* const possProhibitorTo,
208  const NBEdge* const possProhibitedFrom, const NBEdge* const possProhibitedTo,
209  bool regardNonSignalisedLowerPriority) const ;
210 
211 
219  bool foes(const NBEdge* const from1, const NBEdge* const to1,
220  const NBEdge* const from2, const NBEdge* const to2) const ;
221 
222 
226  virtual void setTLControllingInformation(const NBEdgeCont& ec) const = 0;
227 
228 
231  virtual void setParticipantsInformation() ;
232 
233 
237  void addControlledInnerEdges(const std::vector<std::string> &edges) ;
238 
239 
245  virtual void remapRemoved(NBEdge* removed,
246  const EdgeVector& incoming, const EdgeVector& outgoing) = 0;
247 
248 
255  virtual void replaceRemoved(NBEdge* removed, int removedLane,
256  NBEdge* by, int byLane) = 0;
257 
258 
264  bool isLeftMover(const NBEdge* const from, const NBEdge* const to) const ;
265 
266 
270  const EdgeVector& getIncomingEdges() const ;
271 
272 
275  return myControlledLinks;
276  }
277 
278 
279  // @breif returns the controlled nodes
280  const std::vector<NBNode*>& getControlledNodes() const {
281  return myControlledNodes;
282  }
283 
284 
288  const std::string& getProgramID() const {
289  return mySubID;
290  };
291 
292 
293  void setProgramID(const std::string& programID) {
294  mySubID = programID;
295  }
296 
297 
298 protected:
304  virtual NBTrafficLightLogic* myCompute(const NBEdgeCont& ec,
305  unsigned int brakingTime) = 0;
306 
307 
311  virtual void collectLinks() = 0;
312 
313 
316  void collectEdges() ;
317 
318 
324  unsigned int computeBrakingTime(SUMOReal minDecel) const ;
325 
326 
327  // @return whether this traffic light is invalid and should be computed
328  virtual bool amInvalid() const;
329 
330 
331 protected:
333  std::vector<NBNode*> myControlledNodes;
334 
337 
340 
343 
345  std::set<std::string> myControlledInnerEdges;
346 
348  std::string mySubID;
349 
350 };
351 
352 
353 #endif
354 
355 /****************************************************************************/
356