46 #ifdef CHECK_MEMORY_LEAKS
48 #endif // CHECK_MEMORY_LEAKS
65 myOriginalNodes(def->getNodes().begin(), def->getNodes().end()) {
96 NBConnection conn(from, fromLane, to, toLane, linkIndex);
173 if (it->getFrom() == conn.
getFrom() &&
174 it->getTo() == conn.
getTo() &&
185 const int removed = it->getTLIndex();
202 const std::vector<NBTrafficLightLogic::PhaseDefinition> phases =
myTLLogic->
getPhases();
204 for (std::vector<NBTrafficLightLogic::PhaseDefinition>::const_iterator it = phases.begin(); it != phases.end(); it++) {
205 std::string newState = it->state;
206 newState.erase(newState.begin() + removed);
207 newLogic->
addStep(it->duration, newState);
241 (*it).shiftLaneIndex(edge, offset);
250 unsigned int noLinksAll = size;
252 std::vector<NBNode::Crossing> crossings;
254 const std::vector<NBNode::Crossing>& c = (*i)->getCrossings();
256 (*i)->setCrossingTLIndices(noLinksAll);
257 copy(c.begin(), c.end(), std::back_inserter(crossings));
258 noLinksAll += (
unsigned int)c.size();
260 if (crossings.size() > 0) {
274 const std::string crossingDefaultState(crossings.size(),
'r');
277 const std::vector<NBTrafficLightLogic::PhaseDefinition> phases =
myTLLogic->
getPhases();
280 for (std::vector<NBTrafficLightLogic::PhaseDefinition>::const_iterator it = phases.begin(); it != phases.end(); it++) {
void removeConnection(const NBConnection &conn, bool reconstruct=true)
removes the given connection from the traffic light if recontruct=true, reconstructs the logic and in...
bool setControllingTLInformation(const NBConnection &c, const std::string &tlID)
Returns if the link could be set as to be controlled.
TrafficLightType getType() const
get the algorithm type (static etc..)
TrafficLightType myType
The algorithm type for the traffic light.
virtual void addNode(NBNode *node)
Adds a node to the traffic light logic.
NBLoadedSUMOTLDef(const std::string &id, const std::string &programID, SUMOTime offset, TrafficLightType type)
Constructor.
void collectAllLinks()
helper method for use in NBOwnTLDef and NBLoadedSUMOTLDef
void setOffset(SUMOTime offset)
Sets the offset of this tls.
void closeBuilding()
closes the building process
A SUMO-compliant built logic for a traffic light.
TrafficLightType getType() const
get the algorithm type (static etc..)
const std::string & getProgramID() const
Returns the ProgramID.
The representation of a single edge during network building.
class for identifying connections
int getFromLane() const
returns the from-lane
The base class for traffic light logic definitions.
void setOffset(SUMOTime offset)
Sets the offset of this tls.
SUMOTime myOffset
The offset in the program.
NBEdge * getFrom() const
returns the from-edge (start of the connection)
#define UNUSED_PARAMETER(x)
void replaceRemoved(NBEdge *removed, int removedLane, NBEdge *by, int byLane)
Replaces a removed edge/lane.
void setTLIndex(int tlIndex)
SUMOTime getOffset()
Returns the offset.
const std::string & getID() const
Returns the id.
static const int InvalidTlIndex
const std::vector< PhaseDefinition > & getPhases() const
Returns the phases.
const NBConnectionVector & getControlledLinks() const
returns the controlled links (depends on previous call to collectLinks)
void patchIfCrossingsAdded()
repair the plan if controlled nodes received pedestrian crossings
std::set< NBNode * > myOriginalNodes
The original nodes for which the loaded logic is valid.
Storage for edges, including some functionality operating on multiple edges.
static std::string addPedestrianPhases(NBTrafficLightLogic *logic, SUMOTime greenTime, std::string state, const std::vector< NBNode::Crossing > &crossings, const EdgeVector &fromEdges, const EdgeVector &toEdges)
add 1 or 2 phases depending on the presence of pedestrian crossings
NBTrafficLightLogic * myCompute(const NBEdgeCont &ec, unsigned int brakingTime)
Computes the traffic light logic finally in dependence to the type.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
void remapRemoved(NBEdge *removed, const EdgeVector &incoming, const EdgeVector &outgoing)
Replaces occurences of the removed edge in incoming/outgoing edges of all definitions.
SUMOTime getOffset() const
Returns the offset of first switch.
std::set< NBEdge * > myShifted
set of edges with shifted lane indices (to avoid shifting twice)
void setTLControllingInformation() const
Informs edges about being controlled by a tls.
NBNode * getToNode() const
Returns the destination node of the edge.
unsigned int getNumLinks()
Returns the number of participating links.
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
int getToLane() const
returns the to-lane
void collectLinks()
Collects the links participating in this traffic light (only if not previously loaded) ...
NBEdge * getTo() const
returns the to-edge (end of the connection)
~NBLoadedSUMOTLDef()
Destructor.
std::vector< NBNode * > myControlledNodes
The container with participating nodes.
void addStep(SUMOTime duration, const std::string &state, int index=-1)
Adds a phase to the logic.
NBConnectionVector myControlledLinks
The list of controlled links.
void shiftTLConnectionLaneIndex(NBEdge *edge, int offset)
patches signal plans by modifying lane indices
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.
NBNode * getFromNode() const
Returns the origin node of the edge.