aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/GoSafeProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-10-24 22:57:38 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-10-24 22:57:38 +1300
commit5538a83ac7eda6ad5775e582688dd0199e6c538c (patch)
tree7b261a5e9767fd807124c868d2c4a5d72315e7df /src/org/traccar/protocol/GoSafeProtocolDecoder.java
parentbe1baf2b062587099171b485ac1e3f591034816f (diff)
downloadtrackermap-server-5538a83ac7eda6ad5775e582688dd0199e6c538c.tar.gz
trackermap-server-5538a83ac7eda6ad5775e582688dd0199e6c538c.tar.bz2
trackermap-server-5538a83ac7eda6ad5775e582688dd0199e6c538c.zip
Refactor pattern builder class
Diffstat (limited to 'src/org/traccar/protocol/GoSafeProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/GoSafeProtocolDecoder.java96
1 files changed, 48 insertions, 48 deletions
diff --git a/src/org/traccar/protocol/GoSafeProtocolDecoder.java b/src/org/traccar/protocol/GoSafeProtocolDecoder.java
index cba045122..e1321633e 100644
--- a/src/org/traccar/protocol/GoSafeProtocolDecoder.java
+++ b/src/org/traccar/protocol/GoSafeProtocolDecoder.java
@@ -36,67 +36,67 @@ public class GoSafeProtocolDecoder extends BaseProtocolDecoder {
}
private static final Pattern PATTERN = new PatternBuilder()
- .txt("*GS") // header
- .num("d+,") // protocol version
- .num("(d+),") // imei
- .num("(dd)(dd)(dd)") // time
- .num("(dd)(dd)(dd),") // date
- .xpr("(.*)#?") // data
+ .text("*GS") // header
+ .number("d+,") // protocol version
+ .number("(d+),") // imei
+ .number("(dd)(dd)(dd)") // time
+ .number("(dd)(dd)(dd),") // date
+ .expression("(.*)#?") // data
.compile();
private static final Pattern PATTERN_ITEM = new PatternBuilder()
- .num("(x+)?,") // event
+ .number("(x+)?,") // event
.groupBegin()
- .txt("SYS:")
- .nxt(",")
- .groupEnd(true)
+ .text("SYS:")
+ .expression("[^,]*,")
+ .groupEnd("?")
.groupBegin()
- .txt("GPS:")
- .xpr("([AV]);") // validity
- .num("(d+);") // satellites
- .num("([NS])(d+.d+);") // latitude
- .num("([EW])(d+.d+);") // longitude
- .num("(d+);") // speed
- .num("(d+);") // course
- .num("(d+);") // altitude
- .num("(d+.d+)") // hdop
- .opn(";d+.d+") // vdop
- .xpr(",?")
- .groupEnd(false)
+ .text("GPS:")
+ .expression("([AV]);") // validity
+ .number("(d+);") // satellites
+ .number("([NS])(d+.d+);") // latitude
+ .number("([EW])(d+.d+);") // longitude
+ .number("(d+);") // speed
+ .number("(d+);") // course
+ .number("(d+);") // altitude
+ .number("(d+.d+)") // hdop
+ .number("(?:;d+.d+)?") // vdop
+ .expression(",?")
+ .groupEnd()
.groupBegin()
- .txt("GSM:").not(",").xpr(",?")
- .groupEnd(true)
+ .text("GSM:").expression("[^,],?")
+ .groupEnd("?")
.groupBegin()
- .txt("COT:")
- .num("(d+)") // odometer
- .opn(";d+:d+:d+") // engine hours
- .xpr(",?")
- .groupEnd(true)
+ .text("COT:")
+ .number("(d+)") // odometer
+ .number("(?:;d+:d+:d+)?") // engine hours
+ .expression(",?")
+ .groupEnd("?")
.groupBegin()
- .txt("ADC:")
- .num("(d+.d+);") // power
- .num("(d+.d+),?") // battery
- .groupEnd(true)
+ .text("ADC:")
+ .number("(d+.d+);") // power
+ .number("(d+.d+),?") // battery
+ .groupEnd("?")
.groupBegin()
- .txt("DTT:")
- .num("(x+);") // status
- .nxt(";")
- .num("x+;") // geo-fence 0-119
- .num("x+;") // geo-fence 120-155
- .num("x+,?") // event status
- .groupEnd(true)
+ .text("DTT:")
+ .number("(x+);") // status
+ .expression("[^;]*;")
+ .number("x+;") // geo-fence 0-119
+ .number("x+;") // geo-fence 120-155
+ .number("x+,?") // event status
+ .groupEnd("?")
.groupBegin()
- .txt("ETD:").not(",").xpr(",?")
- .groupEnd(true)
+ .text("ETD:").expression("[^,],?")
+ .groupEnd("?")
.groupBegin()
- .txt("OBD:").not(",").xpr(",?")
- .groupEnd(true)
+ .text("OBD:").expression("[^,],?")
+ .groupEnd("?")
.groupBegin()
- .txt("FUL:").not(",").xpr(",?")
- .groupEnd(true)
+ .text("FUL:").expression("[^,],?")
+ .groupEnd("?")
.groupBegin()
- .txt("TRU:").not(",").xpr(",?")
- .groupEnd(true)
+ .text("TRU:").expression("[^,],?")
+ .groupEnd("?")
.compile();
private Position decodePosition(Parser parser, Date time) {