use of org.traccar.reports.model.TripsConfig in project traccar by tananaev.
the class Context method init.
public static void init(String[] arguments) throws Exception {
config = new Config();
if (arguments.length <= 0) {
throw new RuntimeException("Configuration file is not provided");
}
config.load(arguments[0]);
loggerEnabled = config.getBoolean("logger.enable");
if (loggerEnabled) {
Log.setupLogger(config);
}
objectMapper = new ObjectMapper();
objectMapper.setConfig(objectMapper.getSerializationConfig().without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS));
if (Context.getConfig().getBoolean("mapper.prettyPrintedJson")) {
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
}
if (config.hasKey("database.url")) {
dataManager = new DataManager(config);
}
if (config.getBoolean("ldap.enable")) {
ldapProvider = new LdapProvider(config);
}
mediaManager = new MediaManager(config.getString("media.path"));
if (dataManager != null) {
usersManager = new UsersManager(dataManager);
groupsManager = new GroupsManager(dataManager);
deviceManager = new DeviceManager(dataManager);
}
identityManager = deviceManager;
if (config.getBoolean("geocoder.enable")) {
geocoder = initGeocoder();
}
if (config.getBoolean("geolocation.enable")) {
initGeolocationModule();
}
if (config.getBoolean("web.enable")) {
webServer = new WebServer(config, dataManager.getDataSource());
}
permissionsManager = new PermissionsManager(dataManager, usersManager);
connectionManager = new ConnectionManager();
tripsConfig = initTripsConfig();
if (config.getBoolean("event.enable")) {
initEventsModule();
}
serverManager = new ServerManager();
if (config.getBoolean("event.forward.enable")) {
if (Context.getConfig().getBoolean("event.forward.payloadAsParamMode")) {
eventForwarder = new MultiPartEventForwarder();
} else {
eventForwarder = new JsonTypeEventForwarder();
}
}
attributesManager = new AttributesManager(dataManager);
driversManager = new DriversManager(dataManager);
commandsManager = new CommandsManager(dataManager);
statisticsManager = new StatisticsManager();
if (config.getBoolean("sms.smpp.enable")) {
smppClient = new SmppClient();
}
}
use of org.traccar.reports.model.TripsConfig in project traccar by tananaev.
the class MotionEventHandlerTest method testStopWithPositionIgnition.
@Test
public void testStopWithPositionIgnition() throws Exception {
MotionEventHandler motionEventHandler = new MotionEventHandler(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"));
position.set(Position.KEY_MOTION, false);
position.set(Position.KEY_IGNITION, true);
DeviceState deviceState = new DeviceState();
deviceState.setMotionState(true);
deviceState.setMotionPosition(position);
Position nextPosition = new Position();
nextPosition.setTime(date("2017-01-01 00:02:00"));
nextPosition.set(Position.KEY_MOTION, false);
nextPosition.set(Position.KEY_IGNITION, false);
Map<Event, Position> events = motionEventHandler.updateMotionState(deviceState, nextPosition);
assertNotNull(events);
Event event = events.keySet().iterator().next();
assertEquals(Event.TYPE_DEVICE_STOPPED, event.getType());
assertFalse(deviceState.getMotionState());
assertNull(deviceState.getMotionPosition());
}
use of org.traccar.reports.model.TripsConfig in project traccar by tananaev.
the class ReportUtilsTest method testDetectStopsWithTripCut.
@Test
public void testDetectStopsWithTripCut() throws ParseException {
Collection<Position> data = Arrays.asList(position("2016-01-01 00:00:00.000", 0, 0), position("2016-01-01 00:01:00.000", 0, 0), position("2016-01-01 00:02:00.000", 0, 0), position("2016-01-01 00:03:00.000", 0, 0), 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, 0.01);
Collection<StopReport> result = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class);
assertNotNull(result);
assertFalse(result.isEmpty());
StopReport itemStop = result.iterator().next();
assertEquals(date("2016-01-01 00:00:00.000"), itemStop.getStartTime());
assertEquals(date("2016-01-01 00:04:00.000"), itemStop.getEndTime());
assertEquals(240000, itemStop.getDuration());
}
use of org.traccar.reports.model.TripsConfig in project traccar by tananaev.
the class ReportUtilsTest method testDetectTripsSimple.
@Test
public void testDetectTripsSimple() throws ParseException {
List<Position> data = Arrays.asList(position("2016-01-01 00:00:00.000", 0, 0), position("2016-01-01 00:01:00.000", 0, 0), position("2016-01-01 00:02:00.000", 10, 0), position("2016-01-01 00:03:00.000", 10, 1000), position("2016-01-01 00:04:00.000", 10, 2000), position("2016-01-01 00:05:00.000", 0, 3000), 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, 0.01);
Collection<TripReport> trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, TripReport.class);
assertNotNull(trips);
assertFalse(trips.isEmpty());
TripReport itemTrip = trips.iterator().next();
assertEquals(date("2016-01-01 00:02:00.000"), itemTrip.getStartTime());
assertEquals(date("2016-01-01 00:05:00.000"), itemTrip.getEndTime());
assertEquals(180000, itemTrip.getDuration());
assertEquals(10, itemTrip.getAverageSpeed(), 0.01);
assertEquals(10, itemTrip.getMaxSpeed(), 0.01);
assertEquals(3000, itemTrip.getDistance(), 0.01);
Collection<StopReport> stops = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class);
assertNotNull(stops);
assertFalse(stops.isEmpty());
Iterator<StopReport> iterator = stops.iterator();
StopReport itemStop = iterator.next();
assertEquals(date("2016-01-01 00:00:00.000"), itemStop.getStartTime());
assertEquals(date("2016-01-01 00:02:00.000"), itemStop.getEndTime());
assertEquals(120000, itemStop.getDuration());
itemStop = iterator.next();
assertEquals(date("2016-01-01 00:05:00.000"), itemStop.getStartTime());
assertEquals(date("2016-01-01 00:07:00.000"), itemStop.getEndTime());
assertEquals(120000, itemStop.getDuration());
}
use of org.traccar.reports.model.TripsConfig in project traccar by tananaev.
the class ReportUtilsTest method testDetectStopsStartedFromTrip.
@Test
public void testDetectStopsStartedFromTrip() throws ParseException {
Collection<Position> data = Arrays.asList(position("2016-01-01 00:00:00.000", 2, 0), position("2016-01-01 00:01:00.000", 1, 0), position("2016-01-01 00:02:00.000", 0, 0), position("2016-01-01 00:03:00.000", 0, 0), 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, 0.01);
Collection<StopReport> result = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class);
assertNotNull(result);
assertFalse(result.isEmpty());
StopReport itemStop = result.iterator().next();
assertEquals(date("2016-01-01 00:02:00.000"), itemStop.getStartTime());
assertEquals(date("2016-01-01 00:05:00.000"), itemStop.getEndTime());
assertEquals(180000, itemStop.getDuration());
}
Aggregations