diff options
author | Abyss777 <abyss@fox5.ru> | 2016-07-29 15:50:59 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2016-07-29 15:50:59 +0500 |
commit | 20c2456a9df46eaef04c787ea5471bf31a71f93c (patch) | |
tree | f8e76fb8f6cf27b0d1b2a9476dcb8436f4e88feb /src/org/traccar | |
parent | cd0c04a03b359dfc5b1ea3f61b93aaae8f6fec3e (diff) | |
download | trackermap-server-20c2456a9df46eaef04c787ea5471bf31a71f93c.tar.gz trackermap-server-20c2456a9df46eaef04c787ea5471bf31a71f93c.tar.bz2 trackermap-server-20c2456a9df46eaef04c787ea5471bf31a71f93c.zip |
Organized alarms in the first part of protocols
Diffstat (limited to 'src/org/traccar')
-rw-r--r-- | src/org/traccar/model/Position.java | 31 | ||||
-rw-r--r-- | src/org/traccar/protocol/GranitProtocolDecoder.java | 4 | ||||
-rw-r--r-- | src/org/traccar/protocol/MeiligaoProtocolDecoder.java | 30 | ||||
-rw-r--r-- | src/org/traccar/protocol/MxtProtocolDecoder.java | 4 | ||||
-rw-r--r-- | src/org/traccar/protocol/NavisProtocolDecoder.java | 6 | ||||
-rw-r--r-- | src/org/traccar/protocol/NoranProtocolDecoder.java | 13 | ||||
-rw-r--r-- | src/org/traccar/protocol/ProgressProtocolDecoder.java | 2 | ||||
-rw-r--r-- | src/org/traccar/protocol/SuntechProtocolDecoder.java | 2 | ||||
-rw-r--r-- | src/org/traccar/protocol/TotemProtocolDecoder.java | 44 | ||||
-rw-r--r-- | src/org/traccar/protocol/UlbotechProtocolDecoder.java | 33 |
10 files changed, 153 insertions, 16 deletions
diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java index e667f097d..3b6b9c8b1 100644 --- a/src/org/traccar/model/Position.java +++ b/src/org/traccar/model/Position.java @@ -54,6 +54,7 @@ public class Position extends Message { public static final String KEY_APPROXIMATE = "approximate"; public static final String KEY_THROTTLE = "throttle"; public static final String KEY_MOTION = "motion"; + public static final String KEY_GUARD = "guard"; public static final String KEY_OBD_SPEED = "obd-speed"; public static final String KEY_OBD_ODOMETER = "obd-odometer"; @@ -65,15 +66,45 @@ public class Position extends Message { public static final String PREFIX_ADC = "adc"; public static final String PREFIX_IO = "io"; public static final String PREFIX_COUNT = "count"; + public static final String PREFIX_BUTTON = "button"; + public static final String ENDING_PRESSED = "Pressed"; + public static final String ENDING_RELEASED = "Released"; + public static final String ENDING_OPEN = "Open"; + public static final String ENDING_CLOSE = "Close"; + public static final String ENDING_ACTIVE = "Active"; + public static final String ENDING_INACTIVE = "Inactive"; + + + public static final String ALARM_GENERAL = "general"; public static final String ALARM_SOS = "sos"; public static final String ALARM_VIBRATION = "vibration"; public static final String ALARM_MOVEMENT = "movement"; public static final String ALARM_OVERSPEED = "overspeed"; + public static final String ALARM_OVERSPEED_END = "overspeedEnd"; public static final String ALARM_FALL_DOWN = "fallDown"; public static final String ALARM_LOW_BATTERY = "lowBattery"; public static final String ALARM_MOTION = "motion"; public static final String ALARM_FAULT = "fault"; + public static final String ALARM_POWER_OFF = "powerOff"; + public static final String ALARM_JAMMING = "jamming"; + public static final String ALARM_GEOFENCE = "geofence"; + public static final String ALARM_GEOFENCE_ENTER = "geofenceEnter"; + public static final String ALARM_GEOFENCE_EXIT = "geofenceExit"; + public static final String ALARM_ODB = "odb"; + public static final String ALARM_POWER_LOW = "powerLow"; + public static final String ALARM_PARKING = "parking"; + public static final String ALARM_CHARGE_BEGIN = "chargeBegin"; + public static final String ALARM_CHARGE_END = "chargeEnd"; + public static final String ALARM_RFID_NEW = "rfidNew"; + public static final String ALARM_SLEEP_INTO = "intoSleep"; + public static final String ALARM_SLEEP_FROM = "fromSleep"; + public static final String ALARM_TRACKER_ON = "trackerOn"; + public static final String ALARM_SHUTDOWN = "shutdown"; + public static final String ALARM_GPS_BLIND_ENTER = "gpsBlindEnter"; + public static final String ALARM_GPS_BLIND_EXIT = "gpsBlindExit"; + public static final String ALARM_GPS_ANTENNA_CUT = "gpsAntennaCut"; + private String protocol; diff --git a/src/org/traccar/protocol/GranitProtocolDecoder.java b/src/org/traccar/protocol/GranitProtocolDecoder.java index 0c7ea4d1d..3a2d24fa2 100644 --- a/src/org/traccar/protocol/GranitProtocolDecoder.java +++ b/src/org/traccar/protocol/GranitProtocolDecoder.java @@ -71,7 +71,9 @@ public class GranitProtocolDecoder extends BaseProtocolDecoder { private static void decodeStructure(ChannelBuffer buf, Position position) { short flags = buf.readUnsignedByte(); position.setValid(BitUtil.check(flags, 7)); - position.set(Position.KEY_ALARM, BitUtil.check(flags, 1)); + if (BitUtil.check(flags, 1)) { + position.set(Position.KEY_ALARM, Position.ALARM_GENERAL); + } short satDel = buf.readUnsignedByte(); position.set(Position.KEY_SATELLITES, BitUtil.from(satDel, 4)); diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java index 9c7e9ea23..196b24d27 100644 --- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java +++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java @@ -150,6 +150,31 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { } return server; } + + private String decodeAlarm(short value) { + switch (value) { + case 0x01: return Position.ALARM_SOS; + case 0x02: return Position.PREFIX_BUTTON + "B" + Position.ENDING_PRESSED; + case 0x03: return Position.PREFIX_BUTTON + "C" + Position.ENDING_PRESSED; + case 0x04: return Position.PREFIX_IO + "4" + Position.ENDING_ACTIVE; + case 0x05: return Position.PREFIX_IO + "5" + Position.ENDING_ACTIVE; + case 0x10: return Position.ALARM_LOW_BATTERY; + case 0x11: return Position.ALARM_OVERSPEED; + case 0x12: return Position.ALARM_MOVEMENT; + case 0x13: return Position.ALARM_GEOFENCE_ENTER; + case 0x14: return Position.ALARM_TRACKER_ON; + case 0x15: return Position.ALARM_GPS_BLIND_ENTER; + case 0x16: return Position.ALARM_GPS_BLIND_EXIT; + case 0x31: return Position.ALARM_SOS + Position.ENDING_RELEASED; + case 0x32: return Position.PREFIX_BUTTON + "B" + Position.ENDING_RELEASED; + case 0x33: return Position.PREFIX_BUTTON + "C" + Position.ENDING_RELEASED; + case 0x34: return Position.PREFIX_IO + "4" + Position.ENDING_INACTIVE; + case 0x35: return Position.PREFIX_IO + "5" + Position.ENDING_INACTIVE; + case 0x50: return Position.ALARM_POWER_OFF; + case 0x53: return Position.ALARM_GPS_ANTENNA_CUT; + default: return null; + } + } @Override protected Object decode( @@ -196,7 +221,10 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { // Custom data if (command == MSG_ALARM) { - position.set(Position.KEY_ALARM, buf.readUnsignedByte()); + String alarm = decodeAlarm(buf.readUnsignedByte()); + if (alarm != null) { + position.set(Position.KEY_ALARM, alarm); + } } else if (command == MSG_POSITION_LOGGED) { buf.skipBytes(6); } diff --git a/src/org/traccar/protocol/MxtProtocolDecoder.java b/src/org/traccar/protocol/MxtProtocolDecoder.java index 56024057e..1dbfc3696 100644 --- a/src/org/traccar/protocol/MxtProtocolDecoder.java +++ b/src/org/traccar/protocol/MxtProtocolDecoder.java @@ -82,7 +82,9 @@ public class MxtProtocolDecoder extends BaseProtocolDecoder { long flags = buf.readUnsignedInt(); position.set(Position.KEY_IGNITION, BitUtil.check(flags, 0)); - position.set(Position.KEY_ALARM, BitUtil.check(flags, 1)); + if (BitUtil.check(flags, 1)) { + position.set(Position.KEY_ALARM, Position.ALARM_GENERAL); + } position.set(Position.KEY_INPUT, BitUtil.between(flags, 2, 7)); position.set(Position.KEY_OUTPUT, BitUtil.between(flags, 7, 10)); position.setCourse(BitUtil.between(flags, 10, 13) * 45); diff --git a/src/org/traccar/protocol/NavisProtocolDecoder.java b/src/org/traccar/protocol/NavisProtocolDecoder.java index fad24301c..046068c5d 100644 --- a/src/org/traccar/protocol/NavisProtocolDecoder.java +++ b/src/org/traccar/protocol/NavisProtocolDecoder.java @@ -95,7 +95,11 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder { buf.skipBytes(6); // event time - position.set(Position.KEY_ALARM, buf.readUnsignedByte()); + short guardStatus = buf.readUnsignedByte(); + position.set(Position.KEY_GUARD, guardStatus & 0x7F); + if (BitUtil.check(guardStatus, 7)) { + position.set(Position.KEY_ALARM, Position.ALARM_GENERAL); + } position.set(Position.KEY_STATUS, buf.readUnsignedByte()); position.set(Position.KEY_GSM, buf.readUnsignedByte()); diff --git a/src/org/traccar/protocol/NoranProtocolDecoder.java b/src/org/traccar/protocol/NoranProtocolDecoder.java index c2161d9c9..7071b9625 100644 --- a/src/org/traccar/protocol/NoranProtocolDecoder.java +++ b/src/org/traccar/protocol/NoranProtocolDecoder.java @@ -90,7 +90,18 @@ public class NoranProtocolDecoder extends BaseProtocolDecoder { position.setValid(BitUtil.check(buf.readUnsignedByte(), 0)); - position.set(Position.KEY_ALARM, buf.readUnsignedByte()); + short alarm = buf.readUnsignedByte(); + if (alarm != 0x80) { + if (alarm == 1) { + position.set(Position.KEY_ALARM, Position.ALARM_SOS); + } else if (alarm == 2) { + position.set(Position.KEY_ALARM, Position.ALARM_OVERSPEED); + } else if (alarm == 3) { + position.set(Position.KEY_ALARM, Position.ALARM_GEOFENCE_EXIT); + } else if (alarm == 9) { + position.set(Position.KEY_ALARM, Position.ALARM_POWER_OFF); + } + } if (newFormat) { position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedInt())); diff --git a/src/org/traccar/protocol/ProgressProtocolDecoder.java b/src/org/traccar/protocol/ProgressProtocolDecoder.java index e524626fa..0032a9a1b 100644 --- a/src/org/traccar/protocol/ProgressProtocolDecoder.java +++ b/src/org/traccar/protocol/ProgressProtocolDecoder.java @@ -104,7 +104,7 @@ public class ProgressProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_ARCHIVE, true); int subtype = buf.readUnsignedShort(); if (subtype == MSG_ALARM) { - position.set(Position.KEY_ALARM, true); + position.set(Position.KEY_ALARM, Position.ALARM_GENERAL); } if (buf.readUnsignedShort() > buf.readableBytes()) { lastIndex += 1; diff --git a/src/org/traccar/protocol/SuntechProtocolDecoder.java b/src/org/traccar/protocol/SuntechProtocolDecoder.java index 5169e7c67..503f4d6f8 100644 --- a/src/org/traccar/protocol/SuntechProtocolDecoder.java +++ b/src/org/traccar/protocol/SuntechProtocolDecoder.java @@ -68,7 +68,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { if (parser.hasNext()) { String type = parser.next(); if (type.equals("Alert") || type.equals("Emergency")) { - position.set(Position.KEY_ALARM, true); + position.set(Position.KEY_ALARM, Position.ALARM_GENERAL); } } diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java index 7b196f5ad..97201521d 100644 --- a/src/org/traccar/protocol/TotemProtocolDecoder.java +++ b/src/org/traccar/protocol/TotemProtocolDecoder.java @@ -159,6 +159,34 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { .any() .compile(); + private String decodeAlarm(String value) { + switch (value) { + case "01": return Position.ALARM_SOS; + case "49": return Position.PREFIX_BUTTON + "A" + Position.ENDING_PRESSED; + case "09": return Position.ALARM_SHUTDOWN; + case "10": return Position.ALARM_LOW_BATTERY; + case "11": return Position.ALARM_OVERSPEED; + case "13": return Position.ALARM_OVERSPEED_END; + case "30": return Position.ALARM_PARKING; + case "42": return Position.ALARM_GEOFENCE_EXIT; + case "43": return Position.ALARM_GEOFENCE_ENTER; + case "50": return Position.PREFIX_IO + "1" + Position.ENDING_CLOSE; + case "51": return Position.PREFIX_IO + "1" + Position.ENDING_OPEN; + case "52": return Position.PREFIX_IO + "2" + Position.ENDING_CLOSE; + case "53": return Position.PREFIX_IO + "2" + Position.ENDING_OPEN; + case "54": return Position.PREFIX_IO + "3" + Position.ENDING_CLOSE; + case "55": return Position.PREFIX_IO + "3" + Position.ENDING_OPEN; + case "56": return Position.PREFIX_IO + "4" + Position.ENDING_CLOSE; + case "57": return Position.PREFIX_IO + "4" + Position.ENDING_OPEN; + case "60": return Position.ALARM_CHARGE_BEGIN; + case "61": return Position.ALARM_CHARGE_END; + case "66": return Position.ALARM_RFID_NEW; + case "91": return Position.ALARM_SLEEP_INTO; + case "92": return Position.ALARM_SLEEP_FROM; + default: return null; + } + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -193,9 +221,10 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(deviceSession.getDeviceId()); if (pattern == PATTERN1 || pattern == PATTERN2) { - - position.set(Position.KEY_ALARM, parser.next()); - + String alarm = decodeAlarm(parser.next()); + if (alarm != null) { + position.set(Position.KEY_ALARM, alarm); + } DateBuilder dateBuilder = new DateBuilder(); int year = 0; if (pattern == PATTERN2) { @@ -238,9 +267,10 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_ODOMETER, parser.next()); } else if (pattern == PATTERN3) { - - position.set(Position.KEY_ALARM, parser.next()); - + String alarm = decodeAlarm(parser.next()); + if (alarm != null) { + position.set(Position.KEY_ALARM, alarm); + } DateBuilder dateBuilder = new DateBuilder() .setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt()) .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt()); @@ -304,11 +334,9 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { position.setLongitude(parser.nextCoordinate()); } - if (channel != null) { channel.write("ACK OK\r\n"); } - return position; } diff --git a/src/org/traccar/protocol/UlbotechProtocolDecoder.java b/src/org/traccar/protocol/UlbotechProtocolDecoder.java index c17341b5f..7abe9fb70 100644 --- a/src/org/traccar/protocol/UlbotechProtocolDecoder.java +++ b/src/org/traccar/protocol/UlbotechProtocolDecoder.java @@ -115,6 +115,34 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder { } } + private String decodeAlarm(int alarm) { + if (BitUtil.check(alarm, 0)) { + return Position.ALARM_POWER_OFF; + } + if (BitUtil.check(alarm, 1)) { + return Position.ALARM_MOTION; + } + if (BitUtil.check(alarm, 2)) { + return Position.ALARM_OVERSPEED; + } + if (BitUtil.check(alarm, 3)) { + return Position.ALARM_JAMMING; + } + if (BitUtil.check(alarm, 4)) { + return Position.ALARM_GEOFENCE; + } + if (BitUtil.check(alarm, 10)) { + return Position.ALARM_SOS; + } + if (BitUtil.check(alarm, 11)) { + return Position.ALARM_ODB; + } + if (BitUtil.check(alarm, 15)) { + return Position.ALARM_POWER_LOW; + } + return null; + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -181,7 +209,10 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder { int status = buf.readUnsignedShort(); position.set(Position.KEY_IGNITION, BitUtil.check(status, 9)); position.set(Position.KEY_STATUS, status); - position.set(Position.KEY_ALARM, buf.readUnsignedShort()); + String alarm = decodeAlarm(buf.readUnsignedShort()); + if (alarm != null) { + position.set(Position.KEY_ALARM, alarm); + } break; case DATA_ODOMETER: |