diff options
Diffstat (limited to 'src/org/traccar/Context.java')
-rw-r--r-- | src/org/traccar/Context.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java index 306a37e83..a69b1786d 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.model.TripsConfig; import org.traccar.smpp.SmppClient; import org.traccar.web.WebServer; @@ -229,6 +232,33 @@ 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; + } + + private static TripsConfig tripsConfig; + + public static TripsConfig getTripsConfig() { + return tripsConfig; + } + + public static TripsConfig initTripsConfig() { + return new TripsConfig( + config.getLong("report.trip.minimalTripDistance", 500), + config.getLong("report.trip.minimalTripDuration", 300) * 1000, + config.getLong("report.trip.minimalParkingDuration", 300) * 1000, + config.getBoolean("report.trip.greedyParking"), + config.getLong("report.trip.minimalNoDataDuration", 3600) * 1000); + } + public static void init(String[] arguments) throws Exception { config = new Config(); @@ -327,6 +357,8 @@ public final class Context { connectionManager = new ConnectionManager(); + tripsConfig = initTripsConfig(); + if (config.getBoolean("event.enable")) { geofenceManager = new GeofenceManager(dataManager); calendarManager = new CalendarManager(dataManager); @@ -350,6 +382,11 @@ public final class Context { velocityEngine = new VelocityEngine(); velocityEngine.init(velocityProperties); + + motionEventHandler = new MotionEventHandler(tripsConfig); + overspeedEventHandler = new OverspeedEventHandler( + Context.getConfig().getLong("event.overspeed.minimalDuration") * 1000, + Context.getConfig().getBoolean("event.overspeed.notRepeat")); } serverManager = new ServerManager(); |