From 46be66c0639032c8ebf222f79e3a52b2b120ad24 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Thu, 11 Aug 2016 11:34:51 +0500 Subject: - Enabled IgnitionEventHandler in pipeline - Added motorHours to SummaryReport - Added ignition to test-generator.py --- src/org/traccar/reports/Summary.java | 8 ++++++++ src/org/traccar/reports/model/SummaryReport.java | 11 +++++++++++ 2 files changed, 19 insertions(+) (limited to 'src/org/traccar/reports') diff --git a/src/org/traccar/reports/Summary.java b/src/org/traccar/reports/Summary.java index e0da1c87e..2c777b9bb 100644 --- a/src/org/traccar/reports/Summary.java +++ b/src/org/traccar/reports/Summary.java @@ -33,6 +33,14 @@ public final class Summary { if (previousPosition != null) { result.addDistance(DistanceCalculator.distance(previousPosition.getLatitude(), previousPosition.getLongitude(), position.getLatitude(), position.getLongitude())); + if (position.getAttributes().get(Position.KEY_IGNITION) != null + && Boolean.parseBoolean(position.getAttributes().get(Position.KEY_IGNITION).toString()) + && previousPosition.getAttributes().get(Position.KEY_IGNITION) != null + && Boolean.parseBoolean(previousPosition.getAttributes() + .get(Position.KEY_IGNITION).toString())) { + result.addMotorHours(position.getFixTime().getTime() + - previousPosition.getFixTime().getTime()); + } } previousPosition = position; speedSum += position.getSpeed(); diff --git a/src/org/traccar/reports/model/SummaryReport.java b/src/org/traccar/reports/model/SummaryReport.java index e42727eaf..01006558f 100644 --- a/src/org/traccar/reports/model/SummaryReport.java +++ b/src/org/traccar/reports/model/SummaryReport.java @@ -47,4 +47,15 @@ public class SummaryReport { this.maxSpeed = maxSpeed; } } + + private long motorHours; + public long getMotorHours() { + return motorHours; + } + public void setMotorHours(long motorHours) { + this.motorHours = motorHours; + } + public void addMotorHours(long motorHours) { + this.motorHours += motorHours; + } } -- cgit v1.2.3