diff options
author | Anton Tananaev <anton@traccar.org> | 2024-07-06 19:47:06 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2024-07-06 19:47:06 -0700 |
commit | 2005fd55347816cf4a86b66ae97bc245f53f0bcd (patch) | |
tree | a62fce83953b89530c968ef2c95828a80ff18cae /src/main/java/org/traccar/protocol/DmtProtocolDecoder.java | |
parent | b8390005722dd1cdb24d762797ef3f98ebc37755 (diff) | |
download | trackermap-server-2005fd55347816cf4a86b66ae97bc245f53f0bcd.tar.gz trackermap-server-2005fd55347816cf4a86b66ae97bc245f53f0bcd.tar.bz2 trackermap-server-2005fd55347816cf4a86b66ae97bc245f53f0bcd.zip |
Update switch statements
Diffstat (limited to 'src/main/java/org/traccar/protocol/DmtProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/DmtProtocolDecoder.java | 58 |
1 files changed, 18 insertions, 40 deletions
diff --git a/src/main/java/org/traccar/protocol/DmtProtocolDecoder.java b/src/main/java/org/traccar/protocol/DmtProtocolDecoder.java index f8295543f..a18e8bc53 100644 --- a/src/main/java/org/traccar/protocol/DmtProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/DmtProtocolDecoder.java @@ -201,24 +201,12 @@ public class DmtProtocolDecoder extends BaseProtocolDecoder { while (buf.readerIndex() < fieldEnd) { int number = buf.readUnsignedByte(); switch (number) { - case 1: - position.set(Position.KEY_BATTERY, buf.readUnsignedShortLE() * 0.001); - break; - case 2: - position.set(Position.KEY_POWER, buf.readUnsignedShortLE() * 0.01); - break; - case 3: - position.set(Position.KEY_DEVICE_TEMP, buf.readShortLE() * 0.01); - break; - case 4: - position.set(Position.KEY_RSSI, buf.readUnsignedShortLE()); - break; - case 5: - position.set("solarPower", buf.readUnsignedShortLE() * 0.001); - break; - default: - position.set(Position.PREFIX_IO + number, buf.readUnsignedShortLE()); - break; + case 1 -> position.set(Position.KEY_BATTERY, buf.readUnsignedShortLE() * 0.001); + case 2 -> position.set(Position.KEY_POWER, buf.readUnsignedShortLE() * 0.01); + case 3 -> position.set(Position.KEY_DEVICE_TEMP, buf.readShortLE() * 0.01); + case 4 -> position.set(Position.KEY_RSSI, buf.readUnsignedShortLE()); + case 5 -> position.set("solarPower", buf.readUnsignedShortLE() * 0.001); + default -> position.set(Position.PREFIX_IO + number, buf.readUnsignedShortLE()); } } @@ -249,28 +237,18 @@ public class DmtProtocolDecoder extends BaseProtocolDecoder { } private String decodeAlarm(int value) { - switch (value) { - case 12: - return Position.ALARM_BRAKING; - case 13: - return Position.ALARM_ACCELERATION; - case 14: - return Position.ALARM_CORNERING; - case 18: - return Position.ALARM_OVERSPEED; - case 20: - return Position.ALARM_TOW; - case 23: - return Position.ALARM_ACCIDENT; - case 29: - return Position.ALARM_TAMPERING; - case 44: - return Position.ALARM_GEOFENCE_ENTER; - case 45: - return Position.ALARM_GEOFENCE_EXIT; - default: - return null; - } + return switch (value) { + case 12 -> Position.ALARM_BRAKING; + case 13 -> Position.ALARM_ACCELERATION; + case 14 -> Position.ALARM_CORNERING; + case 18 -> Position.ALARM_OVERSPEED; + case 20 -> Position.ALARM_TOW; + case 23 -> Position.ALARM_ACCIDENT; + case 29 -> Position.ALARM_TAMPERING; + case 44 -> Position.ALARM_GEOFENCE_ENTER; + case 45 -> Position.ALARM_GEOFENCE_EXIT; + default -> null; + }; } @Override |