From 27f9003efb6b2c1f23a32559c90345797f6611ef Mon Sep 17 00:00:00 2001 From: HSZ_HeSongZhen <210202959@qq.com> Date: Tue, 6 May 2025 11:21:09 +0800 Subject: [PATCH 1/2] add: IO TODO --- src/main/java/com/iflytop/gd/hardware/controller/IOController.java | 5 +++++ src/main/java/com/iflytop/gd/hardware/service/IOService.java | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 src/main/java/com/iflytop/gd/hardware/controller/IOController.java create mode 100644 src/main/java/com/iflytop/gd/hardware/service/IOService.java diff --git a/src/main/java/com/iflytop/gd/hardware/controller/IOController.java b/src/main/java/com/iflytop/gd/hardware/controller/IOController.java new file mode 100644 index 0000000..340cab4 --- /dev/null +++ b/src/main/java/com/iflytop/gd/hardware/controller/IOController.java @@ -0,0 +1,5 @@ +package com.iflytop.gd.hardware.controller; + +// TODO: +public class IOController { +} diff --git a/src/main/java/com/iflytop/gd/hardware/service/IOService.java b/src/main/java/com/iflytop/gd/hardware/service/IOService.java new file mode 100644 index 0000000..1f43723 --- /dev/null +++ b/src/main/java/com/iflytop/gd/hardware/service/IOService.java @@ -0,0 +1,5 @@ +package com.iflytop.gd.hardware.service; + +// TODO: +public class IOService { +} From a9301d25fe8eecb05a0024957b79cd8497a5ad5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Tue, 6 May 2025 14:40:19 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../debug/ColdTrapStartRecycleCommandHandler.java | 29 ++++++++++++ .../ColdTrapStartRefrigerationCommandHandler.java | 29 ++++++++++++ .../debug/ColdTrapStopHeatingCommandHandler.java | 22 ++++++++++ .../debug/ColdTrapStopRecycleCommandHandler.java | 29 ++++++++++++ .../ColdTrapStopRefrigerationCommandHandler.java | 29 ++++++++++++ .../debug/CoverElevatorLiftDownCommandHandler.java | 30 +++++++++++++ .../debug/CoverElevatorLiftUpCommandHandler.java | 31 +++++++++++++ .../debug/CoverElevatorResetCommandHandler.java | 30 +++++++++++++ .../cmd/debug/CoverElevatorStopCommandHandler.java | 30 +++++++++++++ .../iflytop/gd/app/cmd/debug/DebugDoorClose.java | 31 ------------- .../iflytop/gd/app/cmd/debug/DebugDoorMove.java | 30 ------------- .../iflytop/gd/app/cmd/debug/DebugDoorOpen.java | 31 ------------- .../iflytop/gd/app/cmd/debug/DebugDoorOrigin.java | 29 ------------ .../com/iflytop/gd/app/cmd/debug/DebugDoorSet.java | 32 -------------- .../iflytop/gd/app/cmd/debug/DebugDoorStop.java | 29 ------------ .../com/iflytop/gd/app/cmd/debug/DebugPumpSet.java | 47 -------------------- .../iflytop/gd/app/cmd/debug/DebugPumpStart.java | 48 -------------------- .../iflytop/gd/app/cmd/debug/DebugPumpStop.java | 45 ------------------- .../gd/app/cmd/debug/DebugSualRobotMoveJoint.java | 34 --------------- .../gd/app/cmd/debug/DebugSualRobotMovePoint.java | 32 -------------- .../gd/app/cmd/debug/DebugSualRobotOrigin.java | 45 ------------------- .../gd/app/cmd/debug/DebugSualRobotSet.java | 45 ------------------- .../gd/app/cmd/debug/DebugSualRobotStop.java | 45 ------------------- .../gd/app/cmd/debug/DoorCloseCommandHandler.java | 30 +++++++++++++ .../gd/app/cmd/debug/DoorOpenCommandHandler.java | 29 ++++++++++++ .../gd/app/cmd/debug/DoorStopCommandHandler.java | 29 ++++++++++++ .../gd/app/cmd/debug/FanStartCommandHandler.java | 40 +++++++++++++++++ .../gd/app/cmd/debug/FanStopCommandHandler.java | 40 +++++++++++++++++ .../app/cmd/debug/HeaterStartCommandHandler.java | 41 +++++++++++++++++ .../HeaterStartHeatMaintainingCommandHandler.java | 22 ++++++++++ .../gd/app/cmd/debug/HeaterStopCommandHandler.java | 40 +++++++++++++++++ .../debug/HeaterStopMaintainingCommandHandler.java | 22 ++++++++++ .../cmd/debug/HoldingJawCloseCommandHandler.java | 29 ++++++++++++ .../cmd/debug/HoldingJawOpenCommandHandler.java | 29 ++++++++++++ .../cmd/debug/HoldingJawPauseCommandHandler.java | 30 +++++++++++++ .../cmd/debug/LiquidArmResetCommandHandler.java | 43 ++++++++++++++++++ .../cmd/debug/LiquidArmRotateCommandHandler.java | 35 +++++++++++++++ .../app/cmd/debug/LiquidArmStopCommandHandler.java | 43 ++++++++++++++++++ .../cmd/debug/LiquidPumpStartCommandHandler.java | 47 ++++++++++++++++++++ .../cmd/debug/LiquidPumpStopCommandHandler.java | 43 ++++++++++++++++++ .../PalletElevatorLiftDownCommandHandler.java | 42 ++++++++++++++++++ .../debug/PalletElevatorLiftUpCommandHandler.java | 41 +++++++++++++++++ .../debug/PalletElevatorStopCommandHandler.java | 41 +++++++++++++++++ .../app/cmd/debug/ShakerStartCommandHandler.java | 30 +++++++++++++ .../gd/app/cmd/debug/ShakerStopCommandHandler.java | 30 +++++++++++++ .../debug/TransportationArmMoveCommandHandler.java | 51 ++++++++++++++++++++++ .../TransportationArmResetCommandHandler.java | 50 +++++++++++++++++++++ .../debug/TransportationArmStopCommandHandler.java | 50 +++++++++++++++++++++ 48 files changed, 1186 insertions(+), 523 deletions(-) create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStartRecycleCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStartRefrigerationCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStopHeatingCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStopRecycleCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStopRefrigerationCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorLiftDownCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorLiftUpCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorResetCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorStopCommandHandler.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorClose.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorMove.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorOpen.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorOrigin.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorSet.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorStop.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugPumpSet.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugPumpStart.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugPumpStop.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotMoveJoint.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotMovePoint.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotOrigin.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotSet.java delete mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotStop.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DoorCloseCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DoorOpenCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DoorStopCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/FanStartCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/FanStopCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStartCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStartHeatMaintainingCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStopCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStopMaintainingCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawCloseCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawOpenCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawPauseCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmResetCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmRotateCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmStopCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/LiquidPumpStartCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/LiquidPumpStopCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftDownCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftUpCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorStopCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/ShakerStartCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/ShakerStopCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/TransportationArmMoveCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/TransportationArmResetCommandHandler.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/TransportationArmStopCommandHandler.java diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStartRecycleCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStartRecycleCommandHandler.java new file mode 100644 index 0000000..76889e9 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStartRecycleCommandHandler.java @@ -0,0 +1,29 @@ +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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 处理冷阱开启循环指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_cold_trap_start_recycle") +public class ColdTrapStartRecycleCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + DeviceCommand 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/ColdTrapStartRefrigerationCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStartRefrigerationCommandHandler.java new file mode 100644 index 0000000..aefcdc5 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStartRefrigerationCommandHandler.java @@ -0,0 +1,29 @@ +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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 处理启动冷阱制冷指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_cold_trap_start_refrigeration") +public class ColdTrapStartRefrigerationCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + DeviceCommand 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/ColdTrapStopHeatingCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStopHeatingCommandHandler.java new file mode 100644 index 0000000..778cb84 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStopHeatingCommandHandler.java @@ -0,0 +1,22 @@ +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; + +/** + * 处理冷阱停止加热指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_cold_trap_stop_heating") +public class ColdTrapStopHeatingCommandHandler extends BaseCommandHandler { + @Override + public void handle(CmdDTO cmdDTO) { + + } +} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStopRecycleCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStopRecycleCommandHandler.java new file mode 100644 index 0000000..e13702e --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStopRecycleCommandHandler.java @@ -0,0 +1,29 @@ +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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 处理停止冷阱循环指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_cold_trap_stop_recycle") +public class ColdTrapStopRecycleCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + DeviceCommand 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/ColdTrapStopRefrigerationCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStopRefrigerationCommandHandler.java new file mode 100644 index 0000000..30f0515 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/ColdTrapStopRefrigerationCommandHandler.java @@ -0,0 +1,29 @@ +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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 处理停止冷阱制冷指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_cold_trap_stop_refrigeration") +public class ColdTrapStopRefrigerationCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + DeviceCommand 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/CoverElevatorLiftDownCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorLiftDownCommandHandler.java new file mode 100644 index 0000000..e66bba7 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorLiftDownCommandHandler.java @@ -0,0 +1,30 @@ +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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 处理拍子电机下降指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_cover_elevator_lift_down") +public class CoverElevatorLiftDownCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + Double velocity = cmdDTO.getDoubleParam("velocity"); + DeviceCommand deviceCommand = DeviceCommandGenerator.trayMotorMove(velocity); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } +} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorLiftUpCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorLiftUpCommandHandler.java new file mode 100644 index 0000000..da6972f --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorLiftUpCommandHandler.java @@ -0,0 +1,31 @@ +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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + + +/** + * 处理拍子电机抬升指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_cover_elevator_lift_up") +public class CoverElevatorLiftUpCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + Double velocity = cmdDTO.getDoubleParam("velocity"); + DeviceCommand deviceCommand = DeviceCommandGenerator.trayMotorMove(velocity); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } +} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorResetCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorResetCommandHandler.java new file mode 100644 index 0000000..92abf4c --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorResetCommandHandler.java @@ -0,0 +1,30 @@ +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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 处理拍子抬升电机复位指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_cover_elevator_reset") +public class CoverElevatorResetCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + DeviceCommand 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/CoverElevatorStopCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorStopCommandHandler.java new file mode 100644 index 0000000..fa68a83 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorStopCommandHandler.java @@ -0,0 +1,30 @@ +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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 处理拍子抬升电机停止指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_cover_elevator_stop") +public class CoverElevatorStopCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + DeviceCommand 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/DebugDoorClose.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorClose.java deleted file mode 100644 index 93ccc9d..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorClose.java +++ /dev/null @@ -1,31 +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.DeviceCommand; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * 门电机 关门 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_door_close") -public class DebugDoorClose extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public void handle(CmdDTO cmdDTO) throws Exception { - Double position = cmdDTO.getDoubleParam("position"); - DeviceCommand deviceCommand = DeviceCommandGenerator.doorMove(position); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - } -} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorMove.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorMove.java deleted file mode 100644 index fd332fc..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorMove.java +++ /dev/null @@ -1,30 +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.DeviceCommand; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * 门电机 移动指定距离 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_door_move") -public class DebugDoorMove extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - @Override - public void handle(CmdDTO cmdDTO) throws Exception { - Double position = cmdDTO.getDoubleParam("position"); - DeviceCommand deviceCommand = DeviceCommandGenerator.doorMove(position); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - } -} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorOpen.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorOpen.java deleted file mode 100644 index f0e44e2..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorOpen.java +++ /dev/null @@ -1,31 +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.DeviceCommand; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * 门电机 开门 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_door_open") -public class DebugDoorOpen extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public void handle(CmdDTO cmdDTO) throws Exception { - Double position = cmdDTO.getDoubleParam("position"); - DeviceCommand deviceCommand = DeviceCommandGenerator.doorMove(position); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - } -} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorOrigin.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorOrigin.java deleted file mode 100644 index 4c5e815..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorOrigin.java +++ /dev/null @@ -1,29 +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.DeviceCommand; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * 门电机 回原点 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_door_stop") -public class DebugDoorOrigin extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - @Override - public void handle(CmdDTO cmdDTO) throws Exception { - DeviceCommand 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/DebugDoorSet.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorSet.java deleted file mode 100644 index 7f9d45d..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorSet.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.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommand; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * 门电机 设置参数 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_door_set") -public class DebugDoorSet extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public void handle(CmdDTO cmdDTO) throws Exception { - Integer current = cmdDTO.getIntegerParam("current"); - Double speed = cmdDTO.getDoubleParam("speed"); - DeviceCommand deviceCommand = DeviceCommandGenerator.doorSet(current, speed); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - } -} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorStop.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorStop.java deleted file mode 100644 index b784a56..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorStop.java +++ /dev/null @@ -1,29 +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.DeviceCommand; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * 门电机 停止移动 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_door_stop") -public class DebugDoorStop extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - @Override - public void handle(CmdDTO cmdDTO) throws Exception { - DeviceCommand 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/DebugPumpSet.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugPumpSet.java deleted file mode 100644 index 5d54b14..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugPumpSet.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.DeviceCommand; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import com.iflytop.gd.common.enums.cmd.CmdDevice; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * 加液泵 设置加液泵 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_pump_set") -public class DebugPumpSet extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public void handle(CmdDTO cmdDTO) throws Exception { - String pumpId = cmdDTO.getStringParam("pumpId"); - Integer current = cmdDTO.getIntegerParam("current"); - Double speed = cmdDTO.getDoubleParam("speed"); - Double innerDiameter = cmdDTO.getDoubleParam("innerDiameter"); - CmdDevice pumpDevice = CmdDevice.valueOf(pumpId); - DeviceCommand deviceCommand; - switch (pumpDevice) { - case CmdDevice.acid_pump_1 -> deviceCommand = DeviceCommandGenerator.acidPump1Set(current, speed); - case CmdDevice.acid_pump_2 -> deviceCommand = DeviceCommandGenerator.acidPump2Set(current, speed); - case CmdDevice.acid_pump_3 -> deviceCommand = DeviceCommandGenerator.acidPump3Set(current, speed); - case CmdDevice.acid_pump_4 -> deviceCommand = DeviceCommandGenerator.acidPump4Set(current, speed); - case CmdDevice.acid_pump_5 -> deviceCommand = DeviceCommandGenerator.acidPump5Set(current, speed); - case CmdDevice.acid_pump_6 -> deviceCommand = DeviceCommandGenerator.acidPump6Set(current, speed); - case CmdDevice.acid_pump_7 -> deviceCommand = DeviceCommandGenerator.acidPump7Set(current, speed); - case CmdDevice.acid_pump_8 -> deviceCommand = DeviceCommandGenerator.acidPump8Set(current, speed); - default -> throw new RuntimeException("pumpId 未找到"); - } - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - } -} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugPumpStart.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugPumpStart.java deleted file mode 100644 index d0cc338..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugPumpStart.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.DeviceCommand; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import com.iflytop.gd.common.enums.cmd.CmdDevice; -import com.iflytop.gd.common.enums.cmd.CmdDirection; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * 加液泵 启动加液泵 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_pump_start") -public class DebugPumpStart extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public void handle(CmdDTO cmdDTO) throws Exception { - String pumpId = cmdDTO.getStringParam("pumpId"); - String direction = cmdDTO.getStringParam("direction"); - Double volume = cmdDTO.getDoubleParam("volume"); - CmdDirection directionEnum = CmdDirection.valueOf(direction); - CmdDevice pumpDevice = CmdDevice.valueOf(pumpId); - DeviceCommand deviceCommand; - switch (pumpDevice) { - case CmdDevice.acid_pump_1 -> deviceCommand = DeviceCommandGenerator.acidPump1Move(directionEnum, volume); - case CmdDevice.acid_pump_2 -> deviceCommand = DeviceCommandGenerator.acidPump2Move(directionEnum, volume); - case CmdDevice.acid_pump_3 -> deviceCommand = DeviceCommandGenerator.acidPump3Move(directionEnum, volume); - case CmdDevice.acid_pump_4 -> deviceCommand = DeviceCommandGenerator.acidPump4Move(directionEnum, volume); - case CmdDevice.acid_pump_5 -> deviceCommand = DeviceCommandGenerator.acidPump5Move(directionEnum, volume); - case CmdDevice.acid_pump_6 -> deviceCommand = DeviceCommandGenerator.acidPump6Move(directionEnum, volume); - case CmdDevice.acid_pump_7 -> deviceCommand = DeviceCommandGenerator.acidPump7Move(directionEnum, volume); - case CmdDevice.acid_pump_8 -> deviceCommand = DeviceCommandGenerator.acidPump8Move(directionEnum, volume); - default -> throw new RuntimeException("pumpId 未找到"); - } - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - } -} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugPumpStop.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugPumpStop.java deleted file mode 100644 index 61f475e..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugPumpStop.java +++ /dev/null @@ -1,45 +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.DeviceCommand; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import com.iflytop.gd.common.enums.cmd.CmdDevice; -import com.iflytop.gd.common.enums.cmd.CmdDirection; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * 加液泵 停止加液泵 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_pump_stop") -public class DebugPumpStop extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public void handle(CmdDTO cmdDTO) throws Exception { - String pumpId = cmdDTO.getStringParam("pumpId"); - CmdDevice pumpDevice = CmdDevice.valueOf(pumpId); - DeviceCommand deviceCommand; - switch (pumpDevice) { - case CmdDevice.acid_pump_1 -> deviceCommand = DeviceCommandGenerator.acidPump1Stop(); - case CmdDevice.acid_pump_2 -> deviceCommand = DeviceCommandGenerator.acidPump2Stop(); - case CmdDevice.acid_pump_3 -> deviceCommand = DeviceCommandGenerator.acidPump3Stop(); - case CmdDevice.acid_pump_4 -> deviceCommand = DeviceCommandGenerator.acidPump4Stop(); - case CmdDevice.acid_pump_5 -> deviceCommand = DeviceCommandGenerator.acidPump5Stop(); - case CmdDevice.acid_pump_6 -> deviceCommand = DeviceCommandGenerator.acidPump6Stop(); - case CmdDevice.acid_pump_7 -> deviceCommand = DeviceCommandGenerator.acidPump7Stop(); - case CmdDevice.acid_pump_8 -> deviceCommand = DeviceCommandGenerator.acidPump8Stop(); - default -> throw new RuntimeException("pumpId 未找到"); - } - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - } -} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotMoveJoint.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotMoveJoint.java deleted file mode 100644 index b31ca06..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotMoveJoint.java +++ /dev/null @@ -1,34 +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.DeviceCommand; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * 加液机械臂 轴移动到指定角度 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_sual_robot_move_joint") -public class DebugSualRobotMoveJoint extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public void handle(CmdDTO cmdDTO) throws Exception { - Double joint1 = cmdDTO.getDoubleParam("joint1"); - Double joint2 = cmdDTO.getDoubleParam("joint2"); - DeviceCommand deviceCommandJoint1 = DeviceCommandGenerator.dualRobotJoint1Move(joint1); - CommandFuture deviceCommandJoint1Future = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommandJoint1); - DeviceCommand deviceCommandJoint2 = DeviceCommandGenerator.dualRobotJoint1Move(joint2); - CommandFuture deviceCommandJoint2Future = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommandJoint2); - commandWait(deviceCommandJoint1Future, deviceCommandJoint2Future); - } -} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotMovePoint.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotMovePoint.java deleted file mode 100644 index 322e037..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotMovePoint.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.app.service.DeviceCommandService; -import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommand; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * 加液机械臂 移动到指定坐标 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_sual_robot_move_point") -public class DebugSualRobotMovePoint extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public void handle(CmdDTO cmdDTO) throws Exception { - Double x = cmdDTO.getDoubleParam("x"); - Double y = cmdDTO.getDoubleParam("y"); - DeviceCommand deviceCommand = DeviceCommandGenerator.dualRobotMovePoint(x, y); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - commandWait(deviceCommandFuture); - } -} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotOrigin.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotOrigin.java deleted file mode 100644 index 3d37662..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotOrigin.java +++ /dev/null @@ -1,45 +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.DeviceCommand; -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; - -/** - * 加液机械臂 回原点 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_sual_robot_origin") -public class DebugSualRobotOrigin extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public void handle(CmdDTO cmdDTO) throws Exception { - Boolean joint1 = cmdDTO.getBooleanParam("joint1"); - Boolean joint2 = cmdDTO.getBooleanParam("joint2"); - List futuresList = new ArrayList<>(); - if (joint1) { - DeviceCommand deviceCommand = DeviceCommandGenerator.dualRobotJoint1Origin(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - if (joint2) { - DeviceCommand deviceCommand = DeviceCommandGenerator.dualRobotJoint2Origin(); - 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/DebugSualRobotSet.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotSet.java deleted file mode 100644 index 6096cd5..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotSet.java +++ /dev/null @@ -1,45 +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.DeviceCommand; -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; - -/** - * 加液机械臂 设置参数 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_sual_robot_set") -public class DebugSualRobotSet extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public void handle(CmdDTO cmdDTO) throws Exception { - Double joint1Speed = cmdDTO.getDoubleParam("joint1Speed"); - Double joint2Speed = cmdDTO.getDoubleParam("joint2Speed"); - List futuresList = new ArrayList<>(); - if (joint1Speed != null) { - DeviceCommand deviceCommand = DeviceCommandGenerator.dualRobotJoint1Set(joint1Speed); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - if (joint2Speed != null) { - DeviceCommand deviceCommand = DeviceCommandGenerator.dualRobotJoint2Set(joint2Speed); - 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/DebugSualRobotStop.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotStop.java deleted file mode 100644 index fa64207..0000000 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotStop.java +++ /dev/null @@ -1,45 +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.DeviceCommand; -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; - -/** - * 加液机械臂 停止移动 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("debug_sual_robot_stop") -public class DebugSualRobotStop extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public void handle(CmdDTO cmdDTO) throws Exception { - Boolean joint1 = cmdDTO.getBooleanParam("joint1"); - Boolean joint2 = cmdDTO.getBooleanParam("joint2"); - List futuresList = new ArrayList<>(); - if (joint1) { - DeviceCommand deviceCommand = DeviceCommandGenerator.dualRobotJoint1Stop(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - if (joint2) { - DeviceCommand 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/DoorCloseCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DoorCloseCommandHandler.java new file mode 100644 index 0000000..ef38bb1 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DoorCloseCommandHandler.java @@ -0,0 +1,30 @@ +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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 处理关门指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_door_close") +public class DoorCloseCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + DeviceCommand deviceCommand = DeviceCommandGenerator.doorMove(0.0); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } +} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DoorOpenCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DoorOpenCommandHandler.java new file mode 100644 index 0000000..ca36ecd --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DoorOpenCommandHandler.java @@ -0,0 +1,29 @@ +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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 处理开门指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_door_open") +public class DoorOpenCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + DeviceCommand deviceCommand = DeviceCommandGenerator.doorMove(100.0); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } +} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DoorStopCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DoorStopCommandHandler.java new file mode 100644 index 0000000..3cbcceb --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DoorStopCommandHandler.java @@ -0,0 +1,29 @@ +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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 处理停止门运动指令处理器 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_door_stop") +public class DoorStopCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + DeviceCommand 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/FanStartCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/FanStartCommandHandler.java new file mode 100644 index 0000000..8c0d14a --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/FanStartCommandHandler.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.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 打开冷却风扇 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_fan_start") +public class FanStartCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + Integer index = cmdDTO.getIntegerParam("index"); + DeviceCommand deviceCommand; + switch (index) { + case 1 -> deviceCommand = DeviceCommandGenerator.fan1Open(); + case 2 -> deviceCommand = DeviceCommandGenerator.fan2Open(); + case 3 -> deviceCommand = DeviceCommandGenerator.fan3Open(); + case 4 -> deviceCommand = DeviceCommandGenerator.fan4Open(); + case 5 -> deviceCommand = DeviceCommandGenerator.fan5Open(); + case 6 -> 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/FanStopCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/FanStopCommandHandler.java new file mode 100644 index 0000000..548fbfe --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/FanStopCommandHandler.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.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 关闭冷却风扇 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_fan_stop") +public class FanStopCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + Integer index = cmdDTO.getIntegerParam("index"); + DeviceCommand deviceCommand; + switch (index) { + case 1 -> deviceCommand = DeviceCommandGenerator.fan1Close(); + case 2 -> deviceCommand = DeviceCommandGenerator.fan2Close(); + case 3 -> deviceCommand = DeviceCommandGenerator.fan3Close(); + case 4 -> deviceCommand = DeviceCommandGenerator.fan4Close(); + case 5 -> deviceCommand = DeviceCommandGenerator.fan5Close(); + case 6 -> 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/HeaterStartCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStartCommandHandler.java new file mode 100644 index 0000000..0b9e781 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStartCommandHandler.java @@ -0,0 +1,41 @@ +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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 处理启动加热器指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_heater_start") +public class HeaterStartCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + Integer index = cmdDTO.getIntegerParam("index"); + Double temperature = cmdDTO.getDoubleParam("temperature"); + DeviceCommand deviceCommand; + switch (index) { + case 1 -> deviceCommand = DeviceCommandGenerator.heatRod1Open(temperature); + case 2 -> deviceCommand = DeviceCommandGenerator.heatRod2Open(temperature); + case 3 -> deviceCommand = DeviceCommandGenerator.heatRod3Open(temperature); + case 4 -> deviceCommand = DeviceCommandGenerator.heatRod4Open(temperature); + case 5 -> deviceCommand = DeviceCommandGenerator.heatRod5Open(temperature); + case 6 -> 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/HeaterStartHeatMaintainingCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStartHeatMaintainingCommandHandler.java new file mode 100644 index 0000000..523ed25 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStartHeatMaintainingCommandHandler.java @@ -0,0 +1,22 @@ +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; + +/** + * 处理启动加热器恒温指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_heater_start_heat_maintaining") +public class HeaterStartHeatMaintainingCommandHandler extends BaseCommandHandler { + @Override + public void handle(CmdDTO cmdDTO) { + + } +} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStopCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStopCommandHandler.java new file mode 100644 index 0000000..47d3f5f --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStopCommandHandler.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.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 处理停止加热器指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_heater_stop") +public class HeaterStopCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + Integer index = cmdDTO.getIntegerParam("index"); + DeviceCommand deviceCommand; + switch (index) { + case 1 -> deviceCommand = DeviceCommandGenerator.heatRod1Close(); + case 2 -> deviceCommand = DeviceCommandGenerator.heatRod2Close(); + case 3 -> deviceCommand = DeviceCommandGenerator.heatRod3Close(); + case 4 -> deviceCommand = DeviceCommandGenerator.heatRod4Close(); + case 5 -> deviceCommand = DeviceCommandGenerator.heatRod5Close(); + case 6 -> 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/HeaterStopMaintainingCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStopMaintainingCommandHandler.java new file mode 100644 index 0000000..d8eb9cd --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStopMaintainingCommandHandler.java @@ -0,0 +1,22 @@ +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; + +/** + * 处理停止恒温加热指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_heater_stop_heat_maintaining") +public class HeaterStopMaintainingCommandHandler extends BaseCommandHandler { + @Override + public void handle(CmdDTO cmdDTO) { + + } +} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawCloseCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawCloseCommandHandler.java new file mode 100644 index 0000000..9edef8c --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawCloseCommandHandler.java @@ -0,0 +1,29 @@ +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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 处理夹爪闭合指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_holding_jaw_close") +public class HoldingJawCloseCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + DeviceCommand deviceCommand = DeviceCommandGenerator.clawMove(0.0); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } +} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawOpenCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawOpenCommandHandler.java new file mode 100644 index 0000000..dcd541e --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawOpenCommandHandler.java @@ -0,0 +1,29 @@ +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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 处理打开夹爪指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_holding_jaw_open") +public class HoldingJawOpenCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + DeviceCommand deviceCommand = DeviceCommandGenerator.clawMove(100.0); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } +} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawPauseCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawPauseCommandHandler.java new file mode 100644 index 0000000..56f6a45 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawPauseCommandHandler.java @@ -0,0 +1,30 @@ +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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 处理暂停夹爪指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_holding_jaw_pause") +public class HoldingJawPauseCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + DeviceCommand 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/LiquidArmResetCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmResetCommandHandler.java new file mode 100644 index 0000000..bd9071f --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmResetCommandHandler.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.DeviceCommand; +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; + +/** + * 复位加液臂指令处理器 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_liquid_arm_reset") +public class LiquidArmResetCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + List target = (List) cmdDTO.getParams().get("target"); + List futuresList = new ArrayList<>(); + if (target != null && target.contains("largeArm")) { + DeviceCommand deviceCommand = DeviceCommandGenerator.dualRobotJoint1Origin(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + if (target != null && target.contains("smallArm")) { + DeviceCommand deviceCommand = DeviceCommandGenerator.dualRobotJoint2Origin(); + 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/LiquidArmRotateCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmRotateCommandHandler.java new file mode 100644 index 0000000..0a33b9f --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmRotateCommandHandler.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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 处理加液臂移动指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_liquid_arm_rotation") +public class LiquidArmRotateCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + Double largeArmAngle = cmdDTO.getDoubleParam("largeArmAngle"); + Double smallArmAngle = cmdDTO.getDoubleParam("smallArmAngle"); + DeviceCommand deviceCommandJoint1 = DeviceCommandGenerator.dualRobotJoint1Move(largeArmAngle); + CommandFuture deviceCommandJoint1Future = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommandJoint1); + commandWait(deviceCommandJoint1Future); + DeviceCommand deviceCommandJoint2 = DeviceCommandGenerator.dualRobotJoint1Move(smallArmAngle); + CommandFuture deviceCommandJoint2Future = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommandJoint2); + commandWait(deviceCommandJoint1Future, deviceCommandJoint2Future); + } +} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmStopCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmStopCommandHandler.java new file mode 100644 index 0000000..03a8f8e --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmStopCommandHandler.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.DeviceCommand; +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; + +/** + * 处理加液臂停止指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_liquid_arm_stop") +public class LiquidArmStopCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + List target = (List) cmdDTO.getParams().get("target"); + List futuresList = new ArrayList<>(); + if (target != null && target.contains("largeArm")) { + DeviceCommand deviceCommand = DeviceCommandGenerator.dualRobotJoint1Stop(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + if (target != null && target.contains("smallArm")) { + DeviceCommand 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/LiquidPumpStartCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidPumpStartCommandHandler.java new file mode 100644 index 0000000..2476662 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidPumpStartCommandHandler.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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import com.iflytop.gd.common.enums.cmd.CmdDevice; +import com.iflytop.gd.common.enums.cmd.CmdDirection; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 处理加液泵启动指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_liquid_pump_start") +public class LiquidPumpStartCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + Integer index = cmdDTO.getIntegerParam("index"); + String direction = cmdDTO.getStringParam("direction"); + Double volume = cmdDTO.getDoubleParam("volume"); + CmdDirection directionEnum = CmdDirection.valueOf(direction); + DeviceCommand deviceCommand; + switch (index) { + case 1 -> deviceCommand = DeviceCommandGenerator.acidPump1Move(directionEnum, volume); + case 2 -> deviceCommand = DeviceCommandGenerator.acidPump2Move(directionEnum, volume); + case 3 -> deviceCommand = DeviceCommandGenerator.acidPump3Move(directionEnum, volume); + case 4 -> deviceCommand = DeviceCommandGenerator.acidPump4Move(directionEnum, volume); + case 5 -> deviceCommand = DeviceCommandGenerator.acidPump5Move(directionEnum, volume); + case 6 -> deviceCommand = DeviceCommandGenerator.acidPump6Move(directionEnum, volume); + case 7 -> deviceCommand = DeviceCommandGenerator.acidPump7Move(directionEnum, volume); + case 8 -> deviceCommand = DeviceCommandGenerator.acidPump8Move(directionEnum, 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/LiquidPumpStopCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidPumpStopCommandHandler.java new file mode 100644 index 0000000..5ef06fb --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidPumpStopCommandHandler.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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import com.iflytop.gd.common.enums.cmd.CmdDevice; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 处理加液泵停止指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_liquid_pump_stop") +public class LiquidPumpStopCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + Integer index = cmdDTO.getIntegerParam("index"); + DeviceCommand deviceCommand; + switch (index) { + case 1 -> deviceCommand = DeviceCommandGenerator.acidPump1Stop(); + case 2 -> deviceCommand = DeviceCommandGenerator.acidPump2Stop(); + case 3 -> deviceCommand = DeviceCommandGenerator.acidPump3Stop(); + case 4 -> deviceCommand = DeviceCommandGenerator.acidPump4Stop(); + case 5 -> deviceCommand = DeviceCommandGenerator.acidPump5Stop(); + case 6 -> deviceCommand = DeviceCommandGenerator.acidPump6Stop(); + case 7 -> deviceCommand = DeviceCommandGenerator.acidPump7Stop(); + case 8 -> 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/PalletElevatorLiftDownCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftDownCommandHandler.java new file mode 100644 index 0000000..8560fd0 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftDownCommandHandler.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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + + +/** + * 处理降下托盘指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_pallet_elevator_lift_down") +public class PalletElevatorLiftDownCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + Integer index = cmdDTO.getIntegerParam("index"); + Double distance = cmdDTO.getDoubleParam("distance"); + DeviceCommand deviceCommand; + switch (index) { + case 1 -> deviceCommand = DeviceCommandGenerator.heaterMotor1Move(distance); + case 2 -> deviceCommand = DeviceCommandGenerator.heaterMotor2Move(distance); + case 3 -> deviceCommand = DeviceCommandGenerator.heaterMotor3Move(distance); + case 4 -> deviceCommand = DeviceCommandGenerator.heaterMotor4Move(distance); + case 5 -> deviceCommand = DeviceCommandGenerator.heaterMotor5Move(distance); + case 6 -> deviceCommand = DeviceCommandGenerator.heaterMotor6Move(distance); + 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/PalletElevatorLiftUpCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftUpCommandHandler.java new file mode 100644 index 0000000..6170556 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftUpCommandHandler.java @@ -0,0 +1,41 @@ +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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 处理托盘电机上升到指定位置 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_pallet_elevator_lift_up") +public class PalletElevatorLiftUpCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + Integer index = cmdDTO.getIntegerParam("index"); + Double distance = cmdDTO.getDoubleParam("distance"); + DeviceCommand deviceCommand; + switch (index) { + case 1 -> deviceCommand = DeviceCommandGenerator.heaterMotor1Move(distance); + case 2 -> deviceCommand = DeviceCommandGenerator.heaterMotor2Move(distance); + case 3 -> deviceCommand = DeviceCommandGenerator.heaterMotor3Move(distance); + case 4 -> deviceCommand = DeviceCommandGenerator.heaterMotor4Move(distance); + case 5 -> deviceCommand = DeviceCommandGenerator.heaterMotor5Move(distance); + case 6 -> deviceCommand = DeviceCommandGenerator.heaterMotor6Move(distance); + 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/PalletElevatorStopCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorStopCommandHandler.java new file mode 100644 index 0000000..fc21615 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorStopCommandHandler.java @@ -0,0 +1,41 @@ +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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + + +/** + * 处理停止托盘抬升器指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_pallet_elevator_stop") +public class PalletElevatorStopCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + Integer index = cmdDTO.getIntegerParam("index"); + DeviceCommand deviceCommand; + switch (index) { + case 1 -> deviceCommand = DeviceCommandGenerator.heaterMotor1Stop(); + case 2 -> deviceCommand = DeviceCommandGenerator.heaterMotor2Stop(); + case 3 -> deviceCommand = DeviceCommandGenerator.heaterMotor3Stop(); + case 4 -> deviceCommand = DeviceCommandGenerator.heaterMotor4Stop(); + case 5 -> deviceCommand = DeviceCommandGenerator.heaterMotor5Stop(); + case 6 -> 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/ShakerStartCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/ShakerStartCommandHandler.java new file mode 100644 index 0000000..f78904e --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/ShakerStartCommandHandler.java @@ -0,0 +1,30 @@ +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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 处理启动摇匀器指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_shaker_start") +public class ShakerStartCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + DeviceCommand 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/ShakerStopCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/ShakerStopCommandHandler.java new file mode 100644 index 0000000..c7852d9 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/ShakerStopCommandHandler.java @@ -0,0 +1,30 @@ +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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 处理停止摇匀器指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_shaker_stop") +public class ShakerStopCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + DeviceCommand 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/TransportationArmMoveCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/TransportationArmMoveCommandHandler.java new file mode 100644 index 0000000..c04e9b8 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/TransportationArmMoveCommandHandler.java @@ -0,0 +1,51 @@ +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.DeviceCommand; +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; + +/** + * 处理移动转移机械臂指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_transportation_arm_move") +public class TransportationArmMoveCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + Double x = cmdDTO.getDoubleParam("xDimDistance"); + Double y = cmdDTO.getDoubleParam("yDimDistance"); + Double z = cmdDTO.getDoubleParam("zDimDistance"); + List futuresList = new ArrayList<>(); + if(x != null){ + DeviceCommand deviceCommand = DeviceCommandGenerator.gantryXMove(x); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + if(y != null){ + DeviceCommand deviceCommand = DeviceCommandGenerator.gantryYMove(y); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + if(z != null){ + DeviceCommand deviceCommand = DeviceCommandGenerator.gantryZMove(z); + 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/TransportationArmResetCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/TransportationArmResetCommandHandler.java new file mode 100644 index 0000000..2e89842 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/TransportationArmResetCommandHandler.java @@ -0,0 +1,50 @@ +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.DeviceCommand; +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; + +/** + * 处理复位转移机械臂指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_transportation_arm_reset") +public class TransportationArmResetCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + List dim = (List) cmdDTO.getParams().get("dim"); + List futuresList = new ArrayList<>(); + if (dim != null && dim.contains("x")) { + DeviceCommand deviceCommand = DeviceCommandGenerator.gantryXOrigin(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + if (dim != null && dim.contains("y")) { + DeviceCommand deviceCommand = DeviceCommandGenerator.gantryYOrigin(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + + if (dim != null && dim.contains("z")) { + DeviceCommand 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/TransportationArmStopCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/TransportationArmStopCommandHandler.java new file mode 100644 index 0000000..01da8c0 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/TransportationArmStopCommandHandler.java @@ -0,0 +1,50 @@ +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.DeviceCommand; +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; + +/** + * 处理停止转移机械臂移动指令 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_transportation_arm_stop") +public class TransportationArmStopCommandHandler extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + List dim = (List) cmdDTO.getParams().get("dim"); + List futuresList = new ArrayList<>(); + if (dim != null && dim.contains("x")) { + DeviceCommand deviceCommand = DeviceCommandGenerator.gantryXStop(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + if (dim != null && dim.contains("y")) { + DeviceCommand deviceCommand = DeviceCommandGenerator.gantryYStop(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + + if (dim != null && dim.contains("z")) { + DeviceCommand deviceCommand = DeviceCommandGenerator.gantryZStop(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + + commandWait(futuresList.toArray(new CommandFuture[0])); + } +}