From 02d7fc58a11c38c82b18ea13294b163bd366b428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=A2=A6=E8=BF=9C?= <1063331231@qq.com> Date: Thu, 31 Jul 2025 14:49:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B3=B5=E6=A0=B9=E6=8D=AEco?= =?UTF-8?q?de=E7=A7=BB=E5=8A=A8=E6=8C=87=E4=BB=A4=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=AD=A3=E4=BC=A0=E4=B8=9A=E5=8A=A1=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handacid/app/command/control/PumpRotateStartCommand.java | 6 +++++- .../com/iflytop/handacid/app/service/ChannelCtrlService.java | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iflytop/handacid/app/command/control/PumpRotateStartCommand.java b/src/main/java/com/iflytop/handacid/app/command/control/PumpRotateStartCommand.java index ea896fb..0de86cd 100644 --- a/src/main/java/com/iflytop/handacid/app/command/control/PumpRotateStartCommand.java +++ b/src/main/java/com/iflytop/handacid/app/command/control/PumpRotateStartCommand.java @@ -40,13 +40,17 @@ public class PumpRotateStartCommand extends BaseCommandHandler { if (direction == null) { throw new IllegalArgumentException("参数 direction 不能为空"); } + Double position = commandDTO.getDoubleParam("position"); + if (position == null) { + throw new IllegalArgumentException("参数 position 不能为空"); + } return runAsync(() -> { if (Direction.FORWARD.equals(direction)) { DeviceCommand getPositionDeviceCommand = channelCtrlService.getPumpForwardRotateCommandByChannel(channelCode); CommandFuture positionCommandFuture = deviceCommandService.sendCommand(getPositionDeviceCommand); CommandUtil.wait(positionCommandFuture); Integer currentPosition = (Integer) positionCommandFuture.getResponseResult().get("position"); - DeviceCommand deviceCommand = channelCtrlService.getPumpForwardRotateCommandByChannel(channelCode); + DeviceCommand deviceCommand = channelCtrlService.getPumpMoveCommandByChannel(channelCode, position); CommandFuture commandFuture = deviceCommandService.sendCommand(deviceCommand); CommandUtil.wait(commandFuture); Integer newPosition = (Integer) commandFuture.getResponseResult().get("position"); 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 fc9adf6..ecfe275 100644 --- a/src/main/java/com/iflytop/handacid/app/service/ChannelCtrlService.java +++ b/src/main/java/com/iflytop/handacid/app/service/ChannelCtrlService.java @@ -165,6 +165,18 @@ public class ChannelCtrlService { }; } + /** + * 根据通道code获取泵移动指令 + */ + public DeviceCommand getPumpMoveCommandByChannel(ChannelCode channelCode, Double position) { + return switch (channelCode) { + case CHANNEL_1 -> DeviceCommandGenerator.pump1MoveBy(position); + case CHANNEL_2 -> DeviceCommandGenerator.pump2MoveBy(position); + case CHANNEL_3 -> DeviceCommandGenerator.pump3MoveBy(position); + case CHANNEL_4 -> DeviceCommandGenerator.pump4MoveBy(position); + }; + } + /** * 根据通道code获取泵转数指令