aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorjose <joseantonio@grdar.es>2016-12-13 09:03:08 +0100
committerjose <joseantonio@grdar.es>2016-12-13 09:03:08 +0100
commitedcfdea3e0be9b766100cdf3d3e97655aafcf091 (patch)
tree9b8e8e37c98fb242b92048260eab4a3e7c718d0e /src/org
parent4557cf912fada1dc249333aa05215b0116b8ebab (diff)
downloadtrackermap-server-edcfdea3e0be9b766100cdf3d3e97655aafcf091.tar.gz
trackermap-server-edcfdea3e0be9b766100cdf3d3e97655aafcf091.tar.bz2
trackermap-server-edcfdea3e0be9b766100cdf3d3e97655aafcf091.zip
Fix Meiligao Protocol to work with tk228
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/protocol/MeiligaoProtocolDecoder.java47
1 files changed, 41 insertions, 6 deletions
diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
index 9915eab8c..4623d0610 100644
--- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
@@ -87,17 +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+),") // 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;
public static final int MSG_SERVER = 0x0002;
public static final int MSG_LOGIN = 0x5000;
@@ -110,6 +120,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();
@@ -284,11 +295,33 @@ 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("drivingRange", parser.nextDouble() * 1000);
- position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
+ position.set("averageFuelConsumition", parser.nextDouble());
+ position.set("drivingRange", 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());
+ 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("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());
return position;
}
@@ -353,6 +386,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;