diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-07-09 10:21:29 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-07-09 10:21:29 +1200 |
commit | 539cce7910b2fbf18ff4ea7e059abfae1dba0512 (patch) | |
tree | bf859ab0ae30d291933d4a2c2dda0136a636960e /src/org | |
parent | c9245e2dd791d115011dbb4490733fd9102415d1 (diff) | |
download | trackermap-server-539cce7910b2fbf18ff4ea7e059abfae1dba0512.tar.gz trackermap-server-539cce7910b2fbf18ff4ea7e059abfae1dba0512.tar.bz2 trackermap-server-539cce7910b2fbf18ff4ea7e059abfae1dba0512.zip |
Check if fuel drop threshold is set
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/events/FuelDropEventHandler.java | 20 |
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); + } } } |