Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions data/xsd/statistic_file.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<xsd:attribute name="speed" use="required" type="nonNegativeFloatType"/>
<xsd:attribute name="duration" use="required" type="timeType"/>
<xsd:attribute name="waitingTime" use="required" type="timeType"/>
<xsd:attribute name="timeLoss" use="required" type="timeType"/>
<xsd:attribute name="timeLoss" use="required" type="signedTimeType"/>
<xsd:attribute name="departDelay" use="required" type="timeType"/>
<xsd:attribute name="departDelayWaiting" use="required" type="timeTypeWithErrorValue"/>
<xsd:attribute name="totalTravelTime" use="required" type="timeType"/>
Expand All @@ -78,7 +78,7 @@
<xsd:attribute name="speed" use="required" type="nonNegativeFloatType"/>
<xsd:attribute name="duration" use="required" type="timeType"/>
<xsd:attribute name="waitingTime" use="required" type="timeType"/>
<xsd:attribute name="timeLoss" use="required" type="timeType"/>
<xsd:attribute name="timeLoss" use="required" type="signedTimeType"/>
<xsd:attribute name="departDelay" use="required" type="timeType"/>
<xsd:attribute name="totalTravelTime" use="required" type="timeType"/>
</xsd:complexType>
Expand All @@ -88,7 +88,7 @@
<xsd:attribute name="number" use="required" type="xsd:nonNegativeInteger"/>
<xsd:attribute name="routeLength" use="required" type="nonNegativeFloatType"/>
<xsd:attribute name="duration" use="required" type="timeType"/>
<xsd:attribute name="timeLoss" use="required" type="timeType"/>
<xsd:attribute name="timeLoss" use="required" type="signedTimeType"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="rideStatistics" minOccurs="0" maxOccurs="1" type="rideStatisticsType"/>
Expand All @@ -98,6 +98,7 @@
</xsd:element>

<xsd:complexType name="rideStatisticsType">
<xsd:attribute name="waitingTime" use="optional" type="signedTimeType"/>
<xsd:attribute name="number" use="required" type="xsd:nonNegativeInteger"/>
<xsd:attribute name="routeLength" use="optional" type="nonNegativeFloatType"/>
<xsd:attribute name="duration" use="optional" type="timeType"/>
Expand Down
20 changes: 10 additions & 10 deletions data/xsd/tripinfo_file.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<xsd:attribute name="waitingTime" use="required" type="timeType"/>
<xsd:attribute name="waitingCount" use="required" type="xsd:nonNegativeInteger"/>
<xsd:attribute name="stopTime" use="required" type="timeType"/>
<xsd:attribute name="timeLoss" use="optional" type="timeType"/>
<xsd:attribute name="timeLoss" use="optional" type="signedTimeType"/>
<xsd:attribute name="rerouteNo" type="xsd:nonNegativeInteger" use="required"/>
<xsd:attribute name="devices" use="required" type="xsd:string"/>
<xsd:attribute name="vType" use="required" type="xsd:string"/>
Expand Down Expand Up @@ -115,8 +115,8 @@
<xsd:attribute name="type" use="required" type="xsd:string"/>
<xsd:attribute name="speedFactor" type="positiveFloatType"/>
<xsd:attribute name="duration" type="timeTypeWithErrorValue"/>
<xsd:attribute name="waitingTime" type="timeTypeWithErrorValue"/>
<xsd:attribute name="timeLoss" type="timeTypeWithErrorValue"/>
<xsd:attribute name="waitingTime" type="signedTimeType"/>
<xsd:attribute name="timeLoss" type="signedTimeType"/>
<xsd:attribute name="traveltime" type="timeTypeWithErrorValue"/>
</xsd:complexType>
</xsd:element>
Expand All @@ -132,8 +132,8 @@
<xsd:attribute name="depart" use="required" type="timeTypeWithErrorValue"/>
<xsd:attribute name="type" use="required" type="xsd:string"/>
<xsd:attribute name="duration" type="timeTypeWithErrorValue"/>
<xsd:attribute name="waitingTime" type="timeTypeWithErrorValue"/>
<xsd:attribute name="timeLoss" type="timeTypeWithErrorValue"/>
<xsd:attribute name="waitingTime" type="signedTimeType"/>
<xsd:attribute name="timeLoss" type="signedTimeType"/>
<xsd:attribute name="traveltime" type="timeTypeWithErrorValue"/>
</xsd:complexType>
</xsd:element>
Expand All @@ -149,14 +149,14 @@

