diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-08-11 12:44:35 +0300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-08-11 12:44:35 +0300 |
commit | 1f11fa7db020f8a46e4b298dc61277460d76b678 (patch) | |
tree | 0fc5be35bc87953d1bafb6885237e677da163fb3 /src | |
parent | 40e26cbf38a236f3c92e50dff619b1a29bd413de (diff) | |
download | traccar-server-1f11fa7db020f8a46e4b298dc61277460d76b678.tar.gz traccar-server-1f11fa7db020f8a46e4b298dc61277460d76b678.tar.bz2 traccar-server-1f11fa7db020f8a46e4b298dc61277460d76b678.zip |
Improve Visiontek protocol decoder
Diffstat (limited to 'src')
-rw-r--r-- | src/org/traccar/protocol/VisiontekProtocolDecoder.java | 56 |
1 files changed, 36 insertions, 20 deletions
diff --git a/src/org/traccar/protocol/VisiontekProtocolDecoder.java b/src/org/traccar/protocol/VisiontekProtocolDecoder.java index bfd4a78fa..e2c9b86ba 100644 --- a/src/org/traccar/protocol/VisiontekProtocolDecoder.java +++ b/src/org/traccar/protocol/VisiontekProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2014 - 2016 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,19 +49,23 @@ public class VisiontekProtocolDecoder extends BaseProtocolDecoder { .number("(d+.?d+),") // speed .number("(d+),") // course .groupBegin() - .groupBegin() .number("(d+),") // altitude .number("(d+),") // satellites - .groupEnd("?") .number("(d+),") // odometer - .groupBegin() - .number("(d),") // ignition - .number("(d),") // input 1 - .number("(d),") // input 2 - .number("(d),") // immobilizer - .number("(d),") // external battery status + .number("([01]),") // ignition + .number("([01]),") // input 1 + .number("([01]),") // input 2 + .number("([01]),") // immobilizer + .number("([01]),") // external battery status .number("(d+),") // gsm - .groupEnd("?") + .or() + .number("(d+.d),") // hdop + .number("(d+),") // altitude + .number("(d+),") // odometer + .number("([01],[01],[01],[01]),") // input + .number("([01],[01],[01],[01]),") // output + .number("(d+.?d*),") // adc 1 + .number("(d+.?d*),") // adc 2 .groupEnd("?") .any() .expression("([AV])") // validity @@ -105,16 +109,28 @@ public class VisiontekProtocolDecoder extends BaseProtocolDecoder { parser.next().replace(".", "")) / 10)); position.setCourse(parser.nextDouble()); - position.setAltitude(parser.nextDouble()); - - position.set(Position.KEY_SATELLITES, parser.next()); - position.set(Position.KEY_ODOMETER, parser.next()); - position.set(Position.KEY_IGNITION, parser.next()); - position.set(Position.PREFIX_IO + 1, parser.next()); - position.set(Position.PREFIX_IO + 2, parser.next()); - position.set("immobilizer", parser.next()); - position.set(Position.KEY_POWER, parser.next()); - position.set(Position.KEY_GSM, parser.next()); + + if (parser.hasNext(9)) { + position.setAltitude(parser.nextDouble()); + position.set(Position.KEY_SATELLITES, parser.next()); + position.set(Position.KEY_ODOMETER, parser.next()); + position.set(Position.KEY_IGNITION, parser.next().equals("1")); + position.set(Position.PREFIX_IO + 1, parser.next()); + position.set(Position.PREFIX_IO + 2, parser.next()); + position.set("immobilizer", parser.next()); + position.set(Position.KEY_POWER, parser.next()); + position.set(Position.KEY_GSM, parser.next()); + } + + if (parser.hasNext(7)) { + position.set(Position.KEY_HDOP, parser.next()); + position.setAltitude(parser.nextDouble()); + position.set(Position.KEY_ODOMETER, parser.next()); + position.set(Position.KEY_INPUT, parser.next()); + position.set(Position.KEY_OUTPUT, parser.next()); + position.set(Position.PREFIX_ADC + 1, parser.next()); + position.set(Position.PREFIX_ADC + 2, parser.next()); + } position.setValid(parser.next().equals("A")); |