aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/handler
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-18 13:19:53 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-18 13:19:53 -0700
commit3a293661cd2900c115cfea6037c02d659c57aa52 (patch)
treede6f5f187af17b0272654016a6c2049c98f67d9a /src/main/java/org/traccar/handler
parent589582c7ecc0d1cd5321cb6e9f4b823284369498 (diff)
downloadtrackermap-server-3a293661cd2900c115cfea6037c02d659c57aa52.tar.gz
trackermap-server-3a293661cd2900c115cfea6037c02d659c57aa52.tar.bz2
trackermap-server-3a293661cd2900c115cfea6037c02d659c57aa52.zip
Move device status
Diffstat (limited to 'src/main/java/org/traccar/handler')
-rw-r--r--src/main/java/org/traccar/handler/events/MotionEventHandler.java13
-rw-r--r--src/main/java/org/traccar/handler/events/OverspeedEventHandler.java12
2 files changed, 13 insertions, 12 deletions
diff --git a/src/main/java/org/traccar/handler/events/MotionEventHandler.java b/src/main/java/org/traccar/handler/events/MotionEventHandler.java
index 724e9bf15..bc9d5f722 100644
--- a/src/main/java/org/traccar/handler/events/MotionEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/MotionEventHandler.java
@@ -17,12 +17,12 @@
package org.traccar.handler.events;
import io.netty.channel.ChannelHandler;
-import org.traccar.database.DeviceManager;
import org.traccar.helper.model.PositionUtil;
import org.traccar.model.Device;
import org.traccar.model.Event;
import org.traccar.model.Position;
import org.traccar.reports.common.TripsConfig;
+import org.traccar.session.ConnectionManager;
import org.traccar.session.DeviceState;
import org.traccar.session.cache.CacheManager;
@@ -34,13 +34,14 @@ import java.util.Map;
public class MotionEventHandler extends BaseEventHandler {
private final CacheManager cacheManager;
- private final DeviceManager deviceManager;
+ private final ConnectionManager connectionManager;
private final TripsConfig tripsConfig;
@Inject
- public MotionEventHandler(CacheManager cacheManager, DeviceManager deviceManager, TripsConfig tripsConfig) {
+ public MotionEventHandler(
+ CacheManager cacheManager, ConnectionManager connectionManager, TripsConfig tripsConfig) {
this.cacheManager = cacheManager;
- this.deviceManager = deviceManager;
+ this.connectionManager = connectionManager;
this.tripsConfig = tripsConfig;
}
@@ -123,14 +124,14 @@ public class MotionEventHandler extends BaseEventHandler {
}
Map<Event, Position> result = null;
- DeviceState deviceState = deviceManager.getDeviceState(deviceId);
+ DeviceState deviceState = connectionManager.getDeviceState(deviceId);
if (deviceState.getMotionState() == null) {
deviceState.setMotionState(position.getBoolean(Position.KEY_MOTION));
} else {
result = updateMotionState(deviceState, position);
}
- deviceManager.setDeviceState(deviceId, deviceState);
+ connectionManager.setDeviceState(deviceId, deviceState);
return result;
}
diff --git a/src/main/java/org/traccar/handler/events/OverspeedEventHandler.java b/src/main/java/org/traccar/handler/events/OverspeedEventHandler.java
index 6de56d11e..7f3675308 100644
--- a/src/main/java/org/traccar/handler/events/OverspeedEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/OverspeedEventHandler.java
@@ -22,10 +22,10 @@ import java.util.Map;
import io.netty.channel.ChannelHandler;
import org.traccar.config.Config;
import org.traccar.config.Keys;
-import org.traccar.database.DeviceManager;
import org.traccar.helper.model.AttributeUtil;
import org.traccar.helper.model.PositionUtil;
import org.traccar.model.Device;
+import org.traccar.session.ConnectionManager;
import org.traccar.session.DeviceState;
import org.traccar.model.Event;
import org.traccar.model.Geofence;
@@ -39,7 +39,7 @@ public class OverspeedEventHandler extends BaseEventHandler {
public static final String ATTRIBUTE_SPEED = "speed";
- private final DeviceManager deviceManager;
+ private final ConnectionManager connectionManager;
private final CacheManager cacheManager;
private final boolean notRepeat;
@@ -47,8 +47,8 @@ public class OverspeedEventHandler extends BaseEventHandler {
private final boolean preferLowest;
@Inject
- public OverspeedEventHandler(Config config, DeviceManager deviceManager, CacheManager cacheManager) {
- this.deviceManager = deviceManager;
+ public OverspeedEventHandler(Config config, ConnectionManager connectionManager, CacheManager cacheManager) {
+ this.connectionManager = connectionManager;
this.cacheManager = cacheManager;
notRepeat = config.getBoolean(Keys.EVENT_OVERSPEED_NOT_REPEAT);
minimalDuration = config.getLong(Keys.EVENT_OVERSPEED_MINIMAL_DURATION) * 1000;
@@ -157,7 +157,7 @@ public class OverspeedEventHandler extends BaseEventHandler {
}
Map<Event, Position> result = null;
- DeviceState deviceState = deviceManager.getDeviceState(deviceId);
+ DeviceState deviceState = connectionManager.getDeviceState(deviceId);
if (deviceState.getOverspeedState() == null) {
deviceState.setOverspeedState(position.getSpeed() > speedLimit);
@@ -166,7 +166,7 @@ public class OverspeedEventHandler extends BaseEventHandler {
result = updateOverspeedState(deviceState, position, speedLimit, overspeedGeofenceId);
}
- deviceManager.setDeviceState(deviceId, deviceState);
+ connectionManager.setDeviceState(deviceId, deviceState);
return result;
}