aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/TelicProtocolDecoder.java
diff options
context:
space:
mode:
authorssmipp <sami@toosa.org>2017-01-28 08:59:41 +0200
committerssmipp <sami@toosa.org>2017-01-28 08:59:41 +0200
commit2b5afe7dac4b351c3ff1ba009c2439b4ba6de5f3 (patch)
treedce5007f34108518c032d9d8e46d7a496e92f8ac /src/org/traccar/protocol/TelicProtocolDecoder.java
parent6f6422186015e372ec314e0a3df557d4ee14cc49 (diff)
downloadtrackermap-server-2b5afe7dac4b351c3ff1ba009c2439b4ba6de5f3.tar.gz
trackermap-server-2b5afe7dac4b351c3ff1ba009c2439b4ba6de5f3.tar.bz2
trackermap-server-2b5afe7dac4b351c3ff1ba009c2439b4ba6de5f3.zip
- restored some original formatting
- use parser.nextInt() to get event value
Diffstat (limited to 'src/org/traccar/protocol/TelicProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/TelicProtocolDecoder.java48
1 files changed, 19 insertions, 29 deletions
diff --git a/src/org/traccar/protocol/TelicProtocolDecoder.java b/src/org/traccar/protocol/TelicProtocolDecoder.java
index a9b794c38..6f502bbd1 100644
--- a/src/org/traccar/protocol/TelicProtocolDecoder.java
+++ b/src/org/traccar/protocol/TelicProtocolDecoder.java
@@ -26,7 +26,6 @@ import org.traccar.model.Position;
import java.net.SocketAddress;
import java.util.regex.Pattern;
-import org.traccar.helper.Log;
public class TelicProtocolDecoder extends BaseProtocolDecoder {
@@ -36,27 +35,27 @@ public class TelicProtocolDecoder extends BaseProtocolDecoder {
private static final Pattern PATTERN = new PatternBuilder()
.number("dddd")
- .number("(d{6})") // device id
- .number("(d+),") // type
- .number("d{12},") // event time
+ .number("(d{6})") // device id
+ .number("(d+),") // type
+ .number("d{12},") // event time
.number("d+,")
- .number("(dd)(dd)(dd)") // date
- .number("(dd)(dd)(dd),") // time
+ .number("(dd)(dd)(dd)") // date
+ .number("(dd)(dd)(dd),") // time
.groupBegin()
- .number("(ddd)(dd)(dddd),") // longitude
- .number("(dd)(dd)(dddd),") // latitude
+ .number("(ddd)(dd)(dddd),") // longitude
+ .number("(dd)(dd)(dddd),") // latitude
.or()
- .number("(-?d+),") // longitude
- .number("(-?d+),") // latitude
+ .number("(-?d+),") // longitude
+ .number("(-?d+),") // latitude
.groupEnd()
- .number("(d),") // validity
- .number("(d+),") // speed
- .number("(d+),") // course
- .number("(d+),") // satellites
+ .number("(d),") // validity
+ .number("(d+),") // speed
+ .number("(d+),") // course
+ .number("(d+),") // satellites
.expression("(?:[^,]*,){7}")
- .number("(d+),") // battery
+ .number("(d+),") // battery
.expression("[^,]*,")
- .number("(d+),") // external
+ .number("(d+),") // external
.any()
.compile();
@@ -78,11 +77,10 @@ public class TelicProtocolDecoder extends BaseProtocolDecoder {
}
position.setDeviceId(deviceSession.getDeviceId());
- String eventValue = parser.next();
- position.set(Position.KEY_TYPE, eventValue);
+ int event = parser.nextInt();
+ position.set(Position.KEY_TYPE, event);
- // alarm
- position.set(Position.KEY_ALARM, decodeAlarm(eventValue));
+ position.set(Position.KEY_ALARM, decodeAlarm(event));
DateBuilder dateBuilder = new DateBuilder()
.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt())
@@ -110,15 +108,7 @@ public class TelicProtocolDecoder extends BaseProtocolDecoder {
return position;
}
- private String decodeAlarm(String event) {
-
- int eventId = 0;
-
- try {
- eventId = Integer.parseInt(event);
- } catch (Exception e) {
- Log.error("TelicProtocolDecoder: Error parsing event (" + eventId + "): " + e.toString());
- }
+ private String decodeAlarm(int eventId) {
switch (eventId) {
case 1: