From 2a3fad9496decd83f06ae5abf067f8d4337ec741 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 23 Apr 2015 15:49:56 +1200 Subject: Major code refacroting --- src/org/traccar/protocol/Jt600ProtocolDecoder.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/org/traccar/protocol/Jt600ProtocolDecoder.java') diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java index 197b4103a..80c584d21 100644 --- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java +++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java @@ -35,8 +35,8 @@ import org.traccar.model.Position; public class Jt600ProtocolDecoder extends BaseProtocolDecoder { - public Jt600ProtocolDecoder(DataManager dataManager, String protocol, Properties properties) { - super(dataManager, protocol, properties); + public Jt600ProtocolDecoder(String protocol) { + super(protocol); } private Position decodeNormalMessage(ChannelBuffer buf) throws Exception { @@ -48,12 +48,10 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { // Get device by identifier String id = Long.valueOf(ChannelBufferTools.readHexString(buf, 10)).toString(); - try { - position.setDeviceId(getDataManager().getDeviceByImei(id).getId()); - } catch(Exception error) { - Log.warning("Unknown device - " + id); - //return null; + if (!identify(id)) { + return null; } + position.setDeviceId(getDeviceId()); // Protocol and type int version = ChannelBufferTools.readHexInteger(buf, 1); @@ -166,13 +164,10 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { Integer index = 1; // Get device by identifier - String id = parser.group(index++); - try { - position.setDeviceId(getDataManager().getDeviceByImei(id).getId()); - } catch(Exception error) { - Log.warning("Unknown device - " + id); + if (!identify(parser.group(index++))) { return null; } + position.setDeviceId(getDeviceId()); // Longitude Double longitude = Double.valueOf(parser.group(index++)); -- cgit v1.2.3