diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-08-16 13:48:07 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-16 13:48:07 +0300 |
commit | 376bd7a7342ed46f20b7c0c94d7c9b0074ae99f3 (patch) | |
tree | 3e1336a0597ca649f54e2b271a96df4b37273c9b /src/org/traccar/protocol/MegastekProtocolDecoder.java | |
parent | 70bea1304ded17bb8a94ce8495d1e395e7cdf748 (diff) | |
parent | 96f0143b2cbbb93f1c325e1df7c66a2fc3d55b7e (diff) | |
download | trackermap-server-376bd7a7342ed46f20b7c0c94d7c9b0074ae99f3.tar.gz trackermap-server-376bd7a7342ed46f20b7c0c94d7c9b0074ae99f3.tar.bz2 trackermap-server-376bd7a7342ed46f20b7c0c94d7c9b0074ae99f3.zip |
Merge pull request #2219 from Abyss777/alarms_2
Alarm decoding for next 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 { |