aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-08-15 07:39:46 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2017-08-15 07:39:46 +1200
commit8012240ac5662d8b0a2ec7907ad3f04e86b17627 (patch)
tree6855a975eb8c8940ebaceb2900606b33d3e02bd4 /src/org/traccar/protocol
parent52d19ba205d76d18d62789fbb013a43fef024e91 (diff)
downloadtrackermap-server-8012240ac5662d8b0a2ec7907ad3f04e86b17627.tar.gz
trackermap-server-8012240ac5662d8b0a2ec7907ad3f04e86b17627.tar.bz2
trackermap-server-8012240ac5662d8b0a2ec7907ad3f04e86b17627.zip
Add VT200 trip message support
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/Vt200ProtocolDecoder.java58
1 files changed, 52 insertions, 6 deletions
diff --git a/src/org/traccar/protocol/Vt200ProtocolDecoder.java b/src/org/traccar/protocol/Vt200ProtocolDecoder.java
index 111c29313..6be70c3c1 100644
--- a/src/org/traccar/protocol/Vt200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Vt200ProtocolDecoder.java
@@ -27,6 +27,8 @@ import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
import java.net.SocketAddress;
+import java.util.Arrays;
+import java.util.Date;
public class Vt200ProtocolDecoder extends BaseProtocolDecoder {
@@ -40,6 +42,13 @@ public class Vt200ProtocolDecoder extends BaseProtocolDecoder {
return degrees + minutes * 0.0001 / 60;
}
+ protected Date decodeDate(ChannelBuffer buf) {
+ DateBuilder dateBuilder = new DateBuilder()
+ .setDateReverse(BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2))
+ .setTime(BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2));
+ return dateBuilder.getDate();
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -66,12 +75,7 @@ public class Vt200ProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedByte(); // data type
buf.readUnsignedShort(); // trip id
- DateBuilder dateBuilder = new DateBuilder();
- dateBuilder.setDateReverse(
- BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2));
- dateBuilder.setTime(
- BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2));
- position.setTime(dateBuilder.getDate());
+ position.setTime(decodeDate(buf));
position.setLatitude(decodeCoordinate(BcdUtil.readInteger(buf, 8)));
position.setLongitude(decodeCoordinate(BcdUtil.readInteger(buf, 9)));
@@ -97,6 +101,48 @@ public class Vt200ProtocolDecoder extends BaseProtocolDecoder {
return position;
+ } else if (type == 0x3088) {
+
+ Position position = new Position();
+ position.setProtocol(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
+
+ getLastLocation(position, null);
+
+ buf.readUnsignedShort(); // trip id
+ buf.skipBytes(8); // imei
+ buf.skipBytes(8); // imsi
+
+ position.set("tripStart", decodeDate(buf).getTime());
+ position.set("tripEnd", decodeDate(buf).getTime());
+ position.set("drivingTime", buf.readUnsignedShort());
+
+ position.set(Position.KEY_FUEL_CONSUMPTION, buf.readUnsignedInt());
+ position.set(Position.KEY_ODOMETER_TRIP, buf.readUnsignedInt());
+
+ position.set("maxSpeed", UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
+ position.set("maxRpm", buf.readUnsignedShort());
+ position.set("maxTemp", buf.readUnsignedByte() - 40);
+ position.set("hardAccelerationCount", buf.readUnsignedByte());
+ position.set("hardBreakingCount", buf.readUnsignedByte());
+
+ for (String speedType : Arrays.asList("over", "high", "normal", "low")) {
+ position.set(speedType + "SpeedTime", buf.readUnsignedShort());
+ position.set(speedType + "SpeedDistance", buf.readUnsignedInt());
+ position.set(speedType + "SpeedFuel", buf.readUnsignedInt());
+ }
+
+ position.set("idleTime", buf.readUnsignedShort());
+ position.set("idleFuel", buf.readUnsignedInt());
+
+ position.set("hardCorneringCount", buf.readUnsignedByte());
+ position.set("overspeedCount", buf.readUnsignedByte());
+ position.set("overheatCount", buf.readUnsignedShort());
+ position.set("laneChangeCount", buf.readUnsignedByte());
+ position.set("emergencyRefueling", buf.readUnsignedByte());
+
+ return position;
+
}
return null;