SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NBLoadedSUMOTLDef.h
Go to the documentation of this file.
1 /****************************************************************************/
7 // A complete traffic light logic loaded from a sumo-net. (opted to reimplement
8 // since NBLoadedTLDef is quite vissim specific)
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
11 // Copyright (C) 2001-2014 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 NBLoadedSUMOTLDef_h
22 #define NBLoadedSUMOTLDef_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 <set>
37 #include "NBNode.h"
38 #include "NBEdgeCont.h"
40 #include "NBTrafficLightLogic.h"
41 #include <utils/common/SUMOTime.h>
42 
43 
44 // ===========================================================================
45 // class definitions
46 // ===========================================================================
52 public:
53 
60  NBLoadedSUMOTLDef(const std::string& id, const std::string& programID, SUMOTime offset, TrafficLightType type);
61 
67 
68 
71 
75  void setTLControllingInformation(const NBEdgeCont& ec) const;
76 
82  void remapRemoved(NBEdge* removed,
83  const EdgeVector& incoming, const EdgeVector& outgoing);
84 
85 
92  void replaceRemoved(NBEdge* removed, int removedLane,
93  NBEdge* by, int byLane);
94 
100  void addPhase(SUMOTime duration, const std::string& state);
101 
102 
105  void addConnection(NBEdge* from, NBEdge* to, int fromLane, int toLane, int linkIndex);
106 
107 
112  void removeConnection(const NBConnection& conn, bool reconstruct = true);
113 
117  return myTLLogic;
118  }
119 
123  void setOffset(SUMOTime offset);
124 
125 protected:
129  void collectLinks();
130 
131 
138  unsigned int brakingTime);
139 
140  bool amInvalid() const;
141 
142 private:
143 
146 
148  std::set<NBNode*> myOriginalNodes;
149 
151  void setTLControllingInformation() const;
152 
153 private:
156  public:
159 
160  bool operator()(const NBConnection& c) const {
161  return c.getFrom() == myC.getFrom() && c.getTo() == myC.getTo() &&
162  c.getFromLane() == myC.getFromLane() && c.getToLane() == myC.getToLane();
163  }
164  private:
166  private:
169 
170  };
171 
172 };
173 
174 
175 #endif
176 
177 /****************************************************************************/
178 
void removeConnection(const NBConnection &conn, bool reconstruct=true)
removes the given connection from the traffic light if recontruct=true, reconstructs the logic and in...
NBLoadedSUMOTLDef(const std::string &id, const std::string &programID, SUMOTime offset, TrafficLightType type)
Constructor.
void setOffset(SUMOTime offset)
Sets the offset of this tls.
A loaded (complete) traffic light logic.
A SUMO-compliant built logic for a traffic light.
The representation of a single edge during network building.
Definition: NBEdge.h:71
class for identifying connections
int getFromLane() const
returns the from-lane
The base class for traffic light logic definitions.
bool operator()(const NBConnection &c) const
NBEdge * getFrom() const
returns the from-edge (start of the connection)
void replaceRemoved(NBEdge *removed, int removedLane, NBEdge *by, int byLane)
Replaces a removed edge/lane.
connection_equal(const NBConnection &c)
constructor
std::set< NBNode * > myOriginalNodes
The original nodes for which the loaded logic is valid.
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:66
NBTrafficLightLogic * getLogic()
Returns the internal logic.
NBTrafficLightLogic * myCompute(const NBEdgeCont &ec, unsigned int brakingTime)
Computes the traffic light logic finally in dependence to the type.
void remapRemoved(NBEdge *removed, const EdgeVector &incoming, const EdgeVector &outgoing)
Replaces occurences of the removed edge in incoming/outgoing edges of all definitions.
void setTLControllingInformation() const
Informs edges about being controlled by a tls.
void addPhase(SUMOTime duration, const std::string &state)
Adds a phase to the logic the new phase is inserted at the end of the list of already added phases...
std::vector< NBEdge * > EdgeVector
Definition: NBCont.h:38
int getToLane() const
returns the to-lane
void collectLinks()
Collects the links participating in this traffic light (only if not previously loaded) ...
int SUMOTime
Definition: SUMOTime.h:43
NBEdge * getTo() const
returns the to-edge (end of the connection)
~NBLoadedSUMOTLDef()
Destructor.
connection_equal & operator=(const connection_equal &s)
invalidated assignment operator
NBTrafficLightLogic * myTLLogic
phases are added directly to myTLLogic which is then returned in myCompute()
void addConnection(NBEdge *from, NBEdge *to, int fromLane, int toLane, int linkIndex)
Adds a connection and immediately informs the edges.
TrafficLightType