aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/events/FuelDropEventHandler.java20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/org/traccar/events/FuelDropEventHandler.java b/src/org/traccar/events/FuelDropEventHandler.java
index dfdbf7d7a..a035d408f 100644
--- a/src/org/traccar/events/FuelDropEventHandler.java
+++ b/src/org/traccar/events/FuelDropEventHandler.java
@@ -42,15 +42,17 @@ public class FuelDropEventHandler extends BaseEventHandler {
double fuelDropThreshold = Context.getDeviceManager()
.lookupAttributeDouble(device.getId(), ATTRIBUTE_FUEL_DROP_THRESHOLD, 0, false);
- Position lastPosition = Context.getIdentityManager().getLastPosition(position.getDeviceId());
- if (position.getAttributes().containsKey(Position.KEY_FUEL_LEVEL)
- && lastPosition != null && lastPosition.getAttributes().containsKey(Position.KEY_FUEL_LEVEL)) {
-
- double drop = lastPosition.getDouble(Position.KEY_FUEL_LEVEL) - position.getDouble(Position.KEY_FUEL_LEVEL);
- if (drop >= fuelDropThreshold) {
- Event event = new Event(Event.TYPE_DEVICE_FUEL_DROP, position.getDeviceId(), position.getId());
- event.set(ATTRIBUTE_FUEL_DROP_THRESHOLD, fuelDropThreshold);
- return Collections.singleton(event);
+ if (fuelDropThreshold > 0) {
+ Position lastPosition = Context.getIdentityManager().getLastPosition(position.getDeviceId());
+ if (position.getAttributes().containsKey(Position.KEY_FUEL_LEVEL)
+ && lastPosition != null && lastPosition.getAttributes().containsKey(Position.KEY_FUEL_LEVEL)) {
+
+ double drop = lastPosition.getDouble(Position.KEY_FUEL_LEVEL) - position.getDouble(Position.KEY_FUEL_LEVEL);
+ if (drop >= fuelDropThreshold) {
+ Event event = new Event(Event.TYPE_DEVICE_FUEL_DROP, position.getDeviceId(), position.getId());
+ event.set(ATTRIBUTE_FUEL_DROP_THRESHOLD, fuelDropThreshold);
+ return Collections.singleton(event);
+ }
}
}