aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/TotemProtocolDecoder.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/TotemProtocolDecoder.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/TotemProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/TotemProtocolDecoder.java56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java
index 54eb2b5a5..d2ceebde9 100644
--- a/src/org/traccar/protocol/TotemProtocolDecoder.java
+++ b/src/org/traccar/protocol/TotemProtocolDecoder.java
@@ -220,22 +220,22 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
DateBuilder dateBuilder = new DateBuilder();
int year = 0, month = 0, day = 0;
if (pattern == PATTERN2) {
- day = parser.nextInt();
- month = parser.nextInt();
- year = parser.nextInt();
+ day = parser.nextInt(0);
+ month = parser.nextInt(0);
+ year = parser.nextInt(0);
}
- dateBuilder.setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
if (pattern == PATTERN1) {
- day = parser.nextInt();
- month = parser.nextInt();
- year = parser.nextInt();
+ day = parser.nextInt(0);
+ month = parser.nextInt(0);
+ year = parser.nextInt(0);
}
if (year == 0) {
return null; // ignore invalid data
@@ -253,17 +253,17 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.PREFIX_IO + 1, parser.next());
position.set(Position.KEY_BATTERY, parser.next());
- position.set(Position.KEY_POWER, parser.nextDouble());
+ position.set(Position.KEY_POWER, parser.nextDouble(0));
position.set(Position.PREFIX_ADC + 1, parser.next());
- int lac = parser.nextInt(16);
- int cid = parser.nextInt(16);
+ int lac = parser.nextHexInt(0);
+ int cid = parser.nextHexInt(0);
if (lac != 0 && cid != 0) {
position.setNetwork(new Network(CellTower.fromLacCid(lac, cid)));
}
position.set(Position.PREFIX_TEMP + 1, parser.next());
- position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
+ position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1000);
} else if (pattern == PATTERN3) {
if (parser.hasNext()) {
@@ -273,22 +273,22 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS));
position.set(Position.PREFIX_IO + 1, parser.next());
- position.set(Position.KEY_BATTERY, parser.nextDouble() * 0.1);
- position.set(Position.KEY_POWER, parser.nextDouble());
+ position.set(Position.KEY_BATTERY, parser.nextDouble(0) * 0.1);
+ position.set(Position.KEY_POWER, parser.nextDouble(0));
position.set(Position.PREFIX_ADC + 1, parser.next());
position.set(Position.PREFIX_ADC + 2, parser.next());
position.set(Position.PREFIX_TEMP + 1, parser.next());
position.set(Position.PREFIX_TEMP + 2, parser.next());
position.setNetwork(new Network(
- CellTower.fromLacCid(parser.nextInt(16), parser.nextInt(16))));
+ CellTower.fromLacCid(parser.nextHexInt(0), parser.nextHexInt(0))));
position.setValid(parser.next().equals("A"));
position.set(Position.KEY_SATELLITES, parser.next());
- position.setCourse(parser.nextDouble());
- position.setSpeed(parser.nextDouble());
+ position.setCourse(parser.nextDouble(0));
+ position.setSpeed(parser.nextDouble(0));
position.set(Position.KEY_PDOP, parser.next());
- position.set(Position.KEY_ODOMETER, parser.nextInt() * 1000);
+ position.set(Position.KEY_ODOMETER, parser.nextInt(0) * 1000);
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
@@ -298,8 +298,8 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
position.setTime(parser.nextDateTime());
- position.set(Position.KEY_BATTERY, parser.nextDouble() * 0.1);
- position.set(Position.KEY_POWER, parser.nextDouble());
+ position.set(Position.KEY_BATTERY, parser.nextDouble(0) * 0.1);
+ position.set(Position.KEY_POWER, parser.nextDouble(0));
position.set(Position.PREFIX_ADC + 1, parser.next());
position.set(Position.PREFIX_ADC + 2, parser.next());
@@ -308,15 +308,15 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.PREFIX_TEMP + 1, parser.next());
position.set(Position.PREFIX_TEMP + 2, parser.next());
- CellTower cellTower = CellTower.fromLacCid(parser.nextInt(16), parser.nextInt(16));
- position.set(Position.KEY_SATELLITES, parser.nextInt());
- cellTower.setSignalStrength(parser.nextInt());
+ CellTower cellTower = CellTower.fromLacCid(parser.nextHexInt(0), parser.nextHexInt(0));
+ position.set(Position.KEY_SATELLITES, parser.nextInt(0));
+ cellTower.setSignalStrength(parser.nextInt(0));
position.setNetwork(new Network(cellTower));
- 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.setCourse(parser.nextDouble(0));
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
+ position.set(Position.KEY_HDOP, parser.nextDouble(0));
+ position.set(Position.KEY_ODOMETER, parser.nextInt(0) * 1000);
position.setValid(true);
position.setLatitude(parser.nextCoordinate());