46 #ifdef CHECK_MEMORY_LEAKS
48 #endif // CHECK_MEMORY_LEAKS
59 const std::vector<NBNode*>& junctions,
const std::string& programID,
62 myControlledNodes(junctions),
63 mySubID(programID), myOffset(offset),
77 for (std::vector<NBNode*>::const_iterator i = junctions.begin(); i != junctions.end(); i++) {
78 (*i)->addTrafficLight(
this);
111 for (std::vector<NBNode*>::iterator it = nodes.begin(); it != nodes.end(); it++) {
112 (*it)->removeTrafficLight(
this);
114 WRITE_WARNING(
"The traffic light '" +
getID() +
"' does not control any links; it will not be build.");
121 if (oc.
isSet(
"tls.yellow.time")) {
122 brakingTime = oc.
getInt(
"tls.yellow.time");
137 return (
unsigned int)(vmax / minDecel);
155 const EdgeVector& incoming = (*i)->getIncomingEdges();
156 copy(incoming.begin(), incoming.end(), back_inserter(
myIncomingEdges));
157 const EdgeVector& outgoing = (*i)->getOutgoingEdges();
158 copy(outgoing.begin(), outgoing.end(), back_inserter(myOutgoing));
166 EdgeVector::iterator k = find(myOutgoing.begin(), myOutgoing.end(), edge);
167 if (k != myOutgoing.end()) {
170 (*j)->setIsInnerEdge();
187 std::vector<NBNode*>::const_iterator i =
198 std::vector<NBNode*>::const_iterator i =
203 if (!node->hasOutgoing(to)) {
212 const NBEdge*
const possProhibitedTo,
213 const NBEdge*
const possProhibitorFrom,
214 const NBEdge*
const possProhibitorTo,
215 bool regardNonSignalisedLowerPriority)
const {
216 return forbids(possProhibitorFrom, possProhibitorTo,
217 possProhibitedFrom, possProhibitedTo,
218 regardNonSignalisedLowerPriority);
225 bool regardNonSignalisedLowerPriority)
const {
228 regardNonSignalisedLowerPriority);
234 const NBEdge*
const possProhibitorTo,
235 const NBEdge*
const possProhibitedFrom,
236 const NBEdge*
const possProhibitedTo,
237 bool regardNonSignalisedLowerPriority)
const {
238 if (possProhibitorFrom == 0 || possProhibitorTo == 0 || possProhibitedFrom == 0 || possProhibitedTo == 0) {
242 std::vector<NBNode*>::const_iterator incoming =
244 std::vector<NBNode*>::const_iterator outgoing =
247 NBNode* incnode = *incoming;
248 NBNode* outnode = *outgoing;
249 EdgeVector::const_iterator i;
250 if (incnode != outnode) {
255 for (i = ev1.begin(); i != ev1.end(); ++i) {
256 std::vector<NBNode*>::const_iterator outgoing2 =
261 NBNode* outnode2 = *outgoing2;
262 if (incnode != outnode2) {
265 bool ret1 = incnode->
foes(possProhibitorTo, *i,
266 possProhibitedFrom, possProhibitedTo);
267 bool ret2 = incnode->forbids(possProhibitorFrom, possProhibitorTo,
268 possProhibitedTo, *i,
269 regardNonSignalisedLowerPriority);
270 bool ret = ret1 || ret2;
279 for (i = ev2.begin(); i != ev2.end(); ++i) {
280 std::vector<NBNode*>::const_iterator incoming2 =
285 NBNode* incnode2 = *incoming2;
286 if (incnode2 != outnode) {
289 bool ret1 = incnode2->
foes(possProhibitorTo, *i,
290 possProhibitedFrom, possProhibitedTo);
291 bool ret2 = incnode2->
forbids(possProhibitorTo, *i,
292 possProhibitedFrom, possProhibitedTo,
293 regardNonSignalisedLowerPriority);
294 bool ret = ret1 || ret2;
303 return incnode->forbids(possProhibitorFrom, possProhibitorTo,
304 possProhibitedFrom, possProhibitedTo,
305 regardNonSignalisedLowerPriority);
311 const NBEdge*
const from2,
const NBEdge*
const to2)
const {
312 if (to1 == 0 || to2 == 0) {
316 std::vector<NBNode*>::const_iterator incoming =
319 std::vector<NBNode*>::const_iterator outgoing =
323 NBNode* incnode = *incoming;
324 NBNode* outnode = *outgoing;
325 if (incnode != outnode) {
328 return incnode->
foes(from1, to1, from2, to2);
371 for (
unsigned int j = 0; j < noLanes; j++) {
373 for (std::vector<NBEdge::Connection>::iterator k = connected.begin(); k != connected.end(); k++) {
virtual void setParticipantsInformation()
Builds the list of participating nodes/edges/links.
A structure which describes a connection between edges or lanes.
int toLane
The lane the connections yields in.
virtual void addNode(NBNode *node)
Adds a node to the traffic light logic.
void collectAllLinks()
helper method for use in NBOwnTLDef and NBLoadedSUMOTLDef
NBEdge * toEdge
The edge the connections yields in.
A SUMO-compliant built logic for a traffic light.
EdgeVector myIncomingEdges
The list of incoming edges.
virtual ~NBTrafficLightDefinition()
Destructor.
The representation of a single edge during network building.
bool mayBeTLSControlled(int fromLane, NBEdge *toEdge, int toLane) const
bool mustBrake(const NBEdge *const from, const NBEdge *const to, int toLane) const
Returns the information whether the described flow must let any other flow pass.
Used for sorting the cells by the begin time they describe.
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
const EdgeVector & getIncomingEdges() const
Returns the list of incoming edges (must be build first)
std::vector< Connection > getConnectionsFromLane(unsigned int lane) const
Returns connections from a given lane.
NBEdge * getFrom() const
returns the from-edge (start of the connection)
#define WRITE_WARNING(msg)
virtual void collectLinks()=0
Collects the links participating in this traffic light If a link could not be found.
EdgeVector getConnectedEdges() const
Returns the list of outgoing edges unsorted.
const std::string & getID() const
Returns the id.
void collectEdges()
Build the list of participating edges.
std::set< std::string > myControlledInnerEdges
Set of inner edges that shall be controlled, though.
int fromLane
The lane the connections starts at.
NBTrafficLightLogic * compute(const NBEdgeCont &ec, OptionsCont &oc)
Computes the traffic light logic.
static SUMOReal maxSpeed(const EdgeVector &ev)
unsigned int getNumLanes() const
Returns the number of lanes.
Storage for edges, including some functionality operating on multiple edges.
static const std::string DefaultProgramID
unsigned int computeBrakingTime(SUMOReal minDecel) const
Computes the time vehicles may need to brake.
void addControlledInnerEdges(const std::vector< std::string > &edges)
Adds the given ids into the list of edges not controlled by the tls.
bool mustBrake(const NBEdge *const from, const NBEdge *const to) const
Returns the information whether the described flow must let any other flow pass.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
virtual void removeNode(NBNode *node)
Removes the given node from the list of controlled nodes.
bool isLeftMover(const NBEdge *const from, const NBEdge *const to) const
Computes whether the given connection is a left mover across the junction.
Base class for objects which have an id.
void addTrafficLight(NBTrafficLightDefinition *tlDef)
Adds a traffic light to the list of traffic lights that control this node.
std::vector< NBEdge * > EdgeVector
A storage for options typed value containers)
NBEdge * getTo() const
returns the to-edge (end of the connection)
Represents a single node (junction) during network building.
bool forbids(const NBEdge *const possProhibitorFrom, const NBEdge *const possProhibitorTo, const NBEdge *const possProhibitedFrom, const NBEdge *const possProhibitedTo, bool regardNonSignalisedLowerPriority) const
Returns the information whether "prohibited" flow must let "prohibitor" flow pass.
virtual NBTrafficLightLogic * myCompute(const NBEdgeCont &ec, unsigned int brakingTime)=0
Computes the traffic light logic finally in dependence to the type.
bool isLeftMover(const NBEdge *const from, const NBEdge *const to) const
returns the information whether the given link is a left-mover
std::vector< NBNode * > myControlledNodes
The container with participating nodes.
NBTrafficLightDefinition(const std::string &id, const std::vector< NBNode * > &junctions, const std::string &programID, SUMOTime offset, TrafficLightType type)
Constructor.
virtual bool amInvalid() const
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
bool foes(const NBEdge *const from1, const NBEdge *const to1, const NBEdge *const from2, const NBEdge *const to2) const
Returns the information whether the given flows cross.
NBConnectionVector myControlledLinks
The list of controlled links.
EdgeVector myEdgesWithin
The list of edges within the area controlled by the tls.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
bool forbids(const NBEdge *const possProhibitorFrom, const NBEdge *const possProhibitorTo, const NBEdge *const possProhibitedFrom, const NBEdge *const possProhibitedTo, bool regardNonSignalisedLowerPriority) const
Returns the information whether "prohibited" flow must let "prohibitor" flow pass.
bool foes(const NBEdge *const from1, const NBEdge *const to1, const NBEdge *const from2, const NBEdge *const to2) const
Returns the information whether the given flows cross.