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/MegastekProtocolDecoder.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/MegastekProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/MegastekProtocolDecoder.java | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/MegastekProtocolDecoder.java b/src/org/traccar/protocol/MegastekProtocolDecoder.java index 1ff7add1a..d20532faa 100644 --- a/src/org/traccar/protocol/MegastekProtocolDecoder.java +++ b/src/org/traccar/protocol/MegastekProtocolDecoder.java @@ -156,7 +156,7 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder { Parser parser = new Parser(PATTERN_SIMPLE, status); if (parser.matches()) { - position.set(Position.KEY_ALARM, parser.next()); + position.set(Position.KEY_ALARM, decodeAlarm(parser.next())); DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next(), id); if (deviceSession == null) { @@ -217,7 +217,7 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder { position.set(Position.PREFIX_ADC + 1, parser.next()); position.set(Position.PREFIX_ADC + 2, parser.next()); position.set(Position.PREFIX_ADC + 3, parser.next()); - position.set(Position.KEY_ALARM, parser.next()); + position.set(Position.KEY_ALARM, decodeAlarm(parser.next())); } } @@ -337,11 +337,42 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_BATTERY, Integer.parseInt(battery)); } - position.set(Position.KEY_ALARM, parser.next()); + position.set(Position.KEY_ALARM, decodeAlarm(parser.next())); return position; } + private String decodeAlarm(String value) { + switch (value) { + case "SOS": + case "Help": + return Position.ALARM_SOS; + case "Over Speed": + case "OverSpeed": + return Position.ALARM_OVERSPEED; + case "LowSpeed": + return Position.ALARM_LOW_SPEED; + case "Low Battery": + case "LowBattery": + return Position.ALARM_LOW_BATTERY; + case "VIB": + return Position.ALARM_VIBRATION; + case "Move in": + case "Geo in": + case "Geo1 in": + case "Geo2 in": + return Position.ALARM_GEOFENCE_ENTER; + case "Move out": + case "Geo out": + case "Geo1 out": + case "Geo2 out": + return Position.ALARM_GEOFENCE_EXIT; + default: + break; + } + return null; + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { |