aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java180
1 files changed, 44 insertions, 136 deletions
diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
index 373e1c91c..edcd0fa8b 100644
--- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
@@ -229,32 +229,24 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
switch (parser.nextHexInt()) {
- case 0x16:
- case 0x1A:
- case 0x12:
+ case 0x16, 0x1A, 0x12 -> {
position.set(Position.KEY_IGNITION, false);
position.set(Position.KEY_MOTION, true);
- break;
- case 0x11:
+ }
+ case 0x11 -> {
position.set(Position.KEY_IGNITION, false);
position.set(Position.KEY_MOTION, false);
- break;
- case 0x21:
+ }
+ case 0x21 -> {
position.set(Position.KEY_IGNITION, true);
position.set(Position.KEY_MOTION, false);
- break;
- case 0x22:
+ }
+ case 0x22 -> {
position.set(Position.KEY_IGNITION, true);
position.set(Position.KEY_MOTION, true);
- break;
- case 0x41:
- position.set(Position.KEY_MOTION, false);
- break;
- case 0x42:
- position.set(Position.KEY_MOTION, true);
- break;
- default:
- break;
+ }
+ case 0x41 -> position.set(Position.KEY_MOTION, false);
+ case 0x42 -> position.set(Position.KEY_MOTION, true);
}
position.set(Position.KEY_ICCID, parser.next());
@@ -1495,19 +1487,9 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_IGNITION, reportType % 0x10 == 1);
} else if (type.equals("HBM")) {
switch (reportType % 0x10) {
- case 0:
- case 3:
- position.set(Position.KEY_ALARM, Position.ALARM_BRAKING);
- break;
- case 1:
- case 4:
- position.set(Position.KEY_ALARM, Position.ALARM_ACCELERATION);
- break;
- case 2:
- position.set(Position.KEY_ALARM, Position.ALARM_CORNERING);
- break;
- default:
- break;
+ case 0, 3 -> position.set(Position.KEY_ALARM, Position.ALARM_BRAKING);
+ case 1, 4 -> position.set(Position.KEY_ALARM, Position.ALARM_ACCELERATION);
+ case 2 -> position.set(Position.KEY_ALARM, Position.ALARM_CORNERING);
}
}
@@ -1595,45 +1577,17 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
decodeDeviceTime(position, parser);
switch (type) {
- case "TOW":
- position.set(Position.KEY_ALARM, Position.ALARM_TOW);
- break;
- case "IDL":
- position.set(Position.KEY_ALARM, Position.ALARM_IDLE);
- break;
- case "PNA":
- position.set(Position.KEY_ALARM, Position.ALARM_POWER_ON);
- break;
- case "PFA":
- position.set(Position.KEY_ALARM, Position.ALARM_POWER_OFF);
- break;
- case "EPN":
- case "MPN":
- position.set(Position.KEY_ALARM, Position.ALARM_POWER_RESTORED);
- break;
- case "EPF":
- case "MPF":
- position.set(Position.KEY_ALARM, Position.ALARM_POWER_CUT);
- break;
- case "BPL":
- position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY);
- break;
- case "STT":
- position.set(Position.KEY_ALARM, Position.ALARM_MOVEMENT);
- break;
- case "SWG":
- position.set(Position.KEY_ALARM, Position.ALARM_GEOFENCE);
- break;
- case "TMP":
- case "TEM":
- position.set(Position.KEY_ALARM, Position.ALARM_TEMPERATURE);
- break;
- case "JDR":
- case "JDS":
- position.set(Position.KEY_ALARM, Position.ALARM_JAMMING);
- break;
- default:
- break;
+ case "TOW" -> position.set(Position.KEY_ALARM, Position.ALARM_TOW);
+ case "IDL" -> position.set(Position.KEY_ALARM, Position.ALARM_IDLE);
+ case "PNA" -> position.set(Position.KEY_ALARM, Position.ALARM_POWER_ON);
+ case "PFA" -> position.set(Position.KEY_ALARM, Position.ALARM_POWER_OFF);
+ case "EPN", "MPN" -> position.set(Position.KEY_ALARM, Position.ALARM_POWER_RESTORED);
+ case "EPF", "MPF" -> position.set(Position.KEY_ALARM, Position.ALARM_POWER_CUT);
+ case "BPL" -> position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY);
+ case "STT" -> position.set(Position.KEY_ALARM, Position.ALARM_MOVEMENT);
+ case "SWG" -> position.set(Position.KEY_ALARM, Position.ALARM_GEOFENCE);
+ case "TMP", "TEM" -> position.set(Position.KEY_ALARM, Position.ALARM_TEMPERATURE);
+ case "JDR", "JDS" -> position.set(Position.KEY_ALARM, Position.ALARM_JAMMING);
}
return position;
@@ -1657,72 +1611,26 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
if (sentence.startsWith("+ACK")) {
result = decodeAck(channel, remoteAddress, values);
} else {
- switch (type) {
- case "INF":
- result = decodeInf(channel, remoteAddress, sentence);
- break;
- case "OBD":
- result = decodeObd(channel, remoteAddress, sentence);
- break;
- case "CAN":
- result = decodeCan(channel, remoteAddress, values);
- break;
- case "CTN":
- case "FRI":
- case "GEO":
- case "RTL":
- case "DOG":
- case "STR":
- result = decodeFri(channel, remoteAddress, sentence);
- break;
- case "ERI":
- result = decodeEri(channel, remoteAddress, values);
- break;
- case "IGN":
- case "IGF":
- case "VGN":
- case "VGF":
- result = decodeIgn(channel, remoteAddress, values, type);
- break;
- case "LSW":
- case "TSW":
- result = decodeLsw(channel, remoteAddress, sentence);
- break;
- case "IDA":
- result = decodeIda(channel, remoteAddress, sentence);
- break;
- case "WIF":
- result = decodeWif(channel, remoteAddress, sentence);
- break;
- case "GSM":
- result = decodeGsm(channel, remoteAddress, sentence);
- break;
- case "VER":
- result = decodeVer(channel, remoteAddress, sentence);
- break;
- case "PNA":
- case "PFA":
- result = decodePna(channel, remoteAddress, sentence);
- break;
- case "DAR":
- result = decodeDar(channel, remoteAddress, sentence);
- break;
- case "DTT":
- result = decodeDtt(channel, remoteAddress, sentence);
- break;
- case "BAA":
- result = decodeBaa(channel, remoteAddress, sentence);
- break;
- case "BID":
- result = decodeBid(channel, remoteAddress, sentence);
- break;
- case "LSA":
- result = decodeLsa(channel, remoteAddress, sentence);
- break;
- default:
- result = decodeOther(channel, remoteAddress, sentence, type);
- break;
- }
+ result = switch (type) {
+ case "INF" -> decodeInf(channel, remoteAddress, sentence);
+ case "OBD" -> decodeObd(channel, remoteAddress, sentence);
+ case "CAN" -> decodeCan(channel, remoteAddress, values);
+ case "CTN", "FRI", "GEO", "RTL", "DOG", "STR" -> decodeFri(channel, remoteAddress, sentence);
+ case "ERI" -> decodeEri(channel, remoteAddress, values);
+ case "IGN", "IGF", "VGN", "VGF" -> decodeIgn(channel, remoteAddress, values, type);
+ case "LSW", "TSW" -> decodeLsw(channel, remoteAddress, sentence);
+ case "IDA" -> decodeIda(channel, remoteAddress, sentence);
+ case "WIF" -> decodeWif(channel, remoteAddress, sentence);
+ case "GSM" -> decodeGsm(channel, remoteAddress, sentence);
+ case "VER" -> decodeVer(channel, remoteAddress, sentence);
+ case "PNA", "PFA" -> decodePna(channel, remoteAddress, sentence);
+ case "DAR" -> decodeDar(channel, remoteAddress, sentence);
+ case "DTT" -> decodeDtt(channel, remoteAddress, sentence);
+ case "BAA" -> decodeBaa(channel, remoteAddress, sentence);
+ case "BID" -> decodeBid(channel, remoteAddress, sentence);
+ case "LSA" -> decodeLsa(channel, remoteAddress, sentence);
+ default -> decodeOther(channel, remoteAddress, sentence, type);
+ };
if (result == null) {
result = decodeBasic(channel, remoteAddress, sentence, type);