diff options
author | Anton Tananaev <anton@traccar.org> | 2022-09-25 10:35:20 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-09-25 10:35:20 -0700 |
commit | fe3d9995cceb2f1530a7c2549ae9a4cf457cb7f0 (patch) | |
tree | 36e7d1b457f7c1e8d3b867cd106033d000a59ddf /src/main/java/org/traccar/reports | |
parent | abb26e80a5617424d960a0f7d0b98fcb379a5224 (diff) | |
download | trackermap-server-fe3d9995cceb2f1530a7c2549ae9a4cf457cb7f0.tar.gz trackermap-server-fe3d9995cceb2f1530a7c2549ae9a4cf457cb7f0.tar.bz2 trackermap-server-fe3d9995cceb2f1530a7c2549ae9a4cf457cb7f0.zip |
Persist device state
Diffstat (limited to 'src/main/java/org/traccar/reports')
-rw-r--r-- | src/main/java/org/traccar/reports/common/ReportUtils.java | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/main/java/org/traccar/reports/common/ReportUtils.java b/src/main/java/org/traccar/reports/common/ReportUtils.java index 2bca00df7..57ed4d148 100644 --- a/src/main/java/org/traccar/reports/common/ReportUtils.java +++ b/src/main/java/org/traccar/reports/common/ReportUtils.java @@ -30,7 +30,6 @@ import org.traccar.api.security.PermissionsService; import org.traccar.config.Config; import org.traccar.config.Keys; import org.traccar.geocoder.Geocoder; -import org.traccar.handler.events.MotionEventHandler; import org.traccar.helper.UnitsConverter; import org.traccar.helper.model.PositionUtil; import org.traccar.helper.model.UserUtil; @@ -43,7 +42,8 @@ import org.traccar.model.User; import org.traccar.reports.model.BaseReportItem; import org.traccar.reports.model.StopReportItem; import org.traccar.reports.model.TripReportItem; -import org.traccar.session.DeviceState; +import org.traccar.session.state.MotionProcessor; +import org.traccar.session.state.MotionState; import org.traccar.storage.Storage; import org.traccar.storage.StorageException; import org.traccar.storage.query.Columns; @@ -350,17 +350,16 @@ public class ReportUtils { ArrayList<Position> positions = new ArrayList<>(positionCollection); if (!positions.isEmpty()) { boolean trips = reportClass.equals(TripReportItem.class); - MotionEventHandler motionHandler = new MotionEventHandler(null, null, tripsConfig); - DeviceState deviceState = new DeviceState(); - deviceState.setMotionState(isMoving(positions, 0, tripsConfig)); + MotionState motionState = new MotionState(); + motionState.setMotionState(isMoving(positions, 0, tripsConfig)); - boolean detected = trips == deviceState.getMotionState(); + boolean detected = trips == motionState.getMotionState(); int startEventIndex = detected ? 0 : -1; int startNoEventIndex = -1; for (int i = 0; i < positions.size(); i++) { boolean motion = isMoving(positions, i, tripsConfig); - if (deviceState.getMotionState() != motion) { + if (motionState.getMotionState() != motion) { if (motion == trips) { startEventIndex = detected ? startEventIndex : i; startNoEventIndex = -1; @@ -369,7 +368,8 @@ public class ReportUtils { } } - if (motionHandler.updateMotionState(deviceState, positions.get(i), motion) != null) { + MotionProcessor.updateState(motionState, positions.get(i), motion, tripsConfig); + if (motionState.getEvent() != null) { if (motion == trips) { detected = true; startNoEventIndex = -1; |