44 #include <mesosim/MELoop.h>
45 #include <mesosim/MESegment.h>
48 #ifdef CHECK_MEMORY_LEAKS
50 #endif // CHECK_MEMORY_LEAKS
62 const std::set<std::string>*
const vTypes,
76 typedTravelDistance.clear();
86 for (std::map<const MSVehicleType*, unsigned>::const_iterator it = typedAmount.begin(); it != typedAmount.end(); ++it) {
89 for (std::map<const MSVehicleType*, SUMOReal>::const_iterator it = typedSamples.begin(); it != typedSamples.end(); ++it) {
92 for (std::map<const MSVehicleType*, SUMOReal>::const_iterator it = typedTravelDistance.begin(); it != typedTravelDistance.end(); ++it) {
100 sampleSeconds += timeOnLane;
101 travelledDistance += speed * timeOnLane;
109 if (vehicleApplies(veh)) {
110 if (getLane() == 0 || getLane() == static_cast<MSVehicle&>(veh).getLane()) {
124 return sampleSeconds == 0 && amount == 0;
131 if (sampleSeconds > 0) {
132 dev.
writeAttr(
"amount", amount).
writeAttr(
"averageSpeed",
int(100 * travelledDistance / sampleSeconds));
133 }
else if (defaultTravelTime >= 0.) {
134 dev.
writeAttr(
"amount", amount).
writeAttr(
"averageSpeed",
int(100 * myLaneLength / defaultTravelTime));
139 for (std::map<const MSVehicleType*, unsigned>::const_iterator it = typedAmount.begin(); it != typedAmount.end(); ++it) {
141 dev.
writeAttr(
"amount", it->second).
writeAttr(
"averageSpeed",
int(100 * typedTravelDistance.find(it->first)->second / typedSamples.find(it->first)->second));
153 const SUMOTime dumpEnd,
const bool useLanes,
154 const bool withEmpty,
const bool printDefaults,
155 const bool withInternal,
156 const bool trackVehicles,
160 const std::set<std::string> vTypes)
161 :
MSMeanData(id, dumpBegin, dumpEnd, useLanes, withEmpty, printDefaults,
162 withInternal, trackVehicles, maxTravelTime, minSamples, vTypes),
172 dev.
writeXMLHeader(
"linkData",
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo-sim.org/xsd/amitran/linkdata.xsd\"");
184 const int duration =
int(1000 *
STEPS2TIME(stopTime - startTime) + 0.5);
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason)
Computes current values and adds them to their sums.
Data collector for edges/lanes.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
SumoXMLTag
Numbers representing SUMO-XML - element names.
Network state mean data collector for edges/lanes.
void notifyMoveInternal(SUMOVehicle &veh, SUMOReal timeOnLane, SUMOReal speed)
Internal notification about the vehicle moves.
The vehicle arrived at a junction.
SUMOReal travelledDistance
The sum of the distances the vehicles travelled.
Notification
Definition of a vehicle state.
MSLaneMeanDataValues(MSLane *const lane, const SUMOReal length, const bool doAdd, const std::set< std::string > *const vTypes=0, const MSMeanData_Amitran *parent=0)
Constructor.
const std::set< std::string > myVehicleTypes
The vehicle types to look for (empty means all)
void addTo(MSMeanData::MeanDataValues &val) const
Add the values of this to the given one and store them there.
std::map< const MSVehicleType *, SUMOReal > typedSamples
The number of sampled vehicle movements by type (in s)
bool isEmpty() const
Returns whether any data was collected.
Data structure for mean (aggregated) edge/lane values.
std::map< const MSVehicleType *, unsigned > typedAmount
The number of vehicles that entered this lane within the sample interval by type. ...
bool writeXMLHeader(const std::string &rootElement, const std::string &attrs="", const std::string &comment="")
Writes an XML header with optional configuration.
const SUMOReal myHaltSpeed
the minimum sample seconds
A road/street connecting two junctions.
MSMeanData::MeanDataValues * createValues(MSLane *const lane, const SUMOReal length, const bool doAdd) const
Create an instance of MeanDataValues.
virtual ~MSMeanData_Amitran()
Destructor.
Representation of a vehicle.
Data structure for mean (aggregated) edge/lane values.
virtual bool isEmpty() const
Returns whether any data was collected.
void write(OutputDevice &dev, const SUMOTime period, const SUMOReal numLanes, const SUMOReal defaultTravelTime, const int numVehicles=-1) const
Writes output values into the given stream.
void reset(bool afterWrite=false)
Resets values so they may be used for the next interval.
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 SUMOReal maxTravelTime, const SUMOReal minSamples, const SUMOReal haltSpeed, const std::set< std::string > vTypes)
Constructor.
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.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
virtual void openInterval(OutputDevice &dev, const SUMOTime startTime, const SUMOTime stopTime)
Writes the interval opener.
virtual std::string getEdgeID(const MSEdge *const edge)
Return the relevant edge id.
The vehicle has departed (was inserted into the network)
virtual void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "netstats" as root element.
int getNumericalID() const
Returns the numerical id of the edge.
virtual ~MSLaneMeanDataValues()
Destructor.
Static storage of an output device and its base (abstract) implementation.
bool closeTag()
Closes the most recently opened tag.
const bool myDumpEmpty
Whether empty lanes/edges shall be written.
Representation of a lane in the micro simulation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
std::map< const MSVehicleType *, SUMOReal > typedTravelDistance
The sum of the distances the vehicles travelled by type.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.