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-2023 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
83
85
86
87/* -------------------------------------------------------------------------
88 * NLDetectorBuilder-methods
89 * ----------------------------------------------------------------------- */
92
93
97
98
101 const std::string& lane, double pos, double length, SUMOTime splInterval,
102 const std::string& device, bool friendlyPos,
103 const std::string name,
104 const std::string& vTypes,
105 const std::string& nextEdges,
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);
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 // get and check the lane
139 // get and check the position
140 pos = getPositionChecking(pos, clane, friendlyPos, SUMO_TAG_INSTANT_INDUCTION_LOOP, id);
141 // build the loop
142 MSDetectorFileOutput* loop = createInstantInductLoop(id, clane, pos, device, name, vTypes, nextEdges);
143 // add the file output
145 return loop;
146}
147
148
150NLDetectorBuilder::buildE2Detector(const std::string& id, MSLane* lane, double pos, double endPos, double length,
151 const std::string& device, SUMOTime frequency,
152 SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold,
153 const std::string name, const std::string& vTypes,
154 const std::string& nextEdges,
155 int detectPersons, bool friendlyPos, bool showDetector,
157
158 bool tlsGiven = tlls != nullptr;
159 bool toLaneGiven = toLane != nullptr;
160 bool posGiven = pos != std::numeric_limits<double>::max();
161 bool endPosGiven = endPos != std::numeric_limits<double>::max();
162
163 assert(posGiven || endPosGiven);
164
165 // Check positioning
166 if (posGiven) {
167 if (pos >= lane->getLength() || (pos < 0 && -pos > lane->getLength())) {
168 std::stringstream ss;
169 ss << "The given position (=" << pos << ") for detector '" << id
170 << "' does not lie on the given lane '" << lane->getID()
171 << "' with length " << lane->getLength();
172 if (friendlyPos) {
173 double newPos = pos > 0 ? lane->getLength() - POSITION_EPS : 0.;
174 ss << " (adjusting to new position " << newPos;
175 WRITE_WARNING(ss.str());
176 pos = newPos;
177 } else {
178 ss << " (0 <= pos < lane->getLength() is required)";
179 throw InvalidArgument(ss.str());
180 }
181 }
182 }
183 if (endPosGiven) {
184 if (endPos > lane->getLength() || (endPos <= 0 && -endPos >= lane->getLength())) {
185 std::stringstream ss;
186 ss << "The given end position (=" << endPos << ") for detector '" << id
187 << "' does not lie on the given lane '" << lane->getID()
188 << "' with length " << lane->getLength();
189 if (friendlyPos) {
190 double newEndPos = endPos > 0 ? lane->getLength() : POSITION_EPS;
191 ss << " (adjusting to new position " << newEndPos;
192 WRITE_WARNING(ss.str());
193 pos = newEndPos;
194 } else {
195 ss << " (0 <= pos < lane->getLength() is required)";
196 throw InvalidArgument(ss.str());
197 }
198 }
199 }
200
201 MSE2Collector* det = nullptr;
202 if (tlsGiven) {
203 // Detector connected to TLS
204 det = createE2Detector(id, DU_USER_DEFINED, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons, showDetector);
206 // add the file output (XXX: Where's the corresponding delete?)
207 if (toLaneGiven) {
208 // Detector also associated to specific link
209 const MSLane* const lastLane = det->getLastLane();
210 const MSLink* const link = lastLane->getLinkTo(toLane);
211 if (link == nullptr) {
212 throw InvalidArgument(
213 "The detector '" + id + "' cannot be build as no connection between lanes '"
214 + lastLane->getID() + "' and '" + toLane->getID() + "' exists.");
215 }
217 } else {
218 // detector for tls but without specific link
220 }
221 } else {
222 // User specified detector for xml-output
224 det = createE2Detector(id, DU_USER_DEFINED, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons, showDetector);
225 myNet.getDetectorControl().add(SUMO_TAG_LANE_AREA_DETECTOR, det, device, frequency);
226 }
227 return det;
228}
229
230
232NLDetectorBuilder::buildE2Detector(const std::string& id, std::vector<MSLane*> lanes, double pos, double endPos,
233 const std::string& device, SUMOTime frequency,
234 SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold,
235 const std::string name, const std::string& vTypes,
236 const std::string& nextEdges,
237 int detectPersons, bool friendlyPos, bool showDetector,
239
240 bool tlsGiven = tlls != nullptr;
241 bool toLaneGiven = toLane != nullptr;
242 assert(pos != std::numeric_limits<double>::max());
243 assert(endPos != std::numeric_limits<double>::max());
244 assert(lanes.size() != 0);
245
246 const MSLane* const firstLane = lanes[0];
247 const MSLane* const lastLane = lanes.back();
248
249 // Check positioning
250 if (pos >= firstLane->getLength() || (pos < 0 && -pos > firstLane->getLength())) {
251 std::stringstream ss;
252 ss << "The given position (=" << pos << ") for detector '" << id
253 << "' does not lie on the given lane '" << firstLane->getID()
254 << "' with length " << firstLane->getLength();
255 if (friendlyPos) {
256 double newPos = pos > 0 ? firstLane->getLength() - POSITION_EPS : 0.;
257 ss << " (adjusting to new position " << newPos;
258 WRITE_WARNING(ss.str());
259 pos = newPos;
260 } else {
261 ss << " (0 <= pos < lane->getLength() is required)";
262 throw InvalidArgument(ss.str());
263 }
264 }
265 if (endPos > lastLane->getLength() || (endPos <= 0 && -endPos >= lastLane->getLength())) {
266 std::stringstream ss;
267 ss << "The given end position (=" << endPos << ") for detector '" << id
268 << "' does not lie on the given lane '" << lastLane->getID()
269 << "' with length " << lastLane->getLength();
270 if (friendlyPos) {
271 double newEndPos = endPos > 0 ? lastLane->getLength() : POSITION_EPS;
272 ss << " (adjusting to new position " << newEndPos;
273 WRITE_WARNING(ss.str());
274 pos = newEndPos;
275 } else {
276 ss << " (0 <= pos < lane->getLength() is required)";
277 throw InvalidArgument(ss.str());
278 }
279 }
280
281 MSE2Collector* det = nullptr;
282 if (tlsGiven) {
283 // Detector connected to TLS
284 det = createE2Detector(id, DU_USER_DEFINED, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons, showDetector);
286 // add the file output (XXX: Where's the corresponding delete?)
287 if (toLaneGiven) {
288 // Detector also associated to specific link
289 const MSLane* const lastDetLane = det->getLastLane();
290 const MSLink* const link = lastDetLane->getLinkTo(toLane);
291 if (link == nullptr) {
292 throw InvalidArgument(
293 "The detector '" + id + "' cannot be build as no connection between lanes '"
294 + lastDetLane->getID() + "' and '" + toLane->getID() + "' exists.");
295 }
297 } else {
298 // detector for tls but without specific link
300 }
301 } else {
302 // User specified detector for xml-output
304
305 det = createE2Detector(id, DU_USER_DEFINED, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons, showDetector);
306 myNet.getDetectorControl().add(SUMO_TAG_LANE_AREA_DETECTOR, det, device, frequency);
307 }
308 return det;
309}
310
311
312
315 const std::string& device, SUMOTime splInterval,
316 double haltingSpeedThreshold,
317 SUMOTime haltingTimeThreshold,
318 const std::string name,
319 const std::string& vTypes,
320 const std::string& nextEdges,
321 int detectPersons, bool openEntry, bool expectArrival) {
323 myE3Definition = new E3DetectorDefinition(id, device, haltingSpeedThreshold, haltingTimeThreshold, splInterval, name, vTypes, nextEdges, detectPersons, openEntry, expectArrival);
324 return myE3Definition;
325}
326
327
328void
329NLDetectorBuilder::addE3Entry(const std::string& lane,
330 double pos, bool friendlyPos) {
331 if (myE3Definition == nullptr) {
332 return;
333 }
335 // get and check the position
336 pos = getPositionChecking(pos, clane, friendlyPos, SUMO_TAG_DET_ENTRY, myE3Definition->myID);
337 // build and save the entry
338 myE3Definition->myEntries.push_back(MSCrossSection(clane, pos));
339}
340
341
342void
343NLDetectorBuilder::addE3Exit(const std::string& lane,
344 double pos, bool friendlyPos) {
345 if (myE3Definition == nullptr) {
346 return;
347 }
349 // get and check the position
350 pos = getPositionChecking(pos, clane, friendlyPos, SUMO_TAG_DET_EXIT, myE3Definition->myID);
351 // build and save the exit
352 myE3Definition->myExits.push_back(MSCrossSection(clane, pos));
353}
354
355
356std::string
358 if (myE3Definition == nullptr) {
359 return "<unknown>";
360 }
361 return myE3Definition->myID;
362}
363
364
365void
367 if (myE3Definition == nullptr) {
368 return;
369 }
370 // If E3 own entry or exit detectors
371 if (myE3Definition->myEntries.size() > 0 || myE3Definition->myExits.size() > 0) {
372 // create E3 detector
383 // add to net
385 } else {
386 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)")
387 }
388 // clean up
389 delete myE3Definition;
390 myE3Definition = nullptr;
391}
392
393
394void
396 const std::string& vtype, SUMOTime frequency,
397 const std::string& device) {
399 new MSVTypeProbe(id, vtype, OutputDevice::getDevice(device), frequency);
400}
401
402
403void
404NLDetectorBuilder::buildRouteProbe(const std::string& id, const std::string& edge,
405 SUMOTime frequency, SUMOTime begin,
406 const std::string& device,
407 const std::string& vTypes) {
410 MSRouteProbe* probe = new MSRouteProbe(id, e, id + "_" + toString(begin), id + "_" + toString(begin - frequency), vTypes);
411 // add the file output
412 myNet.getDetectorControl().add(SUMO_TAG_ROUTEPROBE, probe, device, frequency, begin);
413}
414
415
418 MSLane* lane, double pos,
419 double length,
420 const std::string name,
421 const std::string& vTypes,
422 const std::string& nextEdges,
423 int detectPersons,
424 bool /*show*/) {
426 return new MEInductLoop(id, MSGlobals::gMesoNet->getSegmentForEdge(lane->getEdge(), pos), pos, name, vTypes, nextEdges, detectPersons);
427 }
428 return new MSInductLoop(id, lane, pos, length, name, vTypes, nextEdges, detectPersons, false);
429}
430
431
434 MSLane* lane, double pos, const std::string& od,
435 const std::string name, const std::string& vTypes,
436 const std::string& nextEdges) {
437 return new MSInstantInductLoop(id, OutputDevice::getDevice(od), lane, pos, name, vTypes, nextEdges);
438}
439
440
443 DetectorUsage usage, MSLane* lane, double pos, double endPos, double length,
444 SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold,
445 const std::string name, const std::string& vTypes,
446 const std::string& nextEdges,
447 int detectPersons, bool /* showDetector */) {
448 return new MSE2Collector(id, usage, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons);
449}
450
453 DetectorUsage usage, std::vector<MSLane*> lanes, double pos, double endPos,
454 SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold,
455 const std::string name, const std::string& vTypes,
456 const std::string& nextEdges,
457 int detectPersons, bool /* showDetector */) {
458 return new MSE2Collector(id, usage, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons);
459}
460
463 const CrossSectionVector& entries,
464 const CrossSectionVector& exits,
465 double haltingSpeedThreshold,
466 SUMOTime haltingTimeThreshold,
467 const std::string name, const std::string& vTypes,
468 const std::string& nextEdges,
469 int detectPersons,
470 bool openEntry,
471 bool expectArrival) {
472 return new MSE3Collector(id, entries, exits, haltingSpeedThreshold, haltingTimeThreshold, name, vTypes, nextEdges, detectPersons, openEntry, expectArrival);
473}
474
475
476double
477NLDetectorBuilder::getPositionChecking(double pos, MSLane* lane, bool friendlyPos,
478 SumoXMLTag tag,
479 const std::string& detid) {
480 // check whether it is given from the end
481 if (pos < 0) {
482 pos += lane->getLength();
483 }
484 // check whether it is on the lane
485 if (pos > lane->getLength()) {
486 if (friendlyPos) {
487 pos = lane->getLength();
488 } else {
489 throw InvalidArgument("The position of " + toString(tag) + " '" + detid + "' lies beyond the lane's '" + lane->getID() + "' end.");
490 }
491 }
492 if (pos < 0) {
493 if (friendlyPos) {
494 pos = 0.;
495 } else {
496 throw InvalidArgument("The position of " + toString(tag) + " '" + detid + "' lies before the lane's '" + lane->getID() + "' begin.");
497 }
498 }
499 return pos;
500}
501
502
503void
505 SUMOTime begin, SUMOTime end, const std::string& type,
506 const bool useLanes, const bool withEmpty, const bool printDefaults,
507 const bool withInternal, const bool trackVehicles, const int detectPersons,
508 const double maxTravelTime, const double minSamples,
509 const double haltSpeed, const std::string& vTypes,
510 const std::string& writeAttributes,
511 std::vector<MSEdge*> edges,
512 bool aggregate,
513 const std::string& device) {
514 if (begin < 0) {
515 throw InvalidArgument("Negative begin time for meandata dump '" + id + "'.");
516 }
517 if (end < 0) {
518 end = SUMOTime_MAX;
519 }
520 if (end <= begin) {
521 throw InvalidArgument("End before or at begin for meandata dump '" + id + "'.");
522 }
523 checkStepLengthMultiple(begin, " for meandata dump '" + id + "'");
524 MSMeanData* det = nullptr;
525 if (type == "" || type == "performance" || type == "traffic") {
526 det = new MSMeanData_Net(id, begin, end, useLanes, withEmpty,
527 printDefaults, withInternal, trackVehicles, detectPersons, maxTravelTime, minSamples, haltSpeed, vTypes, writeAttributes, edges, aggregate);
528 } else if (type == "emissions" || type == "hbefa") {
529 if (type == "hbefa") {
530 WRITE_WARNING(TL("The netstate type 'hbefa' is deprecated. Please use the type 'emissions' instead."));
531 }
532 det = new MSMeanData_Emissions(id, begin, end, useLanes, withEmpty,
533 printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, vTypes, writeAttributes, edges, aggregate);
534 } else if (type == "harmonoise") {
535 det = new MSMeanData_Harmonoise(id, begin, end, useLanes, withEmpty,
536 printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, vTypes, writeAttributes, edges, aggregate);
537 } else if (type == "amitran") {
538 det = new MSMeanData_Amitran(id, begin, end, useLanes, withEmpty,
539 printDefaults, withInternal, trackVehicles, detectPersons, maxTravelTime, minSamples, haltSpeed, vTypes, writeAttributes, edges, aggregate);
540 } else {
541 throw InvalidArgument("Invalid type '" + type + "' for meandata dump '" + id + "'.");
542 }
543 if (det != nullptr) {
544 if (frequency < 0) {
545 frequency = end - begin;
546 } else {
547 checkStepLengthMultiple(frequency, " for meandata dump '" + id + "'");
548 }
549 MSNet::getInstance()->getDetectorControl().add(det, device, frequency, begin);
550 }
551}
552
553
554
555
556// ------ Value checking/adapting methods ------
557MSEdge*
558NLDetectorBuilder::getEdgeChecking(const std::string& edgeID, SumoXMLTag type,
559 const std::string& detid) {
560 // get and check the lane
561 MSEdge* edge = MSEdge::dictionary(edgeID);
562 if (edge == nullptr) {
563 throw InvalidArgument("The lane with the id '" + edgeID + "' is not known (while building " + toString(type) + " '" + detid + "').");
564 }
565 return edge;
566}
567
568
569MSLane*
570NLDetectorBuilder::getLaneChecking(const std::string& laneID, SumoXMLTag type,
571 const std::string& detid) {
572 // get and check the lane
573 MSLane* lane = MSLane::dictionary(laneID);
574 if (lane == nullptr) {
575 throw InvalidArgument("The lane with the id '" + laneID + "' is not known (while building " + toString(type) + " '" + detid + "').");
576 }
577 return lane;
578}
579
580
581void
582NLDetectorBuilder::checkSampleInterval(SUMOTime splInterval, SumoXMLTag type, const std::string& id) {
583 if (splInterval < 0) {
584 throw InvalidArgument("Negative sampling frequency (in " + toString(type) + " '" + id + "').");
585 }
586 if (splInterval == 0) {
587 throw InvalidArgument("Sampling frequency must not be zero (in " + toString(type) + " '" + id + "').");
588 }
589 checkStepLengthMultiple(splInterval, " (in " + toString(type) + " '" + id + "')");
590}
591
592
593/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
std::vector< MSCrossSection > CrossSectionVector
@ DU_USER_DEFINED
#define WRITE_WARNING(msg)
Definition MsgHandler.h:270
#define TL(string)
Definition MsgHandler.h:287
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:131
#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
T MIN2(T a, T b)
Definition StdDefs.h:76
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.
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: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.
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:2560
double getLength() const
Returns the lane's length.
Definition MSLane.h:593
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition MSLane.cpp:2325
MSEdge & getEdge() const
Returns the lane's edge.
Definition MSLane.h:745
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:443
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:322
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.
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.
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.
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...
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:74
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.