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,
113 }
else if (length > 0 && pos + length > clane->
getLength()) {
131 const std::string& lane,
double pos,
132 const std::string& device,
bool friendlyPos,
133 const std::string name,
134 const std::string& vTypes,
135 const std::string& nextEdges) {
150 const std::string& device,
SUMOTime frequency,
151 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
152 const std::string name,
const std::string& vTypes,
153 const std::string& nextEdges,
154 int detectPersons,
bool friendlyPos,
bool showDetector,
157 bool tlsGiven = tlls !=
nullptr;
158 bool toLaneGiven = toLane !=
nullptr;
159 bool posGiven = pos != std::numeric_limits<double>::max();
160 bool endPosGiven = endPos != std::numeric_limits<double>::max();
162 assert(posGiven || endPosGiven);
167 std::stringstream ss;
168 ss <<
"The given position (=" << pos <<
") for detector '" <<
id
169 <<
"' does not lie on the given lane '" << lane->
getID()
170 <<
"' with length " << lane->
getLength();
172 double newPos = pos > 0 ? lane->
getLength() - POSITION_EPS : 0.;
173 ss <<
" (adjusting to new position " << newPos;
177 ss <<
" (0 <= pos < lane->getLength() is required)";
184 std::stringstream ss;
185 ss <<
"The given end position (=" << endPos <<
") for detector '" <<
id
186 <<
"' does not lie on the given lane '" << lane->
getID()
187 <<
"' with length " << lane->
getLength();
189 double newEndPos = endPos > 0 ? lane->
getLength() : POSITION_EPS;
190 ss <<
" (adjusting to new position " << newEndPos;
194 ss <<
" (0 <= pos < lane->getLength() is required)";
203 det =
createE2Detector(
id,
DU_USER_DEFINED, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons, showDetector);
210 if (link ==
nullptr) {
212 "The detector '" +
id +
"' cannot be build as no connection between lanes '"
213 + lastLane->
getID() +
"' and '" + toLane->
getID() +
"' exists.");
223 det =
createE2Detector(
id,
DU_USER_DEFINED, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons, showDetector);
232 const std::string& device,
SUMOTime frequency,
233 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
234 const std::string name,
const std::string& vTypes,
235 const std::string& nextEdges,
236 int detectPersons,
bool friendlyPos,
bool showDetector,
239 bool tlsGiven = tlls !=
nullptr;
240 bool toLaneGiven = toLane !=
nullptr;
241 assert(pos != std::numeric_limits<double>::max());
242 assert(endPos != std::numeric_limits<double>::max());
243 assert(lanes.size() != 0);
245 const MSLane*
const firstLane = lanes[0];
246 const MSLane*
const lastLane = lanes.back();
250 std::stringstream ss;
251 ss <<
"The given position (=" << pos <<
") for detector '" <<
id
252 <<
"' does not lie on the given lane '" << firstLane->
getID()
253 <<
"' with length " << firstLane->
getLength();
255 double newPos = pos > 0 ? firstLane->
getLength() - POSITION_EPS : 0.;
256 ss <<
" (adjusting to new position " << newPos;
260 ss <<
" (0 <= pos < lane->getLength() is required)";
264 if (endPos > lastLane->
getLength() || (endPos <= 0 && -endPos >= lastLane->
getLength())) {
265 std::stringstream ss;
266 ss <<
"The given end position (=" << endPos <<
") for detector '" <<
id
267 <<
"' does not lie on the given lane '" << lastLane->
getID()
268 <<
"' with length " << lastLane->
getLength();
270 double newEndPos = endPos > 0 ? lastLane->
getLength() : POSITION_EPS;
271 ss <<
" (adjusting to new position " << newEndPos;
275 ss <<
" (0 <= pos < lane->getLength() is required)";
283 det =
createE2Detector(
id,
DU_USER_DEFINED, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons, showDetector);
290 if (link ==
nullptr) {
292 "The detector '" +
id +
"' cannot be build as no connection between lanes '"
293 + lastDetLane->
getID() +
"' and '" + toLane->
getID() +
"' exists.");
304 det =
createE2Detector(
id,
DU_USER_DEFINED, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons, showDetector);
314 const std::string& device,
SUMOTime splInterval,
315 double haltingSpeedThreshold,
317 const std::string name,
318 const std::string& vTypes,
319 const std::string& nextEdges,
320 int detectPersons,
bool openEntry,
bool expectArrival) {
322 myE3Definition =
new E3DetectorDefinition(
id, device, haltingSpeedThreshold, haltingTimeThreshold, splInterval, name, vTypes, nextEdges, detectPersons, openEntry, expectArrival);
329 double pos,
bool friendlyPos) {
343 double pos,
bool friendlyPos) {
395 const std::string& vtype,
SUMOTime frequency,
396 const std::string& device) {
405 const std::string& device,
406 const std::string& vTypes) {
419 const std::string name,
420 const std::string& vTypes,
421 const std::string& nextEdges,
427 return new MSInductLoop(
id, lane, pos, length, name, vTypes, nextEdges, detectPersons,
false);
433 MSLane* lane,
double pos,
const std::string& od,
434 const std::string name,
const std::string& vTypes,
435 const std::string& nextEdges) {
443 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
444 const std::string name,
const std::string& vTypes,
445 const std::string& nextEdges,
446 int detectPersons,
bool ) {
447 return new MSE2Collector(
id, usage, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons);
452 DetectorUsage usage, std::vector<MSLane*> lanes,
double pos,
double endPos,
453 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
454 const std::string name,
const std::string& vTypes,
455 const std::string& nextEdges,
456 int detectPersons,
bool ) {
457 return new MSE2Collector(
id, usage, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, name, vTypes, nextEdges, detectPersons);
464 double haltingSpeedThreshold,
466 const std::string name,
const std::string& vTypes,
467 const std::string& nextEdges,
470 bool expectArrival) {
471 return new MSE3Collector(
id, entries, exits, haltingSpeedThreshold, haltingTimeThreshold, name, vTypes, nextEdges, detectPersons, openEntry, expectArrival);
478 const std::string& detid) {
505 const bool useLanes,
const bool withEmpty,
const bool printDefaults,
506 const bool withInternal,
const bool trackVehicles,
const int detectPersons,
507 const double maxTravelTime,
const double minSamples,
508 const double haltSpeed,
const std::string& vTypes,
509 const std::string& writeAttributes,
510 std::vector<MSEdge*> edges,
512 const std::string& device) {
514 throw InvalidArgument(
"Negative begin time for meandata dump '" +
id +
"'.");
520 throw InvalidArgument(
"End before or at begin for meandata dump '" +
id +
"'.");
524 if (type ==
"" || type ==
"performance" || type ==
"traffic") {
526 printDefaults, withInternal, trackVehicles, detectPersons, maxTravelTime, minSamples, haltSpeed, vTypes, writeAttributes, edges, aggregate);
527 }
else if (type ==
"emissions" || type ==
"hbefa") {
528 if (type ==
"hbefa") {
529 WRITE_WARNING(
TL(
"The netstate type 'hbefa' is deprecated. Please use the type 'emissions' instead."));
532 printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, vTypes, writeAttributes, edges, aggregate);
533 }
else if (type ==
"harmonoise") {
535 printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, vTypes, writeAttributes, edges, aggregate);
536 }
else if (type ==
"amitran") {
538 printDefaults, withInternal, trackVehicles, detectPersons, maxTravelTime, minSamples, haltSpeed, vTypes, writeAttributes, edges, aggregate);
540 throw InvalidArgument(
"Invalid type '" + type +
"' for meandata dump '" +
id +
"'.");
542 if (det !=
nullptr) {
544 frequency = end - begin;
558 const std::string& detid) {
561 if (edge ==
nullptr) {
562 throw InvalidArgument(
"The lane with the id '" + edgeID +
"' is not known (while building " +
toString(type) +
" '" + detid +
"').");
570 const std::string& detid) {
573 if (lane ==
nullptr) {
574 throw InvalidArgument(
"The lane with the id '" + laneID +
"' is not known (while building " +
toString(type) +
" '" + detid +
"').");
582 if (splInterval < 0) {
585 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.