aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/TotemProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-10-19 11:44:53 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-10-19 11:44:53 +1300
commitc46e2e86536abfe36096e4d86cd3d82f0d4e64eb (patch)
tree2f0d21d03de77f5c44fe01c88f0173de04d06e7e /src/org/traccar/protocol/TotemProtocolDecoder.java
parentdbd6de7e462a6e9f52cba1168beeba5ce9773051 (diff)
downloadtrackermap-server-c46e2e86536abfe36096e4d86cd3d82f0d4e64eb.tar.gz
trackermap-server-c46e2e86536abfe36096e4d86cd3d82f0d4e64eb.tar.bz2
trackermap-server-c46e2e86536abfe36096e4d86cd3d82f0d4e64eb.zip
Partially refactor totem decoder
Diffstat (limited to 'src/org/traccar/protocol/TotemProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/TotemProtocolDecoder.java59
1 files changed, 30 insertions, 29 deletions
diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java
index 087416f18..e5096c675 100644
--- a/src/org/traccar/protocol/TotemProtocolDecoder.java
+++ b/src/org/traccar/protocol/TotemProtocolDecoder.java
@@ -92,35 +92,36 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
"\\p{XDigit}{4}" + // Checksum
"\r?\n?");
- private static final Pattern PATTERN3 = Pattern.compile(
- "\\$\\$" + // Header
- "\\p{XDigit}{2}" + // Length
- "(\\d+)\\|" + // IMEI
- "(..)" + // Alarm Type
- "(\\d{2})(\\d{2})(\\d{2})" + // Date (YYMMDD)
- "(\\d{2})(\\d{2})(\\d{2})" + // Time (HHMMSS)
- "(\\p{XDigit}{4})" + // IO Status
- "[01]" + // Charging
- "(\\d{2})" + // Battery
- "(\\d{2})" + // External Power
- "(\\d{4})" + // ADC 1
- "(\\d{4})" + // ADC 2
- "(\\d{3})" + // Temperature 1
- "(\\d{3})" + // Temperature 2
- "(\\p{XDigit}{8})" + // Location Code
- "([AV])" + // Validity
- "(\\d{2})" + // Satellites
- "(\\d{3})" + // Course
- "(\\d{3})" + // Speed
- "(\\d{2}\\.\\d)" + // PDOP
- "(\\d{7})" + // Odometer
- "(\\d{2})(\\d{2}\\.\\d{4})" + // Latitude (DDMM.MMMM)
- "([NS])" +
- "(\\d{3})(\\d{2}\\.\\d{4})" + // Longitude (DDDMM.MMMM)
- "([EW])" +
- "\\d{4}" + // Serial Number
- "\\p{XDigit}{4}" + // Checksum
- "\r?\n?");
+ private static final Pattern PATTERN3 = new PatternBuilder()
+ .txt("$$") // header
+ .num("xx") // length
+ .num("(d+)|") // imei
+ .xpr("(..)") // alarm type
+ .num("(dd)(dd)(dd)") // date (yymmdd)
+ .num("(dd)(dd)(dd)") // time (hhmmss)
+ .num("(xxxx)") // io status
+ .xpr("[01]") // charging
+ .num("(dd)") // battery
+ .num("(dd)") // external power
+ .num("(dddd)") // adc 1
+ .num("(dddd)") // adc 2
+ .num("(ddd)") // temperature 1
+ .num("(ddd)") // temperature 2
+ .num("(x{8})") // location code
+ .xpr("([AV])") // validity
+ .num("(dd)") // satellites
+ .num("(ddd)") // course
+ .num("(ddd)") // speed
+ .num("(dd.d)") // pdop
+ .num("(d{7})") // odometer
+ .num("(dd)(dd.dddd)") // latitude
+ .xpr("([NS])")
+ .num("(ddd)(dd.dddd)") // longitude
+ .xpr("([EW])")
+ .num("dddd") // serial number
+ .num("xxxx") // checksum
+ .any()
+ .compile();
@Override
protected Object decode(