<xsd:element name="ride">
<xsd:complexType>
<xsd:attribute name="waitingTime" use="required" type="timeTypeWithErrorValue"/>
<xsd:attribute name="waitingTime" use="required" type="signedTimeType"/>
<xsd:attribute name="vehicle" use="required" type="xsd:string"/>
<xsd:attribute name="depart" use="required" type="timeTypeWithErrorValue"/>
<xsd:attribute name="arrival" use="required" type="timeTypeWithErrorValue"/>
<xsd:attribute name="arrivalPos" use="required" type="nonNegativeFloatTypeWithErrorValue"/>
<xsd:attribute name="duration" use="required" type="timeTypeWithErrorValue"/>
<xsd:attribute name="routeLength" use="required" type="nonNegativeFloatTypeWithErrorValue"/>
<xsd:attribute name="timeLoss" use="required" type="timeTypeWithErrorValue"/> <!-- negative values indicate jumps -->
<xsd:attribute name="timeLoss" use="required" type="signedTimeType"/> <!-- negative values indicate jumps -->
</xsd:complexType>
</xsd:element>

Expand All @@ -170,7 +170,7 @@
<xsd:attribute name="routeLength" use="required" type="nonNegativeFloatTypeWithErrorValue"/>
<xsd:attribute name="timeLoss" use="required" type="signedTimeType"/> <!-- negative values indicate jumps or shortcuts in jupedsim -->
<xsd:attribute name="maxSpeed" use="required" type="nonNegativeFloatType"/>
<xsd:attribute name="waitingTime" use="required" type="nonNegativeFloatType"/>
<xsd:attribute name="waitingTime" use="required" type="timeType"/>
</xsd:complexType>
</xsd:element>

Expand All @@ -186,14 +186,14 @@

<xsd:element name="transport">
<xsd:complexType>
<xsd:attribute name="waitingTime" use="required" type="timeTypeWithErrorValue"/>
<xsd:attribute name="waitingTime" use="required" type="signedTimeType"/>
<xsd:attribute name="vehicle" use="required" type="xsd:string"/>
<xsd:attribute name="depart" use="required" type="timeTypeWithErrorValue"/>
<xsd:attribute name="arrival" use="required" type="timeTypeWithErrorValue"/>
<xsd:attribute name="arrivalPos" use="required" type="nonNegativeFloatTypeWithErrorValue"/>
<xsd:attribute name="duration" use="required" type="timeTypeWithErrorValue"/>
<xsd:attribute name="routeLength" use="required" type="nonNegativeFloatTypeWithErrorValue"/>
<xsd:attribute name="timeLoss" use="required" type="timeTypeWithErrorValue"/> <!-- negative values indicate jumps -->
<xsd:attribute name="timeLoss" use="required" type="signedTimeType"/> <!-- negative values indicate jumps -->
</xsd:complexType>
</xsd:element>

Expand Down
2 changes: 2 additions & 0 deletions docs/web/docs/Basics/Using_the_Command_Line_Applications.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ By default, all time values written by sumo are in seconds. All applications and

Setting the option **--human-readable-time** also affects how some time values are formatted in sumo-gui dialogs (i.e. breakpoints).

Trip information uses this format for timestamps. Trip intervals with an absolute value of at least one hour also use this format in trip information, console statistics, and **--statistic-output**. Shorter intervals use seconds. A negative time starts with a minus sign.

## Input
All time values in options and xml input may always be given as seconds or in "HH:MM:SS" or "DD:HH:MM:SS" format.

