diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-05-31 18:48:39 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-31 18:48:39 +1200 |
commit | 2a34f67542221e27e64ee48928fe8fd7d59f7714 (patch) | |
tree | 89c06091207e99ae73ff62ecff377847b7960ade /src/org/traccar/reports/Summary.java | |
parent | 607123610018cdc1f0e391fec43e54e769d40a06 (diff) | |
parent | 786f101fab6a81007f67e868d381302f4a502d77 (diff) | |
download | trackermap-server-2a34f67542221e27e64ee48928fe8fd7d59f7714.tar.gz trackermap-server-2a34f67542221e27e64ee48928fe8fd7d59f7714.tar.bz2 trackermap-server-2a34f67542221e27e64ee48928fe8fd7d59f7714.zip |
Merge pull request #3901 from Abyss777/engineHours_handler
Implement engine hours accumulation
Diffstat (limited to 'src/org/traccar/reports/Summary.java')
-rw-r--r-- | src/org/traccar/reports/Summary.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/org/traccar/reports/Summary.java b/src/org/traccar/reports/Summary.java index d789a0a9b..9810424d8 100644 --- a/src/org/traccar/reports/Summary.java +++ b/src/org/traccar/reports/Summary.java @@ -44,12 +44,15 @@ public final class Summary { Position firstPosition = null; Position previousPosition = null; double speedSum = 0; + boolean engineHoursEnabled = Context.getConfig().getBoolean("processing.engineHours.enable"); for (Position position : positions) { if (firstPosition == null) { firstPosition = position; } - if (previousPosition != null && position.getBoolean(Position.KEY_IGNITION) + if (engineHoursEnabled && previousPosition != null + && position.getBoolean(Position.KEY_IGNITION) && previousPosition.getBoolean(Position.KEY_IGNITION)) { + // Temporary fallback for old data, to be removed in May 2019 result.addEngineHours(position.getFixTime().getTime() - previousPosition.getFixTime().getTime()); } @@ -63,6 +66,13 @@ public final class Summary { result.setAverageSpeed(speedSum / positions.size()); result.setSpentFuel(ReportUtils.calculateFuel(firstPosition, previousPosition)); + if (engineHoursEnabled + && 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) { |