aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/FilterHandler.java39
-rw-r--r--src/org/traccar/protocol/EasyTrackProtocolDecoder.java5
-rw-r--r--src/org/traccar/protocol/EelinkProtocolDecoder.java37
-rw-r--r--src/org/traccar/protocol/Gl200TextProtocolDecoder.java8
4 files changed, 61 insertions, 28 deletions
diff --git a/src/org/traccar/FilterHandler.java b/src/org/traccar/FilterHandler.java
index 1f5fffc86..f63fd17dd 100644
--- a/src/org/traccar/FilterHandler.java
+++ b/src/org/traccar/FilterHandler.java
@@ -29,7 +29,8 @@ public class FilterHandler extends BaseDataHandler {
private boolean filterStatic;
private int filterDistance;
private int filterMaxSpeed;
- private long filterLimit;
+ private long skipLimit;
+ private boolean skipAlarms;
public void setFilterInvalid(boolean filterInvalid) {
this.filterInvalid = filterInvalid;
@@ -63,8 +64,12 @@ public class FilterHandler extends BaseDataHandler {
this.filterMaxSpeed = filterMaxSpeed;
}
- public void setFilterLimit(long filterLimit) {
- this.filterLimit = filterLimit;
+ public void setSkipLimit(long skipLimit) {
+ this.skipLimit = skipLimit;
+ }
+
+ public void setSkipAlarms(boolean skipAlarms) {
+ this.skipAlarms = skipAlarms;
}
public FilterHandler() {
@@ -78,7 +83,8 @@ public class FilterHandler extends BaseDataHandler {
filterStatic = config.getBoolean("filter.static");
filterDistance = config.getInteger("filter.distance");
filterMaxSpeed = config.getInteger("filter.maxSpeed");
- filterLimit = config.getLong("filter.limit") * 1000;
+ skipLimit = config.getLong("filter.skipLimit") * 1000;
+ skipAlarms = config.getBoolean("filter.skipAlarms");
}
}
@@ -126,22 +132,21 @@ public class FilterHandler extends BaseDataHandler {
private boolean filterMaxSpeed(Position position, Position last) {
if (filterMaxSpeed != 0 && last != null) {
double distance = position.getDouble(Position.KEY_DISTANCE);
- long time = position.getFixTime().getTime() - last.getFixTime().getTime();
+ double time = position.getFixTime().getTime() - last.getFixTime().getTime();
return UnitsConverter.knotsFromMps(distance / (time / 1000)) > filterMaxSpeed;
}
return false;
}
- private boolean filterLimit(Position position, Position last) {
- if (filterLimit != 0) {
- if (last != null) {
- return (position.getFixTime().getTime() - last.getFixTime().getTime()) > filterLimit;
- } else {
- return false;
- }
- } else {
- return false;
+ private boolean skipLimit(Position position, Position last) {
+ if (skipLimit != 0 && last != null) {
+ return (position.getFixTime().getTime() - last.getFixTime().getTime()) > skipLimit;
}
+ return false;
+ }
+
+ private boolean skipAlarms(Position position) {
+ return skipAlarms && position.getAttributes().containsKey(Position.KEY_ALARM);
}
private boolean filter(Position position) {
@@ -153,6 +158,10 @@ public class FilterHandler extends BaseDataHandler {
last = Context.getIdentityManager().getLastPosition(position.getDeviceId());
}
+ if (skipLimit(position, last) || skipAlarms(position)) {
+ return false;
+ }
+
if (filterInvalid(position)) {
filterType.append("Invalid ");
}
@@ -178,7 +187,7 @@ public class FilterHandler extends BaseDataHandler {
filterType.append("MaxSpeed ");
}
- if (filterType.length() > 0 && !filterLimit(position, last)) {
+ if (filterType.length() > 0) {
StringBuilder message = new StringBuilder();
message.append("Position filtered by ");
diff --git a/src/org/traccar/protocol/EasyTrackProtocolDecoder.java b/src/org/traccar/protocol/EasyTrackProtocolDecoder.java
index f44c91c4a..799254b65 100644
--- a/src/org/traccar/protocol/EasyTrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/EasyTrackProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2017 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@ import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
+import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -92,7 +93,7 @@ public class EasyTrackProtocolDecoder extends BaseProtocolDecoder {
position.setLongitude(parser.nextHexInt(0) / 600000.0);
}
- position.setSpeed(parser.nextHexInt(0) / 100.0);
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextHexInt(0) / 100.0));
position.setCourse(parser.nextHexInt(0) / 100.0);
position.set(Position.KEY_STATUS, parser.next());
diff --git a/src/org/traccar/protocol/EelinkProtocolDecoder.java b/src/org/traccar/protocol/EelinkProtocolDecoder.java
index e16866977..11d111e54 100644
--- a/src/org/traccar/protocol/EelinkProtocolDecoder.java
+++ b/src/org/traccar/protocol/EelinkProtocolDecoder.java
@@ -131,22 +131,37 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder {
position.setValid((buf.readUnsignedByte() & 0x01) != 0);
- if (type == MSG_ALARM) {
- position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte()));
- }
+ if (type == MSG_GPS) {
- if (buf.readableBytes() >= 2) {
- decodeStatus(position, buf.readUnsignedShort());
- }
+ if (buf.readableBytes() >= 2) {
+ decodeStatus(position, buf.readUnsignedShort());
+ }
+
+ if (buf.readableBytes() >= 2 * 4) {
+
+ position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.001);
+
+ position.set(Position.KEY_RSSI, buf.readUnsignedShort());
- if (buf.readableBytes() >= 2 * 4) {
+ position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort());
+ position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShort());
- position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.001);
+ }
+
+ } else if (type == MSG_ALARM) {
+
+ position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte()));
- position.set(Position.KEY_RSSI, buf.readUnsignedShort());
+ } else if (type == MSG_STATE) {
- position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort());
- position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShort());
+ int statusType = buf.readUnsignedByte();
+
+ position.set(Position.KEY_EVENT, statusType);
+
+ if (statusType == 0x01 || statusType == 0x02 || statusType == 0x03) {
+ buf.readUnsignedInt(); // device time
+ decodeStatus(position, buf.readUnsignedShort());
+ }
}
diff --git a/src/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/org/traccar/protocol/Gl200TextProtocolDecoder.java
index 3bee39cc4..e05182022 100644
--- a/src/org/traccar/protocol/Gl200TextProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200TextProtocolDecoder.java
@@ -562,6 +562,10 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_FUEL_LEVEL, parser.nextInt());
decodeDeviceTime(position, parser);
+ if (ignoreFixTime) {
+ positions.clear();
+ positions.add(position);
+ }
return positions;
}
@@ -620,6 +624,10 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
}
decodeDeviceTime(position, parser);
+ if (ignoreFixTime) {
+ positions.clear();
+ positions.add(position);
+ }
return positions;
}