diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-03-08 19:14:23 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-08 19:14:23 +1300 |
commit | e3a3f06cc07bc5d75d3d670e045abb5d6c91fcad (patch) | |
tree | ee424dc1b6b86abb54abcc5fe4f2068ac0cbf286 /src/org/traccar | |
parent | b7e53f57689e1f8a1c0705aeea32dc6e69f3fcb3 (diff) | |
parent | f94613b97cf80af64154ae571920a273771fa1d3 (diff) | |
download | trackermap-server-e3a3f06cc07bc5d75d3d670e045abb5d6c91fcad.tar.gz trackermap-server-e3a3f06cc07bc5d75d3d670e045abb5d6c91fcad.tar.bz2 trackermap-server-e3a3f06cc07bc5d75d3d670e045abb5d6c91fcad.zip |
Merge pull request #2979 from jon-stumpf/jss-add-info
Additional Protocol Information
Diffstat (limited to 'src/org/traccar')
53 files changed, 201 insertions, 185 deletions
diff --git a/src/org/traccar/helper/ObdDecoder.java b/src/org/traccar/helper/ObdDecoder.java index aea23ca60..f2c269f47 100644 --- a/src/org/traccar/helper/ObdDecoder.java +++ b/src/org/traccar/helper/ObdDecoder.java @@ -99,7 +99,7 @@ public final class ObdDecoder { case PID_MIL_DISTANCE: return createEntry("milDistance", value); case PID_FUEL_LEVEL: - return createEntry(Position.KEY_FUEL, convert ? value * 100 / 255 : value); + return createEntry(Position.KEY_FUEL_LEVEL, convert ? value * 100 / 255 : value); case PID_DISTANCE_CLEARED: return createEntry("clearedDistance", value); default: diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java index 96dc1d2ad..82b7e03ce 100644 --- a/src/org/traccar/model/Position.java +++ b/src/org/traccar/model/Position.java @@ -31,15 +31,20 @@ 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"; // meters - public static final String KEY_TRIP_ODOMETER = "tripOdometer"; + public static final String KEY_ODOMETER = "odometer"; // meters + public static final String KEY_ODOMETER_SERVICE = "serviceOdometer"; // meters + public static final String KEY_ODOMETER_TRIP = "tripOdometer"; // meters public static final String KEY_HOURS = "hours"; public static final String KEY_INPUT = "input"; public static final String KEY_OUTPUT = "output"; - public static final String KEY_POWER = "power"; - public static final String KEY_BATTERY = "battery"; - public static final String KEY_FUEL = "fuel"; - public static final String KEY_FUEL_CONSUMPTION = "fuelConsumption"; + + // The units for the below four KEYs currently vary. + // The preferred units of measure are specified in the comment for each. + public static final String KEY_POWER = "power"; // volts + public static final String KEY_BATTERY = "battery"; // volts (or percentage appending '%') + public static final String KEY_FUEL_LEVEL = "fuel"; // liters + public static final String KEY_FUEL_CONSUMPTION = "fuelConsumption"; // liters/hour + public static final String KEY_RFID = "rfid"; public static final String KEY_VERSION_FW = "versionFw"; public static final String KEY_VERSION_HW = "versionHw"; @@ -49,22 +54,23 @@ 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"; // meters - public static final String KEY_TOTAL_DISTANCE = "totalDistance"; + public static final String KEY_DISTANCE = "distance"; // meters + public static final String KEY_TOTAL_DISTANCE = "totalDistance"; // meters public static final String KEY_RPM = "rpm"; public static final String KEY_VIN = "vin"; public static final String KEY_APPROXIMATE = "approximate"; public static final String KEY_THROTTLE = "throttle"; public static final String KEY_MOTION = "motion"; public static final String KEY_ARMED = "armed"; - public static final String KEY_ACCURACY = "accuracy"; public static final String KEY_GEOFENCE = "geofence"; public static final String KEY_ACCELERATION = "acceleration"; - public static final String KEY_DEVICE_TEMP = "deviceTemp"; + public static final String KEY_DEVICE_TEMP = "deviceTemp"; // celsius + public static final String KEY_OPERATOR = "operator"; + public static final String KEY_COMMAND = "command"; public static final String KEY_DTCS = "dtcs"; - public static final String KEY_OBD_SPEED = "obdSpeed"; - public static final String KEY_OBD_ODOMETER = "obdOdometer"; + public static final String KEY_OBD_SPEED = "obdSpeed"; // knots + public static final String KEY_OBD_ODOMETER = "obdOdometer"; // meters public static final String KEY_RESULT = "result"; @@ -215,7 +221,7 @@ public class Position extends Message { this.longitude = longitude; } - private double altitude; + private double altitude; // value in meters public double getAltitude() { return altitude; diff --git a/src/org/traccar/protocol/AdmProtocolDecoder.java b/src/org/traccar/protocol/AdmProtocolDecoder.java index 72a6e5bce..f4a21cad0 100644 --- a/src/org/traccar/protocol/AdmProtocolDecoder.java +++ b/src/org/traccar/protocol/AdmProtocolDecoder.java @@ -66,7 +66,7 @@ public class AdmProtocolDecoder extends BaseProtocolDecoder { position.setProtocol(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); - buf.readUnsignedByte(); // firmware version + position.set(Position.KEY_VERSION_FW, buf.readUnsignedByte()); buf.readUnsignedShort(); // index position.set(Position.KEY_STATUS, buf.readUnsignedShort()); @@ -77,7 +77,7 @@ public class AdmProtocolDecoder extends BaseProtocolDecoder { position.setCourse(buf.readUnsignedShort() * 0.1); position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShort() * 0.1)); - buf.readUnsignedByte(); // acceleration + position.set(Position.KEY_ACCELERATION, buf.readUnsignedByte()); position.setAltitude(buf.readUnsignedShort()); diff --git a/src/org/traccar/protocol/AplicomProtocolDecoder.java b/src/org/traccar/protocol/AplicomProtocolDecoder.java index fbd868b86..c07a656b3 100644 --- a/src/org/traccar/protocol/AplicomProtocolDecoder.java +++ b/src/org/traccar/protocol/AplicomProtocolDecoder.java @@ -120,7 +120,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { private void decodeCanData(ChannelBuffer buf, Position position) { buf.readUnsignedMedium(); // packet identifier - buf.readUnsignedByte(); // version + position.set(Position.KEY_VERSION_FW, buf.readUnsignedByte()); int count = buf.readUnsignedByte(); buf.readUnsignedByte(); // batch count buf.readUnsignedShort(); // selector bit @@ -213,12 +213,12 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { position.setTime(new Date(buf.readUnsignedInt() * 1000)); position.setLatitude(buf.readInt() / 1000000.0); position.setLongitude(buf.readInt() / 1000000.0); - position.set(Position.KEY_SATELLITES, buf.readUnsignedByte()); + position.set(Position.KEY_SATELLITES_VISIBLE, buf.readUnsignedByte()); } if ((selector & 0x0010) != 0) { position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte())); - buf.readUnsignedByte(); // maximum speed + position.set("maximumSpeed", buf.readUnsignedByte()); position.setCourse(buf.readUnsignedByte() * 2.0); } @@ -234,8 +234,8 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { } if ((selector & 0x8000) != 0) { - position.set(Position.KEY_POWER, buf.readUnsignedShort() / 1000.0); - position.set(Position.KEY_BATTERY, buf.readUnsignedShort()); + position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.001); + position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.001); } // Pulse rate 1 @@ -332,7 +332,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { } if ((selector & 0x0100) != 0) { - position.set(Position.KEY_TRIP_ODOMETER, buf.readUnsignedInt() * 5); + position.set(Position.KEY_ODOMETER_TRIP, buf.readUnsignedInt() * 5); } if ((selector & 0x8000) != 0) { @@ -436,14 +436,14 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { return; } - buf.readUnsignedByte(); // version - buf.readUnsignedShort(); // event - buf.readUnsignedByte(); // data validity - buf.readUnsignedByte(); // towed + position.set(Position.KEY_VERSION_FW, buf.readUnsignedByte()); + position.set(Position.KEY_EVENT, buf.readUnsignedShort()); + position.set("dataValidity", buf.readUnsignedByte()); + position.set("towed", buf.readUnsignedByte()); buf.readUnsignedShort(); // length while (buf.readableBytes() > 0) { - buf.readUnsignedByte(); // towed position + position.set("towedPosition", buf.readUnsignedByte()); int type = buf.readUnsignedByte(); int length = buf.readUnsignedByte(); @@ -463,9 +463,9 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { position.set("brakeLining", buf.readUnsignedByte() * 0.4); position.set("brakeTemperature", buf.readUnsignedByte() * 10); } else if (type == 0x06) { - position.set("totalDistance", buf.readUnsignedInt() * 5); - position.set("tripDistance", buf.readUnsignedInt() * 5); - position.set("serviceDistance", (buf.readUnsignedInt() - 2105540607) * 5); + position.set(Position.KEY_ODOMETER, buf.readUnsignedInt() * 5); + position.set(Position.KEY_ODOMETER_TRIP, buf.readUnsignedInt() * 5); + position.set(Position.KEY_ODOMETER_SERVICE, (buf.readUnsignedInt() - 2105540607) * 5); } else if (type == 0x0A) { ChannelBuffer brakeData = buf.readBytes(length); position.set("absStatusCounter", brakeData.readUnsignedShort()); @@ -526,9 +526,9 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { if ((selector & 0x0020) != 0) { position.set(Position.KEY_HOURS, buf.readUnsignedInt()); position.set("serviceDistance", buf.readInt()); - buf.readUnsignedByte(); // driver activity + position.set("driverActivity", buf.readUnsignedByte()); position.set(Position.KEY_THROTTLE, buf.readUnsignedByte()); - position.set(Position.KEY_FUEL, buf.readUnsignedByte()); + position.set(Position.KEY_FUEL_LEVEL, buf.readUnsignedByte()); } if ((selector & 0x0040) != 0) { @@ -547,10 +547,10 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { } if ((selector & 0x0200) != 0) { - buf.readUnsignedByte(); // tachograph based speed - buf.readUnsignedByte(); // driver 1 state - buf.readUnsignedByte(); // driver 2 state - buf.readUnsignedByte(); // tachograph status + position.set("tachographSpeed", buf.readUnsignedByte()); + position.set("driver1State", buf.readUnsignedByte()); + position.set("driver2State", buf.readUnsignedByte()); + position.set("tachographStatus", buf.readUnsignedByte()); position.set("overspeedCount", buf.readUnsignedByte()); } diff --git a/src/org/traccar/protocol/AquilaProtocolDecoder.java b/src/org/traccar/protocol/AquilaProtocolDecoder.java index 11ab15c86..2bc3b3a09 100644 --- a/src/org/traccar/protocol/AquilaProtocolDecoder.java +++ b/src/org/traccar/protocol/AquilaProtocolDecoder.java @@ -136,7 +136,7 @@ public class AquilaProtocolDecoder extends BaseProtocolDecoder { if (parser.hasNext(9)) { - position.set(Position.KEY_FUEL, parser.next()); + position.set(Position.KEY_FUEL_LEVEL, parser.next()); position.set(Position.PREFIX_IO + 1, parser.next()); position.set(Position.KEY_CHARGE, parser.next()); position.set(Position.PREFIX_IO + 2, parser.next()); diff --git a/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java b/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java index 214ccfae2..24c155c84 100644 --- a/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java +++ b/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java @@ -70,7 +70,7 @@ public class ArknavX8ProtocolDecoder extends BaseProtocolDecoder { position.setProtocol(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); - parser.next(); // type + position.set(Position.KEY_TYPE, parser.next()); DateBuilder dateBuilder = new DateBuilder() .setDate(parser.nextInt(), parser.nextInt(), parser.nextInt()) diff --git a/src/org/traccar/protocol/AstraProtocolDecoder.java b/src/org/traccar/protocol/AstraProtocolDecoder.java index 71f2080bb..ea6aa7b30 100644 --- a/src/org/traccar/protocol/AstraProtocolDecoder.java +++ b/src/org/traccar/protocol/AstraProtocolDecoder.java @@ -93,7 +93,7 @@ public class AstraProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // max journey speed buf.skipBytes(6); // accelerometer - buf.readUnsignedShort(); // journey distance + position.set(Position.KEY_ODOMETER_TRIP, buf.readUnsignedShort()); buf.readUnsignedShort(); // journey idle time position.setAltitude(buf.readUnsignedByte() * 20); @@ -105,12 +105,9 @@ public class AstraProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // geofence events if (BitUtil.check(status, 8)) { - position.set(Position.KEY_RFID, buf.readBytes(7).toString(StandardCharsets.US_ASCII)); position.set(Position.KEY_ODOMETER, buf.readUnsignedMedium() * 1000); - - buf.readUnsignedShort(); // engine time - + position.set(Position.KEY_HOURS, buf.readUnsignedShort()); } if (BitUtil.check(status, 6)) { diff --git a/src/org/traccar/protocol/At2000ProtocolDecoder.java b/src/org/traccar/protocol/At2000ProtocolDecoder.java index 182066629..70840c37d 100644 --- a/src/org/traccar/protocol/At2000ProtocolDecoder.java +++ b/src/org/traccar/protocol/At2000ProtocolDecoder.java @@ -140,7 +140,7 @@ public class At2000ProtocolDecoder extends BaseProtocolDecoder { position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort()); position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort()); - position.set(Position.KEY_POWER, buf.readUnsignedShort() + "mV"); + position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.001); buf.readUnsignedShort(); // cid position.set(Position.KEY_RSSI, buf.readUnsignedByte()); diff --git a/src/org/traccar/protocol/AtrackProtocolDecoder.java b/src/org/traccar/protocol/AtrackProtocolDecoder.java index c4b9d512e..bbc7c4479 100644 --- a/src/org/traccar/protocol/AtrackProtocolDecoder.java +++ b/src/org/traccar/protocol/AtrackProtocolDecoder.java @@ -113,7 +113,7 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // rxlev break; case "PC": - buf.readUnsignedInt(); // pulse count + position.set(Position.PREFIX_COUNT + 1, buf.readUnsignedInt()); break; case "AT": position.setAltitude(buf.readUnsignedInt()); @@ -122,7 +122,7 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_RPM, buf.readUnsignedShort()); break; case "GS": - buf.readUnsignedByte(); // gsm status + position.set(Position.KEY_RSSI, buf.readUnsignedByte()); break; case "DT": position.set(Position.KEY_ARCHIVE, buf.readUnsignedByte() == 1); @@ -140,16 +140,16 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_THROTTLE, buf.readUnsignedByte()); break; case "ET": - buf.readUnsignedShort(); // engine coolant temp + position.set(Position.PREFIX_TEMP + 1, buf.readUnsignedShort()); break; case "FL": - position.set(Position.KEY_FUEL, buf.readUnsignedByte()); + position.set(Position.KEY_FUEL_LEVEL, buf.readUnsignedByte()); break; case "ML": buf.readUnsignedByte(); // mil status break; case "FC": - buf.readUnsignedInt(); // fuel used + position.set(Position.KEY_FUEL_CONSUMPTION, buf.readUnsignedInt()); break; case "CI": readString(buf); // format string diff --git a/src/org/traccar/protocol/AutoFonProtocolDecoder.java b/src/org/traccar/protocol/AutoFonProtocolDecoder.java index 1087c8c43..32b4bfa74 100644 --- a/src/org/traccar/protocol/AutoFonProtocolDecoder.java +++ b/src/org/traccar/protocol/AutoFonProtocolDecoder.java @@ -70,7 +70,7 @@ public class AutoFonProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // interval buf.skipBytes(8); // settings } - buf.readUnsignedByte(); // status + position.set(Position.KEY_STATUS, buf.readUnsignedByte()); if (!history) { buf.readUnsignedShort(); } diff --git a/src/org/traccar/protocol/BoxProtocolDecoder.java b/src/org/traccar/protocol/BoxProtocolDecoder.java index b1fe55e5e..e4dcd6ad7 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_DISTANCE, parser.nextDouble() * 1000); + position.set(Position.KEY_ODOMETER_TRIP, parser.nextDouble() * 1000); position.set(Position.KEY_EVENT, parser.next()); int status = parser.nextInt(); diff --git a/src/org/traccar/protocol/CarTrackProtocolDecoder.java b/src/org/traccar/protocol/CarTrackProtocolDecoder.java index 94f5d208b..0952a0978 100644 --- a/src/org/traccar/protocol/CarTrackProtocolDecoder.java +++ b/src/org/traccar/protocol/CarTrackProtocolDecoder.java @@ -74,7 +74,7 @@ public class CarTrackProtocolDecoder extends BaseProtocolDecoder { } position.setDeviceId(deviceSession.getDeviceId()); - position.set("command", parser.next()); + position.set(Position.KEY_COMMAND, parser.next()); DateBuilder dateBuilder = new DateBuilder() .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt(), parser.nextInt()); diff --git a/src/org/traccar/protocol/CarcellProtocolDecoder.java b/src/org/traccar/protocol/CarcellProtocolDecoder.java index 615115147..b41f14ad5 100644 --- a/src/org/traccar/protocol/CarcellProtocolDecoder.java +++ b/src/org/traccar/protocol/CarcellProtocolDecoder.java @@ -127,7 +127,7 @@ public class CarcellProtocolDecoder extends BaseProtocolDecoder { position.set("jamming", parser.next().equals("1")); position.set(Position.KEY_GPS, parser.nextInt()); - parser.next(); // clock type + position.set("clockType", parser.next()); DateBuilder dateBuilder = new DateBuilder(). setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt()) @@ -155,7 +155,7 @@ public class CarcellProtocolDecoder extends BaseProtocolDecoder { if (parser.hasNext(5)) { position.set("timeUntilDelivery", parser.nextInt()); parser.next(); // panic button status - parser.next(); // aux + position.set(Position.KEY_INPUT, parser.next()); Double mainVoltage = parser.nextDouble() / 100d; position.set(Position.KEY_POWER, mainVoltage); diff --git a/src/org/traccar/protocol/CastelProtocolDecoder.java b/src/org/traccar/protocol/CastelProtocolDecoder.java index 07d26f2b1..83664fa5a 100644 --- a/src/org/traccar/protocol/CastelProtocolDecoder.java +++ b/src/org/traccar/protocol/CastelProtocolDecoder.java @@ -178,8 +178,8 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedInt(); // ACC ON time buf.readUnsignedInt(); // UTC time position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); - buf.readUnsignedInt(); // trip odometer - buf.readUnsignedInt(); // total fuel consumption + position.set(Position.KEY_ODOMETER_TRIP, buf.readUnsignedInt()); + position.set(Position.KEY_FUEL_CONSUMPTION, buf.readUnsignedInt()); buf.readUnsignedShort(); // current fuel consumption position.set(Position.KEY_STATUS, buf.readUnsignedInt()); buf.skipBytes(8); @@ -263,8 +263,8 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedInt(); // ACC ON time buf.readUnsignedInt(); // UTC time long odometer = buf.readUnsignedInt(); - buf.readUnsignedInt(); // trip odometer - buf.readUnsignedInt(); // total fuel consumption + long tripOdometer = buf.readUnsignedInt(); + long fuelConsumption = buf.readUnsignedInt(); buf.readUnsignedShort(); // current fuel consumption long status = buf.readUnsignedInt(); buf.skipBytes(8); @@ -276,6 +276,8 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder { for (int i = 0; i < count; i++) { Position position = readPosition(deviceSession, buf); position.set(Position.KEY_ODOMETER, odometer); + position.set(Position.KEY_ODOMETER_TRIP, tripOdometer); + position.set(Position.KEY_FUEL_CONSUMPTION, fuelConsumption); position.set(Position.KEY_STATUS, status); positions.add(position); } diff --git a/src/org/traccar/protocol/CellocatorProtocolDecoder.java b/src/org/traccar/protocol/CellocatorProtocolDecoder.java index 655fadfbd..2b4fa9fb6 100644 --- a/src/org/traccar/protocol/CellocatorProtocolDecoder.java +++ b/src/org/traccar/protocol/CellocatorProtocolDecoder.java @@ -109,9 +109,9 @@ public class CellocatorProtocolDecoder extends BaseProtocolDecoder { } position.setDeviceId(deviceSession.getDeviceId()); - buf.readUnsignedByte(); // hardware version - buf.readUnsignedByte(); // software version - buf.readUnsignedByte(); // protocol version + position.set(Position.KEY_VERSION_HW, buf.readUnsignedByte()); + position.set(Position.KEY_VERSION_FW, buf.readUnsignedByte()); + position.set("protocolVersion", buf.readUnsignedByte()); position.set(Position.KEY_STATUS, buf.getUnsignedByte(buf.readerIndex()) & 0x0f); @@ -121,21 +121,21 @@ public class CellocatorProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // reason data position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte())); - buf.readUnsignedByte(); // mode - buf.readUnsignedInt(); // io + position.set("mode", buf.readUnsignedByte()); + position.set(Position.PREFIX_IO + 1, buf.readUnsignedInt()); operator <<= 8; operator += buf.readUnsignedByte(); - position.set("operator", operator); + position.set(Position.KEY_OPERATOR, operator); - buf.readUnsignedInt(); // adc - buf.readUnsignedMedium(); // odometer + position.set(Position.PREFIX_ADC + 1, buf.readUnsignedInt()); + position.set(Position.KEY_ODOMETER, buf.readUnsignedMedium()); buf.skipBytes(6); // multi-purpose data - buf.readUnsignedShort(); // gps fix - buf.readUnsignedByte(); // location status - buf.readUnsignedByte(); // mode 1 - buf.readUnsignedByte(); // mode 2 + position.set(Position.KEY_GPS, buf.readUnsignedShort()); + position.set("locationStatus", buf.readUnsignedByte()); + position.set("mode1", buf.readUnsignedByte()); + position.set("mode2", buf.readUnsignedByte()); position.set(Position.KEY_SATELLITES, buf.readUnsignedByte()); diff --git a/src/org/traccar/protocol/EasyTrackProtocolDecoder.java b/src/org/traccar/protocol/EasyTrackProtocolDecoder.java index 688629063..c4baad5ab 100644 --- a/src/org/traccar/protocol/EasyTrackProtocolDecoder.java +++ b/src/org/traccar/protocol/EasyTrackProtocolDecoder.java @@ -77,7 +77,7 @@ public class EasyTrackProtocolDecoder extends BaseProtocolDecoder { } position.setDeviceId(deviceSession.getDeviceId()); - position.set("command", parser.next()); + position.set(Position.KEY_COMMAND, parser.next()); position.setValid(parser.next().equals("A")); diff --git a/src/org/traccar/protocol/EelinkProtocolDecoder.java b/src/org/traccar/protocol/EelinkProtocolDecoder.java index 4b77b1ff6..0f6551cc3 100644 --- a/src/org/traccar/protocol/EelinkProtocolDecoder.java +++ b/src/org/traccar/protocol/EelinkProtocolDecoder.java @@ -130,9 +130,9 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder { } position.set(Position.KEY_STATUS, status); - position.set(Position.KEY_BATTERY, buf.readUnsignedShort() + "mV"); + position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.001); - buf.readUnsignedShort(); // signal strength + position.set(Position.KEY_RSSI, buf.readUnsignedShort()); position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort()); position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShort()); diff --git a/src/org/traccar/protocol/FifotrackProtocolDecoder.java b/src/org/traccar/protocol/FifotrackProtocolDecoder.java index 9ccc34384..995722fa7 100644 --- a/src/org/traccar/protocol/FifotrackProtocolDecoder.java +++ b/src/org/traccar/protocol/FifotrackProtocolDecoder.java @@ -83,7 +83,7 @@ public class FifotrackProtocolDecoder extends BaseProtocolDecoder { position.setProtocol(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); - parser.next(); // alarm + position.set(Position.KEY_ALARM, parser.next()); DateBuilder dateBuilder = new DateBuilder() .setDate(parser.nextInt(), parser.nextInt(), parser.nextInt()) diff --git a/src/org/traccar/protocol/FoxProtocolDecoder.java b/src/org/traccar/protocol/FoxProtocolDecoder.java index cf1e4f1f2..e48b13cb7 100644 --- a/src/org/traccar/protocol/FoxProtocolDecoder.java +++ b/src/org/traccar/protocol/FoxProtocolDecoder.java @@ -108,10 +108,10 @@ public class FoxProtocolDecoder extends BaseProtocolDecoder { position.setCourse(parser.nextDouble()); position.set(Position.KEY_INPUT, parser.nextInt(2)); - position.set(Position.KEY_POWER, parser.nextDouble() / 10); + position.set(Position.KEY_POWER, parser.nextDouble() * 0.1); position.set(Position.PREFIX_TEMP + 1, parser.nextInt()); position.set(Position.KEY_RPM, parser.nextInt()); - position.set(Position.KEY_FUEL, parser.nextInt()); + position.set(Position.KEY_FUEL_LEVEL, parser.nextInt()); position.set(Position.PREFIX_ADC + 1, parser.nextInt()); position.set(Position.PREFIX_ADC + 2, parser.nextInt()); position.set(Position.KEY_OUTPUT, parser.nextInt(2)); diff --git a/src/org/traccar/protocol/GalileoProtocolDecoder.java b/src/org/traccar/protocol/GalileoProtocolDecoder.java index a3f99c674..64bfdd270 100644 --- a/src/org/traccar/protocol/GalileoProtocolDecoder.java +++ b/src/org/traccar/protocol/GalileoProtocolDecoder.java @@ -185,7 +185,7 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); break; case 0xc1: - position.set(Position.KEY_FUEL, buf.readUnsignedByte() * 0.4); + position.set(Position.KEY_FUEL_LEVEL, buf.readUnsignedByte() * 0.4); position.set(Position.PREFIX_TEMP + 1, buf.readUnsignedByte() - 40); position.set(Position.KEY_RPM, buf.readUnsignedShort() * 0.125); break; diff --git a/src/org/traccar/protocol/GatorProtocolDecoder.java b/src/org/traccar/protocol/GatorProtocolDecoder.java index f01efb9d8..2ad4be3d3 100644 --- a/src/org/traccar/protocol/GatorProtocolDecoder.java +++ b/src/org/traccar/protocol/GatorProtocolDecoder.java @@ -120,7 +120,7 @@ public class GatorProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_STATUS, buf.readUnsignedByte()); position.set("key", buf.readUnsignedByte()); position.set("oil", buf.readUnsignedShort() / 10.0); - position.set(Position.KEY_POWER, buf.readUnsignedByte() + buf.readUnsignedByte() / 100.0); + position.set(Position.KEY_POWER, buf.readUnsignedByte() + buf.readUnsignedByte() * 0.01); position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); return position; diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java index 4103ebba6..74a734143 100644 --- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java @@ -455,7 +455,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { position.set("dtcsNumber", parser.next()); position.set("dtcsCodes", parser.next()); position.set(Position.KEY_THROTTLE, parser.next()); - position.set(Position.KEY_FUEL, parser.next()); + position.set(Position.KEY_FUEL_LEVEL, parser.next()); position.set(Position.KEY_OBD_ODOMETER, parser.nextInt() * 1000); decodeLocation(position, parser); @@ -533,7 +533,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { } position.set(Position.KEY_RPM, parser.next()); - position.set(Position.KEY_FUEL, parser.next()); + position.set(Position.KEY_FUEL_LEVEL, parser.next()); // workaround for wrong location time if (parser.hasNext(6)) { diff --git a/src/org/traccar/protocol/GranitProtocolDecoder.java b/src/org/traccar/protocol/GranitProtocolDecoder.java index 6e8bc24bf..7518eee1f 100644 --- a/src/org/traccar/protocol/GranitProtocolDecoder.java +++ b/src/org/traccar/protocol/GranitProtocolDecoder.java @@ -89,7 +89,7 @@ public class GranitProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_SATELLITES, BitUtil.from(satDel, 4)); int pdop = BitUtil.to(satDel, 4); - position.set("pdop", pdop); + position.set(Position.KEY_PDOP, pdop); int lonDegrees = buf.readUnsignedByte(); int latDegrees = buf.readUnsignedByte(); diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java index 356097fb2..bbba639c1 100644 --- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -264,7 +264,8 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { if (commandLength > 0) { buf.readUnsignedByte(); // server flag (reserved) - position.set("command", buf.readBytes(commandLength - 1).toString(StandardCharsets.US_ASCII)); + position.set(Position.KEY_COMMAND, + buf.readBytes(commandLength - 1).toString(StandardCharsets.US_ASCII)); } } else if (isSupported(type)) { diff --git a/src/org/traccar/protocol/HaicomProtocolDecoder.java b/src/org/traccar/protocol/HaicomProtocolDecoder.java index 97e980290..db26db820 100644 --- a/src/org/traccar/protocol/HaicomProtocolDecoder.java +++ b/src/org/traccar/protocol/HaicomProtocolDecoder.java @@ -105,7 +105,7 @@ public class HaicomProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_GPS, parser.next()); position.set(Position.KEY_INPUT, parser.next()); position.set(Position.KEY_OUTPUT, parser.next()); - position.set(Position.KEY_BATTERY, parser.nextDouble() / 10); + position.set(Position.KEY_BATTERY, parser.nextDouble() * 0.1); return position; } diff --git a/src/org/traccar/protocol/IdplProtocolDecoder.java b/src/org/traccar/protocol/IdplProtocolDecoder.java index 719314f28..5e3638d8e 100644 --- a/src/org/traccar/protocol/IdplProtocolDecoder.java +++ b/src/org/traccar/protocol/IdplProtocolDecoder.java @@ -94,14 +94,14 @@ public class IdplProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_SATELLITES, parser.nextInt()); position.set(Position.KEY_RSSI, parser.nextInt()); - parser.next(); // vehicle status + position.set("vehicleStatus", parser.next()); position.set(Position.KEY_POWER, parser.nextInt()); position.set(Position.KEY_BATTERY, parser.nextDouble()); if (parser.nextInt() == 1) { position.set(Position.KEY_ALARM, Position.ALARM_SOS); } parser.nextInt(); // body tamper - parser.nextInt(); // ac status + position.set("acStatus", parser.nextInt()); position.set(Position.KEY_IGNITION, parser.nextInt() == 1); position.set(Position.KEY_OUTPUT, parser.nextInt()); position.set(Position.PREFIX_ADC + 1, parser.nextInt()); diff --git a/src/org/traccar/protocol/IntellitracProtocolDecoder.java b/src/org/traccar/protocol/IntellitracProtocolDecoder.java index a2720028f..70251fc51 100644 --- a/src/org/traccar/protocol/IntellitracProtocolDecoder.java +++ b/src/org/traccar/protocol/IntellitracProtocolDecoder.java @@ -108,7 +108,7 @@ public class IntellitracProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_OBD_SPEED, parser.next()); position.set(Position.KEY_RPM, parser.next()); position.set("coolant", parser.next()); - position.set(Position.KEY_FUEL, parser.next()); + position.set(Position.KEY_FUEL_LEVEL, parser.next()); position.set(Position.KEY_FUEL_CONSUMPTION, parser.next()); position.set(Position.PREFIX_TEMP + 1, parser.next()); position.set(Position.KEY_CHARGE, parser.next()); diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java index e632b32d8..c8e41b03f 100644 --- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java +++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java @@ -145,7 +145,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_ODOMETER, buf.readUnsignedInt() * 1000); fuel += buf.readUnsignedByte(); - position.set(Position.KEY_FUEL, fuel); + position.set(Position.KEY_FUEL_LEVEL, fuel); } @@ -201,6 +201,9 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { position.setCourse(parser.nextDouble()); position.set(Position.KEY_POWER, parser.nextDouble()); + position.set(Position.KEY_GPS, parser.nextInt()); + position.set(Position.KEY_RSSI, parser.nextInt()); + position.set("alertType", parser.nextInt()); return position; } diff --git a/src/org/traccar/protocol/KhdProtocolDecoder.java b/src/org/traccar/protocol/KhdProtocolDecoder.java index 1c88a8b9d..d63219736 100644 --- a/src/org/traccar/protocol/KhdProtocolDecoder.java +++ b/src/org/traccar/protocol/KhdProtocolDecoder.java @@ -115,7 +115,7 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder { switch (dataType) { case 0x01: - position.set(Position.KEY_FUEL, + position.set(Position.KEY_FUEL_LEVEL, buf.readUnsignedByte() * 100 + buf.readUnsignedByte()); break; case 0x02: diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java index 9f05bfa6b..de739d0a4 100644 --- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java +++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java @@ -295,7 +295,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { position.set("engineLoad", parser.nextDouble()); position.set(Position.PREFIX_TEMP + 1, parser.nextInt()); position.set(Position.KEY_FUEL_CONSUMPTION, parser.nextDouble()); - position.set("averageFuelConsumition", parser.nextDouble()); + position.set("averageFuelConsumption", parser.nextDouble()); position.set("drivingRange", parser.nextDouble()); position.set(Position.KEY_ODOMETER, parser.nextDouble()); position.set("singleFuelConsumption", parser.nextDouble()); diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java index f5253566b..a4a0d2d42 100644 --- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java +++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java @@ -155,7 +155,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { if (parser.hasNext()) { String fuel = parser.next(); - position.set(Position.KEY_FUEL, + position.set(Position.KEY_FUEL_LEVEL, Integer.parseInt(fuel.substring(0, 2), 16) + Integer.parseInt(fuel.substring(2), 16) * 0.01); } diff --git a/src/org/traccar/protocol/Mta6ProtocolDecoder.java b/src/org/traccar/protocol/Mta6ProtocolDecoder.java index 2a3d84a2c..0fda94eef 100644 --- a/src/org/traccar/protocol/Mta6ProtocolDecoder.java +++ b/src/org/traccar/protocol/Mta6ProtocolDecoder.java @@ -182,7 +182,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder { if (BitUtil.check(flags, 7)) { position.set(Position.KEY_BATTERY, buf.getUnsignedByte(buf.readerIndex()) >> 2); position.set(Position.KEY_POWER, buf.readUnsignedShort() & 0x03ff); - buf.readByte(); // microcontroller temperature + position.set(Position.KEY_DEVICE_TEMP, buf.readByte()); position.set(Position.KEY_RSSI, (buf.getUnsignedByte(buf.readerIndex()) >> 4) & 0x07); @@ -222,7 +222,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder { position.setLongitude(new FloatReader().readFloat(buf) / Math.PI * 180); position.setTime(new TimeReader().readTime(buf)); - buf.readUnsignedByte(); // status + position.set(Position.KEY_STATUS, buf.readUnsignedByte()); if (BitUtil.check(flags, 0)) { position.setAltitude(buf.readUnsignedShort()); @@ -233,7 +233,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder { if (BitUtil.check(flags, 1)) { position.set(Position.KEY_FUEL_CONSUMPTION, new FloatReader().readFloat(buf)); - position.set("hours", new FloatReader().readFloat(buf)); + position.set(Position.KEY_HOURS, new FloatReader().readFloat(buf)); position.set("tank", buf.readUnsignedByte() * 0.4); } @@ -241,11 +241,11 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder { position.set("engine", buf.readUnsignedShort() * 0.125); position.set("pedals", buf.readUnsignedByte()); position.set(Position.PREFIX_TEMP + 1, buf.readUnsignedByte() - 40); - buf.readUnsignedShort(); // service odometer + position.set(Position.KEY_ODOMETER_SERVICE, buf.readUnsignedShort()); } if (BitUtil.check(flags, 3)) { - position.set(Position.KEY_FUEL, buf.readUnsignedShort()); + position.set(Position.KEY_FUEL_LEVEL, buf.readUnsignedShort()); position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShort()); position.set(Position.PREFIX_ADC + 3, buf.readUnsignedShort()); position.set(Position.PREFIX_ADC + 4, buf.readUnsignedShort()); @@ -261,7 +261,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder { if (BitUtil.check(flags, 5)) { position.set(Position.KEY_BATTERY, buf.getUnsignedByte(buf.readerIndex()) >> 2); position.set(Position.KEY_POWER, buf.readUnsignedShort() & 0x03ff); - buf.readByte(); // microcontroller temperature + position.set(Position.KEY_DEVICE_TEMP, buf.readByte()); position.set(Position.KEY_RSSI, buf.getUnsignedByte(buf.readerIndex()) >> 5); diff --git a/src/org/traccar/protocol/MxtProtocolDecoder.java b/src/org/traccar/protocol/MxtProtocolDecoder.java index bf1d3b342..49987ce57 100644 --- a/src/org/traccar/protocol/MxtProtocolDecoder.java +++ b/src/org/traccar/protocol/MxtProtocolDecoder.java @@ -137,7 +137,7 @@ public class MxtProtocolDecoder extends BaseProtocolDecoder { position.setAccuracy(buf.readUnsignedByte()); position.set(Position.KEY_RSSI, buf.readUnsignedByte()); buf.readUnsignedShort(); // time since boot - buf.readUnsignedByte(); // input voltage + position.set(Position.KEY_POWER, buf.readUnsignedByte()); position.set(Position.PREFIX_TEMP + 1, buf.readByte()); } diff --git a/src/org/traccar/protocol/NavigilProtocolDecoder.java b/src/org/traccar/protocol/NavigilProtocolDecoder.java index 263e5fc2b..360b9c81c 100644 --- a/src/org/traccar/protocol/NavigilProtocolDecoder.java +++ b/src/org/traccar/protocol/NavigilProtocolDecoder.java @@ -89,25 +89,25 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(deviceSession.getDeviceId()); buf.readUnsignedShort(); // report trigger - buf.readUnsignedShort(); // flags + position.set(Position.KEY_FLAGS, buf.readUnsignedShort()); position.setLatitude(buf.readInt() * 0.0000001); position.setLongitude(buf.readInt() * 0.0000001); position.setAltitude(buf.readUnsignedShort()); - position.set(Position.KEY_SATELLITES, buf.readUnsignedShort()); // satellites in fix - position.set(Position.KEY_SATELLITES_VISIBLE, buf.readUnsignedShort()); // satellites in track - buf.readUnsignedShort(); // GPS antenna state + position.set(Position.KEY_SATELLITES, buf.readUnsignedShort()); + position.set(Position.KEY_SATELLITES_VISIBLE, buf.readUnsignedShort()); + position.set("gpsAntennaState", buf.readUnsignedShort()); position.setSpeed(buf.readUnsignedShort() * 0.194384); position.setCourse(buf.readUnsignedShort()); - buf.readUnsignedInt(); // distance - buf.readUnsignedInt(); // delta distance + position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); + position.set(Position.KEY_DISTANCE, buf.readUnsignedInt()); position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.001); - position.set(Position.KEY_CHARGE, buf.readUnsignedShort()); // battery charger status + position.set(Position.KEY_CHARGE, buf.readUnsignedShort()); position.setTime(convertTimestamp(buf.readUnsignedInt())); @@ -133,19 +133,20 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { position.setLongitude(buf.readInt() * 0.0000001); position.setAltitude(buf.readUnsignedShort()); - position.set(Position.KEY_SATELLITES, buf.readUnsignedByte()); // satellites in fix - position.set(Position.KEY_SATELLITES_VISIBLE, buf.readUnsignedByte()); // satellites in track + position.set(Position.KEY_SATELLITES, buf.readUnsignedByte()); + position.set(Position.KEY_SATELLITES_VISIBLE, buf.readUnsignedByte()); position.setSpeed(buf.readUnsignedShort() * 0.194384); position.setCourse(buf.readUnsignedShort()); - buf.readUnsignedInt(); // distance - buf.readUnsignedShort(); // maximum speed - buf.readUnsignedShort(); // minimum speed + position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); + position.set("maximumSpeed", buf.readUnsignedShort()); + position.set("minimumSpeed", buf.readUnsignedShort()); + + position.set(Position.PREFIX_IO + 1, buf.readUnsignedShort()); // VSAUT1 voltage + position.set(Position.PREFIX_IO + 2, buf.readUnsignedShort()); // VSAUT2 voltage + position.set(Position.PREFIX_IO + 3, buf.readUnsignedShort()); // solar voltage - buf.readUnsignedShort(); // VSAUT1 voltage - buf.readUnsignedShort(); // VSAUT2 voltage - buf.readUnsignedShort(); // solar voltage position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.001); return position; @@ -170,6 +171,7 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { position.setValid((flags & 0x80) == 0x80 && (flags & 0x40) == 0x40); buf.readUnsignedByte(); // reserved + return position; } @@ -193,7 +195,8 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { position.setValid((flags & 0x80) == 0x80 && (flags & 0x40) == 0x40); position.set(Position.KEY_SATELLITES, buf.readUnsignedByte()); - buf.readUnsignedInt(); // distance + position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); + return position; } @@ -219,18 +222,18 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { position.setLongitude(buf.readInt() * 0.0000001); position.setAltitude(buf.readUnsignedShort()); - position.set(Position.KEY_SATELLITES, buf.readUnsignedByte()); // satellites in fix - position.set(Position.KEY_SATELLITES_VISIBLE, buf.readUnsignedByte()); // satellites in track + position.set(Position.KEY_SATELLITES, buf.readUnsignedByte()); + position.set(Position.KEY_SATELLITES_VISIBLE, buf.readUnsignedByte()); position.setSpeed(buf.readUnsignedShort() * 0.194384); position.setCourse(buf.readUnsignedShort() * 0.1); - buf.readUnsignedByte(); // maximum speed - buf.readUnsignedByte(); // minimum speed - buf.readUnsignedInt(); // distance + position.set("maximumSpeed", buf.readUnsignedByte()); + position.set("minimumSpeed", buf.readUnsignedByte()); + position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); - buf.readUnsignedByte(); // supply voltage 1 - buf.readUnsignedByte(); // supply voltage 2 + position.set(Position.PREFIX_IO + 1, buf.readUnsignedByte()); // supply voltage 1 + position.set(Position.PREFIX_IO + 2, buf.readUnsignedByte()); // supply voltage 2 position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.001); return position; @@ -258,11 +261,10 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte())); position.setCourse(buf.readUnsignedByte() * 2.0); - position.set(Position.KEY_SATELLITES, buf.readUnsignedByte()); // satellites in fix - + position.set(Position.KEY_SATELLITES, buf.readUnsignedByte()); position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.001); + position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); - buf.readUnsignedInt(); // distance return position; } diff --git a/src/org/traccar/protocol/NoranProtocolDecoder.java b/src/org/traccar/protocol/NoranProtocolDecoder.java index ebeacc659..990f50484 100644 --- a/src/org/traccar/protocol/NoranProtocolDecoder.java +++ b/src/org/traccar/protocol/NoranProtocolDecoder.java @@ -151,7 +151,7 @@ public class NoranProtocolDecoder extends BaseProtocolDecoder { if (!newFormat) { position.set(Position.PREFIX_IO + 1, buf.readUnsignedByte()); - position.set(Position.KEY_FUEL, buf.readUnsignedByte()); + position.set(Position.KEY_FUEL_LEVEL, buf.readUnsignedByte()); } else if (type == MSG_UPLOAD_POSITION_NEW) { position.set(Position.PREFIX_TEMP + 1, buf.readShort()); position.set(Position.KEY_ODOMETER, buf.readFloat()); diff --git a/src/org/traccar/protocol/OigoProtocolDecoder.java b/src/org/traccar/protocol/OigoProtocolDecoder.java index 9538053b6..54360c932 100644 --- a/src/org/traccar/protocol/OigoProtocolDecoder.java +++ b/src/org/traccar/protocol/OigoProtocolDecoder.java @@ -121,11 +121,11 @@ public class OigoProtocolDecoder extends BaseProtocolDecoder { } if (BitUtil.check(mask, 9)) { - position.set(Position.KEY_POWER, buf.readUnsignedShort() + "mV"); + position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.001); } if (BitUtil.check(mask, 10)) { - position.set(Position.KEY_BATTERY, buf.readUnsignedShort() + "mV"); + position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.001); } if (BitUtil.check(mask, 11)) { @@ -198,7 +198,7 @@ public class OigoProtocolDecoder extends BaseProtocolDecoder { position.setCourse(buf.readUnsignedShort()); position.setSpeed(UnitsConverter.knotsFromMph(buf.readUnsignedByte())); - position.set(Position.KEY_POWER, buf.readUnsignedByte() * 100 + "mV"); + position.set(Position.KEY_POWER, buf.readUnsignedByte() * 0.1); position.set(Position.PREFIX_IO + 1, buf.readUnsignedByte()); dateBuilder.setSecond(buf.readUnsignedByte()); diff --git a/src/org/traccar/protocol/PricolProtocolDecoder.java b/src/org/traccar/protocol/PricolProtocolDecoder.java index 3313afa22..a33e19b90 100644 --- a/src/org/traccar/protocol/PricolProtocolDecoder.java +++ b/src/org/traccar/protocol/PricolProtocolDecoder.java @@ -51,11 +51,11 @@ public class PricolProtocolDecoder extends BaseProtocolDecoder { position.setProtocol(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); - buf.readUnsignedByte(); // event type - buf.readUnsignedByte(); // packet version - buf.readUnsignedByte(); // device status - buf.readUnsignedByte(); // gsm status - buf.readUnsignedByte(); // gps status + position.set("eventType", buf.readUnsignedByte()); + position.set("packetVersion", buf.readUnsignedByte()); + position.set(Position.KEY_STATUS, buf.readUnsignedByte()); + position.set(Position.KEY_RSSI, buf.readUnsignedByte()); + position.set(Position.KEY_GPS, buf.readUnsignedByte()); position.setTime(new DateBuilder() .setDateReverse(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte()) @@ -76,8 +76,8 @@ public class PricolProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_INPUT, buf.readUnsignedShort()); position.set(Position.KEY_OUTPUT, buf.readUnsignedByte()); - buf.readUnsignedByte(); // analog alerts - buf.readUnsignedShort(); // custom alert types + position.set("analogAlerts", buf.readUnsignedByte()); + position.set("customAlertTypes", buf.readUnsignedShort()); for (int i = 1; i <= 5; i++) { position.set(Position.PREFIX_ADC + i, buf.readUnsignedShort()); diff --git a/src/org/traccar/protocol/RaveonProtocolDecoder.java b/src/org/traccar/protocol/RaveonProtocolDecoder.java index 847bc4fb6..1fd3d4cd7 100644 --- a/src/org/traccar/protocol/RaveonProtocolDecoder.java +++ b/src/org/traccar/protocol/RaveonProtocolDecoder.java @@ -95,7 +95,7 @@ public class RaveonProtocolDecoder extends BaseProtocolDecoder { position.setSpeed(UnitsConverter.knotsFromKph(parser.nextInt())); position.setCourse(parser.nextInt()); - parser.next(); // alerts + position.set(Position.KEY_ALARM, parser.next()); return position; } diff --git a/src/org/traccar/protocol/RitiProtocolDecoder.java b/src/org/traccar/protocol/RitiProtocolDecoder.java index 1ca517057..a879633c2 100644 --- a/src/org/traccar/protocol/RitiProtocolDecoder.java +++ b/src/org/traccar/protocol/RitiProtocolDecoder.java @@ -66,15 +66,15 @@ public class RitiProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(deviceSession.getDeviceId()); position.set("mode", buf.readUnsignedByte()); - position.set("command", buf.readUnsignedByte()); - position.set(Position.KEY_POWER, buf.readUnsignedShort()); + position.set(Position.KEY_COMMAND, buf.readUnsignedByte()); + position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.001); - buf.skipBytes(5); - buf.readUnsignedShort(); - buf.readUnsignedShort(); + buf.skipBytes(5); // status + buf.readUnsignedShort(); // idleCount + buf.readUnsignedShort(); // idleTime in seconds position.set(Position.KEY_DISTANCE, buf.readUnsignedInt()); - position.set(Position.KEY_TRIP_ODOMETER, buf.readUnsignedInt()); + position.set(Position.KEY_ODOMETER_TRIP, buf.readUnsignedInt()); // Parse GPRMC int end = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '*'); diff --git a/src/org/traccar/protocol/SkypatrolProtocolDecoder.java b/src/org/traccar/protocol/SkypatrolProtocolDecoder.java index dfe87caf5..f4dded972 100644 --- a/src/org/traccar/protocol/SkypatrolProtocolDecoder.java +++ b/src/org/traccar/protocol/SkypatrolProtocolDecoder.java @@ -92,15 +92,15 @@ public class SkypatrolProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(deviceSession.getDeviceId()); if (BitUtil.check(mask, 3)) { - buf.readUnsignedShort(); // io data + position.set(Position.PREFIX_IO + 1, buf.readUnsignedShort()); } if (BitUtil.check(mask, 4)) { - buf.readUnsignedShort(); // adc 1 + position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort()); } if (BitUtil.check(mask, 5)) { - buf.readUnsignedShort(); // adc 2 + position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShort()); } if (BitUtil.check(mask, 7)) { @@ -150,11 +150,11 @@ public class SkypatrolProtocolDecoder extends BaseProtocolDecoder { } if (BitUtil.check(mask, 17)) { - buf.readUnsignedShort(); // battery percentage + position.set(Position.KEY_BATTERY, buf.readUnsignedShort()); } if (BitUtil.check(mask, 20)) { - position.set("trip", buf.readUnsignedInt()); + position.set(Position.KEY_ODOMETER_TRIP, buf.readUnsignedInt()); } if (BitUtil.check(mask, 21)) { @@ -166,7 +166,7 @@ public class SkypatrolProtocolDecoder extends BaseProtocolDecoder { } if (BitUtil.check(mask, 24)) { - position.set(Position.KEY_POWER, buf.readUnsignedShort() / 1000.0); + position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.001); } if (BitUtil.check(mask, 25)) { diff --git a/src/org/traccar/protocol/SmokeyProtocolDecoder.java b/src/org/traccar/protocol/SmokeyProtocolDecoder.java index 37010d281..2dcfeb86f 100644 --- a/src/org/traccar/protocol/SmokeyProtocolDecoder.java +++ b/src/org/traccar/protocol/SmokeyProtocolDecoder.java @@ -84,12 +84,12 @@ public class SmokeyProtocolDecoder extends BaseProtocolDecoder { if (type == MSG_DATE_RECORD) { - buf.readUnsignedShort(); // firmware version - Position position = new Position(); position.setProtocol(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); + position.set(Position.KEY_VERSION_FW, buf.readUnsignedShort()); + int status = buf.readUnsignedShort(); position.set(Position.KEY_STATUS, status); diff --git a/src/org/traccar/protocol/Stl060ProtocolDecoder.java b/src/org/traccar/protocol/Stl060ProtocolDecoder.java index 87e55ea86..9f7980032 100644 --- a/src/org/traccar/protocol/Stl060ProtocolDecoder.java +++ b/src/org/traccar/protocol/Stl060ProtocolDecoder.java @@ -100,7 +100,7 @@ public class Stl060ProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_ODOMETER, parser.nextInt()); position.set(Position.KEY_IGNITION, parser.nextInt() == 1); position.set(Position.KEY_INPUT, parser.nextInt() + parser.nextInt() << 1); - position.set(Position.KEY_FUEL, parser.nextInt()); + position.set(Position.KEY_FUEL_LEVEL, parser.nextInt()); } // New format @@ -111,7 +111,7 @@ public class Stl060ProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_RFID, parser.next()); position.set(Position.KEY_ODOMETER, parser.nextInt()); position.set(Position.PREFIX_TEMP + 1, parser.nextInt()); - position.set(Position.KEY_FUEL, parser.nextInt()); + position.set(Position.KEY_FUEL_LEVEL, parser.nextInt()); position.set(Position.KEY_ACCELERATION, parser.nextInt() == 1); position.set(Position.KEY_OUTPUT, parser.nextInt() + parser.nextInt() << 1); } diff --git a/src/org/traccar/protocol/SupermateProtocolDecoder.java b/src/org/traccar/protocol/SupermateProtocolDecoder.java index 7f12121bb..5e6615e9f 100755 --- a/src/org/traccar/protocol/SupermateProtocolDecoder.java +++ b/src/org/traccar/protocol/SupermateProtocolDecoder.java @@ -82,7 +82,7 @@ public class SupermateProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(deviceSession.getDeviceId()); position.set("commandId", parser.next()); - position.set("command", parser.next()); + position.set(Position.KEY_COMMAND, parser.next()); position.setValid(parser.next().equals("A")); diff --git a/src/org/traccar/protocol/T55ProtocolDecoder.java b/src/org/traccar/protocol/T55ProtocolDecoder.java index a41da427a..cd50a99ff 100644 --- a/src/org/traccar/protocol/T55ProtocolDecoder.java +++ b/src/org/traccar/protocol/T55ProtocolDecoder.java @@ -136,7 +136,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(deviceSession.getDeviceId()); position.set(Position.KEY_IGNITION, parser.hasNext() && parser.next().equals("1")); - position.set(Position.KEY_FUEL, parser.nextInt()); + position.set(Position.KEY_FUEL_LEVEL, parser.nextInt()); position.set(Position.KEY_BATTERY, parser.nextInt()); } diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java index a9679f764..30a3f4cda 100644 --- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java +++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java @@ -67,7 +67,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_TYPE, buf.readUnsignedByte()); - position.set("command", buf.readBytes(buf.readInt()).toString(StandardCharsets.US_ASCII)); + position.set(Position.KEY_COMMAND, buf.readBytes(buf.readInt()).toString(StandardCharsets.US_ASCII)); } @@ -96,10 +96,10 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { position.set(Position.PREFIX_ADC + 1, readValue(buf, length, false)); break; case 66: - position.set(Position.KEY_POWER, readValue(buf, length, false) + "mV"); + position.set(Position.KEY_POWER, readValue(buf, length, false) * 0.001); break; case 67: - position.set(Position.KEY_BATTERY, readValue(buf, length, false) + "mV"); + position.set(Position.KEY_BATTERY, readValue(buf, length, false) * 0.001); break; case 70: position.set(Position.KEY_DEVICE_TEMP, readValue(buf, length, true) * 0.1); @@ -178,7 +178,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { } if (BitUtil.check(locationMask, 7)) { - position.set("operator", buf.readUnsignedInt()); + position.set(Position.KEY_OPERATOR, buf.readUnsignedInt()); } } else { diff --git a/src/org/traccar/protocol/TmgProtocolDecoder.java b/src/org/traccar/protocol/TmgProtocolDecoder.java index 40ce04c5b..a0459a161 100644 --- a/src/org/traccar/protocol/TmgProtocolDecoder.java +++ b/src/org/traccar/protocol/TmgProtocolDecoder.java @@ -129,7 +129,7 @@ public class TmgProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_HDOP, parser.nextDouble()); position.set(Position.KEY_SATELLITES, parser.nextInt()); position.set(Position.KEY_SATELLITES_VISIBLE, parser.nextInt()); - position.set("operator", parser.next()); + position.set(Position.KEY_OPERATOR, parser.next()); position.set(Position.KEY_RSSI, parser.nextInt()); position.set(Position.KEY_IGNITION, parser.nextInt() == 1); position.set(Position.KEY_BATTERY, parser.nextDouble()); diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java index f36ef8143..c7dc9e6c1 100644 --- a/src/org/traccar/protocol/TotemProtocolDecoder.java +++ b/src/org/traccar/protocol/TotemProtocolDecoder.java @@ -275,7 +275,7 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { position.setTime(dateBuilder.getDate()); position.set(Position.PREFIX_IO + 1, parser.next()); - position.set(Position.KEY_BATTERY, parser.nextDouble() / 10); + position.set(Position.KEY_BATTERY, parser.nextDouble() * 0.1); position.set(Position.KEY_POWER, parser.nextDouble()); position.set(Position.PREFIX_ADC + 1, parser.next()); position.set(Position.PREFIX_ADC + 2, parser.next()); @@ -289,7 +289,7 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_SATELLITES, parser.next()); position.setCourse(parser.nextDouble()); position.setSpeed(parser.nextDouble()); - position.set("pdop", parser.next()); + position.set(Position.KEY_PDOP, parser.next()); position.set(Position.KEY_ODOMETER, parser.nextInt() * 1000); position.setLatitude(parser.nextCoordinate()); @@ -303,7 +303,7 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt()); position.setTime(dateBuilder.getDate()); - position.set(Position.KEY_BATTERY, parser.nextDouble() / 10); + position.set(Position.KEY_BATTERY, parser.nextDouble() * 0.1); position.set(Position.KEY_POWER, parser.nextDouble()); position.set(Position.PREFIX_ADC + 1, parser.next()); diff --git a/src/org/traccar/protocol/TrakMateProtocolDecoder.java b/src/org/traccar/protocol/TrakMateProtocolDecoder.java index d1bd1398b..95eef67c8 100644 --- a/src/org/traccar/protocol/TrakMateProtocolDecoder.java +++ b/src/org/traccar/protocol/TrakMateProtocolDecoder.java @@ -126,7 +126,7 @@ public class TrakMateProtocolDecoder extends BaseProtocolDecoder { position.setTime(dateBuilder.getDate()); position.set(Position.KEY_VERSION_FW, parser.next()); - parser.next(); // hardware version + position.set(Position.KEY_VERSION_HW, parser.next()); return position; } @@ -195,13 +195,13 @@ public class TrakMateProtocolDecoder extends BaseProtocolDecoder { position.setCourse(parser.nextDouble()); position.set(Position.KEY_IGNITION, parser.nextInt() == 1); - parser.next(); // dop1 - parser.next(); // dop2 - parser.next(); // analog input - position.set(Position.KEY_BATTERY, parser.nextDouble()); // device battery voltage - parser.next(); // vehicle internal voltage - position.set(Position.KEY_ODOMETER, parser.nextDouble()); // gps odometer - parser.next(); // pulse odometer + position.set("dop1", parser.next()); + position.set("dop2", parser.next()); + position.set(Position.KEY_INPUT, parser.next()); + position.set(Position.KEY_BATTERY, parser.nextDouble()); + position.set(Position.KEY_POWER, parser.next()); + position.set(Position.KEY_ODOMETER, parser.nextDouble()); + position.set("pulseOdometer", parser.next()); position.set(Position.KEY_STATUS, parser.nextInt()); position.setValid(parser.nextInt() != 0); diff --git a/src/org/traccar/protocol/TramigoProtocolDecoder.java b/src/org/traccar/protocol/TramigoProtocolDecoder.java index 73356ccfc..8a6f49ef0 100644 --- a/src/org/traccar/protocol/TramigoProtocolDecoder.java +++ b/src/org/traccar/protocol/TramigoProtocolDecoder.java @@ -85,16 +85,16 @@ public class TramigoProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_RSSI, buf.readUnsignedShort()); position.set(Position.KEY_SATELLITES, buf.readUnsignedShort()); position.set(Position.KEY_SATELLITES_VISIBLE, buf.readUnsignedShort()); - buf.readUnsignedShort(); // gps antenna state + position.set("gpsAntennaStatus", buf.readUnsignedShort()); position.setSpeed(buf.readUnsignedShort() * 0.194384); position.setCourse((double) buf.readUnsignedShort()); - buf.readUnsignedInt(); // distance + position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); position.set(Position.KEY_BATTERY, buf.readUnsignedShort()); - position.set(Position.KEY_CHARGE, buf.readUnsignedShort()); // battery charger status + position.set(Position.KEY_CHARGE, buf.readUnsignedShort()); position.setTime(new Date(buf.readUnsignedInt() * 1000)); diff --git a/src/org/traccar/protocol/TytanProtocolDecoder.java b/src/org/traccar/protocol/TytanProtocolDecoder.java index 429479de0..e358e60b1 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_TRIP_ODOMETER, buf.readUnsignedMedium()); + position.set(Position.KEY_ODOMETER_TRIP, buf.readUnsignedMedium()); break; case 5: position.set(Position.KEY_INPUT, buf.readUnsignedByte()); @@ -100,11 +100,11 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder { int fuel = buf.readUnsignedShort(); int fuelFormat = fuel >> 14; if (fuelFormat == 1) { - position.set(Position.KEY_FUEL, (fuel & 0x3fff) * 0.4 + "%"); + position.set(Position.KEY_FUEL_LEVEL, (fuel & 0x3fff) * 0.4 + "%"); } else if (fuelFormat == 2) { - position.set(Position.KEY_FUEL, (fuel & 0x3fff) * 0.5 + " l"); + position.set(Position.KEY_FUEL_LEVEL, (fuel & 0x3fff) * 0.5 + " l"); } else if (fuelFormat == 3) { - position.set(Position.KEY_FUEL, (fuel & 0x3fff) * -0.5 + " l"); + position.set(Position.KEY_FUEL_LEVEL, (fuel & 0x3fff) * -0.5 + " l"); } break; case 108: diff --git a/src/org/traccar/protocol/TzoneProtocolDecoder.java b/src/org/traccar/protocol/TzoneProtocolDecoder.java index 0fc93a03c..69aa916df 100644 --- a/src/org/traccar/protocol/TzoneProtocolDecoder.java +++ b/src/org/traccar/protocol/TzoneProtocolDecoder.java @@ -119,8 +119,8 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder { if (buf.readUnsignedShort() != 0x2424) { return null; } - int hardware = buf.readUnsignedShort(); // model - buf.readUnsignedInt(); // firmware + int hardware = buf.readUnsignedShort(); + long firmware = buf.readUnsignedInt(); String imei = ChannelBuffers.hexDump(buf.readBytes(8)).substring(1); DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei); @@ -132,6 +132,9 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder { position.setProtocol(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); + position.set(Position.KEY_VERSION_HW, hardware); + position.set(Position.KEY_VERSION_FW, firmware); + position.setDeviceTime(new DateBuilder() .setDate(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte()) .setTime(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte()).getDate()); @@ -199,10 +202,10 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder { if (blockLength >= 13) { position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte())); - buf.readUnsignedByte(); // terminal info + position.set("terminalInfo", buf.readUnsignedByte()); position.set(Position.PREFIX_IO + 1, buf.readUnsignedShort()); position.set(Position.KEY_RSSI, buf.readUnsignedByte()); - buf.readUnsignedByte(); // GSM status + position.set("gsmStatus", buf.readUnsignedByte()); position.set(Position.KEY_BATTERY, buf.readUnsignedShort()); position.set(Position.KEY_POWER, buf.readUnsignedShort()); position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort()); diff --git a/src/org/traccar/protocol/UlbotechProtocolDecoder.java b/src/org/traccar/protocol/UlbotechProtocolDecoder.java index ec45be3d1..19e9cd5e9 100644 --- a/src/org/traccar/protocol/UlbotechProtocolDecoder.java +++ b/src/org/traccar/protocol/UlbotechProtocolDecoder.java @@ -248,7 +248,7 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder { break; case DATA_FUEL: - position.set("fuelConsumption", buf.readUnsignedInt() / 10000.0); + position.set(Position.KEY_FUEL_CONSUMPTION, buf.readUnsignedInt() / 10000.0); break; case DATA_OBD2_ALARM: diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java index 032925a4a..9541e1027 100644 --- a/src/org/traccar/reports/ReportUtils.java +++ b/src/org/traccar/reports/ReportUtils.java @@ -78,15 +78,17 @@ public final class ReportUtils { public static String calculateFuel(Position firstPosition, Position lastPosition) { - if (firstPosition.getAttributes().get(Position.KEY_FUEL) != null - && lastPosition.getAttributes().get(Position.KEY_FUEL) != null) { + if (firstPosition.getAttributes().get(Position.KEY_FUEL_LEVEL) != null + && lastPosition.getAttributes().get(Position.KEY_FUEL_LEVEL) != null) { try { switch (firstPosition.getProtocol()) { case "meitrack": case "galileo": case "noran": - BigDecimal v = new BigDecimal(firstPosition.getAttributes().get(Position.KEY_FUEL).toString()); - v = v.subtract(new BigDecimal(lastPosition.getAttributes().get(Position.KEY_FUEL).toString())); + BigDecimal v = new BigDecimal(firstPosition.getAttributes() + .get(Position.KEY_FUEL_LEVEL).toString()); + v = v.subtract(new BigDecimal(lastPosition.getAttributes() + .get(Position.KEY_FUEL_LEVEL).toString())); return v.setScale(2, RoundingMode.HALF_EVEN).toString() + " %"; default: break; |