From f7e82c4d9a66b8ab1ba90d4cae690f9c798d03a7 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Thu, 28 Jul 2016 11:42:10 +0500 Subject: Removed suppressing repeated events during analyzing. --- src/org/traccar/events/MotionEventHandler.java | 32 +++++--------------------- 1 file changed, 6 insertions(+), 26 deletions(-) (limited to 'src/org/traccar/events/MotionEventHandler.java') 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 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; } -- cgit v1.2.3