65 const std::string& device,
double haltingSpeedThreshold,
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) {
95 const std::string& lane,
double pos,
SUMOTime splInterval,
96 const std::string& device,
bool friendlyPos,
97 const std::string& vTypes,
int detectPersons) {
113 const std::string& lane,
double pos,
114 const std::string& device,
bool friendlyPos,
115 const std::string& vTypes) {
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,
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();
140 assert(posGiven || endPosGiven);
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();
150 double newPos = pos > 0 ? lane->
getLength() - POSITION_EPS : 0.;
151 ss <<
" (adjusting to new position " << newPos;
155 ss <<
" (0 <= pos < lane->getLength() is required)";
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();
167 double newEndPos = endPos > 0 ? lane->
getLength() : POSITION_EPS;
168 ss <<
" (adjusting to new position " << newEndPos;
172 ss <<
" (0 <= pos < lane->getLength() is required)";
181 det =
createE2Detector(
id,
DU_USER_DEFINED, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes, detectPersons, showDetector);
188 if (link ==
nullptr) {
190 "The detector '" +
id +
"' cannot be build as no connection between lanes '"
191 + lastLane->
getID() +
"' and '" + toLane->
getID() +
"' exists.");
201 det =
createE2Detector(
id,
DU_USER_DEFINED, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes, detectPersons, showDetector);
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,
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);
221 const MSLane*
const firstLane = lanes[0];
222 const MSLane*
const lastLane = lanes.back();
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();
231 double newPos = pos > 0 ? firstLane->
getLength() - POSITION_EPS : 0.;
232 ss <<
" (adjusting to new position " << newPos;
236 ss <<
" (0 <= pos < lane->getLength() is required)";
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();
246 double newEndPos = endPos > 0 ? lastLane->
getLength() : POSITION_EPS;
247 ss <<
" (adjusting to new position " << newEndPos;
251 ss <<
" (0 <= pos < lane->getLength() is required)";
259 det =
createE2Detector(
id,
DU_USER_DEFINED, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes, detectPersons, showDetector);
266 if (link ==
nullptr) {
268 "The detector '" +
id +
"' cannot be build as no connection between lanes '"
269 + lastDetLane->
getID() +
"' and '" + toLane->
getID() +
"' exists.");
280 det =
createE2Detector(
id,
DU_USER_DEFINED, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes, detectPersons, showDetector);
290 const std::string& device,
SUMOTime splInterval,
291 double haltingSpeedThreshold,
293 const std::string& vTypes,
int detectPersons,
bool openEntry) {
302 double pos,
bool friendlyPos) {
316 double pos,
bool friendlyPos) {
364 const std::string& vtype,
SUMOTime frequency,
365 const std::string& device) {
374 const std::string& device,
375 const std::string& vTypes) {
386 const std::string& vTypes,
392 return new MSInductLoop(
id, lane, pos, vTypes, detectPersons,
false);
398 MSLane* lane,
double pos,
const std::string& od,
399 const std::string& vTypes) {
407 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
408 const std::string& vTypes,
int detectPersons,
bool ) {
409 return new MSE2Collector(
id, usage, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes, detectPersons);
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 ) {
417 return new MSE2Collector(
id, usage, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes, detectPersons);
424 double haltingSpeedThreshold,
426 const std::string& vTypes,
429 return new MSE3Collector(
id, entries, exits, haltingSpeedThreshold, haltingTimeThreshold, vTypes, detectPersons, openEntry);
436 const std::string& detid) {
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) {
470 throw InvalidArgument(
"Negative begin time for meandata dump '" +
id +
"'.");
476 throw InvalidArgument(
"End before or at begin for meandata dump '" +
id +
"'.");
480 if (type ==
"" || type ==
"performance" || type ==
"traffic") {
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.");
488 printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, vTypes, writeAttributes);
489 }
else if (type ==
"harmonoise") {
491 printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, vTypes, writeAttributes);
492 }
else if (type ==
"amitran") {
494 printDefaults, withInternal, trackVehicles, detectPersons, maxTravelTime, minSamples, haltSpeed, vTypes, writeAttributes);
496 throw InvalidArgument(
"Invalid type '" + type +
"' for meandata dump '" +
id +
"'.");
498 if (det !=
nullptr) {
500 frequency = end - begin;
514 const std::string& detid) {
517 if (edge ==
nullptr) {
518 throw InvalidArgument(
"The lane with the id '" + edgeID +
"' is not known (while building " +
toString(type) +
" '" + detid +
"').");
526 const std::string& detid) {
529 if (lane ==
nullptr) {
530 throw InvalidArgument(
"The lane with the id '" + laneID +
"' is not known (while building " +
toString(type) +
" '" + detid +
"').");
538 if (splInterval < 0) {
541 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 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.
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.
int myDetectPersons
person detection mode
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.
virtual ~E3DetectorDefinition()
Destructor.
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.
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
An upper class for objects with additional parameters.
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.