From 4182a99c835859569dc7d5afe03f07c7400ba6d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Tue, 13 May 2025 09:29:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E7=BB=9F=E4=B8=80=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/cmd/debug/ColdTrapStartRecycleCommand.java | 35 ------ .../debug/ColdTrapStartRefrigerationCommand.java | 35 ------ .../app/cmd/debug/ColdTrapStopHeatingCommand.java | 27 ----- .../app/cmd/debug/ColdTrapStopRecycleCommand.java | 35 ------ .../debug/ColdTrapStopRefrigerationCommand.java | 35 ------ .../cmd/debug/CoverElevatorLiftDownCommand.java | 43 ------- .../app/cmd/debug/CoverElevatorLiftUpCommand.java | 44 ------- .../app/cmd/debug/CoverElevatorResetCommand.java | 35 ------ .../gd/app/cmd/debug/CoverElevatorStopCommand.java | 35 ------ .../debug/DebugColdTrapStartRecycleCommand.java | 35 ++++++ .../DebugColdTrapStartRefrigerationCommand.java | 35 ++++++ .../cmd/debug/DebugColdTrapStopRecycleCommand.java | 35 ++++++ .../DebugColdTrapStopRefrigerationCommand.java | 35 ++++++ .../debug/DebugCoverElevatorLiftDownCommand.java | 43 +++++++ .../cmd/debug/DebugCoverElevatorLiftUpCommand.java | 44 +++++++ .../cmd/debug/DebugCoverElevatorResetCommand.java | 35 ++++++ .../cmd/debug/DebugCoverElevatorStopCommand.java | 35 ++++++ .../gd/app/cmd/debug/DebugDoorCloseCommand.java | 35 ++++++ .../gd/app/cmd/debug/DebugDoorOpenCommand.java | 40 +++++++ .../gd/app/cmd/debug/DebugDoorStopCommand.java | 35 ++++++ .../gd/app/cmd/debug/DebugFanStartCommand.java | 47 ++++++++ .../gd/app/cmd/debug/DebugFanStopCommand.java | 47 ++++++++ .../gd/app/cmd/debug/DebugHeaterStartCommand.java | 48 ++++++++ .../gd/app/cmd/debug/DebugHeaterStopCommand.java | 47 ++++++++ .../app/cmd/debug/DebugHoldingJawCloseCommand.java | 65 +++++++++++ .../app/cmd/debug/DebugHoldingJawOpenCommand.java | 72 ++++++++++++ .../app/cmd/debug/DebugHoldingJawPauseCommand.java | 37 ++++++ .../app/cmd/debug/DebugLiquidArmResetCommand.java | 32 ++++++ .../app/cmd/debug/DebugLiquidArmRotateCommand.java | 62 ++++++++++ .../app/cmd/debug/DebugLiquidArmStopCommand.java | 47 ++++++++ .../app/cmd/debug/DebugLiquidPumpStartCommand.java | 68 +++++++++++ .../app/cmd/debug/DebugLiquidPumpStopCommand.java | 49 ++++++++ .../debug/DebugPalletElevatorLiftDownCommand.java | 103 +++++++++++++++++ .../debug/DebugPalletElevatorLiftUpCommand.java | 102 +++++++++++++++++ .../cmd/debug/DebugPalletElevatorStopCommand.java | 52 +++++++++ .../gd/app/cmd/debug/DebugShakerStartCommand.java | 42 +++++++ .../gd/app/cmd/debug/DebugShakerStopCommand.java | 35 ++++++ .../debug/DebugTransportationArmMoveCommand.java | 127 +++++++++++++++++++++ .../debug/DebugTransportationArmResetCommand.java | 54 +++++++++ .../debug/DebugTransportationArmStopCommand.java | 56 +++++++++ .../iflytop/gd/app/cmd/debug/DoorCloseCommand.java | 35 ------ .../iflytop/gd/app/cmd/debug/DoorOpenCommand.java | 40 ------- .../iflytop/gd/app/cmd/debug/DoorStopCommand.java | 35 ------ .../iflytop/gd/app/cmd/debug/FanStartCommand.java | 47 -------- .../iflytop/gd/app/cmd/debug/FanStopCommand.java | 47 -------- .../gd/app/cmd/debug/HeaterStartCommand.java | 48 -------- .../debug/HeaterStartHeatMaintainingCommand.java | 27 ----- .../gd/app/cmd/debug/HeaterStopCommand.java | 47 -------- .../cmd/debug/HeaterStopMaintainingCommand.java | 27 ----- .../gd/app/cmd/debug/HoldingJawCloseCommand.java | 65 ----------- .../gd/app/cmd/debug/HoldingJawOpenCommand.java | 72 ------------ .../gd/app/cmd/debug/HoldingJawPauseCommand.java | 37 ------ .../gd/app/cmd/debug/LiquidArmResetCommand.java | 32 ------ .../gd/app/cmd/debug/LiquidArmRotateCommand.java | 62 ---------- .../gd/app/cmd/debug/LiquidArmStopCommand.java | 47 -------- .../gd/app/cmd/debug/LiquidPumpStartCommand.java | 68 ----------- .../gd/app/cmd/debug/LiquidPumpStopCommand.java | 49 -------- .../cmd/debug/PalletElevatorLiftDownCommand.java | 103 ----------------- .../app/cmd/debug/PalletElevatorLiftUpCommand.java | 102 ----------------- .../app/cmd/debug/PalletElevatorStopCommand.java | 52 --------- .../gd/app/cmd/debug/ShakerStartCommand.java | 42 ------- .../gd/app/cmd/debug/ShakerStopCommand.java | 35 ------ .../cmd/debug/TransportationArmMoveCommand.java | 127 --------------------- .../cmd/debug/TransportationArmResetCommand.java | 54 --------- .../cmd/debug/TransportationArmStopCommand.java | 56 --------- 65 files changed, 1599 insertions(+), 1680 deletions(-) delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStartRecycleCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStartRefrigerationCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStopHeatingCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStopRecycleCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStopRefrigerationCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorLiftDownCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorLiftUpCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorResetCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorStopCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugColdTrapStartRecycleCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugColdTrapStartRefrigerationCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugColdTrapStopRecycleCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugColdTrapStopRefrigerationCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugCoverElevatorLiftDownCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugCoverElevatorLiftUpCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugCoverElevatorResetCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugCoverElevatorStopCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorCloseCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorOpenCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorStopCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugFanStartCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugFanStopCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugHeaterStartCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugHeaterStopCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugHoldingJawCloseCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugHoldingJawOpenCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugHoldingJawPauseCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugLiquidArmResetCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugLiquidArmRotateCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugLiquidArmStopCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugLiquidPumpStartCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugLiquidPumpStopCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugPalletElevatorLiftDownCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugPalletElevatorLiftUpCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugPalletElevatorStopCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugShakerStartCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugShakerStopCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugTransportationArmMoveCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugTransportationArmResetCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugTransportationArmStopCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DoorCloseCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DoorOpenCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DoorStopCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/FanStartCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/FanStopCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStartCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStartHeatMaintainingCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStopCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStopMaintainingCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawCloseCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawOpenCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawPauseCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmResetCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmRotateCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmStopCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/LiquidPumpStartCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/LiquidPumpStopCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftDownCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftUpCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorStopCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/ShakerStartCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/ShakerStopCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/TransportationArmMoveCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/TransportationArmResetCommand.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/TransportationArmStopCommand.java diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStartRecycleCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStartRecycleCommand.java deleted file mode 100644 index 3c7948a..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStartRecycleCommand.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 处理冷阱开启循环指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_cold_trap_start_recycle") -public class ColdTrapStartRecycleCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.coldTrapOpenCircle(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStartRefrigerationCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStartRefrigerationCommand.java deleted file mode 100644 index 7dff130..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStartRefrigerationCommand.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 处理启动冷阱制冷指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_cold_trap_start_refrigeration") -public class ColdTrapStartRefrigerationCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.coldTrapOpenCool(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStopHeatingCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStopHeatingCommand.java deleted file mode 100644 index 77e8d64..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStopHeatingCommand.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.common.annotation.CommandMapping; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 处理冷阱停止加热指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_cold_trap_stop_heating") -public class ColdTrapStopHeatingCommand extends BaseCommandHandler { - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStopRecycleCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStopRecycleCommand.java deleted file mode 100644 index 2189ed5..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStopRecycleCommand.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 处理停止冷阱循环指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_cold_trap_stop_recycle") -public class ColdTrapStopRecycleCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.coldTrapCloseCircle(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStopRefrigerationCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStopRefrigerationCommand.java deleted file mode 100644 index 0d17bc1..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStopRefrigerationCommand.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 处理停止冷阱制冷指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_cold_trap_stop_refrigeration") -public class ColdTrapStopRefrigerationCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.coldTrapCloseCool(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorLiftDownCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorLiftDownCommand.java deleted file mode 100644 index db27c20..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorLiftDownCommand.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 处理拍子电机下降指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_cover_elevator_lift_down") -public class CoverElevatorLiftDownCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - Double distance = cmdDTO.getDoubleParam("distance"); - Double velocity = cmdDTO.getDoubleParam("velocity"); - - if (velocity != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.trayMotorSet(velocity); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - } - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.trayMotorMoveBy(-distance); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorLiftUpCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorLiftUpCommand.java deleted file mode 100644 index 10ea2ef..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorLiftUpCommand.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - - -/** - * 处理拍子电机抬升指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_cover_elevator_lift_up") -public class CoverElevatorLiftUpCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - Double distance = cmdDTO.getDoubleParam("distance"); - Double velocity = cmdDTO.getDoubleParam("velocity"); - - if (velocity != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.trayMotorSet(velocity); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - } - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.trayMotorMoveBy(distance); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorResetCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorResetCommand.java deleted file mode 100644 index 7fb3b6b..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorResetCommand.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 处理拍子抬升电机复位指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_cover_elevator_reset") -public class CoverElevatorResetCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.trayMotorOrigin(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorStopCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorStopCommand.java deleted file mode 100644 index 1bb2da5..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorStopCommand.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 处理拍子抬升电机停止指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_cover_elevator_stop") -public class CoverElevatorStopCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.trayMotorStop(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugColdTrapStartRecycleCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugColdTrapStartRecycleCommand.java new file mode 100644 index 0000000..6202b61 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugColdTrapStartRecycleCommand.java @@ -0,0 +1,35 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 处理冷阱开启循环指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_cold_trap_start_recycle") +public class DebugColdTrapStartRecycleCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.coldTrapOpenCircle(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugColdTrapStartRefrigerationCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugColdTrapStartRefrigerationCommand.java new file mode 100644 index 0000000..e49ae3c --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugColdTrapStartRefrigerationCommand.java @@ -0,0 +1,35 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 处理启动冷阱制冷指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_cold_trap_start_refrigeration") +public class DebugColdTrapStartRefrigerationCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.coldTrapOpenCool(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugColdTrapStopRecycleCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugColdTrapStopRecycleCommand.java new file mode 100644 index 0000000..ce799df --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugColdTrapStopRecycleCommand.java @@ -0,0 +1,35 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 处理停止冷阱循环指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_cold_trap_stop_recycle") +public class DebugColdTrapStopRecycleCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.coldTrapCloseCircle(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugColdTrapStopRefrigerationCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugColdTrapStopRefrigerationCommand.java new file mode 100644 index 0000000..876e6bb --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugColdTrapStopRefrigerationCommand.java @@ -0,0 +1,35 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 处理停止冷阱制冷指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_cold_trap_stop_refrigeration") +public class DebugColdTrapStopRefrigerationCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.coldTrapCloseCool(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugCoverElevatorLiftDownCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugCoverElevatorLiftDownCommand.java new file mode 100644 index 0000000..3fabbb8 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugCoverElevatorLiftDownCommand.java @@ -0,0 +1,43 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 处理拍子电机下降指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_cover_elevator_lift_down") +public class DebugCoverElevatorLiftDownCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + Double distance = cmdDTO.getDoubleParam("distance"); + Double velocity = cmdDTO.getDoubleParam("velocity"); + + if (velocity != null) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.trayMotorSet(velocity); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.trayMotorMoveBy(-distance); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugCoverElevatorLiftUpCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugCoverElevatorLiftUpCommand.java new file mode 100644 index 0000000..5812dbe --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugCoverElevatorLiftUpCommand.java @@ -0,0 +1,44 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + + +/** + * 处理拍子电机抬升指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_cover_elevator_lift_up") +public class DebugCoverElevatorLiftUpCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + Double distance = cmdDTO.getDoubleParam("distance"); + Double velocity = cmdDTO.getDoubleParam("velocity"); + + if (velocity != null) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.trayMotorSet(velocity); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.trayMotorMoveBy(distance); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugCoverElevatorResetCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugCoverElevatorResetCommand.java new file mode 100644 index 0000000..a8d92f0 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugCoverElevatorResetCommand.java @@ -0,0 +1,35 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 处理拍子抬升电机复位指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_cover_elevator_reset") +public class DebugCoverElevatorResetCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.trayMotorOrigin(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugCoverElevatorStopCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugCoverElevatorStopCommand.java new file mode 100644 index 0000000..310a5bf --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugCoverElevatorStopCommand.java @@ -0,0 +1,35 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 处理拍子抬升电机停止指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_cover_elevator_stop") +public class DebugCoverElevatorStopCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.trayMotorStop(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorCloseCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorCloseCommand.java new file mode 100644 index 0000000..a6c9a8a --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorCloseCommand.java @@ -0,0 +1,35 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 处理关门指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_door_close") +public class DebugDoorCloseCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.doorOrigin(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorOpenCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorOpenCommand.java new file mode 100644 index 0000000..6957962 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorOpenCommand.java @@ -0,0 +1,40 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.model.entity.DevicePosition; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.app.service.DevicePositionService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import com.iflytop.gd.common.enums.data.DevicePositionCode; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 处理开门指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_door_open") +public class DebugDoorOpenCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + private final DevicePositionService devicePositionService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + DevicePosition devicePosition = devicePositionService.getPosition(DevicePositionCode.doorOpen); + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.doorMove(devicePosition.getDistance()); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorStopCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorStopCommand.java new file mode 100644 index 0000000..bd274b0 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorStopCommand.java @@ -0,0 +1,35 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 处理停止门运动指令处理器 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_door_stop") +public class DebugDoorStopCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.doorStop(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugFanStartCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugFanStartCommand.java new file mode 100644 index 0000000..f82b0cc --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugFanStartCommand.java @@ -0,0 +1,47 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import com.iflytop.gd.common.enums.HeatModuleCode; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 打开冷却风扇 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_fan_start") +public class DebugFanStartCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + String index = cmdDTO.getStringParam("index"); + HeatModuleCode heatModuleId = HeatModuleCode.valueOf(index); + DeviceCommandBundle deviceCommand; + switch (heatModuleId) { + case heat_module_01 -> deviceCommand = DeviceCommandGenerator.fan1Open(); + case heat_module_02 -> deviceCommand = DeviceCommandGenerator.fan2Open(); + case heat_module_03 -> deviceCommand = DeviceCommandGenerator.fan3Open(); + case heat_module_04 -> deviceCommand = DeviceCommandGenerator.fan4Open(); + case heat_module_05 -> deviceCommand = DeviceCommandGenerator.fan5Open(); + case heat_module_06 -> deviceCommand = DeviceCommandGenerator.fan6Open(); + default -> throw new RuntimeException("index 未找到"); + } + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugFanStopCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugFanStopCommand.java new file mode 100644 index 0000000..343dc13 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugFanStopCommand.java @@ -0,0 +1,47 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import com.iflytop.gd.common.enums.HeatModuleCode; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 关闭冷却风扇 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_fan_stop") +public class DebugFanStopCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + String index = cmdDTO.getStringParam("index"); + HeatModuleCode heatModuleId = HeatModuleCode.valueOf(index); + DeviceCommandBundle deviceCommand; + switch (heatModuleId) { + case heat_module_01 -> deviceCommand = DeviceCommandGenerator.fan1Close(); + case heat_module_02 -> deviceCommand = DeviceCommandGenerator.fan2Close(); + case heat_module_03 -> deviceCommand = DeviceCommandGenerator.fan3Close(); + case heat_module_04 -> deviceCommand = DeviceCommandGenerator.fan4Close(); + case heat_module_05 -> deviceCommand = DeviceCommandGenerator.fan5Close(); + case heat_module_06 -> deviceCommand = DeviceCommandGenerator.fan6Close(); + default -> throw new RuntimeException("index 未找到"); + } + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugHeaterStartCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugHeaterStartCommand.java new file mode 100644 index 0000000..ab4da77 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugHeaterStartCommand.java @@ -0,0 +1,48 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import com.iflytop.gd.common.enums.HeatModuleCode; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 处理启动加热器指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_heater_start") +public class DebugHeaterStartCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + String index = cmdDTO.getStringParam("index"); + Double temperature = cmdDTO.getDoubleParam("temperature"); + HeatModuleCode heatModuleId = HeatModuleCode.valueOf(index); + DeviceCommandBundle deviceCommand; + switch (heatModuleId) { + case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heatRod1Open(temperature); + case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heatRod2Open(temperature); + case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heatRod3Open(temperature); + case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heatRod4Open(temperature); + case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heatRod5Open(temperature); + case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heatRod6Open(temperature); + default -> throw new RuntimeException("index 未找到"); + } + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugHeaterStopCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugHeaterStopCommand.java new file mode 100644 index 0000000..eea16a8 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugHeaterStopCommand.java @@ -0,0 +1,47 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import com.iflytop.gd.common.enums.HeatModuleCode; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 处理停止加热器指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_heater_stop") +public class DebugHeaterStopCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + String index = cmdDTO.getStringParam("index"); + HeatModuleCode heatModuleId = HeatModuleCode.valueOf(index); + DeviceCommandBundle deviceCommand; + switch (heatModuleId) { + case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heatRod1Close(); + case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heatRod2Close(); + case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heatRod3Close(); + case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heatRod4Close(); + case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heatRod5Close(); + case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heatRod6Close(); + default -> throw new RuntimeException("index 未找到"); + } + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugHoldingJawCloseCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugHoldingJawCloseCommand.java new file mode 100644 index 0000000..17ba8bb --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugHoldingJawCloseCommand.java @@ -0,0 +1,65 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 处理夹爪闭合指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_holding_jaw_close") +public class DebugHoldingJawCloseCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + private boolean stop = false; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + this.stop = false; + return runAsync(() -> { + Double velocity = cmdDTO.getDoubleParam("velocity"); + Double distance = cmdDTO.getDoubleParam("distance"); + Integer times = cmdDTO.getIntegerParam("times"); + if (velocity != null) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.clawSet(velocity); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } + if (times != null) { + for (int i = 0; i < times; i++) { + if (stop) { + return; + } + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.clawMove(-distance); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + + DeviceCommandBundle backDeviceCommand = DeviceCommandGenerator.clawMove(distance); + CommandFuture backDeviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), backDeviceCommand); + commandWait(backDeviceCommandFuture); + } + } else { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.clawMove(-distance); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } + + }); + } + + public synchronized void stop() { + this.stop = true; + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugHoldingJawOpenCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugHoldingJawOpenCommand.java new file mode 100644 index 0000000..15964be --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugHoldingJawOpenCommand.java @@ -0,0 +1,72 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 处理打开夹爪指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_holding_jaw_open") +public class DebugHoldingJawOpenCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + private boolean stop = false; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + this.stop = false; + Double velocity = cmdDTO.getDoubleParam("velocity"); + Double openDistance = cmdDTO.getDoubleParam("openDistance"); + Double closeDistance = cmdDTO.getDoubleParam("closeDistance"); + Integer times = cmdDTO.getIntegerParam("times"); + if(openDistance < 34 || openDistance > 54) { + throw new RuntimeException("openDistance must be between 34 and 54"); + } + if(closeDistance < 34 || closeDistance > 54) { + throw new RuntimeException("closeDistance must be between 34 and 54"); + } + return runAsync(() -> { + if (velocity != null) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.clawSet(velocity); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } + if (times != null) { + for (int i = 0; i < times; i++) { + if (stop) { + return; + } + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.clawMove(openDistance); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + + DeviceCommandBundle backDeviceCommand = DeviceCommandGenerator.clawMove(closeDistance); + CommandFuture backDeviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), backDeviceCommand); + commandWait(backDeviceCommandFuture); + } + } else { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.clawMove(openDistance); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } + + }); + } + + public synchronized void stop() { + this.stop = true; + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugHoldingJawPauseCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugHoldingJawPauseCommand.java new file mode 100644 index 0000000..b2d5e0a --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugHoldingJawPauseCommand.java @@ -0,0 +1,37 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 处理暂停夹爪指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_holding_jaw_pause") +public class DebugHoldingJawPauseCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + private final DebugHoldingJawOpenCommand debugHoldingJawOpenCommand; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + debugHoldingJawOpenCommand.stop(); + return runAsync(() -> { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.clawStop(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugLiquidArmResetCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugLiquidArmResetCommand.java new file mode 100644 index 0000000..942846d --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugLiquidArmResetCommand.java @@ -0,0 +1,32 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.hardware.type.LiquidDistributionArmDriver; +import com.iflytop.gd.hardware.type.Servo.LiquidArmMId; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 复位加液臂指令处理器 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_liquid_arm_reset") +public class DebugLiquidArmResetCommand extends BaseCommandHandler { + private final LiquidDistributionArmDriver liquidDistributionArmDriver; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + liquidDistributionArmDriver.liquidDistributionArmEnable(LiquidArmMId.LiquidDistributionArm, 1); + liquidDistributionArmDriver.liquidDistributionArmMoveToBlock(LiquidArmMId.LiquidDistributionArm, 0); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugLiquidArmRotateCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugLiquidArmRotateCommand.java new file mode 100644 index 0000000..248cf71 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugLiquidArmRotateCommand.java @@ -0,0 +1,62 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +/** + * 处理加液臂移动指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_liquid_arm_rotation") +public class DebugLiquidArmRotateCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + Double largeArmAngle = cmdDTO.getDoubleParam("largeArmAngle"); + Double smallArmAngle = cmdDTO.getDoubleParam("smallArmAngle"); + Double largeArmRotationVelocity = cmdDTO.getDoubleParam("largeArmRotationVelocity"); + Double smallArmRotationVelocity = cmdDTO.getDoubleParam("smallArmRotationVelocity"); + if (largeArmRotationVelocity != null) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.dualRobotJoint1Set(largeArmRotationVelocity); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } + if (smallArmRotationVelocity != null) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.dualRobotJoint2Set(smallArmRotationVelocity); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } + + List futuresList = new ArrayList<>(); + if (largeArmAngle != null) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.dualRobotJoint1Move(largeArmAngle); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + if (smallArmAngle != null) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.dualRobotJoint2Move(smallArmAngle); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + + commandWait(futuresList.toArray(new CommandFuture[0])); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugLiquidArmStopCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugLiquidArmStopCommand.java new file mode 100644 index 0000000..8183c6e --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugLiquidArmStopCommand.java @@ -0,0 +1,47 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +/** + * 处理加液臂停止指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_liquid_arm_stop") +public class DebugLiquidArmStopCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + List target = (List) cmdDTO.getParams().get("target"); + List futuresList = new ArrayList<>(); + if (target != null && target.contains("largeArm")) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.dualRobotJoint1Stop(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + if (target != null && target.contains("smallArm")) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.dualRobotJoint2Stop(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + commandWait(futuresList.toArray(new CommandFuture[0])); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugLiquidPumpStartCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugLiquidPumpStartCommand.java new file mode 100644 index 0000000..ea1655d --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugLiquidPumpStartCommand.java @@ -0,0 +1,68 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import com.iflytop.gd.common.enums.AcidPumpDeviceCode; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 处理加液泵启动指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_liquid_pump_start") +public class DebugLiquidPumpStartCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + String index = cmdDTO.getStringParam("index"); + Double volume = cmdDTO.getDoubleParam("volume"); + Double velocity = cmdDTO.getDoubleParam("velocity"); + AcidPumpDeviceCode acidPumpDevice = AcidPumpDeviceCode.valueOf(index); + DeviceCommandBundle deviceCommand; + if (velocity != null) { + switch (acidPumpDevice) { + case acid_pump_01 -> deviceCommand = DeviceCommandGenerator.acidPump1Set(velocity); + case acid_pump_02 -> deviceCommand = DeviceCommandGenerator.acidPump2Set(velocity); + case acid_pump_03 -> deviceCommand = DeviceCommandGenerator.acidPump3Set(velocity); + case acid_pump_04 -> deviceCommand = DeviceCommandGenerator.acidPump4Set(velocity); + case acid_pump_05 -> deviceCommand = DeviceCommandGenerator.acidPump5Set(velocity); + case acid_pump_06 -> deviceCommand = DeviceCommandGenerator.acidPump6Set(velocity); + case acid_pump_07 -> deviceCommand = DeviceCommandGenerator.acidPump7Set(velocity); + case acid_pump_08 -> deviceCommand = DeviceCommandGenerator.acidPump8Set(velocity); + default -> throw new RuntimeException("index 未找到"); + } + + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } + + switch (acidPumpDevice) { + case acid_pump_01 -> deviceCommand = DeviceCommandGenerator.acidPump1MoveBy(volume); + case acid_pump_02 -> deviceCommand = DeviceCommandGenerator.acidPump2MoveBy(volume); + case acid_pump_03 -> deviceCommand = DeviceCommandGenerator.acidPump3MoveBy(volume); + case acid_pump_04 -> deviceCommand = DeviceCommandGenerator.acidPump4MoveBy(volume); + case acid_pump_05 -> deviceCommand = DeviceCommandGenerator.acidPump5MoveBy(volume); + case acid_pump_06 -> deviceCommand = DeviceCommandGenerator.acidPump6MoveBy(volume); + case acid_pump_07 -> deviceCommand = DeviceCommandGenerator.acidPump7MoveBy(volume); + case acid_pump_08 -> deviceCommand = DeviceCommandGenerator.acidPump8MoveBy(volume); + default -> throw new RuntimeException("index 未找到"); + } + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugLiquidPumpStopCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugLiquidPumpStopCommand.java new file mode 100644 index 0000000..0d7a297 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugLiquidPumpStopCommand.java @@ -0,0 +1,49 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import com.iflytop.gd.common.enums.AcidPumpDeviceCode; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 处理加液泵停止指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_liquid_pump_stop") +public class DebugLiquidPumpStopCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + String index = cmdDTO.getStringParam("index"); + AcidPumpDeviceCode acidPumpDevice = AcidPumpDeviceCode.valueOf(index); + DeviceCommandBundle deviceCommand; + switch (acidPumpDevice) { + case acid_pump_01 -> deviceCommand = DeviceCommandGenerator.acidPump1Stop(); + case acid_pump_02 -> deviceCommand = DeviceCommandGenerator.acidPump2Stop(); + case acid_pump_03 -> deviceCommand = DeviceCommandGenerator.acidPump3Stop(); + case acid_pump_04 -> deviceCommand = DeviceCommandGenerator.acidPump4Stop(); + case acid_pump_05 -> deviceCommand = DeviceCommandGenerator.acidPump5Stop(); + case acid_pump_06 -> deviceCommand = DeviceCommandGenerator.acidPump6Stop(); + case acid_pump_07 -> deviceCommand = DeviceCommandGenerator.acidPump7Stop(); + case acid_pump_08 -> deviceCommand = DeviceCommandGenerator.acidPump8Stop(); + default -> throw new RuntimeException("index 未找到"); + } + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugPalletElevatorLiftDownCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugPalletElevatorLiftDownCommand.java new file mode 100644 index 0000000..88aa97c --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugPalletElevatorLiftDownCommand.java @@ -0,0 +1,103 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import com.iflytop.gd.common.enums.HeatModuleCode; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + + +/** + * 处理降下托盘指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_pallet_elevator_lift_down") +public class DebugPalletElevatorLiftDownCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + private boolean stop = false; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + this.stop = false; + return runAsync(() -> { + String index = cmdDTO.getStringParam("index"); + Double distance = cmdDTO.getDoubleParam("distance"); + Double velocity = cmdDTO.getDoubleParam("velocity"); + Integer times = cmdDTO.getIntegerParam("times"); + DeviceCommandBundle deviceCommand; + HeatModuleCode heatModuleId = HeatModuleCode.valueOf(index); + if (velocity != null) { + switch (heatModuleId) { + case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1Set(velocity); + case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2Set(velocity); + case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3Set(velocity); + case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4Set(velocity); + case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5Set(velocity); + case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6Set(velocity); + default -> throw new RuntimeException("index 未找到"); + } + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } + + if (times != null) { + for (int i = 0; i < times; i++) { + if (stop) { + return; + } + switch (heatModuleId) { + case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1MoveBy(-distance); + case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2MoveBy(-distance); + case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3MoveBy(-distance); + case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4MoveBy(-distance); + case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5MoveBy(-distance); + case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6MoveBy(-distance); + default -> throw new RuntimeException("index 未找到"); + } + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + + switch (heatModuleId) { + case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1MoveBy(distance); + case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2MoveBy(distance); + case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3MoveBy(distance); + case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4MoveBy(distance); + case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5MoveBy(distance); + case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6MoveBy(distance); + default -> throw new RuntimeException("index 未找到"); + } + CommandFuture backDeviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(backDeviceCommandFuture); + + } + } else { + switch (heatModuleId) { + case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1MoveBy(-distance); + case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2MoveBy(-distance); + case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3MoveBy(-distance); + case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4MoveBy(-distance); + case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5MoveBy(-distance); + case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6MoveBy(-distance); + default -> throw new RuntimeException("index 未找到"); + } + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } + }); + } + + public synchronized void stop() { + this.stop = true; + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugPalletElevatorLiftUpCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugPalletElevatorLiftUpCommand.java new file mode 100644 index 0000000..78f65bd --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugPalletElevatorLiftUpCommand.java @@ -0,0 +1,102 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import com.iflytop.gd.common.enums.HeatModuleCode; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 处理托盘电机上升到指定位置 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_pallet_elevator_lift_up") +public class DebugPalletElevatorLiftUpCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + private boolean stop = false; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + this.stop = false; + return runAsync(() -> { + String index = cmdDTO.getStringParam("index"); + Double distance = cmdDTO.getDoubleParam("distance"); + Double velocity = cmdDTO.getDoubleParam("velocity"); + Integer times = cmdDTO.getIntegerParam("times"); + DeviceCommandBundle deviceCommand; + HeatModuleCode heatModuleId = HeatModuleCode.valueOf(index); + if (velocity != null) { + switch (heatModuleId) { + case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1Set(velocity); + case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2Set(velocity); + case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3Set(velocity); + case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4Set(velocity); + case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5Set(velocity); + case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6Set(velocity); + default -> throw new RuntimeException("index 未找到"); + } + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } + if (times != null) { + for (int i = 0; i < times; i++) { + if (stop) { + return; + } + switch (heatModuleId) { + case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1MoveBy(distance); + case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2MoveBy(distance); + case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3MoveBy(distance); + case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4MoveBy(distance); + case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5MoveBy(distance); + case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6MoveBy(distance); + default -> throw new RuntimeException("index 未找到"); + } + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + + switch (heatModuleId) { + case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1MoveBy(-distance); + case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2MoveBy(-distance); + case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3MoveBy(-distance); + case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4MoveBy(-distance); + case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5MoveBy(-distance); + case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6MoveBy(-distance); + default -> throw new RuntimeException("index 未找到"); + } + CommandFuture backDeviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(backDeviceCommandFuture); + + } + } else { + switch (heatModuleId) { + case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1MoveBy(distance); + case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2MoveBy(distance); + case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3MoveBy(distance); + case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4MoveBy(distance); + case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5MoveBy(distance); + case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6MoveBy(distance); + default -> throw new RuntimeException("index 未找到"); + } + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } + + }); + } + + public synchronized void stop() { + this.stop = true; + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugPalletElevatorStopCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugPalletElevatorStopCommand.java new file mode 100644 index 0000000..ec2a738 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugPalletElevatorStopCommand.java @@ -0,0 +1,52 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import com.iflytop.gd.common.enums.HeatModuleCode; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + + +/** + * 处理停止托盘抬升器指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_pallet_elevator_stop") +public class DebugPalletElevatorStopCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + private final DebugPalletElevatorLiftUpCommand debugPalletElevatorLiftUpCommand; + private final DebugPalletElevatorLiftDownCommand debugPalletElevatorLiftDownCommand; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + debugPalletElevatorLiftUpCommand.stop(); + debugPalletElevatorLiftDownCommand.stop(); + return runAsync(() -> { + String index = cmdDTO.getStringParam("index"); + HeatModuleCode heatModuleId = HeatModuleCode.valueOf(index); + DeviceCommandBundle deviceCommand; + switch (heatModuleId) { + case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1Stop(); + case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2Stop(); + case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3Stop(); + case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4Stop(); + case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5Stop(); + case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6Stop(); + default -> throw new RuntimeException("index 未找到"); + } + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugShakerStartCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugShakerStartCommand.java new file mode 100644 index 0000000..9602686 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugShakerStartCommand.java @@ -0,0 +1,42 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 处理启动摇匀器指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_shaker_start") +public class DebugShakerStartCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + Double velocity = cmdDTO.getDoubleParam("velocity"); + if (velocity != null) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.shakeMotorSet(velocity); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } + + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.shakeMotorStart(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugShakerStopCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugShakerStopCommand.java new file mode 100644 index 0000000..ceb4f19 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugShakerStopCommand.java @@ -0,0 +1,35 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 处理停止摇匀器指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_shaker_stop") +public class DebugShakerStopCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.shakeMotorStop(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugTransportationArmMoveCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugTransportationArmMoveCommand.java new file mode 100644 index 0000000..00c42c8 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugTransportationArmMoveCommand.java @@ -0,0 +1,127 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +/** + * 处理移动转移机械臂指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_transportation_arm_move") +public class DebugTransportationArmMoveCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + private boolean stop = false; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + this.stop = false; + return runAsync(() -> { + Double xDimDistance = cmdDTO.getDoubleParam("xDimDistance"); + Double yDimDistance = cmdDTO.getDoubleParam("yDimDistance"); + Double zDimDistance = cmdDTO.getDoubleParam("zDimDistance"); + + Double xDimVelocity = cmdDTO.getDoubleParam("xDimVelocity"); + Double yDimVelocity = cmdDTO.getDoubleParam("yDimVelocity"); + Double zDimVelocity = cmdDTO.getDoubleParam("zDimVelocity"); + Integer times = cmdDTO.getIntegerParam("times"); + + List futuresList = new ArrayList<>(); + if (xDimVelocity != null) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXSet(xDimVelocity); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + if (yDimVelocity != null) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryYSet(yDimVelocity); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + if (zDimVelocity != null) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZSet(zDimVelocity); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + commandWait(futuresList.toArray(new CommandFuture[0])); + + futuresList.clear(); + if (times != null) { + for (int i = 0; i < times; i++) { + if (stop) { + return; + } + if (xDimDistance != null) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMoveBy(xDimDistance); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + if (yDimDistance != null) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryYMoveBy(yDimDistance); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + if (zDimDistance != null) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMoveBy(zDimDistance); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + commandWait(futuresList.toArray(new CommandFuture[0])); + if (xDimDistance != null) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMoveBy(-xDimDistance); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + if (yDimDistance != null) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryYMoveBy(-yDimDistance); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + if (zDimDistance != null) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMoveBy(-zDimDistance); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + commandWait(futuresList.toArray(new CommandFuture[0])); + } + } else { + if (xDimDistance != null) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMoveBy(xDimDistance); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + if (yDimDistance != null) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryYMoveBy(yDimDistance); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + if (zDimDistance != null) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMoveBy(zDimDistance); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + + commandWait(futuresList.toArray(new CommandFuture[0])); + } + + + }); + } + + public synchronized void stop() { + this.stop = true; + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugTransportationArmResetCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugTransportationArmResetCommand.java new file mode 100644 index 0000000..f86cb5c --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugTransportationArmResetCommand.java @@ -0,0 +1,54 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +/** + * 处理复位转移机械臂指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_transportation_arm_reset") +public class DebugTransportationArmResetCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + List dim = (List) cmdDTO.getParams().get("dim"); + List futuresList = new ArrayList<>(); + if (dim != null && dim.contains("x")) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXOrigin(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + if (dim != null && dim.contains("y")) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryYOrigin(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + + if (dim != null && dim.contains("z")) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZOrigin(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + + commandWait(futuresList.toArray(new CommandFuture[0])); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugTransportationArmStopCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugTransportationArmStopCommand.java new file mode 100644 index 0000000..659edfa --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugTransportationArmStopCommand.java @@ -0,0 +1,56 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +/** + * 处理停止转移机械臂移动指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_transportation_arm_stop") +public class DebugTransportationArmStopCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + private final DebugTransportationArmMoveCommand debugTransportationArmMoveCommand; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + debugTransportationArmMoveCommand.stop(); + return runAsync(() -> { + List dim = (List) cmdDTO.getParams().get("dim"); + List futuresList = new ArrayList<>(); + if (dim != null && dim.contains("x")) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXStop(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + if (dim != null && dim.contains("y")) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryYStop(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + + if (dim != null && dim.contains("z")) { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZStop(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + + commandWait(futuresList.toArray(new CommandFuture[0])); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DoorCloseCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DoorCloseCommand.java deleted file mode 100644 index 5f3be75..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/DoorCloseCommand.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 处理关门指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_door_close") -public class DoorCloseCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.doorOrigin(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DoorOpenCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DoorOpenCommand.java deleted file mode 100644 index 8cd6015..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/DoorOpenCommand.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.model.entity.DevicePosition; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.app.service.DevicePositionService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import com.iflytop.gd.common.enums.data.DevicePositionCode; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 处理开门指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_door_open") -public class DoorOpenCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - private final DevicePositionService devicePositionService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - DevicePosition devicePosition = devicePositionService.getPosition(DevicePositionCode.doorOpen); - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.doorMove(devicePosition.getDistance()); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DoorStopCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DoorStopCommand.java deleted file mode 100644 index 7a3aab7..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/DoorStopCommand.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 处理停止门运动指令处理器 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_door_stop") -public class DoorStopCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.doorStop(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/FanStartCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/FanStartCommand.java deleted file mode 100644 index be697e4..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/FanStartCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import com.iflytop.gd.common.enums.HeatModuleCode; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 打开冷却风扇 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_fan_start") -public class FanStartCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - String index = cmdDTO.getStringParam("index"); - HeatModuleCode heatModuleId = HeatModuleCode.valueOf(index); - DeviceCommandBundle deviceCommand; - switch (heatModuleId) { - case heat_module_01 -> deviceCommand = DeviceCommandGenerator.fan1Open(); - case heat_module_02 -> deviceCommand = DeviceCommandGenerator.fan2Open(); - case heat_module_03 -> deviceCommand = DeviceCommandGenerator.fan3Open(); - case heat_module_04 -> deviceCommand = DeviceCommandGenerator.fan4Open(); - case heat_module_05 -> deviceCommand = DeviceCommandGenerator.fan5Open(); - case heat_module_06 -> deviceCommand = DeviceCommandGenerator.fan6Open(); - default -> throw new RuntimeException("index 未找到"); - } - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/FanStopCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/FanStopCommand.java deleted file mode 100644 index 895032f..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/FanStopCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import com.iflytop.gd.common.enums.HeatModuleCode; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 关闭冷却风扇 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_fan_stop") -public class FanStopCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - String index = cmdDTO.getStringParam("index"); - HeatModuleCode heatModuleId = HeatModuleCode.valueOf(index); - DeviceCommandBundle deviceCommand; - switch (heatModuleId) { - case heat_module_01 -> deviceCommand = DeviceCommandGenerator.fan1Close(); - case heat_module_02 -> deviceCommand = DeviceCommandGenerator.fan2Close(); - case heat_module_03 -> deviceCommand = DeviceCommandGenerator.fan3Close(); - case heat_module_04 -> deviceCommand = DeviceCommandGenerator.fan4Close(); - case heat_module_05 -> deviceCommand = DeviceCommandGenerator.fan5Close(); - case heat_module_06 -> deviceCommand = DeviceCommandGenerator.fan6Close(); - default -> throw new RuntimeException("index 未找到"); - } - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStartCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStartCommand.java deleted file mode 100644 index 6230e5a..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStartCommand.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import com.iflytop.gd.common.enums.HeatModuleCode; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 处理启动加热器指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_heater_start") -public class HeaterStartCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - String index = cmdDTO.getStringParam("index"); - Double temperature = cmdDTO.getDoubleParam("temperature"); - HeatModuleCode heatModuleId = HeatModuleCode.valueOf(index); - DeviceCommandBundle deviceCommand; - switch (heatModuleId) { - case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heatRod1Open(temperature); - case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heatRod2Open(temperature); - case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heatRod3Open(temperature); - case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heatRod4Open(temperature); - case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heatRod5Open(temperature); - case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heatRod6Open(temperature); - default -> throw new RuntimeException("index 未找到"); - } - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStartHeatMaintainingCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStartHeatMaintainingCommand.java deleted file mode 100644 index dc424e7..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStartHeatMaintainingCommand.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.common.annotation.CommandMapping; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 处理启动加热器恒温指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_heater_start_heat_maintaining") -public class HeaterStartHeatMaintainingCommand extends BaseCommandHandler { - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStopCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStopCommand.java deleted file mode 100644 index aaa45f1..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStopCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import com.iflytop.gd.common.enums.HeatModuleCode; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 处理停止加热器指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_heater_stop") -public class HeaterStopCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - String index = cmdDTO.getStringParam("index"); - HeatModuleCode heatModuleId = HeatModuleCode.valueOf(index); - DeviceCommandBundle deviceCommand; - switch (heatModuleId) { - case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heatRod1Close(); - case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heatRod2Close(); - case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heatRod3Close(); - case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heatRod4Close(); - case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heatRod5Close(); - case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heatRod6Close(); - default -> throw new RuntimeException("index 未找到"); - } - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStopMaintainingCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStopMaintainingCommand.java deleted file mode 100644 index 541506c..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStopMaintainingCommand.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.common.annotation.CommandMapping; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 处理停止恒温加热指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_heater_stop_heat_maintaining") -public class HeaterStopMaintainingCommand extends BaseCommandHandler { - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawCloseCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawCloseCommand.java deleted file mode 100644 index 1801aa1..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawCloseCommand.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 处理夹爪闭合指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_holding_jaw_close") -public class HoldingJawCloseCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - private boolean stop = false; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - this.stop = false; - return runAsync(() -> { - Double velocity = cmdDTO.getDoubleParam("velocity"); - Double distance = cmdDTO.getDoubleParam("distance"); - Integer times = cmdDTO.getIntegerParam("times"); - if (velocity != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.clawSet(velocity); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - } - if (times != null) { - for (int i = 0; i < times; i++) { - if (stop) { - return; - } - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.clawMove(-distance); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - - DeviceCommandBundle backDeviceCommand = DeviceCommandGenerator.clawMove(distance); - CommandFuture backDeviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), backDeviceCommand); - commandWait(backDeviceCommandFuture); - } - } else { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.clawMove(-distance); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - } - - }); - } - - public synchronized void stop() { - this.stop = true; - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawOpenCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawOpenCommand.java deleted file mode 100644 index 620a464..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawOpenCommand.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 处理打开夹爪指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_holding_jaw_open") -public class HoldingJawOpenCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - private boolean stop = false; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - this.stop = false; - Double velocity = cmdDTO.getDoubleParam("velocity"); - Double openDistance = cmdDTO.getDoubleParam("openDistance"); - Double closeDistance = cmdDTO.getDoubleParam("closeDistance"); - Integer times = cmdDTO.getIntegerParam("times"); - if(openDistance < 34 || openDistance > 54) { - throw new RuntimeException("openDistance must be between 34 and 54"); - } - if(closeDistance < 34 || closeDistance > 54) { - throw new RuntimeException("closeDistance must be between 34 and 54"); - } - return runAsync(() -> { - if (velocity != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.clawSet(velocity); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - } - if (times != null) { - for (int i = 0; i < times; i++) { - if (stop) { - return; - } - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.clawMove(openDistance); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - - DeviceCommandBundle backDeviceCommand = DeviceCommandGenerator.clawMove(closeDistance); - CommandFuture backDeviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), backDeviceCommand); - commandWait(backDeviceCommandFuture); - } - } else { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.clawMove(openDistance); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - } - - }); - } - - public synchronized void stop() { - this.stop = true; - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawPauseCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawPauseCommand.java deleted file mode 100644 index c9d6ecb..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawPauseCommand.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 处理暂停夹爪指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_holding_jaw_pause") -public class HoldingJawPauseCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - private final HoldingJawOpenCommand holdingJawOpenCommand; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - holdingJawOpenCommand.stop(); - return runAsync(() -> { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.clawStop(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmResetCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmResetCommand.java deleted file mode 100644 index afa1e9a..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmResetCommand.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.hardware.type.LiquidDistributionArmDriver; -import com.iflytop.gd.hardware.type.Servo.LiquidArmMId; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 复位加液臂指令处理器 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_liquid_arm_reset") -public class LiquidArmResetCommand extends BaseCommandHandler { - private final LiquidDistributionArmDriver liquidDistributionArmDriver; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - liquidDistributionArmDriver.liquidDistributionArmEnable(LiquidArmMId.LiquidDistributionArm, 1); - liquidDistributionArmDriver.liquidDistributionArmMoveToBlock(LiquidArmMId.LiquidDistributionArm, 0); - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmRotateCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmRotateCommand.java deleted file mode 100644 index d1fc489..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmRotateCommand.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CompletableFuture; - -/** - * 处理加液臂移动指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_liquid_arm_rotation") -public class LiquidArmRotateCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - Double largeArmAngle = cmdDTO.getDoubleParam("largeArmAngle"); - Double smallArmAngle = cmdDTO.getDoubleParam("smallArmAngle"); - Double largeArmRotationVelocity = cmdDTO.getDoubleParam("largeArmRotationVelocity"); - Double smallArmRotationVelocity = cmdDTO.getDoubleParam("smallArmRotationVelocity"); - if (largeArmRotationVelocity != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.dualRobotJoint1Set(largeArmRotationVelocity); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - } - if (smallArmRotationVelocity != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.dualRobotJoint2Set(smallArmRotationVelocity); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - } - - List futuresList = new ArrayList<>(); - if (largeArmAngle != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.dualRobotJoint1Move(largeArmAngle); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - if (smallArmAngle != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.dualRobotJoint2Move(smallArmAngle); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - - commandWait(futuresList.toArray(new CommandFuture[0])); - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmStopCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmStopCommand.java deleted file mode 100644 index ac665ce..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmStopCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CompletableFuture; - -/** - * 处理加液臂停止指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_liquid_arm_stop") -public class LiquidArmStopCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - List target = (List) cmdDTO.getParams().get("target"); - List futuresList = new ArrayList<>(); - if (target != null && target.contains("largeArm")) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.dualRobotJoint1Stop(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - if (target != null && target.contains("smallArm")) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.dualRobotJoint2Stop(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - commandWait(futuresList.toArray(new CommandFuture[0])); - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidPumpStartCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidPumpStartCommand.java deleted file mode 100644 index 36a8d50..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidPumpStartCommand.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import com.iflytop.gd.common.enums.AcidPumpDeviceCode; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 处理加液泵启动指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_liquid_pump_start") -public class LiquidPumpStartCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - String index = cmdDTO.getStringParam("index"); - Double volume = cmdDTO.getDoubleParam("volume"); - Double velocity = cmdDTO.getDoubleParam("velocity"); - AcidPumpDeviceCode acidPumpDevice = AcidPumpDeviceCode.valueOf(index); - DeviceCommandBundle deviceCommand; - if (velocity != null) { - switch (acidPumpDevice) { - case acid_pump_01 -> deviceCommand = DeviceCommandGenerator.acidPump1Set(velocity); - case acid_pump_02 -> deviceCommand = DeviceCommandGenerator.acidPump2Set(velocity); - case acid_pump_03 -> deviceCommand = DeviceCommandGenerator.acidPump3Set(velocity); - case acid_pump_04 -> deviceCommand = DeviceCommandGenerator.acidPump4Set(velocity); - case acid_pump_05 -> deviceCommand = DeviceCommandGenerator.acidPump5Set(velocity); - case acid_pump_06 -> deviceCommand = DeviceCommandGenerator.acidPump6Set(velocity); - case acid_pump_07 -> deviceCommand = DeviceCommandGenerator.acidPump7Set(velocity); - case acid_pump_08 -> deviceCommand = DeviceCommandGenerator.acidPump8Set(velocity); - default -> throw new RuntimeException("index 未找到"); - } - - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - } - - switch (acidPumpDevice) { - case acid_pump_01 -> deviceCommand = DeviceCommandGenerator.acidPump1MoveBy(volume); - case acid_pump_02 -> deviceCommand = DeviceCommandGenerator.acidPump2MoveBy(volume); - case acid_pump_03 -> deviceCommand = DeviceCommandGenerator.acidPump3MoveBy(volume); - case acid_pump_04 -> deviceCommand = DeviceCommandGenerator.acidPump4MoveBy(volume); - case acid_pump_05 -> deviceCommand = DeviceCommandGenerator.acidPump5MoveBy(volume); - case acid_pump_06 -> deviceCommand = DeviceCommandGenerator.acidPump6MoveBy(volume); - case acid_pump_07 -> deviceCommand = DeviceCommandGenerator.acidPump7MoveBy(volume); - case acid_pump_08 -> deviceCommand = DeviceCommandGenerator.acidPump8MoveBy(volume); - default -> throw new RuntimeException("index 未找到"); - } - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidPumpStopCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidPumpStopCommand.java deleted file mode 100644 index acf6596..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidPumpStopCommand.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import com.iflytop.gd.common.enums.AcidPumpDeviceCode; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 处理加液泵停止指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_liquid_pump_stop") -public class LiquidPumpStopCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - String index = cmdDTO.getStringParam("index"); - AcidPumpDeviceCode acidPumpDevice = AcidPumpDeviceCode.valueOf(index); - DeviceCommandBundle deviceCommand; - switch (acidPumpDevice) { - case acid_pump_01 -> deviceCommand = DeviceCommandGenerator.acidPump1Stop(); - case acid_pump_02 -> deviceCommand = DeviceCommandGenerator.acidPump2Stop(); - case acid_pump_03 -> deviceCommand = DeviceCommandGenerator.acidPump3Stop(); - case acid_pump_04 -> deviceCommand = DeviceCommandGenerator.acidPump4Stop(); - case acid_pump_05 -> deviceCommand = DeviceCommandGenerator.acidPump5Stop(); - case acid_pump_06 -> deviceCommand = DeviceCommandGenerator.acidPump6Stop(); - case acid_pump_07 -> deviceCommand = DeviceCommandGenerator.acidPump7Stop(); - case acid_pump_08 -> deviceCommand = DeviceCommandGenerator.acidPump8Stop(); - default -> throw new RuntimeException("index 未找到"); - } - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftDownCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftDownCommand.java deleted file mode 100644 index 0570e52..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftDownCommand.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import com.iflytop.gd.common.enums.HeatModuleCode; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - - -/** - * 处理降下托盘指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_pallet_elevator_lift_down") -public class PalletElevatorLiftDownCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - private boolean stop = false; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - this.stop = false; - return runAsync(() -> { - String index = cmdDTO.getStringParam("index"); - Double distance = cmdDTO.getDoubleParam("distance"); - Double velocity = cmdDTO.getDoubleParam("velocity"); - Integer times = cmdDTO.getIntegerParam("times"); - DeviceCommandBundle deviceCommand; - HeatModuleCode heatModuleId = HeatModuleCode.valueOf(index); - if (velocity != null) { - switch (heatModuleId) { - case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1Set(velocity); - case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2Set(velocity); - case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3Set(velocity); - case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4Set(velocity); - case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5Set(velocity); - case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6Set(velocity); - default -> throw new RuntimeException("index 未找到"); - } - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - } - - if (times != null) { - for (int i = 0; i < times; i++) { - if (stop) { - return; - } - switch (heatModuleId) { - case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1MoveBy(-distance); - case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2MoveBy(-distance); - case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3MoveBy(-distance); - case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4MoveBy(-distance); - case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5MoveBy(-distance); - case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6MoveBy(-distance); - default -> throw new RuntimeException("index 未找到"); - } - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - - switch (heatModuleId) { - case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1MoveBy(distance); - case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2MoveBy(distance); - case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3MoveBy(distance); - case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4MoveBy(distance); - case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5MoveBy(distance); - case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6MoveBy(distance); - default -> throw new RuntimeException("index 未找到"); - } - CommandFuture backDeviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(backDeviceCommandFuture); - - } - } else { - switch (heatModuleId) { - case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1MoveBy(-distance); - case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2MoveBy(-distance); - case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3MoveBy(-distance); - case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4MoveBy(-distance); - case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5MoveBy(-distance); - case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6MoveBy(-distance); - default -> throw new RuntimeException("index 未找到"); - } - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - } - }); - } - - public synchronized void stop() { - this.stop = true; - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftUpCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftUpCommand.java deleted file mode 100644 index d9b8b81..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftUpCommand.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import com.iflytop.gd.common.enums.HeatModuleCode; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 处理托盘电机上升到指定位置 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_pallet_elevator_lift_up") -public class PalletElevatorLiftUpCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - private boolean stop = false; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - this.stop = false; - return runAsync(() -> { - String index = cmdDTO.getStringParam("index"); - Double distance = cmdDTO.getDoubleParam("distance"); - Double velocity = cmdDTO.getDoubleParam("velocity"); - Integer times = cmdDTO.getIntegerParam("times"); - DeviceCommandBundle deviceCommand; - HeatModuleCode heatModuleId = HeatModuleCode.valueOf(index); - if (velocity != null) { - switch (heatModuleId) { - case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1Set(velocity); - case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2Set(velocity); - case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3Set(velocity); - case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4Set(velocity); - case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5Set(velocity); - case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6Set(velocity); - default -> throw new RuntimeException("index 未找到"); - } - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - } - if (times != null) { - for (int i = 0; i < times; i++) { - if (stop) { - return; - } - switch (heatModuleId) { - case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1MoveBy(distance); - case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2MoveBy(distance); - case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3MoveBy(distance); - case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4MoveBy(distance); - case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5MoveBy(distance); - case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6MoveBy(distance); - default -> throw new RuntimeException("index 未找到"); - } - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - - switch (heatModuleId) { - case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1MoveBy(-distance); - case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2MoveBy(-distance); - case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3MoveBy(-distance); - case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4MoveBy(-distance); - case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5MoveBy(-distance); - case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6MoveBy(-distance); - default -> throw new RuntimeException("index 未找到"); - } - CommandFuture backDeviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(backDeviceCommandFuture); - - } - } else { - switch (heatModuleId) { - case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1MoveBy(distance); - case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2MoveBy(distance); - case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3MoveBy(distance); - case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4MoveBy(distance); - case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5MoveBy(distance); - case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6MoveBy(distance); - default -> throw new RuntimeException("index 未找到"); - } - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - } - - }); - } - - public synchronized void stop() { - this.stop = true; - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorStopCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorStopCommand.java deleted file mode 100644 index 6ab74c2..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorStopCommand.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import com.iflytop.gd.common.enums.HeatModuleCode; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - - -/** - * 处理停止托盘抬升器指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_pallet_elevator_stop") -public class PalletElevatorStopCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - private final PalletElevatorLiftUpCommand palletElevatorLiftUpCommand; - private final PalletElevatorLiftDownCommand palletElevatorLiftDownCommand; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - palletElevatorLiftUpCommand.stop(); - palletElevatorLiftDownCommand.stop(); - return runAsync(() -> { - String index = cmdDTO.getStringParam("index"); - HeatModuleCode heatModuleId = HeatModuleCode.valueOf(index); - DeviceCommandBundle deviceCommand; - switch (heatModuleId) { - case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1Stop(); - case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2Stop(); - case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3Stop(); - case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4Stop(); - case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5Stop(); - case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6Stop(); - default -> throw new RuntimeException("index 未找到"); - } - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/ShakerStartCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/ShakerStartCommand.java deleted file mode 100644 index f5673f7..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/ShakerStartCommand.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 处理启动摇匀器指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_shaker_start") -public class ShakerStartCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - Double velocity = cmdDTO.getDoubleParam("velocity"); - if (velocity != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.shakeMotorSet(velocity); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - } - - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.shakeMotorStart(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/ShakerStopCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/ShakerStopCommand.java deleted file mode 100644 index 4dfbf61..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/ShakerStopCommand.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 处理停止摇匀器指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_shaker_stop") -public class ShakerStopCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.shakeMotorStop(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/TransportationArmMoveCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/TransportationArmMoveCommand.java deleted file mode 100644 index 6c86423..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/TransportationArmMoveCommand.java +++ /dev/null @@ -1,127 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CompletableFuture; - -/** - * 处理移动转移机械臂指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_transportation_arm_move") -public class TransportationArmMoveCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - private boolean stop = false; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - this.stop = false; - return runAsync(() -> { - Double xDimDistance = cmdDTO.getDoubleParam("xDimDistance"); - Double yDimDistance = cmdDTO.getDoubleParam("yDimDistance"); - Double zDimDistance = cmdDTO.getDoubleParam("zDimDistance"); - - Double xDimVelocity = cmdDTO.getDoubleParam("xDimVelocity"); - Double yDimVelocity = cmdDTO.getDoubleParam("yDimVelocity"); - Double zDimVelocity = cmdDTO.getDoubleParam("zDimVelocity"); - Integer times = cmdDTO.getIntegerParam("times"); - - List futuresList = new ArrayList<>(); - if (xDimVelocity != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXSet(xDimVelocity); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - if (yDimVelocity != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryYSet(yDimVelocity); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - if (zDimVelocity != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZSet(zDimVelocity); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - commandWait(futuresList.toArray(new CommandFuture[0])); - - futuresList.clear(); - if (times != null) { - for (int i = 0; i < times; i++) { - if (stop) { - return; - } - if (xDimDistance != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMoveBy(xDimDistance); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - if (yDimDistance != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryYMoveBy(yDimDistance); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - if (zDimDistance != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMoveBy(zDimDistance); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - commandWait(futuresList.toArray(new CommandFuture[0])); - if (xDimDistance != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMoveBy(-xDimDistance); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - if (yDimDistance != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryYMoveBy(-yDimDistance); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - if (zDimDistance != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMoveBy(-zDimDistance); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - commandWait(futuresList.toArray(new CommandFuture[0])); - } - } else { - if (xDimDistance != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMoveBy(xDimDistance); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - if (yDimDistance != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryYMoveBy(yDimDistance); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - if (zDimDistance != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMoveBy(zDimDistance); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - - commandWait(futuresList.toArray(new CommandFuture[0])); - } - - - }); - } - - public synchronized void stop() { - this.stop = true; - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/TransportationArmResetCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/TransportationArmResetCommand.java deleted file mode 100644 index b80ac88..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/TransportationArmResetCommand.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CompletableFuture; - -/** - * 处理复位转移机械臂指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_transportation_arm_reset") -public class TransportationArmResetCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - return runAsync(() -> { - List dim = (List) cmdDTO.getParams().get("dim"); - List futuresList = new ArrayList<>(); - if (dim != null && dim.contains("x")) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXOrigin(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - if (dim != null && dim.contains("y")) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryYOrigin(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - - if (dim != null && dim.contains("z")) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZOrigin(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - - commandWait(futuresList.toArray(new CommandFuture[0])); - }); - } -} - diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/TransportationArmStopCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/TransportationArmStopCommand.java deleted file mode 100644 index a3e57d4..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/TransportationArmStopCommand.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.iflytop.gd.app.cmd.debug; - -import com.iflytop.gd.app.core.BaseCommandHandler; -import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CompletableFuture; - -/** - * 处理停止转移机械臂移动指令 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_transportation_arm_stop") -public class TransportationArmStopCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - private final TransportationArmMoveCommand transportationArmMoveCommand; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - transportationArmMoveCommand.stop(); - return runAsync(() -> { - List dim = (List) cmdDTO.getParams().get("dim"); - List futuresList = new ArrayList<>(); - if (dim != null && dim.contains("x")) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXStop(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - if (dim != null && dim.contains("y")) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryYStop(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - - if (dim != null && dim.contains("z")) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZStop(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - - commandWait(futuresList.toArray(new CommandFuture[0])); - }); - } -} -