diff options
Diffstat (limited to 'src/net')
6 files changed, 106 insertions, 46 deletions
diff --git a/src/net/sourceforge/opentracking/Position.java b/src/net/sourceforge/opentracking/Position.java index 0e20c22c1..0c4117448 100644 --- a/src/net/sourceforge/opentracking/Position.java +++ b/src/net/sourceforge/opentracking/Position.java @@ -99,6 +99,19 @@ public class Position { public void setLongitude(Double newLongitude) { longitude = newLongitude; } + + /** + * Altitude + */ + private Double altitude; + + public Double getAltitude() { + return altitude; + } + + public void setAltitude(Double newAltitude) { + altitude = newAltitude; + } /** * Speed (knots) 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; + } + + 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)); + * Init Gl200 server + */ + public void initGl200Server(Properties properties) throws SQLException { + + boolean enable = BueOf(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() { diff --git a/src/net/sourceforge/opentracking/protocol/gl200/Gl200ProtocolDecoder.java b/src/net/sourceforge/opentracking/protocol/gl200/Gl200ProtocolDecoder.java index 0b7166ab2..6d0e0a8d9 100644 --- a/src/net/sourceforge/opentracking/protocol/gl200/Gl200ProtocolDecoder.java +++ b/src/net/sourceforge/opentracking/protocol/gl200/Gl200ProtocolDecoder.java @@ -58,19 +58,22 @@ public class Gl200ProtocolDecoder extends OneToOneDecoder { * Regular expressions pattern */ static private Pattern pattern = Pattern.compile( - "imei:" + - "([\\d]+)," + // IMEI - "[^,]+," + - "(\\d{2})(\\d{2})(\\d{2})[\\d]+," + // Date - "[+]?[\\d]*," + - "[FL]," + // F - full / L - low - "([\\d]{2})([\\d]{2})([\\d]{2}).([\\d]{3})," + // Time (HHMMSS.SSS) - "([AV])," + // Validity - "([\\d]{2})([\\d]{2}.[\\d]{4})," + // Latitude (DDMM.MMMM) - "([NS])," + - "([\\d]{3})([\\d]{2}.[\\d]{4})," + // Longitude (DDDMM.MMMM) - "([EW])," + - "([\\d]+.[\\d]{2}),"); // Speed + "\\+RESP:GT...," + + "\\d{6}," + // Protocol version + "(\\d{15})," + // IMEI + "[^,]*," + // Device name + "\\d," + // Report ID + "\\d," + // Report type + "\\d*," + // Number + "(\\d*)," + // GPS accuracy + "(\\d+.\\d)," + // Speed + "(\\d+)," + // Course + "(-?\\d+.\\d)," + // Altitude + "(-?\\d+.\\d+)," + // Longitude + "(-?\\d+.\\d+)," + // Latitude + "(\\d{4})(\\d{2})(\\d{2})" + // Date (YYYYMMDD) + "(\\d{2})(\\d{2})(\\d{2})," + // Time (HHMMSS) + "[^$]*"); /** | 7 |
6 files changed, 106 insertions, 46 deletions
public ChannelPipeline getPipeline() { + ChannelPipeline pipeline = Channels.pipeline(); + pipeline.addLast("openHandler", new OpenChannelHandler(server)); + >+ pipeline.addLast("handler", new TrackerEventHandler(serverCreator)); + return pipeline; + } + } + + oolean.valueOf(properties.getProperty("gl200.enable")); + if (enable) { + * Decode message @@ -81,16 +84,6 @@ public class Gl200ProtocolDecoder extends OneToOneDecoder { String sentence = (String) msg; - // Send response #1 - if (sentence.contains("##")) { - channel.write("LOAD"); - } - - // Send response #2 - if (sentence.length() == 15 && Character.isDigit(sentence.charAt(0))) { - channel.write("ON"); - } - // Parse message Matcher parser = pattern.matcher(sentence); if (!parser.matches()) { @@ -106,10 +99,20 @@ public class Gl200ProtocolDecoder extendass='add'>+ TrackerServer server = new TrackerServer( + Integer.valposition.setDeviceId(dataManager.getDeviceByImei(imei).getId()); + // Validity + position.setValid(Integer.valueOf(parser.group(index++)) == 0 ? false : true); + + // Position info + position.setSpeed(Double.valueOf(parser.group(index++))); + position.setCourse(Double.valueOf(parser.group(index++))); + position.setAltitude(Double.valueOf(parser.group(index++))); + position.setLongitude(Double.valueOf(parser.group(index++))); + position.setLatitude(Double.valueOf(parser.group(index++))); + // Date Calendar time = ns OneToOneDecoder { String imei = parser.group(index++); time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++))); + time.set(Calendar.YEAR, Integer.valueOf(parser.group(index++))); time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1); time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(parser.group(index++))); @@ -117,28 +120,8 @@ public class Gl200ProtocolDecoder extends OneToOneDecoder { time.set(Calendar.HOUR, Integer.valueOf(parser.group(index++))); time.set(Calendar.MINUTE, Integer.valueOf(parser.group(index++))); time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++))); - time.set(Calendar.MILLISECOND, Integer.valueOf(parser.group(index++))); time.clear(); -// Validity - position.setValid(parser.group(index++).compareTo("A") == 0 ? true : false); - - // 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); - - // Longitude - Double lonlitude = Double.valueOf(parser.group(index++)); - lonlitude += Double.valueOf(parser.group(index++)) / 60; - if (parser.group(index++).compareTo("W") == 0) lonlitude = -lonlitude; - podiv>
position.setTime(time.getTime()); - position.setSpeed(Double.valueOf(parser.group(index++))); - position.setCourse(0.0); - return position; } diff --git a/src/net/sourceforge/opentracking/protocol/gps103/Gps103ProtocolDecoder.java b/src/net/sourceforge/opentracking/protocol/gps103/Gps103ProtocolDecoder.java index faccc97d7..c9d8e2da1 100644 --- a/src/net/sourceforge/opentracking/protocol/gps103/Gps103ProtocolDecoder.java +++ b/- - // Speed -,9 @@ public class Gps103ProtocolDecoder extends OneToOneDecoder { lonlitude += Double.valueOf(parser.group(index++)) / 60; if (parser.group(index++).compareTo("W") == 0) lonlitude = -lonlitude; position.setLongitude(lonlitude); + + // Altitude + position.setAltitude(0.0); // Speed position.setSpeed(Double.valueOf(parser.group(index++))); diff --git a/src/net/sourceforge/opentracking/protocol/tk103/Tk103ProtocolDecoder.java b/src/net/sourceforge/opentracking/protocol/tk103/Tk103ProtocolDecoder.java index 2ff6ce949..79350307c 100644 --- a/src/net/sourceforge/opentracking/protocol/tk103/Tk103ProtocolDecoder.java +++ b/src/net/sourceforge/opentracking/protocol/tk103/Tk103ProtocolDecoder.java @@ -126,6 +126,9 @@ public class Tk103ProtocolDecoder extends OneToOneDecoder { if (parser.group(index++).compareTo("W") == 0) lonlitude = -lonlited position.setSpeed(Double.valueOf(parser.group(index++))); diff --git a/src/net/sourceforge/opentracking/protocol/xexun/XexunProtocolDecoder.java b/src/net/sourceforge/opentrac'>src/net/sourceforge/opentracking/protocol/xexun/XexunProtocolDecoder.java +++ b/src/net/sourceforge/opentracking/protocol/gps103/Gps103ProtocolDecoder.java @@ -134,6 +134ude; position.setLongitude(lonlitude); + // Altitude + position.setAltitude(0.0); + // Speking/protocol/xexun/XexunProtocolDecoder.java index afd2405c8..73b7cef11 100644 --- a/@@ -66,8 +66,8 @@ public class XexunProtocolDecoder extends OneToOneDecoder { "([NS])," + "([\\d]{3})([\\d]{2}.[\\d]{4})," + // Longitude (DDDMM.MMMM) "([EW])," + - forge/opentracking/protocol/xexun/XexunProtocolDecoder.java?h=v4.14&id=68d855d0f3c7fa09003c8ae497060831c7bdce7f'>sr // Course + "([\\d]+.[\\d]+)," + // Speed + "([\\d]+.[\\d]+)?," + // Course "([\\d]{2})([\\d]{2})([\\d]{2})," + // Date (DDMMYY) ".*imei:" + "([\\d]+),"); // IMEI @@ -114,6 +114,9 @@ public class XexunProtocolDecoder extends OneToOneDecoder { if (parser.group(index++).compareTo("W") == 0) lonlitude = -lonlitude; position.setLongitude(lonlitude); + // Altitude + position.setAltitude(0.0); + // Speed position.setSpeed "([\\d]+.[\\d]{2})," + // Speed - "([\\d]+.[\\d]{2})?," + div class='footer'>generated by cgit v1.2.3 (git 2.39.1) at 2024-12-15 12:31:24 +0000
|