aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/model/Position.java19
-rw-r--r--src/org/traccar/protocol/MeiligaoProtocolDecoder.java131
2 files changed, 84 insertions, 66 deletions
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 4623d0610..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,42 +72,44 @@ 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
+ .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;
public static final int MSG_SERVER = 0x0002;
public static final int MSG_LOGIN = 0x5000;
@@ -292,36 +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("averageFuelConsumition", parser.nextDouble());
- position.set("drivingRange", 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("singleFuelConsumption", parser.nextDouble());
- position.set("totalFuelConsumption", parser.nextDouble());
- position.set("currentError", parser.nextInt());
- position.set("harshAcelerationNo", parser.nextInt());
- position.set("harshBreakerNo", parser.nextInt());
+ 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);
+ Parser parser = new Parser(PATTERN_OBDA, sentence);
if (!parser.matches()) {
return null;
}
getLastLocation(position, null);
- 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("totalHarsshBrake", parser.nextInt());
+ 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;
}
@@ -338,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) {