diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java | 14 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java | 14 |
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); |