diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-05-22 17:59:22 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-22 17:59:22 +1200 |
commit | 5af130db6edcc25d89a8f84e55350644ba4797b3 (patch) | |
tree | d828de08c9c2f7cabf671f6d75ddda459af77507 | |
parent | 0bafa34ebceba731aae2b45ae9e05c8f55b66b0e (diff) | |
parent | 152e8f2e494275b1259601560abc22bcb39502c3 (diff) | |
download | trackermap-server-5af130db6edcc25d89a8f84e55350644ba4797b3.tar.gz trackermap-server-5af130db6edcc25d89a8f84e55350644ba4797b3.tar.bz2 trackermap-server-5af130db6edcc25d89a8f84e55350644ba4797b3.zip |
Merge pull request #3178 from Abyss777/power_and_charge
Organize KEY_POWER and KEY_CHARGE
7 files changed, 16 insertions, 8 deletions
diff --git a/src/org/traccar/protocol/AquilaProtocolDecoder.java b/src/org/traccar/protocol/AquilaProtocolDecoder.java index 30f5667af..5ff974a7d 100644 --- a/src/org/traccar/protocol/AquilaProtocolDecoder.java +++ b/src/org/traccar/protocol/AquilaProtocolDecoder.java @@ -161,7 +161,7 @@ public class AquilaProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_FUEL_LEVEL, parser.nextInt()); position.set(Position.PREFIX_IN + 1, parser.next()); - position.set(Position.KEY_CHARGE, parser.next()); + position.set(Position.KEY_CHARGE, parser.next().equals("1")); position.set(Position.PREFIX_IN + 2, parser.next()); position.set(Position.KEY_IGNITION, parser.nextInt(0) == 1); @@ -176,7 +176,7 @@ public class AquilaProtocolDecoder extends BaseProtocolDecoder { position.setCourse(parser.nextInt(0)); - position.set(Position.KEY_CHARGE, parser.next()); + position.set(Position.KEY_CHARGE, parser.next().equals("1")); 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)); @@ -195,7 +195,7 @@ public class AquilaProtocolDecoder extends BaseProtocolDecoder { 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.KEY_CHARGE, parser.next().equals("1")); 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)); diff --git a/src/org/traccar/protocol/BlackKiteProtocolDecoder.java b/src/org/traccar/protocol/BlackKiteProtocolDecoder.java index 86736c4c9..561d7c18b 100644 --- a/src/org/traccar/protocol/BlackKiteProtocolDecoder.java +++ b/src/org/traccar/protocol/BlackKiteProtocolDecoder.java @@ -125,7 +125,7 @@ public class BlackKiteProtocolDecoder extends BaseProtocolDecoder { if (BitUtil.check(status, 15)) { position.set(Position.KEY_ALARM, Position.ALARM_GENERAL); } - position.set(Position.KEY_POWER, BitUtil.check(status, 2)); + position.set(Position.KEY_CHARGE, BitUtil.check(status, 2)); break; case TAG_DIGITAL_INPUTS: diff --git a/src/org/traccar/protocol/GoSafeProtocolDecoder.java b/src/org/traccar/protocol/GoSafeProtocolDecoder.java index 900e68236..ff4557636 100644 --- a/src/org/traccar/protocol/GoSafeProtocolDecoder.java +++ b/src/org/traccar/protocol/GoSafeProtocolDecoder.java @@ -164,7 +164,7 @@ public class GoSafeProtocolDecoder extends BaseProtocolDecoder { if (parser.hasNext()) { position.set(Position.KEY_ODOMETER, parser.nextInt(0)); } - position.set(Position.KEY_POWER, parser.nextDouble(0)); + position.set(Position.KEY_POWER, parser.nextDouble()); position.set(Position.KEY_BATTERY, parser.nextDouble()); if (parser.hasNext(6)) { diff --git a/src/org/traccar/protocol/IntellitracProtocolDecoder.java b/src/org/traccar/protocol/IntellitracProtocolDecoder.java index daba15a90..8f4e4c0d6 100644 --- a/src/org/traccar/protocol/IntellitracProtocolDecoder.java +++ b/src/org/traccar/protocol/IntellitracProtocolDecoder.java @@ -107,7 +107,7 @@ public class IntellitracProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_FUEL_LEVEL, parser.nextInt(0)); position.set(Position.KEY_FUEL_CONSUMPTION, parser.nextInt(0)); position.set(Position.PREFIX_TEMP + 1, parser.nextInt(0)); - position.set(Position.KEY_CHARGE, parser.nextInt(0)); + position.set("chargerPressure", parser.nextInt(0)); position.set("tpl", parser.nextInt(0)); position.set("axle", parser.nextInt(0)); position.set(Position.KEY_OBD_ODOMETER, parser.nextInt(0)); diff --git a/src/org/traccar/protocol/TrakMateProtocolDecoder.java b/src/org/traccar/protocol/TrakMateProtocolDecoder.java index 18718cda0..8965a18b4 100644 --- a/src/org/traccar/protocol/TrakMateProtocolDecoder.java +++ b/src/org/traccar/protocol/TrakMateProtocolDecoder.java @@ -189,7 +189,7 @@ public class TrakMateProtocolDecoder extends BaseProtocolDecoder { position.set("dop2", parser.next()); position.set(Position.KEY_INPUT, parser.next()); position.set(Position.KEY_BATTERY, parser.nextDouble(0)); - position.set(Position.KEY_POWER, parser.next()); + position.set(Position.KEY_POWER, parser.nextDouble()); position.set(Position.KEY_ODOMETER, parser.nextDouble(0)); position.set("pulseOdometer", parser.next()); position.set(Position.KEY_STATUS, parser.nextInt(0)); diff --git a/src/org/traccar/protocol/VisiontekProtocolDecoder.java b/src/org/traccar/protocol/VisiontekProtocolDecoder.java index c430c86d8..51c4deb7b 100644 --- a/src/org/traccar/protocol/VisiontekProtocolDecoder.java +++ b/src/org/traccar/protocol/VisiontekProtocolDecoder.java @@ -114,7 +114,7 @@ public class VisiontekProtocolDecoder extends BaseProtocolDecoder { 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_CHARGE, parser.next().equals("1")); position.set(Position.KEY_RSSI, parser.next()); } diff --git a/test/org/traccar/ProtocolTest.java b/test/org/traccar/ProtocolTest.java index c9d4ceeb2..a1b14c74d 100644 --- a/test/org/traccar/ProtocolTest.java +++ b/test/org/traccar/ProtocolTest.java @@ -192,6 +192,10 @@ public class ProtocolTest extends BaseTest { Assert.assertTrue(attributes.get(Position.KEY_FUEL_LEVEL) instanceof Number); } + if (attributes.containsKey(Position.KEY_POWER)) { + Assert.assertTrue(attributes.get(Position.KEY_POWER) instanceof Number); + } + if (attributes.containsKey(Position.KEY_BATTERY)) { Assert.assertTrue(attributes.get(Position.KEY_BATTERY) instanceof Number); } @@ -201,6 +205,10 @@ public class ProtocolTest extends BaseTest { Assert.assertTrue(batteryLevel <= 100 && batteryLevel >= 0); } + if (attributes.containsKey(Position.KEY_CHARGE)) { + Assert.assertTrue(attributes.get(Position.KEY_CHARGE) instanceof Boolean); + } + if (position.getNetwork() != null && position.getNetwork().getCellTowers() != null) { for (CellTower cellTower : position.getNetwork().getCellTowers()) { checkInteger(cellTower.getMobileCountryCode(), 0, 999); |