From 8d6c4e2747c08180fef6f1de0b1207c9a6fbcdb1 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 22 Feb 2017 08:23:43 +1300 Subject: Add additional TMG parameters --- src/org/traccar/protocol/TmgProtocolDecoder.java | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/org/traccar') 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; } -- cgit v1.2.3