diff options
-rw-r--r-- | src/org/traccar/protocol/WialonProtocolDecoder.java | 42 | ||||
-rw-r--r-- | test/org/traccar/protocol/WialonProtocolDecoderTest.java | 9 |
2 files changed, 48 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/WialonProtocolDecoder.java b/src/org/traccar/protocol/WialonProtocolDecoder.java index 5b8d9a24e..6c4c0e8db 100644 --- a/src/org/traccar/protocol/WialonProtocolDecoder.java +++ b/src/org/traccar/protocol/WialonProtocolDecoder.java @@ -49,9 +49,16 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder { "([EW]);" + "(\\d+\\.?\\d*)?;" + // Speed "(\\d+\\.?\\d*)?;" + // Course - "(?:(\\d+\\.?\\d*)|NA);" + // Altitude - "(?:(\\d+)|NA)" + // Satellites - ".*"); // Full format + "(?:NA|(\\d+\\.?\\d*));" + // Altitude + "(?:NA|(\\d+))" + // Satellites + "(?:;" + + "(?:NA|(\\d+\\.?\\d*));" + // hdop + "(?:NA|(\\d+));" + // inputs + "(?:NA|(\\d+));" + // outputs + "(?:NA|([^;]*));" + // adc + "(?:NA|([^;]*));" + // ibutton + "(?:NA|(.*))" + // params + ")?"); private void sendResponse(Channel channel, String prefix, Integer number) { if (channel != null) { @@ -135,6 +142,35 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder { position.setValid(false); } + // Other + extendedInfo.set("hdop", parser.group(index++)); + extendedInfo.set("inputs", parser.group(index++)); + extendedInfo.set("outputs", parser.group(index++)); + + // ADC + String adc = parser.group(index++); + if (adc != null) { + String[] values = adc.split(","); + for (int i = 0; i < values.length; i++) { + extendedInfo.set("adc" + (i + 1), values[i]); + } + } + + // iButton + extendedInfo.set("ibutton", parser.group(index++)); + + // Params + String params = parser.group(index); + if (params != null) { + String[] values = params.split(","); + for (String param : values) { + Matcher paramParser = Pattern.compile( "(.*):[1-3]:(.*)").matcher(param); + if (paramParser.matches()) { + extendedInfo.set(paramParser.group(1).toLowerCase(), paramParser.group(2)); + } + } + } + // Extended info position.setExtendedInfo(extendedInfo.toString()); diff --git a/test/org/traccar/protocol/WialonProtocolDecoderTest.java b/test/org/traccar/protocol/WialonProtocolDecoderTest.java index 13aad6e2e..0f5035650 100644 --- a/test/org/traccar/protocol/WialonProtocolDecoderTest.java +++ b/test/org/traccar/protocol/WialonProtocolDecoderTest.java @@ -34,11 +34,20 @@ public class WialonProtocolDecoderTest { "#D#021214;065947;2237.7552;N;11404.8851;E;0.000;;170.9;5;1.74;NA;NA;NA;NA;NA")); verify(decoder.decode(null, null, + "#D#021214;065947;2237.7552;N;11404.8851;E;0.000;;170.9;5;1.74;NA;NA;;NA;NA")); + + verify(decoder.decode(null, null, "#B#080914;073235;5027.50625;N;03026.19321;E;0.700;0.000;NA;4;NA;NA;NA;;NA;Батарея:3:100 %|080914;073420;5027.50845;N;03026.18854;E;1.996;292.540;NA;4;NA;NA;NA;;NA;Батарея:3:100 %")); verify(decoder.decode(null, null, "#B#110914;102132;5027.50728;N;03026.20369;E;1.979;288.170;NA;NA;NA;NA;NA;;NA;Батарея:3:100 %")); + verify(decoder.decode(null, null, + "#B#110315;045857;5364.0167;N;06127.8262;E;0;155;965;7;2.40;4;0;;NA;Uacc:2:3.4,Iacc:2:0.000,Uext:2:13.2,Tcpu:2:14.4,Balance:2:167.65,GPS:3:Off")); + + verify(decoder.decode(null, null, + "#B#110315;045857;5364.0167;N;06127.8262;E;0;155;965;7;2.40;4;0;14.77,0.02,3.6;AB45DF01145;")); + } } |