54 myIgnoreUnknown(ignoreUnknown)
127 WRITE_ERRORF(
TL(
"Unknown traffic light type '%' for tlLogic '%'."), typeS,
id);
138 if (programs.size() == 0) {
140 WRITE_ERRORF(
TL(
"Cannot load traffic light program for unknown id '%', programID '%'."),
id, programID);
144 const std::string existingProgram = programs.begin()->first;
146 if (loadedDef ==
nullptr) {
148 if (oldDef ==
nullptr) {
152 bool deleteDefault =
false;
153 if (newDef ==
nullptr) {
157 if (newDef ==
nullptr) {
158 WRITE_ERRORF(
TL(
"Cannot load traffic light program for unknown id '%', programID '%'."),
id, programID);
162 deleteDefault =
true;
164 assert(newDef !=
nullptr);
173 const std::vector<NBNode*> nodes = newDef->
getNodes();
175 for (
NBNode*
const n : nodes) {
176 n->removeTrafficLight(newDef);
187 std::vector<NBNode*> nodes = oldDef->
getNodes();
188 for (std::vector<NBNode*>::iterator it = nodes.begin(); it != nodes.end(); it++) {
228 const std::vector<NBEdge::Connection>& connections = from->
getConnections();
229 std::vector<NBEdge::Connection>::const_iterator con_it;
230 con_it = find_if(connections.begin(), connections.end(),
232 if (con_it == connections.end()) {
234 " fromLane=" +
toString(fromLane) +
" toLane=" +
toString(toLane) +
" not found");
251 if (tlIndex2 == -1) {
258 if (programs.size() > 0) {
259 std::map<std::string, NBTrafficLightDefinition*>::const_iterator it;
260 for (it = programs.begin(); it != programs.end(); it++) {
266 + tlID +
"' (program '" + it->first +
"')");
284 if (programs.size() > 0) {
298 std::map<std::string, NBTrafficLightDefinition*>::const_iterator it;
299 for (it = programs.begin(); it != programs.end(); it++) {
305 + tlID +
"' (program '" + it->first +
"')");
315 std::string edgeID = attrs.
get<std::string>(attr,
nullptr, ok);
317 if (edge ==
nullptr) {
318 WRITE_ERRORF(
TL(
"Unknown edge '%' given in connection."), edgeID);
328 int laneIndex = attrs.
get<
int>(attr,
nullptr, ok);
#define WRITE_ERRORF(...)
@ SUMO_TAG_PHASE
a single phase description
@ SUMO_TAG_CONNECTION
connectioon between two lanes
@ SUMO_TAG_TLLOGIC
a traffic light logic
@ SUMO_TAG_PARAM
parameter associated to a certain key
@ SUMO_TAG_DEL
delete certain element (note: DELETE is a macro)
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_TLLINKINDEX2
link: the index of the opposite direction link of a pedestrian crossing
@ SUMO_ATTR_TLID
link,node: the traffic light id responsible for this link
@ SUMO_ATTR_TLLINKINDEX
link: the index of the link within the traffic light
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Storage for edges, including some functionality operating on multiple edges.
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
The representation of a single edge during network building.
const std::vector< Connection > & getConnections() const
Returns the connections.
NBNode * getToNode() const
Returns the destination node of the edge.
const std::string & getID() const
int getNumLanes() const
Returns the number of lanes.
A loaded (complete) traffic light logic.
void phasesLoaded()
mark phases as load
NBTrafficLightLogic * getLogic()
Returns the internal logic.
void removeConnection(const NBConnection &conn, bool reconstruct=true)
removes the given connection from the traffic light if recontruct=true, reconstructs the logic and in...
void setType(TrafficLightType type)
Sets the algorithm type of this tls.
void addConnection(NBEdge *from, NBEdge *to, int fromLane, int toLane, int linkIndex, int linkIndex2, bool reconstruct=true)
Adds a connection and immediately informs the edges.
void setOffset(SUMOTime offset)
Sets the offset of this tls.
Represents a single node (junction) during network building.
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node (The set of tls that control this node)
SumoXMLNodeType getType() const
Returns the type of this node.
A traffic light logics which must be computed (only nodes/edges are given)
The base class for traffic light logic definitions.
const std::vector< NBNode * > & getNodes() const
Returns the list of controlled nodes.
void addControlledInnerEdges(const std::vector< std::string > &edges)
Adds the given ids into the list of inner edges controlled by the tls.
virtual void addNode(NBNode *node)
Adds a node to the traffic light logic.
std::vector< std::string > getControlledInnerEdges() const
Retrieve the ids of edges explicitly controlled by the tls.
static const std::string DefaultProgramID
A container for traffic light definitions and built programs.
bool removeProgram(const std::string id, const std::string programID, bool del=true)
Removes a program of a logic definition from the dictionary.
const std::map< std::string, NBTrafficLightDefinition * > & getPrograms(const std::string &id) const
Returns all programs for the given tl-id.
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
NBTrafficLightDefinition * getDefinition(const std::string &id, const std::string &programID) const
Returns the named definition.
A SUMO-compliant built logic for a traffic light.
void resetPhases()
deletes all phases and reset the expect number of links
int getNumLinks()
Returns the number of participating links.
static void addPhase(const SUMOSAXAttributes &attrs, NBLoadedSUMOTLDef *currentTL)
adds a phase to the traffic lights logic currently build
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
NBEdgeCont & myEdgeCont
The edge container for retrieving edges.
~NIXMLTrafficLightsHandler()
Destructor.
bool myResetPhases
whether phases of a previously loaded traffic light must be reset
NBLoadedSUMOTLDef * myCurrentTL
The currently parsed traffic light.
int retrieveLaneIndex(const SUMOSAXAttributes &attrs, SumoXMLAttr attr, NBEdge *edge, bool &ok, bool isDelete=false)
parses a lane index and verifies its correctness
NBTrafficLightLogicCont & myTLLCont
The traffic light container to fill.
bool myIgnoreUnknown
whether definitions for unknown traffic lights shall be silently ignored
void myEndElement(int element)
Called when a closing tag occurs.
NBEdge * retrieveEdge(const SUMOSAXAttributes &attrs, SumoXMLAttr attr, bool &ok)
parses and edge id an returns an existing edge
std::set< std::string > mySeenIDs
list of traffic light logics that were found
void addTlConnection(const SUMOSAXAttributes &attrs)
reads and adds tl-controlled connection
void removeTlConnection(const SUMOSAXAttributes &attrs)
reads and removes tl-controlled connection
NBLoadedSUMOTLDef * initTrafficLightLogic(const SUMOSAXAttributes &attrs, NBLoadedSUMOTLDef *currentTL)
NIXMLTrafficLightsHandler(NBTrafficLightLogicCont &tlCont, NBEdgeCont &ec, bool ignoreUnknown=false)
Constructor.
const std::string & getID() const
Returns the id.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
static OptionsCont & getOptions()
Retrieves the options.
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue=T(), bool report=true) const
Tries to read given attribute assuming it is an int.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
SAX-handler base for SUMO-files.
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
T get(const std::string &str) const
A structure which describes a connection between edges or lanes.
int fromLane
The lane the connections starts at.
int toLane
The lane the connections yields in.
NBEdge * toEdge
The edge the connections yields in.
int tlLinkIndex2
The index of the internal junction within the controlling traffic light (optional)
int tlLinkIndex
The index of this connection within the controlling traffic light.