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 
101  NBTrafficLightDefinition(const std::string& id,
102  const std::vector<NBNode*>& junctions,
103  const std::string& programID,
104  SUMOTime offset);
105 
106 
113  NBTrafficLightDefinition(const std::string& id,
114  NBNode* junction,
115  const std::string& programID,
116  SUMOTime offset);
117 
118 
124  NBTrafficLightDefinition(const std::string& id, const std::string& programID, SUMOTime offset);
125 
126 
128  virtual ~NBTrafficLightDefinition();
129 
130 
141 
142 
143 
146 
150  virtual void addNode(NBNode* node);
151 
152 
156  virtual void removeNode(NBNode* node);
157 
158 
162  const std::vector<NBNode*>& getNodes() const {
163  return myControlledNodes;
164  }
166 
167 
178  bool mustBrake(const NBEdge* const from, const NBEdge* const to) const;
179 
180 
188  bool mustBrake(const NBConnection& possProhibited,
189  const NBConnection& possProhibitor,
190  bool regardNonSignalisedLowerPriority) const;
191 
201  bool mustBrake(const NBEdge* const possProhibitedFrom, const NBEdge* const possProhibitedTo,
202  const NBEdge* const possProhibitorFrom, const NBEdge* const possProhibitorTo,
203  bool regardNonSignalisedLowerPriority) const;
204 
205 
215  bool forbids(const NBEdge* const possProhibitorFrom, const NBEdge* const possProhibitorTo,
216  const NBEdge* const possProhibitedFrom, const NBEdge* const possProhibitedTo,
217  bool regardNonSignalisedLowerPriority) const;
218 
219 
227  bool foes(const NBEdge* const from1, const NBEdge* const to1,
228  const NBEdge* const from2, const NBEdge* const to2) const;
229 
230 
234  virtual void setTLControllingInformation(const NBEdgeCont& ec) const = 0;
235 
236 
239  virtual void setParticipantsInformation();
240 
241 
245  void addControlledInnerEdges(const std::vector<std::string>& edges);
246 
247 
253  virtual void remapRemoved(NBEdge* removed,
254  const EdgeVector& incoming, const EdgeVector& outgoing) = 0;
255 
256 
263  virtual void replaceRemoved(NBEdge* removed, int removedLane,
264  NBEdge* by, int byLane) = 0;
265 
266 
272  bool isLeftMover(const NBEdge* const from, const NBEdge* const to) const;
273 
274 
278  const EdgeVector& getIncomingEdges() const;
279 
280 
283  return myControlledLinks;
284  }
285 
286 
287  // @breif returns the controlled nodes
288  const std::vector<NBNode*>& getControlledNodes() const {
289  return myControlledNodes;
290  }
291 
292 
296  const std::string& getProgramID() const {
297  return mySubID;
298  };
299 
300 
304  void setProgramID(const std::string& programID) {
305  mySubID = programID;
306  }
307 
308 
313  return myOffset;
314  }
315 
316 
317 protected:
323  virtual NBTrafficLightLogic* myCompute(const NBEdgeCont& ec,
324  unsigned int brakingTime) = 0;
325 
326 
330  virtual void collectLinks() = 0;
331 
332 
335  void collectEdges();
336 
337 
343  unsigned int computeBrakingTime(SUMOReal minDecel) const;
344 
345 
346  // @return whether this traffic light is invalid and should be computed
347  virtual bool amInvalid() const;
348 
349 
350 protected:
352  std::vector<NBNode*> myControlledNodes;
353 
356 
359 
362 
364  std::set<std::string> myControlledInnerEdges;
365 
367  std::string mySubID;
368 
371 
372 };
373 
374 
375 #endif
376 
377 /****************************************************************************/
378