diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-01-23 10:09:58 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-01-23 10:09:58 +1300 |
commit | 2e24e0e311606d7b12b9e36f113dd218e54d67bb (patch) | |
tree | 5e8397d6b40c01989cc333fd9633f633da61fe84 | |
parent | 6ebe7202420731f51cd40f15879ce40bdd1926b6 (diff) | |
download | trackermap-server-2e24e0e311606d7b12b9e36f113dd218e54d67bb.tar.gz trackermap-server-2e24e0e311606d7b12b9e36f113dd218e54d67bb.tar.bz2 trackermap-server-2e24e0e311606d7b12b9e36f113dd218e54d67bb.zip |
Use send time if earlier than GPS time
-rw-r--r-- | src/org/traccar/protocol/Gl200ProtocolDecoder.java | 21 | ||||
-rw-r--r-- | test/org/traccar/protocol/Gl200ProtocolDecoderTest.java | 5 |
2 files changed, 22 insertions, 4 deletions
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java index 42786d4fe..a2681e10d 100644 --- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 - 2015 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2012 - 2016 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -124,8 +124,14 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { .number("(d+.d)?,") // odometer .number("(d{1,3})?,") // battery .groupEnd("?") - .any().text(",") - .number("(xxxx)") + .groupBegin() + .any() + .number("(dddd)(dd)(dd)") // date + .number("(dd)(dd)(dd)") // time + .or() + .any() + .groupEnd() + .number(",(xxxx)") .text("$").optional() .compile(); @@ -227,6 +233,15 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { position.set(Event.KEY_ODOMETER, parser.next()); position.set(Event.KEY_BATTERY, parser.next()); + if (parser.hasNext(6)) { + DateBuilder dateBuilder = new DateBuilder() + .setDate(parser.nextInt(), parser.nextInt(), parser.nextInt()) + .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt()); + if (!position.getOutdated() && position.getFixTime().after(dateBuilder.getDate())) { + position.setTime(dateBuilder.getDate()); + } + } + if (Context.getConfig().getBoolean(getProtocolName() + ".ack") && channel != null) { channel.write("+SACK:" + parser.next() + "$", remoteAddress); } diff --git a/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java b/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java index cba40ddb7..61d38f7d1 100644 --- a/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java @@ -11,6 +11,9 @@ public class Gl200ProtocolDecoderTest extends ProtocolTest { Gl200ProtocolDecoder decoder = new Gl200ProtocolDecoder(new Gl200Protocol()); verifyPosition(decoder, text( + "+BUFF:GTFRI,060402,862894021808798,,,10,1,1,0.0,349,394.3,-63.287717,-17.662410,20160116234031,0736,0003,6ABA,8305,00,3326.8,,,,94,220100,,,,20160116194035,4D83")); + + verifyPosition(decoder, text( "+RESP:GTIDA,06020A,862170013895931,,,D2C4FBC5,1,1,1,0.8,0,22.2,117.198630,31.845229,20120802121626,0460,0000,5663,2BB9,00,0.0,,,,,20120802121627,008E$")); verifyAttributes(decoder, text( @@ -108,7 +111,7 @@ public class Gl200ProtocolDecoderTest extends ProtocolTest { verifyPosition(decoder, text( "+RESP:GTFRI,02010C,867844001274649,,0,0,1,1,0.0,0,122.5,7.684216,51.524512,20140106233722,0262,0007,79EE,1D22,,93,20140107003805,03C4$")); - + verifyPosition(decoder, text( "+BUFF:GTFRI,210101,863286020016706,,,10,1,1,,,,49.903915,40.391669,20140818105815,,,,,,,,,,,210100,,,,,000C$")); |