aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorjon-stumpf <jon.stumpf@gmail.com>2017-02-25 18:33:39 -0500
committerjon-stumpf <jon.stumpf@gmail.com>2017-02-25 18:33:39 -0500
commit7152670b20a40de809db57ae21acb73c5ad5bea5 (patch)
treebb80685d7453fe13af26b18dacfb89d2293ebeac /src/org/traccar/protocol
parent0bc1784f51311a9c5f4b37423c88ec54b970fa01 (diff)
downloadtrackermap-server-7152670b20a40de809db57ae21acb73c5ad5bea5.tar.gz
trackermap-server-7152670b20a40de809db57ae21acb73c5ad5bea5.tar.bz2
trackermap-server-7152670b20a40de809db57ae21acb73c5ad5bea5.zip
Reduced the size of TotemProtocolDecoder.decode() to meet checkstyle restrictions;
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/TotemProtocolDecoder.java21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java
index 3f8d66a2b..86ee09d95 100644
--- a/src/org/traccar/protocol/TotemProtocolDecoder.java
+++ b/src/org/traccar/protocol/TotemProtocolDecoder.java
@@ -218,11 +218,11 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ALARM, decodeAlarm(Short.parseShort(parser.next(), 16)));
}
DateBuilder dateBuilder = new DateBuilder();
- int year = 0;
+ int year = 0, month = 0, day = 0;
if (pattern == PATTERN2) {
- dateBuilder.setDay(parser.nextInt()).setMonth(parser.nextInt());
- year = parser.nextInt();
- dateBuilder.setYear(year);
+ day = parser.nextInt();
+ month = parser.nextInt();
+ year = parser.nextInt();
}
dateBuilder.setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
@@ -233,13 +233,14 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
position.setCourse(parser.nextDouble());
if (pattern == PATTERN1) {
- dateBuilder.setDay(parser.nextInt()).setMonth(parser.nextInt());
- year = parser.nextInt();
- dateBuilder.setYear(year);
+ day = parser.nextInt();
+ month = parser.nextInt();
+ year = parser.nextInt();
}
if (year == 0) {
return null; // ignore invalid data
}
+ dateBuilder.setDate(year, month, day);
position.setTime(dateBuilder.getDate());
if (pattern == PATTERN1) {
@@ -286,19 +287,15 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
position.setValid(parser.next().equals("A"));
position.set(Position.KEY_SATELLITES, parser.next());
-
position.setCourse(parser.nextDouble());
position.setSpeed(parser.nextDouble());
-
position.set("pdop", parser.next());
-
position.set(Position.KEY_ODOMETER, parser.next());
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
} else if (pattern == PATTERN4) {
-
position.set(Position.KEY_STATUS, parser.next());
DateBuilder dateBuilder = new DateBuilder()
@@ -323,14 +320,12 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
position.setCourse(parser.nextDouble());
position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
-
position.set(Position.KEY_HDOP, parser.nextDouble());
position.set(Position.KEY_ODOMETER, parser.nextInt() * 1000);
position.setValid(true);
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
-
}
if (channel != null) {
channel.write("ACK OK\r\n");