diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-07-29 09:54:48 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-29 09:54:48 +1200 |
commit | 4f875a6fb51aa1eb7aebc779d2b971f74a53e901 (patch) | |
tree | bd097caeea4d554b344d10d12b2531b8d1cc312b /src/org/traccar/events/MotionEventHandler.java | |
parent | b1e7bd492b9f6739936e533b4ab16d4825f1ce3c (diff) | |
parent | 6f89644fdcb3dbeb966cadbd810f9795922b8c4e (diff) | |
download | trackermap-server-4f875a6fb51aa1eb7aebc779d2b971f74a53e901.tar.gz trackermap-server-4f875a6fb51aa1eb7aebc779d2b971f74a53e901.tar.bz2 trackermap-server-4f875a6fb51aa1eb7aebc779d2b971f74a53e901.zip |
Merge pull request #2163 from Abyss777/overspeed_extension
OverspeedEventHandler enhancement to use attributes
Diffstat (limited to 'src/org/traccar/events/MotionEventHandler.java')
-rw-r--r-- | src/org/traccar/events/MotionEventHandler.java | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/src/org/traccar/events/MotionEventHandler.java b/src/org/traccar/events/MotionEventHandler.java index 4b652a727..ddb99185f 100644 --- a/src/org/traccar/events/MotionEventHandler.java +++ b/src/org/traccar/events/MotionEventHandler.java @@ -15,13 +15,11 @@ */ package org.traccar.events; -import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; import org.traccar.BaseEventHandler; import org.traccar.Context; -import org.traccar.helper.Log; import org.traccar.model.Device; import org.traccar.model.Event; import org.traccar.model.Position; @@ -29,11 +27,6 @@ import org.traccar.model.Position; public class MotionEventHandler extends BaseEventHandler { private static final double SPEED_THRESHOLD = 0.01; - private int suppressRepeated; - - public MotionEventHandler() { - suppressRepeated = Context.getConfig().getInteger("event.suppressRepeated", 60); - } @Override protected Collection<Event> analyzePosition(Position position) { @@ -53,25 +46,12 @@ public class MotionEventHandler extends BaseEventHandler { if (lastPosition != null) { oldSpeed = lastPosition.getSpeed(); } - try { - if (speed > SPEED_THRESHOLD && oldSpeed <= SPEED_THRESHOLD) { - result = new ArrayList<>(); - result.add(new Event(Event.TYPE_DEVICE_MOVING, position.getDeviceId(), position.getId())); - } else if (speed <= SPEED_THRESHOLD && oldSpeed > SPEED_THRESHOLD) { - result = new ArrayList<>(); - result.add(new Event(Event.TYPE_DEVICE_STOPPED, position.getDeviceId(), position.getId())); - } - - if (result != null && !result.isEmpty()) { - for (Event event : result) { - if (!Context.getDataManager().getLastEvents(position.getDeviceId(), - event.getType(), suppressRepeated).isEmpty()) { - event = null; - } - } - } - } catch (SQLException error) { - Log.warning(error); + if (speed > SPEED_THRESHOLD && oldSpeed <= SPEED_THRESHOLD) { + result = new ArrayList<>(); + result.add(new Event(Event.TYPE_DEVICE_MOVING, position.getDeviceId(), position.getId())); + } else if (speed <= SPEED_THRESHOLD && oldSpeed > SPEED_THRESHOLD) { + result = new ArrayList<>(); + result.add(new Event(Event.TYPE_DEVICE_STOPPED, position.getDeviceId(), position.getId())); } return result; } |