From da9273e16e68485d3c9f3b6418a5afc04cdf621f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=A2=A6=E8=BF=9C?= <1063331231@qq.com> Date: Mon, 26 May 2025 11:21:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E6=94=B9=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sgs/app/cmd/debug/DebugDoorOpenCommand.java | 12 ++++--- .../sgs/app/cmd/debug/DebugDoorSetCommand.java | 37 --------------------- .../cmd/debug/DebugLiquidMotorMoveByCommand.java | 6 ++-- .../cmd/debug/DebugLiquidMotorMoveToCommand.java | 8 +++-- .../app/cmd/debug/DebugLiquidMotorSetCommand.java | 37 --------------------- .../cmd/debug/DebugLiquidPumpMoveByCommand.java | 21 ++++++------ .../app/cmd/debug/DebugLiquidPumpSetCommand.java | 38 ---------------------- .../sgs/app/cmd/debug/DebugMotorXSetCommand.java | 37 --------------------- .../sgs/app/cmd/debug/DebugMotorZSetCommand.java | 37 --------------------- .../sgs/common/cmd/DeviceCommandGenerator.java | 13 ++++++-- 10 files changed, 37 insertions(+), 209 deletions(-) delete mode 100644 src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorSetCommand.java delete mode 100644 src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorSetCommand.java delete mode 100644 src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpSetCommand.java delete mode 100644 src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXSetCommand.java delete mode 100644 src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZSetCommand.java diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorOpenCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorOpenCommand.java index 0d53540..d6e180d 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorOpenCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorOpenCommand.java @@ -1,5 +1,6 @@ package com.iflytop.sgs.app.cmd.debug; +import cn.hutool.core.lang.Assert; import com.iflytop.sgs.app.core.BaseCommandHandler; import com.iflytop.sgs.app.model.dto.CmdDTO; import com.iflytop.sgs.app.model.entity.DevicePosition; @@ -30,11 +31,14 @@ public class DebugDoorOpenCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) { + double speed = cmdDTO.getDoubleParam("speed"); + DevicePosition devicePosition = devicePositionService.getPosition(DevicePositionCode.doorOpen); return runAsync(() -> { - DevicePosition devicePosition = devicePositionService.getPosition(DevicePositionCode.doorOpen); - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.doorMove(devicePosition.getDistance()); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - CommandUtil.wait(deviceCommandFuture); + CommandFuture deviceCommandSetFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), DeviceCommandGenerator.doorSet(speed)); + CommandUtil.wait(deviceCommandSetFuture); + + CommandFuture deviceCommandOpenFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), DeviceCommandGenerator.doorMove(devicePosition.getDistance())); + CommandUtil.wait(deviceCommandOpenFuture); }); } } diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorSetCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorSetCommand.java deleted file mode 100644 index 2a74010..0000000 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorSetCommand.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.iflytop.sgs.app.cmd.debug; - -import com.iflytop.sgs.app.core.BaseCommandHandler; -import com.iflytop.sgs.app.model.dto.CmdDTO; -import com.iflytop.sgs.app.service.device.DeviceCommandService; -import com.iflytop.sgs.common.annotation.CommandMapping; -import com.iflytop.sgs.common.cmd.CommandFuture; -import com.iflytop.sgs.common.cmd.DeviceCommandBundle; -import com.iflytop.sgs.common.cmd.DeviceCommandGenerator; -import com.iflytop.sgs.common.utils.CommandUtil; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 门设置参数 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("door_set") -public class DebugDoorSetCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - double speed = cmdDTO.getDoubleParam("speed"); - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.doorSet(speed); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - CommandUtil.wait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorMoveByCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorMoveByCommand.java index 1e91347..f4e35d3 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorMoveByCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorMoveByCommand.java @@ -45,19 +45,19 @@ public class DebugLiquidMotorMoveByCommand extends BaseCommandHandler { return; } if (distance != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(distance); + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.motorLiquidMoveBy(distance); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandUtil.wait(deviceCommandFuture); } if (distance != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(-distance); + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.motorLiquidMoveBy(-distance); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandUtil.wait(deviceCommandFuture); } } } else { if (distance != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(distance); + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.motorLiquidMoveBy(distance); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandUtil.wait(deviceCommandFuture); } diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorMoveToCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorMoveToCommand.java index ea353cd..86d519f 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorMoveToCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorMoveToCommand.java @@ -28,10 +28,12 @@ public class DebugLiquidMotorMoveToCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) throws Exception { double position = cmdDTO.getDoubleParam("position"); + double speed = cmdDTO.getDoubleParam("speed"); return runAsync(() -> { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.motorLiquidSet(position); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - CommandUtil.wait(deviceCommandFuture); + CommandFuture deviceSetCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), DeviceCommandGenerator.motorLiquidSet(speed)); + CommandUtil.wait(deviceSetCommandFuture); + CommandFuture deviceMoveCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), DeviceCommandGenerator.motorLiquidMove(position)); + CommandUtil.wait(deviceMoveCommandFuture); }); } } diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorSetCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorSetCommand.java deleted file mode 100644 index 4e32718..0000000 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorSetCommand.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.iflytop.sgs.app.cmd.debug; - -import com.iflytop.sgs.app.core.BaseCommandHandler; -import com.iflytop.sgs.app.model.dto.CmdDTO; -import com.iflytop.sgs.app.service.device.DeviceCommandService; -import com.iflytop.sgs.common.annotation.CommandMapping; -import com.iflytop.sgs.common.cmd.CommandFuture; -import com.iflytop.sgs.common.cmd.DeviceCommandBundle; -import com.iflytop.sgs.common.cmd.DeviceCommandGenerator; -import com.iflytop.sgs.common.utils.CommandUtil; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 加液臂电机设置参数 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("liquid_motor_set") -public class DebugLiquidMotorSetCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - double speed = cmdDTO.getDoubleParam("speed"); - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.motorLiquidSet(speed); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - CommandUtil.wait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpMoveByCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpMoveByCommand.java index fee13ba..022ec74 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpMoveByCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpMoveByCommand.java @@ -29,14 +29,13 @@ public class DebugLiquidPumpMoveByCommand extends BaseCommandHandler { public CompletableFuture handle(CmdDTO cmdDTO) { this.stop = false; return runAsync(() -> { - Double dimDistance = cmdDTO.getDoubleParam("distance"); + Double distance = cmdDTO.getDoubleParam("distance"); - Double dimVelocity = cmdDTO.getDoubleParam("velocity"); + Double speed = cmdDTO.getDoubleParam("speed"); Integer times = cmdDTO.getIntegerParam("times"); - Integer channel = 1; - if (dimVelocity != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpSet(dimVelocity, channel); + if (speed != null) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpSet(speed); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandUtil.wait(deviceCommandFuture); } @@ -45,20 +44,20 @@ public class DebugLiquidPumpMoveByCommand extends BaseCommandHandler { if (stop) { return; } - if (dimDistance != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(dimDistance); + if (distance != null) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(distance); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandUtil.wait(deviceCommandFuture); } - if (dimDistance != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(-dimDistance); + if (distance != null) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(-distance); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandUtil.wait(deviceCommandFuture); } } } else { - if (dimDistance != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(dimDistance); + if (distance != null) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(distance); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandUtil.wait(deviceCommandFuture); } diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpSetCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpSetCommand.java deleted file mode 100644 index 9252da9..0000000 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpSetCommand.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.iflytop.sgs.app.cmd.debug; - -import com.iflytop.sgs.app.core.BaseCommandHandler; -import com.iflytop.sgs.app.model.dto.CmdDTO; -import com.iflytop.sgs.app.service.device.DeviceCommandService; -import com.iflytop.sgs.common.annotation.CommandMapping; -import com.iflytop.sgs.common.cmd.CommandFuture; -import com.iflytop.sgs.common.cmd.DeviceCommandBundle; -import com.iflytop.sgs.common.cmd.DeviceCommandGenerator; -import com.iflytop.sgs.common.utils.CommandUtil; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 加液臂电机设置参数 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("motor_liquid_set") -public class DebugLiquidPumpSetCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - double speed = cmdDTO.getDoubleParam("speed"); - Integer channel = 1; - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpSet(speed, channel); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - CommandUtil.wait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXSetCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXSetCommand.java deleted file mode 100644 index 36f9f88..0000000 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXSetCommand.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.iflytop.sgs.app.cmd.debug; - -import com.iflytop.sgs.app.core.BaseCommandHandler; -import com.iflytop.sgs.app.model.dto.CmdDTO; -import com.iflytop.sgs.app.service.device.DeviceCommandService; -import com.iflytop.sgs.common.annotation.CommandMapping; -import com.iflytop.sgs.common.cmd.CommandFuture; -import com.iflytop.sgs.common.cmd.DeviceCommandBundle; -import com.iflytop.sgs.common.cmd.DeviceCommandGenerator; -import com.iflytop.sgs.common.utils.CommandUtil; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 门设置参数 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("x_set") -public class DebugMotorXSetCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - double speed = cmdDTO.getDoubleParam("speed"); - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.doorSet(speed); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - CommandUtil.wait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZSetCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZSetCommand.java deleted file mode 100644 index cae3c42..0000000 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZSetCommand.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.iflytop.sgs.app.cmd.debug; - -import com.iflytop.sgs.app.core.BaseCommandHandler; -import com.iflytop.sgs.app.model.dto.CmdDTO; -import com.iflytop.sgs.app.service.device.DeviceCommandService; -import com.iflytop.sgs.common.annotation.CommandMapping; -import com.iflytop.sgs.common.cmd.CommandFuture; -import com.iflytop.sgs.common.cmd.DeviceCommandBundle; -import com.iflytop.sgs.common.cmd.DeviceCommandGenerator; -import com.iflytop.sgs.common.utils.CommandUtil; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * z轴电机参数设置 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("z_set") -public class DebugMotorZSetCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - double speed = cmdDTO.getDoubleParam("speed"); - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZSet(speed); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - CommandUtil.wait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java b/src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java index 9aa7c2f..e3213a2 100644 --- a/src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java +++ b/src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java @@ -193,16 +193,25 @@ public class DeviceCommandGenerator { return controlMotorCmd(CmdDevice.liquid_motor, CmdAction.move, params, "加液升降电机移动"); } + /** + * 加液机械臂 相对移动 + * + * @param position 加液量 单位mL + */ + public static DeviceCommandBundle motorLiquidMoveBy(Double position) { + DeviceCommandParams params = new DeviceCommandParams(); + params.setPosition(position); + return controlCmd(CmdDevice.liquid_motor, CmdAction.move_by, params, "加液机械臂 相对移动"); + } /** * 加液泵设置参数 * * @param speed 速度 单位 mm/s */ - public static DeviceCommandBundle liquidPumpSet(Double speed,Integer channel) { + public static DeviceCommandBundle liquidPumpSet(Double speed) { DeviceCommandParams params = new DeviceCommandParams(); params.setSpeed(speed); - params.setChannel(channel); return setInfoCmd(CmdDevice.liquid_pump, CmdAction.set, params, "加液泵设置参数"); }