aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-06-29 21:29:48 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2019-06-29 21:29:48 -0700
commit0527e6817084a1c907ddb41ff9bb3c6e67a3dabd (patch)
tree8ef3ee4ca54f8199c3c07f537c261f376eb138c5 /src/main
parent5b7722bd3fd6f7782eadd4b1afc518fdba28e8d3 (diff)
downloadtraccar-server-0527e6817084a1c907ddb41ff9bb3c6e67a3dabd.tar.gz
traccar-server-0527e6817084a1c907ddb41ff9bb3c6e67a3dabd.tar.bz2
traccar-server-0527e6817084a1c907ddb41ff9bb3c6e67a3dabd.zip
Support fuel sensor data
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java46
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;