diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2012-03-22 04:54:46 +0000 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2012-03-22 04:54:46 +0000 |
commit | d0de5245574e223384d9e89421850af16fb7a848 (patch) | |
tree | 8203e522ecfc6540284ef3c29c9af1c42be5e84a /src/org/traccar/protocol/avl08/Avl08ProtocolDecoder.java | |
parent | 2298302ea7f3b4f09b52638355c2b86a952a8306 (diff) | |
download | trackermap-server-d0de5245574e223384d9e89421850af16fb7a848.tar.gz trackermap-server-d0de5245574e223384d9e89421850af16fb7a848.tar.bz2 trackermap-server-d0de5245574e223384d9e89421850af16fb7a848.zip |
Diffstat (limited to 'src/org/traccar/protocol/avl08/Avl08ProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/avl08/Avl08ProtocolDecoder.java | 63 |
1 files changed, 5 insertions, 58 deletions
diff --git a/src/org/traccar/protocol/avl08/Avl08ProtocolDecoder.java b/src/org/traccar/protocol/avl08/Avl08ProtocolDecoder.java index ca59b8413..cc8a2efb7 100644 --- a/src/org/traccar/protocol/avl08/Avl08ProtocolDecoder.java +++ b/src/org/traccar/protocol/avl08/Avl08ProtocolDecoder.java @@ -15,49 +15,27 @@ */ package org.traccar.protocol.avl08; -import java.text.ParseException; 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; /** * AVL-08 tracker protocol decoder */ -public class Avl08ProtocolDecoder extends OneToOneDecoder { +public class Avl08ProtocolDecoder extends GenericProtocolDecoder { /** - * Data manager - */ - private DataManager dataManager; - - /** - * Reset connection delay - */ - private Integer resetDelay; - - /** - * Device ID - */ - private Long deviceId; - - /** - * Init device table + * Initialize */ public Avl08ProtocolDecoder(DataManager dataManager, Integer resetDelay) { - this.dataManager = dataManager; - this.resetDelay = resetDelay; + super(dataManager, resetDelay); } /** @@ -99,7 +77,7 @@ public class Avl08ProtocolDecoder extends OneToOneDecoder { // Get device by IMEI String imei = parser.group(index++); - position.setDeviceId(dataManager.getDeviceByImei(imei).getId()); + position.setDeviceId(getDataManager().getDeviceByImei(imei).getId()); // Time Calendar time = new GregorianCalendar(TimeZone.getTimeZone("UTC")); @@ -147,35 +125,4 @@ public class Avl08ProtocolDecoder extends OneToOneDecoder { return position; } - /** - * 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 Avl08ProtocolDecoder.DisconnectTask(evt.getChannel()), resetDelay); - } - } - } - } |