diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-06-29 21:29:48 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-06-29 21:29:48 -0700 |
commit | 0527e6817084a1c907ddb41ff9bb3c6e67a3dabd (patch) | |
tree | 8ef3ee4ca54f8199c3c07f537c261f376eb138c5 /src/main/java/org/traccar | |
parent | 5b7722bd3fd6f7782eadd4b1afc518fdba28e8d3 (diff) | |
download | trackermap-server-0527e6817084a1c907ddb41ff9bb3c6e67a3dabd.tar.gz trackermap-server-0527e6817084a1c907ddb41ff9bb3c6e67a3dabd.tar.bz2 trackermap-server-0527e6817084a1c907ddb41ff9bb3c6e67a3dabd.zip |
Support fuel sensor data
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r-- | src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java index 1ad984c60..903c37a8f 100644 --- a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java @@ -327,24 +327,36 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { int remaining = Integer.parseInt(values[index++]); while (remaining > 0) { String attribute = values[index++]; - String[] pair = attribute.split("="); - if (pair.length >= 2) { - String value = pair[1].trim(); - if (value.contains(".")) { - value = value.substring(0, value.indexOf('.')); + if (attribute.startsWith("CabAVL")) { + String[] data = attribute.split(","); + double fuel1 = Double.parseDouble(data[2]); + if (fuel1 > 0) { + position.set("fuel1", fuel1); } - switch (pair[0].charAt(0)) { - case 't': - position.set(Position.PREFIX_TEMP + pair[0].charAt(2), Integer.parseInt(value, 16)); - break; - case 'N': - position.set("fuel" + pair[0].charAt(2), Integer.parseInt(value, 16)); - break; - case 'Q': - position.set("drivingQuality", Integer.parseInt(value, 16)); - break; - default: - break; + double fuel2 = Double.parseDouble(data[3]); + if (fuel2 > 0) { + position.set("fuel2", fuel2); + } + } else { + String[] pair = attribute.split("="); + if (pair.length >= 2) { + String value = pair[1].trim(); + if (value.contains(".")) { + value = value.substring(0, value.indexOf('.')); + } + switch (pair[0].charAt(0)) { + case 't': + position.set(Position.PREFIX_TEMP + pair[0].charAt(2), Integer.parseInt(value, 16)); + break; + case 'N': + position.set("fuel" + pair[0].charAt(2), Integer.parseInt(value, 16)); + break; + case 'Q': + position.set("drivingQuality", Integer.parseInt(value, 16)); + break; + default: + break; + } } } remaining -= attribute.length() + 1; |