diff options
author | Abyss777 <abyss@fox5.ru> | 2016-08-16 11:41:53 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2016-08-16 11:41:53 +0500 |
commit | 87a8bf3f5cff9b2e537594d0a13371ed8f06fcea (patch) | |
tree | 223ef63962e9618a3e422e8e8047ca7f2f3aecd2 /src/org/traccar/protocol/HuabaoProtocolDecoder.java | |
parent | 70bea1304ded17bb8a94ce8495d1e395e7cdf748 (diff) | |
download | trackermap-server-87a8bf3f5cff9b2e537594d0a13371ed8f06fcea.tar.gz trackermap-server-87a8bf3f5cff9b2e537594d0a13371ed8f06fcea.tar.bz2 trackermap-server-87a8bf3f5cff9b2e537594d0a13371ed8f06fcea.zip |
- Added alarm decoding for 5 protocols
Diffstat (limited to 'src/org/traccar/protocol/HuabaoProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/HuabaoProtocolDecoder.java | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/org/traccar/protocol/HuabaoProtocolDecoder.java index e4c9a9860..9223ea9a5 100644 --- a/src/org/traccar/protocol/HuabaoProtocolDecoder.java +++ b/src/org/traccar/protocol/HuabaoProtocolDecoder.java @@ -70,6 +70,32 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { sendResponse(channel, remoteAddress, MSG_GENERAL_RESPONSE, id, response); } + private String decodeAlarm(long value) { + if (BitUtil.check(value, 0)) { + return Position.ALARM_SOS; + } + if (BitUtil.check(value, 1)) { + return Position.ALARM_OVERSPEED; + } + if (BitUtil.check(value, 5)) { + return Position.ALARM_GPS_ANTENNA_CUT; + } + if (BitUtil.check(value, 4) || BitUtil.check(value, 9) + || BitUtil.check(value, 10) || BitUtil.check(value, 11)) { + return Position.ALARM_FAULT; + } + if (BitUtil.check(value, 8)) { + return Position.ALARM_POWER_OFF; + } + if (BitUtil.check(value, 20)) { + return Position.ALARM_GEOFENCE; + } + if (BitUtil.check(value, 29)) { + return Position.ALARM_ACCIDENT; + } + return null; + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -105,7 +131,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { position.setProtocol(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); - position.set(Position.KEY_ALARM, buf.readUnsignedInt()); + position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedInt())); int flags = buf.readInt(); |