From 81beb5afb946d8c9ccfa2bbdfcfe884771a5bd3b Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 2 May 2013 22:16:14 +1200 Subject: Fix extended info XML format --- src/org/traccar/protocol/Avl08ProtocolDecoder.java | 58 ++++++---------------- 1 file changed, 15 insertions(+), 43 deletions(-) (limited to 'src/org/traccar/protocol/Avl08ProtocolDecoder.java') diff --git a/src/org/traccar/protocol/Avl08ProtocolDecoder.java b/src/org/traccar/protocol/Avl08ProtocolDecoder.java index 7cd64ad2b..c08b56129 100644 --- a/src/org/traccar/protocol/Avl08ProtocolDecoder.java +++ b/src/org/traccar/protocol/Avl08ProtocolDecoder.java @@ -24,6 +24,7 @@ import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; import org.traccar.ServerManager; import org.traccar.helper.Log; +import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; /** @@ -84,7 +85,7 @@ public class Avl08ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - StringBuilder extendedInfo = new StringBuilder("avl08"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("avl08"); Integer index = 1; @@ -98,9 +99,7 @@ public class Avl08ProtocolDecoder extends BaseProtocolDecoder { } // Alarm type - extendedInfo.append(""); - extendedInfo.append(parser.group(index++)); - extendedInfo.append(""); + extendedInfo.set("alarm", parser.group(index++)); // Time Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC")); @@ -146,65 +145,38 @@ public class Avl08ProtocolDecoder extends BaseProtocolDecoder { position.setTime(time.getTime()); // Dilution of precision - extendedInfo.append(""); - extendedInfo.append(parser.group(index++).replaceFirst ("^0*(?![\\.$])", "")); - extendedInfo.append(""); - extendedInfo.append(""); - extendedInfo.append(parser.group(index++).replaceFirst ("^0*(?![\\.$])", "")); - extendedInfo.append(""); - extendedInfo.append(""); - extendedInfo.append(parser.group(index++).replaceFirst ("^0*(?![\\.$])", "")); - extendedInfo.append(""); + extendedInfo.set("pdop", parser.group(index++).replaceFirst ("^0*(?![\\.$])", "")); + extendedInfo.set("hdop", parser.group(index++).replaceFirst ("^0*(?![\\.$])", "")); + extendedInfo.set("vdop", parser.group(index++).replaceFirst ("^0*(?![\\.$])", "")); // Status - extendedInfo.append(""); - extendedInfo.append(parser.group(index++)); - extendedInfo.append(""); + extendedInfo.set("status", parser.group(index++)); // Real time clock - extendedInfo.append(""); - extendedInfo.append(parser.group(index++)); - extendedInfo.append(""); + extendedInfo.set("clock", parser.group(index++)); // Voltage String voltage = parser.group(index++); position.setPower(Double.valueOf(voltage.substring(1, 4)) / 100); - extendedInfo.append(""); - extendedInfo.append(voltage); - extendedInfo.append(""); + extendedInfo.set("voltage", voltage); // ADC - extendedInfo.append(""); - extendedInfo.append(parser.group(index++)); - extendedInfo.append(""); + extendedInfo.set("adc", parser.group(index++)); // Cell - extendedInfo.append(""); - extendedInfo.append(parser.group(index++)); - extendedInfo.append(""); + extendedInfo.set("cell", parser.group(index++)); // Temperature - extendedInfo.append(""); - extendedInfo.append(parser.group(index++)); - extendedInfo.append(""); + extendedInfo.set("temperature", parser.group(index++)); // Mileage - extendedInfo.append(""); - extendedInfo.append(parser.group(index++)); - extendedInfo.append(""); + extendedInfo.set("mileage", parser.group(index++)); // Serial - extendedInfo.append(""); - extendedInfo.append(parser.group(index++).replaceFirst ("^0*", "")); - extendedInfo.append(""); + extendedInfo.set("serial", parser.group(index++).replaceFirst ("^0*", "")); // RFID - String rfid = parser.group(index++); - if (rfid != null) { - extendedInfo.append(""); - extendedInfo.append(rfid); - extendedInfo.append(""); - } + extendedInfo.set("rfid", parser.group(index++)); // Extended info position.setExtendedInfo(extendedInfo.toString()); -- cgit v1.2.3