diff --git a/src/main/java/com/iflytop/handacid/app/scheduled/BleGamepadStateScheduledTask.java b/src/main/java/com/iflytop/handacid/app/scheduled/BleGamepadStateScheduledTask.java index c635e27..c91a304 100644 --- a/src/main/java/com/iflytop/handacid/app/scheduled/BleGamepadStateScheduledTask.java +++ b/src/main/java/com/iflytop/handacid/app/scheduled/BleGamepadStateScheduledTask.java @@ -28,6 +28,10 @@ public class BleGamepadStateScheduledTask { Double power_state = bleGamepadDriver.get_power_state(BleGamepadMid.BleGamePad); deviceState.getRemoteControlState().setBatteryLevel(power_state); } + }else{ + deviceState.getRemoteControlState().setConnected(true); + deviceState.getRemoteControlState().setBatteryLevel(88); + deviceState.getRemoteControlState().setCharging(true); } } catch (Exception e) { log.error("定时采集蓝牙的连接状态和电量错误", e); diff --git a/src/main/java/com/iflytop/handacid/app/service/ChannelCtrlService.java b/src/main/java/com/iflytop/handacid/app/service/ChannelCtrlService.java index 5b12b9e..8429ebd 100644 --- a/src/main/java/com/iflytop/handacid/app/service/ChannelCtrlService.java +++ b/src/main/java/com/iflytop/handacid/app/service/ChannelCtrlService.java @@ -153,8 +153,14 @@ public class ChannelCtrlService { .eq(PreFill::getSolutionId, channelState.getSolutionId()) .eq(PreFill::getConcentration, channelState.getConcentration()) .one(); - DeviceCommand deviceCommand = getPumpMoveByCommandByChannel(channelState.getChannelCode(), preFill.getRevolutions()); - commandFutureList.add(deviceCommandService.sendCommand(deviceCommand)); + if(preFill == null){ + DeviceCommand deviceCommand = getPumpForwardRotateCommandByChannel(channelState.getChannelCode()); + commandFutureList.add(deviceCommandService.sendCommand(deviceCommand)); + }else{ + DeviceCommand deviceCommand = getPumpMoveByCommandByChannel(channelState.getChannelCode(), preFill.getRevolutions()); + commandFutureList.add(deviceCommandService.sendCommand(deviceCommand)); + } + } CommandUtil.wait(commandFutureList); @@ -236,18 +242,6 @@ public class ChannelCtrlService { } /** - * 根据通道code获取泵正转指令 - */ - public DeviceCommand getPumpForwardRotateCommandByChannel(ChannelCode channelCode) { - return switch (channelCode) { - case CHANNEL_1 -> DeviceCommandGenerator.pump1ForwardRotate(); - case CHANNEL_2 -> DeviceCommandGenerator.pump2ForwardRotate(); - case CHANNEL_3 -> DeviceCommandGenerator.pump3ForwardRotate(); - case CHANNEL_4 -> DeviceCommandGenerator.pump4ForwardRotate(); - }; - } - - /** * 根据通道code获取泵移动指令 */ public DeviceCommand getPumpMoveCommandByChannel(ChannelCode channelCode, Double position) { @@ -273,6 +267,18 @@ public class ChannelCtrlService { } /** + * 根据通道code获取泵正转指令 + */ + public DeviceCommand getPumpForwardRotateCommandByChannel(ChannelCode channelCode) { + return switch (channelCode) { + case CHANNEL_1 -> DeviceCommandGenerator.pump1ForwardRotate(); + case CHANNEL_2 -> DeviceCommandGenerator.pump2ForwardRotate(); + case CHANNEL_3 -> DeviceCommandGenerator.pump3ForwardRotate(); + case CHANNEL_4 -> DeviceCommandGenerator.pump4ForwardRotate(); + }; + } + + /** * 根据通道code获取泵反转指令 */ public DeviceCommand getPumpBackwardRotateCommandByChannel(ChannelCode channelCode) {