diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-12-01 07:53:49 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-12-01 07:53:49 +1300 |
commit | 09a1cbffdf19154a3fc990f0d0562677f29e39d8 (patch) | |
tree | c1ec63509f4c4e4b97fdcfcc357f882f737c9c3a | |
parent | 700f39377da8801377508357292862b18fafd16a (diff) | |
download | trackermap-server-09a1cbffdf19154a3fc990f0d0562677f29e39d8.tar.gz trackermap-server-09a1cbffdf19154a3fc990f0d0562677f29e39d8.tar.bz2 trackermap-server-09a1cbffdf19154a3fc990f0d0562677f29e39d8.zip |
Implement G737IC extra data
-rw-r--r-- | src/org/traccar/model/Position.java | 1 | ||||
-rw-r--r-- | src/org/traccar/protocol/GoSafeProtocolDecoder.java | 34 | ||||
-rw-r--r-- | test/org/traccar/protocol/GoSafeProtocolDecoderTest.java | 3 |
3 files changed, 29 insertions, 9 deletions
diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java index b2965c89c..8ca2588e2 100644 --- a/src/org/traccar/model/Position.java +++ b/src/org/traccar/model/Position.java @@ -59,6 +59,7 @@ public class Position extends Message { public static final String KEY_MOTION = "motion"; public static final String KEY_ARMED = "armed"; public static final String KEY_ACCURACY = "accuracy"; + public static final String KEY_GEOFENCE = "geofence"; public static final String KEY_DTCS = "dtcs"; public static final String KEY_OBD_SPEED = "obdSpeed"; diff --git a/src/org/traccar/protocol/GoSafeProtocolDecoder.java b/src/org/traccar/protocol/GoSafeProtocolDecoder.java index a258e922c..1ae527160 100644 --- a/src/org/traccar/protocol/GoSafeProtocolDecoder.java +++ b/src/org/traccar/protocol/GoSafeProtocolDecoder.java @@ -90,13 +90,14 @@ public class GoSafeProtocolDecoder extends BaseProtocolDecoder { .groupBegin() .text("DTT:") .number("(x+);") // status - .expression("[^;]*;") - .number("x+;") // geo-fence 0-119 - .number("x+;") // geo-fence 120-155 - .number("x+,?") // event status + .number("(x+)?;") // io + .number("(x+);") // geo-fence 0-119 + .number("(x+);") // geo-fence 120-155 + .number("(x+)") // event status + .number("(?:;(x+))?,?") // packet type .groupEnd("?") .groupBegin() - .text("ETD:").expression("[^,]*,?") + .text("ETD:").expression("([^,]+),?") .groupEnd("?") .groupBegin() .text("OBD:") @@ -108,6 +109,9 @@ public class GoSafeProtocolDecoder extends BaseProtocolDecoder { .groupBegin() .text("TRU:").expression("[^,]*,?") .groupEnd("?") + .groupBegin() + .text("TAG:").expression("([^,]+),?") + .groupEnd("?") .compile(); private static final Pattern PATTERN_OLD = new PatternBuilder() @@ -122,7 +126,7 @@ public class GoSafeProtocolDecoder extends BaseProtocolDecoder { .number("([EW])(d+.d+);") // longitude .number("(d+)?;") // speed .number("(d+);") // course - .number("(d+.?d*)").optional() // hdop + .number("(d+.?d*)").optional() // hdop .number("(dd)(dd)(dd)") // date .any() .compile(); @@ -162,16 +166,28 @@ public class GoSafeProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_POWER, parser.next()); position.set(Position.KEY_BATTERY, parser.next()); - String status = parser.next(); - if (status != null) { - position.set(Position.KEY_IGNITION, BitUtil.check(Integer.parseInt(status, 16), 13)); + if (parser.hasNext(6)) { + long status = parser.nextLong(16); + position.set(Position.KEY_IGNITION, BitUtil.check(status, 13)); position.set(Position.KEY_STATUS, status); + position.set("ioStatus", parser.next()); + position.set(Position.KEY_GEOFENCE, parser.next() + parser.next()); + position.set("eventStatus", parser.next()); + position.set("packetType", parser.next()); + } + + if (parser.hasNext()) { + position.set("eventData", parser.next()); } if (parser.hasNext()) { position.set("obd", parser.next()); } + if (parser.hasNext()) { + position.set("tagData", parser.next()); + } + return position; } diff --git a/test/org/traccar/protocol/GoSafeProtocolDecoderTest.java b/test/org/traccar/protocol/GoSafeProtocolDecoderTest.java index fb0dec4fb..35cf5fcb2 100644 --- a/test/org/traccar/protocol/GoSafeProtocolDecoderTest.java +++ b/test/org/traccar/protocol/GoSafeProtocolDecoderTest.java @@ -10,6 +10,9 @@ public class GoSafeProtocolDecoderTest extends ProtocolTest { GoSafeProtocolDecoder decoder = new GoSafeProtocolDecoder(new GoSafeProtocol()); + verifyPositions(decoder, text( + "*GS26,356449061139936,022918011216,,SYS:G737IC;V1.13;V1.0.5,GPS:A;9;N42.651728;W70.623520;0;0;48;1.50,ADC:4.08,DTT:3900C;;0;0;0;1,#")); + verifyNotNull(decoder, text( "*GS56,356449063230915,052339180916,,SYS:G7S;V1.08;V1.2,GPS:V;4;N24.730006;E46.637816;14;0;630,GSM:;;420;4;5655;507A;-70,COT:75242;2-8-17,ADC:13.22;0.08,DTT:23004;;0;0;0;1#")); |