aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/FilterHandler.java4
-rw-r--r--src/org/traccar/TrackerEventHandler.java2
-rw-r--r--src/org/traccar/database/DataManager.java2
-rw-r--r--src/org/traccar/database/ObjectConverter.java2
-rw-r--r--src/org/traccar/model/Data.java63
-rw-r--r--src/org/traccar/model/Device.java34
-rw-r--r--src/org/traccar/model/Message.java57
-rw-r--r--src/org/traccar/model/Position.java162
-rw-r--r--src/org/traccar/protocol/BceProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/GalileoProtocolDecoder.java23
-rw-r--r--src/org/traccar/protocol/NavisProtocolDecoder.java11
-rw-r--r--src/org/traccar/protocol/UlbotechProtocolDecoder.java9
12 files changed, 92 insertions, 279 deletions
diff --git a/src/org/traccar/FilterHandler.java b/src/org/traccar/FilterHandler.java
index 88eeb7080..455e05ffc 100644
--- a/src/org/traccar/FilterHandler.java
+++ b/src/org/traccar/FilterHandler.java
@@ -84,7 +84,7 @@ public class FilterHandler extends OneToOneDecoder {
if (filterDuplicate) {
Position last = lastPositions.get(position.getDeviceId());
if (last != null) {
- return position.getTime().equals(last.getTime());
+ return position.getFixTime().equals(last.getFixTime());
} else {
return false;
}
@@ -113,7 +113,7 @@ public class FilterHandler extends OneToOneDecoder {
if (filterLimit != 0) {
Position last = lastPositions.get(position.getDeviceId());
if (last != null) {
- return (position.getTime().getTime() - last.getTime().getTime()) > filterLimit;
+ return (position.getFixTime().getTime() - last.getFixTime().getTime()) > filterLimit;
} else {
return false;
}
diff --git a/src/org/traccar/TrackerEventHandler.java b/src/org/traccar/TrackerEventHandler.java
index bc3ff0e16..aeb751d4e 100644
--- a/src/org/traccar/TrackerEventHandler.java
+++ b/src/org/traccar/TrackerEventHandler.java
@@ -33,7 +33,7 @@ public class TrackerEventHandler extends IdleStateAwareChannelHandler {
} else {
StringBuilder s = new StringBuilder();
s.append("device: ").append(position.getDeviceId()).append(", ");
- s.append("time: ").append(position.getTime()).append(", ");
+ s.append("time: ").append(position.getFixTime()).append(", ");
s.append("lat: ").append(position.getLatitude()).append(", ");
s.append("lon: ").append(position.getLongitude());
Log.info(s.toString());
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index 4b8f4d5e8..d53ec7838 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -180,7 +180,7 @@ public class DataManager {
private NamedParameterStatement.Params assignVariables(NamedParameterStatement.Params params, Position position) throws SQLException {
params.setLong("device_id", position.getDeviceId());
- params.setTimestamp("time", position.getTime());
+ params.setTimestamp("time", position.getFixTime());
params.setBoolean("valid", position.getValid());
params.setDouble("altitude", position.getAltitude());
params.setDouble("latitude", position.getLatitude());
diff --git a/src/org/traccar/database/ObjectConverter.java b/src/org/traccar/database/ObjectConverter.java
index 072ab7a7d..bd5b03064 100644
--- a/src/org/traccar/database/ObjectConverter.java
+++ b/src/org/traccar/database/ObjectConverter.java
@@ -36,7 +36,7 @@ public class ObjectConverter {
JsonObjectBuilder object = Json.createObjectBuilder();
//object.add("id", position.getId());
- object.add("time", dateFormat.format(position.getTime()));
+ object.add("time", dateFormat.format(position.getFixTime()));
object.add("valid", position.getValid());
object.add("latitude", position.getLatitude());
object.add("longitude", position.getLongitude());
diff --git a/src/org/traccar/model/Data.java b/src/org/traccar/model/Data.java
index 82a9630d5..ce23154c2 100644
--- a/src/org/traccar/model/Data.java
+++ b/src/org/traccar/model/Data.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2013 - 2015 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.
@@ -17,61 +17,26 @@ package org.traccar.model;
import java.util.Date;
-/**
- * Data without location
- */
public class Data {
- /**
- * Id
- */
- private Long id;
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- /**
- * Device
- */
- private Long deviceId;
+ private long id;
+ public long getId() { return id; }
+ public void setId(long id) { this.id = id; }
- public Long getDeviceId() {
- return deviceId;
- }
+ private long deviceId;
+ public long getDeviceId() { return deviceId; }
+ public void setDeviceId(long deviceId) { this.deviceId = deviceId; }
- public void setDeviceId(Long deviceId) {
- this.deviceId = deviceId;
- }
-
- /**
- * Server time (UTC)
- */
private Date serverTime;
+ public Date getServerTime() { return serverTime; }
+ public void setServerTime(Date serverTime) { this.serverTime = serverTime; }
- public Date getServerTime() {
- return serverTime;
- }
-
- public void setServerTime(Date serverTime) {
- this.serverTime = serverTime;
- }
+ private Date deviceTime;
+ public Date getDeviceTime() { return deviceTime; }
+ public void setDeviceTime(Date deviceTime) { this.deviceTime = deviceTime; }
- /**
- * Extended information in XML format
- */
private String extendedInfo;
-
- public String getExtendedInfo() {
- return extendedInfo;
- }
-
- public void setExtendedInfo(String extendedInfo) {
- this.extendedInfo = extendedInfo;
- }
+ public String getExtendedInfo() { return extendedInfo; }
+ public void setExtendedInfo(String extendedInfo) { this.extendedInfo = extendedInfo; }
}
diff --git a/src/org/traccar/model/Device.java b/src/org/traccar/model/Device.java
index cd1985e37..273faebcf 100644
--- a/src/org/traccar/model/Device.java
+++ b/src/org/traccar/model/Device.java
@@ -20,37 +20,23 @@ import java.util.Date;
public class Device {
private long id;
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
+ public long getId() { return id; }
+ public void setId(long id) { this.id = id; }
private String name;
-
- public String getName() {
- return uniqueId;
- }
-
- public void setName(String name) {
- this.name = name;
- }
+ public String getName() { return uniqueId; }
+ public void setName(String name) { this.name = name; }
private String uniqueId;
-
- public String getUniqueId() {
- return uniqueId;
- }
-
- public void setUniqueId(String uniqueId) {
- this.uniqueId = uniqueId;
- }
+ public String getUniqueId() { return uniqueId; }
+ public void setUniqueId(String uniqueId) { this.uniqueId = uniqueId; }
private String status;
private Date lastUpdate;
+
+ private long positionId;
+
+ private long dataId;
}
diff --git a/src/org/traccar/model/Message.java b/src/org/traccar/model/Message.java
deleted file mode 100644
index c699393d8..000000000
--- a/src/org/traccar/model/Message.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.model;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class Message {
-
- private final Map data = new HashMap();
-
- public void putString(String key, String value) {
- data.put(key, value);
- }
-
- public String getString(String key) {
- return (String) data.get(key);
- }
-
- public void putInteger(String key, int value) {
- data.put(key, value);
- }
-
- public int getInteger(String key) {
- return (Integer) data.get(key);
- }
-
- public void putDouble(String key, double value) {
- data.put(key, value);
- }
-
- public double getDouble(String key) {
- return (Double) data.get(key);
- }
-
- public void putBoolean(String key, boolean value) {
- data.put(key, value);
- }
-
- public boolean getBoolean(String key) {
- return (Boolean) data.get(key);
- }
-
-}
diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java
index 898b0d144..14f758b4a 100644
--- a/src/org/traccar/model/Position.java
+++ b/src/org/traccar/model/Position.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2013 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2012 - 2015 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.
@@ -17,137 +17,63 @@ package org.traccar.model;
import java.util.Date;
-/**
- * Position information
- */
-public class Position extends Data {
-
- public Position() {
- }
+public class Position {
+
+ private long id;
+ public long getId() { return id; }
+ public void setId(long id) { this.id = id; }
- public Position(
- long deviceId,
- Date time,
- boolean valid,
- double latitude,
- double longitude,
- double altitude,
- double speed,
- double course) {
-
- setDeviceId(deviceId);
- setTime(time);
- setValid(valid);
- setLatitude(latitude);
- setLongitude(longitude);
- setAltitude(altitude);
- setSpeed(speed);
- setCourse(course);
- }
+ private long deviceId;
+ public long getDeviceId() { return deviceId; }
+ public void setDeviceId(long deviceId) { this.deviceId = deviceId; }
+ private Date serverTime;
+ public Date getServerTime() { return serverTime; }
+ public void setServerTime(Date serverTime) { this.serverTime = serverTime; }
- /**
- * Time (UTC)
- */
- private Date time;
-
- public Date getTime() {
- return time;
- }
+ private Date deviceTime;
+ public Date getDeviceTime() { return deviceTime; }
+ public void setDeviceTime(Date deviceTime) { this.deviceTime = deviceTime; }
+ private Date fixTime;
+ public Date getFixTime() { return fixTime; }
+ public void setFixTime(Date fixTime) { this.fixTime = fixTime; }
+
public void setTime(Date time) {
- this.time = time;
- }
-
- /**
- * Validity flag
- */
- private Boolean valid;
-
- public Boolean getValid() {
- return valid;
- }
-
- public void setValid(Boolean valid) {
- this.valid = valid;
- }
-
- /**
- * Latitude
- */
- private Double latitude;
-
- public Double getLatitude() {
- return latitude;
- }
-
- public void setLatitude(Double latitude) {
- this.latitude = latitude;
+ deviceTime = time;
+ fixTime = time;
}
- /**
- * Longitude
- */
- private Double longitude;
+ private boolean valid;
+ public boolean getValid() { return valid; }
+ public void setValid(boolean valid) { this.valid = valid; }
- public Double getLongitude() {
- return longitude;
- }
+ private double latitude;
+ public double getLatitude() { return latitude; }
+ public void setLatitude(double latitude) { this.latitude = latitude; }
- public void setLongitude(Double longitude) {
- this.longitude = longitude;
- }
+ private double longitude;
+ public double getLongitude() { return longitude; }
+ public void setLongitude(double longitude) { this.longitude = longitude; }
- /**
- * Altitude
- */
- private Double altitude;
+ private double altitude;
+ public double getAltitude() { return altitude; }
+ public void setAltitude(double altitude) { this.altitude = altitude; }
- public Double getAltitude() {
- return altitude;
- }
-
- public void setAltitude(Double altitude) {
- this.altitude = altitude;
- }
+ private double speed; // value in knots
+ public double getSpeed() { return speed; }
+ public void setSpeed(double speed) { this.speed = speed; }
- /**
- * Speed (knots)
- */
- private Double speed;
-
- public Double getSpeed() {
- return speed;
- }
-
- public void setSpeed(Double speed) {
- this.speed = speed;
- }
+ private double course;
+ public double getCourse() { return course; }
+ public void setCourse(double course) { this.course = course; }
- /**
- * Course
- */
- private Double course;
-
- public Double getCourse() {
- return course;
- }
-
- public void setCourse(Double course) {
- this.course = course;
- }
-
- /**
- * Address
- */
private String address;
+ public String getAddress() { return address; }
+ public void setAddress(String address) { this.address = address; }
- public String getAddress() {
- return address;
- }
-
- public void setAddress(String address) {
- this.address = address;
- }
+ private String extendedInfo;
+ public String getExtendedInfo() { return extendedInfo; }
+ public void setExtendedInfo(String extendedInfo) { this.extendedInfo = extendedInfo; }
}
diff --git a/src/org/traccar/protocol/BceProtocolDecoder.java b/src/org/traccar/protocol/BceProtocolDecoder.java
index 2f96ab317..ac8e257e3 100644
--- a/src/org/traccar/protocol/BceProtocolDecoder.java
+++ b/src/org/traccar/protocol/BceProtocolDecoder.java
@@ -136,7 +136,7 @@ public class BceProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedByte();
}
- if (position.getValid() != null) {
+ if (checkBit(mask, 0)) {
positions.add(position);
}
}
diff --git a/src/org/traccar/protocol/GalileoProtocolDecoder.java b/src/org/traccar/protocol/GalileoProtocolDecoder.java
index 99b745175..e30eaf914 100644
--- a/src/org/traccar/protocol/GalileoProtocolDecoder.java
+++ b/src/org/traccar/protocol/GalileoProtocolDecoder.java
@@ -90,6 +90,7 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
List<Position> positions = new LinkedList<Position>();
Set<Integer> tags = new HashSet<Integer>();
+ boolean hasLocation = false;
Position position = new Position();
ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());
@@ -99,8 +100,11 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
int tag = buf.readUnsignedByte();
if (tags.contains(tag)) {
position.setExtendedInfo(extendedInfo.toString());
- positions.add(position);
+ if (hasLocation && position.getFixTime() != null) {
+ positions.add(position);
+ }
tags.clear();
+ hasLocation = false;
position = new Position();
extendedInfo = new ExtendedInfoFormatter(getProtocol());
}
@@ -119,6 +123,7 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
break;
case TAG_COORDINATES:
+ hasLocation = true;
position.setValid((buf.readUnsignedByte() & 0xf0) == 0x00);
position.setLatitude(buf.readInt() / 1000000.0);
position.setLongitude(buf.readInt() / 1000000.0);
@@ -157,7 +162,9 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
}
position.setExtendedInfo(extendedInfo.toString());
- positions.add(position);
+ if (hasLocation && position.getFixTime() != null) {
+ positions.add(position);
+ }
if (!hasDeviceId()) {
Log.warning("Unknown device");
@@ -166,18 +173,8 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
sendReply(channel, buf.readUnsignedShort());
- for (Iterator<Position> i = positions.iterator(); i.hasNext(); ) {
- Position p = i.next();
-
+ for (Position p : positions) {
p.setDeviceId(getDeviceId());
-
- if (p.getAltitude() == null) {
- p.setAltitude(0.0);
- }
-
- if (p.getValid() == null || p.getTime() == null || p.getSpeed() == null) {
- i.remove();
- }
}
if (positions.isEmpty()) {
diff --git a/src/org/traccar/protocol/NavisProtocolDecoder.java b/src/org/traccar/protocol/NavisProtocolDecoder.java
index 8a5afc17f..7ac0dccdf 100644
--- a/src/org/traccar/protocol/NavisProtocolDecoder.java
+++ b/src/org/traccar/protocol/NavisProtocolDecoder.java
@@ -20,7 +20,6 @@ import java.nio.charset.Charset;
import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;
-import java.util.Properties;
import java.util.TimeZone;
import org.jboss.netty.buffer.ChannelBuffer;
@@ -29,8 +28,6 @@ import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
-import org.traccar.database.DataManager;
-import org.traccar.helper.Log;
import org.traccar.model.ExtendedInfoFormatter;
import org.traccar.model.Position;
@@ -64,8 +61,8 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
}
private class ParseResult {
- private long id;
- private Position position;
+ private final long id;
+ private final Position position;
public ParseResult(long id, Position position) {
this.id = id;
@@ -226,7 +223,7 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
sendReply(channel, response);
// No location data
- if (result.getPosition().getValid() == null) {
+ if (result.getPosition().getFixTime() == null) {
return null;
}
@@ -239,7 +236,7 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
for (int i = 0; i < count; i++) {
Position position = parsePosition(buf).getPosition();
- if (position.getValid() != null) {
+ if (position.getFixTime() != null) {
positions.add(position);
}
}
diff --git a/src/org/traccar/protocol/UlbotechProtocolDecoder.java b/src/org/traccar/protocol/UlbotechProtocolDecoder.java
index 9ad590ad4..0872f6238 100644
--- a/src/org/traccar/protocol/UlbotechProtocolDecoder.java
+++ b/src/org/traccar/protocol/UlbotechProtocolDecoder.java
@@ -19,14 +19,11 @@ import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
-import org.traccar.database.DataManager;
import org.traccar.helper.ChannelBufferTools;
-import org.traccar.helper.Log;
import org.traccar.model.ExtendedInfoFormatter;
import org.traccar.model.Position;
import java.util.Date;
-import java.util.Properties;
public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
@@ -72,6 +69,8 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
long seconds = buf.readUnsignedInt() & 0x7fffffffl;
seconds += 946684800l; // 2000-01-01 00:00
position.setTime(new Date(seconds * 1000));
+
+ boolean hasLocation = false;
while (buf.readableBytes() > 3) {
@@ -81,10 +80,10 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
switch (type) {
case DATA_GPS:
+ hasLocation = true;
position.setValid(true);
position.setLatitude(buf.readInt() / 1000000.0);
position.setLongitude(buf.readInt() / 1000000.0);
- position.setAltitude(0.0);
position.setSpeed(buf.readUnsignedShort() * 0.539957);
position.setCourse((double) buf.readUnsignedShort());
extendedInfo.set("hdop", buf.readUnsignedShort());
@@ -98,7 +97,7 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
position.setExtendedInfo(extendedInfo.toString());
- if (position.getValid() != null) {
+ if (hasLocation) {
return position;
}
return null;