aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-04-01 21:43:45 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2019-04-01 21:43:45 -0700
commit91601b305e2ada2f5215af043a00ad50f22e79be (patch)
tree5f2a80a159ab4e531d464e039f58e936f584234c
parent08b950ea73ba142b5681aad4b208755db540cdb0 (diff)
downloadtrackermap-server-91601b305e2ada2f5215af043a00ad50f22e79be.tar.gz
trackermap-server-91601b305e2ada2f5215af043a00ad50f22e79be.tar.bz2
trackermap-server-91601b305e2ada2f5215af043a00ad50f22e79be.zip
Decode ST300H RPM value
-rw-r--r--src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java14
-rw-r--r--src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java14
2 files changed, 28 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java
index 922431021..a80e84728 100644
--- a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java
@@ -37,6 +37,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
private int protocolType;
private boolean hbm;
private boolean includeAdc;
+ private boolean includeRpm;
private boolean includeTemp;
public SuntechProtocolDecoder(Protocol protocol) {
@@ -70,6 +71,15 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
deviceId, getProtocolName() + ".includeAdc", includeAdc, true);
}
+ public void setIncludeRpm(boolean includeRpm) {
+ this.includeRpm = includeRpm;
+ }
+
+ public boolean isIncludeRpm(long deviceId) {
+ return Context.getIdentityManager().lookupAttributeBoolean(
+ deviceId, getProtocolName() + ".includeRpm", includeRpm, true);
+ }
+
public void setIncludeTemp(boolean includeTemp) {
this.includeTemp = includeTemp;
}
@@ -338,6 +348,10 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
}
}
+ if (isIncludeRpm(deviceSession.getDeviceId()) && index < values.length) {
+ position.set(Position.KEY_RPM, Integer.parseInt(values[index++]));
+ }
+
if (values.length - index >= 2) {
String driverUniqueId = values[index++];
if (values[index++].equals("1") && !driverUniqueId.isEmpty()) {
diff --git a/src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java
index 355cda783..f740faa4e 100644
--- a/src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java
@@ -27,6 +27,20 @@ public class SuntechProtocolDecoderTest extends ProtocolTest {
}
@Test
+ public void testDecodeRpm() throws Exception {
+
+ SuntechProtocolDecoder decoder = new SuntechProtocolDecoder(null);
+
+ decoder.setHbm(true);
+ decoder.setIncludeRpm(true);
+
+ verifyAttribute(decoder, text(
+ "ST300STT;907131077;04;706;20190227;23:59:34;cc719;-12.963490;-038.499587;000.067;000.00;7;1;57095;12.50;000000;1;0337;000207;0.0;1;0;012E717F010000;1"),
+ Position.KEY_RPM, 0);
+
+ }
+
+ @Test
public void testDecodeHours() throws Exception {
SuntechProtocolDecoder decoder = new SuntechProtocolDecoder(null);