diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2013-05-02 22:16:14 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2013-05-02 22:16:14 +1200 |
commit | 81beb5afb946d8c9ccfa2bbdfcfe884771a5bd3b (patch) | |
tree | ce4d0b24f1c82381da30472844052f8cfdc1a164 /src/org/traccar/protocol/MeiligaoProtocolDecoder.java | |
parent | f367b71b9c081416f6d64f6efd9844cd05f047ea (diff) | |
download | trackermap-server-81beb5afb946d8c9ccfa2bbdfcfe884771a5bd3b.tar.gz trackermap-server-81beb5afb946d8c9ccfa2bbdfcfe884771a5bd3b.tar.bz2 trackermap-server-81beb5afb946d8c9ccfa2bbdfcfe884771a5bd3b.zip |
Fix extended info XML format
Diffstat (limited to 'src/org/traccar/protocol/MeiligaoProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/MeiligaoProtocolDecoder.java | 40 |
1 files changed, 9 insertions, 31 deletions
diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java index 1d2b6584d..42d7ca350 100644 --- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java +++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java @@ -29,6 +29,7 @@ import org.traccar.BaseProtocolDecoder; import org.traccar.ServerManager; import org.traccar.helper.Crc; import org.traccar.helper.Log; +import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { @@ -37,12 +38,6 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } - //"134743.003,A,0648.9866,S,10707.5795,E,000.0,000.0,260313" - //,,*38|0.8|245|2000|03F6,0000,0000,001C,0000,0000,0000,0000|0194000201CC627C|1A|01160849yt - - /** - * Regular expressions pattern - */ static private Pattern pattern = Pattern.compile( "(\\d{2})(\\d{2})(\\d{2})\\.(\\d+)," + // Time (HHMMSS.SSS) "([AV])," + // Validity @@ -121,13 +116,11 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - StringBuilder extendedInfo = new StringBuilder("<protocol>meiligao</protocol>"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("meiligao"); // Alarm if (command == 0x9999) { - extendedInfo.append("<alarm>"); - extendedInfo.append(buf.getUnsignedByte(offset)); - extendedInfo.append("</alarm>"); + extendedInfo.set("alarm", buf.getUnsignedByte(offset)); } // Data offset @@ -200,12 +193,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { position.setTime(time.getTime()); // Dilution of precision - String hdop = parser.group(index++); - if (hdop != null) { - extendedInfo.append("<hdop>"); - extendedInfo.append(hdop); - extendedInfo.append("</hdop>"); - } + extendedInfo.set("hdop", parser.group(index++)); // Altitude String altitude = parser.group(index++); @@ -218,43 +206,33 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { // State String state = parser.group(index++); if (state != null) { - extendedInfo.append("<state>"); - extendedInfo.append(state); - extendedInfo.append("</state>"); + extendedInfo.set("state", state); } // ADC for (int i = 1; i <= 8; i++) { String adc = parser.group(index++); if (adc != null) { - extendedInfo.append("<adc").append(i).append(">"); - extendedInfo.append(Integer.parseInt(adc, 16)); - extendedInfo.append("</adc").append(i).append(">"); + extendedInfo.set("adc" + i, Integer.parseInt(adc, 16)); } } // Cell identifier String cell = parser.group(index++); if (cell != null) { - extendedInfo.append("<cell>"); - extendedInfo.append(cell); - extendedInfo.append("</cell>"); + extendedInfo.set("cell", cell); } // GSM signal String gsm = parser.group(index++); if (gsm != null) { - extendedInfo.append("<gsm>"); - extendedInfo.append(Integer.parseInt(gsm, 16)); - extendedInfo.append("</gsm>"); + extendedInfo.set("gsm", Integer.parseInt(gsm, 16)); } // Milage String milage = parser.group(index++); if (milage != null) { - extendedInfo.append("<milage>"); - extendedInfo.append(Integer.parseInt(milage, 16)); - extendedInfo.append("</milage>"); + extendedInfo.set("milage", Integer.parseInt(milage, 16)); } // Extended info |