From a51e0dcf72973054da8abd45296498d6664484e9 Mon Sep 17 00:00:00 2001 From: cz-vilda Date: Wed, 10 May 2017 23:56:56 +0200 Subject: Extend xexun protocol - kn and kmh Updated xexun protocol to be able to use kmh as source speed. --- src/org/traccar/protocol/XexunProtocolDecoder.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java index 4d44c2326..303864c3f 100644 --- a/src/org/traccar/protocol/XexunProtocolDecoder.java +++ b/src/org/traccar/protocol/XexunProtocolDecoder.java @@ -109,7 +109,16 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder { position.setValid(parser.next().equals("A")); position.setLatitude(parser.nextCoordinate()); position.setLongitude(parser.nextCoordinate()); - position.setSpeed(parser.nextDouble(0)); + + switch (Context.getConfig().getString(getProtocolName() + ".speed", "kn")) { + case "kmh": + position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0))); + break; + default: + position.setSpeed(parser.nextDouble(0)); + break; + } + position.setCourse(parser.nextDouble(0)); dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0)); -- cgit v1.2.3 From 302af32e85586bd3d609aa73230dd9fae0884b86 Mon Sep 17 00:00:00 2001 From: cz-vilda Date: Thu, 11 May 2017 16:12:52 +0200 Subject: Fix error --- src/org/traccar/protocol/XexunProtocolDecoder.java | 1 + 1 file changed, 1 insertion(+) (limited to 'src/org/traccar') diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java index 303864c3f..d3a71af5b 100644 --- a/src/org/traccar/protocol/XexunProtocolDecoder.java +++ b/src/org/traccar/protocol/XexunProtocolDecoder.java @@ -22,6 +22,7 @@ import org.traccar.helper.DateBuilder; import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; import org.traccar.model.Position; +import org.traccar.helper.UnitsConverter; import java.net.SocketAddress; import java.util.regex.Pattern; -- cgit v1.2.3 From 48d43ff2b9bb35515e96527bb55b48498dd77dcf Mon Sep 17 00:00:00 2001 From: cz-vilda Date: Thu, 11 May 2017 16:23:13 +0200 Subject: again... --- src/org/traccar/protocol/XexunProtocolDecoder.java | 1 + 1 file changed, 1 insertion(+) (limited to 'src/org/traccar') diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java index d3a71af5b..2b31f414e 100644 --- a/src/org/traccar/protocol/XexunProtocolDecoder.java +++ b/src/org/traccar/protocol/XexunProtocolDecoder.java @@ -17,6 +17,7 @@ package org.traccar.protocol; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; +import org.traccar.Context; import org.traccar.DeviceSession; import org.traccar.helper.DateBuilder; import org.traccar.helper.Parser; -- cgit v1.2.3