aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/events
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-05-30 12:07:43 +0500
committerAbyss777 <abyss@fox5.ru>2016-05-30 12:07:43 +0500
commit80119f59a0d4b89396f5d7d57ba2d80257a8da79 (patch)
treef8a55519dac687f9d9f1518f16c148310a915353 /src/org/traccar/events
parent6e00239038002aa383cce39be7f53b85f3d03a94 (diff)
downloadtrackermap-server-80119f59a0d4b89396f5d7d57ba2d80257a8da79.tar.gz
trackermap-server-80119f59a0d4b89396f5d7d57ba2d80257a8da79.tar.bz2
trackermap-server-80119f59a0d4b89396f5d7d57ba2d80257a8da79.zip
- Style fixes (use lower camel case in all cases)
- Added TYPE_prefix for event.type strings - Removed commented code - Removed "database.selectLastEvents" because it is not cross-database. Do the same via code.
Diffstat (limited to 'src/org/traccar/events')
-rw-r--r--src/org/traccar/events/CommandResultEventHandler.java6
-rw-r--r--src/org/traccar/events/MotionEventHandler.java8
-rw-r--r--src/org/traccar/events/OverspeedEventHandler.java46
3 files changed, 13 insertions, 47 deletions
diff --git a/src/org/traccar/events/CommandResultEventHandler.java b/src/org/traccar/events/CommandResultEventHandler.java
index 8ef015841..23c62566a 100644
--- a/src/org/traccar/events/CommandResultEventHandler.java
+++ b/src/org/traccar/events/CommandResultEventHandler.java
@@ -8,9 +8,9 @@ public class CommandResultEventHandler extends BaseEventHandler {
@Override
protected Event analizePosition(Position position) {
- Object cmdResult = position.getAttributes().get(Position.KEY_RESULT);
- if (cmdResult != null) {
- return new Event(Event.COMMAND_RESULT, position.getDeviceId(), position.getId());
+ Object commandResult = position.getAttributes().get(Position.KEY_RESULT);
+ if (commandResult != null) {
+ return new Event(Event.TYPE_COMMAND_RESULT, position.getDeviceId(), position.getId());
}
return null;
}
diff --git a/src/org/traccar/events/MotionEventHandler.java b/src/org/traccar/events/MotionEventHandler.java
index d4dd12a39..a3b81ddc4 100644
--- a/src/org/traccar/events/MotionEventHandler.java
+++ b/src/org/traccar/events/MotionEventHandler.java
@@ -12,10 +12,10 @@ import org.traccar.model.Position;
public class MotionEventHandler extends BaseEventHandler {
private static final double SPEED_THRESHOLD = 0.01;
- private long suppressRepeated;
+ private int suppressRepeated;
public MotionEventHandler() {
- suppressRepeated = Context.getConfig().getLong("event.suppressrepeated", 60);
+ suppressRepeated = Context.getConfig().getInteger("event.suppressRepeated", 60);
}
@Override
@@ -35,10 +35,10 @@ public class MotionEventHandler extends BaseEventHandler {
String motion = device.getMotion();
if (valid && speed > SPEED_THRESHOLD && !motion.equals(Device.STATUS_MOVING)) {
Context.getConnectionManager().updateDevice(position.getDeviceId(), Device.STATUS_MOVING, null);
- event = new Event(Event.DEVICE_MOVING, position.getDeviceId(), position.getId());
+ event = new Event(Event.TYPE_DEVICE_MOVING, position.getDeviceId(), position.getId());
} else if (valid && speed < SPEED_THRESHOLD && motion.equals(Device.STATUS_MOVING)) {
Context.getConnectionManager().updateDevice(position.getDeviceId(), Device.STATUS_STOPPED, null);
- event = new Event(Event.DEVICE_STOPPED, position.getDeviceId(), position.getId());
+ event = new Event(Event.TYPE_DEVICE_STOPPED, position.getDeviceId(), position.getId());
}
try {
if (event != null && !Context.getDataManager().getLastEvents(
diff --git a/src/org/traccar/events/OverspeedEventHandler.java b/src/org/traccar/events/OverspeedEventHandler.java
index 706e9b905..30410ff32 100644
--- a/src/org/traccar/events/OverspeedEventHandler.java
+++ b/src/org/traccar/events/OverspeedEventHandler.java
@@ -6,35 +6,17 @@ import org.traccar.BaseEventHandler;
import org.traccar.Context;
import org.traccar.model.Event;
import org.traccar.model.Position;
-import org.traccar.model.Server;
import org.traccar.helper.Log;
-//import org.traccar.model.Device;
-//import org.traccar.model.Group;
import org.traccar.helper.UnitsConverter;
public class OverspeedEventHandler extends BaseEventHandler {
private double globalSpeedLimit;
- private long suppressRepeated;
+ private int suppressRepeated;
public OverspeedEventHandler() {
- globalSpeedLimit = Context.getConfig().getInteger("event.globalspeedlimit", 0);
- suppressRepeated = Context.getConfig().getLong("event.suppressrepeated", 60);
- try {
- Server server = Context.getDataManager().getServer();
- String speedUnit = server.getSpeedUnit();
- if (speedUnit != null) {
- switch (speedUnit) {
- case "kmh" : globalSpeedLimit = UnitsConverter.knotsFromKph(globalSpeedLimit);
- break;
- case "mph" : globalSpeedLimit = UnitsConverter.knotsFromMph(globalSpeedLimit);
- default : break;
- }
- }
- } catch (SQLException error) {
- Log.warning(error);
- }
-
+ globalSpeedLimit = UnitsConverter.knotsFromKph(Context.getConfig().getInteger("event.globalSpeedLimit", 0));
+ suppressRepeated = Context.getConfig().getInteger("event.suppressRepeated", 60);
}
@Override
@@ -45,28 +27,12 @@ public class OverspeedEventHandler extends BaseEventHandler {
}
double speed = position.getSpeed();
boolean valid = position.getValid();
- double deviceSpeedLimit = 0;
- double groupSpeedLimit = 0;
-// Device device = Context.getIdentityManager().getDeviceById(position.getDeviceId());
-// if (device != null) {
-// deviceSpeedLimit = device.getSpeedLimit();
-// try {
-// Group group = Context.getDataManager().getGroupById(device.getGroupId());
-// if (group != null) {
-// groupSpeedLimit = group.getSpeedLimit();
-// }
-// } catch (SQLException error) {
-// Log.warning(error);
-// }
-// }
- if (valid && globalSpeedLimit != 0 && speed > globalSpeedLimit
- || valid && groupSpeedLimit != 0 && speed > groupSpeedLimit
- || valid && deviceSpeedLimit != 0 && speed > deviceSpeedLimit) {
+ if (valid && globalSpeedLimit != 0 && speed > globalSpeedLimit) {
try {
if (Context.getDataManager().getLastEvents(
- position.getDeviceId(), Event.DEVICE_OVERSPEED, suppressRepeated).isEmpty()) {
- event = new Event(Event.DEVICE_OVERSPEED, position.getDeviceId(), position.getId());
+ position.getDeviceId(), Event.TYPE_DEVICE_OVERSPEED, suppressRepeated).isEmpty()) {
+ event = new Event(Event.TYPE_DEVICE_OVERSPEED, position.getDeviceId(), position.getId());
}
} catch (SQLException error) {
Log.warning(error);