aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/WialonProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-04-23 15:49:56 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-04-23 15:49:56 +1200
commit2a3fad9496decd83f06ae5abf067f8d4337ec741 (patch)
tree69837f0bf89cf6ff78915d70380118575cc5c47a /src/org/traccar/protocol/WialonProtocolDecoder.java
parenta8d2a0170b7ac891ffe784320ac2d1389f11bf68 (diff)
downloadtrackermap-server-2a3fad9496decd83f06ae5abf067f8d4337ec741.tar.gz
trackermap-server-2a3fad9496decd83f06ae5abf067f8d4337ec741.tar.bz2
trackermap-server-2a3fad9496decd83f06ae5abf067f8d4337ec741.zip
Major code refacroting
Diffstat (limited to 'src/org/traccar/protocol/WialonProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/WialonProtocolDecoder.java15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/org/traccar/protocol/WialonProtocolDecoder.java b/src/org/traccar/protocol/WialonProtocolDecoder.java
index 6c4c0e8db..76cf9b924 100644
--- a/src/org/traccar/protocol/WialonProtocolDecoder.java
+++ b/src/org/traccar/protocol/WialonProtocolDecoder.java
@@ -34,10 +34,8 @@ import org.traccar.model.Position;
public class WialonProtocolDecoder extends BaseProtocolDecoder {
- private Long deviceId;
-
- public WialonProtocolDecoder(DataManager dataManager, String protocol, Properties properties) {
- super(dataManager, protocol, properties);
+ public WialonProtocolDecoder(String protocol) {
+ super(protocol);
}
private static final Pattern pattern = Pattern.compile(
@@ -75,14 +73,14 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder {
// Parse message
Matcher parser = pattern.matcher(substring);
- if (deviceId == null || !parser.matches()) {
+ if (!hasDeviceId() || !parser.matches()) {
return null;
}
// Create new position
Position position = new Position();
ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());
- position.setDeviceId(deviceId);
+ position.setDeviceId(getDeviceId());
Integer index = 1;
@@ -187,11 +185,8 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder {
// Detect device ID
if (sentence.startsWith("#L#")) {
String imei = sentence.substring(3, sentence.indexOf(';'));
- try {
- deviceId = getDataManager().getDeviceByImei(imei).getId();
+ if (identify(imei)) {
sendResponse(channel, "#AL#", 1);
- } catch(Exception error) {
- Log.warning("Unknown device - " + imei);
}
}