From 9084c4db98eef6621e93b3f0fce6e7a61b683a06 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 19 Jun 2020 11:21:20 -0700 Subject: Missing Pacific Track attributes --- .../protocol/PacificTrackProtocolDecoder.java | 34 +++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'src/main/java/org/traccar') 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; -- cgit v1.2.3