diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-09-11 23:20:37 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-09-11 23:20:37 -0700 |
commit | dbcde8aee59ebaa488cf9730a0356817e282ee84 (patch) | |
tree | aa9e61e621356085f608b51b534d9f32acad8cc9 | |
parent | 81d2bdab9d91b2faa4824fbced4db2bc0edc821d (diff) | |
download | trackermap-server-dbcde8aee59ebaa488cf9730a0356817e282ee84.tar.gz trackermap-server-dbcde8aee59ebaa488cf9730a0356817e282ee84.tar.bz2 trackermap-server-dbcde8aee59ebaa488cf9730a0356817e282ee84.zip |
Decode driver id value
-rw-r--r-- | src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java | 20 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java | 15 |
2 files changed, 35 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java index fd4af847f..76e3e6ecc 100644 --- a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java @@ -687,6 +687,24 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { return position; } + private Position decodeTravelReport(Channel channel, SocketAddress remoteAddress, String[] values) { + int index = 1; + + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, values[index++]); + if (deviceSession == null) { + return null; + } + + Position position = new Position(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + + getLastLocation(position, null); + + position.set(Position.KEY_DRIVER_UNIQUE_ID, values[values.length - 1]); + + return position; + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -704,6 +722,8 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { if (prefix.length() < 5) { return decodeUniversal(channel, remoteAddress, values); + } else if (prefix.endsWith("HTE")) { + return decodeTravelReport(channel, remoteAddress, values); } else if (prefix.startsWith("ST9")) { return decode9(channel, remoteAddress, values); } else if (prefix.startsWith("ST4")) { diff --git a/src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java index 265eae334..847f6707d 100644 --- a/src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java @@ -63,6 +63,21 @@ public class SuntechProtocolDecoderTest extends ProtocolTest { } @Test + public void testDecodeDriver() throws Exception { + + SuntechProtocolDecoder decoder = new SuntechProtocolDecoder(null); + + verifyAttribute(decoder, buffer( + "ST300HTE;511050566;45;308;20200909;13:38:38;0;12.50;001354;0.0;1;0;1;1;0;-27.636632;-052.277933;-27.636675;-052.277947;000.000;002.296;0;00000000000000"), + Position.KEY_DRIVER_UNIQUE_ID, "00000000000000"); + + verifyAttribute(decoder, buffer( + "ST300HTE;100850001;04;248;20110101;00:13:52;167559;12.28;004005;0.0;1;0;3;3;0;-22.881018;-047.070831;-22.881018;-047.070831;000.000;000.000;0;0;3;0;0;0;01E04D44160000"), + Position.KEY_DRIVER_UNIQUE_ID, "01E04D44160000"); + + } + + @Test public void testDecode() throws Exception { SuntechProtocolDecoder decoder = new SuntechProtocolDecoder(null); |