Expand Down
96 changes: 62 additions & 34 deletions src/microsim/devices/MSDevice_Tripinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,20 +357,20 @@ MSDevice_Tripinfo::generateOutput(OutputDevice* tripinfoOut) const {
assert(param.depart <= SIMSTEP || param.departProcedure != DepartDefinition::GIVEN);
departDelay = SIMSTEP - param.depart;
}
os.writeAttr("departDelay", time2string(departDelay));
os.writeAttr("departDelay", formatTimeInterval(departDelay));
os.writeAttr("arrival", time2string(myArrivalTime));
os.writeAttr("arrivalLane", myArrivalLane);
os.writeAttr("arrivalPos", myArrivalPos);
if (MSGlobals::gLateralResolution > 0) {
os.writeAttr("arrivalPosLat", myArrivalPosLat);
}
os.writeAttr("arrivalSpeed", myArrivalSpeed);
os.writeAttr("duration", time2string(duration));
os.writeAttr("duration", formatTimeInterval(duration));
os.writeAttr("routeLength", routeLength);
os.writeAttr(SUMO_ATTR_WAITINGTIME, time2string(myWaitingTime));
os.writeAttr(SUMO_ATTR_WAITINGTIME, formatTimeInterval(myWaitingTime));
os.writeAttr(SUMO_ATTR_WAITINGCOUNT, myWaitingCount);
os.writeAttr(SUMO_ATTR_STOPTIME, time2string(myStoppingTime));
os.writeAttr(SUMO_ATTR_TIMELOSS, time2string(timeLoss));
os.writeAttr(SUMO_ATTR_STOPTIME, formatTimeInterval(myStoppingTime));
os.writeAttr(SUMO_ATTR_TIMELOSS, formatTimeInterval(timeLoss));
os.writeAttr("rerouteNo", myHolder.getNumberReroutes());
os.writeAttr("devices", toString(myHolder.getDevices()));
os.writeAttr("vType", myHolder.getVehicleType().getID());
Expand Down Expand Up @@ -488,6 +488,34 @@ MSDevice_Tripinfo::addRideTransportData(const bool isPerson, const double distan
}


static bool
useHumanReadableStatisticTime(double seconds) {
return gHumanReadableTime && std::abs(seconds) >= STEPS2TIME(SUMOTime_HOUR);
}


static std::string
formatStatisticTime(double seconds) {
return useHumanReadableStatisticTime(seconds) ? time2string(TIME2STEPS(seconds), true) : toString(seconds);
}


std::string
MSDevice_Tripinfo::formatTimeInterval(SUMOTime time) {
return time2string(time, gHumanReadableTime && (time <= -SUMOTime_HOUR || time >= SUMOTime_HOUR));
}


static void
writeStatisticTime(OutputDevice& out, const std::string& attribute, double seconds) {
if (useHumanReadableStatisticTime(seconds)) {
out.writeAttr(attribute, time2string(TIME2STEPS(seconds), true));
} else {
out.writeAttr(attribute, seconds);
}
}


