aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/TytanProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-05-26 10:02:37 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2016-05-26 10:02:37 -0700
commitd3e34416e9825833fa1db02112c56981999df039 (patch)
treed21b4414b532bfc53c9a905f3caa09f70b43b59e /src/org/traccar/protocol/TytanProtocolDecoder.java
parentac2405f0d57fac51fe95aa755f90fe82f26f73bc (diff)
parentaa12e5c750e771016545269ffa39409b06b47eee (diff)
downloadtraccar-server-d3e34416e9825833fa1db02112c56981999df039.tar.gz
traccar-server-d3e34416e9825833fa1db02112c56981999df039.tar.bz2
traccar-server-d3e34416e9825833fa1db02112c56981999df039.zip
Merge pull request #1978 from Abyss777/master
Simplification of the models hierarchy
Diffstat (limited to 'src/org/traccar/protocol/TytanProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/TytanProtocolDecoder.java31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/org/traccar/protocol/TytanProtocolDecoder.java b/src/org/traccar/protocol/TytanProtocolDecoder.java
index a30bd6763..b657ae029 100644
--- a/src/org/traccar/protocol/TytanProtocolDecoder.java
+++ b/src/org/traccar/protocol/TytanProtocolDecoder.java
@@ -21,7 +21,6 @@ import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.helper.BitUtil;
import org.traccar.helper.UnitsConverter;
-import org.traccar.model.Event;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -49,15 +48,15 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
switch (type) {
case 2:
- position.set(Event.KEY_ODOMETER, buf.readUnsignedMedium());
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedMedium());
break;
case 5:
- position.set(Event.KEY_INPUT, buf.readUnsignedByte());
+ position.set(Position.KEY_INPUT, buf.readUnsignedByte());
break;
case 6:
n = buf.readUnsignedByte() >> 4;
if (n < 2) {
- position.set(Event.PREFIX_ADC + n, buf.readFloat());
+ position.set(Position.PREFIX_ADC + n, buf.readFloat());
} else {
position.set("di" + (n - 2), buf.readFloat());
}
@@ -66,7 +65,7 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
int alarm = buf.readUnsignedByte();
buf.readUnsignedByte();
if (BitUtil.check(alarm, 5)) {
- position.set(Event.KEY_ALARM, BitUtil.to(alarm, 4));
+ position.set(Position.KEY_ALARM, BitUtil.to(alarm, 4));
}
break;
case 8:
@@ -80,7 +79,7 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
break;
case 24:
for (int i = 0; i < length / 2; i++) {
- position.set(Event.PREFIX_TEMP + buf.readUnsignedByte(), buf.readByte());
+ position.set(Position.PREFIX_TEMP + buf.readUnsignedByte(), buf.readByte());
}
break;
case 28:
@@ -88,27 +87,27 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedByte();
break;
case 90:
- position.set(Event.KEY_POWER, buf.readFloat());
+ position.set(Position.KEY_POWER, buf.readFloat());
break;
case 101:
- position.set(Event.KEY_OBD_SPEED, buf.readUnsignedByte());
+ position.set(Position.KEY_OBD_SPEED, buf.readUnsignedByte());
break;
case 102:
- position.set(Event.KEY_RPM, buf.readUnsignedByte() * 50);
+ position.set(Position.KEY_RPM, buf.readUnsignedByte() * 50);
break;
case 107:
int fuel = buf.readUnsignedShort();
int fuelFormat = fuel >> 14;
if (fuelFormat == 1) {
- position.set(Event.KEY_FUEL, (fuel & 0x3fff) * 0.4 + "%");
+ position.set(Position.KEY_FUEL, (fuel & 0x3fff) * 0.4 + "%");
} else if (fuelFormat == 2) {
- position.set(Event.KEY_FUEL, (fuel & 0x3fff) * 0.5 + " l");
+ position.set(Position.KEY_FUEL, (fuel & 0x3fff) * 0.5 + " l");
} else if (fuelFormat == 3) {
- position.set(Event.KEY_FUEL, (fuel & 0x3fff) * -0.5 + " l");
+ position.set(Position.KEY_FUEL, (fuel & 0x3fff) * -0.5 + " l");
}
break;
case 108:
- position.set(Event.KEY_OBD_ODOMETER, buf.readUnsignedInt() * 5);
+ position.set(Position.KEY_OBD_ODOMETER, buf.readUnsignedInt() * 5);
break;
case 150:
position.set("door", buf.readUnsignedByte());
@@ -154,7 +153,7 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
position.setTime(new Date(buf.readUnsignedInt() * 1000));
int flags = buf.readUnsignedByte();
- position.set(Event.KEY_SATELLITES, BitUtil.from(flags, 2));
+ position.set(Position.KEY_SATELLITES, BitUtil.from(flags, 2));
position.setValid(BitUtil.to(flags, 2) > 0);
// Latitude
@@ -169,8 +168,8 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
// Status
flags = buf.readUnsignedByte();
- position.set(Event.KEY_IGNITION, BitUtil.check(flags, 0));
- position.set(Event.KEY_GSM, BitUtil.between(flags, 2, 5));
+ position.set(Position.KEY_IGNITION, BitUtil.check(flags, 0));
+ position.set(Position.KEY_GSM, BitUtil.between(flags, 2, 5));
position.setCourse((BitUtil.from(flags, 5) * 45 + 180) % 360);
// Speed