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) {
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,
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,
152 const std::string& device,
SUMOTime frequency,
153 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
154 const std::string name,
const std::string& vTypes,
155 const std::string& nextEdges,
156 int detectPersons,
bool friendlyPos,
bool showDetector,
159 bool tlsGiven = tlls !=
nullptr;
160 bool toLaneGiven = toLane !=
nullptr;
161 bool posGiven = pos != std::numeric_limits<double>::max();
162 bool endPosGiven = endPos != std::numeric_limits<double>::max();
164 assert(posGiven || endPosGiven);
169 std::stringstream ss;
170 ss <<
"The given position (=" << pos <<
") for detector '" <<
id
171 <<
"' does not lie on the given lane '" << lane->
getID()
172 <<
"' with length " << lane->
getLength();
174 double newPos = pos > 0 ? lane->
getLength() - POSITION_EPS : 0.;
175 ss <<
" (adjusting to new position " << newPos;
179 ss <<
" (0 <= pos < lane->getLength() is required)";
186 std::stringstream ss;
187 ss <<
"The given end position (=" << endPos <<
") for detector '" <<
id
188 <<
"' does not lie on the given lane '" << lane->
getID()
189 <<
"' with length " << lane->
getLength();
191 double newEndPos = endPos > 0 ? lane->
getLength() : POSITION_EPS;
192 ss <<
" (adjusting to new position " << newEndPos;
196 ss <<
" (0 <= pos < lane->getLength() is required)";
205 det =
createE2Detector(
id,
DU_USER_DEFINED, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons, showDetector);
212 if (link ==
nullptr) {
214 "The detector '" +
id +
"' cannot be build as no connection between lanes '"
215 + lastLane->
getID() +
"' and '" + toLane->
getID() +
"' exists.");
225 det =
createE2Detector(
id,
DU_USER_DEFINED, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons, showDetector);
234 const std::string& device,
SUMOTime frequency,
235 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
236 const std::string name,
const std::string& vTypes,
237 const std::string& nextEdges,
238 int detectPersons,
bool friendlyPos,
bool showDetector,
241 bool tlsGiven = tlls !=
nullptr;
242 bool toLaneGiven = toLane !=
nullptr;
243 assert(pos != std::numeric_limits<double>::max());
244 assert(endPos != std::numeric_limits<double>::max());
245 assert(lanes.size() != 0);
247 const MSLane*
const firstLane = lanes[0];
248 const MSLane*
const lastLane = lanes.back();
252 std::stringstream ss;
253 ss <<
"The given position (=" << pos <<
") for detector '" <<
id
254 <<
"' does not lie on the given lane '" << firstLane->
getID()
255 <<
"' with length " << firstLane->
getLength();
257 double newPos = pos > 0 ? firstLane->
getLength() - POSITION_EPS : 0.;
258 ss <<
" (adjusting to new position " << newPos;
262 ss <<
" (0 <= pos < lane->getLength() is required)";
266 if (endPos > lastLane->
getLength() || (endPos <= 0 && -endPos >= lastLane->
getLength())) {
267 std::stringstream ss;
268 ss <<
"The given end position (=" << endPos <<
") for detector '" <<
id
269 <<
"' does not lie on the given lane '" << lastLane->
getID()
270 <<
"' with length " << lastLane->
getLength();
272 double newEndPos = endPos > 0 ? lastLane->
getLength() : POSITION_EPS;
273 ss <<
" (adjusting to new position " << newEndPos;
277 ss <<
" (0 <= pos < lane->getLength() is required)";
285 det =
createE2Detector(
id,
DU_USER_DEFINED, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons, showDetector);
292 if (link ==
nullptr) {
294 "The detector '" +
id +
"' cannot be build as no connection between lanes '"
295 + lastDetLane->
getID() +
"' and '" + toLane->
getID() +
"' exists.");
306 det =
createE2Detector(
id,
DU_USER_DEFINED, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons, showDetector);
316 const std::string& device,
SUMOTime splInterval,
317 double haltingSpeedThreshold,
319 const std::string name,
320 const std::string& vTypes,
321 const std::string& nextEdges,
322 int detectPersons,
bool openEntry,
bool expectArrival) {
324 myE3Definition =
new E3DetectorDefinition(
id, device, haltingSpeedThreshold, haltingTimeThreshold, splInterval, name, vTypes, nextEdges, detectPersons, openEntry, expectArrival);
331 double pos,
bool friendlyPos) {
345 double pos,
bool friendlyPos) {
397 const std::string& vtype,
SUMOTime frequency,
398 const std::string& device) {
407 const std::string& device,
408 const std::string& vTypes) {
421 const std::string name,
422 const std::string& vTypes,
423 const std::string& nextEdges,
430 return new MSInductLoop(
id, lane, pos, length, name, vTypes, nextEdges, detectPersons,
false);
436 MSLane* lane,
double pos,
const std::string& od,
437 const std::string name,
const std::string& vTypes,
438 const std::string& nextEdges,
447 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
448 const std::string name,
const std::string& vTypes,
449 const std::string& nextEdges,
450 int detectPersons,
bool ) {
451 return new MSE2Collector(
id, usage, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons);
456 DetectorUsage usage, std::vector<MSLane*> lanes,
double pos,
double endPos,
457 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
458 const std::string name,
const std::string& vTypes,
459 const std::string& nextEdges,
460 int detectPersons,
bool ) {
461 return new MSE2Collector(
id, usage, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons);
468 double haltingSpeedThreshold,
470 const std::string name,
const std::string& vTypes,
471 const std::string& nextEdges,
474 bool expectArrival) {
475 return new MSE3Collector(
id, entries, exits, haltingSpeedThreshold, haltingTimeThreshold, name, vTypes, nextEdges, detectPersons, openEntry, expectArrival);
482 const std::string& detid) {
509 const bool useLanes,
const std::string& excludeEmpty,
510 const bool withInternal,
const bool trackVehicles,
const int detectPersons,
511 const double maxTravelTime,
const double minSamples,
512 const double haltSpeed,
const double haltSpeedRel,
const std::string& vTypes,
513 const std::string& writeAttributes,
514 std::vector<MSEdge*> edges,
516 const std::string& device) {
518 throw InvalidArgument(
"Negative begin time for meandata dump '" +
id +
"'.");
524 throw InvalidArgument(
"End before or at begin for meandata dump '" +
id +
"'.");
527 std::vector<MeanDataType> types;
547 }
else if (t ==
"performance") {
549 }
else if (t ==
"hbefa") {
550 WRITE_WARNING(
TL(
"The meandata type 'hbefa' is deprecated. Please use the type 'emissions' instead."));
553 throw InvalidArgument(
"Invalid type '" + t +
"' for meandata dump '" +
id +
"'.");
558 frequency = end - begin;
568 withInternal, trackVehicles, detectPersons, maxTravelTime, minSamples, haltSpeed, haltSpeedRel, vTypes, writeAttributes, edges, aggregate);
571 withInternal, trackVehicles, maxTravelTime, minSamples, vTypes, writeAttributes, edges, aggregate);
574 withInternal, trackVehicles, maxTravelTime, minSamples, vTypes, writeAttributes, edges, aggregate);
577 withInternal, trackVehicles, detectPersons, maxTravelTime, minSamples, haltSpeed, vTypes, writeAttributes, edges, aggregate);
579 if (det !=
nullptr) {
580 if (first ==
nullptr) {
583 if (parent !=
nullptr) {
589 if (first !=
nullptr) {
601 const std::string& detid) {
604 if (edge ==
nullptr) {
605 throw InvalidArgument(
"The lane with the id '" + edgeID +
"' is not known (while building " +
toString(type) +
" '" + detid +
"').");
613 const std::string& detid) {
616 if (lane ==
nullptr) {
617 throw InvalidArgument(
"The lane with the id '" + laneID +
"' is not known (while building " +
toString(type) +
" '" + detid +
"').");
625 if (splInterval < 0) {
628 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::bitset< 96 > SumoXMLAttrMask
AggregateType
Numbers representing special SUMO-XML-attribute values Information on edgeData/laneData output should...
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.
static bool supports(const SumoXMLAttrMask &attributeMask)
check whether any of the given attributes can be calculated by this meandata
Noise data collector for edges/lanes.
static bool supports(const SumoXMLAttrMask &attributeMask)
check whether any of the given attributes can be calculated by this meandata
Network state mean data collector for edges/lanes.
static bool supports(const SumoXMLAttrMask &attributeMask)
check whether any of the given attributes can be calculated by this meandata
Data collector for edges/lanes.
void setSubData(MSMeanData *subData)
set a sub collector
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.
MSLane * getLaneChecking(const std::string &laneID, SumoXMLTag type, const std::string &detid)
Returns the named lane.
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 double haltSpeedRel, 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.
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.
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, bool forceMicro=false)
Creates an instance of an e1 detector using the given values.
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 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.
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, bool mesoTLS, int detectPersons)
Builds an e1 detector 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.
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.
static const SumoXMLAttrMask parseWrittenAttributes(const std::vector< std::string > &attrList, const std::string &desc, const std::map< std::string, SumoXMLAttrMask > &special=std::map< std::string, SumoXMLAttrMask >())
Parses a list of strings for attribute names and sets the relevant bits in the returned mask.
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)
std::vector< std::string > getVector()
return vector of strings