28 #include <xercesc/sax/HandlerBase.hpp> 29 #include <xercesc/sax/AttributeList.hpp> 30 #include <xercesc/sax/SAXParseException.hpp> 31 #include <xercesc/sax/SAXException.hpp> 60 myIgnoreUnknown(ignoreUnknown)
119 WRITE_ERROR(
"Definition of tlLogic '" + currentTL->
getID() +
"' was not finished.");
132 WRITE_ERROR(
"Unknown traffic light type '" + typeS +
"' for tlLogic '" +
id +
"'.");
143 if (programs.size() == 0) {
145 WRITE_ERROR(
"Cannot load traffic light program for unknown id '" +
id +
"', programID '" + programID +
"'.");
149 const std::string existingProgram = programs.begin()->first;
151 if (loadedDef ==
nullptr) {
153 if (oldDef ==
nullptr) {
157 if (newDef ==
nullptr) {
161 if (newDef ==
nullptr) {
162 WRITE_ERROR(
"Cannot load traffic light program for unknown id '" +
id +
"', programID '" + programID +
"'.");
169 std::vector<NBNode*> nodes = newDef->
getNodes();
170 for (std::vector<NBNode*>::iterator it = nodes.begin(); it != nodes.end(); it++) {
176 std::vector<NBNode*> nodes = newDef->
getNodes();
177 for (std::vector<NBNode*>::iterator it = nodes.begin(); it != nodes.end(); it++) {
178 (*it)->removeTrafficLight(newDef);
190 std::vector<NBNode*> nodes = oldDef->
getNodes();
191 for (std::vector<NBNode*>::iterator it = nodes.begin(); it != nodes.end(); it++) {
192 loadedDef->addNode(*it);
226 const std::vector<NBEdge::Connection>& connections = from->
getConnections();
227 std::vector<NBEdge::Connection>::const_iterator con_it;
228 con_it = find_if(connections.begin(), connections.end(),
230 if (con_it == connections.end()) {
232 " fromLane=" +
toString(fromLane) +
" toLane=" +
toString(toLane) +
" not found");
251 if (programs.size() > 0) {
252 std::map<std::string, NBTrafficLightDefinition*>::const_iterator it;
253 for (it = programs.begin(); it != programs.end(); it++) {
259 + tlID +
"' (program '" + it->first +
"')");
265 WRITE_ERROR(
"The traffic light '" + tlID +
"' is not known.");
277 if (programs.size() > 0) {
293 std::map<std::string, NBTrafficLightDefinition*>::const_iterator it;
294 for (it = programs.begin(); it != programs.end(); it++) {
300 + tlID +
"' (program '" + it->first +
"')");
310 std::string edgeID = attrs.
get<std::string>(attr,
nullptr, ok);
312 if (edge ==
nullptr) {
313 WRITE_ERROR(
"Unknown edge '" + edgeID +
"' given in connection.");
323 int laneIndex = attrs.
get<
int>(attr,
nullptr, ok);
const std::map< std::string, NBTrafficLightDefinition * > & getPrograms(const std::string &id) const
Returns all programs for the given tl-id.
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 myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
A structure which describes a connection between edges or lanes.
int toLane
The lane the connections yields in.
static void addPhase(const SUMOSAXAttributes &attrs, NBLoadedSUMOTLDef *currentTL)
adds a phase to the traffic lights logic currently build
bool removeProgram(const std::string id, const std::string programID, bool del=true)
Removes a program of a logic definition from the dictionary.
virtual void addNode(NBNode *node)
Adds a node to the traffic light logic.
NBEdge * toEdge
The edge the connections yields in.
void setOffset(SUMOTime offset)
Sets the offset of this tls.
int getNumLinks()
Returns the number of participating links.
A loaded (complete) traffic light logic.
NBEdgeCont & myEdgeCont
The edge container for retrieving edges.
NIXMLTrafficLightsHandler(NBTrafficLightLogicCont &tlCont, NBEdgeCont &ec, bool ignoreUnknown=false)
Constructor.
A container for traffic light definitions and built programs.
A SUMO-compliant built logic for a traffic light.
NBEdge * retrieveEdge(const SUMOSAXAttributes &attrs, SumoXMLAttr attr, bool &ok)
parses and edge id an returns an existing edge
connectio between two lanes
The representation of a single edge during network building.
void phasesLoaded()
mark phases as load
The base class for traffic light logic definitions.
link,node: the traffic light id responsible for this link
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
const std::string & getID() const
Returns the id.
NBLoadedSUMOTLDef * initTrafficLightLogic(const SUMOSAXAttributes &attrs, NBLoadedSUMOTLDef *currentTL)
SAX-handler base for SUMO-files.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
static OptionsCont & getOptions()
Retrieves the options.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
NBTrafficLightLogicCont & myTLLCont
The traffic light container to fill.
int retrieveLaneIndex(const SUMOSAXAttributes &attrs, SumoXMLAttr attr, NBEdge *edge, bool &ok)
parses a lane index and verifies its correctness
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
NBTrafficLightDefinition * getDefinition(const std::string &id, const std::string &programID) const
Returns the named definition.
Encapsulated SAX-Attributes.
std::string tlID
The id of the traffic light that controls this connection.
void addTlConnection(const SUMOSAXAttributes &attrs)
reads and adds tl-controlled connection
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
int getNumLanes() const
Returns the number of lanes.
int fromLane
The lane the connections starts at.
parameter associated to a certain key
void addConnection(NBEdge *from, NBEdge *to, int fromLane, int toLane, int linkIndex, bool reconstruct=true)
Adds a connection and immediately informs the edges.
T get(const std::string &str) const
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
NBLoadedSUMOTLDef * myCurrentTL
The currently parsed traffic light.
bool myIgnoreUnknown
whether definitions for unknown traffic lights shall be silently ignored
Storage for edges, including some functionality operating on multiple edges.
void removeTlConnection(const SUMOSAXAttributes &attrs)
reads and removes tl-controlled connection
NBTrafficLightLogic * getLogic()
Returns the internal logic.
void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
static const std::string DefaultProgramID
void addControlledInnerEdges(const std::vector< std::string > &edges)
Adds the given ids into the list of inner edges controlled by the tls.
int tlLinkIndex
The index of this connection within the controlling traffic light.
bool myResetPhases
whether phases of a previously loaded traffic light must be reset
~NIXMLTrafficLightsHandler()
Destructor.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue, bool report=true) const
Tries to read given attribute assuming it is an int.
void myEndElement(int element)
Called when a closing tag occurs.
const std::vector< Connection > & getConnections() const
Returns the connections.
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
const std::vector< NBNode * > & getNodes() const
Returns the list of controlled nodes.
SumoXMLNodeType getType() const
Returns the type of this node.
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
link: the index of the link within the traffic light
void setType(TrafficLightType type)
Sets the algorithm type of this tls.
A traffic light logics which must be computed (only nodes/edges are given)
std::vector< std::string > getControlledInnerEdges() const
Retrieve the ids of edges explicitly controlled by the tls.
NBNode * getToNode() const
Returns the destination node of the edge.
a single phase description