aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-01-26 21:19:55 +1300
committerGitHub <noreply@github.com>2017-01-26 21:19:55 +1300
commit3155b8697a9b3f8023e085a766a439eee4c058db (patch)
tree2d9ed07ff32b00b330029b187c96b9768f034fef /src/org/traccar
parentb1453ebd231009e9d9078377f2a1e063d852c444 (diff)
parentd0cb885b152d5db3913936c8f1b57e690a47a067 (diff)
downloadtrackermap-server-3155b8697a9b3f8023e085a766a439eee4c058db.tar.gz
trackermap-server-3155b8697a9b3f8023e085a766a439eee4c058db.tar.bz2
trackermap-server-3155b8697a9b3f8023e085a766a439eee4c058db.zip
Merge pull request #2833 from Abyss777/fix_ignition
Rise ignition events only if both positions has ignition attribute
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/events/IgnitionEventHandler.java29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/org/traccar/events/IgnitionEventHandler.java b/src/org/traccar/events/IgnitionEventHandler.java
index 8464c3aef..187b7ce73 100644
--- a/src/org/traccar/events/IgnitionEventHandler.java
+++ b/src/org/traccar/events/IgnitionEventHandler.java
@@ -39,20 +39,21 @@ public class IgnitionEventHandler extends BaseEventHandler {
Collection<Event> result = null;
- boolean ignition = position.getBoolean(Position.KEY_IGNITION);
-
- boolean oldIgnition = false;
- Position lastPosition = Context.getIdentityManager().getLastPosition(position.getDeviceId());
- if (lastPosition != null) {
- oldIgnition = lastPosition.getBoolean(Position.KEY_IGNITION);
- }
-
- if (ignition && !oldIgnition) {
- result = Collections.singleton(
- new Event(Event.TYPE_IGNITION_ON, position.getDeviceId(), position.getId()));
- } else if (!ignition && oldIgnition) {
- result = Collections.singleton(
- new Event(Event.TYPE_IGNITION_OFF, position.getDeviceId(), position.getId()));
+ if (position.getAttributes().containsKey(Position.KEY_IGNITION)) {
+ boolean ignition = position.getBoolean(Position.KEY_IGNITION);
+
+ Position lastPosition = Context.getIdentityManager().getLastPosition(position.getDeviceId());
+ if (lastPosition != null && lastPosition.getAttributes().containsKey(Position.KEY_IGNITION)) {
+ boolean oldIgnition = lastPosition.getBoolean(Position.KEY_IGNITION);
+
+ if (ignition && !oldIgnition) {
+ result = Collections.singleton(
+ new Event(Event.TYPE_IGNITION_ON, position.getDeviceId(), position.getId()));
+ } else if (!ignition && oldIgnition) {
+ result = Collections.singleton(
+ new Event(Event.TYPE_IGNITION_OFF, position.getDeviceId(), position.getId()));
+ }
+ }
}
return result;
}