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/TeltonikaProtocolDecoder.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/TeltonikaProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/TeltonikaProtocolDecoder.java | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java index e052b10d5..e4966aabe 100644 --- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java +++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java @@ -30,7 +30,7 @@ import org.traccar.model.Event; import org.traccar.model.Position; public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { - + public TeltonikaProtocolDecoder(TeltonikaProtocol protocol) { super(protocol); } @@ -51,74 +51,74 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { private static final int CODEC_GH3000 = 0x07; private static final int CODEC_FM4X00 = 0x08; private static final int CODEC_12 = 0x0C; - + private List<Position> parseLocation(Channel channel, ChannelBuffer buf) { List<Position> positions = new LinkedList<>(); - + buf.skipBytes(4); // marker buf.readUnsignedInt(); // data length int codec = buf.readUnsignedByte(); // codec - + if (codec == CODEC_12) { // TODO: decode serial port data return null; } - + int count = buf.readUnsignedByte(); - + for (int i = 0; i < count; i++) { Position position = new Position(); position.setProtocol(getProtocolName()); - + position.setDeviceId(getDeviceId()); - + int globalMask = 0x0f; - + if (codec == CODEC_GH3000) { long time = buf.readUnsignedInt() & 0x3fffffff; time += 1167609600; // 2007-01-01 00:00:00 position.setTime(new Date(time * 1000)); - + globalMask = buf.readUnsignedByte(); if (!BitUtil.check(globalMask, 0)) { return null; } - + int locationMask = buf.readUnsignedByte(); - + if (BitUtil.check(locationMask, 0)) { position.setLatitude(buf.readFloat()); position.setLongitude(buf.readFloat()); } - + if (BitUtil.check(locationMask, 1)) { position.setAltitude(buf.readUnsignedShort()); } - + if (BitUtil.check(locationMask, 2)) { position.setCourse(buf.readUnsignedByte() * 360.0 / 256); } - + if (BitUtil.check(locationMask, 3)) { position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte())); } - + if (BitUtil.check(locationMask, 4)) { int satellites = buf.readUnsignedByte(); position.set(Event.KEY_SATELLITES, satellites); position.setValid(satellites >= 3); } - + if (BitUtil.check(locationMask, 5)) { position.set("area", buf.readUnsignedShort()); position.set(Event.KEY_CELL, buf.readUnsignedShort()); } - + if (BitUtil.check(locationMask, 6)) { position.set(Event.KEY_GSM, buf.readUnsignedByte()); } - + if (BitUtil.check(locationMask, 7)) { position.set("operator", buf.readUnsignedInt()); } @@ -146,7 +146,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // total IO data records } - + // Read 1 byte data if (BitUtil.check(globalMask, 1)) { int cnt = buf.readUnsignedByte(); @@ -185,29 +185,29 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { } positions.add(position); } - + if (channel != null) { ChannelBuffer response = ChannelBuffers.directBuffer(4); response.writeInt(count); channel.write(response); } - + return positions; } - + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { - + ChannelBuffer buf = (ChannelBuffer) msg; - + if (buf.getUnsignedShort(0) > 0) { parseIdentification(channel, buf); } else { return parseLocation(channel, buf); } - + return null; } |