aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2011-02-22 11:03:54 +0000
committerAnton Tananaev <anton.tananaev@gmail.com>2011-02-22 11:03:54 +0000
commit52c26cb593201a74443329221722cc33c142b476 (patch)
treec5ecf20cbc265a9147bf7bfcc856913565149dd6
parentcdd6d038c5adca06db989a3b6fe8bd3fd36fe9ed (diff)
downloadtrackermap-server-52c26cb593201a74443329221722cc33c142b476.tar.gz
trackermap-server-52c26cb593201a74443329221722cc33c142b476.tar.bz2
trackermap-server-52c26cb593201a74443329221722cc33c142b476.zip
-rw-r--r--src/net/sourceforge/opentracking/protocol/xexun/XexunProtocolDecoder.java11
-rw-r--r--test/net/sourceforge/opentracking/protocol/gps103/Gps103ProtocolDecoderTest.java10
-rw-r--r--test/net/sourceforge/opentracking/protocol/xexun/XexunProtocolDecoderTest.java2
3 files changed, 19 insertions, 4 deletions
diff --git a/src/net/sourceforge/opentracking/protocol/xexun/XexunProtocolDecoder.java b/src/net/sourceforge/opentracking/protocol/xexun/XexunProtocolDecoder.java
index 39161f45b..15cb99f55 100644
--- a/src/net/sourceforge/opentracking/protocol/xexun/XexunProtocolDecoder.java
+++ b/src/net/sourceforge/opentracking/protocol/xexun/XexunProtocolDecoder.java
@@ -58,7 +58,7 @@ public class XexunProtocolDecoder extends OneToOneDecoder {
"([\\d]{3})([\\d]{2}.[\\d]{4})," + // Longitude (DDDMM.MMMM)
"([EW])," +
"([\\d]+.[\\d]{2})," + // Speed
- "([\\d]+.[\\d]{2})," + // Course
+ "([\\d]+.[\\d]{2})?," + // Course
"([\\d]{2})([\\d]{2})([\\d]{2})," + // Date (DDMMYY)
".*imei:" +
"([\\d]+),"); // IMEI
@@ -105,9 +105,14 @@ public class XexunProtocolDecoder extends OneToOneDecoder {
if (parser.group(index++).compareTo("W") == 0) lonlitude = -lonlitude;
position.setLongitude(lonlitude);
- // Speed and course
+ // Speed
position.setSpeed(Double.valueOf(parser.group(index++)));
- position.setCourse(Double.valueOf(parser.group(index++)));
+
+ // Course
+ String course = parser.group(index++);
+ if (course != null) {
+ position.setCourse(Double.valueOf(course));
+ }
// Date
time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(parser.group(index++)));
diff --git a/test/net/sourceforge/opentracking/protocol/gps103/Gps103ProtocolDecoderTest.java b/test/net/sourceforge/opentracking/protocol/gps103/Gps103ProtocolDecoderTest.java
index 8d259a89f..3d1adcf34 100644
--- a/test/net/sourceforge/opentracking/protocol/gps103/Gps103ProtocolDecoderTest.java
+++ b/test/net/sourceforge/opentracking/protocol/gps103/Gps103ProtocolDecoderTest.java
@@ -1,6 +1,7 @@
package net.sourceforge.opentracking.protocol.gps103;
-import java.util.Date;
+import java.util.Calendar;
+import java.util.TimeZone;
import java.util.GregorianCalendar;
import java.util.List;
import org.junit.Test;
@@ -30,6 +31,13 @@ public class Gps103ProtocolDecoderTest {
@Test
public void testDecode() throws Exception {
+ Calendar time = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
+ time.set(Calendar.HOUR, 0);
+ time.set(Calendar.MINUTE, 1);
+ time.set(Calendar.SECOND, 2);
+ time.set(Calendar.MILLISECOND, 3);
+ String x = time.getTime().toString();
+
String testMsg1 = "##,imei:10000000000000,A";
// NEW MESSAGE: imei:359587017470280,tracker,0000000000,03184511405,L,;
diff --git a/test/net/sourceforge/opentracking/protocol/xexun/XexunProtocolDecoderTest.java b/test/net/sourceforge/opentracking/protocol/xexun/XexunProtocolDecoderTest.java
index 9adbc2c31..23ef128ec 100644
--- a/test/net/sourceforge/opentracking/protocol/xexun/XexunProtocolDecoderTest.java
+++ b/test/net/sourceforge/opentracking/protocol/xexun/XexunProtocolDecoderTest.java
@@ -33,6 +33,8 @@ public class XexunProtocolDecoderTest {
String testMsg =
"GPRMC,010203.000,A,0102.0003,N,00102.0003,E,1.02,1.02,010203,,,A*00,F,, " +
"imei:10000000000000,";
+ //"GPRMC,233842.000,A,5001.3060,N,01429.3243,E,0.00,,210211,,,A*74,F," +
+ //"imei:354776030495631,";
XexunProtocolDecoder decoder = new XexunProtocolDecoder(new TestDataManager());
Position position = (Position) decoder.decode(null, null, testMsg);