45 #ifdef CHECK_MEMORY_LEAKS
47 #endif // CHECK_MEMORY_LEAKS
64 myConnections.push_back(c);
70 myPhases.push_back(
PhaseDef(time, color));
77 myTRedYellow = tRedYellow;
84 sort(myPhases.begin(), myPhases.end(),
91 if (myTYellow < tyellow) {
92 WRITE_WARNING(
"TYellow of signal group '" +
getID() +
"' was less than the computed one; patched (was:" + toString<SUMOTime>(myTYellow) +
", is:" + toString<int>(tyellow) +
")");
102 std::vector<SUMOReal> ret;
103 for (std::vector<PhaseDef>::const_iterator i = myPhases.begin(); i != myPhases.end(); i++) {
104 ret.push_back((
SUMOReal)(*i).myTime);
108 for (std::vector<PhaseDef>::const_iterator i = myPhases.begin(); i != myPhases.end(); i++) {
111 if (time > cycleDuration) {
112 time = time - cycleDuration ;
124 return (
unsigned int) myConnections.size();
130 assert(myPhases.size() != 0);
131 for (std::vector<PhaseDef>::const_reverse_iterator i = myPhases.rbegin(); i != myPhases.rend(); i++) {
133 if (time >= nextTime) {
143 bool has_red_now = !mayDrive(time);
144 bool had_green = mayDrive(time - myTYellow);
145 return has_red_now && had_green;
151 for (NBConnectionVector::const_iterator i = myConnections.begin(); i != myConnections.end(); i++) {
152 if ((*i).getFrom() == from && (*i).getTo() == to) {
163 assert(pos < myConnections.size());
164 return myConnections[pos];
170 for (NBConnectionVector::const_iterator i = myConnections.begin(); i != myConnections.end(); i++) {
171 if ((*i).getFrom() == from) {
182 for (NBConnectionVector::iterator i = myConnections.begin(); i != myConnections.end();) {
183 if ((*i).getFrom() == which) {
185 i = myConnections.erase(i);
186 for (EdgeVector::const_iterator j = by.begin(); j != by.end(); j++) {
189 throw ProcessError(
"Could not replace edge '" + which->
getID() +
"' by '" + (*j)->getID() +
"'.\nUndefined...");
191 newConns.push_back(curr);
197 copy(newConns.begin(), newConns.end(),
198 back_inserter(myConnections));
204 for (NBConnectionVector::const_iterator i = myConnections.begin(); i != myConnections.end(); i++) {
205 if ((*i).getTo() == to) {
216 for (NBConnectionVector::iterator i = myConnections.begin(); i != myConnections.end();) {
217 if ((*i).getTo() == which) {
219 i = myConnections.erase(i);
220 for (EdgeVector::const_iterator j = by.begin(); j != by.end(); j++) {
223 throw ProcessError(
"Could not replace edge '" + which->
getID() +
"' by '" + (*j)->getID() +
"'.\nUndefined...");
225 newConns.push_back(curr);
231 copy(newConns.begin(), newConns.end(),
232 back_inserter(myConnections));
239 for (NBConnectionVector::iterator i = myConnections.begin(); i != myConnections.end(); i++) {
240 if ((*i).getTo() == removed
242 ((*i).getToLane() == removedLane
244 (*i).getToLane() == -1)) {
245 (*i).replaceTo(removed, removedLane, by, byLane);
247 }
else if ((*i).getTo() == removed && removedLane == -1) {
248 (*i).replaceTo(removed, by);
251 if ((*i).getFrom() == removed
253 ((*i).getFromLane() == removedLane
255 (*i).getFromLane() == -1)) {
256 (*i).replaceFrom(removed, removedLane, by, byLane);
258 }
else if ((*i).getFrom() == removed && removedLane == -1) {
259 (*i).replaceFrom(removed, by);
269 const std::vector<NBNode*> &junctions)
291 NBLoadedTLDef::SignalGroupCont::const_iterator i;
293 std::set<SUMOReal> tmpSwitchTimes;
306 for (std::vector<SUMOReal>::const_iterator k = gtimes.begin(); k != gtimes.end(); k++) {
307 tmpSwitchTimes.insert(*k);
310 std::vector<SUMOReal> switchTimes;
311 copy(tmpSwitchTimes.begin(), tmpSwitchTimes.end(), back_inserter(switchTimes));
312 sort(switchTimes.begin(), switchTimes.end());
315 unsigned int noSignals = 0;
317 noSignals += (*i).second->getLinkNo();
321 for (std::vector<SUMOReal>::iterator l = switchTimes.begin(); l != switchTimes.end(); l++) {
323 unsigned int duration;
324 if (l != switchTimes.end() - 1) {
326 duration = (
unsigned int)((*(l + 1)) - (*l));
347 unsigned int pos = 0;
350 unsigned int linkNo = group->
getLinkNo();
351 for (
unsigned int j = 0; j < linkNo; j++) {
371 unsigned int pos = 0;
378 unsigned int linkNo = group->
getLinkNo();
379 bool mayDrive = group->
mayDrive(time);
388 for (
unsigned int j = 0; j < linkNo; j++) {
392 if (assConn.
check(ec)) {
402 unsigned int linkNo = group->
getLinkNo();
403 for (
unsigned int j = 0; j < linkNo; j++) {
406 if (assConn.
check(ec)) {
407 if (!
mustBrake(ec, assConn, state, pos)) {
408 if (state[pos] ==
'g') {
411 if (state[pos] ==
'y') {
426 const std::string& state,
427 unsigned int strmpos)
const {
429 if (state[strmpos] !=
'g' && state[strmpos] !=
'G') {
435 unsigned int pos = 0;
439 unsigned int linkNo = group->
getLinkNo();
440 for (
unsigned int j = 0; j < linkNo; j++) {
445 if (possProhibitor.
check(ec)) {
451 if (state[pos] ==
'g' || state[pos] ==
'G') {
467 SignalGroupCont::const_iterator m;
470 unsigned int linkNo = group->
getLinkNo();
471 for (
unsigned int j = 0; j < linkNo; j++) {
489 for (
unsigned int j = 0; j < noLanes; j++) {
491 for (std::vector<NBEdge::Connection>::iterator k = elv.begin(); k != elv.end(); k++) {
505 if ((*i).second->containsConnection(from, to)) {
538 for (NBConnectionVector::const_iterator i = connections.begin(); i != connections.end(); i++) {
595 group->
remap(removed, removedLane, by, byLane);