diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/org/traccar/Context.java | 3 | ||||
-rw-r--r-- | src/org/traccar/events/MotionEventHandler.java | 8 | ||||
-rw-r--r-- | src/org/traccar/reports/model/TripsConfig.java | 15 |
3 files changed, 22 insertions, 4 deletions
diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java index a69b1786d..61000172e 100644 --- a/src/org/traccar/Context.java +++ b/src/org/traccar/Context.java @@ -256,7 +256,8 @@ public final class Context { config.getLong("report.trip.minimalTripDuration", 300) * 1000, config.getLong("report.trip.minimalParkingDuration", 300) * 1000, config.getBoolean("report.trip.greedyParking"), - config.getLong("report.trip.minimalNoDataDuration", 3600) * 1000); + config.getLong("report.trip.minimalNoDataDuration", 3600) * 1000, + config.getBoolean("report.trip.stopOnIgnitionOff")); } 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 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); } } diff --git a/src/org/traccar/reports/model/TripsConfig.java b/src/org/traccar/reports/model/TripsConfig.java index 7067781d7..039094b89 100644 --- a/src/org/traccar/reports/model/TripsConfig.java +++ b/src/org/traccar/reports/model/TripsConfig.java @@ -21,13 +21,14 @@ public class TripsConfig { public TripsConfig() { } - public TripsConfig(double minimalTripDistance, long minimalTripDuration, - long minimalParkingDuration, boolean greedyParking, long minimalNoDataDuration) { + public TripsConfig(double minimalTripDistance, long minimalTripDuration, long minimalParkingDuration, + boolean greedyParking, long minimalNoDataDuration, boolean stopOnIgnitionOff) { this.minimalTripDistance = minimalTripDistance; this.minimalTripDuration = minimalTripDuration; this.minimalParkingDuration = minimalParkingDuration; this.greedyParking = greedyParking; this.minimalNoDataDuration = minimalNoDataDuration; + this.stopOnIgnitionOff = stopOnIgnitionOff; } private double minimalTripDistance; @@ -80,4 +81,14 @@ public class TripsConfig { this.minimalNoDataDuration = minimalNoDataDuration; } + private boolean stopOnIgnitionOff; + + public boolean getStopOnIgnitionOff() { + return stopOnIgnitionOff; + } + + public void setStopOnIgnitionOff(boolean stopOnIgnitionOff) { + this.stopOnIgnitionOff = stopOnIgnitionOff; + } + } |