From debe7092f6d48abc51852b808f45144863baebde Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 24 Feb 2016 00:33:02 +1300 Subject: Add another GL200 decoder test case --- src/org/traccar/protocol/Gl200ProtocolDecoder.java | 5 +++++ test/org/traccar/protocol/Gl200ProtocolDecoderTest.java | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java index 9098cbd8c..62d93ce13 100644 --- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java @@ -142,6 +142,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { .expression(PATTERN_LOCATION.pattern()) .expression(")+)") .groupBegin() + .number("(d{1,7}.d)?,").optional() // odometer .number("(d{1,3})?,") // battery .or() .number("(d{1,7}.d)?,") // odometer @@ -169,6 +170,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { .number("d{1,2},") // count .expression(PATTERN_LOCATION.pattern()) .groupBegin() + .number("(d{1,7}.d)?,").optional() // odometer .number("(d{1,3})?,") // battery .or() .number("(d{1,7}.d)?,") // odometer @@ -334,6 +336,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { decodeLocation(position, parser); + position.set(Event.KEY_ODOMETER, parser.next()); position.set(Event.KEY_BATTERY, parser.next()); position.set(Event.KEY_ODOMETER, parser.next()); @@ -361,7 +364,9 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { decodeLocation(position, parser); + position.set(Event.KEY_ODOMETER, parser.next()); position.set(Event.KEY_BATTERY, parser.next()); + position.set(Event.KEY_ODOMETER, parser.next()); if (parser.hasNext(6)) { diff --git a/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java b/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java index 4e7686da7..11c069adb 100644 --- a/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java @@ -10,6 +10,9 @@ public class Gl200ProtocolDecoderTest extends ProtocolTest { Gl200ProtocolDecoder decoder = new Gl200ProtocolDecoder(new Gl200Protocol()); + verifyPosition(decoder, text( + "+RESP:GTFRI,2C0204,867162020003125,GL300W,0,0,2,1,1.7,205,2867.0,-78.481127,-0.206828,20160215210433,0740,0000,7596,5891C,0.0,1,1.7,205,2867.0,-78.481127,-0.206828,20160215210503,0740,0000,7596,5891C,0.0,88,20160215210506,1E78$")); + verifyPositions(decoder, text( "+RESP:GTFRI,060228,862894020178276,,15153,10,1,1,0.0,0,431.7,-63.169571,-17.776235,20160210153458,0736,0003,6AD4,80EF,00,34.9,00117:31:26,13442,15163,0,210101,,,,20160210113503,38EE$")); -- cgit v1.2.3