diff options
author | Anton Tananaev <anton@traccar.org> | 2023-05-14 14:07:50 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2023-05-14 14:07:50 -0700 |
commit | a96a75cc268f2819431b7441090052b01bf61bed (patch) | |
tree | 287c556e270b05a489bc96a4756c82a754af7a41 /src/main/java/org/traccar/handler/events | |
parent | f68d23d79d0321ef47f72fff2388b5f4aac1beff (diff) | |
download | trackermap-server-a96a75cc268f2819431b7441090052b01bf61bed.tar.gz trackermap-server-a96a75cc268f2819431b7441090052b01bf61bed.tar.bz2 trackermap-server-a96a75cc268f2819431b7441090052b01bf61bed.zip |
Per device trip config
Diffstat (limited to 'src/main/java/org/traccar/handler/events')
-rw-r--r-- | src/main/java/org/traccar/handler/events/MotionEventHandler.java | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/handler/events/MotionEventHandler.java b/src/main/java/org/traccar/handler/events/MotionEventHandler.java index c406bd935..63b512291 100644 --- a/src/main/java/org/traccar/handler/events/MotionEventHandler.java +++ b/src/main/java/org/traccar/handler/events/MotionEventHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2022 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2023 Anton Tananaev (anton@traccar.org) * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,6 +19,8 @@ package org.traccar.handler.events; import io.netty.channel.ChannelHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.traccar.config.Keys; +import org.traccar.helper.model.AttributeUtil; import org.traccar.helper.model.PositionUtil; import org.traccar.model.Device; import org.traccar.model.Event; @@ -46,14 +48,12 @@ public class MotionEventHandler extends BaseEventHandler { private final CacheManager cacheManager; private final Storage storage; - private final TripsConfig tripsConfig; @Inject public MotionEventHandler( CacheManager cacheManager, Storage storage, TripsConfig tripsConfig) { this.cacheManager = cacheManager; this.storage = storage; - this.tripsConfig = tripsConfig; } @Override @@ -61,14 +61,16 @@ public class MotionEventHandler extends BaseEventHandler { long deviceId = position.getDeviceId(); Device device = cacheManager.getObject(Device.class, deviceId); - if (device == null) { + if (device == null || !PositionUtil.isLatest(cacheManager, position)) { return null; } - if (!PositionUtil.isLatest(cacheManager, position) - || !tripsConfig.getProcessInvalidPositions() && !position.getValid()) { + boolean processInvalid = AttributeUtil.lookup( + cacheManager, Keys.EVENT_MOTION_PROCESS_INVALID_POSITIONS, deviceId); + if (!processInvalid && !position.getValid()) { return null; } + TripsConfig tripsConfig = new TripsConfig(new AttributeUtil.CacheProvider(cacheManager, deviceId)); MotionState state = MotionState.fromDevice(device); MotionProcessor.updateState(state, position, position.getBoolean(Position.KEY_MOTION), tripsConfig); if (state.isChanged()) { |