diff options
author | Abyss777 <abyss@fox5.ru> | 2017-08-15 16:04:41 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-08-15 16:04:41 +0500 |
commit | 4d7805f783f00914a289b2447521a2f467de87bc (patch) | |
tree | 819d1a56dbbdd9c3badb379337da16d9dd487a54 /src | |
parent | 9b9c715cf0d9604be71a35e5e6e5428a3a891ba9 (diff) | |
parent | 5606c72b19568ddf50e2fa35f35e05358bb671e4 (diff) | |
download | trackermap-server-4d7805f783f00914a289b2447521a2f467de87bc.tar.gz trackermap-server-4d7805f783f00914a289b2447521a2f467de87bc.tar.bz2 trackermap-server-4d7805f783f00914a289b2447521a2f467de87bc.zip |
Merge remote-tracking branch 'upstream/master' into new_trips_detector
Diffstat (limited to 'src')
-rw-r--r-- | src/org/traccar/Context.java | 3 | ||||
-rw-r--r-- | src/org/traccar/database/DataManager.java | 2 | ||||
-rw-r--r-- | src/org/traccar/events/MotionEventHandler.java | 8 | ||||
-rw-r--r-- | src/org/traccar/model/User.java | 2 | ||||
-rw-r--r-- | src/org/traccar/protocol/Vt200ProtocolDecoder.java | 58 | ||||
-rw-r--r-- | src/org/traccar/reports/model/TripsConfig.java | 15 |
6 files changed, 76 insertions, 12 deletions
diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java index 0d2a05b7a..10fdd9f29 100644 --- a/src/org/traccar/Context.java +++ b/src/org/traccar/Context.java @@ -255,7 +255,8 @@ public final class Context { config.getLong("report.trip.minimalTripDistance", 500), config.getLong("report.trip.minimalTripDuration", 300) * 1000, config.getLong("report.trip.minimalParkingDuration", 300) * 1000, - config.getLong("report.trip.minimalNoDataDuration", 3600) * 1000); + config.getLong("report.trip.minimalNoDataDuration", 3600) * 1000, + config.getBoolean("report.trip.useIgnition")); } public static void init(String[] arguments) throws Exception { diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index b7d3cb1e4..2e3e68bc9 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -297,7 +297,7 @@ public class DataManager { public User login(String email, String password) throws SQLException { User user = QueryBuilder.create(dataSource, getQuery("database.loginUser")) - .setString("email", email) + .setString("email", email.trim()) .executeQuerySingle(User.class); if (user != null && user.isPasswordValid(password)) { return user; diff --git a/src/org/traccar/events/MotionEventHandler.java b/src/org/traccar/events/MotionEventHandler.java index b20a11999..8c2d4c56c 100644 --- a/src/org/traccar/events/MotionEventHandler.java +++ b/src/org/traccar/events/MotionEventHandler.java @@ -78,13 +78,19 @@ public class MotionEventHandler extends BaseEventHandler { if (motionPosition != null) { long motionTime = motionPosition.getFixTime().getTime(); double distance = ReportUtils.calculateDistance(motionPosition, position, false); + Boolean ignition = null; + if (tripsConfig.getUseIgnition() + && position.getAttributes().containsKey(Position.KEY_IGNITION)) { + ignition = position.getBoolean(Position.KEY_IGNITION); + } if (newMotion) { if (motionTime + tripsConfig.getMinimalTripDuration() <= currentTime || distance >= tripsConfig.getMinimalTripDistance()) { result = newEvent(deviceState, newMotion); } } else { - if (motionTime + tripsConfig.getMinimalParkingDuration() <= currentTime) { + if (motionTime + tripsConfig.getMinimalParkingDuration() <= currentTime + || ignition != null && !ignition) { result = newEvent(deviceState, newMotion); } } diff --git a/src/org/traccar/model/User.java b/src/org/traccar/model/User.java index b71666f87..3557521ab 100644 --- a/src/org/traccar/model/User.java +++ b/src/org/traccar/model/User.java @@ -43,7 +43,7 @@ public class User extends ExtendedModel { } public void setEmail(String email) { - this.email = email; + this.email = email.trim(); } private String phone; diff --git a/src/org/traccar/protocol/Vt200ProtocolDecoder.java b/src/org/traccar/protocol/Vt200ProtocolDecoder.java index 111c29313..6be70c3c1 100644 --- a/src/org/traccar/protocol/Vt200ProtocolDecoder.java +++ b/src/org/traccar/protocol/Vt200ProtocolDecoder.java @@ -27,6 +27,8 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Position; import java.net.SocketAddress; +import java.util.Arrays; +import java.util.Date; public class Vt200ProtocolDecoder extends BaseProtocolDecoder { @@ -40,6 +42,13 @@ public class Vt200ProtocolDecoder extends BaseProtocolDecoder { return degrees + minutes * 0.0001 / 60; } + protected Date decodeDate(ChannelBuffer buf) { + DateBuilder dateBuilder = new DateBuilder() + .setDateReverse(BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2)) + .setTime(BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2)); + return dateBuilder.getDate(); + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -66,12 +75,7 @@ public class Vt200ProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // data type buf.readUnsignedShort(); // trip id - DateBuilder dateBuilder = new DateBuilder(); - dateBuilder.setDateReverse( - BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2)); - dateBuilder.setTime( - BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2)); - position.setTime(dateBuilder.getDate()); + position.setTime(decodeDate(buf)); position.setLatitude(decodeCoordinate(BcdUtil.readInteger(buf, 8))); position.setLongitude(decodeCoordinate(BcdUtil.readInteger(buf, 9))); @@ -97,6 +101,48 @@ public class Vt200ProtocolDecoder extends BaseProtocolDecoder { return position; + } else if (type == 0x3088) { + + Position position = new Position(); + position.setProtocol(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + + getLastLocation(position, null); + + buf.readUnsignedShort(); // trip id + buf.skipBytes(8); // imei + buf.skipBytes(8); // imsi + + position.set("tripStart", decodeDate(buf).getTime()); + position.set("tripEnd", decodeDate(buf).getTime()); + position.set("drivingTime", buf.readUnsignedShort()); + + position.set(Position.KEY_FUEL_CONSUMPTION, buf.readUnsignedInt()); + position.set(Position.KEY_ODOMETER_TRIP, buf.readUnsignedInt()); + + position.set("maxSpeed", UnitsConverter.knotsFromKph(buf.readUnsignedByte())); + position.set("maxRpm", buf.readUnsignedShort()); + position.set("maxTemp", buf.readUnsignedByte() - 40); + position.set("hardAccelerationCount", buf.readUnsignedByte()); + position.set("hardBreakingCount", buf.readUnsignedByte()); + + for (String speedType : Arrays.asList("over", "high", "normal", "low")) { + position.set(speedType + "SpeedTime", buf.readUnsignedShort()); + position.set(speedType + "SpeedDistance", buf.readUnsignedInt()); + position.set(speedType + "SpeedFuel", buf.readUnsignedInt()); + } + + position.set("idleTime", buf.readUnsignedShort()); + position.set("idleFuel", buf.readUnsignedInt()); + + position.set("hardCorneringCount", buf.readUnsignedByte()); + position.set("overspeedCount", buf.readUnsignedByte()); + position.set("overheatCount", buf.readUnsignedShort()); + position.set("laneChangeCount", buf.readUnsignedByte()); + position.set("emergencyRefueling", buf.readUnsignedByte()); + + return position; + } return null; diff --git a/src/org/traccar/reports/model/TripsConfig.java b/src/org/traccar/reports/model/TripsConfig.java index 4898c1389..22fddd072 100644 --- a/src/org/traccar/reports/model/TripsConfig.java +++ b/src/org/traccar/reports/model/TripsConfig.java @@ -21,12 +21,13 @@ public class TripsConfig { public TripsConfig() { } - public TripsConfig(double minimalTripDistance, long minimalTripDuration, - long minimalParkingDuration, long minimalNoDataDuration) { + public TripsConfig(double minimalTripDistance, long minimalTripDuration, long minimalParkingDuration, + long minimalNoDataDuration, boolean useIgnition) { this.minimalTripDistance = minimalTripDistance; this.minimalTripDuration = minimalTripDuration; this.minimalParkingDuration = minimalParkingDuration; this.minimalNoDataDuration = minimalNoDataDuration; + this.useIgnition = useIgnition; } private double minimalTripDistance; @@ -69,4 +70,14 @@ public class TripsConfig { this.minimalNoDataDuration = minimalNoDataDuration; } + private boolean useIgnition; + + public boolean getUseIgnition() { + return useIgnition; + } + + public void setUseIgnition(boolean useIgnition) { + this.useIgnition = useIgnition; + } + } |