diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-04-17 16:32:02 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-04-17 16:32:02 +1200 |
commit | 1c756c57653b72a656407da9c53ac292c5551cdb (patch) | |
tree | 69e88e24aae184508ab51932ef2692ae9515eef2 /src/org/traccar/protocol/AquilaProtocolDecoder.java | |
parent | 4ab007201bd177a2fbf46a90b7b73262c5792caf (diff) | |
download | trackermap-server-1c756c57653b72a656407da9c53ac292c5551cdb.tar.gz trackermap-server-1c756c57653b72a656407da9c53ac292c5551cdb.tar.bz2 trackermap-server-1c756c57653b72a656407da9c53ac292c5551cdb.zip |
Allow optional primitives
Diffstat (limited to 'src/org/traccar/protocol/AquilaProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/AquilaProtocolDecoder.java | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/src/org/traccar/protocol/AquilaProtocolDecoder.java b/src/org/traccar/protocol/AquilaProtocolDecoder.java index 5f421727f..9c7b1bb12 100644 --- a/src/org/traccar/protocol/AquilaProtocolDecoder.java +++ b/src/org/traccar/protocol/AquilaProtocolDecoder.java @@ -142,20 +142,20 @@ public class AquilaProtocolDecoder extends BaseProtocolDecoder { position.setProtocol(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); - position.set(Position.KEY_EVENT, parser.nextInt()); + position.set(Position.KEY_EVENT, parser.nextInt(0)); - position.setLatitude(parser.nextDouble()); - position.setLongitude(parser.nextDouble()); + position.setLatitude(parser.nextDouble(0)); + position.setLongitude(parser.nextDouble(0)); position.setTime(parser.nextDateTime()); position.setValid(parser.next().equals("A")); - position.set(Position.KEY_RSSI, parser.nextInt()); + position.set(Position.KEY_RSSI, parser.nextInt(0)); - position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble())); + position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0))); - position.set(Position.KEY_ODOMETER, parser.nextInt()); + position.set(Position.KEY_ODOMETER, parser.nextInt(0)); if (parser.hasNext(9)) { @@ -164,21 +164,22 @@ public class AquilaProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_CHARGE, parser.next()); position.set(Position.PREFIX_IN + 2, parser.next()); - position.set(Position.KEY_IGNITION, parser.nextInt() == 1); + position.set(Position.KEY_IGNITION, parser.nextInt(0) == 1); - int course = (parser.nextInt() << 3) + (parser.nextInt() << 2) + (parser.nextInt() << 1) + parser.nextInt(); + int course = (parser.nextInt(0) << 3) + (parser.nextInt(0) << 2) + + (parser.nextInt(0) << 1) + parser.nextInt(0); if (course > 0 && course <= 8) { position.setCourse((course - 1) * 45); } } else if (parser.hasNext(7)) { - position.setCourse(parser.nextInt()); + position.setCourse(parser.nextInt(0)); position.set(Position.KEY_CHARGE, parser.next()); - position.set(Position.KEY_IGNITION, parser.nextInt() == 1); - position.set(Position.KEY_POWER, parser.nextInt()); - position.set(Position.KEY_BATTERY, parser.nextInt()); + position.set(Position.KEY_IGNITION, parser.nextInt(0) == 1); + position.set(Position.KEY_POWER, parser.nextInt(0)); + position.set(Position.KEY_BATTERY, parser.nextInt(0)); String obd = parser.next(); position.set("obd", obd.substring(1, obd.length() - 1)); @@ -188,17 +189,17 @@ public class AquilaProtocolDecoder extends BaseProtocolDecoder { } else { - position.setCourse(parser.nextInt()); + position.setCourse(parser.nextInt(0)); - position.set(Position.KEY_SATELLITES, parser.nextInt()); - position.set(Position.KEY_HDOP, parser.nextDouble()); - position.set(Position.PREFIX_ADC + 1, parser.nextInt()); - position.set(Position.PREFIX_IN + 1, parser.nextInt()); + position.set(Position.KEY_SATELLITES, parser.nextInt(0)); + position.set(Position.KEY_HDOP, parser.nextDouble(0)); + position.set(Position.PREFIX_ADC + 1, parser.nextInt(0)); + position.set(Position.PREFIX_IN + 1, parser.nextInt(0)); position.set(Position.KEY_CHARGE, parser.next()); - position.set(Position.PREFIX_IN + 2, parser.nextInt()); - position.set(Position.KEY_IGNITION, parser.nextInt() == 1); - position.set(Position.KEY_POWER, parser.nextInt()); - position.set(Position.KEY_BATTERY, parser.nextInt()); + position.set(Position.PREFIX_IN + 2, parser.nextInt(0)); + position.set(Position.KEY_IGNITION, parser.nextInt(0) == 1); + position.set(Position.KEY_POWER, parser.nextInt(0)); + position.set(Position.KEY_BATTERY, parser.nextInt(0)); } |