diff options
author | Abyss777 <abyss@fox5.ru> | 2016-07-27 11:31:39 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2016-07-27 11:31:39 +0500 |
commit | b00b35b33095110cef46c8a255686cad87ac7150 (patch) | |
tree | 5c040c4a61cf79d69b1b43e1ea2a5d57c227e290 | |
parent | 387b774ae1b87db6b722e50576eb0b814501b101 (diff) | |
download | trackermap-server-b00b35b33095110cef46c8a255686cad87ac7150.tar.gz trackermap-server-b00b35b33095110cef46c8a255686cad87ac7150.tar.bz2 trackermap-server-b00b35b33095110cef46c8a255686cad87ac7150.zip |
Added option to rise event only once during overspeed period.
-rw-r--r-- | debug.xml | 1 | ||||
-rw-r--r-- | src/org/traccar/events/OverspeedEventHandler.java | 13 |
2 files changed, 12 insertions, 2 deletions
@@ -45,6 +45,7 @@ <entry key='event.suppressRepeated'>60</entry> <entry key='event.overspeedHandler'>true</entry> <entry key='event.overspeed.groupsEnabled'>true</entry> + <entry key='event.overspeed.riseOnce'>true</entry> <entry key='event.motionHandler'>true</entry> <entry key='event.geofenceHandler'>true</entry> <entry key='event.alertHandler'>true</entry> diff --git a/src/org/traccar/events/OverspeedEventHandler.java b/src/org/traccar/events/OverspeedEventHandler.java index e488b9df2..b61277548 100644 --- a/src/org/traccar/events/OverspeedEventHandler.java +++ b/src/org/traccar/events/OverspeedEventHandler.java @@ -33,10 +33,12 @@ public class OverspeedEventHandler extends BaseEventHandler { public static final String ATTRIBUTE_SPEED_LIMIT = "speedLimit"; private boolean checkGroups; + private boolean riseOnce; private int suppressRepeated; public OverspeedEventHandler() { checkGroups = Context.getConfig().getBoolean("event.overspeed.groupsEnabled"); + riseOnce = Context.getConfig().getBoolean("event.overspeed.riseOnce"); suppressRepeated = Context.getConfig().getInteger("event.suppressRepeated", 60); } @@ -86,7 +88,15 @@ public class OverspeedEventHandler extends BaseEventHandler { Log.warning(error); } } - if (speedLimit != 0 && speed > UnitsConverter.knotsFromKph(speedLimit)) { + double oldSpeed = 0; + if (riseOnce) { + Position lastPosition = Context.getDeviceManager().getLastPosition(position.getDeviceId()); + if (lastPosition != null) { + oldSpeed = lastPosition.getSpeed(); + } + } + speedLimit = UnitsConverter.knotsFromKph(speedLimit); + if (speedLimit != 0 && speed > speedLimit && oldSpeed <= speedLimit) { try { if (Context.getDataManager().getLastEvents( position.getDeviceId(), Event.TYPE_DEVICE_OVERSPEED, suppressRepeated).isEmpty()) { @@ -95,7 +105,6 @@ public class OverspeedEventHandler extends BaseEventHandler { } catch (SQLException error) { Log.warning(error); } - } return events; } |