diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-07-18 06:56:03 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-07-18 06:56:03 +1200 |
commit | d62797376e7dc1d5810c1b8728da1e5443cc8e14 (patch) | |
tree | 57b636b5cb74b87cd969ccd666cd3294652bef06 | |
parent | cb0d7cccaecfe049e04defd90884976ac1e982f9 (diff) | |
download | traccar-server-d62797376e7dc1d5810c1b8728da1e5443cc8e14.tar.gz traccar-server-d62797376e7dc1d5810c1b8728da1e5443cc8e14.tar.bz2 traccar-server-d62797376e7dc1d5810c1b8728da1e5443cc8e14.zip |
Refactor TAIP decoder
-rw-r--r-- | src/org/traccar/protocol/TaipProtocolDecoder.java | 16 | ||||
-rw-r--r-- | test/org/traccar/protocol/TaipProtocolDecoderTest.java | 3 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/TaipProtocolDecoder.java b/src/org/traccar/protocol/TaipProtocolDecoder.java index 7702a89fb..a08bb6f2b 100644 --- a/src/org/traccar/protocol/TaipProtocolDecoder.java +++ b/src/org/traccar/protocol/TaipProtocolDecoder.java @@ -104,15 +104,21 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder { Position position = new Position(); position.setProtocol(getProtocolName()); + Integer event = null; + if (parser.hasNext(3)) { - position.set(Position.KEY_EVENT, parser.nextInt(0)); + event = parser.nextInt(); position.setTime(getTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0))); } else if (parser.hasNext()) { position.setTime(getTime(parser.nextInt(0))); } if (parser.hasNext()) { - position.set(Position.KEY_EVENT, parser.nextInt(0)); + event = parser.nextInt(); + } + + if (event != null) { + position.set(Position.KEY_EVENT, event); } if (parser.hasNext(6)) { @@ -150,6 +156,12 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder { attributes = sentence.substring(beginIndex, endIndex).split(";"); } + return decodeAttributes(channel, remoteAddress, position, attributes); + } + + private Position decodeAttributes( + Channel channel, SocketAddress remoteAddress, Position position, String[] attributes) { + String uniqueId = null; DeviceSession deviceSession = null; String messageIndex = null; diff --git a/test/org/traccar/protocol/TaipProtocolDecoderTest.java b/test/org/traccar/protocol/TaipProtocolDecoderTest.java index 2251763cc..6d24a504f 100644 --- a/test/org/traccar/protocol/TaipProtocolDecoderTest.java +++ b/test/org/traccar/protocol/TaipProtocolDecoderTest.java @@ -11,6 +11,9 @@ public class TaipProtocolDecoderTest extends ProtocolTest { TaipProtocolDecoder decoder = new TaipProtocolDecoder(new TaipProtocol()); verifyPosition(decoder, text( + ">REV011958000369+0307185+1016144400000032;IO=200;SV=9;BL=4158;CF=0,0,0;AD=12347;IX=10213040;FF=0,0,0,0;VO=338572;ID=357042063052352<")); + + verifyPosition(decoder, text( ">REV421942237017+1170957-0701880200000032;ID=356612022463055<")); verifyPosition(decoder, text( |