diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-10-04 13:20:46 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-10-04 13:20:46 +1300 |
commit | d4dbf85d9536bfec85252a58fc552e2bad42ff17 (patch) | |
tree | 4a849426c2cd60538b152138b147abef47b40966 /src/org/traccar/protocol/NavigilProtocolDecoder.java | |
parent | 9218bc65b9673b24d2866aae3d5bbe1a5388bab0 (diff) | |
download | trackermap-server-d4dbf85d9536bfec85252a58fc552e2bad42ff17.tar.gz trackermap-server-d4dbf85d9536bfec85252a58fc552e2bad42ff17.tar.bz2 trackermap-server-d4dbf85d9536bfec85252a58fc552e2bad42ff17.zip |
Remove trailing whitespaces from code
Diffstat (limited to 'src/org/traccar/protocol/NavigilProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/NavigilProtocolDecoder.java | 104 |
1 files changed, 52 insertions, 52 deletions
diff --git a/src/org/traccar/protocol/NavigilProtocolDecoder.java b/src/org/traccar/protocol/NavigilProtocolDecoder.java index 7938fd7cc..3e38890d4 100644 --- a/src/org/traccar/protocol/NavigilProtocolDecoder.java +++ b/src/org/traccar/protocol/NavigilProtocolDecoder.java @@ -32,7 +32,7 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { public NavigilProtocolDecoder(NavigilProtocol protocol) { super(protocol); } - + private static final int LEAP_SECONDS_DELTA = 25; private static final int MESSAGE_ERROR = 2; @@ -50,18 +50,18 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { private static final int MESSAGE_TRACKING_DATA = 18; private static final int MESSAGE_MOTION_ALARM = 19; private static final int MESSAGE_ACKNOWLEDGEMENT = 255; - + private static Date convertTimestamp(long timestamp) { return new Date((timestamp - LEAP_SECONDS_DELTA) * 1000l); } - + private int senderSequenceNumber = 1; - + private void sendAcknowledgment(Channel channel, int sequenceNumber) { ChannelBuffer data = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 4); data.writeShort(sequenceNumber); data.writeShort(0); // OK - + ChannelBuffer header = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 20); header.writeByte(1); header.writeByte(0); header.writeShort(senderSequenceNumber++); @@ -71,12 +71,12 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { header.writeShort(Crc.crc16X25Ccitt(data.toByteBuffer())); header.writeInt(0); header.writeInt((int) (System.currentTimeMillis() / 1000) + LEAP_SECONDS_DELTA); - + if (channel != null) { channel.write(ChannelBuffers.copiedBuffer(header, data)); } } - + private Position parseUnitReport(ChannelBuffer buf, int sequenceNumber) { Position position = new Position(); position.setProtocol(getProtocolName()); @@ -84,34 +84,34 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { position.setValid(true); position.set(Event.KEY_INDEX, sequenceNumber); position.setDeviceId(getDeviceId()); - + buf.readUnsignedShort(); // report trigger buf.readUnsignedShort(); // flags - + position.setLatitude(buf.readInt() * 0.0000001); position.setLongitude(buf.readInt() * 0.0000001); position.setAltitude( buf.readUnsignedShort()); - + buf.readUnsignedShort(); // satellites in fix buf.readUnsignedShort(); // satellites in track buf.readUnsignedShort(); // GPS antenna state - + position.setSpeed(buf.readUnsignedShort() * 0.194384); position.setCourse(buf.readUnsignedShort()); - + buf.readUnsignedInt(); // distance buf.readUnsignedInt(); // delta distance position.set(Event.KEY_BATTERY, buf.readUnsignedShort() * 0.001); - + buf.readUnsignedShort(); // battery charger status - + position.setTime(convertTimestamp(buf.readUnsignedInt())); - + // TODO: a lot of other stuff return position; } - + private Position parseTg2Report(ChannelBuffer buf, int sequenceNumber) { Position position = new Position(); position.setProtocol(getProtocolName()); @@ -119,23 +119,23 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { position.setValid(true); position.set(Event.KEY_INDEX, sequenceNumber); position.setDeviceId(getDeviceId()); - + buf.readUnsignedShort(); // report trigger buf.readUnsignedByte(); // reserved buf.readUnsignedByte(); // assisted GPS age - + position.setTime(convertTimestamp(buf.readUnsignedInt())); - + position.setLatitude(buf.readInt() * 0.0000001); position.setLongitude(buf.readInt() * 0.0000001); position.setAltitude(buf.readUnsignedShort()); - + buf.readUnsignedByte(); // satellites in fix buf.readUnsignedByte(); // satellites in track - + position.setSpeed(buf.readUnsignedShort() * 0.194384); position.setCourse(buf.readUnsignedShort()); - + buf.readUnsignedInt(); // distance buf.readUnsignedShort(); // maximum speed buf.readUnsignedShort(); // minimum speed @@ -144,11 +144,11 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedShort(); // VSAUT2 voltage buf.readUnsignedShort(); // solar voltage position.set(Event.KEY_BATTERY, buf.readUnsignedShort() * 0.001); - + // TODO: a lot of other stuff return position; } - + private Position parsePositionReport(ChannelBuffer buf, int sequenceNumber, long timestamp) { Position position = new Position(); position.setProtocol(getProtocolName()); @@ -156,20 +156,20 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { position.set(Event.KEY_INDEX, sequenceNumber); position.setDeviceId(getDeviceId()); position.setTime(convertTimestamp(timestamp)); - + position.setLatitude(buf.readMedium() * 0.00002); position.setLongitude(buf.readMedium() * 0.00002); - + position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte())); position.setCourse(buf.readUnsignedByte() * 2); - + short flags = buf.readUnsignedByte(); position.setValid((flags & 0x80) == 0x80 && (flags & 0x40) == 0x40); - + buf.readUnsignedByte(); // reserved return position; } - + private Position parsePositionReport2(ChannelBuffer buf, int sequenceNumber, long timestamp) { Position position = new Position(); position.setProtocol(getProtocolName()); @@ -177,22 +177,22 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { position.set(Event.KEY_INDEX, sequenceNumber); position.setDeviceId(getDeviceId()); position.setTime(convertTimestamp(timestamp)); - + position.setLatitude(buf.readInt() * 0.0000001); position.setLongitude(buf.readInt() * 0.0000001); - + buf.readUnsignedByte(); // report trigger position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte())); - + short flags = buf.readUnsignedByte(); position.setValid((flags & 0x80) == 0x80 && (flags & 0x40) == 0x40); - + int x = buf.readUnsignedByte(); // satellites in fix buf.readUnsignedInt(); // distance return position; } - + private Position parseSnapshot4(ChannelBuffer buf, int sequenceNumber) { Position position = new Position(); position.setProtocol(getProtocolName()); @@ -204,22 +204,22 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // position fix source buf.readUnsignedByte(); // GNSS fix quality buf.readUnsignedByte(); // GNSS assistance age - + long flags = buf.readUnsignedInt(); position.setValid((flags & 0x0400) == 0x0400); - + position.setTime(convertTimestamp(buf.readUnsignedInt())); - + position.setLatitude(buf.readInt() * 0.0000001); position.setLongitude(buf.readInt() * 0.0000001); position.setAltitude(buf.readUnsignedShort()); - + buf.readUnsignedByte(); // satellites in fix buf.readUnsignedByte(); // satellites in track - + position.setSpeed(buf.readUnsignedShort() * 0.194384); position.setCourse(buf.readUnsignedShort() * 0.1); - + buf.readUnsignedByte(); // maximum speed buf.readUnsignedByte(); // minimum speed buf.readUnsignedInt(); // distance @@ -231,7 +231,7 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { // TODO: a lot of other stuff return position; } - + private Position parseTrackingData(ChannelBuffer buf, int sequenceNumber, long timestamp) { Position position = new Position(); position.setProtocol(getProtocolName()); @@ -241,33 +241,33 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { position.setTime(convertTimestamp(timestamp)); buf.readUnsignedByte(); // tracking mode - + short flags = buf.readUnsignedByte(); position.setValid((flags & 0x01) == 0x01); - + buf.readUnsignedShort(); // duration position.setLatitude(buf.readInt() * 0.0000001); position.setLongitude(buf.readInt() * 0.0000001); - + position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte())); position.setCourse(buf.readUnsignedByte() * 2.0); buf.readUnsignedByte(); // satellites in fix - + position.set(Event.KEY_BATTERY, buf.readUnsignedShort() * 0.001); - + buf.readUnsignedInt(); // distance return position; } - + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { - + ChannelBuffer buf = (ChannelBuffer) msg; - + buf.readUnsignedByte(); // protocol version buf.readUnsignedByte(); // version id int sequenceNumber = buf.readUnsignedShort(); @@ -275,7 +275,7 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedShort(); // length int flags = buf.readUnsignedShort(); buf.readUnsignedShort(); // checksum - + // Get device identifier if (!identify(String.valueOf(buf.readUnsignedInt()), channel)) { return null; @@ -287,7 +287,7 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { if ((flags & 0x1) == 0x0) { sendAcknowledgment(channel, sequenceNumber); } - + // Parse messages switch (messageId) { case MESSAGE_UNIT_REPORT: @@ -303,7 +303,7 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { case MESSAGE_TRACKING_DATA: return parseTrackingData(buf, sequenceNumber, timestamp); } - + return null; } |