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");
139 return (
unsigned int)(vmax / minDecel);
157 const EdgeVector& incoming = (*i)->getIncomingEdges();
158 copy(incoming.begin(), incoming.end(), back_inserter(
myIncomingEdges));
159 const EdgeVector& outgoing = (*i)->getOutgoingEdges();
160 copy(outgoing.begin(), outgoing.end(), back_inserter(myOutgoing));
168 EdgeVector::iterator k = find(myOutgoing.begin(), myOutgoing.end(), edge);
169 if (k != myOutgoing.end()) {
172 (*j)->setIsInnerEdge();
189 std::vector<NBNode*>::const_iterator i =
200 std::vector<NBNode*>::const_iterator i =
205 if (!node->hasOutgoing(to)) {
214 const NBEdge*
const possProhibitedTo,
215 const NBEdge*
const possProhibitorFrom,
216 const NBEdge*
const possProhibitorTo,
217 bool regardNonSignalisedLowerPriority)
const {
218 return forbids(possProhibitorFrom, possProhibitorTo,
219 possProhibitedFrom, possProhibitedTo,
220 regardNonSignalisedLowerPriority);
227 bool regardNonSignalisedLowerPriority)
const {
230 regardNonSignalisedLowerPriority);
236 const NBEdge*
const possProhibitorTo,
237 const NBEdge*
const possProhibitedFrom,
238 const NBEdge*
const possProhibitedTo,
239 bool regardNonSignalisedLowerPriority)
const {
240 if (possProhibitorFrom == 0 || possProhibitorTo == 0 || possProhibitedFrom == 0 || possProhibitedTo == 0) {
244 std::vector<NBNode*>::const_iterator incoming =
246 std::vector<NBNode*>::const_iterator outgoing =
249 NBNode* incnode = *incoming;
250 NBNode* outnode = *outgoing;
251 EdgeVector::const_iterator i;
252 if (incnode != outnode) {
257 for (i = ev1.begin(); i != ev1.end(); ++i) {
258 std::vector<NBNode*>::const_iterator outgoing2 =
263 NBNode* outnode2 = *outgoing2;
264 if (incnode != outnode2) {
267 bool ret1 = incnode->
foes(possProhibitorTo, *i,
268 possProhibitedFrom, possProhibitedTo);
269 bool ret2 = incnode->forbids(possProhibitorFrom, possProhibitorTo,
270 possProhibitedTo, *i,
271 regardNonSignalisedLowerPriority);
272 bool ret = ret1 || ret2;
281 for (i = ev2.begin(); i != ev2.end(); ++i) {
282 std::vector<NBNode*>::const_iterator incoming2 =
287 NBNode* incnode2 = *incoming2;
288 if (incnode2 != outnode) {
291 bool ret1 = incnode2->
foes(possProhibitorTo, *i,
292 possProhibitedFrom, possProhibitedTo);
293 bool ret2 = incnode2->
forbids(possProhibitorTo, *i,
294 possProhibitedFrom, possProhibitedTo,
295 regardNonSignalisedLowerPriority);
296 bool ret = ret1 || ret2;
305 return incnode->forbids(possProhibitorFrom, possProhibitorTo,
306 possProhibitedFrom, possProhibitedTo,
307 regardNonSignalisedLowerPriority);
313 const NBEdge*
const from2,
const NBEdge*
const to2)
const {
314 if (to1 == 0 || to2 == 0) {
318 std::vector<NBNode*>::const_iterator incoming =
321 std::vector<NBNode*>::const_iterator outgoing =
325 NBNode* incnode = *incoming;
326 NBNode* outnode = *outgoing;
327 if (incnode != outnode) {
330 return incnode->
foes(from1, to1, from2, to2);
373 for (
unsigned int j = 0; j < noLanes; j++) {
375 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 std::map< std::string, std::string > & getMap() const
Returns the inner key/value map.
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 addParameter(const std::string &key, const std::string &value)
Adds a parameter.
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.