 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
54 const std::string& name,
55 const std::vector<int>& groupids,
59 const std::vector<int>& vehicleTypes)
60 : myID(id), myName(name), myGroupIDs(groupids),
61 myEdgeID(edgeid), myLane(laneno), myPosition(position),
62 myVehicleTypes(vehicleTypes) {}
69 return poly.
around(getPosition());
82 SignalDictType::iterator i =
myDict.find(lsaid);
87 SSignalDictType::iterator j = (*i).second.find(
id);
88 if (j == (*i).second.end()) {
98 SignalDictType::iterator i =
myDict.find(lsaid);
102 SSignalDictType::iterator j = (*i).second.find(
id);
103 if (j == (*i).second.end()) {
112 for (SignalDictType::iterator i =
myDict.begin(); i !=
myDict.end(); i++) {
113 for (SSignalDictType::iterator j = (*i).second.begin(); j != (*i).second.end(); j++) {
123 SignalDictType::iterator i =
myDict.find(tlid);
138 if (edge ==
nullptr) {
139 WRITE_WARNING(
"Could not set tls signal at edge '" +
toString(myEdgeID) +
"' - the edge was not built.");
147 for (std::vector<NBEdge::Connection>::iterator i = connections.begin(); i != connections.end(); i++) {
156 for (std::vector<NBEdge::Connection>::iterator i = connections.begin(); i != connections.end(); i++) {
167 if (tmpFrom !=
nullptr && tmpTo !=
nullptr) {
169 assignedConnections.push_back(
NBConnection(tmpFrom, -1, tmpTo, -1));
176 assert(myGroupIDs.size() != 0);
188 return tl->
addToSignalGroup(toString<int>(myGroupIDs.front()), assignedConnections);
202 const std::string& name,
203 bool isGreenBegin,
const std::vector<double>& times,
206 myFirstIsRed(!isGreenBegin), myTRedYellow(tredyellow),
207 myTYellow(tyellow) {}
216 GroupDictType::iterator i =
myDict.find(lsaid);
221 SGroupDictType::iterator j = (*i).second.find(
id);
222 if (j == (*i).second.end()) {
240 GroupDictType::iterator i =
myDict.find(lsaid);
244 SGroupDictType::iterator j = (*i).second.find(
id);
245 if (j == (*i).second.end()) {
253 for (GroupDictType::iterator i =
myDict.begin(); i !=
myDict.end(); i++) {
254 for (SGroupDictType::iterator j = (*i).second.begin(); j != (*i).second.end(); j++) {
264 GroupDictType::iterator i =
myDict.find(tlid);
277 std::string
id = toString<int>(
myID);
279 for (std::vector<double>::const_iterator i = myTimes.begin(); i != myTimes.end(); i++) {
284 if (myTimes.size() == 0) {
305 const std::string& name,
SUMOTime absdur,
321 const std::string& name,
SUMOTime absdur,
333 DictType::iterator i =
myDict.find(
id);
344 DictType::iterator i =
myDict.find(
id);
354 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); i++) {
372 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); i++) {
380 std::string
id = toString<int>(tl->
myID);
385 WRITE_ERROR(
"Error on adding a traffic light\n Must be a multiple id ('" +
id +
"')");
391 for (SGroupDictType::const_iterator j = sgs.begin(); j != sgs.end(); j++) {
392 if (!(*j).second->addTo(def)) {
393 WRITE_WARNING(
"The signal group '" + toString<int>((*j).first) +
"' could not be assigned to tl '" + toString<int>(tl->
myID) +
"'.");
400 for (SSignalDictType::const_iterator k = signals.begin(); k != signals.end(); k++) {
401 if (!(*k).second->addTo(ec, def)) {
402 WRITE_WARNING(
"The signal '" + toString<int>((*k).first) +
"' could not be assigned to tl '" + toString<int>(tl->
myID) +
"'.");
409 WRITE_WARNING(
"Could not set " + toString<int>(ref) +
" of " + toString<int>((
int)
myDict.size()) +
" traffic lights.");
411 if (ref_groups != 0) {
412 WRITE_WARNING(
"Could not set " + toString<int>(ref_groups) +
" of " + toString<int>(no_groups) +
" groups.");
414 if (ref_signals != 0) {
415 WRITE_WARNING(
"Could not set " + toString<int>(ref_signals) +
" of " + toString<int>(no_signals) +
" signals.");
NBEdge * toEdge
The edge the connections yields in.
NIVissimTLSignalGroup(int id, const std::string &name, bool isGreenBegin, const std::vector< double > ×, SUMOTime tredyellow, SUMOTime tyellow)
Position getPosition() const
#define WRITE_WARNING(msg)
Storage for edges, including some functionality operating on multiple edges.
A container for traffic light definitions and built programs.
NIVissimTL(int id, const std::string &type, const std::string &name, SUMOTime absdur, SUMOTime offset)
void addSignalGroup(const std::string &id)
Adds a signal group.
static SSignalDictType getSignalsFor(int tlid)
std::vector< Connection > getConnectionsFromLane(int lane, NBEdge *to=nullptr, int toLane=-1) const
Returns connections from a given lane.
void addSignalGroupPhaseBegin(const std::string &groupid, SUMOTime time, TLColor color)
Sets the information about the begin of a phase.
static bool dictionary(int lsaid, int id, NIVissimTLSignal *o)
void setCycleDuration(int cycleDur)
Sets the duration of a cycle.
static bool dictionary(int id, const std::string &type, const std::string &name, SUMOTime absdur, SUMOTime offset)
The representation of a single edge during network building.
static bool dict_SetSignals(NBTrafficLightLogicCont &tlc, NBEdgeCont &ec)
int toLane
The lane the connections yields in.
NIVissimTLSignalGroup * myCurrentGroup
bool lanesWereAssigned() const
Check if lanes were assigned.
bool addTo(NBEdgeCont &ec, NBLoadedTLDef *node) const
TLColor
An enumeration of possible tl-signal states.
bool around(const Position &p, double offset=0) const
Returns the information whether the position vector describes a polygon lying around the given point.
void setSignalYellowTimes(const std::string &groupid, SUMOTime tRedYellow, SUMOTime tYellow)
Sets the times the light is yellow or red/yellow.
int getNumLanes() const
Returns the number of lanes.
NBEdge * retrievePossiblySplit(const std::string &id, bool downstream) const
Tries to retrieve an edge, even if it is splitted.
A point in 2D or 3D with translation and scaling methods.
static bool dictionary(int lsaid, int id, NIVissimTLSignalGroup *o)
static bool dictionary(int id, NIVissimAbstractEdge *e)
static GroupDictType myDict
bool addTo(NBLoadedTLDef *node) const
NIVissimTLSignal(int id, const std::string &name, const std::vector< int > &groupids, int edgeid, int laneno, double position, const std::vector< int > &assignedVehicleTypes)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
std::map< int, SGroupDictType > GroupDictType
std::map< int, SSignalDictType > SignalDictType
std::map< int, NIVissimTL * > DictType
static SignalDictType myDict
A loaded (complete) traffic light logic.
std::map< int, NIVissimTLSignalGroup * > SGroupDictType
std::vector< NBConnection > NBConnectionVector
Definition of a connection vector.
std::string getType() const
static bool dictionary(int id, NIVissimConnection *o)
bool isWithin(const PositionVector &poly) const
int getFromEdgeID() const
std::map< int, NIVissimTLSignal * > SSignalDictType
A structure which describes a connection between edges or lanes.
static SGroupDictType getGroupsFor(int tlid)
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
bool addToSignalGroup(const std::string &groupid, const NBConnection &connection)
Adds a connection to a signal group.