aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/GlobalSatProtocolDecoder.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/GlobalSatProtocolDecoder.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/GlobalSatProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/GlobalSatProtocolDecoder.java19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java
index fd0c04bb4..1a0132c4a 100644
--- a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java
+++ b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java
@@ -25,6 +25,7 @@ import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
+import org.traccar.Context;
import org.traccar.database.DataManager;
import org.traccar.helper.Log;
import org.traccar.model.ExtendedInfoFormatter;
@@ -36,9 +37,10 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder {
private String format0 = "TSPRXAB27GHKLMnaicz*U!";
private String format1 = "SARY*U!";
- public GlobalSatProtocolDecoder(DataManager dataManager, String protocol, Properties properties) {
- super(dataManager, protocol, properties);
+ public GlobalSatProtocolDecoder(String protocol) {
+ super(protocol);
+ Properties properties = Context.getProps();
if (properties != null) {
if (properties.containsKey(protocol + ".format0")) {
format0 = properties.getProperty(protocol + ".format0");
@@ -97,12 +99,10 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder {
switch(format.charAt(formatIndex)) {
case 'S':
- try {
- position.setDeviceId(getDataManager().getDeviceByImei(value).getId());
- } catch(Exception error) {
- Log.warning("Unknown device - " + value);
+ if (!identify(value)) {
return null;
}
+ position.setDeviceId(getDeviceId());
break;
case 'A':
if (value.isEmpty()) {
@@ -215,13 +215,10 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder {
Integer index = 1;
// Identification
- String imei = parser.group(index++);
- try {
- position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
- } catch(Exception error) {
- Log.warning("Unknown device - " + imei);
+ if (!identify(parser.group(index++))) {
return null;
}
+ position.setDeviceId(getDeviceId());
// Validity
position.setValid(parser.group(index++).compareTo("1") != 0);