61 #include <mesosim/MEInductLoop.h>
62 #include <mesosim/MELoop.h>
63 #include <mesosim/MESegment.h>
66 #ifdef CHECK_MEMORY_LEAKS
68 #endif // CHECK_MEMORY_LEAKS
79 SUMOTime haltingTimeThreshold,
int splInterval)
80 : myID(id), myDevice(device),
81 myHaltingSpeedThreshold(haltingSpeedThreshold),
82 myHaltingTimeThreshold(haltingTimeThreshold),
83 mySampleInterval(splInterval) {}
101 const std::string& lane,
SUMOReal pos,
int splInterval,
108 pos = getPositionChecking(pos, clane, friendlyPos,
id);
118 MESegment* s = MSGlobals::gMesoNet->getSegmentForEdge(clane->
getEdge());
121 while (cpos + prev->getLength() < pos && s != 0) {
123 cpos += s->getLength();
124 s = s->getNextSegment();
127 if (rpos > prev->getLength() || rpos < 0) {
129 rpos = prev->getLength() - (
SUMOReal) 0.1;
131 throw InvalidArgument(
"The position of detector '" +
id +
"' lies beyond the lane's '" + lane +
"' length.");
135 createMEInductLoop(
id, prev, rpos);
144 const std::string& lane,
SUMOReal pos,
149 pos = getPositionChecking(pos, clane, friendlyPos,
id);
160 bool cont,
int splInterval,
170 convUncontE2PosLength(
id, clane, pos, length, friendlyPos);
171 det = buildSingleLaneE2Det(
id,
DU_USER_DEFINED, clane, pos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold);
174 convContE2PosLength(
id, clane, pos, length, friendlyPos);
175 det = buildMultiLaneE2Det(
id,
DU_USER_DEFINED, clane, pos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold);
190 if (tlls.getActive() == 0) {
191 throw InvalidArgument(
"The detector '" +
id +
"' refers to the unknown lsa.");
197 convUncontE2PosLength(
id, clane, pos, length, friendlyPos);
198 det = buildSingleLaneE2Det(
id,
DU_USER_DEFINED, clane, pos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold);
201 convContE2PosLength(
id, clane, pos, length, friendlyPos);
202 det = buildMultiLaneE2Det(
id,
DU_USER_DEFINED, clane, pos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold);
215 const std::string& tolane,
220 if (tlls.getActive() == 0) {
221 throw InvalidArgument(
"The detector '" +
id +
"' refers to the unknown lsa.");
228 "The detector output can not be build as no connection between lanes '"
229 + lane +
"' and '" + tolane +
"' exists.");
237 convUncontE2PosLength(
id, clane, pos, length, friendlyPos);
238 det = buildSingleLaneE2Det(
id,
DU_USER_DEFINED, clane, pos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold);
241 convContE2PosLength(
id, clane, pos, length, friendlyPos);
242 det = buildMultiLaneE2Det(
id,
DU_USER_DEFINED, clane, pos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold);
255 pos = getPositionChecking(pos, clane, friendlyPos,
id);
258 length = clane->getLength() + length;
260 if (length + pos > clane->getLength()) {
262 length = clane->getLength() - pos - (
SUMOReal) 0.1;
264 throw InvalidArgument(
"The length of detector '" +
id +
"' lies beyond the lane's '" + clane->getID() +
"' length.");
271 throw InvalidArgument(
"The length of detector '" +
id +
"' is almost 0.");
282 pos = getPositionChecking(pos, clane, friendlyPos,
id);
293 myE3Definition =
new E3DetectorDefinition(
id, device, haltingSpeedThreshold, haltingTimeThreshold, splInterval);
300 if (myE3Definition == 0) {
305 pos = getPositionChecking(pos, clane, friendlyPos, myE3Definition->
myID);
314 if (myE3Definition == 0) {
319 pos = getPositionChecking(pos, clane, friendlyPos, myE3Definition->
myID);
352 const std::string& vtype,
SUMOTime frequency,
380 length, haltingTimeThreshold, haltingSpeedThreshold,
392 lane, pos, haltingTimeThreshold, haltingSpeedThreshold,
415 NLDetectorBuilder::createMEInductLoop(
const std::string&
id,
417 return new MEInductLoop(
id, s, pos);
426 return new MSE2Collector(
id, usage, lane, pos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold);
444 return new MSE3Collector(
id, entries, exits, haltingSpeedThreshold, haltingTimeThreshold);
453 pos = lane->getLength() + pos;
456 if (pos > lane->getLength()) {
458 pos = lane->getLength() - (
SUMOReal) 0.1;
460 throw InvalidArgument(
"The position of detector '" + detid +
"' lies beyond the lane's '" + lane->getID() +
"' length.");
467 throw InvalidArgument(
"The position of detector '" + detid +
"' lies beyond the lane's '" + lane->getID() +
"' length.");
477 const bool useLanes,
const bool withEmpty,
const bool printDefaults,
478 const bool withInternal,
const bool trackVehicles,
480 const SUMOReal haltSpeed,
const std::string& vTypes,
483 throw InvalidArgument(
"Negative begin time for meandata dump '" +
id +
"'.");
489 throw InvalidArgument(
"End before or at begin for meandata dump '" +
id +
"'.");
491 std::set<std::string> vt;
494 vt.insert(st.
next());
497 if (type ==
"" || type ==
"performance" || type ==
"traffic") {
499 printDefaults, withInternal, trackVehicles,
500 maxTravelTime, minSamples, haltSpeed, vt);
501 }
else if (type ==
"hbefa") {
503 printDefaults, withInternal, trackVehicles,
504 maxTravelTime, minSamples, vt);
505 }
else if (type ==
"harmonoise") {
507 printDefaults, withInternal, trackVehicles,
508 maxTravelTime, minSamples, vt);
510 throw InvalidArgument(
"Invalid type '" + type +
"' for meandata dump '" +
id +
"'.");
514 frequency = end - begin;
530 throw InvalidArgument(
"The lane with the id '" + edgeID +
"' is not known (while building " +
toString(type) +
" '" + detid +
"').");
542 throw InvalidArgument(
"The lane with the id '" + laneID +
"' is not known (while building " +
toString(type) +
" '" + detid +
"').");
550 if (splInterval < 0) {
553 if (splInterval == 0) {