aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-01-23 20:49:19 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2019-01-23 20:49:19 -0800
commit364ee0cdf23dd6d63714b8fb118ad87b850f99c3 (patch)
treef4f977746ec144ba5adee173161c4f19e48c7561 /src/org/traccar
parent9ca14dcccffc65b9c4c2683bc53e13b796fa1228 (diff)
downloadtraccar-server-364ee0cdf23dd6d63714b8fb118ad87b850f99c3.tar.gz
traccar-server-364ee0cdf23dd6d63714b8fb118ad87b850f99c3.tar.bz2
traccar-server-364ee0cdf23dd6d63714b8fb118ad87b850f99c3.zip
Extend VTFMS protocol support
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/VtfmsProtocolDecoder.java25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/org/traccar/protocol/VtfmsProtocolDecoder.java b/src/org/traccar/protocol/VtfmsProtocolDecoder.java
index c08261a59..17fac4311 100644
--- a/src/org/traccar/protocol/VtfmsProtocolDecoder.java
+++ b/src/org/traccar/protocol/VtfmsProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2019 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.
@@ -60,7 +60,7 @@ public class VtfmsProtocolDecoder extends BaseProtocolDecoder {
.number("(d+.d+),") // power voltage
.number("[^,]*,") // reserved
.number("(d+)?,") // fuel level
- .number("(d+.d+),") // adc 1
+ .number("(d+.d+)?,") // adc 1
.number("[^,]*,") // reserved
.number("(d+.d+)?,") // adc 2
.expression("([01]),") // di 1
@@ -93,6 +93,11 @@ public class VtfmsProtocolDecoder extends BaseProtocolDecoder {
}
}
+ private double convertToDegrees(double value) {
+ double degrees = Math.floor(value / 100);
+ return degrees + (value - degrees * 100) / 60;
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -116,12 +121,18 @@ public class VtfmsProtocolDecoder extends BaseProtocolDecoder {
position.setValid(parser.next().equals("A"));
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.HMS_DMY));
- position.setLatitude(parser.nextDouble(0));
- position.setLongitude(parser.nextDouble(0));
- if (parser.hasNext()) {
- position.setCourse(parser.nextDouble(0));
+ double latitude = parser.nextDouble();
+ double longitude = parser.nextDouble();
+ if (Math.abs(latitude) > 90 || Math.abs(longitude) > 180) {
+ position.setLatitude(convertToDegrees(latitude));
+ position.setLongitude(convertToDegrees(longitude));
+ } else {
+ position.setLatitude(latitude);
+ position.setLongitude(longitude);
}
+
+ position.setCourse(parser.nextDouble(0));
if (parser.hasNext()) {
String direction = parser.next();
for (int i = 0; i < DIRECTIONS.length; i++) {
@@ -132,7 +143,7 @@ public class VtfmsProtocolDecoder extends BaseProtocolDecoder {
}
}
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
position.set(Position.KEY_HOURS, UnitsConverter.msFromHours(parser.nextInt()));
position.set("idleHours", parser.nextInt());