 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
57 typedTravelDistance.clear();
67 for (std::map<const MSVehicleType*, int>::const_iterator it = typedAmount.begin(); it != typedAmount.end(); ++it) {
70 for (std::map<const MSVehicleType*, double>::const_iterator it = typedSamples.begin(); it != typedSamples.end(); ++it) {
73 for (std::map<const MSVehicleType*, double>::const_iterator it = typedTravelDistance.begin(); it != typedTravelDistance.end(); ++it) {
81 sampleSeconds += timeOnLane;
82 travelledDistance += travelledDistanceVehicleOnLane;
84 typedTravelDistance[&veh.
getVehicleType()] += travelledDistanceVehicleOnLane;
90 if (myParent->vehicleApplies(veh)) {
91 if (getLane() ==
nullptr || getLane() == static_cast<MSVehicle&>(veh).getLane()) {
105 return sampleSeconds == 0 && amount == 0;
111 const double ,
const double defaultTravelTime,
const int )
const {
112 if (sampleSeconds > 0) {
113 dev.
writeAttr(
"amount", amount).
writeAttr(
"averageSpeed",
int(100 * travelledDistance / sampleSeconds));
114 }
else if (defaultTravelTime >= 0.) {
115 dev.
writeAttr(
"amount", amount).
writeAttr(
"averageSpeed",
int(100 * myLaneLength / defaultTravelTime));
119 if (myParent->isTyped()) {
120 for (std::map<const MSVehicleType*, int>::const_iterator it = typedAmount.begin(); it != typedAmount.end(); ++it) {
122 dev.
writeAttr(
"amount", it->second).
writeAttr(
"averageSpeed",
int(100 * typedTravelDistance.find(it->first)->second / typedSamples.find(it->first)->second));
134 const SUMOTime dumpEnd,
const bool useLanes,
135 const bool withEmpty,
const bool printDefaults,
136 const bool withInternal,
137 const bool trackVehicles,
139 const double maxTravelTime,
140 const double minSamples,
141 const double haltSpeed,
142 const std::string& vTypes)
143 :
MSMeanData(id, dumpBegin, dumpEnd, useLanes, withEmpty, printDefaults,
144 withInternal, trackVehicles,
detectPersons, maxTravelTime, minSamples, vTypes),
166 const int duration = int(1000 *
STEPS2TIME(stopTime - startTime) + 0.5);
MSMeanData::MeanDataValues * createValues(MSLane *const lane, const double length, const bool doAdd) const
Create an instance of MeanDataValues.
Representation of a vehicle or person.
virtual void openInterval(OutputDevice &dev, const SUMOTime startTime, const SUMOTime stopTime)
Writes the interval opener.
const bool myDumpEmpty
Whether empty lanes/edges shall be written.
int getNumericalID() const
Returns the numerical id of the edge.
Representation of a lane in the micro simulation.
Static storage of an output device and its base (abstract) implementation.
void notifyMoveInternal(const SUMOTrafficObject &veh, const double, const double timeOnLane, const double, const double meanSpeedVehicleOnLane, const double travelledDistanceFrontOnLane, const double travelledDistanceVehicleOnLane, const double)
Internal notification about the vehicle moves.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
void reset(bool afterWrite=false)
Resets values so they may be used for the next interval.
virtual bool isEmpty() const
Returns whether any data was collected.
SumoXMLTag
Numbers representing SUMO-XML - element names.
virtual ~MSMeanData_Amitran()
Destructor.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Data collector for edges/lanes.
Network state mean data collector for edges/lanes.
MSMeanData_Amitran(const std::string &id, const SUMOTime dumpBegin, const SUMOTime dumpEnd, 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)
Constructor.
double travelledDistance
The sum of the distances the vehicles travelled.
void write(OutputDevice &dev, const SUMOTime period, const double numLanes, const double defaultTravelTime, const int numVehicles=-1) const
Writes output values into the given stream.
A road/street connecting two junctions.
The vehicle has departed (was inserted into the network)
MSLaneMeanDataValues(MSLane *const lane, const double length, const bool doAdd, const MSMeanData_Amitran *parent)
Constructor.
virtual ~MSLaneMeanDataValues()
Destructor.
Data structure for mean (aggregated) edge/lane values.
std::map< const MSVehicleType *, double > typedSamples
The number of sampled vehicle movements by type (in s)
bool detectPersons() const
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
std::map< const MSVehicleType *, double > typedTravelDistance
The sum of the distances the vehicles travelled by type.
const double myHaltSpeed
the minimum sample seconds
std::map< const MSVehicleType *, int > typedAmount
The number of vehicles that entered this lane within the sample interval by type.
void addTo(MSMeanData::MeanDataValues &val) const
Add the values of this to the given one and store them there.
Data structure for mean (aggregated) edge/lane values.
virtual void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "netstats" as root element.
bool isEmpty() const
Returns whether any data was collected.
virtual bool writePrefix(OutputDevice &dev, const MeanDataValues &values, const SumoXMLTag tag, const std::string id) const
Checks for emptiness and writes prefix into the given stream.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Computes current values and adds them to their sums.
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >())
Writes an XML header with optional configuration.
Notification
Definition of a vehicle state.
The vehicle arrived at a junction.
virtual std::string getEdgeID(const MSEdge *const edge)
Return the relevant edge id.