aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/BasePipelineFactory.java (renamed from src/org/traccar/GenericPipelineFactory.java)11
-rw-r--r--src/org/traccar/BaseProtocolDecoder.java (renamed from src/org/traccar/GenericProtocolDecoder.java)37
-rw-r--r--src/org/traccar/ServerManager.java50
-rw-r--r--src/org/traccar/TrackerServer.java4
-rw-r--r--src/org/traccar/protocol/Avl08ProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/EnforaProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/Ev603ProtocolDecoder.java30
-rw-r--r--src/org/traccar/protocol/Gl100ProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/Gl200ProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/Gps103ProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/Gt02ProtocolDecoder.java44
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/H02ProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/Jt600ProtocolDecoder.java52
-rw-r--r--src/org/traccar/protocol/MaxonProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/MeiligaoProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/MeitrackProtocolDecoder.java20
-rw-r--r--src/org/traccar/protocol/NavisProtocolDecoder.java78
-rw-r--r--src/org/traccar/protocol/ProgressProtocolDecoder.java22
-rw-r--r--src/org/traccar/protocol/Pt502ProtocolDecoder.java13
-rw-r--r--src/org/traccar/protocol/ST210ProtocolDecoder.java123
-rw-r--r--src/org/traccar/protocol/SkypatrolProtocolDecoder.java54
-rw-r--r--src/org/traccar/protocol/T55ProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/Tk103ProtocolDecoder.java12
-rw-r--r--src/org/traccar/protocol/Tr20ProtocolDecoder.java28
-rw-r--r--src/org/traccar/protocol/V680ProtocolDecoder.java24
-rw-r--r--src/org/traccar/protocol/Xexun2ProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/XexunProtocolDecoder.java10
28 files changed, 358 insertions, 364 deletions
diff --git a/src/org/traccar/GenericPipelineFactory.java b/src/org/traccar/BasePipelineFactory.java
index 4537ac4f7..139f5e526 100644
--- a/src/org/traccar/GenericPipelineFactory.java
+++ b/src/org/traccar/BasePipelineFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2012 - 2013 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,9 +26,9 @@ import org.traccar.helper.Log;
import org.traccar.model.DataManager;
/**
- * Generic pipeline factory
+ * Base pipeline factory
*/
-public abstract class GenericPipelineFactory implements ChannelPipelineFactory {
+public abstract class BasePipelineFactory implements ChannelPipelineFactory {
private TrackerServer server;
private DataManager dataManager;
@@ -85,7 +85,7 @@ public abstract class GenericPipelineFactory implements ChannelPipelineFactory {
}
}
- public GenericPipelineFactory(ServerManager serverManager, TrackerServer server, String protocol) {
+ public BasePipelineFactory(ServerManager serverManager, TrackerServer server, String protocol) {
this.server = server;
dataManager = serverManager.getDataManager();
loggerEnabled = serverManager.isLoggerEnabled();
@@ -120,4 +120,5 @@ public abstract class GenericPipelineFactory implements ChannelPipelineFactory {
pipeline.addLast("handler", new TrackerEventHandler(dataManager));
return pipeline;
}
-} \ No newline at end of file
+
+}
diff --git a/src/org/traccar/GenericProtocolDecoder.java b/src/org/traccar/BaseProtocolDecoder.java
index 440b37dcb..9b8dbb362 100644
--- a/src/org/traccar/GenericProtocolDecoder.java
+++ b/src/org/traccar/BaseProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2012 - 2013 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,47 +15,38 @@
*/
package org.traccar;
-import java.util.Timer;
-import java.util.TimerTask;
-import org.jboss.netty.channel.*;
import org.jboss.netty.handler.codec.oneone.OneToOneDecoder;
import org.traccar.model.DataManager;
/**
* Base class for protocol decoders
*/
-public abstract class GenericProtocolDecoder extends OneToOneDecoder {
+public abstract class BaseProtocolDecoder extends OneToOneDecoder {
- /**
- * Data manager
- */
+ private ServerManager serverManager;
private DataManager dataManager;
- /**
- * Set data manager
- */
public final void setDataManager(DataManager dataManager) {
this.dataManager = dataManager;
}
- /**
- * Return data manager
- */
public final DataManager getDataManager() {
return dataManager;
}
- /**
- * Default constructor
- */
- public GenericProtocolDecoder() {
+ public final void setServerManager(ServerManager serverManager) {
+ this.serverManager = serverManager;
}
- /**
- * Initialize
- */
- public GenericProtocolDecoder(DataManager dataManager) {
- setDataManager(dataManager);
+ public final ServerManager getServerManager() {
+ return serverManager;
+ }
+
+ public BaseProtocolDecoder() {
+ }
+
+ public BaseProtocolDecoder(ServerManager serverManager) {
+ this.serverManager = serverManager;
}
}
diff --git a/src/org/traccar/ServerManager.java b/src/org/traccar/ServerManager.java
index 68c537cba..b1cd51040 100644
--- a/src/org/traccar/ServerManager.java
+++ b/src/org/traccar/ServerManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2012 - 2013 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -234,7 +234,7 @@ public class ServerManager {
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new XexunFrameDecoder());
pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new XexunProtocolDecoder(getDataManager()));
+ pipeline.addLast("objectDecoder", new XexunProtocolDecoder(ServerManager.this));
}
});
}
@@ -250,7 +250,7 @@ public class ServerManager {
new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter)));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new Gps103ProtocolDecoder(getDataManager()));
+ pipeline.addLast("objectDecoder", new Gps103ProtocolDecoder(ServerManager.this));
}
});
}
@@ -266,7 +266,7 @@ public class ServerManager {
new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter)));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new Tk103ProtocolDecoder(getDataManager()));
+ pipeline.addLast("objectDecoder", new Tk103ProtocolDecoder(ServerManager.this));
}
});
}
@@ -282,7 +282,7 @@ public class ServerManager {
new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter)));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new Gl100ProtocolDecoder(getDataManager()));
+ pipeline.addLast("objectDecoder", new Gl100ProtocolDecoder(ServerManager.this));
}
});
}
@@ -298,7 +298,7 @@ public class ServerManager {
new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter)));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new Gl200ProtocolDecoder(getDataManager()));
+ pipeline.addLast("objectDecoder", new Gl200ProtocolDecoder(ServerManager.this));
}
});
}
@@ -314,7 +314,7 @@ public class ServerManager {
new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter)));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new T55ProtocolDecoder(getDataManager()));
+ pipeline.addLast("objectDecoder", new T55ProtocolDecoder(ServerManager.this));
}
});
}
@@ -329,7 +329,7 @@ public class ServerManager {
pipeline.addLast("frameDecoder",
new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter)));
pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new Xexun2ProtocolDecoder(getDataManager()));
+ pipeline.addLast("objectDecoder", new Xexun2ProtocolDecoder(ServerManager.this));
}
});
}
@@ -344,7 +344,7 @@ public class ServerManager {
pipeline.addLast("frameDecoder",
new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter)));
pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new Avl08ProtocolDecoder(getDataManager()));
+ pipeline.addLast("objectDecoder", new Avl08ProtocolDecoder(ServerManager.this));
}
});
}
@@ -356,7 +356,7 @@ public class ServerManager {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 0, 2, -2, 2));
- pipeline.addLast("objectDecoder", new EnforaProtocolDecoder(getDataManager()));
+ pipeline.addLast("objectDecoder", new EnforaProtocolDecoder(ServerManager.this));
}
});
}
@@ -368,7 +368,7 @@ public class ServerManager {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, -4, 4));
- pipeline.addLast("objectDecoder", new MeiligaoProtocolDecoder(getDataManager()));
+ pipeline.addLast("objectDecoder", new MeiligaoProtocolDecoder(ServerManager.this));
}
});
}
@@ -384,7 +384,7 @@ public class ServerManager {
new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter)));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new MaxonProtocolDecoder(getDataManager()));
+ pipeline.addLast("objectDecoder", new MaxonProtocolDecoder(ServerManager.this));
}
});
}
@@ -399,7 +399,7 @@ public class ServerManager {
pipeline.addLast("frameDecoder",
new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter)));
pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new ST210ProtocolDecoder(getDataManager()));
+ pipeline.addLast("objectDecoder", new ST210ProtocolDecoder(ServerManager.this));
}
});
}
@@ -411,7 +411,7 @@ public class ServerManager {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, 0, 0));
- pipeline.addLast("objectDecoder", new ProgressProtocolDecoder(getDataManager()));
+ pipeline.addLast("objectDecoder", new ProgressProtocolDecoder(ServerManager.this));
}
});
}
@@ -426,7 +426,7 @@ public class ServerManager {
pipeline.addLast("frameDecoder",
new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter)));
pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new H02ProtocolDecoder(getDataManager()));
+ pipeline.addLast("objectDecoder", new H02ProtocolDecoder(ServerManager.this));
}
});
}
@@ -438,7 +438,7 @@ public class ServerManager {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new Jt600FrameDecoder());
- pipeline.addLast("objectDecoder", new Jt600ProtocolDecoder(getDataManager()));
+ pipeline.addLast("objectDecoder", new Jt600ProtocolDecoder(ServerManager.this));
}
});
}
@@ -453,7 +453,7 @@ public class ServerManager {
pipeline.addLast("frameDecoder",
new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter)));
pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new Ev603ProtocolDecoder(getDataManager()));
+ pipeline.addLast("objectDecoder", new Ev603ProtocolDecoder(ServerManager.this));
}
});
}
@@ -468,7 +468,7 @@ public class ServerManager {
pipeline.addLast("frameDecoder",
new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter)));
pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new V680ProtocolDecoder(getDataManager()));
+ pipeline.addLast("objectDecoder", new V680ProtocolDecoder(ServerManager.this));
}
});
}
@@ -484,7 +484,7 @@ public class ServerManager {
new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter)));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new Pt502ProtocolDecoder(getDataManager()));
+ pipeline.addLast("objectDecoder", new Pt502ProtocolDecoder(ServerManager.this));
}
});
}
@@ -500,7 +500,7 @@ public class ServerManager {
new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter)));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new Tr20ProtocolDecoder(getDataManager()));
+ pipeline.addLast("objectDecoder", new Tr20ProtocolDecoder(ServerManager.this));
}
});
}
@@ -512,7 +512,7 @@ public class ServerManager {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(4 * 1024, 12, 2, 2, 0));
- pipeline.addLast("objectDecoder", new NavisProtocolDecoder(getDataManager()));
+ pipeline.addLast("objectDecoder", new NavisProtocolDecoder(ServerManager.this));
}
});
}
@@ -528,7 +528,7 @@ public class ServerManager {
new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter)));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new MeitrackProtocolDecoder(getDataManager()));
+ pipeline.addLast("objectDecoder", new MeitrackProtocolDecoder(ServerManager.this));
}
});
}
@@ -539,7 +539,7 @@ public class ServerManager {
serverList.add(new TrackerServer(this, new ConnectionlessBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("objectDecoder", new SkypatrolProtocolDecoder(getDataManager()));
+ pipeline.addLast("objectDecoder", new SkypatrolProtocolDecoder(ServerManager.this));
}
});
}
@@ -551,7 +551,7 @@ public class ServerManager {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(256, 2, 1, 2, 0));
- pipeline.addLast("objectDecoder", new Gt02ProtocolDecoder(getDataManager()));
+ pipeline.addLast("objectDecoder", new Gt02ProtocolDecoder(ServerManager.this));
}
});
}
@@ -563,7 +563,7 @@ public class ServerManager {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(256, 2, 1, 2, 0));
- pipeline.addLast("objectDecoder", new Gt06ProtocolDecoder(getDataManager()));
+ pipeline.addLast("objectDecoder", new Gt06ProtocolDecoder(ServerManager.this));
}
});
}
diff --git a/src/org/traccar/TrackerServer.java b/src/org/traccar/TrackerServer.java
index 36c0ce70e..1d7185fe6 100644
--- a/src/org/traccar/TrackerServer.java
+++ b/src/org/traccar/TrackerServer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2012 - 2013 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,7 +52,7 @@ public abstract class TrackerServer {
String portProperty = serverManager.getProperties().getProperty(protocol + ".port");
port = (portProperty != null) ? Integer.valueOf(portProperty) : 5000;
- bootstrap.setPipelineFactory(new GenericPipelineFactory(serverManager, this, protocol) {
+ bootstrap.setPipelineFactory(new BasePipelineFactory(serverManager, this, protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
TrackerServer.this.addSpecificHandlers(pipeline);
diff --git a/src/org/traccar/protocol/Avl08ProtocolDecoder.java b/src/org/traccar/protocol/Avl08ProtocolDecoder.java
index a01771c35..488008be4 100644
--- a/src/org/traccar/protocol/Avl08ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Avl08ProtocolDecoder.java
@@ -21,21 +21,21 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.traccar.GenericProtocolDecoder;
+import org.traccar.BaseProtocolDecoder;
+import org.traccar.ServerManager;
import org.traccar.helper.Log;
-import org.traccar.model.DataManager;
import org.traccar.model.Position;
/**
* AVL-08 tracker protocol decoder
*/
-public class Avl08ProtocolDecoder extends GenericProtocolDecoder {
+public class Avl08ProtocolDecoder extends BaseProtocolDecoder {
/**
* Initialize
*/
- public Avl08ProtocolDecoder(DataManager dataManager) {
- super(dataManager);
+ public Avl08ProtocolDecoder(ServerManager serverManager) {
+ super(serverManager);
}
/**
diff --git a/src/org/traccar/protocol/EnforaProtocolDecoder.java b/src/org/traccar/protocol/EnforaProtocolDecoder.java
index aa6dbaf13..e389e0fdd 100644
--- a/src/org/traccar/protocol/EnforaProtocolDecoder.java
+++ b/src/org/traccar/protocol/EnforaProtocolDecoder.java
@@ -23,22 +23,22 @@ import java.util.regex.Pattern;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.traccar.GenericProtocolDecoder;
+import org.traccar.BaseProtocolDecoder;
+import org.traccar.ServerManager;
import org.traccar.helper.ChannelBufferTools;
import org.traccar.helper.Log;
-import org.traccar.model.DataManager;
import org.traccar.model.Position;
/**
* Enfora protocol decoder
*/
-public class EnforaProtocolDecoder extends GenericProtocolDecoder {
+public class EnforaProtocolDecoder extends BaseProtocolDecoder {
/**
* Initialize
*/
- public EnforaProtocolDecoder(DataManager dataManager) {
- super(dataManager);
+ public EnforaProtocolDecoder(ServerManager serverManager) {
+ super(serverManager);
}
/**
diff --git a/src/org/traccar/protocol/Ev603ProtocolDecoder.java b/src/org/traccar/protocol/Ev603ProtocolDecoder.java
index 6d89120a8..e80717cdf 100644
--- a/src/org/traccar/protocol/Ev603ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Ev603ProtocolDecoder.java
@@ -1,7 +1,7 @@
/*
* Copyright 2012 Anton Tananaev (anton.tananaev@gmail.com)
* Luis Parada (luis.parada@gmail.com)
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -22,28 +22,28 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.traccar.GenericProtocolDecoder;
+import org.traccar.BaseProtocolDecoder;
+import org.traccar.ServerManager;
import org.traccar.helper.Log;
-import org.traccar.model.DataManager;
import org.traccar.model.Position;
/**
* Ev603 Protocol Decoder
*/
-public class Ev603ProtocolDecoder extends GenericProtocolDecoder{
+public class Ev603ProtocolDecoder extends BaseProtocolDecoder{
/**
* Device ID
*/
private Long deviceId;
-
+
/**
* Initialize
*/
- public Ev603ProtocolDecoder(DataManager dataManager) {
- super(dataManager);
+ public Ev603ProtocolDecoder(ServerManager serverManager) {
+ super(serverManager);
}
-
+
/**
* Regular expressions pattern
*/
@@ -76,20 +76,20 @@ public class Ev603ProtocolDecoder extends GenericProtocolDecoder{
return null;
}
}
-
+
else if (sentence.startsWith("!A,")) {
// Parse message
Matcher parser = pattern.matcher(sentence);
if (!parser.matches()) {
return null;
}
-
+
// Create new position
Position position = new Position();
position.setDeviceId(deviceId);
StringBuilder extendedInfo = new StringBuilder("<protocol>ev603</protocol>");
Integer index = 1;
-
+
// Date
Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
time.clear();
@@ -102,7 +102,7 @@ public class Ev603ProtocolDecoder extends GenericProtocolDecoder{
time.set(Calendar.MINUTE, Integer.valueOf(parser.group(index++)));
time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++)));
position.setTime(time.getTime());
-
+
// Validity
position.setValid(true);
@@ -115,13 +115,13 @@ public class Ev603ProtocolDecoder extends GenericProtocolDecoder{
// Speed
position.setSpeed(Double.valueOf(parser.group(index++)));
-
+
// Course
position.setCourse(Double.valueOf(parser.group(index++)));
-
+
// Extended info
position.setExtendedInfo(extendedInfo.toString());
-
+
return position;
}
diff --git a/src/org/traccar/protocol/Gl100ProtocolDecoder.java b/src/org/traccar/protocol/Gl100ProtocolDecoder.java
index 760e91f68..d99953f24 100644
--- a/src/org/traccar/protocol/Gl100ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl100ProtocolDecoder.java
@@ -21,21 +21,21 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.traccar.GenericProtocolDecoder;
+import org.traccar.BaseProtocolDecoder;
+import org.traccar.ServerManager;
import org.traccar.helper.Log;
-import org.traccar.model.DataManager;
import org.traccar.model.Position;
/**
* GL200 tracker protocol decoder
*/
-public class Gl100ProtocolDecoder extends GenericProtocolDecoder {
+public class Gl100ProtocolDecoder extends BaseProtocolDecoder {
/**
* Initialize
*/
- public Gl100ProtocolDecoder(DataManager dataManager) {
- super(dataManager);
+ public Gl100ProtocolDecoder(ServerManager serverManager) {
+ super(serverManager);
}
/**
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
index 019c839cd..639c9439a 100644
--- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
@@ -21,21 +21,21 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.traccar.GenericProtocolDecoder;
+import org.traccar.BaseProtocolDecoder;
+import org.traccar.ServerManager;
import org.traccar.helper.Log;
-import org.traccar.model.DataManager;
import org.traccar.model.Position;
/**
* GL200 tracker protocol decoder
*/
-public class Gl200ProtocolDecoder extends GenericProtocolDecoder {
+public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
/**
* Initialize
*/
- public Gl200ProtocolDecoder(DataManager dataManager) {
- super(dataManager);
+ public Gl200ProtocolDecoder(ServerManager serverManager) {
+ super(serverManager);
}
/**
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
index 935697c51..e79ae109f 100644
--- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
@@ -21,21 +21,21 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.traccar.GenericProtocolDecoder;
+import org.traccar.BaseProtocolDecoder;
+import org.traccar.ServerManager;
import org.traccar.helper.Log;
-import org.traccar.model.DataManager;
import org.traccar.model.Position;
/**
* Gps 103 tracker protocol decoder
*/
-public class Gps103ProtocolDecoder extends GenericProtocolDecoder {
+public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
/**
* Initialize
*/
- public Gps103ProtocolDecoder(DataManager dataManager) {
- super(dataManager);
+ public Gps103ProtocolDecoder(ServerManager serverManager) {
+ super(serverManager);
}
/**
diff --git a/src/org/traccar/protocol/Gt02ProtocolDecoder.java b/src/org/traccar/protocol/Gt02ProtocolDecoder.java
index 69d54cb5b..16b2955d5 100644
--- a/src/org/traccar/protocol/Gt02ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt02ProtocolDecoder.java
@@ -21,23 +21,23 @@ import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.traccar.GenericProtocolDecoder;
+import org.traccar.BaseProtocolDecoder;
+import org.traccar.ServerManager;
import org.traccar.helper.Log;
-import org.traccar.model.DataManager;
import org.traccar.model.Position;
/**
* T55 tracker protocol decoder
*/
-public class Gt02ProtocolDecoder extends GenericProtocolDecoder {
+public class Gt02ProtocolDecoder extends BaseProtocolDecoder {
/**
* Initialize
*/
- public Gt02ProtocolDecoder(DataManager dataManager) {
- super(dataManager);
+ public Gt02ProtocolDecoder(ServerManager serverManager) {
+ super(serverManager);
}
-
+
private String readImei(ChannelBuffer buf) {
int b = buf.readUnsignedByte();
StringBuilder imei = new StringBuilder();
@@ -52,7 +52,7 @@ public class Gt02ProtocolDecoder extends GenericProtocolDecoder {
private static final int MSG_HEARTBEAT = 0x1A;
private static final int MSG_DATA = 0x10;
-
+
/**
* Decode message
*/
@@ -62,38 +62,38 @@ public class Gt02ProtocolDecoder extends GenericProtocolDecoder {
throws Exception {
ChannelBuffer buf = (ChannelBuffer) msg;
-
+
buf.skipBytes(2); // header
buf.readByte(); // size
-
+
// Zero for location messages
buf.readByte(); // voltage
buf.readByte(); // gsm signal
-
+
String imei = readImei(buf);
long index = buf.readUnsignedShort();
int type = buf.readUnsignedByte();
-
+
if (type == MSG_HEARTBEAT) {
if (channel != null) {
byte[] response = {0x54, 0x68, 0x1A, 0x0D, 0x0A};
channel.write(ChannelBuffers.wrappedBuffer(response));
}
}
-
+
else if (type == MSG_DATA) {
-
+
// Create new position
Position position = new Position();
position.setId(index);
-
+
// Get device id
try {
position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
} catch(Exception error) {
Log.warning("Unknown device - " + imei);
}
-
+
// Date and time
Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
time.clear();
@@ -104,27 +104,27 @@ public class Gt02ProtocolDecoder extends GenericProtocolDecoder {
time.set(Calendar.MINUTE, buf.readUnsignedByte());
time.set(Calendar.SECOND, buf.readUnsignedByte());
position.setTime(time.getTime());
-
+
// Latitude
double latitude = buf.readUnsignedInt() / (60.0 * 30000.0);
-
+
// Longitude
double longitude = buf.readUnsignedInt() / (60.0 * 30000.0);
-
+
// Speed
position.setSpeed((double) buf.readUnsignedByte());
-
+
// Course
position.setCourse((double) buf.readUnsignedShort());
-
+
buf.skipBytes(3); // reserved
-
+
// Flags
long flags = buf.readUnsignedInt();
position.setValid((flags & 0x1) == 0x1);
if ((flags & 0x2) == 0) latitude = -latitude;
if ((flags & 0x4) == 0) longitude = -longitude;
-
+
position.setLatitude(latitude);
position.setLongitude(longitude);
position.setAltitude(0.0);
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index 0005df19b..a3306dc97 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -21,24 +21,24 @@ import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.traccar.GenericProtocolDecoder;
+import org.traccar.BaseProtocolDecoder;
+import org.traccar.ServerManager;
import org.traccar.helper.Crc;
import org.traccar.helper.Log;
-import org.traccar.model.DataManager;
import org.traccar.model.Position;
/**
* T55 tracker protocol decoder
*/
-public class Gt06ProtocolDecoder extends GenericProtocolDecoder {
+public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
private Long deviceId;
/**
* Initialize
*/
- public Gt06ProtocolDecoder(DataManager dataManager) {
- super(dataManager);
+ public Gt06ProtocolDecoder(ServerManager serverManager) {
+ super(serverManager);
}
private String readImei(ChannelBuffer buf) {
diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java
index 2d4fb9a21..d09343bcd 100644
--- a/src/org/traccar/protocol/H02ProtocolDecoder.java
+++ b/src/org/traccar/protocol/H02ProtocolDecoder.java
@@ -21,21 +21,21 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.traccar.GenericProtocolDecoder;
+import org.traccar.BaseProtocolDecoder;
+import org.traccar.ServerManager;
import org.traccar.helper.Log;
-import org.traccar.model.DataManager;
import org.traccar.model.Position;
/**
* H02 tracker protocol decoder
*/
-public class H02ProtocolDecoder extends GenericProtocolDecoder {
+public class H02ProtocolDecoder extends BaseProtocolDecoder {
/**
* Initialize
*/
- public H02ProtocolDecoder(DataManager dataManager) {
- super(dataManager);
+ public H02ProtocolDecoder(ServerManager serverManager) {
+ super(serverManager);
}
/**
diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
index d765c1b42..6a8f9da52 100644
--- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
@@ -23,33 +23,33 @@ import java.util.regex.Pattern;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.traccar.GenericProtocolDecoder;
+import org.traccar.BaseProtocolDecoder;
+import org.traccar.ServerManager;
import org.traccar.helper.ChannelBufferTools;
import org.traccar.helper.Log;
-import org.traccar.model.DataManager;
import org.traccar.model.Position;
/**
* JT600 protocol decoder
*/
-public class Jt600ProtocolDecoder extends GenericProtocolDecoder {
+public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
/**
* Initialize
*/
- public Jt600ProtocolDecoder(DataManager dataManager) {
- super(dataManager);
+ public Jt600ProtocolDecoder(ServerManager serverManager) {
+ super(serverManager);
}
/**
* Decode regular message
*/
private Position decodeNormalMessage(ChannelBuffer buf) throws Exception {
-
+
Position position = new Position();
-
+
buf.readByte(); // header
-
+
// Get device by identifier
String id = Long.valueOf(ChannelBufferTools.readHexString(buf, 10)).toString();
try {
@@ -58,11 +58,11 @@ public class Jt600ProtocolDecoder extends GenericProtocolDecoder {
Log.warning("Unknown device - " + id);
return null;
}
-
+
buf.readByte(); // protocol version + data type
-
+
buf.readBytes(2); // length
-
+
// Time
Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
time.clear();
@@ -73,7 +73,7 @@ public class Jt600ProtocolDecoder extends GenericProtocolDecoder {
time.set(Calendar.MINUTE, ChannelBufferTools.readHexInteger(buf, 2));
time.set(Calendar.SECOND, ChannelBufferTools.readHexInteger(buf, 2));
position.setTime(time.getTime());
-
+
// Coordinates
int temp = ChannelBufferTools.readHexInteger(buf, 8);
double latitude = temp % 1000000;
@@ -83,7 +83,7 @@ public class Jt600ProtocolDecoder extends GenericProtocolDecoder {
double longitude = temp % 1000000;
longitude /= 60 * 10000;
longitude += temp / 1000000;
-
+
// Flags
byte flags = buf.readByte();
position.setValid((flags & 0x1) == 0x1);
@@ -91,7 +91,7 @@ public class Jt600ProtocolDecoder extends GenericProtocolDecoder {
position.setLatitude(latitude);
if ((flags & 0x4) == 0) longitude = -longitude;
position.setLongitude(longitude);
-
+
// Speed
double speed = ChannelBufferTools.readHexInteger(buf, 2);
position.setSpeed(speed);
@@ -99,26 +99,26 @@ public class Jt600ProtocolDecoder extends GenericProtocolDecoder {
// Course
double course = buf.readUnsignedByte() * 2;
position.setCourse(course);
-
+
buf.readByte(); // number of satellites
-
+
// Course
double power = buf.readUnsignedByte();
position.setPower(power);
-
+
buf.readByte(); // other flags and sensors
-
+
// Altitude
double altitude = buf.readUnsignedShort();
position.setAltitude(altitude);
-
+
buf.readUnsignedShort(); // cell id
buf.readUnsignedShort(); // lac
-
+
buf.readUnsignedByte(); // gsm signal
-
+
buf.readUnsignedByte(); // message number
-
+
return position;
}
@@ -150,7 +150,7 @@ public class Jt600ProtocolDecoder extends GenericProtocolDecoder {
private Position decodeAlertMessage(ChannelBuffer buf) throws Exception {
String message = buf.toString(Charset.defaultCharset());
-
+
// Parse message
Matcher parser = pattern.matcher(message);
if (!parser.matches()) {
@@ -175,7 +175,7 @@ public class Jt600ProtocolDecoder extends GenericProtocolDecoder {
lonlitude += Double.valueOf(parser.group(index++)) / 60;
if (parser.group(index++).compareTo("W") == 0) lonlitude = -lonlitude;
position.setLongitude(lonlitude);
-
+
// Latitude
Double latitude = Double.valueOf(parser.group(index++));
latitude += Double.valueOf(parser.group(index++)) / 60;
@@ -184,7 +184,7 @@ public class Jt600ProtocolDecoder extends GenericProtocolDecoder {
// Validity
position.setValid(parser.group(index++).compareTo("A") == 0 ? true : false);
-
+
// Time
Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
time.clear();
@@ -204,7 +204,7 @@ public class Jt600ProtocolDecoder extends GenericProtocolDecoder {
// Power
position.setPower(Double.valueOf(parser.group(index++)));
-
+
return position;
}
diff --git a/src/org/traccar/protocol/MaxonProtocolDecoder.java b/src/org/traccar/protocol/MaxonProtocolDecoder.java
index 9bad2c965..c5b53bab0 100644
--- a/src/org/traccar/protocol/MaxonProtocolDecoder.java
+++ b/src/org/traccar/protocol/MaxonProtocolDecoder.java
@@ -21,9 +21,9 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.traccar.GenericProtocolDecoder;
+import org.traccar.BaseProtocolDecoder;
+import org.traccar.ServerManager;
import org.traccar.helper.Log;
-import org.traccar.model.DataManager;
import org.traccar.model.Position;
/**
@@ -33,7 +33,7 @@ import org.traccar.model.Position;
* It sends its identity after the GPRMC sentence, and with the type
* GPFID.
*/
-public class MaxonProtocolDecoder extends GenericProtocolDecoder {
+public class MaxonProtocolDecoder extends BaseProtocolDecoder {
/**
* Device ID
@@ -43,8 +43,8 @@ public class MaxonProtocolDecoder extends GenericProtocolDecoder {
/**
* Initialize
*/
- public MaxonProtocolDecoder(DataManager dataManager) {
- super(dataManager);
+ public MaxonProtocolDecoder(ServerManager serverManager) {
+ super(serverManager);
}
/**
diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
index 0ba9568ba..e5c2a9845 100644
--- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
@@ -25,22 +25,22 @@ import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.HeapChannelBufferFactory;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.traccar.GenericProtocolDecoder;
+import org.traccar.BaseProtocolDecoder;
+import org.traccar.ServerManager;
import org.traccar.helper.Crc;
import org.traccar.helper.Log;
-import org.traccar.model.DataManager;
import org.traccar.model.Position;
/**
* Meiligao protocol decoder
*/
-public class MeiligaoProtocolDecoder extends GenericProtocolDecoder {
+public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
/**
* Initialize
*/
- public MeiligaoProtocolDecoder(DataManager dataManager) {
- super(dataManager);
+ public MeiligaoProtocolDecoder(ServerManager serverManager) {
+ super(serverManager);
}
/**
diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
index 6bb9a915f..87d222c37 100644
--- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
@@ -21,21 +21,21 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.traccar.GenericProtocolDecoder;
+import org.traccar.BaseProtocolDecoder;
+import org.traccar.ServerManager;
import org.traccar.helper.Log;
-import org.traccar.model.DataManager;
import org.traccar.model.Position;
/**
* Meitrack protocol decoder
*/
-public class MeitrackProtocolDecoder extends GenericProtocolDecoder {
+public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
/**
* Initialize
*/
- public MeitrackProtocolDecoder(DataManager dataManager) {
- super(dataManager);
+ public MeitrackProtocolDecoder(ServerManager serverManager) {
+ super(serverManager);
}
/**
@@ -94,11 +94,11 @@ public class MeitrackProtocolDecoder extends GenericProtocolDecoder {
extendedInfo.append("<event>");
extendedInfo.append(parser.group(index++));
extendedInfo.append("</event>");
-
+
// Coordinates
position.setLatitude(Double.valueOf(parser.group(index++)));
position.setLongitude(Double.valueOf(parser.group(index++)));
-
+
// Time
Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
time.clear();
@@ -109,10 +109,10 @@ public class MeitrackProtocolDecoder extends GenericProtocolDecoder {
time.set(Calendar.MINUTE, Integer.valueOf(parser.group(index++)));
time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++)));
position.setTime(time.getTime());
-
+
// Validity
position.setValid(parser.group(index++).compareTo("A") == 0 ? true : false);
-
+
// Satellites
extendedInfo.append("<satellites>");
extendedInfo.append(parser.group(index++));
@@ -136,7 +136,7 @@ public class MeitrackProtocolDecoder extends GenericProtocolDecoder {
// Altitude
position.setAltitude(Double.valueOf(parser.group(index++)));
-
+
// Milage
extendedInfo.append("<milage>");
extendedInfo.append(parser.group(index++));
diff --git a/src/org/traccar/protocol/NavisProtocolDecoder.java b/src/org/traccar/protocol/NavisProtocolDecoder.java
index 291d2b87c..1c384969d 100644
--- a/src/org/traccar/protocol/NavisProtocolDecoder.java
+++ b/src/org/traccar/protocol/NavisProtocolDecoder.java
@@ -25,19 +25,19 @@ import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.traccar.GenericProtocolDecoder;
+import org.traccar.BaseProtocolDecoder;
+import org.traccar.ServerManager;
import org.traccar.helper.Log;
-import org.traccar.model.DataManager;
import org.traccar.model.Position;
/**
* Navis protocol decoder
*/
-public class NavisProtocolDecoder extends GenericProtocolDecoder {
+public class NavisProtocolDecoder extends BaseProtocolDecoder {
private String prefix;
private long deviceId, serverId;
-
+
private static final Charset charset = Charset.defaultCharset();
private String imei;
@@ -46,8 +46,8 @@ public class NavisProtocolDecoder extends GenericProtocolDecoder {
/**
* Initialize
*/
- public NavisProtocolDecoder(DataManager dataManager) {
- super(dataManager);
+ public NavisProtocolDecoder(ServerManager serverManager) {
+ super(serverManager);
}
// Format types
@@ -58,7 +58,7 @@ public class NavisProtocolDecoder extends GenericProtocolDecoder {
public static final int F50 = 0x05;
public static final int F51 = 0x15;
public static final int F52 = 0x25;
-
+
private static boolean isFormat(int type, int... types) {
for (int i : types) {
if (type == i) {
@@ -71,7 +71,7 @@ public class NavisProtocolDecoder extends GenericProtocolDecoder {
private Position parsePosition(ChannelBuffer buf) {
Position position = new Position();
StringBuilder extendedInfo = new StringBuilder("<protocol>navis</protocol>");
-
+
position.setDeviceId(databaseDeviceId);
position.setAltitude(0.0);
@@ -85,14 +85,14 @@ public class NavisProtocolDecoder extends GenericProtocolDecoder {
extendedInfo.append("<format>");
extendedInfo.append(format);
extendedInfo.append("</format>");
-
+
position.setId(buf.readUnsignedInt()); // sequence number
// Event type
extendedInfo.append("<event>");
extendedInfo.append(buf.readUnsignedShort());
extendedInfo.append("</event>");
-
+
// Event time
Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
time.clear();
@@ -105,22 +105,22 @@ public class NavisProtocolDecoder extends GenericProtocolDecoder {
extendedInfo.append("<time>");
extendedInfo.append(time.getTimeInMillis());
extendedInfo.append("</time>");
-
+
// Alarm status
extendedInfo.append("<alarm>");
extendedInfo.append(buf.readUnsignedByte());
extendedInfo.append("</alarm>");
-
+
// Modules status
extendedInfo.append("<status>");
extendedInfo.append(buf.readUnsignedByte());
extendedInfo.append("</status>");
-
+
// GSM signal
extendedInfo.append("<gsm>");
extendedInfo.append(buf.readUnsignedByte());
extendedInfo.append("</gsm>");
-
+
// Output
extendedInfo.append("<output>");
if (isFormat(format, F10, F20, F30)) {
@@ -129,7 +129,7 @@ public class NavisProtocolDecoder extends GenericProtocolDecoder {
extendedInfo.append(buf.readUnsignedByte());
}
extendedInfo.append("</output>");
-
+
// Input
extendedInfo.append("<input>");
if (isFormat(format, F10, F20, F30, F40)) {
@@ -138,7 +138,7 @@ public class NavisProtocolDecoder extends GenericProtocolDecoder {
extendedInfo.append(buf.readUnsignedByte());
}
extendedInfo.append("</input>");
-
+
position.setPower(buf.readUnsignedShort() / 1000.0); // power
// Battery power
@@ -164,13 +164,13 @@ public class NavisProtocolDecoder extends GenericProtocolDecoder {
extendedInfo.append(buf.readUnsignedShort());
extendedInfo.append("</adc2>");
}
-
+
if (isFormat(format, F20, F50, F51, F52)) {
// Impulse counters
buf.readUnsignedInt();
buf.readUnsignedInt();
}
-
+
if (isFormat(format, F20, F50, F51, F52)) {
// Validity
int locationStatus = buf.readUnsignedByte();
@@ -185,28 +185,28 @@ public class NavisProtocolDecoder extends GenericProtocolDecoder {
time.set(Calendar.MONTH, buf.readUnsignedByte());
time.set(Calendar.YEAR, 2000 + buf.readUnsignedByte());
position.setTime(time.getTime());
-
+
// Location data
position.setLatitude(buf.readFloat() / Math.PI * 180);
position.setLongitude(buf.readFloat() / Math.PI * 180);
position.setSpeed((double) buf.readFloat());
position.setCourse((double) buf.readUnsignedShort());
-
+
// Milage
extendedInfo.append("<milage>");
extendedInfo.append(buf.readFloat());
extendedInfo.append("</milage>");
-
+
// Last segment
extendedInfo.append("<segment>");
extendedInfo.append(buf.readFloat());
extendedInfo.append("</segment>");
-
+
// Segment times
buf.readUnsignedShort();
buf.readUnsignedShort();
}
-
+
if (isFormat(format, F51, F52)) {
// Other stuff
buf.readUnsignedShort();
@@ -219,7 +219,7 @@ public class NavisProtocolDecoder extends GenericProtocolDecoder {
buf.readByte();
buf.readUnsignedShort();
}
-
+
if (isFormat(format, F40, F52)) {
// Four temperature sensors
buf.readByte();
@@ -233,10 +233,10 @@ public class NavisProtocolDecoder extends GenericProtocolDecoder {
return position;
}
-
+
private Object processSingle(Channel channel, ChannelBuffer buf) {
Position position = parsePosition(buf);
-
+
ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 8);
response.writeBytes(ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN, "*<T", charset));
response.writeInt(position.getId().intValue());
@@ -246,10 +246,10 @@ public class NavisProtocolDecoder extends GenericProtocolDecoder {
if (position.getValid() == null) {
return null;
}
-
+
return position;
}
-
+
private Object processArray(Channel channel, ChannelBuffer buf) {
List<Position> positions = new LinkedList<Position>();
int count = buf.readUnsignedByte();
@@ -260,7 +260,7 @@ public class NavisProtocolDecoder extends GenericProtocolDecoder {
positions.add(position);
}
}
-
+
ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 8);
response.writeBytes(ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN, "*<A", charset));
response.writeByte(count);
@@ -270,10 +270,10 @@ public class NavisProtocolDecoder extends GenericProtocolDecoder {
if (positions.isEmpty()) {
return null;
}
-
+
return positions;
}
-
+
private Object processHandshake(Channel channel, ChannelBuffer buf) {
buf.readByte(); // semicolon symbol
imei = buf.toString(Charset.defaultCharset());
@@ -285,7 +285,7 @@ public class NavisProtocolDecoder extends GenericProtocolDecoder {
}
return null;
}
-
+
private static short checksum(ChannelBuffer buf) {
short sum = 0;
for (int i = 0; i < buf.readableBytes(); i++) {
@@ -293,7 +293,7 @@ public class NavisProtocolDecoder extends GenericProtocolDecoder {
}
return sum;
}
-
+
private void sendReply(Channel channel, ChannelBuffer data) {
ChannelBuffer header = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 16);
header.writeBytes(ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN, prefix, charset));
@@ -302,19 +302,19 @@ public class NavisProtocolDecoder extends GenericProtocolDecoder {
header.writeShort(data.readableBytes());
header.writeByte(checksum(data));
header.writeByte(checksum(header));
-
+
if (channel != null) {
channel.write(ChannelBuffers.copiedBuffer(header, data));
}
}
-
+
/**
* Decode message
*/
protected Object decode(
ChannelHandlerContext ctx, Channel channel, Object msg)
throws Exception {
-
+
ChannelBuffer buf = (ChannelBuffer) msg;
// Read header
@@ -324,15 +324,15 @@ public class NavisProtocolDecoder extends GenericProtocolDecoder {
deviceId = buf.readUnsignedInt();
int length = buf.readUnsignedShort();
buf.skipBytes(2); // header and data XOR checksum
-
+
if (length == 0) {
return null; // keep alive message
}
-
+
// Read message type
String type = buf.toString(buf.readerIndex(), 3, charset);
buf.skipBytes(type.length());
-
+
if (type.equals("*>T")) {
return processSingle(channel, buf);
} else if (type.equals("*>A")) {
diff --git a/src/org/traccar/protocol/ProgressProtocolDecoder.java b/src/org/traccar/protocol/ProgressProtocolDecoder.java
index 35db6e113..06904711e 100644
--- a/src/org/traccar/protocol/ProgressProtocolDecoder.java
+++ b/src/org/traccar/protocol/ProgressProtocolDecoder.java
@@ -22,15 +22,15 @@ import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.traccar.GenericProtocolDecoder;
+import org.traccar.BaseProtocolDecoder;
+import org.traccar.ServerManager;
import org.traccar.helper.Log;
-import org.traccar.model.DataManager;
import org.traccar.model.Position;
/**
* Progress tracker protocol decoder
*/
-public class ProgressProtocolDecoder extends GenericProtocolDecoder {
+public class ProgressProtocolDecoder extends BaseProtocolDecoder {
/**
* Device ID
@@ -40,8 +40,8 @@ public class ProgressProtocolDecoder extends GenericProtocolDecoder {
/**
* Initialize
*/
- public ProgressProtocolDecoder(DataManager dataManager) {
- super(dataManager);
+ public ProgressProtocolDecoder(ServerManager serverManager) {
+ super(serverManager);
}
/*
@@ -56,7 +56,7 @@ public class ProgressProtocolDecoder extends GenericProtocolDecoder {
private static final int MSG_TEXT = 102;
private static final int MSG_ALARM = 200;
private static final int MSG_ALARM_RECIEVED = 201;
-
+
private static final String HEX_CHARS = "0123456789ABCDEF";
/**
@@ -135,7 +135,7 @@ public class ProgressProtocolDecoder extends GenericProtocolDecoder {
extendedInfo.append("<milage>");
extendedInfo.append(buf.readUnsignedInt());
extendedInfo.append("</milage>");
-
+
long extraFlags = buf.readLong();
// Analog inputs
@@ -146,7 +146,7 @@ public class ProgressProtocolDecoder extends GenericProtocolDecoder {
extendedInfo.append(buf.readUnsignedShort());
extendedInfo.append("</adc").append(i).append(">");
}
-
+
}
// CAN adapter
@@ -157,11 +157,11 @@ public class ProgressProtocolDecoder extends GenericProtocolDecoder {
extendedInfo.append("</can>");
buf.skipBytes(size);
}
-
+
// Passenger sensor
if ((extraFlags & 0x4) == 0x4) {
int size = buf.readUnsignedShort();
-
+
// Convert binary data to hex
StringBuilder hex = new StringBuilder();
for (int i = buf.readerIndex(); i < buf.readerIndex() + size; i++) {
@@ -173,7 +173,7 @@ public class ProgressProtocolDecoder extends GenericProtocolDecoder {
extendedInfo.append("<passenger>");
extendedInfo.append(hex);
extendedInfo.append("</passenger>");
-
+
buf.skipBytes(size);
}
diff --git a/src/org/traccar/protocol/Pt502ProtocolDecoder.java b/src/org/traccar/protocol/Pt502ProtocolDecoder.java
index e5f2e9224..a00913ae4 100644
--- a/src/org/traccar/protocol/Pt502ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Pt502ProtocolDecoder.java
@@ -22,22 +22,23 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.traccar.GenericProtocolDecoder;
+import org.traccar.BaseProtocolDecoder;
+import org.traccar.ServerManager;
import org.traccar.helper.Log;
-import org.traccar.model.DataManager;
import org.traccar.model.Position;
/**
* PT502 tracker protocol decoder
*/
-public class Pt502ProtocolDecoder extends GenericProtocolDecoder {
+public class Pt502ProtocolDecoder extends BaseProtocolDecoder {
/**
* Initialize
*/
- public Pt502ProtocolDecoder(DataManager dataManager) {
- super(dataManager);
+ public Pt502ProtocolDecoder(ServerManager serverManager) {
+ super(serverManager);
}
+
/**
* Regular expressions pattern
*/
@@ -124,7 +125,7 @@ public class Pt502ProtocolDecoder extends GenericProtocolDecoder {
} else {
position.setSpeed(0.0);
}
-
+
// Course
String course = parser.group(index++);
if (course != null) {
diff --git a/src/org/traccar/protocol/ST210ProtocolDecoder.java b/src/org/traccar/protocol/ST210ProtocolDecoder.java
index 642079361..d8d42eed6 100644
--- a/src/org/traccar/protocol/ST210ProtocolDecoder.java
+++ b/src/org/traccar/protocol/ST210ProtocolDecoder.java
@@ -8,42 +8,43 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.traccar.GenericProtocolDecoder;
+import org.traccar.BaseProtocolDecoder;
+import org.traccar.ServerManager;
import org.traccar.helper.Log;
import org.traccar.model.DataManager;
import org.traccar.model.Position;
-public class ST210ProtocolDecoder extends GenericProtocolDecoder {
-
+public class ST210ProtocolDecoder extends BaseProtocolDecoder {
- public ST210ProtocolDecoder(DataManager dataManager) {
- super(dataManager);
+
+ public ST210ProtocolDecoder(ServerManager serverManager) {
+ super(serverManager);
}
private enum ST210FIELDS {
- HDR_STATUS("SA200STT;","Status Report"),
- HDR_EMERGENCY("SA200EMG;","Emergency Report"),
- HDR_EVENT("SA200EVT;", "Event Report"),
- HDR_ALERT("SA200ALT;","Alert Report"),
- HDR_ALIVE("SA200ALV;","Alive Report"),
- DEV_ID("(\\d+);", "Device ID"),
- SW_VER("(\\d{3});", "Software Release Version"),
- DATE("(\\d+);","GPS date (yyyymmdd) Year + Month + Day"),
- TIME("(\\d{2}:\\d{2}:\\d{2});","GPS time (hh:mm:ss) Hour : Minute : Second"),
- CELL("(\\w+);","Location Code ID (3 digits hex) + Serving Cell BSIC(2 digits decimal)"),
- LAT("(-\\d{2}.\\d+);", "Latitude (+/-xx.xxxxxx)"),
- LON("(-\\d{3}.\\d+);", "Longitude (+/-xxx.xxxxxx)"),
- SPD("(\\d{3}.\\d{3});","Speed in km/h - This value returns to 0 when it is over than 200,000Km"),
+ HDR_STATUS("SA200STT;","Status Report"),
+ HDR_EMERGENCY("SA200EMG;","Emergency Report"),
+ HDR_EVENT("SA200EVT;", "Event Report"),
+ HDR_ALERT("SA200ALT;","Alert Report"),
+ HDR_ALIVE("SA200ALV;","Alive Report"),
+ DEV_ID("(\\d+);", "Device ID"),
+ SW_VER("(\\d{3});", "Software Release Version"),
+ DATE("(\\d+);","GPS date (yyyymmdd) Year + Month + Day"),
+ TIME("(\\d{2}:\\d{2}:\\d{2});","GPS time (hh:mm:ss) Hour : Minute : Second"),
+ CELL("(\\w+);","Location Code ID (3 digits hex) + Serving Cell BSIC(2 digits decimal)"),
+ LAT("(-\\d{2}.\\d+);", "Latitude (+/-xx.xxxxxx)"),
+ LON("(-\\d{3}.\\d+);", "Longitude (+/-xxx.xxxxxx)"),
+ SPD("(\\d{3}.\\d{3});","Speed in km/h - This value returns to 0 when it is over than 200,000Km"),
CRS("(\\d{3}.\\d{2});", "Course over ground in degree"),
SATT("(\\d+);", "Number of satellites"),
- FIX("(\\d);","GPS is fixed(1)\n" + "GPS is not fixed(0)"),
- DIST("(\\d+);","Traveled ddistance in meter"),
- PWR_VOLT("(\\d+.\\d{2});","Voltage value of main power"),
- IO("(\\d+);","Current I/O status of inputs and outputs."),
+ FIX("(\\d);","GPS is fixed(1)\n" + "GPS is not fixed(0)"),
+ DIST("(\\d+);","Traveled ddistance in meter"),
+ PWR_VOLT("(\\d+.\\d{2});","Voltage value of main power"),
+ IO("(\\d+);","Current I/O status of inputs and outputs."),
MODE("(\\d);","1 = Idle mode (Parking)\n" + "2 = Active Mode (Driving)"),
- MSG_NUM("(\\d{4});","Message number - After 9999 is reported, message number returns to 0000"),
- EMG_ID("(\\d);", "Emergency type"),
- EVT_ID("(\\d);", "Event type"),
+ MSG_NUM("(\\d{4});","Message number - After 9999 is reported, message number returns to 0000"),
+ EMG_ID("(\\d);", "Emergency type"),
+ EVT_ID("(\\d);", "Event type"),
ALERT_ID("(\\d+);", "Alert type");
private String pattern;
@@ -92,7 +93,7 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder {
case SPD:
position.setSpeed(Double.valueOf(groupValue));
break;
-
+
case MODE:
//position.setMode(Integer.parseInt(groupValue));
break;
@@ -104,15 +105,15 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder {
time.set(Calendar.YEAR, Integer.valueOf(Integer.valueOf(groupValue.substring(0, 4))));
time.set(Calendar.MONTH, Integer.valueOf(Integer.valueOf(groupValue.substring(4, 6))-1));
time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(Integer.valueOf(groupValue.substring(6, 8))));
-
+
/*Calendar ret = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
-
- ret.setTimeInMillis(time.getTimeInMillis() +
+
+ ret.setTimeInMillis(time.getTimeInMillis() +
TimeZone.getTimeZone("UTC").getOffset(time.getTimeInMillis()) -
TimeZone.getDefault().getOffset(time.getTimeInMillis()));*/
position.setTime(time.getTime());
-
+
break;
}
@@ -121,19 +122,19 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder {
Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
time.clear();
time.setTime(position.getTime());
-
+
time.set(Calendar.HOUR_OF_DAY, Integer.valueOf(Integer.valueOf(groupValue.substring(0, 2))));
time.set(Calendar.MINUTE, Integer.valueOf(Integer.valueOf(groupValue.substring(3, 5))));
time.set(Calendar.SECOND, Integer.valueOf(Integer.valueOf(groupValue.substring(6, 8))));
/*Calendar ret = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
-
- ret.setTimeInMillis(time.getTimeInMillis() +
+
+ ret.setTimeInMillis(time.getTimeInMillis() +
TimeZone.getTimeZone("UTC").getOffset(time.getTimeInMillis()) -
TimeZone.getDefault().getOffset(time.getTimeInMillis()));*/
position.setTime(time.getTime());
-
+
break;
}
@@ -219,9 +220,9 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder {
}
private enum FIELD_EMG_ID_VALUE {
- PANIC(1, "Emergency by panic button"),
- PARKING(2,"Emergency by parking lock"),
- MAIN_POWER(3,"Emergency by removing main power"),
+ PANIC(1, "Emergency by panic button"),
+ PARKING(2,"Emergency by parking lock"),
+ MAIN_POWER(3,"Emergency by removing main power"),
ANTI_THEFT(5,"Emergency by anti-theft");
private int value;
@@ -263,11 +264,11 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder {
}
private enum FIELD_EVT_ID_VALUE {
- INPUT1_GROUND(1, "Input1 goes to ground state"),
- INPUT1_OPEN(2,"Input1 goes to open state"),
- INPUT2_GROUND(3,"Input2 goes to ground state"),
- INPUT2_OPEN(4,"Input2 goes to open state"),
- INPUT3_GROUND(5,"Input3 goes to ground state"),
+ INPUT1_GROUND(1, "Input1 goes to ground state"),
+ INPUT1_OPEN(2,"Input1 goes to open state"),
+ INPUT2_GROUND(3,"Input2 goes to ground state"),
+ INPUT2_OPEN(4,"Input2 goes to open state"),
+ INPUT3_GROUND(5,"Input3 goes to ground state"),
INPUT3_OPEN(6,"Input3 goes to open state");
private int value;
@@ -290,7 +291,7 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder {
public FIELD_EVT_ID_VALUE getValueOf(String indiceStr) {
int indice = Integer.valueOf(indiceStr);
return getValueOf(indice);
- }
+ }
public FIELD_EVT_ID_VALUE getValueOf(int indice) {
switch (indice) {
@@ -313,19 +314,19 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder {
}
private enum FIELD_ALERT_ID_VALUE {
- DRIVING_FASTER(1, "Start driving faster than SPEED_LIMIT"),
- OVER_SPPED(2, "Ended over speed condition"),
- DISCON_GPS(3,"Disconnected GPS antenna"),
- RECON_GPS(4,"Reconnected GPS antenna after disconnected"),
- OUT_GEO_FENCE(5,"The vehicle went out from the geo-fence that has following ID"),
- INTO_GEO_FENCE(6,"The vehicle entered into the geo-fence that has following ID"),
- SHORTED_GPS(8, "Shorted GPS antenna"),
- DEEP_SLEEP_ON(9,"Enter to deep sleep mode"),
- DEEP_SLEEP_OFF(10,"Exite from deep sleep mode"),
- BKP_BATTERY(13,"Backup battery error"),
- BATTERY_DOWN(14,"Vehicle battery goes down to so low level"),
- SHOCKED(15,"Shocked"),
- COLLISION(16, "Occurred some collision"),
+ DRIVING_FASTER(1, "Start driving faster than SPEED_LIMIT"),
+ OVER_SPPED(2, "Ended over speed condition"),
+ DISCON_GPS(3,"Disconnected GPS antenna"),
+ RECON_GPS(4,"Reconnected GPS antenna after disconnected"),
+ OUT_GEO_FENCE(5,"The vehicle went out from the geo-fence that has following ID"),
+ INTO_GEO_FENCE(6,"The vehicle entered into the geo-fence that has following ID"),
+ SHORTED_GPS(8, "Shorted GPS antenna"),
+ DEEP_SLEEP_ON(9,"Enter to deep sleep mode"),
+ DEEP_SLEEP_OFF(10,"Exite from deep sleep mode"),
+ BKP_BATTERY(13,"Backup battery error"),
+ BATTERY_DOWN(14,"Vehicle battery goes down to so low level"),
+ SHOCKED(15,"Shocked"),
+ COLLISION(16, "Occurred some collision"),
DEVIATE_ROUT(18, "Deviate from predefined rout"),
ENTER_ROUT(19,"Enter into predefined rout");
@@ -492,7 +493,7 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder {
if(patternStr.endsWith(";")){
patternStr = patternStr.substring(0, patternStr.length()-1);
}
-
+
return Pattern.compile(patternStr);
}
@@ -608,9 +609,9 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder {
public Object decode(ChannelHandlerContext ctx, Channel channel, Object msg) {
String sentence = (String) msg;
Log.info("Msg: " + msg);
-
+
Position position = null;
-
+
try{
position = decodeMsg(sentence);
Log.info("MESSAGE DECODED WITH SUCCESS!");
@@ -618,7 +619,7 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder {
catch(Exception e){
Log.severe("ERROR WHILE DECODING MESSAGE: " + e.getMessage());
}
-
+
return position;
}
@@ -639,7 +640,7 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder {
if(report.equals(ST210REPORTS.ALIVE)){
return null;
}
-
+
// Create new position
Position position = new Position();
diff --git a/src/org/traccar/protocol/SkypatrolProtocolDecoder.java b/src/org/traccar/protocol/SkypatrolProtocolDecoder.java
index 3f54fd0bf..11f9424aa 100644
--- a/src/org/traccar/protocol/SkypatrolProtocolDecoder.java
+++ b/src/org/traccar/protocol/SkypatrolProtocolDecoder.java
@@ -21,41 +21,41 @@ import java.util.TimeZone;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.traccar.GenericProtocolDecoder;
+import org.traccar.BaseProtocolDecoder;
+import org.traccar.ServerManager;
import org.traccar.helper.Log;
-import org.traccar.model.DataManager;
import org.traccar.model.Position;
/**
* T55 tracker protocol decoder
*/
-public class SkypatrolProtocolDecoder extends GenericProtocolDecoder {
+public class SkypatrolProtocolDecoder extends BaseProtocolDecoder {
/**
* Initialize
*/
- public SkypatrolProtocolDecoder(DataManager dataManager) {
- super(dataManager);
+ public SkypatrolProtocolDecoder(ServerManager serverManager) {
+ super(serverManager);
}
private static boolean checkBit(long mask, int bit) {
long checkMask = 1 << bit;
return (mask & checkMask) == checkMask;
}
-
+
private static double convertCoordinate(long coordinate) {
int sign = 1;
if (coordinate > 0x7fffffffl) {
sign = -1;
coordinate = 0xffffffffl - coordinate;
}
-
+
double degrees = coordinate / 1000000;
degrees += (coordinate % 1000000) / 600000.0;
-
+
return sign * degrees;
}
-
+
/**
* Decode message
*/
@@ -81,18 +81,18 @@ public class SkypatrolProtocolDecoder extends GenericProtocolDecoder {
commandType == 2 &&
messageType == 1 &&
checkBit(mask, 0)) {
-
+
// Create new position
Position position = new Position();
StringBuilder extendedInfo = new StringBuilder("<protocol>skypatrol</protocol>");
-
+
// Status code
if (checkBit(mask, 1)) {
extendedInfo.append("<status>");
extendedInfo.append(buf.readUnsignedInt());
extendedInfo.append("</status>");
}
-
+
// Device id
String id = null;
if (checkBit(mask, 23)) {
@@ -111,12 +111,12 @@ public class SkypatrolProtocolDecoder extends GenericProtocolDecoder {
Log.warning("Unknown device - " + id);
return null;
}
-
+
// IO data
if (checkBit(mask, 3)) {
buf.readUnsignedShort();
}
-
+
// ADC 1
if (checkBit(mask, 4)) {
buf.readUnsignedShort();
@@ -131,7 +131,7 @@ public class SkypatrolProtocolDecoder extends GenericProtocolDecoder {
if (checkBit(mask, 7)) {
buf.readUnsignedByte();
}
-
+
Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
time.clear();
@@ -156,7 +156,7 @@ public class SkypatrolProtocolDecoder extends GenericProtocolDecoder {
if (checkBit(mask, 11)) {
position.setLongitude(convertCoordinate(buf.readUnsignedInt()));
}
-
+
// Speed
if (checkBit(mask, 12)) {
position.setSpeed(buf.readUnsignedShort() / 10.0);
@@ -173,60 +173,60 @@ public class SkypatrolProtocolDecoder extends GenericProtocolDecoder {
time.set(Calendar.MINUTE, buf.readUnsignedByte());
time.set(Calendar.SECOND, buf.readUnsignedByte());
}
-
+
position.setTime(time.getTime());
-
+
// Altitude
if (checkBit(mask, 15)) {
buf.skipBytes(3);
}
-
+
// Satellites
if (checkBit(mask, 16)) {
extendedInfo.append("<satellites>");
extendedInfo.append(buf.readUnsignedByte());
extendedInfo.append("</satellites>");
}
-
+
// Battery percentage
if (checkBit(mask, 17)) {
buf.readUnsignedShort();
}
-
+
// Trip milage
if (checkBit(mask, 20)) {
extendedInfo.append("<trip>");
extendedInfo.append(buf.readUnsignedInt());
extendedInfo.append("</trip>");
}
-
+
// Milage
if (checkBit(mask, 21)) {
extendedInfo.append("<milage>");
extendedInfo.append(buf.readUnsignedInt());
extendedInfo.append("</milage>");
}
-
+
// Time of message generation
if (checkBit(mask, 22)) {
buf.skipBytes(6);
}
-
+
// Battery level
if (checkBit(mask, 24)) {
position.setPower(buf.readUnsignedShort() / 1000.0);
}
-
+
// GPS overspeed
if (checkBit(mask, 25)) {
buf.skipBytes(18);
}
-
+
// Cell information
if (checkBit(mask, 26)) {
buf.skipBytes(54);
}
-
+
// Sequence number
if (checkBit(mask, 28)) {
position.setId((long) buf.readUnsignedShort());
diff --git a/src/org/traccar/protocol/T55ProtocolDecoder.java b/src/org/traccar/protocol/T55ProtocolDecoder.java
index 184f5e40b..8903bf3e1 100644
--- a/src/org/traccar/protocol/T55ProtocolDecoder.java
+++ b/src/org/traccar/protocol/T55ProtocolDecoder.java
@@ -21,15 +21,15 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.traccar.GenericProtocolDecoder;
+import org.traccar.BaseProtocolDecoder;
+import org.traccar.ServerManager;
import org.traccar.helper.Log;
-import org.traccar.model.DataManager;
import org.traccar.model.Position;
/**
* T55 tracker protocol decoder
*/
-public class T55ProtocolDecoder extends GenericProtocolDecoder {
+public class T55ProtocolDecoder extends BaseProtocolDecoder {
/**
* Device ID
@@ -39,8 +39,8 @@ public class T55ProtocolDecoder extends GenericProtocolDecoder {
/**
* Initialize
*/
- public T55ProtocolDecoder(DataManager dataManager) {
- super(dataManager);
+ public T55ProtocolDecoder(ServerManager serverManager) {
+ super(serverManager);
}
/**
diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
index 7145cf893..65cf6fcd0 100644
--- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
@@ -21,21 +21,21 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.traccar.GenericProtocolDecoder;
+import org.traccar.BaseProtocolDecoder;
+import org.traccar.ServerManager;
import org.traccar.helper.Log;
-import org.traccar.model.DataManager;
import org.traccar.model.Position;
/**
* Gps 103 tracker protocol decoder
*/
-public class Tk103ProtocolDecoder extends GenericProtocolDecoder {
+public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
/**
* Initialize
*/
- public Tk103ProtocolDecoder(DataManager dataManager) {
- super(dataManager);
+ public Tk103ProtocolDecoder(ServerManager serverManager) {
+ super(serverManager);
}
/**
@@ -66,7 +66,7 @@ public class Tk103ProtocolDecoder extends GenericProtocolDecoder {
throws Exception {
String sentence = (String) msg;
-
+
// TODO: Send answer
//(090411121854AP05)
diff --git a/src/org/traccar/protocol/Tr20ProtocolDecoder.java b/src/org/traccar/protocol/Tr20ProtocolDecoder.java
index 0424b70b0..95935cd29 100644
--- a/src/org/traccar/protocol/Tr20ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tr20ProtocolDecoder.java
@@ -21,21 +21,21 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.traccar.GenericProtocolDecoder;
+import org.traccar.BaseProtocolDecoder;
+import org.traccar.ServerManager;
import org.traccar.helper.Log;
-import org.traccar.model.DataManager;
import org.traccar.model.Position;
/**
* TR20 tracker protocol decoder
*/
-public class Tr20ProtocolDecoder extends GenericProtocolDecoder {
+public class Tr20ProtocolDecoder extends BaseProtocolDecoder {
/**
* Initialize
*/
- public Tr20ProtocolDecoder(DataManager dataManager) {
- super(dataManager);
+ public Tr20ProtocolDecoder(ServerManager serverManager) {
+ super(serverManager);
}
static private Pattern patternPing = Pattern.compile(
@@ -69,16 +69,16 @@ public class Tr20ProtocolDecoder extends GenericProtocolDecoder {
// Keep alive message
Matcher parser = patternPing.matcher(sentence);
if (parser.matches()) {
-
+
// Send response
if (channel != null) {
channel.write("&&" + parser.group(1) + "\r\n");
}
} else {
-
+
// Data message parse
parser = patternData.matcher(sentence);
-
+
// Unknown message
if (!parser.matches()) {
return null;
@@ -89,7 +89,7 @@ public class Tr20ProtocolDecoder extends GenericProtocolDecoder {
StringBuilder extendedInfo = new StringBuilder("<protocol>tr20</protocol>");
Integer index = 1;
-
+
// Get device by id
String id = parser.group(index++);
try {
@@ -98,10 +98,10 @@ public class Tr20ProtocolDecoder extends GenericProtocolDecoder {
Log.warning("Unknown device - " + id);
return null;
}
-
+
// Validity
position.setValid(parser.group(index++).compareTo("A") == 0 ? true : false);
-
+
// Time
Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
time.clear();
@@ -112,7 +112,7 @@ public class Tr20ProtocolDecoder extends GenericProtocolDecoder {
time.set(Calendar.MINUTE, Integer.parseInt(parser.group(index++)));
time.set(Calendar.SECOND, Integer.parseInt(parser.group(index++)));
position.setTime(time.getTime());
-
+
// Latitude
int hemisphere = 1;
if (parser.group(index++).compareTo("S") == 0) hemisphere = -1;
@@ -135,10 +135,10 @@ public class Tr20ProtocolDecoder extends GenericProtocolDecoder {
// Altitude
position.setAltitude(0.0);
-
+
// Extended info
position.setExtendedInfo(extendedInfo.toString());
-
+
return position;
}
diff --git a/src/org/traccar/protocol/V680ProtocolDecoder.java b/src/org/traccar/protocol/V680ProtocolDecoder.java
index 57e5982dc..c8a16c377 100644
--- a/src/org/traccar/protocol/V680ProtocolDecoder.java
+++ b/src/org/traccar/protocol/V680ProtocolDecoder.java
@@ -21,21 +21,21 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.traccar.GenericProtocolDecoder;
+import org.traccar.BaseProtocolDecoder;
+import org.traccar.ServerManager;
import org.traccar.helper.Log;
-import org.traccar.model.DataManager;
import org.traccar.model.Position;
/**
* V680 tracker protocol decoder
*/
-public class V680ProtocolDecoder extends GenericProtocolDecoder {
+public class V680ProtocolDecoder extends BaseProtocolDecoder {
/**
* Initialize
*/
- public V680ProtocolDecoder(DataManager dataManager) {
- super(dataManager);
+ public V680ProtocolDecoder(ServerManager serverManager) {
+ super(serverManager);
}
/**
@@ -95,41 +95,41 @@ public class V680ProtocolDecoder extends GenericProtocolDecoder {
// Validity
position.setValid(parser.group(index++).compareTo("1") == 0 ? true : false);
-
+
// Password
extendedInfo.append("<password>");
extendedInfo.append(parser.group(index++));
extendedInfo.append("</password>");
-
+
// Packet number
extendedInfo.append("<packet>");
extendedInfo.append(parser.group(index++));
extendedInfo.append("</packet>");
-
+
// GSM base station
extendedInfo.append("<gsm>");
extendedInfo.append(parser.group(index++));
extendedInfo.append("</gsm>");
-
+
// Longitude
Double lonlitude = Double.valueOf(parser.group(index++));
lonlitude += Double.valueOf(parser.group(index++)) / 60;
if (parser.group(index++).compareTo("W") == 0) lonlitude = -lonlitude;
position.setLongitude(lonlitude);
-
+
// Latitude
Double latitude = Double.valueOf(parser.group(index++));
latitude += Double.valueOf(parser.group(index++)) / 60;
if (parser.group(index++).compareTo("S") == 0) latitude = -latitude;
position.setLatitude(latitude);
-
+
// Altitude
position.setAltitude(0.0);
// Speed and Course
position.setSpeed(Double.valueOf(parser.group(index++)));
position.setCourse(Double.valueOf(parser.group(index++)));
-
+
// Date
Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
time.clear();
diff --git a/src/org/traccar/protocol/Xexun2ProtocolDecoder.java b/src/org/traccar/protocol/Xexun2ProtocolDecoder.java
index 54f502667..2e84ef47f 100644
--- a/src/org/traccar/protocol/Xexun2ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Xexun2ProtocolDecoder.java
@@ -21,21 +21,21 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.traccar.GenericProtocolDecoder;
+import org.traccar.BaseProtocolDecoder;
+import org.traccar.ServerManager;
import org.traccar.helper.Log;
-import org.traccar.model.DataManager;
import org.traccar.model.Position;
/**
* Xexun tracker protocol decoder
*/
-public class Xexun2ProtocolDecoder extends GenericProtocolDecoder {
+public class Xexun2ProtocolDecoder extends BaseProtocolDecoder {
/**
* Initialize
*/
- public Xexun2ProtocolDecoder(DataManager dataManager) {
- super(dataManager);
+ public Xexun2ProtocolDecoder(ServerManager serverManager) {
+ super(serverManager);
}
/**
diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java
index 6610730e9..1fd572896 100644
--- a/src/org/traccar/protocol/XexunProtocolDecoder.java
+++ b/src/org/traccar/protocol/XexunProtocolDecoder.java
@@ -22,21 +22,21 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.traccar.GenericProtocolDecoder;
+import org.traccar.BaseProtocolDecoder;
+import org.traccar.ServerManager;
import org.traccar.helper.Log;
-import org.traccar.model.DataManager;
import org.traccar.model.Position;
/**
* Xexun tracker protocol decoder
*/
-public class XexunProtocolDecoder extends GenericProtocolDecoder {
+public class XexunProtocolDecoder extends BaseProtocolDecoder {
/**
* Initialize
*/
- public XexunProtocolDecoder(DataManager dataManager) {
- super(dataManager);
+ public XexunProtocolDecoder(ServerManager serverManager) {
+ super(serverManager);
}
/**