aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-04-26 17:06:43 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2017-04-26 17:07:00 +1200
commit1f3185d8a06f5d8cd3c05c15cbb7abbbfa81af37 (patch)
treef45f77fc14943215dd6112bf10decd7e5cb90ee9 /src/org
parent1669e9c453f6bf2add655bbb2cf48b68bbbfb503 (diff)
downloadtrackermap-server-1f3185d8a06f5d8cd3c05c15cbb7abbbfa81af37.tar.gz
trackermap-server-1f3185d8a06f5d8cd3c05c15cbb7abbbfa81af37.tar.bz2
trackermap-server-1f3185d8a06f5d8cd3c05c15cbb7abbbfa81af37.zip
Implement additional Xirgo attributes
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/helper/Parser.java8
-rw-r--r--src/org/traccar/helper/UnitsConverter.java9
-rw-r--r--src/org/traccar/protocol/XirgoProtocolDecoder.java39
3 files changed, 53 insertions, 3 deletions
diff --git a/src/org/traccar/helper/Parser.java b/src/org/traccar/helper/Parser.java
index 69c80adb2..582b497cf 100644
--- a/src/org/traccar/helper/Parser.java
+++ b/src/org/traccar/helper/Parser.java
@@ -121,6 +121,14 @@ public class Parser {
}
}
+ public Double nextDouble() {
+ if (hasNext()) {
+ return Double.parseDouble(next());
+ } else {
+ return null;
+ }
+ }
+
public double nextDouble(double defaultValue) {
if (hasNext()) {
return Double.parseDouble(next());
diff --git a/src/org/traccar/helper/UnitsConverter.java b/src/org/traccar/helper/UnitsConverter.java
index e0d94c6dc..56d15e4e7 100644
--- a/src/org/traccar/helper/UnitsConverter.java
+++ b/src/org/traccar/helper/UnitsConverter.java
@@ -22,6 +22,7 @@ public final class UnitsConverter {
private static final double KNOTS_TO_MPS_RATIO = 1.94384;
private static final double KNOTS_TO_CPS_RATIO = 0.0194384449;
private static final double METERS_TO_FEET_RATIO = 0.3048;
+ private static final double METERS_TO_MILE_RATIO = 1609.34;
private UnitsConverter() {
}
@@ -62,4 +63,12 @@ public final class UnitsConverter {
return value * METERS_TO_FEET_RATIO;
}
+ public static double milesFromMeters(double value) {
+ return value / METERS_TO_MILE_RATIO;
+ }
+
+ public static double metersFromMiles(double value) {
+ return value * METERS_TO_MILE_RATIO;
+ }
+
}
diff --git a/src/org/traccar/protocol/XirgoProtocolDecoder.java b/src/org/traccar/protocol/XirgoProtocolDecoder.java
index c6d4b6978..77327e001 100644
--- a/src/org/traccar/protocol/XirgoProtocolDecoder.java
+++ b/src/org/traccar/protocol/XirgoProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -75,6 +75,23 @@ public class XirgoProtocolDecoder extends BaseProtocolDecoder {
.number("(d+.d+),") // battery
.number("(d+),") // gsm
.number("(d+),") // gps
+ .groupBegin()
+ .number("d,") // reset mode
+ .expression("([01])") // input 1
+ .expression("([01])") // input 1
+ .expression("([01])") // input 1
+ .expression("([01]),") // output 1
+ .number("(d+.?d*),") // adc 1
+ .number("(d+.?d*),") // fuel level
+ .number("d+,") // engine load
+ .number("(d+),") // engine hours
+ .number("(d+),") // oil pressure
+ .number("(d+),") // oil level
+ .number("(-?d+),") // oil temperature
+ .number("(d+),") // coolant pressure
+ .number("(d+),") // coolant level
+ .number("(-?d+)") // coolant temperature
+ .groupEnd("?")
.any()
.compile();
@@ -131,7 +148,7 @@ public class XirgoProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_HDOP, parser.next());
if (newFormat) {
- position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1609.34);
+ position.set(Position.KEY_ODOMETER, UnitsConverter.metersFromMiles(parser.nextDouble(0)));
position.set(Position.KEY_FUEL_CONSUMPTION, parser.next());
}
@@ -139,11 +156,27 @@ public class XirgoProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_RSSI, parser.next());
if (!newFormat) {
- position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1609.34);
+ position.set(Position.KEY_ODOMETER, UnitsConverter.metersFromMiles(parser.nextDouble(0)));
}
position.setValid(parser.nextInt(0) == 1);
+ if (newFormat && parser.hasNext(13)) {
+ position.set(Position.PREFIX_IN + 1, parser.nextInt());
+ position.set(Position.PREFIX_IN + 2, parser.nextInt());
+ position.set(Position.PREFIX_IN + 3, parser.nextInt());
+ position.set(Position.PREFIX_OUT + 1, parser.nextInt());
+ position.set(Position.PREFIX_ADC + 1, parser.nextDouble());
+ position.set(Position.KEY_FUEL_LEVEL, parser.nextDouble());
+ position.set(Position.KEY_HOURS, parser.nextInt());
+ position.set("oilPressure", parser.nextInt());
+ position.set("oilLevel", parser.nextInt());
+ position.set("oilTemp", parser.nextInt());
+ position.set("coolantPressure", parser.nextInt());
+ position.set("coolantLevel", parser.nextInt());
+ position.set("coolantTemp", parser.nextInt());
+ }
+
return position;
}