aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/database/DataManager.java4
-rw-r--r--src/org/traccar/protocol/TramigoProtocolDecoder.java7
-rw-r--r--test/org/traccar/protocol/TramigoProtocolDecoderTest.java12
3 files changed, 18 insertions, 5 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index 17c1299e8..b7d3cb1e4 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -419,9 +419,9 @@ public class DataManager {
}
}
- public static String makeNameId(Class<?> clazz) {
+ private static String makeNameId(Class<?> clazz) {
String name = clazz.getSimpleName();
- return Introspector.decapitalize(name) + (name.indexOf("Id") == -1 ? "Id" : "");
+ return Introspector.decapitalize(name) + (!name.contains("Id") ? "Id" : "");
}
public Collection<Permission> getPermissions(Class<? extends BaseModel> owner, Class<? extends BaseModel> property)
diff --git a/src/org/traccar/protocol/TramigoProtocolDecoder.java b/src/org/traccar/protocol/TramigoProtocolDecoder.java
index b39e3eab1..b1e28e17d 100644
--- a/src/org/traccar/protocol/TramigoProtocolDecoder.java
+++ b/src/org/traccar/protocol/TramigoProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2014 - 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.
@@ -130,12 +130,13 @@ public class TramigoProtocolDecoder extends BaseProtocolDecoder {
position.setSpeed(UnitsConverter.knotsFromKph(Double.parseDouble(matcher.group(2))));
}
- pattern = Pattern.compile("(\\d{1,2}:\\d{2} \\w{3} \\d{1,2})");
+ pattern = Pattern.compile("(\\d{1,2}:\\d{2}(:\\d{2})? \\w{3} \\d{1,2})");
matcher = pattern.matcher(sentence);
if (!matcher.find()) {
return null;
}
- DateFormat dateFormat = new SimpleDateFormat("HH:mm MMM d yyyy", Locale.ENGLISH);
+ DateFormat dateFormat = new SimpleDateFormat(
+ matcher.group(2) != null ? "HH:mm:ss MMM d yyyy" : "HH:mm MMM d yyyy", Locale.ENGLISH);
position.setTime(DateUtil.correctYear(
dateFormat.parse(matcher.group(1) + " " + Calendar.getInstance().get(Calendar.YEAR))));
diff --git a/test/org/traccar/protocol/TramigoProtocolDecoderTest.java b/test/org/traccar/protocol/TramigoProtocolDecoderTest.java
index 96f795172..5e1f09543 100644
--- a/test/org/traccar/protocol/TramigoProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/TramigoProtocolDecoderTest.java
@@ -12,6 +12,18 @@ public class TramigoProtocolDecoderTest extends ProtocolTest {
TramigoProtocolDecoder decoder = new TramigoProtocolDecoder(new TramigoProtocol());
+ verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "8000c426b000a6000101c557037598050d5c8a595472616d69676f3a204d6f76696e672c20302e3132206b6d2045206f66204c617275742054696e2049736c616d6963205072696d617279205363686f6f6c2c2054616970696e672c20506572616b2c204d592c20342e38333134392c203130302e37333038352c204e572077697468207370656564203130206b6d2f682c2030303a34393a30382041756720392020454f46"));
+
+ verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "8000c526b000a6000101f17d03759805115c8a595472616d69676f3a204d6f76696e672c20302e3133206b6d205345206f66204c617275742054696e2049736c616d6963205072696d617279205363686f6f6c2c2054616970696e672c20506572616b2c204d592c20342e38333132322c203130302e37333037382c204e4520776974682073706565642039206b6d2f682c2030303a34383a35332041756720392020454f46"));
+
+ verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "8000d426b0009f00010184f20375980593638a595472616d69676f3a204d6f76696e672c20302e3039206b6d204e57206f66204a616c616e2053696d70616e672042617475204d61726b65742c2054616970696e672c20506572616b2c204d592c20342e38333034332c203130302e37323230342c20532077697468207370656564203130206b6d2f682c2030313a32313a31322041756720392020454f46"));
+
+ verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "8000d626b0007f0001013c0b037598051d648a595472616d69676f3a2053746f707065642c206174204a616c616e2053696d70616e672042617475204d61726b65742c2054616970696e672c20506572616b2c204d592c20342e38323937322c203130302e37323233322c2030313a32323a34342041756720392020454f46"));
+
verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
"80003d1ac0001c00010100000367152b13bc1d5970696e6720454f46"));