aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-07-28 11:42:10 +0500
committerAbyss777 <abyss@fox5.ru>2016-07-28 11:42:10 +0500
commitf7e82c4d9a66b8ab1ba90d4cae690f9c798d03a7 (patch)
treed7629335bf8cc14ca4531f198713b4c69b53e6a7
parentb00b35b33095110cef46c8a255686cad87ac7150 (diff)
downloadtrackermap-server-f7e82c4d9a66b8ab1ba90d4cae690f9c798d03a7.tar.gz
trackermap-server-f7e82c4d9a66b8ab1ba90d4cae690f9c798d03a7.tar.bz2
trackermap-server-f7e82c4d9a66b8ab1ba90d4cae690f9c798d03a7.zip
Removed suppressing repeated events during analyzing.
-rw-r--r--debug.xml1
-rw-r--r--src/org/traccar/events/GeofenceEventHandler.java37
-rw-r--r--src/org/traccar/events/MotionEventHandler.java32
-rw-r--r--src/org/traccar/events/OverspeedEventHandler.java11
4 files changed, 15 insertions, 66 deletions
diff --git a/debug.xml b/debug.xml
index b33abc455..62e34d5d7 100644
--- a/debug.xml
+++ b/debug.xml
@@ -42,7 +42,6 @@
<entry key='logger.file'>target/tracker-server.log</entry>
<entry key='event.enable'>true</entry>
- <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>
diff --git a/src/org/traccar/events/GeofenceEventHandler.java b/src/org/traccar/events/GeofenceEventHandler.java
index a9bed6f82..a0291dcfa 100644
--- a/src/org/traccar/events/GeofenceEventHandler.java
+++ b/src/org/traccar/events/GeofenceEventHandler.java
@@ -15,30 +15,23 @@
*/
package org.traccar.events;
-import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.traccar.BaseEventHandler;
import org.traccar.Context;
-import org.traccar.database.DataManager;
import org.traccar.database.GeofenceManager;
-import org.traccar.helper.Log;
import org.traccar.model.Device;
import org.traccar.model.Event;
import org.traccar.model.Position;
public class GeofenceEventHandler extends BaseEventHandler {
- private int suppressRepeated;
private GeofenceManager geofenceManager;
- private DataManager dataManager;
public GeofenceEventHandler() {
- suppressRepeated = Context.getConfig().getInteger("event.suppressRepeated", 60);
geofenceManager = Context.getGeofenceManager();
- dataManager = Context.getDataManager();
}
@Override
@@ -63,29 +56,15 @@ public class GeofenceEventHandler extends BaseEventHandler {
device.setGeofenceIds(currentGeofences);
Collection<Event> events = new ArrayList<>();
- try {
- if (dataManager.getLastEvents(position.getDeviceId(),
- Event.TYPE_GEOFENCE_ENTER, suppressRepeated).isEmpty()) {
- for (long geofenceId : newGeofences) {
- Event event = new Event(Event.TYPE_GEOFENCE_ENTER, position.getDeviceId(), position.getId());
- event.setGeofenceId(geofenceId);
- events.add(event);
- }
- }
- } catch (SQLException error) {
- Log.warning(error);
+ for (long geofenceId : newGeofences) {
+ Event event = new Event(Event.TYPE_GEOFENCE_ENTER, position.getDeviceId(), position.getId());
+ event.setGeofenceId(geofenceId);
+ events.add(event);
}
- try {
- if (dataManager.getLastEvents(position.getDeviceId(),
- Event.TYPE_GEOFENCE_EXIT, suppressRepeated).isEmpty()) {
- for (long geofenceId : oldGeofences) {
- Event event = new Event(Event.TYPE_GEOFENCE_EXIT, position.getDeviceId(), position.getId());
- event.setGeofenceId(geofenceId);
- events.add(event);
- }
- }
- } catch (SQLException error) {
- Log.warning(error);
+ for (long geofenceId : oldGeofences) {
+ Event event = new Event(Event.TYPE_GEOFENCE_EXIT, position.getDeviceId(), position.getId());
+ event.setGeofenceId(geofenceId);
+ events.add(event);
}
return events;
}
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;
}
diff --git a/src/org/traccar/events/OverspeedEventHandler.java b/src/org/traccar/events/OverspeedEventHandler.java
index b61277548..0328b9109 100644
--- a/src/org/traccar/events/OverspeedEventHandler.java
+++ b/src/org/traccar/events/OverspeedEventHandler.java
@@ -34,12 +34,10 @@ public class OverspeedEventHandler extends BaseEventHandler {
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);
}
@Override
@@ -97,14 +95,7 @@ public class OverspeedEventHandler extends BaseEventHandler {
}
speedLimit = UnitsConverter.knotsFromKph(speedLimit);
if (speedLimit != 0 && speed > speedLimit && oldSpeed <= speedLimit) {
- try {
- if (Context.getDataManager().getLastEvents(
- position.getDeviceId(), Event.TYPE_DEVICE_OVERSPEED, suppressRepeated).isEmpty()) {
- events.add(new Event(Event.TYPE_DEVICE_OVERSPEED, position.getDeviceId(), position.getId()));
- }
- } catch (SQLException error) {
- Log.warning(error);
- }
+ events.add(new Event(Event.TYPE_DEVICE_OVERSPEED, position.getDeviceId(), position.getId()));
}
return events;
}