aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java48
1 files changed, 22 insertions, 26 deletions
diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
index 8edce9346..3cc430035 100644
--- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
@@ -1033,36 +1033,32 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
return positions;
}
- private static final Pattern PATTERN_IGN = new PatternBuilder()
- .text("+").expression("(?:RESP|BUFF):GT[IV]G[NF],")
- .expression("(?:.{6}|.{10})?,") // protocol version
- .number("(d{15}|x{14}),") // imei
- .expression("[^,]*,") // device name
- .number("d+,") // ignition off duration
- .expression(PATTERN_LOCATION.pattern())
- .number("(d{5}:dd:dd)?,") // hour meter
- .number("(d{1,7}.d)?,") // odometer
- .number("(dddd)(dd)(dd)") // date (yyyymmdd)
- .number("(dd)(dd)(dd)").optional(2) // time (hhmmss)
- .text(",")
- .number("(xxxx)") // count number
- .text("$").optional()
- .compile();
-
- private Object decodeIgn(Channel channel, SocketAddress remoteAddress, String sentence) {
- Parser parser = new Parser(PATTERN_IGN, sentence);
- Position position = initPosition(parser, channel, remoteAddress);
- if (position == null) {
+ private Object decodeIgn(Channel channel, SocketAddress remoteAddress, String[] v, String type) throws ParseException {
+ int index = 1; // header
+ String protocolVersion = v[index++]; // protocol version
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, v[index++]);
+ if (deviceSession == null) {
return null;
}
+ Position position = new Position(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
- decodeLocation(position, parser);
+ String model = getDeviceModel(deviceSession, protocolVersion);
+ index += 1; // device name
+ index += 1; // duration of ignition on/off
- position.set(Position.KEY_IGNITION, sentence.contains("GN"));
- position.set(Position.KEY_HOURS, parseHours(parser.next()));
- position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
+ decodeLocation(position, model, v, index);
- decodeDeviceTime(position, parser);
+ position.set(Position.KEY_IGNITION, type.contains("GN"));
+ position.set(Position.KEY_HOURS, parseHours(v[index++]));
+ position.set(Position.KEY_ODOMETER, Double.parseDouble(v[index]) * 1000);
+
+ Date time = dateFormat.parse(v[v.length - 2]);
+ if (ignoreFixTime) {
+ position.setTime(time);
+ } else {
+ position.setDeviceTime(time);
+ }
return position;
}
@@ -1682,7 +1678,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
case "IGF":
case "VGN":
case "VGF":
- result = decodeIgn(channel, remoteAddress, sentence);
+ result = decodeIgn(channel, remoteAddress, values, type);
break;
case "LSW":
case "TSW":