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