aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-07-27 11:31:39 +0500
committerAbyss777 <abyss@fox5.ru>2016-07-27 11:31:39 +0500
commitb00b35b33095110cef46c8a255686cad87ac7150 (patch)
tree5c040c4a61cf79d69b1b43e1ea2a5d57c227e290 /src
parent387b774ae1b87db6b722e50576eb0b814501b101 (diff)
downloadtrackermap-server-b00b35b33095110cef46c8a255686cad87ac7150.tar.gz
trackermap-server-b00b35b33095110cef46c8a255686cad87ac7150.tar.bz2
trackermap-server-b00b35b33095110cef46c8a255686cad87ac7150.zip
Added option to rise event only once during overspeed period.
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/events/OverspeedEventHandler.java13
1 files changed, 11 insertions, 2 deletions
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;
}