From 536888fd7e64f00ca9693ea9b41624360949c8ab Mon Sep 17 00:00:00 2001 From: edvalley <52469633+edvalley@users.noreply.github.com> Date: Sun, 9 Jul 2023 14:01:12 -0400 Subject: Conditionally set digital input 3 and analog input 2 according to device model --- .../traccar/protocol/LaipacProtocolDecoder.java | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java b/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java index c2146c22d..df0f1e2ed 100644 --- a/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java @@ -113,17 +113,22 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder { if (event.length() == 1) { char inputStatus = event.charAt(0); + String deviceModel = device.getModel(); if (inputStatus >= 'A' && inputStatus <= 'D') { int inputStatusInt = inputStatus - 'A'; - position.set(Position.PREFIX_IN + 1, BitUtil.check(inputStatusInt, 0)); - position.set(Position.PREFIX_IN + 2, BitUtil.check(inputStatusInt, 1)); - position.set(Position.PREFIX_IN + 3, 0); + position.set(Position.PREFIX_IN + 1, (boolean) BitUtil.check(inputStatusInt, 0)); + position.set(Position.PREFIX_IN + 2, (boolean) BitUtil.check(inputStatusInt, 1)); + if (deviceModel == "SF-Lite") { + position.set(Position.PREFIX_IN + 3, false); + } return null; } else if (inputStatus >= 'O' && inputStatus <= 'R') { int inputStatusInt = inputStatus - 'O'; - position.set(Position.PREFIX_IN + 1, BitUtil.check(inputStatusInt, 0)); - position.set(Position.PREFIX_IN + 2, BitUtil.check(inputStatusInt, 1)); - position.set(Position.PREFIX_IN + 3, 1); + position.set(Position.PREFIX_IN + 1, (boolean) BitUtil.check(inputStatusInt, 0)); + position.set(Position.PREFIX_IN + 2, (boolean) BitUtil.check(inputStatusInt, 1)); + if (deviceModel == "SF-Lite") { + position.set(Position.PREFIX_IN + 3, true); + } return null; } } @@ -247,7 +252,11 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder { 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); - position.set(Position.PREFIX_ADC + 2, parser.nextDouble() * 0.001); + + String deviceModel = device.getModel(); + if (deviceModel == "AVL110" || deviceModel == "AVL120") { + position.set(Position.PREFIX_ADC + 2, parser.nextDouble() * 0.001); + } Integer lac = parser.nextHexInt(); Integer cid = parser.nextHexInt(); -- cgit v1.2.3