From 9e758d437c048b954d224935664b76d6f6f8416c Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Fri, 19 May 2017 14:41:23 +0500 Subject: Adjust battery and batteryLevel type --- src/org/traccar/protocol/WondexProtocolDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/org/traccar/protocol/WondexProtocolDecoder.java') diff --git a/src/org/traccar/protocol/WondexProtocolDecoder.java b/src/org/traccar/protocol/WondexProtocolDecoder.java index b1b06a5da..d490fbfb0 100644 --- a/src/org/traccar/protocol/WondexProtocolDecoder.java +++ b/src/org/traccar/protocol/WondexProtocolDecoder.java @@ -110,7 +110,7 @@ public class WondexProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_SATELLITES, satellites); position.set(Position.KEY_EVENT, parser.next()); - position.set(Position.KEY_BATTERY, parser.next()); + position.set(Position.KEY_BATTERY, parser.nextDouble(0)); if (parser.hasNext()) { position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1000); } -- cgit v1.2.3 From ab46ebf23066f91369b0d037f273bed1ea814d82 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Fri, 19 May 2017 16:31:55 +0500 Subject: Fixed optional values --- src/org/traccar/protocol/Gl200ProtocolDecoder.java | 10 ++++------ src/org/traccar/protocol/GoSafeProtocolDecoder.java | 2 +- src/org/traccar/protocol/T55ProtocolDecoder.java | 2 +- src/org/traccar/protocol/WondexProtocolDecoder.java | 2 +- test/org/traccar/ProtocolTest.java | 5 ++--- 5 files changed, 9 insertions(+), 12 deletions(-) (limited to 'src/org/traccar/protocol/WondexProtocolDecoder.java') diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java index 081048a40..7e76fd6c9 100644 --- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java @@ -399,9 +399,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_BATTERY, parser.nextDouble(0)); position.set(Position.KEY_CHARGE, parser.nextInt(0) == 1); - if (parser.hasNext()) { - position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt(0)); - } + position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt()); position.set(Position.PREFIX_TEMP + 1, parser.next()); @@ -546,13 +544,13 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { } position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1000); - position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt(0)); + position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt()); position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1000); position.set(Position.KEY_HOURS, parser.next()); position.set(Position.PREFIX_ADC + 1, parser.next()); position.set(Position.PREFIX_ADC + 2, parser.next()); - position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt(0)); + position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt()); decodeStatus(position, parser); @@ -599,7 +597,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_HOURS, parser.next()); position.set(Position.PREFIX_ADC + 1, parser.next()); position.set(Position.PREFIX_ADC + 2, parser.next()); - position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt(0)); + position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt()); decodeStatus(position, parser); diff --git a/src/org/traccar/protocol/GoSafeProtocolDecoder.java b/src/org/traccar/protocol/GoSafeProtocolDecoder.java index 604dcad32..900e68236 100644 --- a/src/org/traccar/protocol/GoSafeProtocolDecoder.java +++ b/src/org/traccar/protocol/GoSafeProtocolDecoder.java @@ -165,7 +165,7 @@ public class GoSafeProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_ODOMETER, parser.nextInt(0)); } position.set(Position.KEY_POWER, parser.nextDouble(0)); - position.set(Position.KEY_BATTERY, parser.nextDouble(0)); + position.set(Position.KEY_BATTERY, parser.nextDouble()); if (parser.hasNext(6)) { long status = parser.nextLong(16, 0); diff --git a/src/org/traccar/protocol/T55ProtocolDecoder.java b/src/org/traccar/protocol/T55ProtocolDecoder.java index f1a03ed44..82766cc60 100644 --- a/src/org/traccar/protocol/T55ProtocolDecoder.java +++ b/src/org/traccar/protocol/T55ProtocolDecoder.java @@ -137,7 +137,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_IGNITION, parser.hasNext() && parser.next().equals("1")); position.set(Position.KEY_FUEL_LEVEL, parser.nextInt(0)); - position.set(Position.KEY_BATTERY, parser.nextInt(0)); + position.set(Position.KEY_BATTERY, parser.nextInt()); } if (parser.hasNext()) { diff --git a/src/org/traccar/protocol/WondexProtocolDecoder.java b/src/org/traccar/protocol/WondexProtocolDecoder.java index d490fbfb0..dc334becc 100644 --- a/src/org/traccar/protocol/WondexProtocolDecoder.java +++ b/src/org/traccar/protocol/WondexProtocolDecoder.java @@ -110,7 +110,7 @@ public class WondexProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_SATELLITES, satellites); position.set(Position.KEY_EVENT, parser.next()); - position.set(Position.KEY_BATTERY, parser.nextDouble(0)); + position.set(Position.KEY_BATTERY, parser.nextDouble()); if (parser.hasNext()) { position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1000); } diff --git a/test/org/traccar/ProtocolTest.java b/test/org/traccar/ProtocolTest.java index 94c5edb9f..c9d4ceeb2 100644 --- a/test/org/traccar/ProtocolTest.java +++ b/test/org/traccar/ProtocolTest.java @@ -197,9 +197,8 @@ public class ProtocolTest extends BaseTest { } if (attributes.containsKey(Position.KEY_BATTERY_LEVEL)) { - Object batteryLevel = attributes.get(Position.KEY_BATTERY_LEVEL); - Assert.assertTrue(batteryLevel instanceof Number); - Assert.assertTrue(((Number) batteryLevel).intValue() <=100 && ((Number) batteryLevel).intValue() >= 0); + int batteryLevel = ((Number) attributes.get(Position.KEY_BATTERY_LEVEL)).intValue(); + Assert.assertTrue(batteryLevel <= 100 && batteryLevel >= 0); } if (position.getNetwork() != null && position.getNetwork().getCellTowers() != null) { -- cgit v1.2.3