aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/TaipProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol/TaipProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/TaipProtocolDecoder.java22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/org/traccar/protocol/TaipProtocolDecoder.java b/src/org/traccar/protocol/TaipProtocolDecoder.java
index 252f4e712..180be3268 100644
--- a/src/org/traccar/protocol/TaipProtocolDecoder.java
+++ b/src/org/traccar/protocol/TaipProtocolDecoder.java
@@ -16,7 +16,7 @@
package org.traccar.protocol;
import java.net.SocketAddress;
-import java.util.Calendar;
+import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
import java.util.regex.Matcher;
@@ -29,7 +29,7 @@ import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
public class TaipProtocolDecoder extends BaseProtocolDecoder {
-
+
private final boolean sendResponse;
public TaipProtocolDecoder(TaipProtocol protocol, boolean sendResponse) {
@@ -65,18 +65,18 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
return new Date(millis);
}
-
+
private Date getTime(long seconds) {
Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
time.set(Calendar.HOUR_OF_DAY, 0);
time.set(Calendar.MINUTE, 0);
time.set(Calendar.SECOND, 0);
time.set(Calendar.MILLISECOND, 0);
-
+
long millis = time.getTimeInMillis() + seconds * 1000;
-
+
long diff = System.currentTimeMillis() - millis;
-
+
if (diff > 12 * 60 * 60 * 1000) {
millis += 24 * 60 * 60 * 1000;
} else if (diff < -12 * 60 * 60 * 1000) {
@@ -85,14 +85,14 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
return new Date(millis);
}
-
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg)
throws Exception {
String sentence = (String) msg;
-
+
// Find message start
int beginIndex = sentence.indexOf('>');
if (beginIndex != -1) {
@@ -134,7 +134,7 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(getDeviceId());
Integer index = 1;
-
+
// Time
String week = parser.group(index++);
String day = parser.group(index++);
@@ -167,11 +167,11 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
String longitude = parser.group(index) + '.' + parser.group(index + 1);
index += 2;
position.setLongitude(Double.valueOf(longitude));
-
+
// Speed and Course
position.setSpeed(UnitsConverter.knotsFromMph(Double.valueOf(parser.group(index++))));
position.setCourse(Double.valueOf(parser.group(index++)));
-
+
// Validity
position.setValid(Integer.valueOf(parser.group(index++)) != 0);
return position;