From 8313471a752dc08e5e7a270349e9f03417672b08 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 14 Aug 2017 14:43:17 +0500 Subject: Correct motion state by ignition. --- src/org/traccar/events/MotionEventHandler.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/org/traccar/events') diff --git a/src/org/traccar/events/MotionEventHandler.java b/src/org/traccar/events/MotionEventHandler.java index b20a11999..208fd5b42 100644 --- a/src/org/traccar/events/MotionEventHandler.java +++ b/src/org/traccar/events/MotionEventHandler.java @@ -78,13 +78,19 @@ public class MotionEventHandler extends BaseEventHandler { if (motionPosition != null) { long motionTime = motionPosition.getFixTime().getTime(); double distance = ReportUtils.calculateDistance(motionPosition, position, false); + Boolean ignition = null; + if (tripsConfig.getStopOnIgnitionOff() + && position.getAttributes().containsKey(Position.KEY_IGNITION)) { + ignition = position.getBoolean(Position.KEY_IGNITION); + } if (newMotion) { if (motionTime + tripsConfig.getMinimalTripDuration() <= currentTime || distance >= tripsConfig.getMinimalTripDistance()) { result = newEvent(deviceState, newMotion); } } else { - if (motionTime + tripsConfig.getMinimalParkingDuration() <= currentTime) { + if (motionTime + tripsConfig.getMinimalParkingDuration() <= currentTime + || ignition != null && !ignition) { result = newEvent(deviceState, newMotion); } } -- cgit v1.2.3 From fdc14dd2a286b7d9470ff97703d120c217a39dcb Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 14 Aug 2017 16:40:45 +0500 Subject: Rename parameter and field to "useIgnition" --- src/org/traccar/Context.java | 2 +- src/org/traccar/events/MotionEventHandler.java | 2 +- src/org/traccar/reports/model/TripsConfig.java | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/org/traccar/events') diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java index 61000172e..aa7e6acf9 100644 --- a/src/org/traccar/Context.java +++ b/src/org/traccar/Context.java @@ -257,7 +257,7 @@ public final class Context { config.getLong("report.trip.minimalParkingDuration", 300) * 1000, config.getBoolean("report.trip.greedyParking"), config.getLong("report.trip.minimalNoDataDuration", 3600) * 1000, - config.getBoolean("report.trip.stopOnIgnitionOff")); + config.getBoolean("report.trip.useIgnition")); } public static void init(String[] arguments) throws Exception { diff --git a/src/org/traccar/events/MotionEventHandler.java b/src/org/traccar/events/MotionEventHandler.java index 208fd5b42..8c2d4c56c 100644 --- a/src/org/traccar/events/MotionEventHandler.java +++ b/src/org/traccar/events/MotionEventHandler.java @@ -79,7 +79,7 @@ public class MotionEventHandler extends BaseEventHandler { long motionTime = motionPosition.getFixTime().getTime(); double distance = ReportUtils.calculateDistance(motionPosition, position, false); Boolean ignition = null; - if (tripsConfig.getStopOnIgnitionOff() + if (tripsConfig.getUseIgnition() && position.getAttributes().containsKey(Position.KEY_IGNITION)) { ignition = position.getBoolean(Position.KEY_IGNITION); } diff --git a/src/org/traccar/reports/model/TripsConfig.java b/src/org/traccar/reports/model/TripsConfig.java index 039094b89..2e2403619 100644 --- a/src/org/traccar/reports/model/TripsConfig.java +++ b/src/org/traccar/reports/model/TripsConfig.java @@ -22,13 +22,13 @@ public class TripsConfig { } public TripsConfig(double minimalTripDistance, long minimalTripDuration, long minimalParkingDuration, - boolean greedyParking, long minimalNoDataDuration, boolean stopOnIgnitionOff) { + boolean greedyParking, long minimalNoDataDuration, boolean useIgnition) { this.minimalTripDistance = minimalTripDistance; this.minimalTripDuration = minimalTripDuration; this.minimalParkingDuration = minimalParkingDuration; this.greedyParking = greedyParking; this.minimalNoDataDuration = minimalNoDataDuration; - this.stopOnIgnitionOff = stopOnIgnitionOff; + this.useIgnition = useIgnition; } private double minimalTripDistance; @@ -81,14 +81,14 @@ public class TripsConfig { this.minimalNoDataDuration = minimalNoDataDuration; } - private boolean stopOnIgnitionOff; + private boolean useIgnition; - public boolean getStopOnIgnitionOff() { - return stopOnIgnitionOff; + public boolean getUseIgnition() { + return useIgnition; } - public void setStopOnIgnitionOff(boolean stopOnIgnitionOff) { - this.stopOnIgnitionOff = stopOnIgnitionOff; + public void setUseIgnition(boolean useIgnition) { + this.useIgnition = useIgnition; } } -- cgit v1.2.3