aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-11-15 10:55:43 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2018-11-15 10:55:43 +1300
commite36c69db0c5e610d30977de7b2fa71e715d9a1ae (patch)
tree23dc1bb35a235f5a5dd8607efcd9a223913ee0fe /src/org/traccar/protocol
parent997cd43457c01440ec32ec19e0fa3f3b7be3bdb9 (diff)
downloadtraccar-server-e36c69db0c5e610d30977de7b2fa71e715d9a1ae.tar.gz
traccar-server-e36c69db0c5e610d30977de7b2fa71e715d9a1ae.tar.bz2
traccar-server-e36c69db0c5e610d30977de7b2fa71e715d9a1ae.zip
Support Sysomate TMD-300 format
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/TrakMateProtocolDecoder.java74
1 files changed, 44 insertions, 30 deletions
diff --git a/src/org/traccar/protocol/TrakMateProtocolDecoder.java b/src/org/traccar/protocol/TrakMateProtocolDecoder.java
index f677ab36e..4d5cb18f5 100644
--- a/src/org/traccar/protocol/TrakMateProtocolDecoder.java
+++ b/src/org/traccar/protocol/TrakMateProtocolDecoder.java
@@ -45,7 +45,8 @@ public class TrakMateProtocolDecoder extends BaseProtocolDecoder {
.compile();
private static final Pattern PATTERN_PER = new PatternBuilder()
- .text("^TMPER|")
+ .text("^TM")
+ .expression("...|") // type
.expression("([^ ]+)|") // uid
.number("(d+)|") // seq
.number("(d+.d+)|") // latitude
@@ -54,17 +55,23 @@ public class TrakMateProtocolDecoder extends BaseProtocolDecoder {
.number("(dd)(dd)(dd)|") // date (ddmmyy)
.number("(d+.d+)|") // speed
.number("(d+.d+)|") // heading
- .number("(d+)|") // ignition
+ .number("(d+)|").optional() // satellites
+ .number("([01])|") // ignition
+ .groupBegin()
.number("(d+)|") // dop1
.number("(d+)|") // dop2
.number("(d+.d+)|") // analog
.number("(d+.d+)|") // internal battery
+ .or()
+ .number("-?d+ -?d+ -?d+|") // accelerometer
+ .number("([01])|") // movement
+ .groupEnd()
.number("(d+.d+)|") // vehicle battery
.number("(d+.d+)|") // gps odometer
- .number("(d+.d+)|") // pulse odometer
- .number("(d+)|") // main power status
- .number("(d+)|") // gps data validity
- .number("(d+)|") // live or cache
+ .number("(d+.d+)|").optional() // pulse odometer
+ .number("([01])|") // main power status
+ .number("([01])|") // gps data validity
+ .number("([01])|") // live or cache
.any()
.compile();
@@ -111,8 +118,8 @@ public class TrakMateProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
- position.setLatitude(parser.nextDouble(0));
- position.setLongitude(parser.nextDouble(0));
+ position.setLatitude(parser.nextDouble());
+ position.setLongitude(parser.nextDouble());
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.HMS_DMY));
@@ -138,16 +145,16 @@ public class TrakMateProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
parser.next(); // seq
- position.set(Position.KEY_ALARM, decodeAlarm(parser.nextInt(0)));
+ position.set(Position.KEY_ALARM, decodeAlarm(parser.nextInt()));
parser.next(); // alert status or data
- position.setLatitude(parser.nextDouble(0));
- position.setLongitude(parser.nextDouble(0));
+ position.setLatitude(parser.nextDouble());
+ position.setLongitude(parser.nextDouble());
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.HMS_DMY));
- position.setSpeed(parser.nextDouble(0));
- position.setCourse(parser.nextDouble(0));
+ position.setSpeed(parser.nextDouble());
+ position.setCourse(parser.nextDouble());
return position;
}
@@ -169,27 +176,36 @@ public class TrakMateProtocolDecoder extends BaseProtocolDecoder {
parser.next(); // seq
- position.setLatitude(parser.nextDouble(0));
- position.setLongitude(parser.nextDouble(0));
+ position.setLatitude(parser.nextDouble());
+ position.setLongitude(parser.nextDouble());
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.HMS_DMY));
- position.setSpeed(parser.nextDouble(0));
- position.setCourse(parser.nextDouble(0));
+ position.setSpeed(parser.nextDouble());
+ position.setCourse(parser.nextDouble());
+
+ position.set(Position.KEY_SATELLITES, parser.nextInt());
+ position.set(Position.KEY_IGNITION, parser.nextInt() > 0);
+
+ if (parser.hasNext(4)) {
+ position.set("dop1", parser.nextInt());
+ position.set("dop2", parser.nextInt());
+ position.set(Position.PREFIX_ADC + 1, parser.nextDouble());
+ position.set(Position.KEY_BATTERY, parser.nextDouble());
+ }
+
+ if (parser.hasNext()) {
+ position.set(Position.KEY_MOTION, parser.nextInt(0) > 0);
+ }
- position.set(Position.KEY_IGNITION, parser.nextInt(0) == 1);
- position.set("dop1", parser.next());
- position.set("dop2", parser.next());
- position.set(Position.KEY_INPUT, parser.next());
- position.set(Position.KEY_BATTERY, parser.nextDouble(0));
position.set(Position.KEY_POWER, parser.nextDouble());
- position.set(Position.KEY_ODOMETER, parser.nextDouble(0));
- position.set("pulseOdometer", parser.next());
- position.set(Position.KEY_STATUS, parser.nextInt(0));
+ position.set(Position.KEY_ODOMETER, parser.nextDouble());
+ position.set("pulseOdometer", parser.nextDouble());
+ position.set(Position.KEY_STATUS, parser.nextInt());
- position.setValid(parser.nextInt(0) != 0);
+ position.setValid(parser.nextInt() > 0);
- position.set(Position.KEY_ARCHIVE, parser.nextInt(0) == 1);
+ position.set(Position.KEY_ARCHIVE, parser.nextInt() > 0);
return position;
}
@@ -209,10 +225,8 @@ public class TrakMateProtocolDecoder extends BaseProtocolDecoder {
return decodeAlt(channel, remoteAddress, sentence);
case "SRT":
return decodeSrt(channel, remoteAddress, sentence);
- case "PER":
- return decodePer(channel, remoteAddress, sentence);
default:
- return null;
+ return decodePer(channel, remoteAddress, sentence);
}
}