aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/Gl200ProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-05-26 10:02:37 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2016-05-26 10:02:37 -0700
commitd3e34416e9825833fa1db02112c56981999df039 (patch)
treed21b4414b532bfc53c9a905f3caa09f70b43b59e /src/org/traccar/protocol/Gl200ProtocolDecoder.java
parentac2405f0d57fac51fe95aa755f90fe82f26f73bc (diff)
parentaa12e5c750e771016545269ffa39409b06b47eee (diff)
downloadtrackermap-server-d3e34416e9825833fa1db02112c56981999df039.tar.gz
trackermap-server-d3e34416e9825833fa1db02112c56981999df039.tar.bz2
trackermap-server-d3e34416e9825833fa1db02112c56981999df039.zip
Merge pull request #1978 from Abyss777/master
Simplification of the models hierarchy
Diffstat (limited to 'src/org/traccar/protocol/Gl200ProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/Gl200ProtocolDecoder.java85
1 files changed, 42 insertions, 43 deletions
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
index 4e78ff6ed..2793e123a 100644
--- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
@@ -23,7 +23,6 @@ import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.helper.UnitsConverter;
-import org.traccar.model.Event;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -264,10 +263,10 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
}
position.setDeviceId(getDeviceId());
- position.set(Event.KEY_STATUS, parser.next());
- position.set(Event.KEY_POWER, parser.next());
- position.set(Event.KEY_BATTERY, parser.next());
- position.set(Event.KEY_CHARGE, parser.next());
+ position.set(Position.KEY_STATUS, parser.next());
+ position.set(Position.KEY_POWER, parser.next());
+ position.set(Position.KEY_BATTERY, parser.next());
+ position.set(Position.KEY_CHARGE, parser.next());
DateBuilder dateBuilder = new DateBuilder()
.setDate(parser.nextInt(), parser.nextInt(), parser.nextInt())
@@ -275,7 +274,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, dateBuilder.getDate());
- position.set(Event.KEY_INDEX, parser.next());
+ position.set(Position.KEY_INDEX, parser.next());
return position;
}
@@ -299,15 +298,15 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
}
if (parser.hasNext(4)) {
- position.set(Event.KEY_MCC, parser.nextInt());
- position.set(Event.KEY_MNC, parser.nextInt());
- position.set(Event.KEY_LAC, parser.nextInt(16));
- position.set(Event.KEY_CID, parser.nextInt(16));
+ position.set(Position.KEY_MCC, parser.nextInt());
+ position.set(Position.KEY_MNC, parser.nextInt());
+ position.set(Position.KEY_LAC, parser.nextInt(16));
+ position.set(Position.KEY_CID, parser.nextInt(16));
}
parser.skip(4); // alternative networks
- position.set(Event.KEY_ODOMETER, parser.next());
+ position.set(Position.KEY_ODOMETER, parser.next());
}
private Object decodeObd(Channel channel, SocketAddress remoteAddress, String sentence) {
@@ -324,21 +323,21 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
}
position.setDeviceId(getDeviceId());
- position.set(Event.KEY_RPM, parser.next());
- position.set(Event.KEY_OBD_SPEED, parser.next());
- position.set(Event.PREFIX_TEMP + 1, parser.next());
+ position.set(Position.KEY_RPM, parser.next());
+ position.set(Position.KEY_OBD_SPEED, parser.next());
+ position.set(Position.PREFIX_TEMP + 1, parser.next());
position.set("fuel-consumption", parser.next());
position.set("dtcs-cleared-distance", parser.next());
position.set("odb-connect", parser.next());
position.set("dtcs-number", parser.next());
position.set("dtcs-codes", parser.next());
- position.set(Event.KEY_THROTTLE, parser.next());
- position.set(Event.KEY_FUEL, parser.next());
- position.set(Event.KEY_OBD_ODOMETER, parser.next());
+ position.set(Position.KEY_THROTTLE, parser.next());
+ position.set(Position.KEY_FUEL, parser.next());
+ position.set(Position.KEY_OBD_ODOMETER, parser.next());
decodeLocation(position, parser);
- position.set(Event.KEY_ODOMETER, parser.next());
+ position.set(Position.KEY_ODOMETER, parser.next());
if (parser.hasNext(6)) {
DateBuilder dateBuilder = new DateBuilder()
@@ -373,7 +372,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
- position.set(Event.KEY_VIN, vin);
+ position.set(Position.KEY_VIN, vin);
decodeLocation(position, itemParser);
@@ -386,31 +385,31 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
// power value only on some devices
if (power > 10) {
- position.set(Event.KEY_POWER, power);
+ position.set(Position.KEY_POWER, power);
}
- position.set(Event.KEY_ODOMETER, parser.next());
- position.set(Event.KEY_BATTERY, parser.next());
+ position.set(Position.KEY_ODOMETER, parser.next());
+ position.set(Position.KEY_BATTERY, parser.next());
- position.set(Event.KEY_ODOMETER, parser.next());
- position.set(Event.KEY_HOURS, parser.next());
- position.set(Event.PREFIX_ADC + 1, parser.next());
- position.set(Event.PREFIX_ADC + 2, parser.next());
- position.set(Event.KEY_BATTERY, parser.next());
+ position.set(Position.KEY_ODOMETER, parser.next());
+ position.set(Position.KEY_HOURS, parser.next());
+ position.set(Position.PREFIX_ADC + 1, parser.next());
+ position.set(Position.PREFIX_ADC + 2, parser.next());
+ position.set(Position.KEY_BATTERY, parser.next());
if (parser.hasNext(3)) {
int ignition = parser.nextInt(16);
if (BitUtil.check(ignition, 4)) {
- position.set(Event.KEY_IGNITION, false);
+ position.set(Position.KEY_IGNITION, false);
} else if (BitUtil.check(ignition, 5)) {
- position.set(Event.KEY_IGNITION, true);
+ position.set(Position.KEY_IGNITION, true);
}
- position.set(Event.KEY_INPUT, parser.nextInt(16));
- position.set(Event.KEY_OUTPUT, parser.nextInt(16));
+ position.set(Position.KEY_INPUT, parser.nextInt(16));
+ position.set(Position.KEY_OUTPUT, parser.nextInt(16));
}
- position.set(Event.KEY_RPM, parser.next());
- position.set(Event.KEY_FUEL, parser.next());
+ position.set(Position.KEY_RPM, parser.next());
+ position.set(Position.KEY_FUEL, parser.next());
// workaround for wrong location time
if (parser.hasNext(6)) {
@@ -441,8 +440,8 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
decodeLocation(position, parser);
- position.set(Event.KEY_HOURS, parser.next());
- position.set(Event.KEY_ODOMETER, parser.next());
+ position.set(Position.KEY_HOURS, parser.next());
+ position.set(Position.KEY_ODOMETER, parser.next());
if (parser.hasNext(6)) {
DateBuilder dateBuilder = new DateBuilder()
@@ -470,11 +469,11 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
}
position.setDeviceId(getDeviceId());
- position.set(Event.KEY_RFID, parser.next());
+ position.set(Position.KEY_RFID, parser.next());
decodeLocation(position, parser);
- position.set(Event.KEY_ODOMETER, parser.next());
+ position.set(Position.KEY_ODOMETER, parser.next());
if (parser.hasNext(6)) {
DateBuilder dateBuilder = new DateBuilder()
@@ -504,15 +503,15 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
int reportType = parser.nextInt();
if (type.equals("NMR")) {
- position.set(Event.KEY_MOTION, reportType);
+ position.set(Position.KEY_MOTION, reportType);
}
decodeLocation(position, parser);
- position.set(Event.KEY_ODOMETER, parser.next());
- position.set(Event.KEY_BATTERY, parser.next());
+ position.set(Position.KEY_ODOMETER, parser.next());
+ position.set(Position.KEY_BATTERY, parser.next());
- position.set(Event.KEY_ODOMETER, parser.next());
+ position.set(Position.KEY_ODOMETER, parser.next());
// workaround for wrong location time
if (parser.hasNext(6)) {
@@ -614,10 +613,10 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
if (result != null) {
if (result instanceof Position) {
- ((Position) result).set(Event.KEY_TYPE, type);
+ ((Position) result).set(Position.KEY_TYPE, type);
} else {
for (Position p : (List<Position>) result) {
- p.set(Event.KEY_TYPE, type);
+ p.set(Position.KEY_TYPE, type);
}
}
}