aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java50
1 files changed, 39 insertions, 11 deletions
diff --git a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java
index bd485ca70..e40096a77 100644
--- a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java
@@ -50,7 +50,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
public int getProtocolType(long deviceId) {
return Context.getIdentityManager().lookupAttributeInteger(
- deviceId, getProtocolName() + ".protocolType", protocolType, true);
+ deviceId, getProtocolName() + ".protocolType", protocolType, false, true);
}
public void setHbm(boolean hbm) {
@@ -59,7 +59,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
public boolean isHbm(long deviceId) {
return Context.getIdentityManager().lookupAttributeBoolean(
- deviceId, getProtocolName() + ".hbm", hbm, true);
+ deviceId, getProtocolName() + ".hbm", hbm, false, true);
}
public void setIncludeAdc(boolean includeAdc) {
@@ -68,7 +68,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
public boolean isIncludeAdc(long deviceId) {
return Context.getIdentityManager().lookupAttributeBoolean(
- deviceId, getProtocolName() + ".includeAdc", includeAdc, true);
+ deviceId, getProtocolName() + ".includeAdc", includeAdc, false, true);
}
public void setIncludeRpm(boolean includeRpm) {
@@ -77,7 +77,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
public boolean isIncludeRpm(long deviceId) {
return Context.getIdentityManager().lookupAttributeBoolean(
- deviceId, getProtocolName() + ".includeRpm", includeRpm, true);
+ deviceId, getProtocolName() + ".includeRpm", includeRpm, false, true);
}
public void setIncludeTemp(boolean includeTemp) {
@@ -86,7 +86,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
public boolean isIncludeTemp(long deviceId) {
return Context.getIdentityManager().lookupAttributeBoolean(
- deviceId, getProtocolName() + ".includeTemp", includeTemp, true);
+ deviceId, getProtocolName() + ".includeTemp", includeTemp, false, true);
}
private Position decode9(
@@ -326,12 +326,40 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
case "UEX":
int remaining = Integer.parseInt(values[index++]);
while (remaining > 0) {
- String value = values[index++];
- String[] pair = value.split("=");
- if (pair.length >= 2) {
- position.set(pair[0].toLowerCase(), pair[1].trim());
+ String attribute = values[index++];
+ if (attribute.startsWith("CabAVL")) {
+ String[] data = attribute.split(",");
+ double fuel1 = Double.parseDouble(data[2]);
+ if (fuel1 > 0) {
+ position.set("fuel1", fuel1);
+ }
+ 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 -= value.length() + 1;
+ remaining -= attribute.length() + 1;
}
break;
default:
@@ -393,7 +421,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
String type = values[index++];
- if (!type.equals("STT")) {
+ if (!type.equals("STT") && !type.equals("ALT")) {
return null;
}