aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-06-19 11:21:20 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-06-19 11:21:20 -0700
commit9084c4db98eef6621e93b3f0fce6e7a61b683a06 (patch)
treebc5c1a8fc534cd4dcb86143b21a7f6a66433245d
parentd834c23f8602fd8f3321d8cb8ff9648b163cdafd (diff)
downloadtrackermap-server-9084c4db98eef6621e93b3f0fce6e7a61b683a06.tar.gz
trackermap-server-9084c4db98eef6621e93b3f0fce6e7a61b683a06.tar.bz2
trackermap-server-9084c4db98eef6621e93b3f0fce6e7a61b683a06.zip
Missing Pacific Track attributes
-rw-r--r--src/main/java/org/traccar/protocol/PacificTrackProtocolDecoder.java34
-rw-r--r--src/test/java/org/traccar/protocol/PacificTrackProtocolDecoderTest.java3
2 files changed, 36 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/PacificTrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/PacificTrackProtocolDecoder.java
index d49a73a86..b1c13d486 100644
--- a/src/main/java/org/traccar/protocol/PacificTrackProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/PacificTrackProtocolDecoder.java
@@ -105,12 +105,31 @@ public class PacificTrackProtocolDecoder extends BaseProtocolDecoder {
case 0b00001:
position.set(Position.KEY_RPM, buf.readUnsignedByte() * 32);
break;
+ case 0b01001:
+ position.set("defLevel", buf.readUnsignedByte() * 0.4);
+ break;
+ case 0b01010:
+ position.set(Position.KEY_ENGINE_LOAD, buf.readUnsignedByte());
+ break;
+ case 0b01011:
+ position.set("barometer", buf.readUnsignedByte() * 0.5);
+ break;
default:
buf.readUnsignedByte();
break;
}
} else if (fieldPrefix < 0b110) {
- buf.readUnsignedShort();
+ switch (BitUtil.to(field, 5)) {
+ case 0b00010:
+ position.set(Position.KEY_FUEL_CONSUMPTION, buf.readUnsignedShort() / 512.0);
+ break;
+ case 0b00011:
+ position.set(Position.PREFIX_TEMP + 1, buf.readUnsignedShort() * 0.03125 - 273);
+ break;
+ default:
+ buf.readUnsignedShort();
+ break;
+ }
} else if (fieldPrefix < 0b111) {
switch (BitUtil.to(field, 5)) {
case 0b00000:
@@ -122,6 +141,12 @@ public class PacificTrackProtocolDecoder extends BaseProtocolDecoder {
case 0b00010:
position.set("idleHours", buf.readUnsignedInt() * 180);
break;
+ case 0b00100:
+ position.set(Position.KEY_FUEL_USED, buf.readUnsignedInt() * 0.5);
+ break;
+ case 0b00101:
+ position.set("fuelUsedIdle", buf.readUnsignedInt() * 0.5);
+ break;
default:
buf.readUnsignedInt();
break;
@@ -141,8 +166,15 @@ public class PacificTrackProtocolDecoder extends BaseProtocolDecoder {
}
}
+ if (deviceSession == null) {
+ deviceSession = getDeviceSession(channel, remoteAddress);
+ }
+
if (deviceSession != null) {
position.setDeviceId(deviceSession.getDeviceId());
+ if (position.getFixTime() == null) {
+ getLastLocation(position, null);
+ }
return position;
} else {
return null;
diff --git a/src/test/java/org/traccar/protocol/PacificTrackProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/PacificTrackProtocolDecoderTest.java
index ade2804da..994407d25 100644
--- a/src/test/java/org/traccar/protocol/PacificTrackProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/PacificTrackProtocolDecoderTest.java
@@ -27,6 +27,9 @@ public class PacificTrackProtocolDecoderTest extends ProtocolTest {
verifyPosition(decoder, binary(
"fb82e80280883527530900009110818202c0909308990b122519076138fc03b3480205a3e80003a0834dd19fb08112c08f0143000e020000000100000014000101929f806328c0000f4240810a858ce011314334424a57464758444c3533313737330190868102100828cf"));
+ verifyAttributes(decoder, binary(
+ "FB80B48181B20192AE86E68780882D89BB8A648BCEA008ACA16600A20380C10003DF2CC200004E20C3004428C0C4000008C6C5000316A4"));
+
}
}