From 78f7e386fe4fb46fc0c9295853a2467408330dfd Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 25 Oct 2015 15:40:42 +1300 Subject: Implement Ulbotech driver behavior --- .../traccar/protocol/UlbotechProtocolDecoder.java | 32 +++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/UlbotechProtocolDecoder.java b/src/org/traccar/protocol/UlbotechProtocolDecoder.java index a81c02ce1..dc4741340 100644 --- a/src/org/traccar/protocol/UlbotechProtocolDecoder.java +++ b/src/org/traccar/protocol/UlbotechProtocolDecoder.java @@ -66,6 +66,36 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder { } } + private void decodeDriverBehavior(Position position, ChannelBuffer buf) { + + int value = buf.readUnsignedByte(); + + if (BitUtil.check(value, 0)) { + position.set("rapid-acceleration", true); + } + if (BitUtil.check(value, 1)) { + position.set("rough-braking", true); + } + if (BitUtil.check(value, 2)) { + position.set("harsh-course", true); + } + if (BitUtil.check(value, 3)) { + position.set("no-warm-up", true); + } + if (BitUtil.check(value, 4)) { + position.set("long-idle", true); + } + if (BitUtil.check(value, 5)) { + position.set("fatigue-driving", true); + } + if (BitUtil.check(value, 6)) { + position.set("rough-terrain", true); + } + if (BitUtil.check(value, 7)) { + position.set("high-rpm", true); + } + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -156,7 +186,7 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder { break; case DATA_HARSH_DRIVER: - position.set("driver-behavior", buf.readUnsignedByte()); + decodeDriverBehavior(position, buf); break; case DATA_CANBUS: -- cgit v1.2.3