diff options
Diffstat (limited to 'src/org/traccar')
18 files changed, 28 insertions, 29 deletions
diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java index aacf57c33..a259e773a 100644 --- a/src/org/traccar/model/Position.java +++ b/src/org/traccar/model/Position.java @@ -28,7 +28,8 @@ public class Position extends Message { public static final String KEY_EVENT = "event"; public static final String KEY_ALARM = "alarm"; public static final String KEY_STATUS = "status"; - public static final String KEY_ODOMETER = "odometer"; + public static final String KEY_ODOMETER = "odometer"; // meters + public static final String KEY_TRIP_ODOMETER = "tripOdometer"; public static final String KEY_HOURS = "hours"; public static final String KEY_INPUT = "input"; public static final String KEY_OUTPUT = "output"; @@ -48,7 +49,7 @@ public class Position extends Message { public static final String KEY_CHARGE = "charge"; public static final String KEY_IP = "ip"; public static final String KEY_ARCHIVE = "archive"; - public static final String KEY_DISTANCE = "distance"; + public static final String KEY_DISTANCE = "distance"; // meters public static final String KEY_TOTAL_DISTANCE = "totalDistance"; public static final String KEY_RPM = "rpm"; public static final String KEY_VIN = "vin"; diff --git a/src/org/traccar/protocol/AtrackProtocolDecoder.java b/src/org/traccar/protocol/AtrackProtocolDecoder.java index 60d5244a0..cb89f9438 100644 --- a/src/org/traccar/protocol/AtrackProtocolDecoder.java +++ b/src/org/traccar/protocol/AtrackProtocolDecoder.java @@ -227,7 +227,7 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder { position.setCourse(buf.readUnsignedShort()); position.set(Position.KEY_TYPE, buf.readUnsignedByte()); - position.set(Position.KEY_ODOMETER, buf.readUnsignedInt() * 0.1); + position.set(Position.KEY_ODOMETER, buf.readUnsignedInt() * 100); position.set(Position.KEY_HDOP, buf.readUnsignedShort() * 0.1); position.set(Position.KEY_INPUT, buf.readUnsignedByte()); diff --git a/src/org/traccar/protocol/BoxProtocolDecoder.java b/src/org/traccar/protocol/BoxProtocolDecoder.java index f0a90ad97..55d3142b2 100644 --- a/src/org/traccar/protocol/BoxProtocolDecoder.java +++ b/src/org/traccar/protocol/BoxProtocolDecoder.java @@ -92,7 +92,7 @@ public class BoxProtocolDecoder extends BaseProtocolDecoder { position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble())); position.setCourse(parser.nextDouble()); - position.set(Position.KEY_ODOMETER, parser.next()); + position.set(Position.KEY_DISTANCE, parser.nextDouble() * 1000); position.set(Position.KEY_EVENT, parser.next()); int status = parser.nextInt(); diff --git a/src/org/traccar/protocol/DishaProtocolDecoder.java b/src/org/traccar/protocol/DishaProtocolDecoder.java index fb540c8d3..eb00700d8 100644 --- a/src/org/traccar/protocol/DishaProtocolDecoder.java +++ b/src/org/traccar/protocol/DishaProtocolDecoder.java @@ -97,7 +97,7 @@ public class DishaProtocolDecoder extends BaseProtocolDecoder { position.set(Position.PREFIX_ADC + 1, parser.nextInt()); position.set(Position.PREFIX_ADC + 2, parser.nextInt()); - position.set(Position.KEY_ODOMETER, parser.next()); + position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000); position.set(Position.KEY_INPUT, parser.next()); return position; diff --git a/src/org/traccar/protocol/EasyTrackProtocolDecoder.java b/src/org/traccar/protocol/EasyTrackProtocolDecoder.java index 41f395fd9..cec68b967 100644 --- a/src/org/traccar/protocol/EasyTrackProtocolDecoder.java +++ b/src/org/traccar/protocol/EasyTrackProtocolDecoder.java @@ -105,7 +105,7 @@ public class EasyTrackProtocolDecoder extends BaseProtocolDecoder { position.set("signal", parser.next()); position.set(Position.KEY_POWER, parser.nextDouble()); position.set("oil", parser.nextInt(16)); - position.set(Position.KEY_ODOMETER, parser.nextInt(16)); + position.set(Position.KEY_ODOMETER, parser.nextInt(16) * 100); position.setAltitude(parser.nextDouble()); diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java index 148fc6357..385039399 100644 --- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java @@ -308,7 +308,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { parser.skip(4); // alternative networks - position.set(Position.KEY_ODOMETER, parser.next()); + position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000); } private Object decodeObd(Channel channel, SocketAddress remoteAddress, String sentence) { @@ -392,7 +392,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_POWER, power); } - position.set(Position.KEY_ODOMETER, parser.next()); + position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000); position.set(Position.KEY_BATTERY, parser.next()); position.set(Position.KEY_ODOMETER, parser.next()); @@ -446,7 +446,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { decodeLocation(position, parser); position.set(Position.KEY_HOURS, parser.next()); - position.set(Position.KEY_ODOMETER, parser.next()); + position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000); if (parser.hasNext(6)) { DateBuilder dateBuilder = new DateBuilder() @@ -479,7 +479,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { decodeLocation(position, parser); - position.set(Position.KEY_ODOMETER, parser.next()); + position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000); if (parser.hasNext(6)) { DateBuilder dateBuilder = new DateBuilder() @@ -518,7 +518,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_ODOMETER, parser.next()); position.set(Position.KEY_BATTERY, parser.next()); - position.set(Position.KEY_ODOMETER, parser.next()); + position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000); // workaround for wrong location time if (parser.hasNext(6)) { diff --git a/src/org/traccar/protocol/IntellitracProtocolDecoder.java b/src/org/traccar/protocol/IntellitracProtocolDecoder.java index 88c247253..af9f9bbab 100644 --- a/src/org/traccar/protocol/IntellitracProtocolDecoder.java +++ b/src/org/traccar/protocol/IntellitracProtocolDecoder.java @@ -114,7 +114,7 @@ public class IntellitracProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_CHARGE, parser.next()); position.set("tpl", parser.next()); position.set("axle", parser.next()); - position.set(Position.KEY_ODOMETER, parser.next()); + position.set(Position.KEY_OBD_ODOMETER, parser.next()); return position; } diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java index 372b4cac1..b7193d24b 100644 --- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java +++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java @@ -110,7 +110,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { int fuel = buf.readUnsignedByte() << 8; position.set(Position.KEY_STATUS, buf.readUnsignedInt()); - position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); + position.set(Position.KEY_ODOMETER, buf.readUnsignedInt() * 1000); fuel += buf.readUnsignedByte(); position.set(Position.KEY_FUEL, fuel); diff --git a/src/org/traccar/protocol/MegastekProtocolDecoder.java b/src/org/traccar/protocol/MegastekProtocolDecoder.java index d20532faa..71aae6ca3 100644 --- a/src/org/traccar/protocol/MegastekProtocolDecoder.java +++ b/src/org/traccar/protocol/MegastekProtocolDecoder.java @@ -305,7 +305,7 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder { position.setCourse(parser.nextDouble()); position.setAltitude(parser.nextDouble()); - position.set(Position.KEY_ODOMETER, parser.nextDouble()); + position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000); position.set(Position.KEY_MCC, parser.nextInt()); position.set(Position.KEY_MNC, parser.nextInt()); position.set(Position.KEY_LAC, parser.nextInt(16)); diff --git a/src/org/traccar/protocol/Mta6ProtocolDecoder.java b/src/org/traccar/protocol/Mta6ProtocolDecoder.java index b6aea9092..1da55f715 100644 --- a/src/org/traccar/protocol/Mta6ProtocolDecoder.java +++ b/src/org/traccar/protocol/Mta6ProtocolDecoder.java @@ -155,7 +155,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder { } if (BitUtil.check(flags, 3)) { - position.set(Position.KEY_ODOMETER, buf.readUnsignedShort()); + position.set(Position.KEY_ODOMETER, buf.readUnsignedShort() * 1000); } if (BitUtil.check(flags, 4)) { diff --git a/src/org/traccar/protocol/NavisProtocolDecoder.java b/src/org/traccar/protocol/NavisProtocolDecoder.java index 72c5f53c3..03e578fe9 100644 --- a/src/org/traccar/protocol/NavisProtocolDecoder.java +++ b/src/org/traccar/protocol/NavisProtocolDecoder.java @@ -147,9 +147,8 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder { position.setSpeed(buf.readFloat()); position.setCourse(buf.readUnsignedShort()); - position.set(Position.KEY_ODOMETER, buf.readFloat()); - - position.set("segment", buf.readFloat()); // last segment + position.set(Position.KEY_ODOMETER, buf.readFloat() * 1000); + position.set(Position.KEY_DISTANCE, buf.readFloat()); // Segment times buf.readUnsignedShort(); diff --git a/src/org/traccar/protocol/Pt502ProtocolDecoder.java b/src/org/traccar/protocol/Pt502ProtocolDecoder.java index 1436eb5ac..d925e1b4d 100644 --- a/src/org/traccar/protocol/Pt502ProtocolDecoder.java +++ b/src/org/traccar/protocol/Pt502ProtocolDecoder.java @@ -106,7 +106,7 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder { }
}
- position.set(Position.KEY_ODOMETER, parser.next());
+ position.set(Position.KEY_ODOMETER, parser.nextInt());
position.set(Position.KEY_RFID, parser.next());
if (parser.hasNext()) {
diff --git a/src/org/traccar/protocol/RitiProtocolDecoder.java b/src/org/traccar/protocol/RitiProtocolDecoder.java index bf041554f..455c1387a 100644 --- a/src/org/traccar/protocol/RitiProtocolDecoder.java +++ b/src/org/traccar/protocol/RitiProtocolDecoder.java @@ -73,8 +73,8 @@ public class RitiProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedShort(); buf.readUnsignedShort(); - position.set("distance", buf.readUnsignedInt()); - position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); + position.set(Position.KEY_DISTANCE, buf.readUnsignedInt()); + position.set(Position.KEY_TRIP_ODOMETER, buf.readUnsignedInt()); // Parse GPRMC int end = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '*'); diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java index 72c0f6306..e7a689a8b 100644 --- a/src/org/traccar/protocol/TotemProtocolDecoder.java +++ b/src/org/traccar/protocol/TotemProtocolDecoder.java @@ -252,7 +252,7 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { } position.set(Position.PREFIX_TEMP + 1, parser.next()); - position.set(Position.KEY_ODOMETER, parser.next()); + position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000); } else if (pattern == PATTERN3) { if (parser.hasNext()) { @@ -314,7 +314,7 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble())); position.set(Position.KEY_HDOP, parser.nextDouble()); - position.set(Position.KEY_ODOMETER, parser.nextInt()); + position.set(Position.KEY_ODOMETER, parser.nextInt() * 1000); position.setValid(true); position.setLatitude(parser.nextCoordinate()); diff --git a/src/org/traccar/protocol/TytanProtocolDecoder.java b/src/org/traccar/protocol/TytanProtocolDecoder.java index 2733a568b..7b5dc5ffe 100644 --- a/src/org/traccar/protocol/TytanProtocolDecoder.java +++ b/src/org/traccar/protocol/TytanProtocolDecoder.java @@ -49,7 +49,7 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder { switch (type) { case 2: - position.set(Position.KEY_ODOMETER, buf.readUnsignedMedium()); + position.set(Position.KEY_TRIP_ODOMETER, buf.readUnsignedMedium()); break; case 5: position.set(Position.KEY_INPUT, buf.readUnsignedByte()); diff --git a/src/org/traccar/protocol/WondexProtocolDecoder.java b/src/org/traccar/protocol/WondexProtocolDecoder.java index d048b9b31..97426d78c 100644 --- a/src/org/traccar/protocol/WondexProtocolDecoder.java +++ b/src/org/traccar/protocol/WondexProtocolDecoder.java @@ -115,7 +115,7 @@ public class WondexProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_EVENT, parser.next()); position.set(Position.KEY_BATTERY, parser.next()); - position.set(Position.KEY_ODOMETER, parser.next()); + position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000); position.set(Position.KEY_INPUT, parser.next()); position.set(Position.PREFIX_ADC + 1, parser.next()); position.set(Position.PREFIX_ADC + 2, parser.next()); diff --git a/src/org/traccar/protocol/XirgoProtocolDecoder.java b/src/org/traccar/protocol/XirgoProtocolDecoder.java index df5665992..830caf6d9 100644 --- a/src/org/traccar/protocol/XirgoProtocolDecoder.java +++ b/src/org/traccar/protocol/XirgoProtocolDecoder.java @@ -133,7 +133,7 @@ public class XirgoProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_HDOP, parser.next()); if (newFormat) { - position.set(Position.KEY_ODOMETER, parser.next()); + position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1609.34); position.set(Position.KEY_FUEL_CONSUMPTION, parser.next()); } @@ -141,7 +141,7 @@ public class XirgoProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_GSM, parser.next()); if (!newFormat) { - position.set(Position.KEY_ODOMETER, parser.next()); + position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1609.34); } position.setValid(parser.nextInt() == 1); diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java index 34f04ac87..67d577904 100644 --- a/src/org/traccar/reports/ReportUtils.java +++ b/src/org/traccar/reports/ReportUtils.java @@ -48,8 +48,7 @@ public final class ReportUtils { if (useOdometer && firstPosition.getAttributes().containsKey(Position.KEY_ODOMETER) && lastPosition.getAttributes().containsKey(Position.KEY_ODOMETER)) { distance = (((Number) lastPosition.getAttributes().get(Position.KEY_ODOMETER)).doubleValue() - - ((Number) firstPosition.getAttributes().get(Position.KEY_ODOMETER)).doubleValue()) - * 1000; + - ((Number) firstPosition.getAttributes().get(Position.KEY_ODOMETER)).doubleValue()); } else if (firstPosition.getAttributes().containsKey(Position.KEY_TOTAL_DISTANCE) && lastPosition.getAttributes().containsKey(Position.KEY_TOTAL_DISTANCE)) { distance = ((Number) lastPosition.getAttributes().get(Position.KEY_TOTAL_DISTANCE)).doubleValue() |