aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/TytanProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-10-09 22:33:56 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-10-09 22:33:56 +1300
commit30cf4d484307ad89ce538bae36c47c91eb430536 (patch)
tree78caf275ff46530c53d8d1ccb89092aea00f23b4 /src/org/traccar/protocol/TytanProtocolDecoder.java
parent9e569d3f839838f84f46e164660f294e9d4ca709 (diff)
downloadtrackermap-server-30cf4d484307ad89ce538bae36c47c91eb430536.tar.gz
trackermap-server-30cf4d484307ad89ce538bae36c47c91eb430536.tar.bz2
trackermap-server-30cf4d484307ad89ce538bae36c47c91eb430536.zip
Fix some check style issues
Diffstat (limited to 'src/org/traccar/protocol/TytanProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/TytanProtocolDecoder.java68
1 files changed, 31 insertions, 37 deletions
diff --git a/src/org/traccar/protocol/TytanProtocolDecoder.java b/src/org/traccar/protocol/TytanProtocolDecoder.java
index 3cc0d0568..f31e8aead 100644
--- a/src/org/traccar/protocol/TytanProtocolDecoder.java
+++ b/src/org/traccar/protocol/TytanProtocolDecoder.java
@@ -112,6 +112,8 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
if (length == 255) {
length += buf.readUnsignedByte();
}
+
+ int n = 0;
switch (type) {
case 2:
@@ -121,22 +123,18 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
position.set(Event.KEY_INPUT, buf.readUnsignedByte());
break;
case 6:
- {
- int n = buf.readUnsignedByte() >> 4;
- if (n < 2) {
- position.set(Event.PREFIX_ADC + n, readSwappedFloat(buf));
- } else {
- position.set("di" + (n - 2), readSwappedFloat(buf));
- }
+ n = buf.readUnsignedByte() >> 4;
+ if (n < 2) {
+ position.set(Event.PREFIX_ADC + n, readSwappedFloat(buf));
+ } else {
+ position.set("di" + (n - 2), readSwappedFloat(buf));
}
break;
case 7:
- {
- int alarm = buf.readUnsignedByte();
- buf.readUnsignedByte();
- if (BitUtil.check(alarm, 5)) {
- position.set(Event.KEY_ALARM, BitUtil.range(alarm, 0, 4));
- }
+ int alarm = buf.readUnsignedByte();
+ buf.readUnsignedByte();
+ if (BitUtil.check(alarm, 5)) {
+ position.set(Event.KEY_ALARM, BitUtil.range(alarm, 0, 4));
}
break;
case 8:
@@ -149,19 +147,17 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
position.set("unauthorized", ChannelBufferTools.readHexString(buf, 16));
break;
case 24:
- {
- Set<Integer> temps = new LinkedHashSet<>();
- int temp = buf.readUnsignedByte();
- for (int i = 3; i >= 0; i--) {
- int n = (temp >> (2 * i)) & 0x03;
- if (!temps.contains(n)) {
- temps.add(n);
- }
- }
- for (int n : temps) {
- position.set(Event.PREFIX_TEMP + n, buf.readUnsignedByte());
+ Set<Integer> temps = new LinkedHashSet<>();
+ int temp = buf.readUnsignedByte();
+ for (int i = 3; i >= 0; i--) {
+ n = (temp >> (2 * i)) & 0x03;
+ if (!temps.contains(n)) {
+ temps.add(n);
}
}
+ for (int i : temps) {
+ position.set(Event.PREFIX_TEMP + n, buf.readUnsignedByte());
+ }
break;
case 28:
position.set("weight", buf.readUnsignedShort());
@@ -177,19 +173,17 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
position.set(Event.KEY_RPM, buf.readUnsignedByte() * 50);
break;
case 107:
- {
- int fuel = buf.readUnsignedShort();
- switch (fuel >> 14) {
- case 1:
- position.set(Event.KEY_FUEL, (fuel & 0x3fff) * 0.4 + "%");
- break;
- case 2:
- position.set(Event.KEY_FUEL, (fuel & 0x3fff) * 0.5 + " l");
- break;
- case 3:
- position.set(Event.KEY_FUEL, (fuel & 0x3fff) * -0.5 + " l");
- break;
- }
+ int fuel = buf.readUnsignedShort();
+ switch (fuel >> 14) {
+ case 1:
+ position.set(Event.KEY_FUEL, (fuel & 0x3fff) * 0.4 + "%");
+ break;
+ case 2:
+ position.set(Event.KEY_FUEL, (fuel & 0x3fff) * 0.5 + " l");
+ break;
+ case 3:
+ position.set(Event.KEY_FUEL, (fuel & 0x3fff) * -0.5 + " l");
+ break;
}
break;
case 108: