diff options
author | Abyss777 <abyss@fox5.ru> | 2016-05-26 09:30:43 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2016-05-26 09:30:43 +0500 |
commit | aa12e5c750e771016545269ffa39409b06b47eee (patch) | |
tree | d21b4414b532bfc53c9a905f3caa09f70b43b59e /src/org/traccar/protocol/MeitrackProtocolDecoder.java | |
parent | ac2405f0d57fac51fe95aa755f90fe82f26f73bc (diff) | |
download | trackermap-server-aa12e5c750e771016545269ffa39409b06b47eee.tar.gz trackermap-server-aa12e5c750e771016545269ffa39409b06b47eee.tar.bz2 trackermap-server-aa12e5c750e771016545269ffa39409b06b47eee.zip |
- Simplification of the hierarchy of models classes
- Removed automatically founded unnecessary imports
Diffstat (limited to 'src/org/traccar/protocol/MeitrackProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/MeitrackProtocolDecoder.java | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java index bbd7c521c..a03a3aeec 100644 --- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java +++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java @@ -23,7 +23,6 @@ import org.traccar.helper.DateBuilder; import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; import org.traccar.helper.UnitsConverter; -import org.traccar.model.Event; import org.traccar.model.Position; import java.net.SocketAddress; @@ -97,7 +96,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(getDeviceId()); int event = parser.nextInt(); - position.set(Event.KEY_EVENT, event); + position.set(Position.KEY_EVENT, event); position.setLatitude(parser.nextDouble()); position.setLongitude(parser.nextDouble()); @@ -109,38 +108,38 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { position.setValid(parser.next().equals("A")); - position.set(Event.KEY_SATELLITES, parser.next()); - position.set(Event.KEY_GSM, parser.next()); + position.set(Position.KEY_SATELLITES, parser.next()); + position.set(Position.KEY_GSM, parser.next()); position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble())); position.setCourse(parser.nextDouble()); - position.set(Event.KEY_HDOP, parser.next()); + position.set(Position.KEY_HDOP, parser.next()); position.setAltitude(parser.nextDouble()); - position.set(Event.KEY_ODOMETER, parser.next()); + position.set(Position.KEY_ODOMETER, parser.next()); position.set("runtime", parser.next()); - position.set(Event.KEY_MCC, parser.nextInt()); - position.set(Event.KEY_MNC, parser.nextInt()); - position.set(Event.KEY_LAC, parser.nextInt(16)); - position.set(Event.KEY_CID, parser.nextInt(16)); - position.set(Event.KEY_STATUS, parser.next()); + position.set(Position.KEY_MCC, parser.nextInt()); + position.set(Position.KEY_MNC, parser.nextInt()); + position.set(Position.KEY_LAC, parser.nextInt(16)); + position.set(Position.KEY_CID, parser.nextInt(16)); + position.set(Position.KEY_STATUS, parser.next()); for (int i = 1; i <= 3; i++) { if (parser.hasNext()) { - position.set(Event.PREFIX_ADC + i, parser.nextInt(16)); + position.set(Position.PREFIX_ADC + i, parser.nextInt(16)); } } - position.set(Event.KEY_BATTERY, parser.nextInt(16)); - position.set(Event.KEY_POWER, parser.nextInt(16)); + position.set(Position.KEY_BATTERY, parser.nextInt(16)); + position.set(Position.KEY_POWER, parser.nextInt(16)); String eventData = parser.next(); if (eventData != null && !eventData.isEmpty()) { switch (event) { case 37: - position.set(Event.KEY_RFID, eventData); + position.set(Position.KEY_RFID, eventData); break; default: position.set("event-data", eventData); @@ -150,7 +149,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { if (parser.hasNext()) { String fuel = parser.next(); - position.set(Event.KEY_FUEL, + position.set(Position.KEY_FUEL, Integer.parseInt(fuel.substring(0, 2), 16) + Integer.parseInt(fuel.substring(2), 16) * 0.01); } @@ -176,7 +175,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { position.setProtocol(getProtocolName()); position.setDeviceId(getDeviceId()); - position.set(Event.KEY_EVENT, buf.readUnsignedByte()); + position.set(Position.KEY_EVENT, buf.readUnsignedByte()); position.setLatitude(buf.readInt() * 0.000001); position.setLongitude(buf.readInt() * 0.000001); @@ -185,27 +184,27 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { position.setValid(buf.readUnsignedByte() == 1); - position.set(Event.KEY_SATELLITES, buf.readUnsignedByte()); - position.set(Event.KEY_GSM, buf.readUnsignedByte()); + position.set(Position.KEY_SATELLITES, buf.readUnsignedByte()); + position.set(Position.KEY_GSM, buf.readUnsignedByte()); position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShort())); position.setCourse(buf.readUnsignedShort()); - position.set(Event.KEY_HDOP, buf.readUnsignedShort() * 0.1); + position.set(Position.KEY_HDOP, buf.readUnsignedShort() * 0.1); position.setAltitude(buf.readUnsignedShort()); - position.set(Event.KEY_ODOMETER, buf.readUnsignedInt()); + position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); position.set("runtime", buf.readUnsignedInt()); - position.set(Event.KEY_MCC, buf.readUnsignedShort()); - position.set(Event.KEY_MNC, buf.readUnsignedShort()); - position.set(Event.KEY_LAC, buf.readUnsignedShort()); - position.set(Event.KEY_CID, buf.readUnsignedShort()); - position.set(Event.KEY_STATUS, buf.readUnsignedShort()); - - position.set(Event.PREFIX_ADC + 1, buf.readUnsignedShort()); - position.set(Event.KEY_BATTERY, buf.readUnsignedShort() * 0.01); - position.set(Event.KEY_POWER, buf.readUnsignedShort()); + position.set(Position.KEY_MCC, buf.readUnsignedShort()); + position.set(Position.KEY_MNC, buf.readUnsignedShort()); + position.set(Position.KEY_LAC, buf.readUnsignedShort()); + position.set(Position.KEY_CID, buf.readUnsignedShort()); + position.set(Position.KEY_STATUS, buf.readUnsignedShort()); + + position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort()); + position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.01); + position.set(Position.KEY_POWER, buf.readUnsignedShort()); buf.readUnsignedInt(); // geo-fence |