aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEdward Valley <ed.valley@yandex.com>2023-07-09 18:04:33 -0400
committerEdward Valley <ed.valley@yandex.com>2023-07-09 18:04:33 -0400
commit60522a68d292541c44efa3736967f471d4347a50 (patch)
treeb48933a409ce8255c0e8a3ee8b7520d34ead5dbc /src
parent97240fd579c2d01f43a5b7ba1f9b16bad19085f2 (diff)
downloadtrackermap-server-60522a68d292541c44efa3736967f471d4347a50.tar.gz
trackermap-server-60522a68d292541c44efa3736967f471d4347a50.tar.bz2
trackermap-server-60522a68d292541c44efa3736967f471d4347a50.zip
Follow refactor suggestion
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java b/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java
index 6a5b67669..5745909c7 100644
--- a/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java
@@ -110,7 +110,7 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder {
}
}
- private String decodeEvent(String event, Position position, String deviceModel) {
+ private String decodeEvent(String event, Position position, String model) {
if (event.length() == 1) {
char inputStatus = event.charAt(0);
@@ -118,7 +118,7 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder {
int inputStatusInt = inputStatus - 'A';
position.set(Position.PREFIX_IN + 1, (boolean) BitUtil.check(inputStatusInt, 0));
position.set(Position.PREFIX_IN + 2, (boolean) BitUtil.check(inputStatusInt, 1));
- if ("SF-Lite".equals(deviceModel)) {
+ if ("SF-Lite".equals(model)) {
position.set(Position.PREFIX_IN + 3, false);
}
return null;
@@ -126,7 +126,7 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder {
int inputStatusInt = inputStatus - 'O';
position.set(Position.PREFIX_IN + 1, (boolean) BitUtil.check(inputStatusInt, 0));
position.set(Position.PREFIX_IN + 2, (boolean) BitUtil.check(inputStatusInt, 1));
- if ("SF-Lite".equals(deviceModel)) {
+ if ("SF-Lite".equals(model)) {
position.set(Position.PREFIX_IN + 3, true);
}
return null;
@@ -226,11 +226,7 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- String deviceModel = null;
- Device device = getCacheManager().getObject(Device.class, deviceSession.getDeviceId());
- if (device != null) {
- deviceModel = device.getModel();
- }
+ String model = getCacheManager().getObject(Device.class, deviceSession.getDeviceId()).getModel();
Position position = new Position(getProtocolName());
@@ -253,13 +249,13 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder {
String event = parser.next();
position.set(Position.KEY_ALARM, decodeAlarm(event));
- position.set(Position.KEY_EVENT, decodeEvent(event, position, deviceModel));
+ position.set(Position.KEY_EVENT, decodeEvent(event, position, model));
position.set(Position.KEY_BATTERY, Double.parseDouble(parser.next().replaceAll("\\.", "")) * 0.001);
position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
position.set(Position.KEY_GPS, parser.nextInt());
position.set(Position.PREFIX_ADC + 1, parser.nextDouble() * 0.001);
- if ("AVL110".equals(deviceModel) || "AVL120".equals(deviceModel)) {
+ if ("AVL110".equals(model) || "AVL120".equals(model)) {
position.set(Position.PREFIX_ADC + 2, parser.nextDouble() * 0.001);
} else {
parser.next();