aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debug.xml1
-rw-r--r--src/org/traccar/events/OverspeedEventHandler.java13
2 files changed, 12 insertions, 2 deletions
diff --git a/debug.xml b/debug.xml
index c08d46531..b33abc455 100644
--- a/debug.xml
+++ b/debug.xml
@@ -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;
}