diff options
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/protocol/TelicProtocolDecoder.java | 48 |
1 files changed, 19 insertions, 29 deletions
diff --git a/src/org/traccar/protocol/TelicProtocolDecoder.java b/src/org/traccar/protocol/TelicProtocolDecoder.java index a9b794c38..6f502bbd1 100644 --- a/src/org/traccar/protocol/TelicProtocolDecoder.java +++ b/src/org/traccar/protocol/TelicProtocolDecoder.java @@ -26,7 +26,6 @@ import org.traccar.model.Position; import java.net.SocketAddress; import java.util.regex.Pattern; -import org.traccar.helper.Log; public class TelicProtocolDecoder extends BaseProtocolDecoder { @@ -36,27 +35,27 @@ public class TelicProtocolDecoder extends BaseProtocolDecoder { private static final Pattern PATTERN = new PatternBuilder() .number("dddd") - .number("(d{6})") // device id - .number("(d+),") // type - .number("d{12},") // event time + .number("(d{6})") // device id + .number("(d+),") // type + .number("d{12},") // event time .number("d+,") - .number("(dd)(dd)(dd)") // date - .number("(dd)(dd)(dd),") // time + .number("(dd)(dd)(dd)") // date + .number("(dd)(dd)(dd),") // time .groupBegin() - .number("(ddd)(dd)(dddd),") // longitude - .number("(dd)(dd)(dddd),") // latitude + .number("(ddd)(dd)(dddd),") // longitude + .number("(dd)(dd)(dddd),") // latitude .or() - .number("(-?d+),") // longitude - .number("(-?d+),") // latitude + .number("(-?d+),") // longitude + .number("(-?d+),") // latitude .groupEnd() - .number("(d),") // validity - .number("(d+),") // speed - .number("(d+),") // course - .number("(d+),") // satellites + .number("(d),") // validity + .number("(d+),") // speed + .number("(d+),") // course + .number("(d+),") // satellites .expression("(?:[^,]*,){7}") - .number("(d+),") // battery + .number("(d+),") // battery .expression("[^,]*,") - .number("(d+),") // external + .number("(d+),") // external .any() .compile(); @@ -78,11 +77,10 @@ public class TelicProtocolDecoder extends BaseProtocolDecoder { } position.setDeviceId(deviceSession.getDeviceId()); - String eventValue = parser.next(); - position.set(Position.KEY_TYPE, eventValue); + int event = parser.nextInt(); + position.set(Position.KEY_TYPE, event); - // alarm - position.set(Position.KEY_ALARM, decodeAlarm(eventValue)); + position.set(Position.KEY_ALARM, decodeAlarm(event)); DateBuilder dateBuilder = new DateBuilder() .setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt()) @@ -110,15 +108,7 @@ public class TelicProtocolDecoder extends BaseProtocolDecoder { return position; } - private String decodeAlarm(String event) { - - int eventId = 0; - - try { - eventId = Integer.parseInt(event); - } catch (Exception e) { - Log.error("TelicProtocolDecoder: Error parsing event (" + eventId + "): " + e.toString()); - } + private String decodeAlarm(int eventId) { switch (eventId) { case 1: |