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-2020 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 
53 #include <mesosim/MEInductLoop.h>
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& vTypes, bool openEntry) :
68  myID(id), myDevice(device),
69  myHaltingSpeedThreshold(haltingSpeedThreshold),
70  myHaltingTimeThreshold(haltingTimeThreshold),
71  mySampleInterval(splInterval),
72  myVehicleTypes(vTypes),
73  myOpenEntry(openEntry) {
74 }
75 
76 
78 
79 
80 /* -------------------------------------------------------------------------
81  * NLDetectorBuilder-methods
82  * ----------------------------------------------------------------------- */
84  : myNet(net), myE3Definition(nullptr) {}
85 
86 
88  delete myE3Definition;
89 }
90 
91 
92 void
93 NLDetectorBuilder::buildInductLoop(const std::string& id,
94  const std::string& lane, double pos, SUMOTime splInterval,
95  const std::string& device, bool friendlyPos,
96  const std::string& vTypes) {
97  checkSampleInterval(splInterval, SUMO_TAG_E1DETECTOR, id);
98  // get and check the lane
99  MSLane* clane = getLaneChecking(lane, SUMO_TAG_E1DETECTOR, id);
100  // get and check the position
101  pos = getPositionChecking(pos, clane, friendlyPos, id);
102  // build the loop
103  MSDetectorFileOutput* loop = createInductLoop(id, clane, pos, vTypes);
104  // add the file output
105  myNet.getDetectorControl().add(SUMO_TAG_INDUCTION_LOOP, loop, device, splInterval);
106 }
107 
108 
109 void
111  const std::string& lane, double pos,
112  const std::string& device, bool friendlyPos,
113  const std::string& vTypes) {
114  // get and check the lane
116  // get and check the position
117  pos = getPositionChecking(pos, clane, friendlyPos, id);
118  // build the loop
119  MSDetectorFileOutput* loop = createInstantInductLoop(id, clane, pos, device, vTypes);
120  // add the file output
122 }
123 
124 
125 void
126 NLDetectorBuilder::buildE2Detector(const std::string& id, MSLane* lane, double pos, double endPos, double length,
127  const std::string& device, SUMOTime frequency,
128  SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold,
129  const std::string& vTypes, bool friendlyPos, bool showDetector,
131 
132  bool tlsGiven = tlls != nullptr;
133  bool toLaneGiven = toLane != nullptr;
134  bool posGiven = pos != std::numeric_limits<double>::max();
135  bool endPosGiven = endPos != std::numeric_limits<double>::max();
136 
137  assert(posGiven || endPosGiven);
138 
139  // Check positioning
140  if (posGiven) {
141  if (pos >= lane->getLength() || (pos < 0 && -pos > lane->getLength())) {
142  std::stringstream ss;
143  ss << "The given position (=" << pos << ") for detector '" << id
144  << "' does not lie on the given lane '" << lane->getID()
145  << "' with length " << lane->getLength();
146  if (friendlyPos) {
147  double newPos = pos > 0 ? lane->getLength() - POSITION_EPS : 0.;
148  ss << " (adjusting to new position " << newPos;
149  WRITE_WARNING(ss.str());
150  pos = newPos;
151  } else {
152  ss << " (0 <= pos < lane->getLength() is required)";
153  throw InvalidArgument(ss.str());
154  }
155  }
156  }
157  if (endPosGiven) {
158  if (endPos > lane->getLength() || (endPos <= 0 && -endPos >= lane->getLength())) {
159  std::stringstream ss;
160  ss << "The given end position (=" << endPos << ") for detector '" << id
161  << "' does not lie on the given lane '" << lane->getID()
162  << "' with length " << lane->getLength();
163  if (friendlyPos) {
164  double newEndPos = endPos > 0 ? lane->getLength() : POSITION_EPS;
165  ss << " (adjusting to new position " << newEndPos;
166  WRITE_WARNING(ss.str());
167  pos = newEndPos;
168  } else {
169  ss << " (0 <= pos < lane->getLength() is required)";
170  throw InvalidArgument(ss.str());
171  }
172  }
173  }
174 
175  MSE2Collector* det = nullptr;
176  if (tlsGiven) {
177  // Detector connected to TLS
178  det = createE2Detector(id, DU_USER_DEFINED, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes, showDetector);
180  // add the file output (XXX: Where's the corresponding delete?)
181  if (toLaneGiven) {
182  // Detector also associated to specific link
183  const MSLane* const lastLane = det->getLastLane();
184  const MSLink* const link = lastLane->getLinkTo(toLane);
185  if (link == nullptr) {
186  throw InvalidArgument(
187  "The detector '" + id + "' cannot be build as no connection between lanes '"
188  + lastLane->getID() + "' and '" + toLane->getID() + "' exists.");
189  }
191  } else {
192  // detector for tls but without specific link
194  }
195  } else {
196  // User specified detector for xml-output
198  det = createE2Detector(id, DU_USER_DEFINED, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes, showDetector);
199  myNet.getDetectorControl().add(SUMO_TAG_LANE_AREA_DETECTOR, det, device, frequency);
200  }
201 
202 }
203 
204 void
205 NLDetectorBuilder::buildE2Detector(const std::string& id, std::vector<MSLane*> lanes, double pos, double endPos,
206  const std::string& device, SUMOTime frequency,
207  SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold,
208  const std::string& vTypes, bool friendlyPos, bool showDetector,
210 
211  bool tlsGiven = tlls != nullptr;
212  bool toLaneGiven = toLane != nullptr;
213  assert(pos != std::numeric_limits<double>::max());
214  assert(endPos != std::numeric_limits<double>::max());
215  assert(lanes.size() != 0);
216 
217  const MSLane* const firstLane = lanes[0];
218  const MSLane* const lastLane = lanes.back();
219 
220  // Check positioning
221  if (pos >= firstLane->getLength() || (pos < 0 && -pos > firstLane->getLength())) {
222  std::stringstream ss;
223  ss << "The given position (=" << pos << ") for detector '" << id
224  << "' does not lie on the given lane '" << firstLane->getID()
225  << "' with length " << firstLane->getLength();
226  if (friendlyPos) {
227  double newPos = pos > 0 ? firstLane->getLength() - POSITION_EPS : 0.;
228  ss << " (adjusting to new position " << newPos;
229  WRITE_WARNING(ss.str());
230  pos = newPos;
231  } else {
232  ss << " (0 <= pos < lane->getLength() is required)";
233  throw InvalidArgument(ss.str());
234  }
235  }
236  if (endPos > lastLane->getLength() || (endPos <= 0 && -endPos >= lastLane->getLength())) {
237  std::stringstream ss;
238  ss << "The given end position (=" << endPos << ") for detector '" << id
239  << "' does not lie on the given lane '" << lastLane->getID()
240  << "' with length " << lastLane->getLength();
241  if (friendlyPos) {
242  double newEndPos = endPos > 0 ? lastLane->getLength() : POSITION_EPS;
243  ss << " (adjusting to new position " << newEndPos;
244  WRITE_WARNING(ss.str());
245  pos = newEndPos;
246  } else {
247  ss << " (0 <= pos < lane->getLength() is required)";
248  throw InvalidArgument(ss.str());
249  }
250  }
251 
252  MSE2Collector* det = nullptr;
253  if (tlsGiven) {
254  // Detector connected to TLS
255  det = createE2Detector(id, DU_USER_DEFINED, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes, showDetector);
257  // add the file output (XXX: Where's the corresponding delete?)
258  if (toLaneGiven) {
259  // Detector also associated to specific link
260  const MSLane* const lastDetLane = det->getLastLane();
261  const MSLink* const link = lastDetLane->getLinkTo(toLane);
262  if (link == nullptr) {
263  throw InvalidArgument(
264  "The detector '" + id + "' cannot be build as no connection between lanes '"
265  + lastDetLane->getID() + "' and '" + toLane->getID() + "' exists.");
266  }
268  } else {
269  // detector for tls but without specific link
271  }
272  } else {
273  // User specified detector for xml-output
275 
276  det = createE2Detector(id, DU_USER_DEFINED, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes, showDetector);
277  myNet.getDetectorControl().add(SUMO_TAG_LANE_AREA_DETECTOR, det, device, frequency);
278  }
279 
280 }
281 
282 
283 
284 void
286  const std::string& device, SUMOTime splInterval,
287  double haltingSpeedThreshold,
288  SUMOTime haltingTimeThreshold,
289  const std::string& vTypes, bool openEntry) {
290  checkSampleInterval(splInterval, SUMO_TAG_E3DETECTOR, id);
291  myE3Definition = new E3DetectorDefinition(id, device, haltingSpeedThreshold, haltingTimeThreshold, splInterval, vTypes, openEntry);
292 }
293 
294 
295 void
296 NLDetectorBuilder::addE3Entry(const std::string& lane,
297  double pos, bool friendlyPos) {
298  if (myE3Definition == nullptr) {
299  return;
300  }
302  // get and check the position
303  pos = getPositionChecking(pos, clane, friendlyPos, myE3Definition->myID);
304  // build and save the entry
305  myE3Definition->myEntries.push_back(MSCrossSection(clane, pos));
306 }
307 
308 
309 void
310 NLDetectorBuilder::addE3Exit(const std::string& lane,
311  double pos, bool friendlyPos) {
312  if (myE3Definition == nullptr) {
313  return;
314  }
316  // get and check the position
317  pos = getPositionChecking(pos, clane, friendlyPos, myE3Definition->myID);
318  // build and save the exit
319  myE3Definition->myExits.push_back(MSCrossSection(clane, pos));
320 }
321 
322 
323 std::string
325  if (myE3Definition == nullptr) {
326  return "<unknown>";
327  }
328  return myE3Definition->myID;
329 }
330 
331 
332 void
334  if (myE3Definition == nullptr) {
335  return;
336  }
337  // If E3 own entry or exit detectors
338  if (myE3Definition->myEntries.size() > 0 || myE3Definition->myExits.size() > 0) {
339  // create E3 detector
344  // add to net
346  } else
347  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)")
348 
349  // clean up
350  delete myE3Definition;
351  myE3Definition = nullptr;
352 }
353 
354 
355 void
357  const std::string& vtype, SUMOTime frequency,
358  const std::string& device) {
360  new MSVTypeProbe(id, vtype, OutputDevice::getDevice(device), frequency);
361 }
362 
363 
364 void
365 NLDetectorBuilder::buildRouteProbe(const std::string& id, const std::string& edge,
366  SUMOTime frequency, SUMOTime begin,
367  const std::string& device,
368  const std::string& vTypes) {
371  MSRouteProbe* probe = new MSRouteProbe(id, e, id + "_" + toString(begin), id + "_" + toString(begin - frequency), vTypes);
372  // add the file output
373  myNet.getDetectorControl().add(SUMO_TAG_ROUTEPROBE, probe, device, frequency, begin);
374 }
375 
378  MSLane* lane, double pos,
379  const std::string& vTypes, bool) {
381  return new MEInductLoop(id, MSGlobals::gMesoNet->getSegmentForEdge(lane->getEdge(), pos), pos, vTypes);
382  }
383  return new MSInductLoop(id, lane, pos, vTypes, false);
384 }
385 
386 
389  MSLane* lane, double pos, const std::string& od,
390  const std::string& vTypes) {
391  return new MSInstantInductLoop(id, OutputDevice::getDevice(od), lane, pos, vTypes);
392 }
393 
394 
397  DetectorUsage usage, MSLane* lane, double pos, double endPos, double length,
398  SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold,
399  const std::string& vTypes, bool /* showDetector */) {
400  return new MSE2Collector(id, usage, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes);
401 }
402 
405  DetectorUsage usage, std::vector<MSLane*> lanes, double pos, double endPos,
406  SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold,
407  const std::string& vTypes, bool /* showDetector */) {
408  return new MSE2Collector(id, usage, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes);
409 }
410 
413  const CrossSectionVector& entries,
414  const CrossSectionVector& exits,
415  double haltingSpeedThreshold,
416  SUMOTime haltingTimeThreshold,
417  const std::string& vTypes,
418  bool openEntry) {
419  return new MSE3Collector(id, entries, exits, haltingSpeedThreshold, haltingTimeThreshold, vTypes, openEntry);
420 }
421 
422 
423 double
424 NLDetectorBuilder::getPositionChecking(double pos, MSLane* lane, bool friendlyPos,
425  const std::string& detid) {
426  // check whether it is given from the end
427  if (pos < 0) {
428  pos += lane->getLength();
429  }
430  // check whether it is on the lane
431  if (pos > lane->getLength()) {
432  if (friendlyPos) {
433  pos = lane->getLength();
434  } else {
435  throw InvalidArgument("The position of detector '" + detid + "' lies beyond the lane's '" + lane->getID() + "' end.");
436  }
437  }
438  if (pos < 0) {
439  if (friendlyPos) {
440  pos = 0.;
441  } else {
442  throw InvalidArgument("The position of detector '" + detid + "' lies before the lane's '" + lane->getID() + "' begin.");
443  }
444  }
445  return pos;
446 }
447 
448 
449 void
450 NLDetectorBuilder::createEdgeLaneMeanData(const std::string& id, SUMOTime frequency,
451  SUMOTime begin, SUMOTime end, const std::string& type,
452  const bool useLanes, const bool withEmpty, const bool printDefaults,
453  const bool withInternal, const bool trackVehicles, const int detectPersons,
454  const double maxTravelTime, const double minSamples,
455  const double haltSpeed, const std::string& vTypes,
456  const std::string& writeAttributes,
457  const std::string& device) {
458  if (begin < 0) {
459  throw InvalidArgument("Negative begin time for meandata dump '" + id + "'.");
460  }
461  if (end < 0) {
462  end = SUMOTime_MAX;
463  }
464  if (end <= begin) {
465  throw InvalidArgument("End before or at begin for meandata dump '" + id + "'.");
466  }
467  checkStepLengthMultiple(begin, " for meandata dump '" + id + "'");
468  MSMeanData* det = nullptr;
469  if (type == "" || type == "performance" || type == "traffic") {
470  det = new MSMeanData_Net(id, begin, end, useLanes, withEmpty,
471  printDefaults, withInternal, trackVehicles, detectPersons, maxTravelTime, minSamples, haltSpeed, vTypes, writeAttributes);
472  } else if (type == "emissions" || type == "hbefa") {
473  if (type == "hbefa") {
474  WRITE_WARNING("The netstate type 'hbefa' is deprecated. Please use the type 'emissions' instead.");
475  }
476  det = new MSMeanData_Emissions(id, begin, end, useLanes, withEmpty,
477  printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, vTypes, writeAttributes);
478  } else if (type == "harmonoise") {
479  det = new MSMeanData_Harmonoise(id, begin, end, useLanes, withEmpty,
480  printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, vTypes, writeAttributes);
481  } else if (type == "amitran") {
482  det = new MSMeanData_Amitran(id, begin, end, useLanes, withEmpty,
483  printDefaults, withInternal, trackVehicles, detectPersons, maxTravelTime, minSamples, haltSpeed, vTypes, writeAttributes);
484  } else {
485  throw InvalidArgument("Invalid type '" + type + "' for meandata dump '" + id + "'.");
486  }
487  if (det != nullptr) {
488  if (frequency < 0) {
489  frequency = end - begin;
490  } else {
491  checkStepLengthMultiple(frequency, " for meandata dump '" + id + "'");
492  }
493  MSNet::getInstance()->getDetectorControl().add(det, device, frequency, begin);
494  }
495 }
496 
497 
498 
499 
500 // ------ Value checking/adapting methods ------
501 MSEdge*
502 NLDetectorBuilder::getEdgeChecking(const std::string& edgeID, SumoXMLTag type,
503  const std::string& detid) {
504  // get and check the lane
505  MSEdge* edge = MSEdge::dictionary(edgeID);
506  if (edge == nullptr) {
507  throw InvalidArgument("The lane with the id '" + edgeID + "' is not known (while building " + toString(type) + " '" + detid + "').");
508  }
509  return edge;
510 }
511 
512 
513 MSLane*
514 NLDetectorBuilder::getLaneChecking(const std::string& laneID, SumoXMLTag type,
515  const std::string& detid) {
516  // get and check the lane
517  MSLane* lane = MSLane::dictionary(laneID);
518  if (lane == nullptr) {
519  throw InvalidArgument("The lane with the id '" + laneID + "' is not known (while building " + toString(type) + " '" + detid + "').");
520  }
521  return lane;
522 }
523 
524 
525 void
526 NLDetectorBuilder::checkSampleInterval(SUMOTime splInterval, SumoXMLTag type, const std::string& id) {
527  if (splInterval < 0) {
528  throw InvalidArgument("Negative sampling frequency (in " + toString(type) + " '" + id + "').");
529  }
530  if (splInterval == 0) {
531  throw InvalidArgument("Sampling frequency must not be zero (in " + toString(type) + " '" + id + "').");
532  }
533  checkStepLengthMultiple(splInterval, " (in " + toString(type) + " '" + id + "')");
534 }
535 
536 
537 /****************************************************************************/
std::vector< MSCrossSection > CrossSectionVector
@ DU_USER_DEFINED
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:276
bool checkStepLengthMultiple(const SUMOTime t, const std::string &error, SUMOTime deltaT)
check if given SUMOTime is multiple of the step length
Definition: SUMOTime.cpp:122
#define SUMOTime_MAX
Definition: SUMOTime.h:32
long long int SUMOTime
Definition: SUMOTime.h:31
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::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
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 splInterval, 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:58
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:814
static bool gUseMesoSim
Definition: MSGlobals.h:88
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition: MSGlobals.h:94
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:82
const MSLink * getLinkTo(const MSLane *const) const
returns the link to the given lane or nullptr, if it is not connected
Definition: MSLane.cpp:2128
double getLength() const
Returns the lane's length.
Definition: MSLane.h:539
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:1908
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:673
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
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:171
MSDetectorControl & getDetectorControl()
Returns the detector control.
Definition: MSNet.h:434
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:313
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 device the detector shall use.
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.
E3DetectorDefinition(const std::string &id, const std::string &device, double haltingSpeedThreshold, SUMOTime haltingTimeThreshold, SUMOTime splInterval, const std::string &vTypes, bool openEntry)
Constructor.
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.
virtual MSDetectorFileOutput * createInstantInductLoop(const std::string &id, MSLane *lane, double pos, const std::string &od, const std::string &vTypes)
Creates an instance of an e1 detector using the given values.
void buildInductLoop(const std::string &id, const std::string &lane, double pos, SUMOTime splInterval, const std::string &device, bool friendlyPos, const std::string &vTypes)
Builds an e1 detector and adds it to the net.
MSLane * getLaneChecking(const std::string &laneID, SumoXMLTag type, const std::string &detid)
Returns the named lane.
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 &vTypes, bool showDetector=true)
Creates a MSE2Collector instance, overridden by GUIE2Collector::createE2Detector()
void beginE3Detector(const std::string &id, const std::string &device, SUMOTime splInterval, double haltingSpeedThreshold, SUMOTime haltingTimeThreshold, const std::string &vTypes, bool openEntry)
Stores temporary the initial information about an e3 detector to build.
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 ~NLDetectorBuilder()
Destructor.
MSEdge * getEdgeChecking(const std::string &edgeID, SumoXMLTag type, const std::string &detid)
Returns the named edge.
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, const std::string &device)
Creates edge based mean data collector using the given specification.
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.
double getPositionChecking(double pos, MSLane *lane, bool friendlyPos, const std::string &detid)
Computes the position to use.
void addE3Entry(const std::string &lane, double pos, bool friendlyPos)
Builds an entry point of an e3 detector.
virtual MSDetectorFileOutput * createInductLoop(const std::string &id, MSLane *lane, double pos, const std::string &vTypes, bool show=true)
Creates an instance of an e1 detector using the given values.
void buildInstantInductLoop(const std::string &id, const std::string &lane, double pos, const std::string &device, bool friendlyPos, const std::string &vTypes)
Builds an instantenous induction and adds it to the net.
E3DetectorDefinition * myE3Definition
definition of the currently parsed e3 detector
std::string getCurrentE3ID() const
Returns the id of the currently built e3 detector.
void 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 &vTypes, 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...
NLDetectorBuilder(MSNet &net)
Constructor.
virtual MSDetectorFileOutput * createE3Detector(const std::string &id, const CrossSectionVector &entries, const CrossSectionVector &exits, double haltingSpeedThreshold, SUMOTime haltingTimeThreshold, const std::string &vTypes, bool openEntry)
Creates an instance of an e3 detector using the given values.
const std::string & getID() const
Returns the id.
Definition: Named.h:73
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.