diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2012-04-02 20:03:08 +0000 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2012-04-02 20:03:08 +0000 |
commit | 96beee5caf560e4b441d2d9e2ebba434c70f5f79 (patch) | |
tree | eddcf0977b73ad716fa86dfa33ec00b7fe846847 /src/org/traccar/protocol/avl08/Avl08ProtocolDecoder.java | |
parent | 932111062285ffdbb8f22a9c25e4946c893a6e71 (diff) | |
download | trackermap-server-96beee5caf560e4b441d2d9e2ebba434c70f5f79.tar.gz trackermap-server-96beee5caf560e4b441d2d9e2ebba434c70f5f79.tar.bz2 trackermap-server-96beee5caf560e4b441d2d9e2ebba434c70f5f79.zip |
Diffstat (limited to 'src/org/traccar/protocol/avl08/Avl08ProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/avl08/Avl08ProtocolDecoder.java | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/avl08/Avl08ProtocolDecoder.java b/src/org/traccar/protocol/avl08/Avl08ProtocolDecoder.java index 382c9e998..4fb33f5ba 100644 --- a/src/org/traccar/protocol/avl08/Avl08ProtocolDecoder.java +++ b/src/org/traccar/protocol/avl08/Avl08ProtocolDecoder.java @@ -45,7 +45,7 @@ public class Avl08ProtocolDecoder extends GenericProtocolDecoder { static private Pattern pattern = Pattern.compile( "\\$\\$.{2}" + // Length "(\\d{15})\\|" + // IMEI - ".{2}" + // Alarm Type + "(.{2})" + // Alarm Type "\\$GPRMC," + "(\\d{2})(\\d{2})(\\d{2}).(\\d{3})," + // Time (HHMMSS.SSS) "([AV])," + // Validity @@ -55,7 +55,17 @@ public class Avl08ProtocolDecoder extends GenericProtocolDecoder { "([EW])," + "(\\d+.\\d{2})?," + // Speed "(\\d+.\\d{2})?," + // Course - "(\\d{2})(\\d{2})(\\d{2})" + // Date (DDMMYY) + "(\\d{2})(\\d{2})(\\d{2}),[^\\|]*\\|" + // Date (DDMMYY) + "(\\d+.\\d)\\|(\\d+.\\d)\\|(\\d+.\\d)\\|" + // Dilution of precision + "(\\d{12})\\|" + // Status + "(\\d{14})\\|" + // Clock + "(\\d{8})\\|" + // Voltage + "(\\d{8})\\|" + // ADC + "(.{8})\\|" + // Cell + "(.\\d{3})\\|" + // Temperature + "(\\d+.\\d{4})\\|" + // Mileage + "(\\d{4})\\|" + // Serial + "(.{10})?\\|" + // RFID ".+"); /** * Decode message @@ -73,6 +83,7 @@ public class Avl08ProtocolDecoder extends GenericProtocolDecoder { // Create new position Position position = new Position(); + String extendedInfo = "<protocol>avl08</protocol>"; Integer index = 1; @@ -80,6 +91,9 @@ public class Avl08ProtocolDecoder extends GenericProtocolDecoder { String imei = parser.group(index++); position.setDeviceId(getDataManager().getDeviceByImei(imei).getId()); + // Alarm type + extendedInfo += "<alarm>" + parser.group(index++) + "</alarm>"; + // Time Calendar time = new GregorianCalendar(TimeZone.getTimeZone("UTC")); time.clear(); @@ -123,6 +137,46 @@ public class Avl08ProtocolDecoder extends GenericProtocolDecoder { time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++))); position.setTime(time.getTime()); + // Dilution of precision + extendedInfo += "<pdop>" + parser.group(index++).replaceFirst ("^0*(?![\\.$])", "") + "</pdop>"; + extendedInfo += "<hdop>" + parser.group(index++).replaceFirst ("^0*(?![\\.$])", "") + "</hdop>"; + extendedInfo += "<vdop>" + parser.group(index++).replaceFirst ("^0*(?![\\.$])", "") + "</vdop>"; + + // Status + extendedInfo += "<status>" + parser.group(index++) + "</status>"; + + // Real time clock + extendedInfo += "<clock>" + parser.group(index++) + "</clock>"; + + // Voltage + String voltage = parser.group(index++); + position.setPower(Double.valueOf(voltage.substring(1, 4)) / 100); + extendedInfo += "<voltage>" + voltage + "</voltage>"; + + // ADC + extendedInfo += "<adc>" + parser.group(index++) + "</adc>"; + + // Cell + extendedInfo += "<cell>" + parser.group(index++) + "</cell>"; + + // Temperature + extendedInfo += "<temperature>" + parser.group(index++) + "</temperature>"; + + // Mileage + extendedInfo += "<mileage>" + parser.group(index++) + "</mileage>"; + + // Serial + extendedInfo += "<serial>" + parser.group(index++).replaceFirst ("^0*", "") + "</serial>"; + + // RFID + String rfid = parser.group(index++); + if (rfid != null) { + extendedInfo += "<rfid>" + rfid + "</rfid>"; + } + + // Extended info + position.setExtendedInfo(extendedInfo); + return position; } |