 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
27 #include <xercesc/sax/HandlerBase.hpp>
28 #include <xercesc/sax/AttributeList.hpp>
29 #include <xercesc/sax/SAXParseException.hpp>
30 #include <xercesc/sax/SAXException.hpp>
59 myIgnoreUnknown(ignoreUnknown)
118 WRITE_ERROR(
"Definition of tlLogic '" + currentTL->
getID() +
"' was not finished.");
131 WRITE_ERROR(
"Unknown traffic light type '" + typeS +
"' for tlLogic '" +
id +
"'.");
142 if (programs.size() == 0) {
144 WRITE_ERROR(
"Cannot load traffic light program for unknown id '" +
id +
"', programID '" + programID +
"'.");
148 const std::string existingProgram = programs.begin()->first;
150 if (loadedDef ==
nullptr) {
152 if (oldDef ==
nullptr) {
156 bool deleteDefault =
false;
157 if (newDef ==
nullptr) {
161 if (newDef ==
nullptr) {
162 WRITE_ERROR(
"Cannot load traffic light program for unknown id '" +
id +
"', programID '" + programID +
"'.");
166 deleteDefault =
true;
171 std::vector<NBNode*> nodes = newDef->
getNodes();
172 for (std::vector<NBNode*>::iterator it = nodes.begin(); it != nodes.end(); it++) {
178 std::vector<NBNode*> nodes = newDef->
getNodes();
179 for (std::vector<NBNode*>::iterator it = nodes.begin(); it != nodes.end(); it++) {
180 (*it)->removeTrafficLight(newDef);
192 std::vector<NBNode*> nodes = oldDef->
getNodes();
193 for (std::vector<NBNode*>::iterator it = nodes.begin(); it != nodes.end(); it++) {
194 loadedDef->addNode(*it);
232 const std::vector<NBEdge::Connection>& connections = from->
getConnections();
233 std::vector<NBEdge::Connection>::const_iterator con_it;
234 con_it = find_if(connections.begin(), connections.end(),
236 if (con_it == connections.end()) {
238 " fromLane=" +
toString(fromLane) +
" toLane=" +
toString(toLane) +
" not found");
255 if (tlIndex2 == -1) {
262 if (programs.size() > 0) {
263 std::map<std::string, NBTrafficLightDefinition*>::const_iterator it;
264 for (it = programs.begin(); it != programs.end(); it++) {
270 + tlID +
"' (program '" + it->first +
"')");
276 WRITE_ERROR(
"The traffic light '" + tlID +
"' is not known.");
288 if (programs.size() > 0) {
304 std::map<std::string, NBTrafficLightDefinition*>::const_iterator it;
305 for (it = programs.begin(); it != programs.end(); it++) {
311 + tlID +
"' (program '" + it->first +
"')");
321 std::string edgeID = attrs.
get<std::string>(attr,
nullptr, ok);
323 if (edge ==
nullptr) {
324 WRITE_ERROR(
"Unknown edge '" + edgeID +
"' given in connection.");
334 int laneIndex = attrs.
get<
int>(attr,
nullptr, ok);
NBEdge * toEdge
The edge the connections yields in.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
std::vector< std::string > getControlledInnerEdges() const
Retrieve the ids of edges explicitly controlled by the tls.
const std::map< std::string, NBTrafficLightDefinition * > & getPrograms(const std::string &id) const
Returns all programs for the given tl-id.
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
bool removeProgram(const std::string id, const std::string programID, bool del=true)
Removes a program of a logic definition from the dictionary.
Storage for edges, including some functionality operating on multiple edges.
static void addPhase(const SUMOSAXAttributes &attrs, NBLoadedSUMOTLDef *currentTL)
adds a phase to the traffic lights logic currently build
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
SAX-handler base for SUMO-files.
A container for traffic light definitions and built programs.
void removeConnection(const NBConnection &conn, bool reconstruct=true)
removes the given connection from the traffic light if recontruct=true, reconstructs the logic and in...
parameter associated to a certain key
int retrieveLaneIndex(const SUMOSAXAttributes &attrs, SumoXMLAttr attr, NBEdge *edge, bool &ok, bool isDelete=false)
parses a lane index and verifies its correctness
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
NBTrafficLightLogicCont & myTLLCont
The traffic light container to fill.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
link,node: the traffic light id responsible for this link
static OptionsCont & getOptions()
Retrieves the options.
SumoXMLNodeType getType() const
Returns the type of this node.
void setOffset(SUMOTime offset)
Sets the offset of this tls.
NBTrafficLightLogic * getLogic()
Returns the internal logic.
int tlLinkIndex
The index of this connection within the controlling traffic light.
a single phase description
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.
NIXMLTrafficLightsHandler(NBTrafficLightLogicCont &tlCont, NBEdgeCont &ec, bool ignoreUnknown=false)
Constructor.
int fromLane
The lane the connections starts at.
The representation of a single edge during network building.
int toLane
The lane the connections yields in.
NBTrafficLightDefinition * getDefinition(const std::string &id, const std::string &programID) const
Returns the named definition.
~NIXMLTrafficLightsHandler()
Destructor.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
NBNode * getToNode() const
Returns the destination node of the edge.
void addControlledInnerEdges(const std::vector< std::string > &edges)
Adds the given ids into the list of inner edges controlled by the tls.
link: the index of the opposite direction link of a pedestrian crossing
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
T get(const std::string &str) const
int getNumLinks()
Returns the number of participating links.
void removeTlConnection(const SUMOSAXAttributes &attrs)
reads and removes tl-controlled connection
int getNumLanes() const
Returns the number of lanes.
int tlLinkIndex2
The index of the internal junction within the controlling traffic light (optional)
NBEdgeCont & myEdgeCont
The edge container for retrieving edges.
const std::vector< NBNode * > & getNodes() const
Returns the list of controlled nodes.
void phasesLoaded()
mark phases as load
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.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
link: the index of the link within the traffic light
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node (The set of tls that control this node)
NBLoadedSUMOTLDef * myCurrentTL
The currently parsed traffic light.
static const std::string DefaultProgramID
connectio between two lanes
virtual void addNode(NBNode *node)
Adds a node to the traffic light logic.
void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
bool myIgnoreUnknown
whether definitions for unknown traffic lights shall be silently ignored
A SUMO-compliant built logic for a traffic light.
A structure which describes a connection between edges or lanes.
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Encapsulated SAX-Attributes.
void addTlConnection(const SUMOSAXAttributes &attrs)
reads and adds tl-controlled connection
const std::string & getID() const
Returns the id.
NBLoadedSUMOTLDef * initTrafficLightLogic(const SUMOSAXAttributes &attrs, NBLoadedSUMOTLDef *currentTL)
const std::vector< Connection > & getConnections() const
Returns the connections.
NBEdge * retrieveEdge(const SUMOSAXAttributes &attrs, SumoXMLAttr attr, bool &ok)
parses and edge id an returns an existing edge
The base class for traffic light logic definitions.
void myEndElement(int element)
Called when a closing tag occurs.
bool myResetPhases
whether phases of a previously loaded traffic light must be reset
void setType(TrafficLightType type)
Sets the algorithm type of this tls.
const std::string & getID() const
A loaded (complete) traffic light logic.