aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-02-22 08:23:43 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-02-22 08:23:43 +1300
commit8d6c4e2747c08180fef6f1de0b1207c9a6fbcdb1 (patch)
treefd389ce9c8381ed15ca3a0fb80a8dcb5b4ab26d0 /src
parent8ad8f84cf2d1f37759633ac274ea1144aeea6903 (diff)
downloadtraccar-server-8d6c4e2747c08180fef6f1de0b1207c9a6fbcdb1.tar.gz
traccar-server-8d6c4e2747c08180fef6f1de0b1207c9a6fbcdb1.tar.bz2
traccar-server-8d6c4e2747c08180fef6f1de0b1207c9a6fbcdb1.zip
Add additional TMG parameters
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/protocol/TmgProtocolDecoder.java23
1 files changed, 21 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;
}