aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-09-02 15:28:56 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-09-02 15:28:56 +1200
commit69200d5d68bbd4ed5b5c6b10d4231f365b10db80 (patch)
tree095e6af04ed89e763ce0e696083add411fc054fe
parent5cf8952d716419871259ad5a6d4bf8ac98c21efe (diff)
downloadtraccar-server-69200d5d68bbd4ed5b5c6b10d4231f365b10db80.tar.gz
traccar-server-69200d5d68bbd4ed5b5c6b10d4231f365b10db80.tar.bz2
traccar-server-69200d5d68bbd4ed5b5c6b10d4231f365b10db80.zip
Add panic status code
-rw-r--r--src/org/traccar/WebDataHandler.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/org/traccar/WebDataHandler.java b/src/org/traccar/WebDataHandler.java
index 5f12b9c93..6a359ba0f 100644
--- a/src/org/traccar/WebDataHandler.java
+++ b/src/org/traccar/WebDataHandler.java
@@ -21,6 +21,7 @@ import java.util.Locale;
import java.util.TimeZone;
import org.traccar.helper.Crc;
import org.traccar.model.Device;
+import org.traccar.model.Event;
import org.traccar.model.Position;
public class WebDataHandler extends BaseDataHandler {
@@ -56,6 +57,16 @@ public class WebDataHandler extends BaseDataHandler {
return s.toString();
}
+ private String calculateStatus(Position position) {
+ if (position.getOther().containsKey(Event.KEY_ALARM) && (Boolean) position.getOther().get(Event.KEY_ALARM)) {
+ return "0xF841"; // STATUS_PANIC_ON
+ } else if (position.getSpeed() < 1.0) {
+ return "0xF020"; // STATUS_LOCATION
+ } else {
+ return "0xF11C"; // STATUS_MOTION_MOVING
+ }
+ }
+
@Override
protected Position handlePosition(Position position) {
@@ -68,7 +79,7 @@ public class WebDataHandler extends BaseDataHandler {
.replace("{latitude}", String.valueOf(position.getLatitude()))
.replace("{longitude}", String.valueOf(position.getLongitude()))
.replace("{gprmc}", formatSentence(position))
- .replace("{statusCode}", position.getSpeed() < 1.0 ? "0xF020" : "0xF11C");
+ .replace("{statusCode}", calculateStatus(position));
Context.getAsyncHttpClient().prepareGet(request).execute();