From 69595987b3da18b518ac0dcb7082324d096cdb35 Mon Sep 17 00:00:00 2001 From: jose Date: Tue, 13 Dec 2016 09:03:08 +0100 Subject: Fix Meiligao Protocol to work with tk228 --- src/org/traccar/model/Position.java | 19 +++- .../traccar/protocol/MeiligaoProtocolDecoder.java | 122 ++++++++++++++------- 2 files changed, 97 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java index 8ca2588e2..3e8cb27bc 100644 --- a/src/org/traccar/model/Position.java +++ b/src/org/traccar/model/Position.java @@ -60,11 +60,26 @@ public class Position extends Message { 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_DTCS = "dtcs"; public static final String KEY_OBD_SPEED = "obdSpeed"; public static final String KEY_OBD_ODOMETER = "obdOdometer"; - + public static final String KEY_OBD_ENGINE_LOAD = "engineLoad"; + public static final String KEY_OBD_AVERAGE_FUEL = "averageFuelConsumition"; + public static final String KEY_OBD_DRIVING_RANGE = "drivingRange"; + public static final String KEY_OBD_SINGLE_FUEL_CONSUMPTION = "singleFuelConsumption"; + public static final String KEY_OBD_TOTAL_FUEL_CONSUMPTION = "totalFuelConsumption"; + public static final String KEY_OBD_CURRENT_ERROR = "currentError"; + public static final String KEY_OBD_HARSH_ACCELERATION = "harshAcelerationNo"; + public static final String KEY_OBD_HARSH_BREAK = "harshBreakerNo"; + public static final String KEY_OBD_TOTAL_IGNITION = "totalIgnitionNo"; + public static final String KEY_OBD_TOTAL_DRIVING_TIME = "totalDrivingTime"; + public static final String KEY_OBD_TOTAL_IDLING_TIME = "totalIdlingTime"; + public static final String KEY_OBD_AVERAGE_HOT_START = "averageHotStartTime"; + public static final String KEY_OBD_AVERAGE_SPEED = "averageSpeed"; + public static final String KEY_OBD_HISTORY_HIGHT_SPEED = "historyHightestSpeed"; + public static final String KEY_OBD_HISTORY_HIGHT_RPM = "historyHightestRPM"; + public static final String KEY_OBD_TOTAL_HARSH_ACCELERATION = "totalHarshAccerleration"; + public static final String KEY_OBD_TOTAL_HARSH_BRAKE = "totalHarshBrake"; public static final String KEY_RESULT = "result"; // Starts with 1 not 0 diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java index 9915eab8c..ee41c26c3 100644 --- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java +++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java @@ -39,31 +39,31 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { } private static final Pattern PATTERN = new PatternBuilder() - .number("(dd)(dd)(dd).?(d+)?,") // time - .expression("([AV]),") // validity - .number("(d+)(dd.d+),") // latitude + .number("(dd)(dd)(dd).?(d+)?,") // time + .expression("([AV]),") // validity + .number("(d+)(dd.d+),") // latitude .expression("([NS]),") - .number("(d+)(dd.d+),") // longitude + .number("(d+)(dd.d+),") // longitude .expression("([EW]),") - .number("(d+.?d*)?,") // speed - .number("(d+.?d*)?,") // course - .number("(dd)(dd)(dd)") // date (ddmmyy) + .number("(d+.?d*)?,") // speed + .number("(d+.?d*)?,") // course + .number("(dd)(dd)(dd)") // date (ddmmyy) .expression("[^\\|]*") .groupBegin() - .number("|(d+.d+)?") // hdop - .number("|(-?d+.?d*)?") // altitude - .number("|(xxxx)?") // state + .number("|(d+.d+)?") // hdop + .number("|(-?d+.?d*)?") // altitude + .number("|(xxxx)?") // state .groupBegin() - .number("|(xxxx),(xxxx)") // adc + .number("|(xxxx),(xxxx)") // adc .number("(?:,(xxxx),(xxxx),(xxxx),(xxxx),(xxxx),(xxxx))?") .groupBegin() - .number("|x{16}") // cell - .number("|(xx)") // gsm - .number("|(x{8})") // odometer + .number("|x{16}") // cell + .number("|(xx)") // gsm + .number("|(x{8})") // odometer .or() - .number("|(x{9})") // odometer + .number("|(x{9})") // odometer .groupBegin() - .number("|(x{5,})") // rfid + .number("|(x{5,})") // rfid .groupEnd("?") .groupEnd("?") .groupEnd("?") @@ -72,30 +72,42 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { .compile(); private static final Pattern PATTERN_RFID = new PatternBuilder() - .number("|(dd)(dd)(dd),") // time - .number("(dd)(dd)(dd),") // Date (ddmmyy) - .number("(d+)(dd.d+),") // latitude + .number("|(dd)(dd)(dd),") // time + .number("(dd)(dd)(dd),") // Date (ddmmyy) + .number("(d+)(dd.d+),") // latitude .expression("([NS]),") - .number("(d+)(dd.d+),") // longitude + .number("(d+)(dd.d+),") // longitude .expression("([EW])") .compile(); private static final Pattern PATTERN_OBD = new PatternBuilder() - .number("(d+.d+),") // battery - .number("(d+),") // rpm - .number("(d+),") // speed - .number("(d+.d+),") // throttle - .number("(d+.d+),") // engine load - .number("(-?d+),") // coolant temp - .number("d+.d+,") // instantaneous fuel - .number("(d+.d+),") // average fuel - .number("(d+.d+),") // driving range - .number("(d+.?d*),") // odometer - .number("(d+.d+),") - .number("(d+.d+),") - .number("(d+),") // error code count - .number("d+,") // harsh acceleration count - .number("d+") // harsh break count + .number("(d+.d+),") // battery + .number("(d+),") // rpm + .number("(d+),") // speed + .number("(d+.d+),") // throttle + .number("(d+.d+),") // engine load + .number("(-?d+),") // coolant temp + .number("(d+.d+),") // instantaneous fuel + .number("(d+.d+),") // average fuel + .number("(d+.d+),") // driving range + .number("(d+.?d*),") // odometer + .number("(d+.d+),") // Single Fuel Consumption + .number("(d+.d+),") // Total Fuel Consumption + .number("(d+),") // error code count + .number("(d+),") // harsh acceleration count + .number("(d+)") // harsh break count + .compile(); + + private static final Pattern PATTERN_OBDA = new PatternBuilder() + .number("(d+),") // Total ignition + .number("(d+.d+),") // Total driving time + .number("(d+.d+),") // Total idling time + .number("(d+),") // Average hot start time + .number("(d+),") // Average speed + .number("(d+),") // history hightest speed + .number("(d+),") // history hightest rpm + .number("(d+),") // total harsh acceleration + .number("(d+)") // total harsh break n0 .compile(); public static final int MSG_HEARTBEAT = 0x0001; @@ -110,6 +122,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { public static final int MSG_RFID = 0x9966; public static final int MSG_OBD_RT = 0x9901; + public static final int MSG_OBD_RTA = 0x9902; private DeviceSession identify(ChannelBuffer buf, Channel channel, SocketAddress remoteAddress) { StringBuilder builder = new StringBuilder(); @@ -281,14 +294,37 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_RPM, parser.nextInt()); position.set(Position.KEY_OBD_SPEED, parser.nextInt()); position.set(Position.KEY_THROTTLE, parser.nextDouble()); - position.set("engineLoad", parser.nextDouble()); + position.set(Position.KEY_OBD_ENGINE_LOAD, parser.nextDouble()); position.set(Position.PREFIX_TEMP + 1, parser.nextInt()); position.set(Position.KEY_FUEL_CONSUMPTION, parser.nextDouble()); - position.set("drivingRange", parser.nextDouble() * 1000); - position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000); - position.set("singleFuelConsumption", parser.nextDouble()); - position.set("totalFuelConsumption", parser.nextDouble()); + position.set(Position.KEY_OBD_AVERAGE_FUEL, parser.nextDouble()); + position.set(Position.KEY_OBD_DRIVING_RANGE, parser.nextDouble()); + position.set(Position.KEY_ODOMETER, parser.nextDouble()); + position.set(Position.KEY_OBD_SINGLE_FUEL_CONSUMPTION, parser.nextDouble()); + position.set(Position.KEY_OBD_TOTAL_FUEL_CONSUMPTION, parser.nextDouble()); + position.set(Position.KEY_OBD_CURRENT_ERROR, parser.nextInt()); + position.set(Position.KEY_OBD_HARSH_ACCELERATION, parser.nextInt()); + position.set(Position.KEY_OBD_HARSH_BREAK, parser.nextInt()); + return position; + } + + private Position decodeObdA(Position position, String sentence) { + Parser parser = new Parser(PATTERN_OBDA, sentence); + if (!parser.matches()) { + return null; + } + + getLastLocation(position, null); + position.set(Position.KEY_OBD_TOTAL_IGNITION, parser.nextInt()); + position.set(Position.KEY_OBD_TOTAL_DRIVING_TIME, parser.nextDouble()); + position.set(Position.KEY_OBD_TOTAL_IDLING_TIME, parser.nextDouble()); + position.set(Position.KEY_OBD_AVERAGE_HOT_START, parser.nextInt()); + position.set(Position.KEY_OBD_AVERAGE_SPEED, parser.nextInt()); + position.set(Position.KEY_OBD_HISTORY_HIGHT_SPEED, parser.nextInt()); + position.set(Position.KEY_OBD_HISTORY_HIGHT_RPM, parser.nextInt()); + position.set(Position.KEY_OBD_TOTAL_HARSH_ACCELERATION, parser.nextInt()); + position.set(Position.KEY_OBD_TOTAL_HARSH_BRAKE, parser.nextInt()); return position; } @@ -305,11 +341,11 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { if (channel != null) { if (command == MSG_LOGIN) { - response = ChannelBuffers.wrappedBuffer(new byte[] {0x01}); + response = ChannelBuffers.wrappedBuffer(new byte[]{0x01}); sendResponse(channel, remoteAddress, id, MSG_LOGIN_RESPONSE, response); return null; } else if (command == MSG_HEARTBEAT) { - response = ChannelBuffers.wrappedBuffer(new byte[] {0x01}); + response = ChannelBuffers.wrappedBuffer(new byte[]{0x01}); sendResponse(channel, remoteAddress, id, MSG_HEARTBEAT, response); return null; } else if (command == MSG_SERVER) { @@ -353,6 +389,8 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { return decodeRfid(position, sentence); } else if (command == MSG_OBD_RT) { return decodeObd(position, sentence); + } else if (command == MSG_OBD_RTA) { + return decodeObdA(position, sentence); } return null; -- cgit v1.2.3 From fa90c985d9f569216ca4d7fa5d8be3421d9c1534 Mon Sep 17 00:00:00 2001 From: jose Date: Tue, 13 Dec 2016 09:03:08 +0100 Subject: Fix Meiligao Protocol to work with tk228 Fix the style issues --- src/org/traccar/model/Position.java | 19 ++++++- .../traccar/protocol/MeiligaoProtocolDecoder.java | 62 +++++++++++++++++----- .../protocol/MeiligaoProtocolDecoderTest.java | 2 +- 3 files changed, 68 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java index 8ca2588e2..3e8cb27bc 100644 --- a/src/org/traccar/model/Position.java +++ b/src/org/traccar/model/Position.java @@ -60,11 +60,26 @@ public class Position extends Message { 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_DTCS = "dtcs"; public static final String KEY_OBD_SPEED = "obdSpeed"; public static final String KEY_OBD_ODOMETER = "obdOdometer"; - + public static final String KEY_OBD_ENGINE_LOAD = "engineLoad"; + public static final String KEY_OBD_AVERAGE_FUEL = "averageFuelConsumition"; + public static final String KEY_OBD_DRIVING_RANGE = "drivingRange"; + public static final String KEY_OBD_SINGLE_FUEL_CONSUMPTION = "singleFuelConsumption"; + public static final String KEY_OBD_TOTAL_FUEL_CONSUMPTION = "totalFuelConsumption"; + public static final String KEY_OBD_CURRENT_ERROR = "currentError"; + public static final String KEY_OBD_HARSH_ACCELERATION = "harshAcelerationNo"; + public static final String KEY_OBD_HARSH_BREAK = "harshBreakerNo"; + public static final String KEY_OBD_TOTAL_IGNITION = "totalIgnitionNo"; + public static final String KEY_OBD_TOTAL_DRIVING_TIME = "totalDrivingTime"; + public static final String KEY_OBD_TOTAL_IDLING_TIME = "totalIdlingTime"; + public static final String KEY_OBD_AVERAGE_HOT_START = "averageHotStartTime"; + public static final String KEY_OBD_AVERAGE_SPEED = "averageSpeed"; + public static final String KEY_OBD_HISTORY_HIGHT_SPEED = "historyHightestSpeed"; + public static final String KEY_OBD_HISTORY_HIGHT_RPM = "historyHightestRPM"; + public static final String KEY_OBD_TOTAL_HARSH_ACCELERATION = "totalHarshAccerleration"; + public static final String KEY_OBD_TOTAL_HARSH_BRAKE = "totalHarshBrake"; public static final String KEY_RESULT = "result"; // Starts with 1 not 0 diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java index 9915eab8c..d3a3a2b3a 100644 --- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java +++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java @@ -87,15 +87,27 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { .number("(d+.d+),") // throttle .number("(d+.d+),") // engine load .number("(-?d+),") // coolant temp - .number("d+.d+,") // instantaneous fuel + .number("(d+.d+),") // instantaneous fuel .number("(d+.d+),") // average fuel .number("(d+.d+),") // driving range .number("(d+.?d*),") // odometer - .number("(d+.d+),") - .number("(d+.d+),") + .number("(d+.d+),") // Single Fuel Consumption + .number("(d+.d+),") // Total Fuel Consumption .number("(d+),") // error code count - .number("d+,") // harsh acceleration count - .number("d+") // harsh break count + .number("(d+),") // harsh acceleration count + .number("(d+)") // harsh break count + .compile(); + + private static final Pattern PATTERN_OBDA = new PatternBuilder() + .number("(d+),") // Total ignition + .number("(d+.d+),") // Total driving time + .number("(d+.d+),") // Total idling time + .number("(d+),") // Average hot start time + .number("(d+),") // Average speed + .number("(d+),") // history hightest speed + .number("(d+),") // history hightest rpm + .number("(d+),") // total harsh acceleration + .number("(d+)") // total harsh break n0 .compile(); public static final int MSG_HEARTBEAT = 0x0001; @@ -110,6 +122,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { public static final int MSG_RFID = 0x9966; public static final int MSG_OBD_RT = 0x9901; + public static final int MSG_OBD_RTA = 0x9902; private DeviceSession identify(ChannelBuffer buf, Channel channel, SocketAddress remoteAddress) { StringBuilder builder = new StringBuilder(); @@ -281,14 +294,37 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_RPM, parser.nextInt()); position.set(Position.KEY_OBD_SPEED, parser.nextInt()); position.set(Position.KEY_THROTTLE, parser.nextDouble()); - position.set("engineLoad", parser.nextDouble()); + position.set(Position.KEY_OBD_ENGINE_LOAD, parser.nextDouble()); position.set(Position.PREFIX_TEMP + 1, parser.nextInt()); position.set(Position.KEY_FUEL_CONSUMPTION, parser.nextDouble()); - position.set("drivingRange", parser.nextDouble() * 1000); - position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000); - position.set("singleFuelConsumption", parser.nextDouble()); - position.set("totalFuelConsumption", parser.nextDouble()); + position.set(Position.KEY_OBD_AVERAGE_FUEL, parser.nextDouble()); + position.set(Position.KEY_OBD_DRIVING_RANGE, parser.nextDouble()); + position.set(Position.KEY_ODOMETER, parser.nextDouble()); + position.set(Position.KEY_OBD_SINGLE_FUEL_CONSUMPTION, parser.nextDouble()); + position.set(Position.KEY_OBD_TOTAL_FUEL_CONSUMPTION, parser.nextDouble()); + position.set(Position.KEY_OBD_CURRENT_ERROR, parser.nextInt()); + position.set(Position.KEY_OBD_HARSH_ACCELERATION, parser.nextInt()); + position.set(Position.KEY_OBD_HARSH_BREAK, parser.nextInt()); + return position; + } + + private Position decodeObdA(Position position, String sentence) { + Parser parser = new Parser(PATTERN_OBDA, sentence); + if (!parser.matches()) { + return null; + } + + getLastLocation(position, null); + position.set(Position.KEY_OBD_TOTAL_IGNITION, parser.nextInt()); + position.set(Position.KEY_OBD_TOTAL_DRIVING_TIME, parser.nextDouble()); + position.set(Position.KEY_OBD_TOTAL_IDLING_TIME, parser.nextDouble()); + position.set(Position.KEY_OBD_AVERAGE_HOT_START, parser.nextInt()); + position.set(Position.KEY_OBD_AVERAGE_SPEED, parser.nextInt()); + position.set(Position.KEY_OBD_HISTORY_HIGHT_SPEED, parser.nextInt()); + position.set(Position.KEY_OBD_HISTORY_HIGHT_RPM, parser.nextInt()); + position.set(Position.KEY_OBD_TOTAL_HARSH_ACCELERATION, parser.nextInt()); + position.set(Position.KEY_OBD_TOTAL_HARSH_BRAKE, parser.nextInt()); return position; } @@ -305,11 +341,11 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { if (channel != null) { if (command == MSG_LOGIN) { - response = ChannelBuffers.wrappedBuffer(new byte[] {0x01}); + response = ChannelBuffers.wrappedBuffer(new byte[]{0x01}); sendResponse(channel, remoteAddress, id, MSG_LOGIN_RESPONSE, response); return null; } else if (command == MSG_HEARTBEAT) { - response = ChannelBuffers.wrappedBuffer(new byte[] {0x01}); + response = ChannelBuffers.wrappedBuffer(new byte[]{0x01}); sendResponse(channel, remoteAddress, id, MSG_HEARTBEAT, response); return null; } else if (command == MSG_SERVER) { @@ -353,6 +389,8 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { return decodeRfid(position, sentence); } else if (command == MSG_OBD_RT) { return decodeObd(position, sentence); + } else if (command == MSG_OBD_RTA) { + return decodeObdA(position, sentence); } return null; diff --git a/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java b/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java index 10fa3f971..fb1c44bb7 100644 --- a/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java +++ b/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java @@ -17,7 +17,7 @@ public class MeiligaoProtocolDecoderTest extends ProtocolTest { "2424007d0000000000000099553231303333302e3030302c562c343533342e333832342c532c30373230332e303630302c572c302e30302c302c3231313031362c2c2a31327c302e307c3332397c323030307c303030452c303030437c303244413030303145413634393541417c31307c30303030303030306e540d0a")); verifyAttributes(decoder, binary( - "4040005066104020094432990131302E312C302C3135362C302E30302C31392E36312C2D33342C33342E32362C32312E38332C372E39312C313033332C322E36392C362E35352C302C302C309DBF0D0A")); + "2424005066104020094432990131302E312C302C3135362C302E30302C31392E36312C2D33342C33342E32362C32312E38332C372E39312C313033332C322E36392C362E35352C302C302C309DBF0D0A")); verifyPosition(decoder, binary( "242400746251103044ffff99553033353033392e3939392c412c323832332e373632312c4e2c31303635322e303730342c572c3030302e302c3030302e302c3136303631362c2c2c412a37357c302e397c323038332e327c303030307c303030302c303030307c31303034333736333265780d0a")); -- cgit v1.2.3 From d9e0b44ed13f9dd1aac96551555191283e45e020 Mon Sep 17 00:00:00 2001 From: jose Date: Fri, 16 Dec 2016 17:41:39 +0100 Subject: Fix Meiligao Protocol to work with tk228 --- src/org/traccar/model/Position.java | 18 ++---------- .../traccar/protocol/MeiligaoProtocolDecoder.java | 32 +++++++++++----------- .../protocol/MeiligaoProtocolDecoderTest.java | 5 +++- 3 files changed, 22 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java index 49a304df7..8ca2588e2 100644 --- a/src/org/traccar/model/Position.java +++ b/src/org/traccar/model/Position.java @@ -60,25 +60,11 @@ public class Position extends Message { 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_DTCS = "dtcs"; public static final String KEY_OBD_SPEED = "obdSpeed"; public static final String KEY_OBD_ODOMETER = "obdOdometer"; - public static final String KEY_OBD_ENGINE_LOAD = "engineLoad"; - public static final String KEY_OBD_AVERAGE_FUEL = "averageFuelConsumition"; - public static final String KEY_OBD_DRIVING_RANGE = "drivingRange"; - public static final String KEY_OBD_SINGLE_FUEL_CONSUMPTION = "singleFuelConsumption"; - public static final String KEY_OBD_TOTAL_FUEL_CONSUMPTION = "totalFuelConsumption"; - public static final String KEY_OBD_HARSH_ACCELERATION = "harshAcelerationNo"; - public static final String KEY_OBD_HARSH_BREAK = "harshBreakerNo"; - public static final String KEY_OBD_TOTAL_IGNITION = "totalIgnitionNo"; - public static final String KEY_OBD_TOTAL_DRIVING_TIME = "totalDrivingTime"; - public static final String KEY_OBD_TOTAL_IDLING_TIME = "totalIdlingTime"; - public static final String KEY_OBD_AVERAGE_HOT_START = "averageHotStartTime"; - public static final String KEY_OBD_AVERAGE_SPEED = "averageSpeed"; - public static final String KEY_OBD_HISTORY_HIGHT_SPEED = "historyHightestSpeed"; - public static final String KEY_OBD_HISTORY_HIGHT_RPM = "historyHightestRPM"; - public static final String KEY_OBD_TOTAL_HARSH_ACCELERATION = "totalHarshAccerleration"; - public static final String KEY_OBD_TOTAL_HARSH_BRAKE = "totalHarshBrake"; + public static final String KEY_RESULT = "result"; // Starts with 1 not 0 diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java index 3d57eecfd..706655b83 100644 --- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java +++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java @@ -292,17 +292,17 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_RPM, parser.nextInt()); position.set(Position.KEY_OBD_SPEED, parser.nextInt()); position.set(Position.KEY_THROTTLE, parser.nextDouble()); - position.set(Position.KEY_OBD_ENGINE_LOAD, parser.nextDouble()); + position.set("engineLoad", parser.nextDouble()); position.set(Position.PREFIX_TEMP + 1, parser.nextInt()); position.set(Position.KEY_FUEL_CONSUMPTION, parser.nextDouble()); - position.set(Position.KEY_OBD_AVERAGE_FUEL, parser.nextDouble()); - position.set(Position.KEY_OBD_DRIVING_RANGE, parser.nextDouble()); + position.set("averageFuelConsumition", parser.nextDouble()); + position.set("drivingRange", parser.nextDouble()); position.set(Position.KEY_ODOMETER, parser.nextDouble()); - position.set(Position.KEY_OBD_SINGLE_FUEL_CONSUMPTION, parser.nextDouble()); - position.set(Position.KEY_OBD_TOTAL_FUEL_CONSUMPTION, parser.nextDouble()); + position.set("singleFuelConsumption", parser.nextDouble()); + position.set("totalFuelConsumption", parser.nextDouble()); position.set(Position.KEY_DTCS, parser.nextInt()); - position.set(Position.KEY_OBD_HARSH_ACCELERATION, parser.nextInt()); - position.set(Position.KEY_OBD_HARSH_BREAK, parser.nextInt()); + position.set("harshAcelerationNo", parser.nextInt()); + position.set("harshBreakerNo", parser.nextInt()); return position; } @@ -314,15 +314,15 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { getLastLocation(position, null); - position.set(Position.KEY_OBD_TOTAL_IGNITION, parser.nextInt()); - position.set(Position.KEY_OBD_TOTAL_DRIVING_TIME, parser.nextDouble()); - position.set(Position.KEY_OBD_TOTAL_IDLING_TIME, parser.nextDouble()); - position.set(Position.KEY_OBD_AVERAGE_HOT_START, parser.nextInt()); - position.set(Position.KEY_OBD_AVERAGE_SPEED, parser.nextInt()); - position.set(Position.KEY_OBD_HISTORY_HIGHT_SPEED, parser.nextInt()); - position.set(Position.KEY_OBD_HISTORY_HIGHT_RPM, parser.nextInt()); - position.set(Position.KEY_OBD_TOTAL_HARSH_ACCELERATION, parser.nextInt()); - position.set(Position.KEY_OBD_TOTAL_HARSH_BRAKE, parser.nextInt()); + position.set("totalIgnitionNo", parser.nextInt()); + position.set("totalDrivingTime", parser.nextDouble()); + position.set("totalIdlingTime", parser.nextDouble()); + position.set("averageHotStartTime", parser.nextInt()); + position.set("averageSpeed", parser.nextInt()); + position.set("historyHightestSpeed", parser.nextInt()); + position.set("historyHightestRPM", parser.nextInt()); + position.set("totalHarshAccerleration", parser.nextInt()); + position.set("totalHarshBrake", parser.nextInt()); return position; } diff --git a/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java b/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java index 81910d42c..0633a6291 100644 --- a/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java +++ b/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java @@ -17,7 +17,10 @@ public class MeiligaoProtocolDecoderTest extends ProtocolTest { "2424007d0000000000000099553231303333302e3030302c562c343533342e333832342c532c30373230332e303630302c572c302e30302c302c3231313031362c2c2a31327c302e307c3332397c323030307c303030452c303030437c303244413030303145413634393541417c31307c30303030303030306e540d0a")); verifyAttributes(decoder, binary( - "242400736610402421174399553132343334342e3937382c412c333933342e313838302c4e2c30303234302e363231302c452c303030302c3030302c3038313231362c2c2a31437c31312e357c3139347c313030317c303344462c303030307c30303131323030307c30303030303068320d0a2424004c66104024211743990131342e302c3934352c302c31332e33332c322e37352c36392c312e32302c382e31302c302e36382c3131322c302e30382c392e39312c302c312c3040f70d0a2424003266104024211743990232362c322e35342c302e38302c32322c34342c3131392c333735362c37382c31366fc20d0a")); + "4040005066104020094432990131302E312C302C3135362C302E30302C31392E36312C2D33342C33342E32362C32312E38332C372E39312C313033332C322E36392C362E35352C302C302C309DBF0D0A")); + + verifyAttributes(decoder, binary( + "242400736610402421174399553130353033342e3937382c412c333933352e333638392c4e2c30303233382e313638342c452c303034382c3034322c3038313231362c2c2a31437c31312e357c3139347c313030317c303341362c303030307c30303130343030307c3030303030303cd00d0a2424004e66104024211743990131342e312c323638372c39302c32312e35372c342e37312c38352c372e31302c382e31362c342e32372c3130342c302e33342c392e33342c302c312c30b7160d0a2424003266104024211743990232352c322e34302c302e37392c32322c34332c3131392c333735362c37352c3132e4c90d0a")); verifyPosition(decoder, binary( "242400746251103044ffff99553033353033392e3939392c412c323832332e373632312c4e2c31303635322e303730342c572c3030302e302c3030302e302c3136303631362c2c2c412a37357c302e397c323038332e327c303030307c303030302c303030307c31303034333736333265780d0a")); -- cgit v1.2.3