aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-08-19 12:55:25 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2017-08-19 12:55:25 +1200
commitd7725b0fb8ecde4d883a07d8bc4e77974c56eada (patch)
tree7d875d71a2be5ee2228ce3dfe2ac2791a0f45a64 /src/org/traccar/protocol
parent8482304d444ebdd25901be066eaf4b5c4048a278 (diff)
downloadtraccar-server-d7725b0fb8ecde4d883a07d8bc4e77974c56eada.tar.gz
traccar-server-d7725b0fb8ecde4d883a07d8bc4e77974c56eada.tar.bz2
traccar-server-d7725b0fb8ecde4d883a07d8bc4e77974c56eada.zip
Add Suntech temperature support
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/SuntechProtocolDecoder.java50
1 files changed, 48 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/SuntechProtocolDecoder.java b/src/org/traccar/protocol/SuntechProtocolDecoder.java
index 42e81f60c..93c53d2cf 100644
--- a/src/org/traccar/protocol/SuntechProtocolDecoder.java
+++ b/src/org/traccar/protocol/SuntechProtocolDecoder.java
@@ -32,18 +32,34 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
private int protocolType;
private boolean hbm;
+ private boolean includeAdc;
+ private boolean includeTemp;
public SuntechProtocolDecoder(SuntechProtocol protocol) {
super(protocol);
protocolType = Context.getConfig().getInteger(getProtocolName() + ".protocolType");
hbm = Context.getConfig().getBoolean(getProtocolName() + ".hbm");
+ includeAdc = Context.getConfig().getBoolean(getProtocolName() + ".includeAdc");
+ includeTemp = Context.getConfig().getBoolean(getProtocolName() + ".includeTemp");
}
public void setProtocolType(int protocolType) {
this.protocolType = protocolType;
}
+ public void setHbm(boolean hbm) {
+ this.hbm = hbm;
+ }
+
+ public void setIncludeAdc(boolean includeAdc) {
+ this.includeAdc = includeAdc;
+ }
+
+ public void setIncludeTemp(boolean includeTemp) {
+ this.includeTemp = includeTemp;
+ }
+
private Position decode9(
Channel channel, SocketAddress remoteAddress, String[] values) throws ParseException {
int index = 1;
@@ -87,7 +103,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
position.setValid(values[index++].equals("1"));
if (protocolType == 1) {
- position.set(Position.KEY_ODOMETER, Integer.parseInt(values[index]));
+ position.set(Position.KEY_ODOMETER, Integer.parseInt(values[index++]));
}
return position;
@@ -155,7 +171,37 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
}
if (index < values.length) {
- position.set(Position.KEY_BATTERY, Double.parseDouble(values[index]));
+ position.set(Position.KEY_BATTERY, Double.parseDouble(values[index++]));
+ }
+
+ if (index < values.length) {
+ if (values[index++].equals("0")) {
+ position.set(Position.KEY_ARCHIVE, true);
+ }
+ }
+
+ if (includeAdc) {
+ position.set(Position.PREFIX_ADC + 1, Double.parseDouble(values[index++]));
+ position.set(Position.PREFIX_ADC + 2, Double.parseDouble(values[index++]));
+ position.set(Position.PREFIX_ADC + 3, Double.parseDouble(values[index++]));
+ }
+
+ if (values.length - index >= 2) {
+ String driverUniqueId = values[index++];
+ if (values[index++].equals("1") && !driverUniqueId.isEmpty()) {
+ position.set(Position.KEY_DRIVER_UNIQUE_ID, driverUniqueId);
+ }
+ }
+
+ if (includeTemp) {
+ for (int i = 1; i <= 3; i++) {
+ String temperature = values[index++];
+ String value = temperature.substring(temperature.indexOf(':') + 1);
+ if (!value.isEmpty()) {
+ position.set(Position.PREFIX_TEMP + i, Double.parseDouble(value));
+ }
+ }
+
}
}