aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/reports/Summary.java
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2018-05-31 09:04:38 +0500
committerAbyss777 <abyss@fox5.ru>2018-05-31 09:04:38 +0500
commit3d14b6504b01b26e529717b88318be54094b8816 (patch)
tree2586ec5b6e0d0e28615a6caf7b7f69ce94f7573b /src/org/traccar/reports/Summary.java
parent607123610018cdc1f0e391fec43e54e769d40a06 (diff)
downloadtrackermap-server-3d14b6504b01b26e529717b88318be54094b8816.tar.gz
trackermap-server-3d14b6504b01b26e529717b88318be54094b8816.tar.bz2
trackermap-server-3d14b6504b01b26e529717b88318be54094b8816.zip
Add engine hours handler
Diffstat (limited to 'src/org/traccar/reports/Summary.java')
-rw-r--r--src/org/traccar/reports/Summary.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/org/traccar/reports/Summary.java b/src/org/traccar/reports/Summary.java
index d789a0a9b..f57372e8d 100644
--- a/src/org/traccar/reports/Summary.java
+++ b/src/org/traccar/reports/Summary.java
@@ -44,11 +44,13 @@ public final class Summary {
Position firstPosition = null;
Position previousPosition = null;
double speedSum = 0;
+ boolean needCalculateEngineHours = Context.getConfig().getBoolean("engineHours.enable");
for (Position position : positions) {
if (firstPosition == null) {
firstPosition = position;
}
- if (previousPosition != null && position.getBoolean(Position.KEY_IGNITION)
+ if (needCalculateEngineHours && previousPosition != null
+ && position.getBoolean(Position.KEY_IGNITION)
&& previousPosition.getBoolean(Position.KEY_IGNITION)) {
result.addEngineHours(position.getFixTime().getTime()
- previousPosition.getFixTime().getTime());
@@ -63,6 +65,13 @@ public final class Summary {
result.setAverageSpeed(speedSum / positions.size());
result.setSpentFuel(ReportUtils.calculateFuel(firstPosition, previousPosition));
+ if (needCalculateEngineHours
+ && firstPosition.getAttributes().containsKey(Position.KEY_HOURS)
+ && previousPosition.getAttributes().containsKey(Position.KEY_HOURS)) {
+ result.setEngineHours(
+ previousPosition.getLong(Position.KEY_HOURS) - firstPosition.getLong(Position.KEY_HOURS));
+ }
+
if (!ignoreOdometer
&& firstPosition.getDouble(Position.KEY_ODOMETER) != 0
&& previousPosition.getDouble(Position.KEY_ODOMETER) != 0) {