diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-04-13 14:24:28 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-04-13 14:25:08 +1200 |
commit | 13bd5f99a4dde7d42ffa0fa7e323ba266a081d70 (patch) | |
tree | cb6673bc8f75adc848e4b4eb9db1020dcdbd47d6 | |
parent | 33ddc7a4087b0bc091c5ce4db44409668c591a7a (diff) | |
download | trackermap-server-13bd5f99a4dde7d42ffa0fa7e323ba266a081d70.tar.gz trackermap-server-13bd5f99a4dde7d42ffa0fa7e323ba266a081d70.tar.bz2 trackermap-server-13bd5f99a4dde7d42ffa0fa7e323ba266a081d70.zip |
Add support for GV500 protocol
-rw-r--r-- | src/org/traccar/protocol/Gl200ProtocolDecoder.java | 23 | ||||
-rw-r--r-- | test/org/traccar/protocol/Gl200ProtocolDecoderTest.java | 9 |
2 files changed, 31 insertions, 1 deletions
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java index 28b1005df..d34868b6a 100644 --- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java @@ -17,6 +17,7 @@ package org.traccar.protocol; import java.net.SocketAddress; import java.util.LinkedList; +import java.util.List; import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; @@ -26,6 +27,7 @@ import org.traccar.helper.BitUtil; import org.traccar.helper.DateBuilder; import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; +import org.traccar.helper.PatternUtil; import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; @@ -133,6 +135,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { .text("+").expression("(?:RESP|BUFF):GTFRI,") .number("(?:[0-9A-Z]{2}xxxx)?,") // protocol version .number("(d{15}|x{14}),") // imei + .expression("(?:([0-9A-Z]{17}),)?") // vin .expression("[^,]*,") // device name .number("(d+)?,") // power .number("d{1,2},") // report type @@ -149,7 +152,10 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { .number("(x+)?,") // adc 1 .number("(x+)?,") // adc 2 .number("(d{1,3})?,") // battery - .number("(?:(xx)(xx)(xx))?,,,,") // device status + .number("(?:(xx)(xx)(xx))?,") // device status + .number("(d+)?,") // rpm + .number("(?:d+.?d*|Inf|NaN)?,") // fuel consumption + .number("(d+)?,") // fuel level .groupEnd() .number("(dddd)(dd)(dd)") // date .number("(dd)(dd)(dd)").optional(2) // time @@ -358,6 +364,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { return null; } + String vin = parser.next(); int power = parser.nextInt(); Parser itemParser = new Parser(PATTERN_LOCATION, parser.next()); @@ -366,6 +373,8 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { position.setProtocol(getProtocolName()); position.setDeviceId(getDeviceId()); + position.set(Event.KEY_VIN, vin); + decodeLocation(position, itemParser); positions.add(position); @@ -388,6 +397,8 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { position.set(Event.PREFIX_ADC + 1, parser.next()); position.set(Event.PREFIX_ADC + 2, parser.next()); position.set(Event.KEY_BATTERY, parser.next()); + position.set(Event.KEY_RPM, parser.next()); + position.set(Event.KEY_FUEL, parser.next()); if (parser.hasNext(3)) { int ignition = parser.nextInt(16); @@ -600,6 +611,16 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { result = decodeBasic(channel, remoteAddress, sentence); } + if (result != null) { + if (result instanceof Position) { + ((Position) result).set(Event.KEY_TYPE, type); + } else { + for (Position p : (List<Position>) result) { + p.set(Event.KEY_TYPE, type); + } + } + } + return result; } diff --git a/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java b/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java index 4bb66d960..b4f3addf2 100644 --- a/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java @@ -10,6 +10,15 @@ public class Gl200ProtocolDecoderTest extends ProtocolTest { Gl200ProtocolDecoder decoder = new Gl200ProtocolDecoder(new Gl200Protocol()); + verifyPositions(decoder, text( + "+RESP:GTFRI,1F0101,135790246811220,1G1JC5444R7252367,,,00,2,1,4.3,92,70.0,121.354335,31.222073,20090214013254,0460,0000,18d8,6141,00,0,4.3,92,70.0,121.354335,31.222073,20090101000000,0460,0000,18d8,6141,00,2000.0,12345:12:34,,,80,210100,,,50,20090214093254,11F0$")); + + verifyPositions(decoder, text( + "+RESP:GTFRI,1F0101,135790246811220,1G1JC5444R7252367,,,00,1,1,4.3,92,70.0,121.354335,31.222073,20090214013254,0460,0000,18d8,6141,00,2000.0,12345:12:34,,92,80,210100,,,50,20090214093254,11F0$")); + + verifyPositions(decoder, text( + "+RESP:GTFRI,1F0201,864251020108126,1C6RR7GM4FS572742,,13286,10,1,3,0.0,191,211.2,-76.729721,39.798626,20160407155620,0310,0260,043F,7BE0,00,18800.6,00038:08:54,,,0,220000,679,48,,20160407155624,25A1$")); + verifyPosition(decoder, text( "+RESP:GTSTT,060228,862894020178276,,21,0,0.0,0,411.3,-63.169745,-17.776330,20160319132220,0736,0003,6AD4,5BAA,00,20160319092223,1FBD$")); |