53 const std::string& name,
54 const std::vector<int>& groupids,
58 const std::vector<int>& vehicleTypes)
59 : myID(id), myName(name), myGroupIDs(groupids),
60 myEdgeID(edgeid), myLane(laneno), myPosition(position),
61 myVehicleTypes(vehicleTypes) {}
68 return poly.
around(getPosition());
81 SignalDictType::iterator i =
myDict.find(lsaid);
86 SSignalDictType::iterator j = (*i).second.find(
id);
87 if (j == (*i).second.end()) {
97 SignalDictType::iterator i =
myDict.find(lsaid);
101 SSignalDictType::iterator j = (*i).second.find(
id);
102 if (j == (*i).second.end()) {
111 for (SignalDictType::iterator i =
myDict.begin(); i !=
myDict.end(); i++) {
112 for (SSignalDictType::iterator j = (*i).second.begin(); j != (*i).second.end(); j++) {
122 SignalDictType::iterator i =
myDict.find(tlid);
137 if (edge ==
nullptr) {
138 WRITE_WARNINGF(
TL(
"Could not set tls signal at edge '%' - the edge was not built."), myEdgeID);
146 for (std::vector<NBEdge::Connection>::iterator i = connections.begin(); i != connections.end(); i++) {
155 for (std::vector<NBEdge::Connection>::iterator i = connections.begin(); i != connections.end(); i++) {
166 if (tmpFrom !=
nullptr && tmpTo !=
nullptr) {
168 assignedConnections.push_back(
NBConnection(tmpFrom, -1, tmpTo, -1));
175 assert(myGroupIDs.size() != 0);
187 return tl->
addToSignalGroup(toString<int>(myGroupIDs.front()), assignedConnections);
201 const std::string& name,
202 bool isGreenBegin,
const std::vector<SUMOTime>& times,
205 myFirstIsRed(!isGreenBegin), myTRedYellow(tredyellow),
206 myTYellow(tyellow) {}
215 GroupDictType::iterator i =
myDict.find(lsaid);
220 SGroupDictType::iterator j = (*i).second.find(
id);
221 if (j == (*i).second.end()) {
239 GroupDictType::iterator i =
myDict.find(lsaid);
243 SGroupDictType::iterator j = (*i).second.find(
id);
244 if (j == (*i).second.end()) {
252 for (GroupDictType::iterator i =
myDict.begin(); i !=
myDict.end(); i++) {
253 for (SGroupDictType::iterator j = (*i).second.begin(); j != (*i).second.end(); j++) {
263 GroupDictType::iterator i =
myDict.find(tlid);
276 std::string
id = toString<int>(
myID);
283 if (myTimes.size() == 0) {
298 const std::string& name,
SUMOTime absdur,
311 const std::string& name,
SUMOTime absdur,
323 DictType::iterator i =
myDict.find(
id);
334 DictType::iterator i =
myDict.find(
id);
344 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); i++) {
362 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); i++) {
370 std::string
id = toString<int>(tl->
myID);
375 WRITE_ERRORF(
TL(
"Error on adding a traffic light\n Must be a multiple id ('%')"),
id);
381 for (SGroupDictType::const_iterator j = sgs.begin(); j != sgs.end(); j++) {
382 if (!(*j).second->addTo(def)) {
383 WRITE_WARNINGF(
TL(
"The signal group '%' could not be assigned to tl '%'."), toString<int>((*j).first), toString<int>(tl->
myID));
390 for (SSignalDictType::const_iterator k = signals.begin(); k != signals.end(); k++) {
391 if (!(*k).second->addTo(ec, def)) {
392 WRITE_WARNINGF(
TL(
"The signal '%' could not be assigned to tl '%'."), toString<int>((*k).first), toString<int>(tl->
myID));
399 WRITE_WARNINGF(
TL(
"Could not set % of % traffic lights."), toString<int>(ref), toString<int>((
int)
myDict.size()));
401 if (ref_groups != 0) {
402 WRITE_WARNINGF(
TL(
"Could not set % of % groups."), toString<int>(ref_groups), toString<int>(no_groups));
404 if (ref_signals != 0) {
405 WRITE_WARNINGF(
TL(
"Could not set % of % signals."), toString<int>(ref_signals), toString<int>(no_signals));
#define WRITE_WARNINGF(...)
#define WRITE_ERRORF(...)
std::vector< NBConnection > NBConnectionVector
Definition of a connection vector.
Storage for edges, including some functionality operating on multiple edges.
NBEdge * retrievePossiblySplit(const std::string &id, bool downstream) const
Tries to retrieve an edge, even if it is splitted.
The representation of a single edge during network building.
int getNumLanes() const
Returns the number of lanes.
std::vector< Connection > getConnectionsFromLane(int lane, const NBEdge *to=nullptr, int toLane=-1) const
Returns connections from a given lane.
bool lanesWereAssigned() const
Check if lanes were assigned.
A loaded (complete) traffic light logic.
bool addToSignalGroup(const std::string &groupid, const NBConnection &connection)
Adds a connection to a signal group.
void addSignalGroupPhaseBegin(const std::string &groupid, SUMOTime time, TLColor color)
Sets the information about the begin of a phase.
void setSignalYellowTimes(const std::string &groupid, SUMOTime tRedYellow, SUMOTime tYellow)
Sets the times the light is yellow or red/yellow.
void addSignalGroup(const std::string &id)
Adds a signal group.
void setCycleDuration(SUMOTime cycleDur)
Sets the duration of a cycle.
TLColor
An enumeration of possible tl-signal states.
@ TLCOLOR_GREEN
Signal shows green.
@ TLCOLOR_RED
Signal shows red.
A container for traffic light definitions and built programs.
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
static bool dictionary(int id, NIVissimAbstractEdge *e)
int getFromEdgeID() const
static bool dictionary(int id, NIVissimConnection *o)
static bool dictionary(int lsaid, int id, NIVissimTLSignalGroup *o)
static SGroupDictType getGroupsFor(int tlid)
NIVissimTLSignalGroup(int id, const std::string &name, bool isGreenBegin, const std::vector< SUMOTime > ×, SUMOTime tredyellow, SUMOTime tyellow)
static GroupDictType myDict
bool addTo(NBLoadedTLDef *node) const
bool isWithin(const PositionVector &poly) const
static bool dictionary(int lsaid, int id, NIVissimTLSignal *o)
bool addTo(NBEdgeCont &ec, NBLoadedTLDef *node) const
Position getPosition() const
NIVissimTLSignal(int id, const std::string &name, const std::vector< int > &groupids, int edgeid, int laneno, double position, const std::vector< int > &assignedVehicleTypes)
static SSignalDictType getSignalsFor(int tlid)
static SignalDictType myDict
NIVissimTLSignalGroup * myCurrentGroup
std::map< int, NIVissimTLSignalGroup * > SGroupDictType
static bool dict_SetSignals(NBTrafficLightLogicCont &tlc, NBEdgeCont &ec)
static bool dictionary(int id, const std::string &type, const std::string &name, SUMOTime absdur, SUMOTime offset)
std::map< int, SGroupDictType > GroupDictType
NIVissimTL(int id, const std::string &type, const std::string &name, SUMOTime absdur, SUMOTime offset)
std::string getType() const
std::map< int, SSignalDictType > SignalDictType
std::map< int, NIVissimTL * > DictType
std::map< int, NIVissimTLSignal * > SSignalDictType
A point in 2D or 3D with translation and scaling methods.
bool around(const Position &p, double offset=0) const
Returns the information whether the position vector describes a polygon lying around the given point.
A structure which describes a connection between edges or lanes.
int toLane
The lane the connections yields in.
NBEdge * toEdge
The edge the connections yields in.