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 int detectPersons) {
107 // get and check the lane
108 MSLane* clane = getLaneChecking(lane, SUMO_TAG_E1DETECTOR, id);
109 // get and check the position
110 pos = getPositionChecking(pos, clane, friendlyPos, SUMO_TAG_E1DETECTOR, id);
111 if (length < 0) {
112 throw InvalidArgument("The length of " + toString(SUMO_TAG_E1DETECTOR) + " '" + id + "' cannot be negative");
113 } else if (length > 0 && pos + length > clane->getLength()) {
114 if (friendlyPos) {
115 length = MIN2(length, clane->getLength());
116 pos = clane->getLength() - length;
117 } else {
118 throw InvalidArgument("The length of " + toString(SUMO_TAG_E1DETECTOR) + " '" + id + "' puts it beyond the lane's '" + clane->getID() + "' end.");
119 }
120 }
121 // build the loop
122 MSDetectorFileOutput* loop = createInductLoop(id, clane, pos, length, name, vTypes, nextEdges, detectPersons, true);
123 // add the file output
124 myNet.getDetectorControl().add(SUMO_TAG_INDUCTION_LOOP, loop, device, splInterval);
125 return loop;
126}
127
128
131 const std::string& lane, double pos,
132 const std::string& device, bool friendlyPos,
133 const std::string name,
134 const std::string& vTypes,
135 const std::string& nextEdges,
136 int detectPersons) {
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, detectPersons);
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 int detectPersons) {
438 return new MSInstantInductLoop(id, OutputDevice::getDevice(od), lane, pos, name, vTypes, nextEdges, detectPersons);
439}
440
441
444 DetectorUsage usage, MSLane* lane, double pos, double endPos, double length,
445 SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold,
446 const std::string name, const std::string& vTypes,
447 const std::string& nextEdges,
448 int detectPersons, bool /* showDetector */) {
449 return new MSE2Collector(id, usage, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons);
450}
451
454 DetectorUsage usage, std::vector<MSLane*> lanes, double pos, double endPos,
455 SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold,
456 const std::string name, const std::string& vTypes,
457 const std::string& nextEdges,
458 int detectPersons, bool /* showDetector */) {
459 return new MSE2Collector(id, usage, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons);
460}
461
464 const CrossSectionVector& entries,
465 const CrossSectionVector& exits,
466 double haltingSpeedThreshold,
467 SUMOTime haltingTimeThreshold,
468 const std::string name, const std::string& vTypes,
469 const std::string& nextEdges,
470 int detectPersons,
471 bool openEntry,
472 bool expectArrival) {
473 return new MSE3Collector(id, entries, exits, haltingSpeedThreshold, haltingTimeThreshold, name, vTypes, nextEdges, detectPersons, openEntry, expectArrival);
474}
475
476
477double
478NLDetectorBuilder::getPositionChecking(double pos, MSLane* lane, bool friendlyPos,
479 SumoXMLTag tag,
480 const std::string& detid) {
481 // check whether it is given from the end
482 if (pos < 0) {
483 pos += lane->getLength();
484 }
485 // check whether it is on the lane
486 if (pos > lane->getLength()) {
487 if (friendlyPos) {
488 pos = lane->getLength();
489 } else {
490 throw InvalidArgument("The position of " + toString(tag) + " '" + detid + "' lies beyond the lane's '" + lane->getID() + "' end.");
491 }
492 }
493 if (pos < 0) {
494 if (friendlyPos) {
495 pos = 0.;
496 } else {
497 throw InvalidArgument("The position of " + toString(tag) + " '" + detid + "' lies before the lane's '" + lane->getID() + "' begin.");
498 }
499 }
500 return pos;
501}
502
503
504void
506 SUMOTime begin, SUMOTime end, const std::string& type,
507 const bool useLanes, const std::string& excludeEmpty,
508 const bool withInternal, const bool trackVehicles, const int detectPersons,
509 const double maxTravelTime, const double minSamples,
510 const double haltSpeed, const std::string& vTypes,
511 const std::string& writeAttributes,
512 std::vector<MSEdge*> edges,
513 AggregateType aggregate,
514 const std::string& device) {
515 if (begin < 0) {
516 throw InvalidArgument("Negative begin time for meandata dump '" + id + "'.");
517 }
518 if (end < 0) {
519 end = SUMOTime_MAX;
520 }
521 if (end <= begin) {
522 throw InvalidArgument("End before or at begin for meandata dump '" + id + "'.");
523 }
524 checkStepLengthMultiple(begin, " for meandata dump '" + id + "'");
525 MSMeanData* det = nullptr;
528 (type == "performance")) {
529 det = new MSMeanData_Net(id, begin, end, useLanes, excludeEmpty,
530 withInternal, trackVehicles, detectPersons, maxTravelTime, minSamples, haltSpeed, vTypes, writeAttributes, edges, aggregate);
531 } else if ((type == SUMOXMLDefinitions::MeanDataTypes.getString(MeanDataType::EMISSIONS)) || (type == "hbefa")) {
532 if (type == "hbefa") {
533 WRITE_WARNING(TL("The netstate type 'hbefa' is deprecated. Please use the type 'emissions' instead."));
534 }
535 det = new MSMeanData_Emissions(id, begin, end, useLanes, excludeEmpty,
536 withInternal, trackVehicles, maxTravelTime, minSamples, vTypes, writeAttributes, edges, aggregate);
537 } else if (type == SUMOXMLDefinitions::MeanDataTypes.getString(MeanDataType::HARMONOISE)) {
538 det = new MSMeanData_Harmonoise(id, begin, end, useLanes, excludeEmpty,
539 withInternal, trackVehicles, maxTravelTime, minSamples, vTypes, writeAttributes, edges, aggregate);
540 } else if (type == SUMOXMLDefinitions::MeanDataTypes.getString(MeanDataType::AMITRAN)) {
541 det = new MSMeanData_Amitran(id, begin, end, useLanes, excludeEmpty,
542 withInternal, trackVehicles, detectPersons, maxTravelTime, minSamples, haltSpeed, vTypes, writeAttributes, edges, aggregate);
543 } else {
544 throw InvalidArgument("Invalid type '" + type + "' for meandata dump '" + id + "'.");
545 }
546 if (det != nullptr) {
547 if (frequency < 0) {
548 frequency = end - begin;
549 } else {
550 checkStepLengthMultiple(frequency, " for meandata dump '" + id + "'");
551 }
552 MSNet::getInstance()->getDetectorControl().add(det, device, frequency, begin);
553 }
554}
555
556
557
558
559// ------ Value checking/adapting methods ------
560MSEdge*
561NLDetectorBuilder::getEdgeChecking(const std::string& edgeID, SumoXMLTag type,
562 const std::string& detid) {
563 // get and check the lane
564 MSEdge* edge = MSEdge::dictionary(edgeID);
565 if (edge == nullptr) {
566 throw InvalidArgument("The lane with the id '" + edgeID + "' is not known (while building " + toString(type) + " '" + detid + "').");
567 }
568 return edge;
569}
570
571
572MSLane*
573NLDetectorBuilder::getLaneChecking(const std::string& laneID, SumoXMLTag type,
574 const std::string& detid) {
575 // get and check the lane
576 MSLane* lane = MSLane::dictionary(laneID);
577 if (lane == nullptr) {
578 throw InvalidArgument("The lane with the id '" + laneID + "' is not known (while building " + toString(type) + " '" + detid + "').");
579 }
580 return lane;
581}
582
583
584void
585NLDetectorBuilder::checkSampleInterval(SUMOTime splInterval, SumoXMLTag type, const std::string& id) {
586 if (splInterval < 0) {
587 throw InvalidArgument("Negative sampling frequency (in " + toString(type) + " '" + id + "').");
588 }
589 if (splInterval == 0) {
590 throw InvalidArgument("Sampling frequency must not be zero (in " + toString(type) + " '" + id + "').");
591 }
592 checkStepLengthMultiple(splInterval, " (in " + toString(type) + " '" + id + "')");
593}
594
595
596/****************************************************************************/
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
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: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:1075
static bool gUseMesoSim
Definition MSGlobals.h:106
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition MSGlobals.h:112
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:2758
double getLength() const
Returns the lane's length.
Definition MSLane.h:617
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition MSLane.cpp:2495
MSEdge & getEdge() const
Returns the lane's edge.
Definition MSLane.h:775
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:89
MSDetectorControl & getDetectorControl()
Returns the detector control.
Definition MSNet.h:455
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition MSNet.cpp:187
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.
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.
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.
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 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.
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: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.
static StringBijection< MeanDataType > MeanDataTypes
reference positions (used creating certain elements in netedit)