diff options
author | Hans van den Elsen <hans.elsen@esds.nl> | 2016-02-13 16:13:35 +0100 |
---|---|---|
committer | Hans van den Elsen <hans.elsen@esds.nl> | 2016-02-13 16:13:35 +0100 |
commit | 54f8bba338b7262ad6c938bb2284c148fee6cd62 (patch) | |
tree | d87961aa0c060f461d17f9ac00b8122eb34be22b /src/org/traccar/protocol/Gps103ProtocolDecoder.java | |
parent | 8622ba6e081b987a96e3b1885209576f3c389266 (diff) | |
parent | 9b11013c2376ad0401c194d5cfa0014e0a08502e (diff) | |
download | trackermap-server-54f8bba338b7262ad6c938bb2284c148fee6cd62.tar.gz trackermap-server-54f8bba338b7262ad6c938bb2284c148fee6cd62.tar.bz2 trackermap-server-54f8bba338b7262ad6c938bb2284c148fee6cd62.zip |
Merge branch 'master' of https://github.com/tananaev/traccar
Diffstat (limited to 'src/org/traccar/protocol/Gps103ProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/Gps103ProtocolDecoder.java | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java index 2c7397231..a45e20ba2 100644 --- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 - 2015 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2012 - 2016 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,6 +78,27 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { .number("##,imei:(d+),A") .compile(); + private static final Pattern PATTERN_OBD = new PatternBuilder() + .text("imei:") + .number("(d+),") // imei + .expression("OBD,") // type + .number("(dd)(dd)(dd)") // date + .number("(dd)(dd)(dd),") // time + .number("(d+),") // odometer + .number("(d+.d+)?,") // fuel instant + .number("(?:d+.d+)?,") // fuel average + .number("(d+),") // speed + .number("d+,") // power load + .number("(d+.d+%),") // throttle + .number("(d+),") // rpm + .number("(d+.d+%),") // battery + .number("[^,]*,") // dtc 1 + .number("[^,]*,") // dtc 2 + .number("[^,]*,") // dtc 3 + .number("[^,]*") // dtc 4 + .any() + .compile(); + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -124,6 +145,31 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { } + parser = new Parser(PATTERN_OBD, sentence); + if (parser.matches()) { + + if (!identify(parser.next(), channel, remoteAddress)) { + return null; + } + position.setDeviceId(getDeviceId()); + + DateBuilder dateBuilder = new DateBuilder() + .setDate(parser.nextInt(), parser.nextInt(), parser.nextInt()) + .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt()); + + getLastLocation(position, dateBuilder.getDate()); + + position.set(Event.KEY_ODOMETER, parser.nextInt()); + position.set(Event.KEY_FUEL, parser.next()); + position.set(Event.KEY_OBD_SPEED, parser.next()); + position.set(Event.KEY_THROTTLE, parser.next()); + position.set(Event.KEY_RPM, parser.next()); + position.set(Event.KEY_BATTERY, parser.next()); + + return position; + + } + parser = new Parser(PATTERN, sentence); if (!parser.matches()) { return null; |