aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pom.xml24
-rw-r--r--src/org/traccar/BaseProtocolDecoder.java38
-rw-r--r--src/org/traccar/protocol/Tk103ProtocolDecoder.java2
-rw-r--r--test/org/traccar/protocol/Tk103ProtocolDecoderTest.java3
4 files changed, 41 insertions, 26 deletions
diff --git a/pom.xml b/pom.xml
index 4d6e944a4..22000da3d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -136,6 +136,23 @@
<plugins>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>2.17</version>
+ <configuration>
+ <configLocation>checkstyle.xml</configLocation>
+ </configuration>
+ <executions>
+ <execution>
+ <id>checkstyle</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
@@ -214,13 +231,6 @@
<version>2.5</version>
</plugin>
<plugin>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.17</version>
- <configuration>
- <configLocation>checkstyle.xml</configLocation>
- </configuration>
- </plugin>
- <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.4</version>
diff --git a/src/org/traccar/BaseProtocolDecoder.java b/src/org/traccar/BaseProtocolDecoder.java
index 9a253e351..59205bc6f 100644
--- a/src/org/traccar/BaseProtocolDecoder.java
+++ b/src/org/traccar/BaseProtocolDecoder.java
@@ -78,25 +78,27 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder {
}
public void getLastLocation(Position position, Date deviceTime) {
- position.setOutdated(true);
-
- Position last = Context.getIdentityManager().getLastPosition(getDeviceId());
- if (last != null) {
- position.setFixTime(last.getFixTime());
- position.setValid(last.getValid());
- position.setLatitude(last.getLatitude());
- position.setLongitude(last.getLongitude());
- position.setAltitude(last.getAltitude());
- position.setSpeed(last.getSpeed());
- position.setCourse(last.getCourse());
- } else {
- position.setFixTime(new Date(0));
- }
+ if (position.getDeviceId() != 0) {
+ position.setOutdated(true);
+
+ Position last = Context.getIdentityManager().getLastPosition(position.getDeviceId());
+ if (last != null) {
+ position.setFixTime(last.getFixTime());
+ position.setValid(last.getValid());
+ position.setLatitude(last.getLatitude());
+ position.setLongitude(last.getLongitude());
+ position.setAltitude(last.getAltitude());
+ position.setSpeed(last.getSpeed());
+ position.setCourse(last.getCourse());
+ } else {
+ position.setFixTime(new Date(0));
+ }
- if (deviceTime != null) {
- position.setDeviceTime(deviceTime);
- } else {
- position.setDeviceTime(new Date());
+ if (deviceTime != null) {
+ position.setDeviceTime(deviceTime);
+ } else {
+ position.setDeviceTime(new Date());
+ }
}
}
diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
index 36378d088..a22eaa4ba 100644
--- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
@@ -121,7 +121,7 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
int power = parser.nextInt();
if (power != 65535) {
- position.set(Position.KEY_POWER, battery);
+ position.set(Position.KEY_POWER, power);
}
return position;
diff --git a/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java b/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java
index b64f1ae26..bd54a4ade 100644
--- a/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class Tk103ProtocolDecoderTest extends ProtocolTest {
Tk103ProtocolDecoder decoder = new Tk103ProtocolDecoder(new Tk103Protocol());
verifyAttributes(decoder, text(
+ "(013632651491,ZC20,180716,144222,6,392,65535,255"));
+
+ verifyAttributes(decoder, text(
"(087072009461BR00000007V0000.0000N00000.0000E000.00014039900000000L00000000"));
verifyPosition(decoder, text(