Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
NLDetectorBuilder.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2002-2026 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
23// Builds detectors for microsim
24/****************************************************************************/
25#include <config.h>
26
27#include <string>
28#include <iostream>
29#include <microsim/MSNet.h>
30#include <microsim/MSLane.h>
31#include <microsim/MSEdge.h>
34// #include <microsim/output/MSMultiLaneE2Collector.h>
42#include <microsim/MSGlobals.h>
50#include "NLDetectorBuilder.h"
52
54#include <mesosim/MELoop.h>
55#include <mesosim/MESegment.h>
56
57
58// ===========================================================================
59// method definitions
60// ===========================================================================
61/* -------------------------------------------------------------------------
62 * NLDetectorBuilder::E3DetectorDefinition-methods
63 * ----------------------------------------------------------------------- */
65 const std::string& device, double haltingSpeedThreshold,
66 SUMOTime haltingTimeThreshold, SUMOTime splInterval,
67 const std::string name, const std::string& vTypes,
68 const std::string& nextEdges,
69 int detectPersons, bool openEntry, bool expectArrival) :
70 myID(id), myDevice(device),
71 myHaltingSpeedThreshold(haltingSpeedThreshold),
72 myHaltingTimeThreshold(haltingTimeThreshold),
73 mySampleInterval(splInterval),
74 myName(name),
75 myVehicleTypes(vTypes),
76 myNextEdges(nextEdges),
77 myDetectPersons(detectPersons),
78 myOpenEntry(openEntry),
79 myExpectArrival(expectArrival) {
80}
81
82
84
85
86/* -------------------------------------------------------------------------
87 * NLDetectorBuilder-methods
88 * ----------------------------------------------------------------------- */
91
92
96
97
100 const std::string& lane, double pos, double length, SUMOTime splInterval,
101 const std::string& device, bool friendlyPos,
102 const std::string name,
103 const std::string& vTypes,
104 const std::string& nextEdges,
105 bool mesoTLS,
106 int detectPersons) {
108 // get and check the lane
109 MSLane* clane = getLaneChecking(lane, SUMO_TAG_E1DETECTOR, id);
110 // get and check the position
111 pos = getPositionChecking(pos, clane, friendlyPos, SUMO_TAG_E1DETECTOR, id);
112 if (length < 0) {
113 throw InvalidArgument("The length of " + toString(SUMO_TAG_E1DETECTOR) + " '" + id + "' cannot be negative");
114 } else if (length > 0 && pos + length > clane->getLength()) {
115 if (friendlyPos) {
116 length = MIN2(length, clane->getLength());
117 pos = clane->getLength() - length;
118 } else {
119 throw InvalidArgument("The length of " + toString(SUMO_TAG_E1DETECTOR) + " '" + id + "' puts it beyond the lane's '" + clane->getID() + "' end.");
120 }
121 }
122 // build the loop
123 MSDetectorFileOutput* loop = createInductLoop(id, clane, pos, length, name, vTypes, nextEdges, detectPersons, true, mesoTLS);
124 // add the file output
125 myNet.getDetectorControl().add(SUMO_TAG_INDUCTION_LOOP, loop, device, splInterval);
126 return loop;
127}
128
129
132 const std::string& lane, double pos,
133 const std::string& device, bool friendlyPos,
134 const std::string name,
135 const std::string& vTypes,
136 const std::string& nextEdges,
137 int detectPersons) {
138 // get and check the lane
140 // get and check the position
141 pos = getPositionChecking(pos, clane, friendlyPos, SUMO_TAG_INSTANT_INDUCTION_LOOP, id);
142 // build the loop
143 MSDetectorFileOutput* loop = createInstantInductLoop(id, clane, pos, device, name, vTypes, nextEdges, detectPersons);
144 // add the file output
146 return loop;
147}
148
149
151NLDetectorBuilder::buildE2Detector(const std::string& id, MSLane* lane, double pos, double endPos, double length,
152 const std::string& device, SUMOTime frequency,
153 SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold,
154 const std::string name, const std::string& vTypes,
155 const std::string& nextEdges,
156 int detectPersons, bool friendlyPos, bool showDetector,
158
159 bool tlsGiven = tlls != nullptr;
160 bool toLaneGiven = toLane != nullptr;
161 bool posGiven = pos != std::numeric_limits<double>::max();
162 bool endPosGiven = endPos != std::numeric_limits<double>::max();
163
164 assert(posGiven || endPosGiven);
165
166 // Check positioning
167 if (posGiven) {
168 if (pos >= lane->getLength() || (pos < 0 && -pos > lane->getLength())) {
169 std::stringstream ss;
170 ss << "The given position (=" << pos << ") for detector '" << id
171 << "' does not lie on the given lane '" << lane->getID()
172 << "' with length " << lane->getLength();
173 if (friendlyPos) {
174 double newPos = pos > 0 ? lane->getLength() - POSITION_EPS : 0.;
175 ss << " (adjusting to new position " << newPos;
176 WRITE_WARNING(ss.str());
177 pos = newPos;
178 } else {
179 ss << " (0 <= pos < lane->getLength() is required)";
180 throw InvalidArgument(ss.str());
181 }
182 }
183 }
184 if (endPosGiven) {
185 if (endPos > lane->getLength() || (endPos <= 0 && -endPos >= lane->getLength())) {
186 std::stringstream ss;
187 ss << "The given end position (=" << endPos << ") for detector '" << id
188 << "' does not lie on the given lane '" << lane->getID()
189 << "' with length " << lane->getLength();
190 if (friendlyPos) {
191 double newEndPos = endPos > 0 ? lane->getLength() : POSITION_EPS;
192 ss << " (adjusting to new position " << newEndPos;
193 WRITE_WARNING(ss.str());
194 pos = newEndPos;
195 } else {
196 ss << " (0 <= pos < lane->getLength() is required)";
197 throw InvalidArgument(ss.str());
198 }
199 }
200 }
201
202 MSE2Collector* det = nullptr;
203 if (tlsGiven) {
204 // Detector connected to TLS
205 det = createE2Detector(id, DU_USER_DEFINED, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons, showDetector);
207 // add the file output (XXX: Where's the corresponding delete?)
208 if (toLaneGiven) {
209 // Detector also associated to specific link
210 const MSLane* const lastLane = det->getLastLane();
211 const MSLink* const link = lastLane->getLinkTo(toLane);
212 if (link == nullptr) {
213 throw InvalidArgument(
214 "The detector '" + id + "' cannot be build as no connection between lanes '"
215 + lastLane->getID() + "' and '" + toLane->getID() + "' exists.");
216 }
218 } else {
219 // detector for tls but without specific link
221 }
222 } else {
223 // User specified detector for xml-output
225 det = createE2Detector(id, DU_USER_DEFINED, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons, showDetector);
226 myNet.getDetectorControl().add(SUMO_TAG_LANE_AREA_DETECTOR, det, device, frequency);
227 }
228 return det;
229}
230
231
233NLDetectorBuilder::buildE2Detector(const std::string& id, std::vector<MSLane*> lanes, double pos, double endPos,
234 const std::string& device, SUMOTime frequency,
235 SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold,
236 const std::string name, const std::string& vTypes,
237 const std::string& nextEdges,
238 int detectPersons, bool friendlyPos, bool showDetector,
240
241 bool tlsGiven = tlls != nullptr;
242 bool toLaneGiven = toLane != nullptr;
243 assert(pos != std::numeric_limits<double>::max());
244 assert(endPos != std::numeric_limits<double>::max());
245 assert(lanes.size() != 0);
246
247 const MSLane* const firstLane = lanes[0];
248 const MSLane* const lastLane = lanes.back();
249
250 // Check positioning
251 if (pos >= firstLane->getLength() || (pos < 0 && -pos > firstLane->getLength())) {
252 std::stringstream ss;
253 ss << "The given position (=" << pos << ") for detector '" << id
254 << "' does not lie on the given lane '" << firstLane->getID()
255 << "' with length " << firstLane->getLength();
256 if (friendlyPos) {
257 double newPos = pos > 0 ? firstLane->getLength() - POSITION_EPS : 0.;
258 ss << " (adjusting to new position " << newPos;
259 WRITE_WARNING(ss.str());
260 pos = newPos;
261 } else {
262 ss << " (0 <= pos < lane->getLength() is required)";
263 throw InvalidArgument(ss.str());
264 }
265 }
266 if (endPos > lastLane->getLength() || (endPos <= 0 && -endPos >= lastLane->getLength())) {
267 std::stringstream ss;
268 ss << "The given end position (=" << endPos << ") for detector '" << id
269 << "' does not lie on the given lane '" << lastLane->getID()
270 << "' with length " << lastLane->getLength();
271 if (friendlyPos) {
272 double newEndPos = endPos > 0 ? lastLane->getLength() : POSITION_EPS;
273 ss << " (adjusting to new position " << newEndPos;
274 WRITE_WARNING(ss.str());
275 pos = newEndPos;
276 } else {
277 ss << " (0 <= pos < lane->getLength() is required)";
278 throw InvalidArgument(ss.str());
279 }
280 }
281
282 MSE2Collector* det = nullptr;
283 if (tlsGiven) {
284 // Detector connected to TLS
285 det = createE2Detector(id, DU_USER_DEFINED, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons, showDetector);
287 // add the file output (XXX: Where's the corresponding delete?)
288 if (toLaneGiven) {
289 // Detector also associated to specific link
290 const MSLane* const lastDetLane = det->getLastLane();
291 const MSLink* const link = lastDetLane->getLinkTo(toLane);
292 if (link == nullptr) {
293 throw InvalidArgument(
294 "The detector '" + id + "' cannot be build as no connection between lanes '"
295 + lastDetLane->getID() + "' and '" + toLane->getID() + "' exists.");
296 }
298 } else {
299 // detector for tls but without specific link
301 }
302 } else {
303 // User specified detector for xml-output
305
306 det = createE2Detector(id, DU_USER_DEFINED, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons, showDetector);
307 myNet.getDetectorControl().add(SUMO_TAG_LANE_AREA_DETECTOR, det, device, frequency);
308 }
309 return det;
310}
311
312
313
316 const std::string& device, SUMOTime splInterval,
317 double haltingSpeedThreshold,
318 SUMOTime haltingTimeThreshold,
319 const std::string name,
320 const std::string& vTypes,
321 const std::string& nextEdges,
322 int detectPersons, bool openEntry, bool expectArrival) {
324 myE3Definition = new E3DetectorDefinition(id, device, haltingSpeedThreshold, haltingTimeThreshold, splInterval, name, vTypes, nextEdges, detectPersons, openEntry, expectArrival);
325 return myE3Definition;
326}
327
328
329void
330NLDetectorBuilder::addE3Entry(const std::string& lane,
331 double pos, bool friendlyPos) {
332 if (myE3Definition == nullptr) {
333 return;
334 }
336 // get and check the position
337 pos = getPositionChecking(pos, clane, friendlyPos, SUMO_TAG_DET_ENTRY, myE3Definition->myID);
338 // build and save the entry
339 myE3Definition->myEntries.push_back(MSCrossSection(clane, pos));
340}
341
342
343void
344NLDetectorBuilder::addE3Exit(const std::string& lane,
345 double pos, bool friendlyPos) {
346 if (myE3Definition == nullptr) {
347 return;
348 }
350 // get and check the position
351 pos = getPositionChecking(pos, clane, friendlyPos, SUMO_TAG_DET_EXIT, myE3Definition->myID);
352 // build and save the exit
353 myE3Definition->myExits.push_back(MSCrossSection(clane, pos));
354}
355
356
357std::string
359 if (myE3Definition == nullptr) {
360 return "<unknown>";
361 }
362 return myE3Definition->myID;
363}
364
365
366void
368 if (myE3Definition == nullptr) {
369 return;
370 }
371 // If E3 own entry or exit detectors
372 if (myE3Definition->myEntries.size() > 0 || myE3Definition->myExits.size() > 0) {
373 // create E3 detector
384 // add to net
386 } else {
387 WRITE_WARNING(toString(SUMO_TAG_E3DETECTOR) + " with id = '" + myE3Definition->myID + "' will not be created because is empty (no " + toString(SUMO_TAG_DET_ENTRY) + " or " + toString(SUMO_TAG_DET_EXIT) + " was defined)")
388 }
389 // clean up
390 delete myE3Definition;
391 myE3Definition = nullptr;
392}
393
394
395void
397 const std::string& vtype, SUMOTime frequency,
398 const std::string& device) {
400 new MSVTypeProbe(id, vtype, OutputDevice::getDevice(device), frequency);
401}
402
403
404void
405NLDetectorBuilder::buildRouteProbe(const std::string& id, const std::string& edge,
406 SUMOTime frequency, SUMOTime begin,
407 const std::string& device,
408 const std::string& vTypes) {
411 MSRouteProbe* probe = new MSRouteProbe(id, e, id + "_" + toString(begin), id + "_" + toString(begin - frequency), vTypes);
412 // add the file output
413 myNet.getDetectorControl().add(SUMO_TAG_ROUTEPROBE, probe, device, frequency, begin);
414}
415
416
419 MSLane* lane, double pos,
420 double length,
421 const std::string name,
422 const std::string& vTypes,
423 const std::string& nextEdges,
424 int detectPersons,
425 bool /*show*/,
426 bool forceMicro) {
427 if (MSGlobals::gUseMesoSim && !forceMicro) {
428 return new MEInductLoop(id, MSGlobals::gMesoNet->getSegmentForEdge(lane->getEdge(), pos), pos, name, vTypes, nextEdges, detectPersons);
429 }
430 return new MSInductLoop(id, lane, pos, length, name, vTypes, nextEdges, detectPersons, false);
431}
432
433
436 MSLane* lane, double pos, const std::string& od,
437 const std::string name, const std::string& vTypes,
438 const std::string& nextEdges,
439 int detectPersons) {
440 return new MSInstantInductLoop(id, OutputDevice::getDevice(od), lane, pos, name, vTypes, nextEdges, detectPersons);
441}
442
443
446 DetectorUsage usage, MSLane* lane, double pos, double endPos, double length,
447 SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold,
448 const std::string name, const std::string& vTypes,
449 const std::string& nextEdges,
450 int detectPersons, bool /* showDetector */) {
451 return new MSE2Collector(id, usage, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons);
452}
453
456 DetectorUsage usage, std::vector<MSLane*> lanes, double pos, double endPos,
457 SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold,
458 const std::string name, const std::string& vTypes,
459 const std::string& nextEdges,
460 int detectPersons, bool /* showDetector */) {
461 return new MSE2Collector(id, usage, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons);
462}
463
466 const CrossSectionVector& entries,
467 const CrossSectionVector& exits,
468 double haltingSpeedThreshold,
469 SUMOTime haltingTimeThreshold,
470 const std::string name, const std::string& vTypes,
471 const std::string& nextEdges,
472 int detectPersons,
473 bool openEntry,
474 bool expectArrival) {
475 return new MSE3Collector(id, entries, exits, haltingSpeedThreshold, haltingTimeThreshold, name, vTypes, nextEdges, detectPersons, openEntry, expectArrival);
476}
477
478
479double
480NLDetectorBuilder::getPositionChecking(double pos, MSLane* lane, bool friendlyPos,
481 SumoXMLTag tag,
482 const std::string& detid) {
483 // check whether it is given from the end
484 if (pos < 0) {
485 pos += lane->getLength();
486 }
487 // check whether it is on the lane
488 if (pos > lane->getLength()) {
489 if (friendlyPos) {
490 pos = lane->getLength();
491 } else {
492 throw InvalidArgument("The position of " + toString(tag) + " '" + detid + "' lies beyond the lane's '" + lane->getID() + "' end.");
493 }
494 }
495 if (pos < 0) {
496 if (friendlyPos) {
497 pos = 0.;
498 } else {
499 throw InvalidArgument("The position of " + toString(tag) + " '" + detid + "' lies before the lane's '" + lane->getID() + "' begin.");
500 }
501 }
502 return pos;
503}
504
505
506void
508 SUMOTime begin, SUMOTime end, const std::string& type,
509 const bool useLanes, const std::string& excludeEmpty,
510 const bool withInternal, const bool trackVehicles, const int detectPersons,
511 const double maxTravelTime, const double minSamples,
512 const double haltSpeed, const double haltSpeedRel, const std::string& vTypes,
513 const std::string& writeAttributes,
514 std::vector<MSEdge*> edges,
515 AggregateType aggregate,
516 const std::string& device) {
517 if (begin < 0) {
518 throw InvalidArgument("Negative begin time for meandata dump '" + id + "'.");
519 }
520 if (end < 0) {
521 end = SUMOTime_MAX;
522 }
523 if (end <= begin) {
524 throw InvalidArgument("End before or at begin for meandata dump '" + id + "'.");
525 }
526 checkStepLengthMultiple(begin, " for meandata dump '" + id + "'");
527 std::vector<MeanDataType> types;
529 const SumoXMLAttrMask attrs = OutputDevice::parseWrittenAttributes(StringTokenizer(writeAttributes).getVector(), "meandata '" + id + "'");
530 if (attrs.none()) {
531 types.push_back(MeanDataType::TRAFFIC);
532 } else {
533 if (MSMeanData_Net::supports(attrs)) {
534 types.push_back(MeanDataType::TRAFFIC);
535 }
537 types.push_back(MeanDataType::EMISSIONS);
538 }
540 types.push_back(MeanDataType::HARMONOISE);
541 }
542 }
543 } else {
544 for (const std::string& t : StringTokenizer(type).getVector()) {
545 if (SUMOXMLDefinitions::MeanDataTypes.hasString(t)) {
546 types.push_back(SUMOXMLDefinitions::MeanDataTypes.get(t));
547 } else if (t == "performance") {
548 types.push_back(MeanDataType::TRAFFIC);
549 } else if (t == "hbefa") {
550 WRITE_WARNING(TL("The meandata type 'hbefa' is deprecated. Please use the type 'emissions' instead."));
551 types.push_back(MeanDataType::EMISSIONS);
552 } else {
553 throw InvalidArgument("Invalid type '" + t + "' for meandata dump '" + id + "'.");
554 }
555 }
556 }
557 if (frequency < 0) {
558 frequency = end - begin;
559 } else {
560 checkStepLengthMultiple(frequency, " for meandata dump '" + id + "'");
561 }
562 MSMeanData* first = nullptr;
563 MSMeanData* parent = nullptr;
564 for (const MeanDataType t : types) {
565 MSMeanData* det = nullptr;
566 if (t == MeanDataType::TRAFFIC) {
567 det = new MSMeanData_Net(id, begin, end, useLanes, excludeEmpty,
568 withInternal, trackVehicles, detectPersons, maxTravelTime, minSamples, haltSpeed, haltSpeedRel, vTypes, writeAttributes, edges, aggregate);
569 } else if (t == MeanDataType::EMISSIONS) {
570 det = new MSMeanData_Emissions(id, begin, end, useLanes, excludeEmpty,
571 withInternal, trackVehicles, maxTravelTime, minSamples, vTypes, writeAttributes, edges, aggregate);
572 } else if (t == MeanDataType::HARMONOISE) {
573 det = new MSMeanData_Harmonoise(id, begin, end, useLanes, excludeEmpty,
574 withInternal, trackVehicles, maxTravelTime, minSamples, vTypes, writeAttributes, edges, aggregate);
575 } else if (t == MeanDataType::AMITRAN) {
576 det = new MSMeanData_Amitran(id, begin, end, useLanes, excludeEmpty,
577 withInternal, trackVehicles, detectPersons, maxTravelTime, minSamples, haltSpeed, vTypes, writeAttributes, edges, aggregate);
578 }
579 if (det != nullptr) {
580 if (first == nullptr) {
581 first = det;
582 }
583 if (parent != nullptr) {
584 parent->setSubData(det);
585 }
586 parent = det;
587 }
588 }
589 if (first != nullptr) {
590 // needs to be delayed because it might call init for the subdata
591 MSNet::getInstance()->getDetectorControl().add(first, device, frequency, begin);
592 }
593}
594
595
596
597
598// ------ Value checking/adapting methods ------
599MSEdge*
600NLDetectorBuilder::getEdgeChecking(const std::string& edgeID, SumoXMLTag type,
601 const std::string& detid) {
602 // get and check the lane
603 MSEdge* edge = MSEdge::dictionary(edgeID);
604 if (edge == nullptr) {
605 throw InvalidArgument("The lane with the id '" + edgeID + "' is not known (while building " + toString(type) + " '" + detid + "').");
606 }
607 return edge;
608}
609
610
611MSLane*
612NLDetectorBuilder::getLaneChecking(const std::string& laneID, SumoXMLTag type,
613 const std::string& detid) {
614 // get and check the lane
615 MSLane* lane = MSLane::dictionary(laneID);
616 if (lane == nullptr) {
617 throw InvalidArgument("The lane with the id '" + laneID + "' is not known (while building " + toString(type) + " '" + detid + "').");
618 }
619 return lane;
620}
621
622
623void
624NLDetectorBuilder::checkSampleInterval(SUMOTime splInterval, SumoXMLTag type, const std::string& id) {
625 if (splInterval < 0) {
626 throw InvalidArgument("Negative sampling frequency (in " + toString(type) + " '" + id + "').");
627 }
628 if (splInterval == 0) {
629 throw InvalidArgument("Sampling frequency must not be zero (in " + toString(type) + " '" + id + "').");
630 }
631 checkStepLengthMultiple(splInterval, " (in " + toString(type) + " '" + id + "')");
632}
633
634
635/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
std::vector< MSCrossSection > CrossSectionVector
@ DU_USER_DEFINED
#define WRITE_WARNING(msg)
Definition MsgHandler.h:286
#define TL(string)
Definition MsgHandler.h:304
bool checkStepLengthMultiple(const SUMOTime t, const std::string &error, SUMOTime deltaT, SUMOTime begin)
check if given SUMOTime is multiple of the step length
Definition SUMOTime.cpp:158
#define SUMOTime_MAX
Definition SUMOTime.h:34
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_ROUTEPROBE
a routeprobe detector
@ SUMO_TAG_E2DETECTOR
an e2 detector
@ SUMO_TAG_DET_ENTRY
an e3 entry point
@ SUMO_TAG_VTYPEPROBE
a vtypeprobe detector
@ SUMO_TAG_INSTANT_INDUCTION_LOOP
An instantenous induction loop.
@ SUMO_TAG_E1DETECTOR
an e1 detector
@ SUMO_TAG_DET_EXIT
an e3 exit point
@ SUMO_TAG_LANE_AREA_DETECTOR
alternative tag for e2 detector
@ SUMO_TAG_INDUCTION_LOOP
alternative tag for e1 detector
@ SUMO_TAG_ENTRY_EXIT_DETECTOR
alternative tag for e3 detector
@ SUMO_TAG_E3DETECTOR
an e3 detector
std::bitset< 96 > SumoXMLAttrMask
AggregateType
Numbers representing special SUMO-XML-attribute values Information on edgeData/laneData output should...
T MIN2(T a, T b)
Definition StdDefs.h:80
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:49
Writes e2 state on each tls switch.
Writes e2 state of a link for the time the link has yellow/red.
An induction loop for mesoscopic simulation.
A simple description of a position on a lane (crossing of a lane)
void add(SumoXMLTag type, MSDetectorFileOutput *d, const std::string &device, SUMOTime interval, SUMOTime begin=-1)
Adds a detector/output combination into the containers.
Base of value-generating classes (detectors)
An areal detector corresponding to a sequence of consecutive lanes.
MSLane * getLastLane() const
Returns the id of the detector's last lane.
A detector of vehicles passing an area between entry/exit points.
A road/street connecting two junctions.
Definition MSEdge.h:77
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary....
Definition MSEdge.cpp:1089
static bool gUseMesoSim
Definition MSGlobals.h:106
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition MSGlobals.h:115
An unextended detector measuring at a fixed position on a fixed lane.
An instantaneous induction loop.
Representation of a lane in the micro simulation.
Definition MSLane.h:84
const MSLink * getLinkTo(const MSLane *const) const
returns the link to the given lane or nullptr, if it is not connected
Definition MSLane.cpp:2791
double getLength() const
Returns the lane's length.
Definition MSLane.h:632
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition MSLane.cpp:2528
MSEdge & getEdge() const
Returns the lane's edge.
Definition MSLane.h:790
Network state mean data collector for edges/lanes.
Emission data collector for edges/lanes.
static bool supports(const SumoXMLAttrMask &attributeMask)
check whether any of the given attributes can be calculated by this meandata
Noise data collector for edges/lanes.
static bool supports(const SumoXMLAttrMask &attributeMask)
check whether any of the given attributes can be calculated by this meandata
Network state mean data collector for edges/lanes.
static bool supports(const SumoXMLAttrMask &attributeMask)
check whether any of the given attributes can be calculated by this meandata
Data collector for edges/lanes.
Definition MSMeanData.h:57
void setSubData(MSMeanData *subData)
set a sub collector
Definition MSMeanData.h:405
The simulated network and simulation perfomer.
Definition MSNet.h:89
MSDetectorControl & getDetectorControl()
Returns the detector control.
Definition MSNet.h:465
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition MSNet.cpp:199
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition MSNet.h:334
Writes routes of vehicles passing a certain edge.
Storage for all programs of a single tls.
Writes positions of vehicles that have a certain (named) type.
Holds the incoming definitions of an e3 detector unless the detector is build.
const std::string myVehicleTypes
The types to filter.
CrossSectionVector myEntries
List of detector's entries.
const std::string myID
The id of the detector.
SUMOTime mySampleInterval
The aggregation interval.
bool myOpenEntry
Whether the detector is declared as having incomplete entry detectors.
const std::string myNextEdges
The route edges to filter by.
double myHaltingSpeedThreshold
The speed a vehicle's speed must be below to be assigned as jammed.
E3DetectorDefinition(const std::string &id, const std::string &device, double haltingSpeedThreshold, SUMOTime haltingTimeThreshold, SUMOTime splInterval, const std::string name, const std::string &vTypes, const std::string &nextEdges, int detectPersons, bool openEntry, bool expectArrival)
Constructor.
bool myExpectArrival
Whether the detector expects vehicles to arrive inside (and doesn't issue a warning in this case)
const std::string myDevice
The device the detector shall use.
SUMOTime myHaltingTimeThreshold
The time a vehicle's speed must be below haltingSpeedThreshold to be assigned as jammed.
CrossSectionVector myExits
List of detector's exits.
void checkSampleInterval(SUMOTime splInterval, SumoXMLTag type, const std::string &id)
Checks whether the given frequency (sample interval) is valid.
void endE3Detector()
Builds of an e3 detector using collected values.
MSNet & myNet
The net to fill.
MSLane * getLaneChecking(const std::string &laneID, SumoXMLTag type, const std::string &detid)
Returns the named lane.
void createEdgeLaneMeanData(const std::string &id, SUMOTime frequency, SUMOTime begin, SUMOTime end, const std::string &type, const bool useLanes, const std::string &excludeEmpty, const bool withInternal, const bool trackVehicles, const int detectPersons, const double maxTravelTime, const double minSamples, const double haltSpeed, const double haltSpeedRel, const std::string &vTypes, const std::string &writeAttributes, std::vector< MSEdge * > edges, AggregateType aggregate, const std::string &device)
Creates edge based mean data collector using the given specification.
double getPositionChecking(double pos, MSLane *lane, bool friendlyPos, SumoXMLTag tag, const std::string &detid)
Computes the position to use.
Parameterised * buildInstantInductLoop(const std::string &id, const std::string &lane, double pos, const std::string &device, bool friendlyPos, const std::string name, const std::string &vTypes, const std::string &nextEdges, int detectPersons)
Builds an instantenous induction and adds it to the net.
virtual MSE2Collector * createE2Detector(const std::string &id, DetectorUsage usage, MSLane *lane, double pos, double endPos, double length, SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold, const std::string name, const std::string &vTypes, const std::string &nextEdges, int detectPersons, bool showDetector)
Creates a MSE2Collector instance, overridden by GUIE2Collector::createE2Detector()
void buildVTypeProbe(const std::string &id, const std::string &vtype, SUMOTime frequency, const std::string &device)
Builds a vTypeProbe and adds it to the net.
virtual MSDetectorFileOutput * createInductLoop(const std::string &id, MSLane *lane, double pos, double length, const std::string name, const std::string &vTypes, const std::string &nextEdges, int detectPersons, bool show, bool forceMicro=false)
Creates an instance of an e1 detector using the given values.
void addE3Exit(const std::string &lane, double pos, bool friendlyPos)
Builds an exit point of an e3 detector.
virtual ~NLDetectorBuilder()
Destructor.
MSEdge * getEdgeChecking(const std::string &edgeID, SumoXMLTag type, const std::string &detid)
Returns the named edge.
void buildRouteProbe(const std::string &id, const std::string &edge, SUMOTime frequency, SUMOTime begin, const std::string &device, const std::string &vTypes)
Builds a routeProbe and adds it to the net.
Parameterised * buildInductLoop(const std::string &id, const std::string &lane, double pos, double length, SUMOTime splInterval, const std::string &device, bool friendlyPos, const std::string name, const std::string &vTypes, const std::string &nextEdges, bool mesoTLS, int detectPersons)
Builds an e1 detector and adds it to the net.
virtual MSDetectorFileOutput * createE3Detector(const std::string &id, const CrossSectionVector &entries, const CrossSectionVector &exits, double haltingSpeedThreshold, SUMOTime haltingTimeThreshold, const std::string name, const std::string &vTypes, const std::string &nextEdges, int detectPersons, bool openEntry, bool expectArrival)
Creates an instance of an e3 detector using the given values.
void addE3Entry(const std::string &lane, double pos, bool friendlyPos)
Builds an entry point of an e3 detector.
virtual MSDetectorFileOutput * createInstantInductLoop(const std::string &id, MSLane *lane, double pos, const std::string &od, const std::string name, const std::string &vTypes, const std::string &nextEdges, int detectPersons)
Creates an instance of an e1 detector using the given values.
Parameterised * buildE2Detector(const std::string &id, MSLane *lane, double pos, double endPos, double length, const std::string &device, SUMOTime frequency, SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold, const std::string name, const std::string &vTypes, const std::string &nextEdges, int detectPersons, bool friendlyPos, bool showDetector, MSTLLogicControl::TLSLogicVariants *tlls=0, MSLane *toLane=0)
Builds a new E2 detector and adds it to the net's detector control. Also performs some consistency ch...
Parameterised * beginE3Detector(const std::string &id, const std::string &device, SUMOTime splInterval, double haltingSpeedThreshold, SUMOTime haltingTimeThreshold, const std::string name, const std::string &vTypes, const std::string &nextEdges, int detectPersons, bool openEntry, bool expectArrival)
Stores temporary the initial information about an e3 detector to build.
E3DetectorDefinition * myE3Definition
definition of the currently parsed e3 detector
std::string getCurrentE3ID() const
Returns the id of the currently built e3 detector.
NLDetectorBuilder(MSNet &net)
Constructor.
const std::string & getID() const
Returns the id.
Definition Named.h:73
static const SumoXMLAttrMask parseWrittenAttributes(const std::vector< std::string > &attrList, const std::string &desc, const std::map< std::string, SumoXMLAttrMask > &special=std::map< std::string, SumoXMLAttrMask >())
Parses a list of strings for attribute names and sets the relevant bits in the returned mask.
static OutputDevice & getDevice(const std::string &name, bool usePrefix=true)
Returns the described OutputDevice.
An upper class for objects with additional parameters.
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
void updateParameters(const Parameterised::Map &mapArg)
Adds or updates all given parameters from the map.
static StringBijection< MeanDataType > MeanDataTypes
reference positions (used creating certain elements in netedit)
std::vector< std::string > getVector()
return vector of strings