aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/SupermateProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-04-17 16:32:02 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2017-04-17 16:32:02 +1200
commit1c756c57653b72a656407da9c53ac292c5551cdb (patch)
tree69e88e24aae184508ab51932ef2692ae9515eef2 /src/org/traccar/protocol/SupermateProtocolDecoder.java
parent4ab007201bd177a2fbf46a90b7b73262c5792caf (diff)
downloadtrackermap-server-1c756c57653b72a656407da9c53ac292c5551cdb.tar.gz
trackermap-server-1c756c57653b72a656407da9c53ac292c5551cdb.tar.bz2
trackermap-server-1c756c57653b72a656407da9c53ac292c5551cdb.zip
Allow optional primitives
Diffstat (limited to 'src/org/traccar/protocol/SupermateProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/SupermateProtocolDecoder.java28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/org/traccar/protocol/SupermateProtocolDecoder.java b/src/org/traccar/protocol/SupermateProtocolDecoder.java
index 17e870950..d9b58a7f4 100644
--- a/src/org/traccar/protocol/SupermateProtocolDecoder.java
+++ b/src/org/traccar/protocol/SupermateProtocolDecoder.java
@@ -19,6 +19,7 @@ import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.model.Position;
@@ -79,28 +80,31 @@ public class SupermateProtocolDecoder extends BaseProtocolDecoder {
position.setValid(parser.next().equals("A"));
- position.setTime(parser.nextDateTime(16));
+ DateBuilder dateBuilder = new DateBuilder()
+ .setDate(parser.nextHexInt(0), parser.nextHexInt(0), parser.nextHexInt(0))
+ .setTime(parser.nextHexInt(0), parser.nextHexInt(0), parser.nextHexInt(0));
+ position.setTime(dateBuilder.getDate());
- if (parser.nextInt(16) == 8) {
- position.setLatitude(-parser.nextInt(16) / 600000.0);
+ if (parser.nextHexInt(0) == 8) {
+ position.setLatitude(-parser.nextHexInt(0) / 600000.0);
} else {
- position.setLatitude(parser.nextInt(16) / 600000.0);
+ position.setLatitude(parser.nextHexInt(0) / 600000.0);
}
- if (parser.nextInt(16) == 8) {
- position.setLongitude(-parser.nextInt(16) / 600000.0);
+ if (parser.nextHexInt(0) == 8) {
+ position.setLongitude(-parser.nextHexInt(0) / 600000.0);
} else {
- position.setLongitude(parser.nextInt(16) / 600000.0);
+ position.setLongitude(parser.nextHexInt(0) / 600000.0);
}
- position.setSpeed(parser.nextInt(16) / 100.0);
- position.setCourse(parser.nextInt(16) / 100.0);
+ position.setSpeed(parser.nextHexInt(0) / 100.0);
+ position.setCourse(parser.nextHexInt(0) / 100.0);
position.set(Position.KEY_STATUS, parser.next());
position.set("signal", parser.next());
- position.set(Position.KEY_POWER, parser.nextDouble());
- position.set("oil", parser.nextInt(16));
- position.set(Position.KEY_ODOMETER, parser.nextInt(16));
+ position.set(Position.KEY_POWER, parser.nextDouble(0));
+ position.set("oil", parser.nextHexInt(0));
+ position.set(Position.KEY_ODOMETER, parser.nextHexInt(0));
if (channel != null) {
Calendar calendar = Calendar.getInstance();