diff options
author | Abyss777 <abyss@fox5.ru> | 2017-08-11 15:06:09 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-08-11 15:06:09 +0500 |
commit | 32a0fee0b092e488662ed29b7b7f1f303ae57e0f (patch) | |
tree | 8bfa422fd12567c1fd8cababe9b225a913492f7b /src/org/traccar/database | |
parent | 2e459d8d591ee9d3578a38d981e7c1c13eb3c389 (diff) | |
download | trackermap-server-32a0fee0b092e488662ed29b7b7f1f303ae57e0f.tar.gz trackermap-server-32a0fee0b092e488662ed29b7b7f1f303ae57e0f.tar.bz2 trackermap-server-32a0fee0b092e488662ed29b7b7f1f303ae57e0f.zip |
Make Overspeed and Motion events handlers singleton and move some code to function
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r-- | src/org/traccar/database/ConnectionManager.java | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/src/org/traccar/database/ConnectionManager.java b/src/org/traccar/database/ConnectionManager.java index b1dd1b726..7a0a6d30d 100644 --- a/src/org/traccar/database/ConnectionManager.java +++ b/src/org/traccar/database/ConnectionManager.java @@ -21,15 +21,12 @@ import org.jboss.netty.util.TimerTask; import org.traccar.Context; import org.traccar.GlobalTimer; import org.traccar.Protocol; -import org.traccar.events.MotionEventHandler; import org.traccar.events.OverspeedEventHandler; import org.traccar.helper.Log; import org.traccar.model.Device; import org.traccar.model.DeviceState; import org.traccar.model.Event; import org.traccar.model.Position; -import org.traccar.reports.ReportUtils; -import org.traccar.reports.model.TripsConfig; import java.net.SocketAddress; import java.sql.SQLException; @@ -47,9 +44,6 @@ public class ConnectionManager { private final long deviceTimeout; private final boolean enableStatusEvents; private final boolean updateDeviceState; - private TripsConfig tripsConfig = null; - private long minimalOverspeedDuration; - private boolean overspeedNotRepeat; private final Map<Long, ActiveDevice> activeDevices = new ConcurrentHashMap<>(); private final Map<Long, Set<UpdateListener>> listeners = new ConcurrentHashMap<>(); @@ -59,11 +53,6 @@ public class ConnectionManager { deviceTimeout = Context.getConfig().getLong("status.timeout", DEFAULT_TIMEOUT) * 1000; enableStatusEvents = Context.getConfig().getBoolean("event.enable"); updateDeviceState = Context.getConfig().getBoolean("status.updateDeviceState"); - if (updateDeviceState) { - tripsConfig = ReportUtils.initTripsConfig(); - minimalOverspeedDuration = Context.getConfig().getLong("event.overspeed.minimalDuration") * 1000; - overspeedNotRepeat = Context.getConfig().getBoolean("event.overspeed.notRepeat"); - } } public void addActiveDevice(long deviceId, Protocol protocol, Channel channel, SocketAddress remoteAddress) { @@ -150,14 +139,13 @@ public class ConnectionManager { DeviceState deviceState = Context.getDeviceManager().getDeviceState(deviceId); Set<Event> result = new HashSet<>(); - Event event = MotionEventHandler.updateMotionState(deviceState, tripsConfig); + Event event = Context.getMotionEventHandler().updateMotionState(deviceState); if (event != null) { result.add(event); } - event = OverspeedEventHandler.updateOverspeedState(deviceState, Context.getDeviceManager(). - lookupAttributeDouble(deviceId, OverspeedEventHandler.ATTRIBUTE_SPEED_LIMIT, 0, false), - minimalOverspeedDuration, overspeedNotRepeat); + event = Context.getOverspeedEventHandler().updateOverspeedState(deviceState, Context.getDeviceManager(). + lookupAttributeDouble(deviceId, OverspeedEventHandler.ATTRIBUTE_SPEED_LIMIT, 0, false)); if (event != null) { result.add(event); } |