std::string
MSDevice_Tripinfo::printStatistics() {
std::ostringstream msg;
Expand All @@ -497,31 +525,31 @@ MSDevice_Tripinfo::printStatistics() {
msg << "Statistics (avg of " << myVehicleCount << "):\n";
msg << " RouteLength: " << getAvgRouteLength() << "\n"
<< " Speed: " << getAvgTripSpeed() << "\n"
<< " Duration: " << getAvgDuration() << "\n"
<< " WaitingTime: " << getAvgWaitingTime() << "\n"
<< " TimeLoss: " << getAvgTimeLoss() << "\n"
<< " DepartDelay: " << getAvgDepartDelay() << "\n";
<< " Duration: " << formatStatisticTime(getAvgDuration()) << "\n"
<< " WaitingTime: " << formatStatisticTime(getAvgWaitingTime()) << "\n"
<< " TimeLoss: " << formatStatisticTime(getAvgTimeLoss()) << "\n"
<< " DepartDelay: " << formatStatisticTime(getAvgDepartDelay()) << "\n";
}
if (myBikeCount > 0) {
msg << "Bike Statistics (avg of " << myBikeCount << "):\n"
<< " RouteLength: " << getAvgBikeRouteLength() << "\n"
<< " Speed: " << getAvgBikeTripSpeed() << "\n"
<< " Duration: " << getAvgBikeDuration() << "\n"
<< " WaitingTime: " << getAvgBikeWaitingTime() << "\n"
<< " TimeLoss: " << getAvgBikeTimeLoss() << "\n"
<< " DepartDelay: " << getAvgBikeDepartDelay() << "\n";
<< " Duration: " << formatStatisticTime(getAvgBikeDuration()) << "\n"
<< " WaitingTime: " << formatStatisticTime(getAvgBikeWaitingTime()) << "\n"
<< " TimeLoss: " << formatStatisticTime(getAvgBikeTimeLoss()) << "\n"
<< " DepartDelay: " << formatStatisticTime(getAvgBikeDepartDelay()) << "\n";
if (myVehicleCount > 0 && myWaitingDepartDelay >= 0) {
msg << "Statistics (avg of " << (myVehicleCount + myBikeCount) << "):\n";
}
}
if (myWaitingDepartDelay >= 0) {
msg << " DepartDelayWaiting: " << getAvgDepartDelayWaiting() << "\n";
msg << " DepartDelayWaiting: " << formatStatisticTime(getAvgDepartDelayWaiting()) << "\n";
}
if (myWalkCount > 0) {
msg << "Pedestrian Statistics (avg of " << myWalkCount << " walks):\n"
<< " RouteLength: " << getAvgWalkRouteLength() << "\n"
<< " Duration: " << getAvgWalkDuration() << "\n"
<< " TimeLoss: " << getAvgWalkTimeLoss() << "\n";
<< " Duration: " << formatStatisticTime(getAvgWalkDuration()) << "\n"
<< " TimeLoss: " << formatStatisticTime(getAvgWalkTimeLoss()) << "\n";
}
printRideStatistics(msg, "Ride", "rides", 0);
printRideStatistics(msg, "Transport", "transports", 1);
Expand All @@ -532,9 +560,9 @@ void
MSDevice_Tripinfo::printRideStatistics(std::ostringstream& msg, const std::string& category, const std::string& modeName, const int index) {
if (myRideCount[index] > 0) {
msg << category << " Statistics (avg of " << myRideCount[index] << " " << modeName << "):\n";
msg << " WaitingTime: " << STEPS2TIME(myTotalRideWaitingTime[index] / myRideCount[index]) << "\n";
msg << " WaitingTime: " << formatStatisticTime(STEPS2TIME(myTotalRideWaitingTime[index] / myRideCount[index])) << "\n";
msg << " RouteLength: " << myTotalRideRouteLength[index] / myRideCount[index] << "\n";
msg << " Duration: " << STEPS2TIME(myTotalRideDuration[index] / myRideCount[index]) << "\n";
msg << " Duration: " << formatStatisticTime(STEPS2TIME(myTotalRideDuration[index] / myRideCount[index])) << "\n";
if (myRideBusCount[index] > 0) {
msg << " Bus: " << myRideBusCount[index] << "\n";
}
Expand Down Expand Up @@ -562,31 +590,31 @@ MSDevice_Tripinfo::writeStatistics(OutputDevice& od) {
od.writeAttr("count", myVehicleCount);
od.writeAttr("routeLength", getAvgRouteLength());
od.writeAttr("speed", getAvgTripSpeed());
od.writeAttr("duration", getAvgDuration());
od.writeAttr("waitingTime", getAvgWaitingTime());
od.writeAttr("timeLoss", getAvgTimeLoss());
od.writeAttr("departDelay", getAvgDepartDelay());
od.writeAttr("departDelayWaiting", getAvgDepartDelayWaiting());
od.writeAttr("totalTravelTime", time2string(myTotalDuration));
od.writeAttr("totalDepartDelay", time2string(TIME2STEPS(getTotalDepartDelay() + getTotalBikeDepartDelay())));
writeStatisticTime(od, "duration", getAvgDuration());
writeStatisticTime(od, "waitingTime", getAvgWaitingTime());
writeStatisticTime(od, "timeLoss", getAvgTimeLoss());
writeStatisticTime(od, "departDelay", getAvgDepartDelay());
writeStatisticTime(od, "departDelayWaiting", getAvgDepartDelayWaiting());
od.writeAttr("totalTravelTime", formatTimeInterval(myTotalDuration));
od.writeAttr("totalDepartDelay", formatTimeInterval(TIME2STEPS(getTotalDepartDelay() + getTotalBikeDepartDelay())));
od.closeTag();
if (myBikeCount > 0) {
od.openTag("bikeTripStatistics");
od.writeAttr("count", myBikeCount);
od.writeAttr("routeLength", getAvgBikeRouteLength());
od.writeAttr("speed", getAvgBikeTripSpeed());
od.writeAttr("duration", getAvgBikeDuration());
od.writeAttr("waitingTime", getAvgBikeWaitingTime());
od.writeAttr("timeLoss", getAvgBikeTimeLoss());
od.writeAttr("departDelay", getAvgBikeDepartDelay());
od.writeAttr("totalTravelTime", time2string(myTotalBikeDuration));
writeStatisticTime(od, "duration", getAvgBikeDuration());
writeStatisticTime(od, "waitingTime", getAvgBikeWaitingTime());
writeStatisticTime(od, "timeLoss", getAvgBikeTimeLoss());
writeStatisticTime(od, "departDelay", getAvgBikeDepartDelay());
od.writeAttr("totalTravelTime", formatTimeInterval(myTotalBikeDuration));
od.closeTag();
}
od.openTag("pedestrianStatistics");
od.writeAttr("number", myWalkCount);
od.writeAttr("routeLength", getAvgWalkRouteLength());
od.writeAttr("duration", getAvgWalkDuration());
od.writeAttr("timeLoss", getAvgWalkTimeLoss());
writeStatisticTime(od, "duration", getAvgWalkDuration());
writeStatisticTime(od, "timeLoss", getAvgWalkTimeLoss());
od.closeTag();
writeRideStatistics(od, "rideStatistics", 0);
writeRideStatistics(od, "transportStatistics", 1);
Expand All @@ -597,9 +625,9 @@ MSDevice_Tripinfo::writeRideStatistics(OutputDevice& od, const std::string& cate
od.openTag(category);
od.writeAttr("number", myRideCount[index]);
if (myRideCount[index] > 0) {
od.writeAttr("waitingTime", STEPS2TIME(myTotalRideWaitingTime[index] / myRideCount[index]));
writeStatisticTime(od, "waitingTime", STEPS2TIME(myTotalRideWaitingTime[index] / myRideCount[index]));
od.writeAttr("routeLength", myTotalRideRouteLength[index] / myRideCount[index]);
od.writeAttr("duration", STEPS2TIME(myTotalRideDuration[index] / myRideCount[index]));
writeStatisticTime(od, "duration", STEPS2TIME(myTotalRideDuration[index] / myRideCount[index]));
od.writeAttr("bus", myRideBusCount[index]);
od.writeAttr("train", myRideRailCount[index]);
od.writeAttr("taxi", myRideTaxiCount[index]);
Expand Down
3 changes: 3 additions & 0 deletions src/microsim/devices/MSDevice_Tripinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ class MSDevice_Tripinfo : public MSVehicleDevice {
static void addRideTransportData(const bool isPerson, const double distance, const SUMOTime duration,
const SUMOVehicleClass vClass, const std::string& line, const SUMOTime waitingTime);

/// @brief format a trip interval using clock notation for magnitudes of at least one hour
static std::string formatTimeInterval(SUMOTime time);

/// @brief get statistics for printing to stdout
static std::string printStatistics();

Expand Down
3 changes: 2 additions & 1 deletion src/microsim/transportables/MSPerson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <utils/geom/GeomHelper.h>
#include <utils/router/IntermodalNetwork.h>
#include <microsim/MSNet.h>
#include <microsim/devices/MSDevice_Tripinfo.h>
#include <microsim/MSEdge.h>
#include <microsim/MSLane.h>
#include <microsim/transportables/MSTransportableControl.h>
Expand Down Expand Up @@ -128,7 +129,7 @@ MSPerson::MSPersonStage_Access::tripInfoOutput(OutputDevice& os, const MSTranspo
}
os.writeAttr("depart", time2string(myDeparted));
os.writeAttr("arrival", myArrived >= 0 ? time2string(myArrived) : "-1");
os.writeAttr("duration", myArrived > 0 ? time2string(getDuration()) : "-1");
os.writeAttr("duration", myArrived > 0 ? MSDevice_Tripinfo::formatTimeInterval(getDuration()) : "-1");
os.writeAttr("routeLength", myDist);
os.closeTag();
}
Expand Down
Loading
Loading