aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/t55/T55ProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol/t55/T55ProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/t55/T55ProtocolDecoder.java57
1 files changed, 5 insertions, 52 deletions
diff --git a/src/org/traccar/protocol/t55/T55ProtocolDecoder.java b/src/org/traccar/protocol/t55/T55ProtocolDecoder.java
index ad674d4a8..5b1558c00 100644
--- a/src/org/traccar/protocol/t55/T55ProtocolDecoder.java
+++ b/src/org/traccar/protocol/t55/T55ProtocolDecoder.java
@@ -18,45 +18,29 @@ package org.traccar.protocol.t55;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.TimeZone;
-import java.util.Timer;
-import java.util.TimerTask;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.oneone.OneToOneDecoder;
import org.traccar.Position;
import org.traccar.DataManager;
-import org.jboss.netty.channel.ChannelEvent;
-import org.jboss.netty.channel.ChannelState;
-import org.jboss.netty.channel.ChannelStateEvent;
+import org.traccar.GenericProtocolDecoder;
/**
* T55 tracker protocol decoder
*/
-public class T55ProtocolDecoder extends OneToOneDecoder {
+public class T55ProtocolDecoder extends GenericProtocolDecoder {
/**
- * Data manager
- */
- private DataManager dataManager;
-
- /**
- * Reset connection delay
- */
- private Integer resetDelay;
-
- /**
* Device ID
*/
private Long deviceId;
/**
- * Init device table
+ * Initialize
*/
public T55ProtocolDecoder(DataManager dataManager, Integer resetDelay) {
- this.dataManager = dataManager;
- this.resetDelay = resetDelay;
+ super(dataManager, resetDelay);
}
/**
@@ -89,7 +73,7 @@ public class T55ProtocolDecoder extends OneToOneDecoder {
// Detect device ID
if (sentence.contains("$PGID")) {
String imei = sentence.substring(6, 6 + 15);
- deviceId = dataManager.getDeviceByImei(imei).getId();
+ deviceId = getDataManager().getDeviceByImei(imei).getId();
}
// Parse message
@@ -166,35 +150,4 @@ public class T55ProtocolDecoder extends OneToOneDecoder {
return null;
}
- /**
- * Disconnect channel
- */
- class DisconnectTask extends TimerTask {
- private Channel channel;
-
- public DisconnectTask(Channel channel) {
- this.channel = channel;
- }
-
- public void run() {
- channel.disconnect();
- }
- }
-
- /**
- * Handle connect event
- */
- @Override
- public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent evt) throws Exception {
- super.handleUpstream(ctx, evt);
-
- if (evt instanceof ChannelStateEvent) {
- ChannelStateEvent event = (ChannelStateEvent) evt;
-
- if (event.getState() == ChannelState.CONNECTED && event.getValue() != null && resetDelay != 0) {
- new Timer().schedule(new DisconnectTask(evt.getChannel()), resetDelay);
- }
- }
- }
-
}