diff options
-rw-r--r-- | src/org/traccar/protocol/DwayProtocolDecoder.java | 15 | ||||
-rw-r--r-- | test/org/traccar/protocol/DwayProtocolDecoderTest.java | 6 |
2 files changed, 7 insertions, 14 deletions
diff --git a/src/org/traccar/protocol/DwayProtocolDecoder.java b/src/org/traccar/protocol/DwayProtocolDecoder.java index 993aa91b2..767b35c72 100644 --- a/src/org/traccar/protocol/DwayProtocolDecoder.java +++ b/src/org/traccar/protocol/DwayProtocolDecoder.java @@ -42,15 +42,16 @@ public class DwayProtocolDecoder extends BaseProtocolDecoder { .number("(-?d+.d+),") // latitude .number("(-?d+.d+),") // longitude .number("(-?d+),") // altitude - .number("(d+.d+),") // speed + .number(" ?(d+.d+),") // speed .number("(d+),") // course .number("([01]{4}),") // input .number("([01]{4}),") // output - .number("([01])([01])([01])([01]),") // flags + .number("([01]+),") // flags .number("(d+),") // battery .number("(d+),") // adc1 .number("(d+),") // adc2 .number("(d+)") // driver + .any() .compile(); @Override @@ -79,6 +80,7 @@ public class DwayProtocolDecoder extends BaseProtocolDecoder { position.setProtocol(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); + position.setValid(true); position.setTime(parser.nextDateTime()); position.setLatitude(parser.nextDouble()); position.setLongitude(parser.nextDouble()); @@ -89,15 +91,6 @@ public class DwayProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_INPUT, parser.nextBinInt()); position.set(Position.KEY_OUTPUT, parser.nextBinInt()); - position.setValid(parser.next().equals("1")); - - position.set(Position.KEY_IGNITION, parser.next().equals("1")); - position.set(Position.KEY_CHARGE, parser.next().equals("1")); - - if (parser.next().equals("1")) { - position.set(Position.KEY_ALARM, Position.ALARM_SHOCK); - } - position.set(Position.KEY_BATTERY, parser.nextInt() * 0.001); position.set(Position.PREFIX_ADC + 1, parser.nextInt() * 0.001); position.set(Position.PREFIX_ADC + 2, parser.nextInt() * 0.001); diff --git a/test/org/traccar/protocol/DwayProtocolDecoderTest.java b/test/org/traccar/protocol/DwayProtocolDecoderTest.java index 481382535..be51f2b94 100644 --- a/test/org/traccar/protocol/DwayProtocolDecoderTest.java +++ b/test/org/traccar/protocol/DwayProtocolDecoderTest.java @@ -10,13 +10,13 @@ public class DwayProtocolDecoderTest extends ProtocolTest { DwayProtocolDecoder decoder = new DwayProtocolDecoder(new DwayProtocol()); - verifyNull(decoder, text( + verifyPosition(decoder, text( "AA55,36,10024,1,171025,161055,36.0294,-79.7881,201, 2.5,111,1000,0000,00000,3578,0,0,0,D")); - verifyNull(decoder, text( + verifyPosition(decoder, text( "AA55,115,318,1,171024,195059,28.0153,-82.4761,3, 1.0,319,1000,0000,00000,4244,0,0,0,D")); - verifyNull(decoder, text( + verifyPosition(decoder, text( "AA55,117,318,1,171025,153758,28.0152,-82.4759,19, 0.6,319,1000,0000,10000,4242,0,0,0,D")); verifyPosition(decoder, text( |