From b19f1a505f7088ff48f467b32b5f1c207aa3be01 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 12 Jul 2017 14:22:03 +0500 Subject: - Handle rfid attributes and populate driverUniqueId - Add Driver Name to Trip report --- src/org/traccar/protocol/AplicomProtocolDecoder.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/org/traccar/protocol/AplicomProtocolDecoder.java') diff --git a/src/org/traccar/protocol/AplicomProtocolDecoder.java b/src/org/traccar/protocol/AplicomProtocolDecoder.java index eb8d77011..448cd94fc 100644 --- a/src/org/traccar/protocol/AplicomProtocolDecoder.java +++ b/src/org/traccar/protocol/AplicomProtocolDecoder.java @@ -263,7 +263,8 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { } if ((selector & 0x0200) != 0) { - position.set(Position.KEY_RFID, (((long) buf.readUnsignedShort()) << 32) + buf.readUnsignedInt()); + position.set(Position.KEY_RFID, + String.valueOf(((long) buf.readUnsignedShort()) << 32) + buf.readUnsignedInt()); } if ((selector & 0x0400) != 0) { -- cgit v1.2.3 From 9949cadcdf3f07a4590742e2f0303d82efb653f9 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Fri, 14 Jul 2017 11:34:58 +0500 Subject: Save driver identification (rfid/ibutton etc.) as driverUniqueId attribute --- src/org/traccar/model/Position.java | 1 - src/org/traccar/protocol/AplicomProtocolDecoder.java | 2 +- src/org/traccar/protocol/AstraProtocolDecoder.java | 2 +- src/org/traccar/protocol/AtrackProtocolDecoder.java | 2 +- src/org/traccar/protocol/FifotrackProtocolDecoder.java | 2 +- src/org/traccar/protocol/Gl200ProtocolDecoder.java | 2 +- src/org/traccar/protocol/GnxProtocolDecoder.java | 2 +- src/org/traccar/protocol/Gps103ProtocolDecoder.java | 2 +- src/org/traccar/protocol/MegastekProtocolDecoder.java | 2 +- src/org/traccar/protocol/MeiligaoProtocolDecoder.java | 4 ++-- src/org/traccar/protocol/MeitrackProtocolDecoder.java | 2 +- src/org/traccar/protocol/MxtProtocolDecoder.java | 2 +- src/org/traccar/protocol/OsmAndProtocolDecoder.java | 2 +- src/org/traccar/protocol/Pt502ProtocolDecoder.java | 2 +- src/org/traccar/protocol/StarLinkProtocolDecoder.java | 2 +- src/org/traccar/protocol/Stl060ProtocolDecoder.java | 2 +- src/org/traccar/protocol/TeltonikaProtocolDecoder.java | 2 +- src/org/traccar/protocol/TmgProtocolDecoder.java | 2 +- src/org/traccar/protocol/UlbotechProtocolDecoder.java | 3 ++- src/org/traccar/protocol/VisiontekProtocolDecoder.java | 2 +- src/org/traccar/protocol/WialonProtocolDecoder.java | 2 +- test/org/traccar/ProtocolTest.java | 4 ++-- 22 files changed, 24 insertions(+), 24 deletions(-) (limited to 'src/org/traccar/protocol/AplicomProtocolDecoder.java') diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java index 97b3f365f..9e7bac932 100644 --- a/src/org/traccar/model/Position.java +++ b/src/org/traccar/model/Position.java @@ -49,7 +49,6 @@ public class Position extends Message { 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"; public static final String KEY_TYPE = "type"; diff --git a/src/org/traccar/protocol/AplicomProtocolDecoder.java b/src/org/traccar/protocol/AplicomProtocolDecoder.java index 448cd94fc..6f63d0c17 100644 --- a/src/org/traccar/protocol/AplicomProtocolDecoder.java +++ b/src/org/traccar/protocol/AplicomProtocolDecoder.java @@ -263,7 +263,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { } if ((selector & 0x0200) != 0) { - position.set(Position.KEY_RFID, + position.set(Position.KEY_DRIVER_UNIQUE_ID, String.valueOf(((long) buf.readUnsignedShort()) << 32) + buf.readUnsignedInt()); } diff --git a/src/org/traccar/protocol/AstraProtocolDecoder.java b/src/org/traccar/protocol/AstraProtocolDecoder.java index ea6aa7b30..8d86cd2be 100644 --- a/src/org/traccar/protocol/AstraProtocolDecoder.java +++ b/src/org/traccar/protocol/AstraProtocolDecoder.java @@ -105,7 +105,7 @@ 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_DRIVER_UNIQUE_ID, buf.readBytes(7).toString(StandardCharsets.US_ASCII)); position.set(Position.KEY_ODOMETER, buf.readUnsignedMedium() * 1000); position.set(Position.KEY_HOURS, buf.readUnsignedShort()); } diff --git a/src/org/traccar/protocol/AtrackProtocolDecoder.java b/src/org/traccar/protocol/AtrackProtocolDecoder.java index 79b3c36cc..23cb67e15 100644 --- a/src/org/traccar/protocol/AtrackProtocolDecoder.java +++ b/src/org/traccar/protocol/AtrackProtocolDecoder.java @@ -327,7 +327,7 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_OUTPUT, buf.readUnsignedByte()); position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort() * 0.001); - position.set("driver", readString(buf)); + position.set(Position.KEY_DRIVER_UNIQUE_ID, readString(buf)); position.set(Position.PREFIX_TEMP + 1, buf.readShort() * 0.1); position.set(Position.PREFIX_TEMP + 2, buf.readShort() * 0.1); diff --git a/src/org/traccar/protocol/FifotrackProtocolDecoder.java b/src/org/traccar/protocol/FifotrackProtocolDecoder.java index f8f4fb078..304f6a2c3 100644 --- a/src/org/traccar/protocol/FifotrackProtocolDecoder.java +++ b/src/org/traccar/protocol/FifotrackProtocolDecoder.java @@ -110,7 +110,7 @@ public class FifotrackProtocolDecoder extends BaseProtocolDecoder { position.set(Position.PREFIX_ADC + (i + 1), Integer.parseInt(adc[i], 16)); } - position.set(Position.KEY_RFID, parser.next()); + position.set(Position.KEY_DRIVER_UNIQUE_ID, parser.next()); if (parser.hasNext()) { String[] sensors = parser.next().split("\\|"); diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java index a3062c942..140d3300a 100644 --- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java @@ -644,7 +644,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { return null; } - position.set(Position.KEY_RFID, parser.next()); + position.set(Position.KEY_DRIVER_UNIQUE_ID, parser.next()); decodeLocation(position, parser); diff --git a/src/org/traccar/protocol/GnxProtocolDecoder.java b/src/org/traccar/protocol/GnxProtocolDecoder.java index 070d394e8..2274ec164 100644 --- a/src/org/traccar/protocol/GnxProtocolDecoder.java +++ b/src/org/traccar/protocol/GnxProtocolDecoder.java @@ -102,7 +102,7 @@ public class GnxProtocolDecoder extends BaseProtocolDecoder { position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM)); if (type.equals("MIF")) { - position.set(Position.KEY_RFID, parser.next()); + position.set(Position.KEY_DRIVER_UNIQUE_ID, parser.next()); } return position; diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java index f5ba3cff7..a9a72b110 100644 --- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java @@ -258,7 +258,7 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { String rfid = parser.next(); if (alarm.equals("rfid")) { - position.set(Position.KEY_RFID, rfid); + position.set(Position.KEY_DRIVER_UNIQUE_ID, rfid); } String utcHours = parser.next(); diff --git a/src/org/traccar/protocol/MegastekProtocolDecoder.java b/src/org/traccar/protocol/MegastekProtocolDecoder.java index 15a384cc0..994e2d983 100644 --- a/src/org/traccar/protocol/MegastekProtocolDecoder.java +++ b/src/org/traccar/protocol/MegastekProtocolDecoder.java @@ -327,7 +327,7 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder { } } - position.set(Position.KEY_RFID, parser.next()); + position.set(Position.KEY_DRIVER_UNIQUE_ID, parser.next()); String battery = parser.next(); if (battery != null) { diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java index 77e117262..dbbf61f71 100644 --- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java +++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java @@ -253,7 +253,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { } if (parser.hasNext()) { - position.set(Position.KEY_RFID, String.valueOf(parser.nextHexInt(0))); + position.set(Position.KEY_DRIVER_UNIQUE_ID, String.valueOf(parser.nextHexInt(0))); } return position; @@ -370,7 +370,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { if (rfid != 0) { String card = String.format("%010d", rfid); position.set("card" + (i + 1), card); - position.set(Position.KEY_RFID, card); + position.set(Position.KEY_DRIVER_UNIQUE_ID, card); } } } diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java index 38ecde519..711697fc4 100644 --- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java +++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java @@ -201,7 +201,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { if (eventData != null && !eventData.isEmpty()) { switch (event) { case 37: - position.set(Position.KEY_RFID, eventData); + position.set(Position.KEY_DRIVER_UNIQUE_ID, eventData); break; default: position.set("eventData", eventData); diff --git a/src/org/traccar/protocol/MxtProtocolDecoder.java b/src/org/traccar/protocol/MxtProtocolDecoder.java index 49987ce57..6d82e4a4b 100644 --- a/src/org/traccar/protocol/MxtProtocolDecoder.java +++ b/src/org/traccar/protocol/MxtProtocolDecoder.java @@ -159,7 +159,7 @@ public class MxtProtocolDecoder extends BaseProtocolDecoder { } if (BitUtil.check(infoGroups, 7)) { - position.set(Position.KEY_RFID, buf.readUnsignedInt()); + position.set(Position.KEY_DRIVER_UNIQUE_ID, String.valueOf(buf.readUnsignedInt())); } buf.readerIndex(buf.writerIndex() - 3); diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java index 20cd54b2f..cb324aa86 100644 --- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java +++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java @@ -129,7 +129,7 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_BATTERY_LEVEL, Double.parseDouble(value)); break; case "rfid": - position.set(Position.KEY_RFID, value); + position.set(Position.KEY_DRIVER_UNIQUE_ID, value); break; default: try { diff --git a/src/org/traccar/protocol/Pt502ProtocolDecoder.java b/src/org/traccar/protocol/Pt502ProtocolDecoder.java index b1851f8ca..e12bbdf28 100644 --- a/src/org/traccar/protocol/Pt502ProtocolDecoder.java +++ b/src/org/traccar/protocol/Pt502ProtocolDecoder.java @@ -129,7 +129,7 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder { } position.set(Position.KEY_ODOMETER, parser.nextInt(0)); - position.set(Position.KEY_RFID, parser.next()); + position.set(Position.KEY_DRIVER_UNIQUE_ID, parser.next()); if (parser.hasNext()) { int value = parser.nextHexInt(0); diff --git a/src/org/traccar/protocol/StarLinkProtocolDecoder.java b/src/org/traccar/protocol/StarLinkProtocolDecoder.java index e90dde455..38f6980f6 100644 --- a/src/org/traccar/protocol/StarLinkProtocolDecoder.java +++ b/src/org/traccar/protocol/StarLinkProtocolDecoder.java @@ -196,7 +196,7 @@ public class StarLinkProtocolDecoder extends BaseProtocolDecoder { if (rfid.matches("0+")) { rfid = data[data.length - 2]; } - position.set(Position.KEY_RFID, rfid); + position.set(Position.KEY_DRIVER_UNIQUE_ID, rfid); } return position; diff --git a/src/org/traccar/protocol/Stl060ProtocolDecoder.java b/src/org/traccar/protocol/Stl060ProtocolDecoder.java index c81e83aab..26817a5c8 100644 --- a/src/org/traccar/protocol/Stl060ProtocolDecoder.java +++ b/src/org/traccar/protocol/Stl060ProtocolDecoder.java @@ -104,7 +104,7 @@ public class Stl060ProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_CHARGE, parser.nextInt(0) == 1); position.set(Position.KEY_IGNITION, parser.nextInt(0) == 1); position.set(Position.KEY_INPUT, parser.nextInt(0)); - position.set(Position.KEY_RFID, parser.next()); + position.set(Position.KEY_DRIVER_UNIQUE_ID, parser.next()); position.set(Position.KEY_ODOMETER, parser.nextInt(0)); position.set(Position.PREFIX_TEMP + 1, parser.nextInt(0)); position.set(Position.KEY_FUEL_LEVEL, parser.nextInt(0)); diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java index f1fd55d98..72e06c083 100644 --- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java +++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java @@ -114,7 +114,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { position.set(Position.PREFIX_TEMP + 3, readValue(buf, length, true) * 0.1); break; case 78: - position.set(Position.KEY_RFID, String.valueOf(readValue(buf, length, false))); + position.set(Position.KEY_DRIVER_UNIQUE_ID, String.valueOf(readValue(buf, length, false))); break; case 182: position.set(Position.KEY_HDOP, readValue(buf, length, false) * 0.1); diff --git a/src/org/traccar/protocol/TmgProtocolDecoder.java b/src/org/traccar/protocol/TmgProtocolDecoder.java index c10523117..b8458dd52 100644 --- a/src/org/traccar/protocol/TmgProtocolDecoder.java +++ b/src/org/traccar/protocol/TmgProtocolDecoder.java @@ -144,7 +144,7 @@ public class TmgProtocolDecoder extends BaseProtocolDecoder { position.set(Position.PREFIX_ADC + 1, parser.nextDouble(0)); position.set(Position.PREFIX_ADC + 2, parser.nextDouble(0)); position.set(Position.KEY_VERSION_FW, parser.next()); - position.set(Position.KEY_RFID, parser.next()); + position.set(Position.KEY_DRIVER_UNIQUE_ID, parser.next()); return position; } diff --git a/src/org/traccar/protocol/UlbotechProtocolDecoder.java b/src/org/traccar/protocol/UlbotechProtocolDecoder.java index 1b22eeb75..31a3d2cfe 100644 --- a/src/org/traccar/protocol/UlbotechProtocolDecoder.java +++ b/src/org/traccar/protocol/UlbotechProtocolDecoder.java @@ -308,7 +308,8 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder { break; case DATA_RFID: - position.set(Position.KEY_RFID, buf.readBytes(length - 1).toString(StandardCharsets.US_ASCII)); + position.set(Position.KEY_DRIVER_UNIQUE_ID, + buf.readBytes(length - 1).toString(StandardCharsets.US_ASCII)); position.set("authorized", buf.readUnsignedByte() != 0); break; diff --git a/src/org/traccar/protocol/VisiontekProtocolDecoder.java b/src/org/traccar/protocol/VisiontekProtocolDecoder.java index 636a3d640..f32c9fbfe 100644 --- a/src/org/traccar/protocol/VisiontekProtocolDecoder.java +++ b/src/org/traccar/protocol/VisiontekProtocolDecoder.java @@ -130,7 +130,7 @@ public class VisiontekProtocolDecoder extends BaseProtocolDecoder { position.setValid(parser.next().equals("A")); - position.set(Position.KEY_RFID, parser.next()); + position.set(Position.KEY_DRIVER_UNIQUE_ID, parser.next()); return position; } diff --git a/src/org/traccar/protocol/WialonProtocolDecoder.java b/src/org/traccar/protocol/WialonProtocolDecoder.java index 82098413b..4eb3b9b8e 100644 --- a/src/org/traccar/protocol/WialonProtocolDecoder.java +++ b/src/org/traccar/protocol/WialonProtocolDecoder.java @@ -109,7 +109,7 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder { } } - position.set(Position.KEY_RFID, parser.next()); + position.set(Position.KEY_DRIVER_UNIQUE_ID, parser.next()); if (parser.hasNext()) { String[] values = parser.next().split(","); diff --git a/test/org/traccar/ProtocolTest.java b/test/org/traccar/ProtocolTest.java index dc4f70981..cb9cdf759 100644 --- a/test/org/traccar/ProtocolTest.java +++ b/test/org/traccar/ProtocolTest.java @@ -245,8 +245,8 @@ public class ProtocolTest extends BaseTest { Assert.assertTrue(attributes.get(Position.KEY_ARCHIVE) instanceof Boolean); } - if (attributes.containsKey(Position.KEY_RFID)) { - Assert.assertTrue(attributes.get(Position.KEY_RFID) instanceof String); + if (attributes.containsKey(Position.KEY_DRIVER_UNIQUE_ID)) { + Assert.assertTrue(attributes.get(Position.KEY_DRIVER_UNIQUE_ID) instanceof String); } if (position.getNetwork() != null && position.getNetwork().getCellTowers() != null) { -- cgit v1.2.3