aboutsummaryrefslogtreecommitdiff
path: root/src/net/sourceforge/opentracking/Server.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2011-09-05 08:07:43 +0000
committerAnton Tananaev <anton.tananaev@gmail.com>2011-09-05 08:07:43 +0000
commit68d855d0f3c7fa09003c8ae497060831c7bdce7f (patch)
tree6ca413488db8c2697550b66dc89ddb0beff7ae56 /src/net/sourceforge/opentracking/Server.java
parent39e60fdb4c4427d73881e4dc692c87b135582a8e (diff)
downloadtrackermap-server-68d855d0f3c7fa09003c8ae497060831c7bdce7f.tar.gz
trackermap-server-68d855d0f3c7fa09003c8ae497060831c7bdce7f.tar.bz2
trackermap-server-68d855d0f3c7fa09003c8ae497060831c7bdce7f.zip
Diffstat (limited to 'src/net/sourceforge/opentracking/Server.java')
-rw-r--r--src/net/sourceforge/opentracking/Server.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/net/sourceforge/opentracking/Server.java b/src/net/sourceforge/opentracking/Server.java
index b34e4cf46..5d1332f38 100644
--- a/src/net/sourceforge/opentracking/Server.java
+++ b/src/net/sourceforge/opentracking/Server.java
@@ -44,6 +44,7 @@ import net.sourceforge.opentracking.protocol.xexun.XexunFrameDecoder;
import net.sourceforge.opentracking.protocol.xexun.XexunProtocolDecoder;
import net.sourceforge.opentracking.protocol.gps103.Gps103ProtocolDecoder;
import net.sourceforge.opentracking.protocol.tk103.Tk103ProtocolDecoder;
+import net.sourceforge.opentracking.protocol.gl200.Gl200ProtocolDecoder;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
@@ -90,6 +91,7 @@ public class Server implements DataManager {
initXexunServer(properties);
initGps103Server(properties);
initTk103Server(properties);
+ initGl200Server(properties);
}
/**
@@ -177,6 +179,7 @@ public class Server implements DataManager {
insertPosition.setLong("device_id", position.getDeviceId());
insertPosition.setTimestamp("time", position.getTime());
insertPosition.setBoolean("valid", position.getValid());
+ insertPosition.setDouble("altitude", position.getAltitude());
insertPosition.setDouble("latitude", position.getLatitude());
insertPosition.setDouble("longitude", position.getLongitude());
insertPosition.setDouble("speed", position.getSpeed());
@@ -393,6 +396,58 @@ public class Server implements DataManager {
}
/**
+ * Gl200 pipeline factory
+ */
+ protected class Gl200PipelineFactory implements ChannelPipelineFactory {
+
+ private TrackerServer server;
+ private Server serverCreator;
+ private Integer resetDelay;
+
+ public Gl200PipelineFactory(
+ TrackerServer server, Server serverCreator, Integer resetDelay) {
+ this.server = server;
+ this.serverCreator = serverCreator;
+ this.resetDelay = resetDelay;
+ }
+
+ public ChannelPipeline getPipeline() {
+ ChannelPipeline pipeline = Channels.pipeline();
+ pipeline.addLast("openHandler", new OpenChannelHandler(server));
+ if (serverCreator.isLoggerEnabled()) {
+ pipeline.addLast("logger", new LoggingHandler("logger"));
+ }
+ byte delimiter[] = { (byte) '$' };
+ pipeline.addLast("frameDecoder",
+ new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter)));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new Gl200ProtocolDecoder(serverCreator, resetDelay));
+ pipeline.addLast("handler", new TrackerEventHandler(serverCreator));
+ return pipeline;
+ }
+ }
+
+ /**
+ * Init Gl200 server
+ */
+ public void initGl200Server(Properties properties) throws SQLException {
+
+ boolean enable = Boolean.valueOf(properties.getProperty("gl200.enable"));
+ if (enable) {
+
+ TrackerServer server = new TrackerServer(
+ Integer.valueOf(properties.getProperty("gl200.port")));
+
+ String resetDelay = properties.getProperty("gl200.resetDelay");
+ server.setPipelineFactory(new Gl200PipelineFactory(
+ server, this, (resetDelay == null) ? 0 : Integer.valueOf(resetDelay)));
+
+ serverList.add(server);
+ }
+ }
+
+ /**
* Start
*/
public void start() {