65 const std::string& device,
double haltingSpeedThreshold,
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),
75 myVehicleTypes(vTypes),
76 myNextEdges(nextEdges),
77 myDetectPersons(detectPersons),
78 myOpenEntry(openEntry),
79 myExpectArrival(expectArrival)
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,
114 }
else if (length > 0 && pos + length > clane->
getLength()) {
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) {
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,
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();
163 assert(posGiven || endPosGiven);
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();
173 double newPos = pos > 0 ? lane->
getLength() - POSITION_EPS : 0.;
174 ss <<
" (adjusting to new position " << newPos;
178 ss <<
" (0 <= pos < lane->getLength() is required)";
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();
190 double newEndPos = endPos > 0 ? lane->
getLength() : POSITION_EPS;
191 ss <<
" (adjusting to new position " << newEndPos;
195 ss <<
" (0 <= pos < lane->getLength() is required)";
204 det =
createE2Detector(
id,
DU_USER_DEFINED, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons, showDetector);
211 if (link ==
nullptr) {
213 "The detector '" +
id +
"' cannot be build as no connection between lanes '"
214 + lastLane->
getID() +
"' and '" + toLane->
getID() +
"' exists.");
224 det =
createE2Detector(
id,
DU_USER_DEFINED, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons, showDetector);
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,
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);
246 const MSLane*
const firstLane = lanes[0];
247 const MSLane*
const lastLane = lanes.back();
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();
256 double newPos = pos > 0 ? firstLane->
getLength() - POSITION_EPS : 0.;
257 ss <<
" (adjusting to new position " << newPos;
261 ss <<
" (0 <= pos < lane->getLength() is required)";
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();
271 double newEndPos = endPos > 0 ? lastLane->
getLength() : POSITION_EPS;
272 ss <<
" (adjusting to new position " << newEndPos;
276 ss <<
" (0 <= pos < lane->getLength() is required)";
284 det =
createE2Detector(
id,
DU_USER_DEFINED, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons, showDetector);
291 if (link ==
nullptr) {
293 "The detector '" +
id +
"' cannot be build as no connection between lanes '"
294 + lastDetLane->
getID() +
"' and '" + toLane->
getID() +
"' exists.");
305 det =
createE2Detector(
id,
DU_USER_DEFINED, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons, showDetector);
315 const std::string& device,
SUMOTime splInterval,
316 double haltingSpeedThreshold,
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);
330 double pos,
bool friendlyPos) {
344 double pos,
bool friendlyPos) {
396 const std::string& vtype,
SUMOTime frequency,
397 const std::string& device) {
406 const std::string& device,
407 const std::string& vTypes) {
420 const std::string name,
421 const std::string& vTypes,
422 const std::string& nextEdges,
428 return new MSInductLoop(
id, lane, pos, length, name, vTypes, nextEdges, detectPersons,
false);
434 MSLane* lane,
double pos,
const std::string& od,
435 const std::string name,
const std::string& vTypes,
436 const std::string& nextEdges) {
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 ) {
448 return new MSE2Collector(
id, usage, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons);
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 ) {
458 return new MSE2Collector(
id, usage, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons);
465 double haltingSpeedThreshold,
467 const std::string name,
const std::string& vTypes,
468 const std::string& nextEdges,
471 bool expectArrival) {
472 return new MSE3Collector(
id, entries, exits, haltingSpeedThreshold, haltingTimeThreshold, name, vTypes, nextEdges, detectPersons, openEntry, expectArrival);
479 const std::string& detid) {
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,
513 const std::string& device) {
515 throw InvalidArgument(
"Negative begin time for meandata dump '" +
id +
"'.");
521 throw InvalidArgument(
"End before or at begin for meandata dump '" +
id +
"'.");
525 if (type ==
"" || type ==
"performance" || type ==
"traffic") {
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."));
533 printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, vTypes, writeAttributes, edges, aggregate);
534 }
else if (type ==
"harmonoise") {
536 printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, vTypes, writeAttributes, edges, aggregate);
537 }
else if (type ==
"amitran") {
539 printDefaults, withInternal, trackVehicles, detectPersons, maxTravelTime, minSamples, haltSpeed, vTypes, writeAttributes, edges, aggregate);
541 throw InvalidArgument(
"Invalid type '" + type +
"' for meandata dump '" +
id +
"'.");
543 if (det !=
nullptr) {
545 frequency = end - begin;
559 const std::string& detid) {
562 if (edge ==
nullptr) {
563 throw InvalidArgument(
"The lane with the id '" + edgeID +
"' is not known (while building " +
toString(type) +
" '" + detid +
"').");
571 const std::string& detid) {
574 if (lane ==
nullptr) {
575 throw InvalidArgument(
"The lane with the id '" + laneID +
"' is not known (while building " +
toString(type) +
" '" + detid +
"').");
583 if (splInterval < 0) {
586 if (splInterval == 0) {
std::vector< MSCrossSection > CrossSectionVector
#define WRITE_WARNING(msg)
bool checkStepLengthMultiple(const SUMOTime t, const std::string &error, SUMOTime deltaT, SUMOTime begin)
check if given SUMOTime is multiple of the step length
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)
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.
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....
static MELoop * gMesoNet
mesoscopic simulation infrastructure
An unextended detector measuring at a fixed position on a fixed lane.
An instantaneous induction loop.
Representation of a lane in the micro simulation.
const MSLink * getLinkTo(const MSLane *const) const
returns the link to the given lane or nullptr, if it is not connected
double getLength() const
Returns the lane's length.
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
MSEdge & getEdge() const
Returns the lane's edge.
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.
The simulated network and simulation perfomer.
MSDetectorControl & getDetectorControl()
Returns the detector control.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
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.
int myDetectPersons
person detection mode
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.
virtual ~E3DetectorDefinition()
Destructor.
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.
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.