aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-06-03 23:11:46 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-06-03 23:12:12 -0700
commit0be1c61132ecff3d5b502926f3c30d7ada5b968a (patch)
tree148f96049671f558adea45271cd5ab25c8609b9b /src/main
parent20ac86632a7d42c7ed4cb888219a05cf7ba4c8b0 (diff)
downloadtrackermap-server-0be1c61132ecff3d5b502926f3c30d7ada5b968a.tar.gz
trackermap-server-0be1c61132ecff3d5b502926f3c30d7ada5b968a.tar.bz2
trackermap-server-0be1c61132ecff3d5b502926f3c30d7ada5b968a.zip
Calculate total fuel
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java
index e65ab6167..3d6f5b8a5 100644
--- a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java
@@ -339,16 +339,19 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
break;
case "UEX":
int remaining = Integer.parseInt(values[index++]);
+ double totalFuel = 0;
while (remaining > 0) {
String attribute = values[index++];
if (attribute.startsWith("CabAVL")) {
String[] data = attribute.split(",");
double fuel1 = Double.parseDouble(data[2]);
if (fuel1 > 0) {
+ totalFuel += fuel1;
position.set("fuel1", fuel1);
}
double fuel2 = Double.parseDouble(data[3]);
if (fuel2 > 0) {
+ totalFuel += fuel2;
position.set("fuel2", fuel2);
}
} else {
@@ -363,7 +366,9 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
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));
+ int fuel = Integer.parseInt(value, 16);
+ totalFuel += fuel;
+ position.set("fuel" + pair[0].charAt(2), fuel);
break;
case 'Q':
position.set("drivingQuality", Integer.parseInt(value, 16));
@@ -375,6 +380,9 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
}
remaining -= attribute.length() + 1;
}
+ if (totalFuel > 0) {
+ position.set(Position.KEY_FUEL_LEVEL, totalFuel);
+ }
index += 1; // checksum
break;
default: