From b19f1a505f7088ff48f467b32b5f1c207aa3be01 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 12 Jul 2017 14:22:03 +0500 Subject: - Handle rfid attributes and populate driverUniqueId - Add Driver Name to Trip report --- src/org/traccar/BasePipelineFactory.java | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/org/traccar/BasePipelineFactory.java') diff --git a/src/org/traccar/BasePipelineFactory.java b/src/org/traccar/BasePipelineFactory.java index a6446dbaa..9f0824b6c 100644 --- a/src/org/traccar/BasePipelineFactory.java +++ b/src/org/traccar/BasePipelineFactory.java @@ -40,6 +40,7 @@ import org.traccar.events.AlertEventHandler; import org.traccar.helper.Log; import org.traccar.processing.ComputedAttributesHandler; import org.traccar.processing.CopyAttributesHandler; +import org.traccar.processing.PopulateDriverHandler; import java.net.InetSocketAddress; @@ -54,6 +55,7 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory { private GeocoderHandler geocoderHandler; private GeolocationHandler geolocationHandler; private HemisphereHandler hemisphereHandler; + private PopulateDriverHandler populateDriverHandler; private CopyAttributesHandler copyAttributesHandler; private ComputedAttributesHandler computedAttributesHandler; @@ -152,6 +154,8 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory { hemisphereHandler = new HemisphereHandler(); } + populateDriverHandler = new PopulateDriverHandler(); + if (Context.getConfig().getBoolean("processing.copyAttributes.enable")) { copyAttributesHandler = new CopyAttributesHandler(); } @@ -214,6 +218,10 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory { pipeline.addLast("motion", motionHandler); } + if (populateDriverHandler != null) { + pipeline.addLast("populateDriver", populateDriverHandler); + } + if (copyAttributesHandler != null) { pipeline.addLast("copyAttributes", copyAttributesHandler); } -- cgit v1.2.3 From c13dce2dd0227f58135c1066461304bbdc551554 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 12 Jul 2017 16:40:55 +0500 Subject: Implement Driver Unauthorized Event --- src/org/traccar/BasePipelineFactory.java | 7 +++ src/org/traccar/events/DriverEventHandler.java | 59 ++++++++++++++++++++++++++ src/org/traccar/model/Event.java | 2 + 3 files changed, 68 insertions(+) create mode 100644 src/org/traccar/events/DriverEventHandler.java (limited to 'src/org/traccar/BasePipelineFactory.java') diff --git a/src/org/traccar/BasePipelineFactory.java b/src/org/traccar/BasePipelineFactory.java index 9f0824b6c..98a327220 100644 --- a/src/org/traccar/BasePipelineFactory.java +++ b/src/org/traccar/BasePipelineFactory.java @@ -30,6 +30,7 @@ import org.jboss.netty.channel.SimpleChannelHandler; import org.jboss.netty.handler.logging.LoggingHandler; import org.jboss.netty.handler.timeout.IdleStateHandler; import org.traccar.events.CommandResultEventHandler; +import org.traccar.events.DriverEventHandler; import org.traccar.events.FuelDropEventHandler; import org.traccar.events.GeofenceEventHandler; import org.traccar.events.IgnitionEventHandler; @@ -67,6 +68,7 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory { private AlertEventHandler alertEventHandler; private IgnitionEventHandler ignitionEventHandler; private MaintenanceEventHandler maintenanceEventHandler; + private DriverEventHandler driverEventHandler; private static final class OpenChannelHandler extends SimpleChannelHandler { @@ -173,6 +175,7 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory { alertEventHandler = new AlertEventHandler(); ignitionEventHandler = new IgnitionEventHandler(); maintenanceEventHandler = new MaintenanceEventHandler(); + driverEventHandler = new DriverEventHandler(); } } @@ -270,6 +273,10 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory { pipeline.addLast("MaintenanceEventHandler", maintenanceEventHandler); } + if (driverEventHandler != null) { + pipeline.addLast("DriverEventHandler", driverEventHandler); + } + pipeline.addLast("mainHandler", new MainEventHandler()); return pipeline; } diff --git a/src/org/traccar/events/DriverEventHandler.java b/src/org/traccar/events/DriverEventHandler.java new file mode 100644 index 000000000..9109373c7 --- /dev/null +++ b/src/org/traccar/events/DriverEventHandler.java @@ -0,0 +1,59 @@ +/* + * Copyright 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.traccar.events; + +import java.util.Collection; +import java.util.Collections; + +import org.traccar.BaseEventHandler; +import org.traccar.Context; +import org.traccar.model.Event; +import org.traccar.model.Position; + +public class DriverEventHandler extends BaseEventHandler { + + private boolean notRepeat; + + public DriverEventHandler() { + notRepeat = Context.getConfig().getBoolean("event.driver.notRepeat"); + } + + @Override + protected Collection analyzePosition(Position position) { + if (!Context.getIdentityManager().isLatestPosition(position)) { + return null; + } + String driverUniqueId = position.getString(Position.KEY_DRIVER_UNIQUE_ID); + if (driverUniqueId != null) { + String oldDriverUniqueId = null; + if (notRepeat) { + Position lastPosition = Context.getIdentityManager().getLastPosition(position.getDeviceId()); + if (lastPosition != null) { + oldDriverUniqueId = lastPosition.getString(Position.KEY_DRIVER_UNIQUE_ID); + } + } + if (!driverUniqueId.equals(oldDriverUniqueId) + && !Context.getDriversManager().authorizeDriverByUniqueId(driverUniqueId, position.getDeviceId())) { + Event event = new Event(Event.TYPE_DRIVER_UNAUTHORIZED, position.getDeviceId(), position.getId()); + event.set(Position.KEY_DRIVER_UNIQUE_ID, driverUniqueId); + return Collections.singleton(event); + } + } + return null; + } + +} diff --git a/src/org/traccar/model/Event.java b/src/org/traccar/model/Event.java index 6a24d91c6..dd5358f75 100644 --- a/src/org/traccar/model/Event.java +++ b/src/org/traccar/model/Event.java @@ -61,6 +61,8 @@ public class Event extends Message { public static final String TYPE_TEXT_MESSAGE = "textMessage"; + public static final String TYPE_DRIVER_UNAUTHORIZED = "driverUnauthorized"; + private Date serverTime; public Date getServerTime() { -- cgit v1.2.3 From eee59141bd21d929467819a8eb6c904140efceaa Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 13 Jul 2017 02:47:03 +1200 Subject: Fix max speed filtering (fix #3342) --- src/org/traccar/BasePipelineFactory.java | 3 ++- src/org/traccar/FilterHandler.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src/org/traccar/BasePipelineFactory.java') diff --git a/src/org/traccar/BasePipelineFactory.java b/src/org/traccar/BasePipelineFactory.java index a6446dbaa..bde4b558b 100644 --- a/src/org/traccar/BasePipelineFactory.java +++ b/src/org/traccar/BasePipelineFactory.java @@ -125,7 +125,8 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory { } } - distanceHandler = new DistanceHandler(Context.getConfig().getBoolean("coordinates.filter"), + distanceHandler = new DistanceHandler( + Context.getConfig().getBoolean("coordinates.filter"), Context.getConfig().getInteger("coordinates.minError"), Context.getConfig().getInteger("coordinates.maxError")); diff --git a/src/org/traccar/FilterHandler.java b/src/org/traccar/FilterHandler.java index 9e532347d..71c0a1cf5 100644 --- a/src/org/traccar/FilterHandler.java +++ b/src/org/traccar/FilterHandler.java @@ -127,7 +127,7 @@ public class FilterHandler extends BaseDataHandler { if (filterMaxSpeed != 0 && last != null) { double distance = position.getDouble(Position.KEY_DISTANCE); long time = position.getFixTime().getTime() - last.getFixTime().getTime(); - return UnitsConverter.knotsFromMps(distance / time) > filterMaxSpeed; + return UnitsConverter.knotsFromMps(distance / (time / 1000)) > filterMaxSpeed; } return false; } -- cgit v1.2.3 From 44691a373200b0e265df5a24e159f5cdff89fb96 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Fri, 14 Jul 2017 10:56:20 +0500 Subject: Populate driverUniqueId in CopyAttributesHanler --- src/org/traccar/BasePipelineFactory.java | 8 ---- .../traccar/processing/CopyAttributesHandler.java | 1 + .../traccar/processing/PopulateDriverHandler.java | 45 ---------------------- .../org/traccar/processing/PopulateDriverTest.java | 21 ---------- 4 files changed, 1 insertion(+), 74 deletions(-) delete mode 100644 src/org/traccar/processing/PopulateDriverHandler.java delete mode 100644 test/org/traccar/processing/PopulateDriverTest.java (limited to 'src/org/traccar/BasePipelineFactory.java') diff --git a/src/org/traccar/BasePipelineFactory.java b/src/org/traccar/BasePipelineFactory.java index 98a327220..edbebc9e2 100644 --- a/src/org/traccar/BasePipelineFactory.java +++ b/src/org/traccar/BasePipelineFactory.java @@ -41,7 +41,6 @@ import org.traccar.events.AlertEventHandler; import org.traccar.helper.Log; import org.traccar.processing.ComputedAttributesHandler; import org.traccar.processing.CopyAttributesHandler; -import org.traccar.processing.PopulateDriverHandler; import java.net.InetSocketAddress; @@ -56,7 +55,6 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory { private GeocoderHandler geocoderHandler; private GeolocationHandler geolocationHandler; private HemisphereHandler hemisphereHandler; - private PopulateDriverHandler populateDriverHandler; private CopyAttributesHandler copyAttributesHandler; private ComputedAttributesHandler computedAttributesHandler; @@ -156,8 +154,6 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory { hemisphereHandler = new HemisphereHandler(); } - populateDriverHandler = new PopulateDriverHandler(); - if (Context.getConfig().getBoolean("processing.copyAttributes.enable")) { copyAttributesHandler = new CopyAttributesHandler(); } @@ -221,10 +217,6 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory { pipeline.addLast("motion", motionHandler); } - if (populateDriverHandler != null) { - pipeline.addLast("populateDriver", populateDriverHandler); - } - if (copyAttributesHandler != null) { pipeline.addLast("copyAttributes", copyAttributesHandler); } diff --git a/src/org/traccar/processing/CopyAttributesHandler.java b/src/org/traccar/processing/CopyAttributesHandler.java index 3a96ca98d..a9e761c3d 100644 --- a/src/org/traccar/processing/CopyAttributesHandler.java +++ b/src/org/traccar/processing/CopyAttributesHandler.java @@ -35,6 +35,7 @@ public class CopyAttributesHandler extends BaseDataHandler { position.getDeviceId(), "processing.copyAttributes", null, true); Position last = getLastPosition(position.getDeviceId()); if (attributesString != null && last != null) { + attributesString += Position.KEY_DRIVER_UNIQUE_ID + ","; for (String attribute : attributesString.split("[ ,]")) { if (last.getAttributes().containsKey(attribute) && !position.getAttributes().containsKey(attribute)) { position.getAttributes().put(attribute, last.getAttributes().get(attribute)); diff --git a/src/org/traccar/processing/PopulateDriverHandler.java b/src/org/traccar/processing/PopulateDriverHandler.java deleted file mode 100644 index 339cc5548..000000000 --- a/src/org/traccar/processing/PopulateDriverHandler.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2017 Anton Tananaev (anton@traccar.org) - * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.traccar.processing; - -import org.traccar.BaseDataHandler; -import org.traccar.Context; -import org.traccar.model.Position; - -public class PopulateDriverHandler extends BaseDataHandler { - - private Position getLastPosition(long deviceId) { - if (Context.getIdentityManager() != null) { - return Context.getIdentityManager().getLastPosition(deviceId); - } - return null; - } - - @Override - protected Position handlePosition(Position position) { - if (position.getAttributes().containsKey(Position.KEY_RFID)) { - position.set(Position.KEY_DRIVER_UNIQUE_ID, position.getString(Position.KEY_RFID)); - } else { - Position last = getLastPosition(position.getDeviceId()); - if (last != null && last.getAttributes().containsKey(Position.KEY_DRIVER_UNIQUE_ID)) { - position.set(Position.KEY_DRIVER_UNIQUE_ID, last.getString(Position.KEY_DRIVER_UNIQUE_ID)); - } - } - return position; - } - -} diff --git a/test/org/traccar/processing/PopulateDriverTest.java b/test/org/traccar/processing/PopulateDriverTest.java deleted file mode 100644 index 7c6ee9f06..000000000 --- a/test/org/traccar/processing/PopulateDriverTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.traccar.processing; - -import org.junit.Assert; -import org.junit.Test; -import org.traccar.model.Position; - -public class PopulateDriverTest { - - @Test - public void testPopulateDriver() { - Position position = new Position(); - PopulateDriverHandler populateDriverHandler = new PopulateDriverHandler(); - Assert.assertNull(populateDriverHandler.handlePosition(position).getString(Position.KEY_DRIVER_UNIQUE_ID)); - position.set(Position.KEY_DRIVER_UNIQUE_ID, "123"); - Assert.assertEquals("123", - populateDriverHandler.handlePosition(position).getString(Position.KEY_DRIVER_UNIQUE_ID)); - position.set(Position.KEY_RFID, "321"); - Assert.assertEquals("321", - populateDriverHandler.handlePosition(position).getString(Position.KEY_DRIVER_UNIQUE_ID)); - } -} -- cgit v1.2.3 From 32a0fee0b092e488662ed29b7b7f1f303ae57e0f Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Fri, 11 Aug 2017 15:06:09 +0500 Subject: Make Overspeed and Motion events handlers singleton and move some code to function --- src/org/traccar/BasePipelineFactory.java | 4 +-- src/org/traccar/Context.java | 20 +++++++++++ src/org/traccar/database/ConnectionManager.java | 18 ++-------- src/org/traccar/events/MotionEventHandler.java | 34 +++++++++--------- src/org/traccar/events/OverspeedEventHandler.java | 40 ++++++++++------------ .../org/traccar/events/MotionEventHandlerTest.java | 14 ++++---- .../traccar/events/OverspeedEventHandlerTest.java | 17 +++++---- 7 files changed, 79 insertions(+), 68 deletions(-) (limited to 'src/org/traccar/BasePipelineFactory.java') diff --git a/src/org/traccar/BasePipelineFactory.java b/src/org/traccar/BasePipelineFactory.java index b368c800d..da8060071 100644 --- a/src/org/traccar/BasePipelineFactory.java +++ b/src/org/traccar/BasePipelineFactory.java @@ -165,9 +165,9 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory { if (Context.getConfig().getBoolean("event.enable")) { commandResultEventHandler = new CommandResultEventHandler(); - overspeedEventHandler = new OverspeedEventHandler(); + overspeedEventHandler = Context.getOverspeedEventHandler(); fuelDropEventHandler = new FuelDropEventHandler(); - motionEventHandler = new MotionEventHandler(); + motionEventHandler = Context.getMotionEventHandler(); geofenceEventHandler = new GeofenceEventHandler(); alertEventHandler = new AlertEventHandler(); ignitionEventHandler = new IgnitionEventHandler(); diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java index 306a37e83..4bcc1468b 100644 --- a/src/org/traccar/Context.java +++ b/src/org/traccar/Context.java @@ -41,6 +41,8 @@ import org.traccar.database.GeofenceManager; import org.traccar.database.GroupsManager; import org.traccar.database.StatisticsManager; import org.traccar.database.UsersManager; +import org.traccar.events.MotionEventHandler; +import org.traccar.events.OverspeedEventHandler; import org.traccar.geocoder.BingMapsGeocoder; import org.traccar.geocoder.FactualGeocoder; import org.traccar.geocoder.GeocodeFarmGeocoder; @@ -65,6 +67,7 @@ import org.traccar.geolocation.GeolocationProvider; import org.traccar.geolocation.MozillaGeolocationProvider; import org.traccar.geolocation.OpenCellIdGeolocationProvider; import org.traccar.notification.EventForwarder; +import org.traccar.reports.ReportUtils; import org.traccar.smpp.SmppClient; import org.traccar.web.WebServer; @@ -229,6 +232,18 @@ public final class Context { return smppClient; } + private static MotionEventHandler motionEventHandler; + + public static MotionEventHandler getMotionEventHandler() { + return motionEventHandler; + } + + private static OverspeedEventHandler overspeedEventHandler; + + public static OverspeedEventHandler getOverspeedEventHandler() { + return overspeedEventHandler; + } + public static void init(String[] arguments) throws Exception { config = new Config(); @@ -350,6 +365,11 @@ public final class Context { velocityEngine = new VelocityEngine(); velocityEngine.init(velocityProperties); + + motionEventHandler = new MotionEventHandler(ReportUtils.initTripsConfig()); + overspeedEventHandler = new OverspeedEventHandler( + Context.getConfig().getLong("event.overspeed.minimalDuration") * 1000, + Context.getConfig().getBoolean("event.overspeed.notRepeat")); } serverManager = new ServerManager(); 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 activeDevices = new ConcurrentHashMap<>(); private final Map> 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 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); } diff --git a/src/org/traccar/events/MotionEventHandler.java b/src/org/traccar/events/MotionEventHandler.java index 1a8cb0ef8..b20a11999 100644 --- a/src/org/traccar/events/MotionEventHandler.java +++ b/src/org/traccar/events/MotionEventHandler.java @@ -32,11 +32,20 @@ public class MotionEventHandler extends BaseEventHandler { private TripsConfig tripsConfig; - public MotionEventHandler() { - tripsConfig = ReportUtils.initTripsConfig(); + public MotionEventHandler(TripsConfig tripsConfig) { + this.tripsConfig = tripsConfig; } - public static Event updateMotionState(DeviceState deviceState, TripsConfig tripsConfig) { + private Event newEvent(DeviceState deviceState, boolean newMotion) { + String eventType = newMotion ? Event.TYPE_DEVICE_MOVING : Event.TYPE_DEVICE_STOPPED; + Event event = new Event(eventType, deviceState.getMotionPosition().getDeviceId(), + deviceState.getMotionPosition().getId()); + deviceState.setMotionState(newMotion); + deviceState.setMotionPosition(null); + return event; + } + + public Event updateMotionState(DeviceState deviceState) { Event result = null; if (deviceState.getMotionState() != null && deviceState.getMotionPosition() != null) { boolean newMotion = !deviceState.getMotionState(); @@ -45,16 +54,13 @@ public class MotionEventHandler extends BaseEventHandler { long motionTime = motionPosition.getFixTime().getTime() + (newMotion ? tripsConfig.getMinimalTripDuration() : tripsConfig.getMinimalParkingDuration()); if (motionTime <= currentTime) { - String eventType = newMotion ? Event.TYPE_DEVICE_MOVING : Event.TYPE_DEVICE_STOPPED; - result = new Event(eventType, motionPosition.getDeviceId(), motionPosition.getId()); - deviceState.setMotionState(newMotion); - deviceState.setMotionPosition(null); + result = newEvent(deviceState, newMotion); } } return result; } - public static Event updateMotionState(DeviceState deviceState, Position position, TripsConfig tripsConfig) { + public Event updateMotionState(DeviceState deviceState, Position position) { Event result = null; Boolean oldMotion = deviceState.getMotionState(); @@ -75,17 +81,11 @@ public class MotionEventHandler extends BaseEventHandler { if (newMotion) { if (motionTime + tripsConfig.getMinimalTripDuration() <= currentTime || distance >= tripsConfig.getMinimalTripDistance()) { - result = new Event(Event.TYPE_DEVICE_MOVING, motionPosition.getDeviceId(), - motionPosition.getId()); - deviceState.setMotionState(true); - deviceState.setMotionPosition(null); + result = newEvent(deviceState, newMotion); } } else { if (motionTime + tripsConfig.getMinimalParkingDuration() <= currentTime) { - result = new Event(Event.TYPE_DEVICE_STOPPED, motionPosition.getDeviceId(), - motionPosition.getId()); - deviceState.setMotionState(false); - deviceState.setMotionPosition(null); + result = newEvent(deviceState, newMotion); } } } @@ -110,7 +110,7 @@ public class MotionEventHandler extends BaseEventHandler { if (deviceState.getMotionState() == null) { deviceState.setMotionState(position.getBoolean(Position.KEY_MOTION)); } else { - result = updateMotionState(deviceState, position, tripsConfig); + result = updateMotionState(deviceState, position); } Context.getDeviceManager().setDeviceState(deviceId, deviceState); if (result != null) { diff --git a/src/org/traccar/events/OverspeedEventHandler.java b/src/org/traccar/events/OverspeedEventHandler.java index f0bf8a032..953af6b33 100644 --- a/src/org/traccar/events/OverspeedEventHandler.java +++ b/src/org/traccar/events/OverspeedEventHandler.java @@ -32,13 +32,22 @@ public class OverspeedEventHandler extends BaseEventHandler { private boolean notRepeat; private long minimalDuration; - public OverspeedEventHandler() { - notRepeat = Context.getConfig().getBoolean("event.overspeed.notRepeat"); - minimalDuration = Context.getConfig().getLong("event.overspeed.minimalDuration") * 1000; + public OverspeedEventHandler(long minimalDuration, boolean notRepeat) { + this.notRepeat = notRepeat; + this.minimalDuration = minimalDuration; } - public static Event updateOverspeedState(DeviceState deviceState, double speedLimit, - long minimalDuration, boolean notRepeat) { + private Event newEvent(DeviceState deviceState, double speedLimit) { + Event event = new Event(Event.TYPE_DEVICE_OVERSPEED, deviceState.getOverspeedPosition().getDeviceId(), + deviceState.getOverspeedPosition().getId()); + event.set("speed", deviceState.getOverspeedPosition().getSpeed()); + event.set(ATTRIBUTE_SPEED_LIMIT, speedLimit); + deviceState.setOverspeedState(notRepeat); + deviceState.setOverspeedPosition(null); + return event; + } + + public Event updateOverspeedState(DeviceState deviceState, double speedLimit) { Event result = null; if (deviceState.getOverspeedState() != null && !deviceState.getOverspeedState() && deviceState.getOverspeedPosition() != null && speedLimit != 0) { @@ -46,19 +55,13 @@ public class OverspeedEventHandler extends BaseEventHandler { Position overspeedPosition = deviceState.getOverspeedPosition(); long overspeedTime = overspeedPosition.getFixTime().getTime(); if (overspeedTime + minimalDuration <= currentTime) { - result = new Event(Event.TYPE_DEVICE_OVERSPEED, overspeedPosition.getDeviceId(), - overspeedPosition.getId()); - result.set("speed", overspeedPosition.getSpeed()); - result.set(ATTRIBUTE_SPEED_LIMIT, speedLimit); - deviceState.setOverspeedState(notRepeat); - deviceState.setOverspeedPosition(null); + result = newEvent(deviceState, speedLimit); } } return result; } - public static Event updateOverspeedState(DeviceState deviceState, Position position, double speedLimit, - long minimalOverspeedDuration, boolean notRepeat) { + public Event updateOverspeedState(DeviceState deviceState, Position position, double speedLimit) { Event result = null; Boolean oldOverspeed = deviceState.getOverspeedState(); @@ -78,13 +81,8 @@ public class OverspeedEventHandler extends BaseEventHandler { Position overspeedPosition = deviceState.getOverspeedPosition(); if (overspeedPosition != null) { long overspeedTime = overspeedPosition.getFixTime().getTime(); - if (newOverspeed && overspeedTime + minimalOverspeedDuration <= currentTime) { - result = new Event(Event.TYPE_DEVICE_OVERSPEED, overspeedPosition.getDeviceId(), - overspeedPosition.getId()); - result.set("speed", overspeedPosition.getSpeed()); - result.set(ATTRIBUTE_SPEED_LIMIT, speedLimit); - deviceState.setOverspeedState(notRepeat); - deviceState.setOverspeedPosition(null); + if (newOverspeed && overspeedTime + minimalDuration <= currentTime) { + result = newEvent(deviceState, speedLimit); } } return result; @@ -113,7 +111,7 @@ public class OverspeedEventHandler extends BaseEventHandler { if (deviceState.getOverspeedState() == null) { deviceState.setOverspeedState(position.getSpeed() > speedLimit); } else { - result = updateOverspeedState(deviceState, position, speedLimit, minimalDuration, notRepeat); + result = updateOverspeedState(deviceState, position, speedLimit); } Context.getDeviceManager().setDeviceState(deviceId, deviceState); diff --git a/test/org/traccar/events/MotionEventHandlerTest.java b/test/org/traccar/events/MotionEventHandlerTest.java index 9df573244..6b7b9daee 100644 --- a/test/org/traccar/events/MotionEventHandlerTest.java +++ b/test/org/traccar/events/MotionEventHandlerTest.java @@ -28,7 +28,8 @@ public class MotionEventHandlerTest extends BaseTest { @Test public void testMotionWithPosition() throws Exception { - TripsConfig tripsConfig = new TripsConfig(500, 300 * 1000, 300 * 1000, false, 0); + MotionEventHandler motionEventHandler = new MotionEventHandler( + new TripsConfig(500, 300 * 1000, 300 * 1000, false, 0)); Position position = new Position(); position.setTime(date("2017-01-01 00:00:00")); @@ -43,11 +44,11 @@ public class MotionEventHandlerTest extends BaseTest { nextPosition.set(Position.KEY_MOTION, true); nextPosition.set(Position.KEY_TOTAL_DISTANCE, 200); - Event event = MotionEventHandler.updateMotionState(deviceState, nextPosition, tripsConfig); + Event event = motionEventHandler.updateMotionState(deviceState, nextPosition); assertNull(event); nextPosition.set(Position.KEY_TOTAL_DISTANCE, 600); - event = MotionEventHandler.updateMotionState(deviceState, nextPosition, tripsConfig); + event = motionEventHandler.updateMotionState(deviceState, nextPosition); assertNotNull(event); assertEquals(Event.TYPE_DEVICE_MOVING, event.getType()); assertTrue(deviceState.getMotionState()); @@ -57,7 +58,7 @@ public class MotionEventHandlerTest extends BaseTest { deviceState.setMotionPosition(position); nextPosition.setTime(date("2017-01-01 00:06:00")); nextPosition.set(Position.KEY_TOTAL_DISTANCE, 200); - event = MotionEventHandler.updateMotionState(deviceState, nextPosition, tripsConfig); + event = motionEventHandler.updateMotionState(deviceState, nextPosition); assertNotNull(event); assertEquals(Event.TYPE_DEVICE_MOVING, event.getType()); assertTrue(deviceState.getMotionState()); @@ -66,7 +67,8 @@ public class MotionEventHandlerTest extends BaseTest { @Test public void testMotionWithStatus() throws Exception { - TripsConfig tripsConfig = new TripsConfig(500, 300 * 1000, 300 * 1000, false, 0); + MotionEventHandler motionEventHandler = new MotionEventHandler( + new TripsConfig(500, 300 * 1000, 300 * 1000, false, 0)); Position position = new Position(); position.setTime(new Date(System.currentTimeMillis() - 360000)); @@ -75,7 +77,7 @@ public class MotionEventHandlerTest extends BaseTest { deviceState.setMotionState(false); deviceState.setMotionPosition(position); - Event event = MotionEventHandler.updateMotionState(deviceState, tripsConfig); + Event event = motionEventHandler.updateMotionState(deviceState); assertNotNull(event); assertEquals(Event.TYPE_DEVICE_MOVING, event.getType()); diff --git a/test/org/traccar/events/OverspeedEventHandlerTest.java b/test/org/traccar/events/OverspeedEventHandlerTest.java index eae0917c0..48d7445ff 100644 --- a/test/org/traccar/events/OverspeedEventHandlerTest.java +++ b/test/org/traccar/events/OverspeedEventHandlerTest.java @@ -26,13 +26,15 @@ public class OverspeedEventHandlerTest extends BaseTest { } private void testOverspeedWithPosition(boolean notRepeat) throws Exception { + OverspeedEventHandler overspeedEventHandler = new OverspeedEventHandler(15000, notRepeat); + Position position = new Position(); position.setTime(date("2017-01-01 00:00:00")); position.setSpeed(50); DeviceState deviceState = new DeviceState(); deviceState.setOverspeedState(false); - Event event = OverspeedEventHandler.updateOverspeedState(deviceState, position, 40, 15000, notRepeat); + Event event = overspeedEventHandler.updateOverspeedState(deviceState, position, 40); assertNull(event); assertFalse(deviceState.getOverspeedState()); assertEquals(position, deviceState.getOverspeedPosition()); @@ -41,12 +43,12 @@ public class OverspeedEventHandlerTest extends BaseTest { nextPosition.setTime(date("2017-01-01 00:00:10")); nextPosition.setSpeed(55); - event = OverspeedEventHandler.updateOverspeedState(deviceState, nextPosition, 40, 15000, notRepeat); + event = overspeedEventHandler.updateOverspeedState(deviceState, nextPosition, 40); assertNull(event); nextPosition.setTime(date("2017-01-01 00:00:20")); - event = OverspeedEventHandler.updateOverspeedState(deviceState, nextPosition, 40, 15000, notRepeat); + event = overspeedEventHandler.updateOverspeedState(deviceState, nextPosition, 40); assertNotNull(event); assertEquals(Event.TYPE_DEVICE_OVERSPEED, event.getType()); assertEquals(50, event.getDouble("speed"), 0.1); @@ -56,7 +58,7 @@ public class OverspeedEventHandlerTest extends BaseTest { assertNull(deviceState.getOverspeedPosition()); nextPosition.setTime(date("2017-01-01 00:00:30")); - event = OverspeedEventHandler.updateOverspeedState(deviceState, nextPosition, 40, 15000, notRepeat); + event = overspeedEventHandler.updateOverspeedState(deviceState, nextPosition, 40); assertNull(event); assertEquals(notRepeat, deviceState.getOverspeedState()); @@ -69,13 +71,15 @@ public class OverspeedEventHandlerTest extends BaseTest { nextPosition.setTime(date("2017-01-01 00:00:40")); nextPosition.setSpeed(30); - event = OverspeedEventHandler.updateOverspeedState(deviceState, nextPosition, 40, 15000, notRepeat); + event = overspeedEventHandler.updateOverspeedState(deviceState, nextPosition, 40); assertNull(event); assertFalse(deviceState.getOverspeedState()); assertNull(deviceState.getOverspeedPosition()); } private void testOverspeedWithStatus(boolean notRepeat) throws Exception { + OverspeedEventHandler overspeedEventHandler = new OverspeedEventHandler(15000, notRepeat); + Position position = new Position(); position.setTime(new Date(System.currentTimeMillis() - 30000)); position.setSpeed(50); @@ -83,12 +87,11 @@ public class OverspeedEventHandlerTest extends BaseTest { deviceState.setOverspeedState(false); deviceState.setOverspeedPosition(position); - Event event = OverspeedEventHandler.updateOverspeedState(deviceState, 40, 15000, notRepeat); + Event event = overspeedEventHandler.updateOverspeedState(deviceState, 40); assertNotNull(event); assertEquals(Event.TYPE_DEVICE_OVERSPEED, event.getType()); assertEquals(notRepeat, deviceState.getOverspeedState()); - } @Test -- cgit v1.2.3 From 901bcf5da82eb7d1370856ceb732397e8ef4c670 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 21 Aug 2017 00:32:38 +1200 Subject: Do not save IP by default --- src/org/traccar/BasePipelineFactory.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/org/traccar/BasePipelineFactory.java') diff --git a/src/org/traccar/BasePipelineFactory.java b/src/org/traccar/BasePipelineFactory.java index da8060071..ac1d450c5 100644 --- a/src/org/traccar/BasePipelineFactory.java +++ b/src/org/traccar/BasePipelineFactory.java @@ -51,6 +51,7 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory { private FilterHandler filterHandler; private DistanceHandler distanceHandler; + private RemoteAddressHandler remoteAddressHandler; private MotionHandler motionHandler; private GeocoderHandler geocoderHandler; private GeolocationHandler geolocationHandler; @@ -132,6 +133,10 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory { Context.getConfig().getInteger("coordinates.minError"), Context.getConfig().getInteger("coordinates.maxError")); + if (Context.getConfig().getBoolean("processing.remoteAddress.enable")) { + remoteAddressHandler = new RemoteAddressHandler(); + } + if (Context.getConfig().getBoolean("filter.enable")) { filterHandler = new FilterHandler(); } @@ -202,7 +207,9 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory { pipeline.addLast("distance", distanceHandler); } - pipeline.addLast("remoteAddress", new RemoteAddressHandler()); + if (remoteAddressHandler != null) { + pipeline.addLast("remoteAddress", remoteAddressHandler); + } addDynamicHandlers(pipeline); -- cgit v1.2.3 From 36ad4ac525b8eb25ac1c2eed8c05d690754399c5 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Thu, 21 Sep 2017 18:01:10 +0500 Subject: Move speedThreshold to TripsConfig --- src/org/traccar/BasePipelineFactory.java | 2 +- src/org/traccar/Context.java | 3 +- src/org/traccar/reports/ReportUtils.java | 11 +++--- src/org/traccar/reports/Stops.java | 4 +-- src/org/traccar/reports/Trips.java | 4 +-- src/org/traccar/reports/model/TripsConfig.java | 13 ++++++- .../org/traccar/events/MotionEventHandlerTest.java | 6 ++-- test/org/traccar/reports/ReportUtilsTest.java | 42 +++++++++++----------- 8 files changed, 46 insertions(+), 39 deletions(-) (limited to 'src/org/traccar/BasePipelineFactory.java') diff --git a/src/org/traccar/BasePipelineFactory.java b/src/org/traccar/BasePipelineFactory.java index ac1d450c5..771ab8acb 100644 --- a/src/org/traccar/BasePipelineFactory.java +++ b/src/org/traccar/BasePipelineFactory.java @@ -153,7 +153,7 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory { Context.getConfig().getBoolean("geolocation.processInvalidPositions")); } - motionHandler = new MotionHandler(Context.getConfig().getDouble("event.motion.speedThreshold", 0.01)); + motionHandler = new MotionHandler(Context.getTripsConfig().getSpeedThreshold()); if (Context.getConfig().hasKey("location.latitudeHemisphere") || Context.getConfig().hasKey("location.longitudeHemisphere")) { diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java index cf857178f..3b24c6460 100644 --- a/src/org/traccar/Context.java +++ b/src/org/traccar/Context.java @@ -259,7 +259,8 @@ public final class Context { config.getLong("report.trip.minimalParkingDuration", 300) * 1000, config.getLong("report.trip.minimalNoDataDuration", 3600) * 1000, config.getBoolean("report.trip.useIgnition"), - config.getBoolean("event.motion.processInvalidPositions")); + config.getBoolean("event.motion.processInvalidPositions"), + config.getDouble("event.motion.speedThreshold", 0.01)); } public static void init(String[] arguments) throws Exception { diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java index 5f718feac..f6f386e99 100644 --- a/src/org/traccar/reports/ReportUtils.java +++ b/src/org/traccar/reports/ReportUtils.java @@ -253,8 +253,7 @@ public final class ReportUtils { } } - private static boolean isMoving(ArrayList positions, int index, - TripsConfig tripsConfig, double speedThreshold) { + private static boolean isMoving(ArrayList positions, int index, TripsConfig tripsConfig) { if (tripsConfig.getMinimalNoDataDuration() > 0) { boolean beforeGap = index < positions.size() - 1 && positions.get(index + 1).getFixTime().getTime() - positions.get(index).getFixTime().getTime() @@ -270,12 +269,12 @@ public final class ReportUtils { && positions.get(index).getAttributes().get(Position.KEY_MOTION) instanceof Boolean) { return positions.get(index).getBoolean(Position.KEY_MOTION); } else { - return positions.get(index).getSpeed() > speedThreshold; + return positions.get(index).getSpeed() > tripsConfig.getSpeedThreshold(); } } public static Collection detectTripsAndStops(Collection positionCollection, - TripsConfig tripsConfig, boolean ignoreOdometer, double speedThreshold, Class reportClass) { + TripsConfig tripsConfig, boolean ignoreOdometer, Class reportClass) { Collection result = new ArrayList<>(); ArrayList positions = new ArrayList<>(positionCollection); @@ -283,12 +282,12 @@ public final class ReportUtils { boolean trips = reportClass.equals(TripReport.class); MotionEventHandler motionHandler = new MotionEventHandler(tripsConfig); DeviceState deviceState = new DeviceState(); - deviceState.setMotionState(isMoving(positions, 0, tripsConfig, speedThreshold)); + deviceState.setMotionState(isMoving(positions, 0, tripsConfig)); int startEventIndex = trips == deviceState.getMotionState() ? 0 : -1; int startNoEventIndex = -1; for (int i = 0; i < positions.size(); i++) { Map event = motionHandler.updateMotionState(deviceState, positions.get(i), - isMoving(positions, i, tripsConfig, speedThreshold)); + isMoving(positions, i, tripsConfig)); if (startEventIndex == -1 && (trips != deviceState.getMotionState() && deviceState.getMotionPosition() != null || trips == deviceState.getMotionState() && event != null)) { diff --git a/src/org/traccar/reports/Stops.java b/src/org/traccar/reports/Stops.java index 1e72cc927..14b3a2437 100644 --- a/src/org/traccar/reports/Stops.java +++ b/src/org/traccar/reports/Stops.java @@ -39,14 +39,12 @@ public final class Stops { } private static Collection detectStops(long deviceId, Date from, Date to) throws SQLException { - double speedThreshold = Context.getConfig().getDouble("event.motion.speedThreshold", 0.01); - boolean ignoreOdometer = Context.getDeviceManager() .lookupAttributeBoolean(deviceId, "report.ignoreOdometer", false, true); Collection result = ReportUtils.detectTripsAndStops( Context.getDataManager().getPositions(deviceId, from, to), - Context.getTripsConfig(), ignoreOdometer, speedThreshold, StopReport.class); + Context.getTripsConfig(), ignoreOdometer, StopReport.class); return result; } diff --git a/src/org/traccar/reports/Trips.java b/src/org/traccar/reports/Trips.java index 1ee62e87c..696defa94 100644 --- a/src/org/traccar/reports/Trips.java +++ b/src/org/traccar/reports/Trips.java @@ -38,14 +38,12 @@ public final class Trips { } private static Collection detectTrips(long deviceId, Date from, Date to) throws SQLException { - double speedThreshold = Context.getConfig().getDouble("event.motion.speedThreshold", 0.01); - boolean ignoreOdometer = Context.getDeviceManager() .lookupAttributeBoolean(deviceId, "report.ignoreOdometer", false, true); Collection result = ReportUtils.detectTripsAndStops( Context.getDataManager().getPositions(deviceId, from, to), - Context.getTripsConfig(), ignoreOdometer, speedThreshold, TripReport.class); + Context.getTripsConfig(), ignoreOdometer, TripReport.class); return result; } diff --git a/src/org/traccar/reports/model/TripsConfig.java b/src/org/traccar/reports/model/TripsConfig.java index ca361a466..0f0c615d3 100644 --- a/src/org/traccar/reports/model/TripsConfig.java +++ b/src/org/traccar/reports/model/TripsConfig.java @@ -22,13 +22,14 @@ public class TripsConfig { } public TripsConfig(double minimalTripDistance, long minimalTripDuration, long minimalParkingDuration, - long minimalNoDataDuration, boolean useIgnition, boolean processInvalidPositions) { + long minimalNoDataDuration, boolean useIgnition, boolean processInvalidPositions, double speedThreshold) { this.minimalTripDistance = minimalTripDistance; this.minimalTripDuration = minimalTripDuration; this.minimalParkingDuration = minimalParkingDuration; this.minimalNoDataDuration = minimalNoDataDuration; this.useIgnition = useIgnition; this.processInvalidPositions = processInvalidPositions; + this.speedThreshold = speedThreshold; } private double minimalTripDistance; @@ -91,4 +92,14 @@ public class TripsConfig { this.processInvalidPositions = processInvalidPositions; } + private double speedThreshold; + + public double getSpeedThreshold() { + return speedThreshold; + } + + public void setSpeedThreshold(double speedThreshold) { + this.speedThreshold = speedThreshold; + } + } diff --git a/test/org/traccar/events/MotionEventHandlerTest.java b/test/org/traccar/events/MotionEventHandlerTest.java index a2e5cf651..3fc63adf0 100644 --- a/test/org/traccar/events/MotionEventHandlerTest.java +++ b/test/org/traccar/events/MotionEventHandlerTest.java @@ -31,7 +31,7 @@ public class MotionEventHandlerTest extends BaseTest { @Test public void testMotionWithPosition() throws Exception { MotionEventHandler motionEventHandler = new MotionEventHandler( - new TripsConfig(500, 300 * 1000, 300 * 1000, 0, false, false)); + new TripsConfig(500, 300 * 1000, 300 * 1000, 0, false, false, 0.01)); Position position = new Position(); position.setTime(date("2017-01-01 00:00:00")); @@ -72,7 +72,7 @@ public class MotionEventHandlerTest extends BaseTest { @Test public void testMotionWithStatus() throws Exception { MotionEventHandler motionEventHandler = new MotionEventHandler( - new TripsConfig(500, 300 * 1000, 300 * 1000, 0, false, false)); + new TripsConfig(500, 300 * 1000, 300 * 1000, 0, false, false, 0.01)); Position position = new Position(); position.setTime(new Date(System.currentTimeMillis() - 360000)); @@ -93,7 +93,7 @@ public class MotionEventHandlerTest extends BaseTest { @Test public void testStopWithPositionIgnition() throws Exception { MotionEventHandler motionEventHandler = new MotionEventHandler( - new TripsConfig(500, 300 * 1000, 300 * 1000, 0, true, false)); + new TripsConfig(500, 300 * 1000, 300 * 1000, 0, true, false, 0.01)); Position position = new Position(); position.setTime(date("2017-01-01 00:00:00")); diff --git a/test/org/traccar/reports/ReportUtilsTest.java b/test/org/traccar/reports/ReportUtilsTest.java index 23fdbd0b1..4f7a4eb68 100644 --- a/test/org/traccar/reports/ReportUtilsTest.java +++ b/test/org/traccar/reports/ReportUtilsTest.java @@ -80,9 +80,9 @@ public class ReportUtilsTest extends BaseTest { position("2016-01-01 00:06:00.000", 0, 3000), position("2016-01-01 00:07:00.000", 0, 3000)); - TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, false, false); + TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, false, false, 0.01); - Collection trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, 0.01, TripReport.class); + Collection trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, TripReport.class); assertNotNull(trips); assertFalse(trips.isEmpty()); @@ -96,7 +96,7 @@ public class ReportUtilsTest extends BaseTest { assertEquals(10, itemTrip.getMaxSpeed(), 0.01); assertEquals(3000, itemTrip.getDistance(), 0.01); - Collection stops = ReportUtils.detectTripsAndStops(data, tripsConfig, false, 0.01, StopReport.class); + Collection stops = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class); assertNotNull(stops); assertFalse(stops.isEmpty()); @@ -132,9 +132,9 @@ public class ReportUtilsTest extends BaseTest { data.get(5).set(Position.KEY_IGNITION, false); - TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, true, false); + TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, true, false, 0.01); - Collection trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, 0.01, TripReport.class); + Collection trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, TripReport.class); assertNotNull(trips); assertFalse(trips.isEmpty()); @@ -148,7 +148,7 @@ public class ReportUtilsTest extends BaseTest { assertEquals(10, itemTrip.getMaxSpeed(), 0.01); assertEquals(3000, itemTrip.getDistance(), 0.01); - trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, 0.01, TripReport.class); + trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, TripReport.class); assertNotNull(trips); assertFalse(trips.isEmpty()); @@ -162,7 +162,7 @@ public class ReportUtilsTest extends BaseTest { assertEquals(10, itemTrip.getMaxSpeed(), 0.01); assertEquals(3000, itemTrip.getDistance(), 0.01); - Collection stops = ReportUtils.detectTripsAndStops(data, tripsConfig, false, 0.01, StopReport.class); + Collection stops = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class); assertNotNull(stops); assertFalse(stops.isEmpty()); @@ -200,9 +200,9 @@ public class ReportUtilsTest extends BaseTest { position("2016-01-01 00:10:00.000", 0, 7000), position("2016-01-01 00:11:00.000", 0, 7000)); - TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, false, false); + TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, false, false, 0.01); - Collection trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, 0.01, TripReport.class); + Collection trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, TripReport.class); assertNotNull(trips); assertFalse(trips.isEmpty()); @@ -216,7 +216,7 @@ public class ReportUtilsTest extends BaseTest { assertEquals(10, itemTrip.getMaxSpeed(), 0.01); assertEquals(7000, itemTrip.getDistance(), 0.01); - Collection stops = ReportUtils.detectTripsAndStops(data, tripsConfig, false, 0.01, StopReport.class); + Collection stops = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class); assertNotNull(stops); assertFalse(stops.isEmpty()); @@ -248,9 +248,9 @@ public class ReportUtilsTest extends BaseTest { position("2016-01-01 00:04:00.000", 1, 0), position("2016-01-01 00:05:00.000", 0, 0)); - TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false); + TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01); - Collection result = ReportUtils.detectTripsAndStops(data, tripsConfig, false, 0.01, StopReport.class); + Collection result = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class); assertNotNull(result); assertFalse(result.isEmpty()); @@ -274,9 +274,9 @@ public class ReportUtilsTest extends BaseTest { position("2016-01-01 00:04:00.000", 1, 0), position("2016-01-01 00:05:00.000", 2, 0)); - TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false); + TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01); - Collection result = ReportUtils.detectTripsAndStops(data, tripsConfig, false, 0.01, StopReport.class); + Collection result = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class); assertNotNull(result); assertFalse(result.isEmpty()); @@ -300,9 +300,9 @@ public class ReportUtilsTest extends BaseTest { position("2016-01-01 00:04:00.000", 0, 0), position("2016-01-01 00:05:00.000", 0, 0)); - TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false); + TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01); - Collection result = ReportUtils.detectTripsAndStops(data, tripsConfig, false, 0.01, StopReport.class); + Collection result = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class); assertNotNull(result); assertFalse(result.isEmpty()); @@ -326,9 +326,9 @@ public class ReportUtilsTest extends BaseTest { position("2016-01-01 00:04:00.000", 5, 0), position("2016-01-01 00:05:00.000", 5, 0)); - TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false); + TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01); - Collection result = ReportUtils.detectTripsAndStops(data, tripsConfig, false, 0.01, StopReport.class); + Collection result = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class); assertNotNull(result); assertTrue(result.isEmpty()); @@ -348,9 +348,9 @@ public class ReportUtilsTest extends BaseTest { position("2016-01-01 00:24:00.000", 5, 800), position("2016-01-01 00:25:00.000", 5, 900)); - TripsConfig tripsConfig = new TripsConfig(500, 200000, 200000, 900000, false, false); + TripsConfig tripsConfig = new TripsConfig(500, 200000, 200000, 900000, false, false, 0.01); - Collection trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, 0.01, TripReport.class); + Collection trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, TripReport.class); assertNotNull(trips); assertFalse(trips.isEmpty()); @@ -364,7 +364,7 @@ public class ReportUtilsTest extends BaseTest { assertEquals(7, itemTrip.getMaxSpeed(), 0.01); assertEquals(600, itemTrip.getDistance(), 0.01); - Collection stops = ReportUtils.detectTripsAndStops(data, tripsConfig, false, 0.01, StopReport.class); + Collection stops = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class); assertNotNull(stops); assertFalse(stops.isEmpty()); -- cgit v1.2.3