diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-02-22 08:23:43 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-02-22 08:23:43 +1300 |
commit | 8d6c4e2747c08180fef6f1de0b1207c9a6fbcdb1 (patch) | |
tree | fd389ce9c8381ed15ca3a0fb80a8dcb5b4ab26d0 | |
parent | 8ad8f84cf2d1f37759633ac274ea1144aeea6903 (diff) | |
download | trackermap-server-8d6c4e2747c08180fef6f1de0b1207c9a6fbcdb1.tar.gz trackermap-server-8d6c4e2747c08180fef6f1de0b1207c9a6fbcdb1.tar.bz2 trackermap-server-8d6c4e2747c08180fef6f1de0b1207c9a6fbcdb1.zip |
Add additional TMG parameters
-rw-r--r-- | src/org/traccar/protocol/TmgProtocolDecoder.java | 23 | ||||
-rw-r--r-- | test/org/traccar/protocol/TmgProtocolDecoderTest.java | 6 |
2 files changed, 27 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/TmgProtocolDecoder.java b/src/org/traccar/protocol/TmgProtocolDecoder.java index 3b73a1516..1a03267b5 100644 --- a/src/org/traccar/protocol/TmgProtocolDecoder.java +++ b/src/org/traccar/protocol/TmgProtocolDecoder.java @@ -18,6 +18,7 @@ package org.traccar.protocol; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.DeviceSession; +import org.traccar.helper.BitUtil; import org.traccar.helper.DateBuilder; import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; @@ -60,6 +61,11 @@ public class TmgProtocolDecoder extends BaseProtocolDecoder { .expression("([01]+),") // input .expression("([01]+),") // output .expression("[01]+,") // temper status + .number("(d+.?d*),") // adc1 + .number("(d+.?d*),") // adc2 + .number("d+.?d*,") // trip meter + .expression("([^,]*),") // software version + .expression("([^,]*),").optional() // rfid .any() .compile(); @@ -128,8 +134,21 @@ public class TmgProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_IGNITION, parser.nextInt() == 1); position.set(Position.KEY_BATTERY, parser.nextDouble()); position.set(Position.KEY_POWER, parser.nextDouble()); - position.set(Position.KEY_INPUT, parser.nextInt(2)); - position.set(Position.KEY_OUTPUT, parser.nextInt(2)); + + int input = parser.nextInt(2); + int output = parser.nextInt(2); + + if (!BitUtil.check(input, 0)) { + position.set(Position.KEY_ALARM, Position.ALARM_SOS); + } + + position.set(Position.KEY_INPUT, input); + position.set(Position.KEY_OUTPUT, output); + + position.set(Position.PREFIX_ADC + 1, parser.nextDouble()); + position.set(Position.PREFIX_ADC + 2, parser.nextDouble()); + position.set(Position.KEY_VERSION_FW, parser.next()); + position.set(Position.KEY_RFID, parser.next()); return position; } diff --git a/test/org/traccar/protocol/TmgProtocolDecoderTest.java b/test/org/traccar/protocol/TmgProtocolDecoderTest.java index cbfe82abc..ba5ff4894 100644 --- a/test/org/traccar/protocol/TmgProtocolDecoderTest.java +++ b/test/org/traccar/protocol/TmgProtocolDecoderTest.java @@ -11,6 +11,12 @@ public class TmgProtocolDecoderTest extends ProtocolTest { TmgProtocolDecoder decoder = new TmgProtocolDecoder(new TmgProtocol()); verifyPosition(decoder, text( + "$nor,L,868325023006341,14022017,103947,1,2836.6542,N,07706.2504,E,0.0,0.0,0.0,0.0,0,22,VODAFONE - DELH,15,49B7,1,2.57,13.2,00000010,00000000,0111,00.0,00.0,0.0,SW10.12,NA,#")); + + verifyPosition(decoder, text( + "$rid,L,868325023006341,14022017,103706,1,2836.6542,N,07706.2504,E,0.0,0.0,0.0,0.0,0,22,VODAFONE - DELH,15,49B7,1,2.57,13.2,00000011,00000000,0111,00.0,00.0,0.0,SW10.12,0004909463,#")); + + verifyPosition(decoder, text( "$ion,H,868324023777431,27012017,101057,4,2830.2952,N,07705.2532,E,0.0,202.38,225.9,1.22,8,20,N.A,0,N.A,1,4.09,00.0,00000111,00000000,1101,00.0-00.0,00.0-0.0,4.42,01.02,#")); verifyPosition(decoder, text( |