65 const std::string& device,
double haltingSpeedThreshold,
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) {
94 const std::string& lane,
double pos,
SUMOTime splInterval,
95 const std::string& device,
bool friendlyPos,
96 const std::string& vTypes) {
111 const std::string& lane,
double pos,
112 const std::string& device,
bool friendlyPos,
113 const std::string& vTypes) {
127 const std::string& device,
SUMOTime frequency,
128 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
129 const std::string& vTypes,
bool friendlyPos,
bool showDetector,
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();
137 assert(posGiven || endPosGiven);
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();
147 double newPos = pos > 0 ? lane->
getLength() - POSITION_EPS : 0.;
148 ss <<
" (adjusting to new position " << newPos;
152 ss <<
" (0 <= pos < lane->getLength() is required)";
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();
164 double newEndPos = endPos > 0 ? lane->
getLength() : POSITION_EPS;
165 ss <<
" (adjusting to new position " << newEndPos;
169 ss <<
" (0 <= pos < lane->getLength() is required)";
178 det =
createE2Detector(
id,
DU_USER_DEFINED, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes, showDetector);
185 if (link ==
nullptr) {
187 "The detector '" +
id +
"' cannot be build as no connection between lanes '"
188 + lastLane->
getID() +
"' and '" + toLane->
getID() +
"' exists.");
198 det =
createE2Detector(
id,
DU_USER_DEFINED, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes, showDetector);
206 const std::string& device,
SUMOTime frequency,
207 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
208 const std::string& vTypes,
bool friendlyPos,
bool showDetector,
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);
217 const MSLane*
const firstLane = lanes[0];
218 const MSLane*
const lastLane = lanes.back();
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();
227 double newPos = pos > 0 ? firstLane->
getLength() - POSITION_EPS : 0.;
228 ss <<
" (adjusting to new position " << newPos;
232 ss <<
" (0 <= pos < lane->getLength() is required)";
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();
242 double newEndPos = endPos > 0 ? lastLane->
getLength() : POSITION_EPS;
243 ss <<
" (adjusting to new position " << newEndPos;
247 ss <<
" (0 <= pos < lane->getLength() is required)";
262 if (link ==
nullptr) {
264 "The detector '" +
id +
"' cannot be build as no connection between lanes '"
265 + lastDetLane->
getID() +
"' and '" + toLane->
getID() +
"' exists.");
286 const std::string& device,
SUMOTime splInterval,
287 double haltingSpeedThreshold,
289 const std::string& vTypes,
bool openEntry) {
297 double pos,
bool friendlyPos) {
311 double pos,
bool friendlyPos) {
357 const std::string& vtype,
SUMOTime frequency,
358 const std::string& device) {
367 const std::string& device,
368 const std::string& vTypes) {
379 const std::string& vTypes,
bool) {
389 MSLane* lane,
double pos,
const std::string& od,
390 const std::string& vTypes) {
398 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
399 const std::string& vTypes,
bool ) {
400 return new MSE2Collector(
id, usage, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes);
405 DetectorUsage usage, std::vector<MSLane*> lanes,
double pos,
double endPos,
406 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
407 const std::string& vTypes,
bool ) {
408 return new MSE2Collector(
id, usage, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes);
415 double haltingSpeedThreshold,
417 const std::string& vTypes,
419 return new MSE3Collector(
id, entries, exits, haltingSpeedThreshold, haltingTimeThreshold, vTypes, openEntry);
425 const std::string& detid) {
435 throw InvalidArgument(
"The position of detector '" + detid +
"' lies beyond the lane's '" + lane->
getID() +
"' end.");
442 throw InvalidArgument(
"The position of detector '" + detid +
"' lies before the lane's '" + lane->
getID() +
"' begin.");
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) {
459 throw InvalidArgument(
"Negative begin time for meandata dump '" +
id +
"'.");
465 throw InvalidArgument(
"End before or at begin for meandata dump '" +
id +
"'.");
469 if (type ==
"" || type ==
"performance" || type ==
"traffic") {
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.");
477 printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, vTypes, writeAttributes);
478 }
else if (type ==
"harmonoise") {
480 printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, vTypes, writeAttributes);
481 }
else if (type ==
"amitran") {
483 printDefaults, withInternal, trackVehicles, detectPersons, maxTravelTime, minSamples, haltSpeed, vTypes, writeAttributes);
485 throw InvalidArgument(
"Invalid type '" + type +
"' for meandata dump '" +
id +
"'.");
487 if (det !=
nullptr) {
489 frequency = end - begin;
503 const std::string& detid) {
506 if (edge ==
nullptr) {
507 throw InvalidArgument(
"The lane with the id '" + edgeID +
"' is not known (while building " +
toString(type) +
" '" + detid +
"').");
515 const std::string& detid) {
518 if (lane ==
nullptr) {
519 throw InvalidArgument(
"The lane with the id '" + laneID +
"' is not known (while building " +
toString(type) +
" '" + detid +
"').");
527 if (splInterval < 0) {
530 if (splInterval == 0) {
std::vector< MSCrossSection > CrossSectionVector
#define WRITE_WARNING(msg)
bool checkStepLengthMultiple(const SUMOTime t, const std::string &error, SUMOTime deltaT)
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 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.
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.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSDetectorControl & getDetectorControl()
Returns the detector control.
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 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()
Destructor.
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.
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.