Eclipse SUMO - Simulation of Urban MObility
NLDetectorBuilder.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2002-2022 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) :
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}
80
81
83
84
85/* -------------------------------------------------------------------------
86 * NLDetectorBuilder-methods
87 * ----------------------------------------------------------------------- */
89 : myNet(net), myE3Definition(nullptr) {}
90
91
93 delete myE3Definition;
94}
95
96
99 const std::string& lane, double pos, double length, SUMOTime splInterval,
100 const std::string& device, bool friendlyPos,
101 const std::string name,
102 const std::string& vTypes,
103 const std::string& nextEdges,
104 int detectPersons) {
106 // get and check the lane
107 MSLane* clane = getLaneChecking(lane, SUMO_TAG_E1DETECTOR, id);
108 // get and check the position
109 pos = getPositionChecking(pos, clane, friendlyPos, SUMO_TAG_E1DETECTOR, id);
110 if (length < 0) {
111 throw InvalidArgument("The length of " + toString(SUMO_TAG_E1DETECTOR) + " '" + id + "' cannot be negative");
112 } else if (length > 0 && pos + length > clane->getLength()) {
113 if (friendlyPos) {
114 length = MIN2(length, clane->getLength());
115 pos = clane->getLength() - length;
116 } else {
117 throw InvalidArgument("The length of " + toString(SUMO_TAG_E1DETECTOR) + " '" + id + "' puts it beyond the lane's '" + clane->getID() + "' end.");
118 }
119 }
120 // build the loop
121 MSDetectorFileOutput* loop = createInductLoop(id, clane, pos, length, name, vTypes, nextEdges, detectPersons, true);
122 // add the file output
123 myNet.getDetectorControl().add(SUMO_TAG_INDUCTION_LOOP, loop, device, splInterval);
124 return loop;
125}
126
127
130 const std::string& lane, double pos,
131 const std::string& device, bool friendlyPos,
132 const std::string name,
133 const std::string& vTypes,
134 const std::string& nextEdges) {
135 // get and check the lane
137 // get and check the position
138 pos = getPositionChecking(pos, clane, friendlyPos, SUMO_TAG_INSTANT_INDUCTION_LOOP, id);
139 // build the loop
140 MSDetectorFileOutput* loop = createInstantInductLoop(id, clane, pos, device, name, vTypes, nextEdges);
141 // add the file output
143 return loop;
144}
145
146
148NLDetectorBuilder::buildE2Detector(const std::string& id, MSLane* lane, double pos, double endPos, double length,
149 const std::string& device, SUMOTime frequency,
150 SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold,
151 const std::string name, const std::string& vTypes,
152 const std::string& nextEdges,
153 int detectPersons, bool friendlyPos, bool showDetector,
155
156 bool tlsGiven = tlls != nullptr;
157 bool toLaneGiven = toLane != nullptr;
158 bool posGiven = pos != std::numeric_limits<double>::max();
159 bool endPosGiven = endPos != std::numeric_limits<double>::max();
160
161 assert(posGiven || endPosGiven);
162
163 // Check positioning
164 if (posGiven) {
165 if (pos >= lane->getLength() || (pos < 0 && -pos > lane->getLength())) {
166 std::stringstream ss;
167 ss << "The given position (=" << pos << ") for detector '" << id
168 << "' does not lie on the given lane '" << lane->getID()
169 << "' with length " << lane->getLength();
170 if (friendlyPos) {
171 double newPos = pos > 0 ? lane->getLength() - POSITION_EPS : 0.;
172 ss << " (adjusting to new position " << newPos;
173 WRITE_WARNING(ss.str());
174 pos = newPos;
175 } else {
176 ss << " (0 <= pos < lane->getLength() is required)";
177 throw InvalidArgument(ss.str());
178 }
179 }
180 }
181 if (endPosGiven) {
182 if (endPos > lane->getLength() || (endPos <= 0 && -endPos >= lane->getLength())) {
183 std::stringstream ss;
184 ss << "The given end position (=" << endPos << ") for detector '" << id
185 << "' does not lie on the given lane '" << lane->getID()
186 << "' with length " << lane->getLength();
187 if (friendlyPos) {
188 double newEndPos = endPos > 0 ? lane->getLength() : POSITION_EPS;
189 ss << " (adjusting to new position " << newEndPos;
190 WRITE_WARNING(ss.str());
191 pos = newEndPos;
192 } else {
193 ss << " (0 <= pos < lane->getLength() is required)";
194 throw InvalidArgument(ss.str());
195 }
196 }
197 }
198
199 MSE2Collector* det = nullptr;
200 if (tlsGiven) {
201 // Detector connected to TLS
202 det = createE2Detector(id, DU_USER_DEFINED, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons, showDetector);
204 // add the file output (XXX: Where's the corresponding delete?)
205 if (toLaneGiven) {
206 // Detector also associated to specific link
207 const MSLane* const lastLane = det->getLastLane();
208 const MSLink* const link = lastLane->getLinkTo(toLane);
209 if (link == nullptr) {
210 throw InvalidArgument(
211 "The detector '" + id + "' cannot be build as no connection between lanes '"
212 + lastLane->getID() + "' and '" + toLane->getID() + "' exists.");
213 }
215 } else {
216 // detector for tls but without specific link
218 }
219 } else {
220 // User specified detector for xml-output
222 det = createE2Detector(id, DU_USER_DEFINED, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons, showDetector);
223 myNet.getDetectorControl().add(SUMO_TAG_LANE_AREA_DETECTOR, det, device, frequency);
224 }
225 return det;
226}
227
228
230NLDetectorBuilder::buildE2Detector(const std::string& id, std::vector<MSLane*> lanes, double pos, double endPos,
231 const std::string& device, SUMOTime frequency,
232 SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold,
233 const std::string name, const std::string& vTypes,
234 const std::string& nextEdges,
235 int detectPersons, bool friendlyPos, bool showDetector,
237
238 bool tlsGiven = tlls != nullptr;
239 bool toLaneGiven = toLane != nullptr;
240 assert(pos != std::numeric_limits<double>::max());
241 assert(endPos != std::numeric_limits<double>::max());
242 assert(lanes.size() != 0);
243
244 const MSLane* const firstLane = lanes[0];
245 const MSLane* const lastLane = lanes.back();
246
247 // Check positioning
248 if (pos >= firstLane->getLength() || (pos < 0 && -pos > firstLane->getLength())) {
249 std::stringstream ss;
250 ss << "The given position (=" << pos << ") for detector '" << id
251 << "' does not lie on the given lane '" << firstLane->getID()
252 << "' with length " << firstLane->getLength();
253 if (friendlyPos) {
254 double newPos = pos > 0 ? firstLane->getLength() - POSITION_EPS : 0.;
255 ss << " (adjusting to new position " << newPos;
256 WRITE_WARNING(ss.str());
257 pos = newPos;
258 } else {
259 ss << " (0 <= pos < lane->getLength() is required)";
260 throw InvalidArgument(ss.str());
261 }
262 }
263 if (endPos > lastLane->getLength() || (endPos <= 0 && -endPos >= lastLane->getLength())) {
264 std::stringstream ss;
265 ss << "The given end position (=" << endPos << ") for detector '" << id
266 << "' does not lie on the given lane '" << lastLane->getID()
267 << "' with length " << lastLane->getLength();
268 if (friendlyPos) {
269 double newEndPos = endPos > 0 ? lastLane->getLength() : POSITION_EPS;
270 ss << " (adjusting to new position " << newEndPos;
271 WRITE_WARNING(ss.str());
272 pos = newEndPos;
273 } else {
274 ss << " (0 <= pos < lane->getLength() is required)";
275 throw InvalidArgument(ss.str());
276 }
277 }
278
279 MSE2Collector* det = nullptr;
280 if (tlsGiven) {
281 // Detector connected to TLS
282 det = createE2Detector(id, DU_USER_DEFINED, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons, showDetector);
284 // add the file output (XXX: Where's the corresponding delete?)
285 if (toLaneGiven) {
286 // Detector also associated to specific link
287 const MSLane* const lastDetLane = det->getLastLane();
288 const MSLink* const link = lastDetLane->getLinkTo(toLane);
289 if (link == nullptr) {
290 throw InvalidArgument(
291 "The detector '" + id + "' cannot be build as no connection between lanes '"
292 + lastDetLane->getID() + "' and '" + toLane->getID() + "' exists.");
293 }
295 } else {
296 // detector for tls but without specific link
298 }
299 } else {
300 // User specified detector for xml-output
302
303 det = createE2Detector(id, DU_USER_DEFINED, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons, showDetector);
304 myNet.getDetectorControl().add(SUMO_TAG_LANE_AREA_DETECTOR, det, device, frequency);
305 }
306 return det;
307}
308
309
310
313 const std::string& device, SUMOTime splInterval,
314 double haltingSpeedThreshold,
315 SUMOTime haltingTimeThreshold,
316 const std::string name,
317 const std::string& vTypes,
318 const std::string& nextEdges,
319 int detectPersons, bool openEntry) {
321 myE3Definition = new E3DetectorDefinition(id, device, haltingSpeedThreshold, haltingTimeThreshold, splInterval, name, vTypes, nextEdges, detectPersons, openEntry);
322 return myE3Definition;
323}
324
325
326void
327NLDetectorBuilder::addE3Entry(const std::string& lane,
328 double pos, bool friendlyPos) {
329 if (myE3Definition == nullptr) {
330 return;
331 }
333 // get and check the position
334 pos = getPositionChecking(pos, clane, friendlyPos, SUMO_TAG_DET_ENTRY, myE3Definition->myID);
335 // build and save the entry
336 myE3Definition->myEntries.push_back(MSCrossSection(clane, pos));
337}
338
339
340void
341NLDetectorBuilder::addE3Exit(const std::string& lane,
342 double pos, bool friendlyPos) {
343 if (myE3Definition == nullptr) {
344 return;
345 }
347 // get and check the position
348 pos = getPositionChecking(pos, clane, friendlyPos, SUMO_TAG_DET_EXIT, myE3Definition->myID);
349 // build and save the exit
350 myE3Definition->myExits.push_back(MSCrossSection(clane, pos));
351}
352
353
354std::string
356 if (myE3Definition == nullptr) {
357 return "<unknown>";
358 }
359 return myE3Definition->myID;
360}
361
362
363void
365 if (myE3Definition == nullptr) {
366 return;
367 }
368 // If E3 own entry or exit detectors
369 if (myE3Definition->myEntries.size() > 0 || myE3Definition->myExits.size() > 0) {
370 // create E3 detector
380 // add to net
382 } else {
383 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)")
384 }
385 // clean up
386 delete myE3Definition;
387 myE3Definition = nullptr;
388}
389
390
391void
393 const std::string& vtype, SUMOTime frequency,
394 const std::string& device) {
396 new MSVTypeProbe(id, vtype, OutputDevice::getDevice(device), frequency);
397}
398
399
400void
401NLDetectorBuilder::buildRouteProbe(const std::string& id, const std::string& edge,
402 SUMOTime frequency, SUMOTime begin,
403 const std::string& device,
404 const std::string& vTypes) {
407 MSRouteProbe* probe = new MSRouteProbe(id, e, id + "_" + toString(begin), id + "_" + toString(begin - frequency), vTypes);
408 // add the file output
409 myNet.getDetectorControl().add(SUMO_TAG_ROUTEPROBE, probe, device, frequency, begin);
410}
411
412
415 MSLane* lane, double pos,
416 double length,
417 const std::string name,
418 const std::string& vTypes,
419 const std::string& nextEdges,
420 int detectPersons,
421 bool /*show*/) {
423 return new MEInductLoop(id, MSGlobals::gMesoNet->getSegmentForEdge(lane->getEdge(), pos), pos, name, vTypes, nextEdges, detectPersons);
424 }
425 return new MSInductLoop(id, lane, pos, length, name, vTypes, nextEdges, detectPersons, false);
426}
427
428
431 MSLane* lane, double pos, const std::string& od,
432 const std::string name, const std::string& vTypes,
433 const std::string& nextEdges) {
434 return new MSInstantInductLoop(id, OutputDevice::getDevice(od), lane, pos, name, vTypes, nextEdges);
435}
436
437
440 DetectorUsage usage, MSLane* lane, double pos, double endPos, double length,
441 SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold,
442 const std::string name, const std::string& vTypes,
443 const std::string& nextEdges,
444 int detectPersons, bool /* showDetector */) {
445 return new MSE2Collector(id, usage, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons);
446}
447
450 DetectorUsage usage, std::vector<MSLane*> lanes, double pos, double endPos,
451 SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold,
452 const std::string name, const std::string& vTypes,
453 const std::string& nextEdges,
454 int detectPersons, bool /* showDetector */) {
455 return new MSE2Collector(id, usage, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons);
456}
457
460 const CrossSectionVector& entries,
461 const CrossSectionVector& exits,
462 double haltingSpeedThreshold,
463 SUMOTime haltingTimeThreshold,
464 const std::string name, const std::string& vTypes,
465 const std::string& nextEdges,
466 int detectPersons,
467 bool openEntry) {
468 return new MSE3Collector(id, entries, exits, haltingSpeedThreshold, haltingTimeThreshold, name, vTypes, nextEdges, detectPersons, openEntry);
469}
470
471
472double
473NLDetectorBuilder::getPositionChecking(double pos, MSLane* lane, bool friendlyPos,
474 SumoXMLTag tag,
475 const std::string& detid) {
476 // check whether it is given from the end
477 if (pos < 0) {
478 pos += lane->getLength();
479 }
480 // check whether it is on the lane
481 if (pos > lane->getLength()) {
482 if (friendlyPos) {
483 pos = lane->getLength();
484 } else {
485 throw InvalidArgument("The position of " + toString(tag) + " '" + detid + "' lies beyond the lane's '" + lane->getID() + "' end.");
486 }
487 }
488 if (pos < 0) {
489 if (friendlyPos) {
490 pos = 0.;
491 } else {
492 throw InvalidArgument("The position of " + toString(tag) + " '" + detid + "' lies before the lane's '" + lane->getID() + "' begin.");
493 }
494 }
495 return pos;
496}
497
498
499void
501 SUMOTime begin, SUMOTime end, const std::string& type,
502 const bool useLanes, const bool withEmpty, const bool printDefaults,
503 const bool withInternal, const bool trackVehicles, const int detectPersons,
504 const double maxTravelTime, const double minSamples,
505 const double haltSpeed, const std::string& vTypes,
506 const std::string& writeAttributes,
507 std::vector<MSEdge*> edges,
508 bool aggregate,
509 const std::string& device) {
510 if (begin < 0) {
511 throw InvalidArgument("Negative begin time for meandata dump '" + id + "'.");
512 }
513 if (end < 0) {
514 end = SUMOTime_MAX;
515 }
516 if (end <= begin) {
517 throw InvalidArgument("End before or at begin for meandata dump '" + id + "'.");
518 }
519 checkStepLengthMultiple(begin, " for meandata dump '" + id + "'");
520 MSMeanData* det = nullptr;
521 if (type == "" || type == "performance" || type == "traffic") {
522 det = new MSMeanData_Net(id, begin, end, useLanes, withEmpty,
523 printDefaults, withInternal, trackVehicles, detectPersons, maxTravelTime, minSamples, haltSpeed, vTypes, writeAttributes, edges, aggregate);
524 } else if (type == "emissions" || type == "hbefa") {
525 if (type == "hbefa") {
526 WRITE_WARNING(TL("The netstate type 'hbefa' is deprecated. Please use the type 'emissions' instead."));
527 }
528 det = new MSMeanData_Emissions(id, begin, end, useLanes, withEmpty,
529 printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, vTypes, writeAttributes, edges, aggregate);
530 } else if (type == "harmonoise") {
531 det = new MSMeanData_Harmonoise(id, begin, end, useLanes, withEmpty,
532 printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, vTypes, writeAttributes, edges, aggregate);
533 } else if (type == "amitran") {
534 det = new MSMeanData_Amitran(id, begin, end, useLanes, withEmpty,
535 printDefaults, withInternal, trackVehicles, detectPersons, maxTravelTime, minSamples, haltSpeed, vTypes, writeAttributes, edges, aggregate);
536 } else {
537 throw InvalidArgument("Invalid type '" + type + "' for meandata dump '" + id + "'.");
538 }
539 if (det != nullptr) {
540 if (frequency < 0) {
541 frequency = end - begin;
542 } else {
543 checkStepLengthMultiple(frequency, " for meandata dump '" + id + "'");
544 }
545 MSNet::getInstance()->getDetectorControl().add(det, device, frequency, begin);
546 }
547}
548
549
550
551
552// ------ Value checking/adapting methods ------
553MSEdge*
554NLDetectorBuilder::getEdgeChecking(const std::string& edgeID, SumoXMLTag type,
555 const std::string& detid) {
556 // get and check the lane
557 MSEdge* edge = MSEdge::dictionary(edgeID);
558 if (edge == nullptr) {
559 throw InvalidArgument("The lane with the id '" + edgeID + "' is not known (while building " + toString(type) + " '" + detid + "').");
560 }
561 return edge;
562}
563
564
565MSLane*
566NLDetectorBuilder::getLaneChecking(const std::string& laneID, SumoXMLTag type,
567 const std::string& detid) {
568 // get and check the lane
569 MSLane* lane = MSLane::dictionary(laneID);
570 if (lane == nullptr) {
571 throw InvalidArgument("The lane with the id '" + laneID + "' is not known (while building " + toString(type) + " '" + detid + "').");
572 }
573 return lane;
574}
575
576
577void
578NLDetectorBuilder::checkSampleInterval(SUMOTime splInterval, SumoXMLTag type, const std::string& id) {
579 if (splInterval < 0) {
580 throw InvalidArgument("Negative sampling frequency (in " + toString(type) + " '" + id + "').");
581 }
582 if (splInterval == 0) {
583 throw InvalidArgument("Sampling frequency must not be zero (in " + toString(type) + " '" + id + "').");
584 }
585 checkStepLengthMultiple(splInterval, " (in " + toString(type) + " '" + id + "')");
586}
587
588
589/****************************************************************************/
long long int SUMOTime
Definition: GUI.h:36
std::vector< MSCrossSection > CrossSectionVector
@ DU_USER_DEFINED
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:265
#define TL(string)
Definition: MsgHandler.h:282
bool checkStepLengthMultiple(const SUMOTime t, const std::string &error, SUMOTime deltaT)
check if given SUMOTime is multiple of the step length
Definition: SUMOTime.cpp:123
#define SUMOTime_MAX
Definition: SUMOTime.h:33
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
T MIN2(T a, T b)
Definition: StdDefs.h:71
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
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.
Definition: MEInductLoop.h:45
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.
Definition: MSE2Collector.h:79
MSLane * getLastLane() const
Returns the id of the detector's last lane.
A detector of vehicles passing an area between entry/exit points.
Definition: MSE3Collector.h:59
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:945
static bool gUseMesoSim
Definition: MSGlobals.h:103
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition: MSGlobals.h:109
An unextended detector measuring at a fixed position on a fixed lane.
Definition: MSInductLoop.h:62
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:2428
double getLength() const
Returns the lane's length.
Definition: MSLane.h:575
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:2199
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:713
Network state mean data collector for edges/lanes.
Emission data collector for edges/lanes.
Noise data collector for edges/lanes.
Network state mean data collector for edges/lanes.
Data collector for edges/lanes.
Definition: MSMeanData.h:57
The simulated network and simulation perfomer.
Definition: MSNet.h:88
MSDetectorControl & getDetectorControl()
Returns the detector control.
Definition: MSNet.h:442
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:183
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:321
Writes routes of vehicles passing a certain edge.
Definition: MSRouteProbe.h:58
Storage for all programs of a single tls.
Writes positions of vehicles that have a certain (named) type.
Definition: MSVTypeProbe.h:50
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.
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)
Constructor.
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.
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.
void createEdgeLaneMeanData(const std::string &id, SUMOTime frequency, SUMOTime begin, SUMOTime end, const std::string &type, const bool useLanes, const bool withEmpty, const bool printDefaults, const bool withInternal, const bool trackVehicles, const int detectPersons, const double maxTravelTime, const double minSamples, const double haltSpeed, const std::string &vTypes, const std::string &writeAttributes, std::vector< MSEdge * > edges, bool aggregate, const std::string &device)
Creates edge based mean data collector using the given specification.
MSLane * getLaneChecking(const std::string &laneID, SumoXMLTag type, const std::string &detid)
Returns the named lane.
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)
Creates an instance of an e1 detector using the given values.
double getPositionChecking(double pos, MSLane *lane, bool friendlyPos, SumoXMLTag tag, const std::string &detid)
Computes the position to use.
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.
void addE3Exit(const std::string &lane, double pos, bool friendlyPos)
Builds an exit point of an e3 detector.
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)
Creates an instance of an e1 detector using the given values.
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 * 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)
Stores temporary the initial information about an e3 detector to build.
void addE3Entry(const std::string &lane, double pos, bool friendlyPos)
Builds an entry point of an e3 detector.
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)
Creates an instance of an e3 detector using the given values.
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, int detectPersons)
Builds an e1 detector and adds it to the net.
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)
Builds an instantenous induction and adds it to the net.
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...
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:74
static OutputDevice & getDevice(const std::string &name, bool usePrefix=true)
Returns the described OutputDevice.
An upper class for objects with additional parameters.
Definition: Parameterised.h:41
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.