From 933f990cefb03d141508abd60681f5615e3db9e2 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 30 Sep 2015 11:45:35 +1300 Subject: Fix TK103 speed and time decoding --- src/org/traccar/protocol/Tk103ProtocolDecoder.java | 34 +++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java index 21aa81bda..72fdc10b7 100644 --- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java @@ -44,7 +44,7 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder { "([NS]),?" + "(\\d{3})(\\d{2}\\.\\d+)" + // Longitude (DDDMM.MMMM) "([EW]),?" + - "(\\d+\\.\\d{1,2}),?" + // Speed + "(\\d+\\.\\d)(?:\\d*,)?" + // Speed "(\\d{2})(\\d{2})(\\d{2}),?" + // Time (HHMMSS) "(\\d+\\.?\\d{1,2}),?" + // Course "(?:([01]{8})|([0-9a-fA-F]{8}))?,?" + // State @@ -96,45 +96,45 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder { Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC")); time.clear(); if (parser.group(index++) == null) { - time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++))); - time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1); - time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(parser.group(index++))); + time.set(Calendar.YEAR, 2000 + Integer.parseInt(parser.group(index++))); + time.set(Calendar.MONTH, Integer.parseInt(parser.group(index++)) - 1); + time.set(Calendar.DAY_OF_MONTH, Integer.parseInt(parser.group(index++))); } else { - time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(parser.group(index++))); - time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1); - time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++))); + time.set(Calendar.DAY_OF_MONTH, Integer.parseInt(parser.group(index++))); + time.set(Calendar.MONTH, Integer.parseInt(parser.group(index++)) - 1); + time.set(Calendar.YEAR, 2000 + Integer.parseInt(parser.group(index++))); } // Validity position.setValid(parser.group(index++).compareTo("A") == 0); // Latitude - Double latitude = Double.valueOf(parser.group(index++)); - latitude += Double.valueOf(parser.group(index++)) / 60; + Double latitude = Double.parseDouble(parser.group(index++)); + latitude += Double.parseDouble(parser.group(index++)) / 60; if (parser.group(index++).compareTo("S") == 0) latitude = -latitude; position.setLatitude(latitude); // Longitude - Double longitude = Double.valueOf(parser.group(index++)); - longitude += Double.valueOf(parser.group(index++)) / 60; + Double longitude = Double.parseDouble(parser.group(index++)); + longitude += Double.parseDouble(parser.group(index++)) / 60; if (parser.group(index++).compareTo("W") == 0) longitude = -longitude; position.setLongitude(longitude); // Speed if (Context.getConfig().getBoolean(getProtocolName() + ".mph")) { - position.setSpeed(UnitsConverter.knotsFromMph(Double.valueOf(parser.group(index++)))); + position.setSpeed(UnitsConverter.knotsFromMph(Double.parseDouble(parser.group(index++)))); } else { - position.setSpeed(UnitsConverter.knotsFromKph(Double.valueOf(parser.group(index++)))); + position.setSpeed(UnitsConverter.knotsFromKph(Double.parseDouble(parser.group(index++)))); } // Time - time.set(Calendar.HOUR_OF_DAY, Integer.valueOf(parser.group(index++))); - time.set(Calendar.MINUTE, Integer.valueOf(parser.group(index++))); - time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++))); + time.set(Calendar.HOUR_OF_DAY, Integer.parseInt(parser.group(index++))); + time.set(Calendar.MINUTE, Integer.parseInt(parser.group(index++))); + time.set(Calendar.SECOND, Integer.parseInt(parser.group(index++))); position.setTime(time.getTime()); // Course - position.setCourse(Double.valueOf(parser.group(index++))); + position.setCourse(Double.parseDouble(parser.group(index++))); // State String status = parser.group(index++); // binary status -- cgit v1.2.3