From 2817f08ea122cd8bff9d3d540899a9ab3db6797d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=A2=A6=E8=BF=9C?= <1063331231@qq.com> Date: Tue, 27 May 2025 12:25:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=A2=9E=E5=8A=A0=E5=85=A8=E9=83=A8?= =?UTF-8?q?=E7=94=B5=E6=9C=BA=E4=BD=BF=E8=83=BD=20=E5=A4=B1=E8=83=BD=20?= =?UTF-8?q?=E5=81=9C=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../debug/step/DebugDisabledAllMotorCommand.java | 22 +++++- .../cmd/debug/step/DebugEnableAllMotorCommand.java | 23 +++++- .../cmd/debug/step/DebugStopAllMotorCommand.java | 25 +++++- .../sgs/app/service/device/StepCommandService.java | 19 ----- .../app/ws/client/DeviceEmergencyStopConfig.java | 2 - .../sgs/common/cmd/DeviceCommandGenerator.java | 90 ++++++++++++++++++++-- .../iflytop/sgs/common/enums/cmd/CmdAction.java | 2 +- .../iflytop/sgs/common/enums/cmd/CmdDevice.java | 2 - 8 files changed, 143 insertions(+), 42 deletions(-) delete mode 100644 src/main/java/com/iflytop/sgs/app/service/device/StepCommandService.java diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/step/DebugDisabledAllMotorCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/step/DebugDisabledAllMotorCommand.java index 57a107d..36adefa 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/step/DebugDisabledAllMotorCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/debug/step/DebugDisabledAllMotorCommand.java @@ -2,8 +2,10 @@ package com.iflytop.sgs.app.cmd.debug.step; import com.iflytop.sgs.app.core.BaseCommandHandler; import com.iflytop.sgs.app.model.dto.CmdDTO; -import com.iflytop.sgs.app.service.device.StepCommandService; +import com.iflytop.sgs.app.service.device.DeviceCommandService; import com.iflytop.sgs.common.annotation.CommandDebugMapping; +import com.iflytop.sgs.common.cmd.DeviceCommandBundle; +import com.iflytop.sgs.common.cmd.DeviceCommandGenerator; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -18,13 +20,27 @@ import java.util.concurrent.CompletableFuture; @RequiredArgsConstructor @CommandDebugMapping("debug_disabled_all_motor") public class DebugDisabledAllMotorCommand extends BaseCommandHandler { - private final StepCommandService stepCommandService; + private final DeviceCommandService deviceCommandService; @Override public CompletableFuture handle(CmdDTO cmdDTO) throws Exception { return runAsync(() -> { - //stepCommandService.disabilityAll(); + //门电机 + DeviceCommandBundle doorDisableDeviceCommandBundle = DeviceCommandGenerator.doorDisable(); + deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), doorDisableDeviceCommandBundle); + //x轴 + DeviceCommandBundle xDisableDeviceCommandBundle = DeviceCommandGenerator.transferXDisable(); + deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), xDisableDeviceCommandBundle); + //z轴 + DeviceCommandBundle yDisableDeviceCommandBundle = DeviceCommandGenerator.transferZDisable(); + deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), yDisableDeviceCommandBundle); + //机械臂 + DeviceCommandBundle liquidMotorDisableDeviceCommandBundle = DeviceCommandGenerator.liquidMotorDisable(); + deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidMotorDisableDeviceCommandBundle); + //蠕动泵 + DeviceCommandBundle liquidPumpDisableDeviceCommandBundle = DeviceCommandGenerator.liquidPumpDisable(); + deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidPumpDisableDeviceCommandBundle); }); } } diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/step/DebugEnableAllMotorCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/step/DebugEnableAllMotorCommand.java index f82f58b..2997407 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/step/DebugEnableAllMotorCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/debug/step/DebugEnableAllMotorCommand.java @@ -2,8 +2,10 @@ package com.iflytop.sgs.app.cmd.debug.step; import com.iflytop.sgs.app.core.BaseCommandHandler; import com.iflytop.sgs.app.model.dto.CmdDTO; -import com.iflytop.sgs.app.service.device.StepCommandService; +import com.iflytop.sgs.app.service.device.DeviceCommandService; import com.iflytop.sgs.common.annotation.CommandDebugMapping; +import com.iflytop.sgs.common.cmd.DeviceCommandBundle; +import com.iflytop.sgs.common.cmd.DeviceCommandGenerator; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -18,13 +20,26 @@ import java.util.concurrent.CompletableFuture; @RequiredArgsConstructor @CommandDebugMapping("debug_enable_all_motor") public class DebugEnableAllMotorCommand extends BaseCommandHandler { - private final StepCommandService stepCommandService; - + private final DeviceCommandService deviceCommandService; @Override public CompletableFuture handle(CmdDTO cmdDTO) throws Exception { return runAsync(() -> { - //stepCommandService.enableAll(); + //门电机 + DeviceCommandBundle doorEnableDeviceCommandBundle = DeviceCommandGenerator.doorEnable(); + deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), doorEnableDeviceCommandBundle); + //x轴 + DeviceCommandBundle xEnableDeviceCommandBundle = DeviceCommandGenerator.transferXEnable(); + deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), xEnableDeviceCommandBundle); + //z轴 + DeviceCommandBundle yEnableDeviceCommandBundle = DeviceCommandGenerator.transferZEnable(); + deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), yEnableDeviceCommandBundle); + //机械臂 + DeviceCommandBundle liquidMotorEnableDeviceCommandBundle = DeviceCommandGenerator.liquidMotorEnable(); + deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidMotorEnableDeviceCommandBundle); + //蠕动泵 + DeviceCommandBundle liquidPumpEnableDeviceCommandBundle = DeviceCommandGenerator.liquidPumpEnable(); + deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidPumpEnableDeviceCommandBundle); }); } } diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/step/DebugStopAllMotorCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/step/DebugStopAllMotorCommand.java index 6470fd3..0afde06 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/step/DebugStopAllMotorCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/debug/step/DebugStopAllMotorCommand.java @@ -2,8 +2,12 @@ package com.iflytop.sgs.app.cmd.debug.step; import com.iflytop.sgs.app.core.BaseCommandHandler; import com.iflytop.sgs.app.model.dto.CmdDTO; -import com.iflytop.sgs.app.service.device.StepCommandService; +import com.iflytop.sgs.app.service.device.DeviceCommandService; import com.iflytop.sgs.common.annotation.CommandDebugMapping; +import com.iflytop.sgs.common.cmd.CommandFuture; +import com.iflytop.sgs.common.cmd.DeviceCommandBundle; +import com.iflytop.sgs.common.cmd.DeviceCommandGenerator; +import com.iflytop.sgs.common.utils.CommandUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -18,12 +22,27 @@ import java.util.concurrent.CompletableFuture; @RequiredArgsConstructor @CommandDebugMapping("debug_stop_all_motor") public class DebugStopAllMotorCommand extends BaseCommandHandler { - private final StepCommandService stepCommandService; + private final DeviceCommandService deviceCommandService; @Override public CompletableFuture handle(CmdDTO cmdDTO) throws Exception { return runAsync(() -> { - //stepCommandService.stopAll(); + //门电机 + DeviceCommandBundle doorStopDeviceCommandBundle = DeviceCommandGenerator.doorStop(); + deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), doorStopDeviceCommandBundle); + //x轴 + DeviceCommandBundle xStopDeviceCommandBundle = DeviceCommandGenerator.transferXStop(); + deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), xStopDeviceCommandBundle); + //z轴 + DeviceCommandBundle yStopDeviceCommandBundle = DeviceCommandGenerator.transferZStop(); + deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), yStopDeviceCommandBundle); + //机械臂 + DeviceCommandBundle liquidMotorStopDeviceCommandBundle = DeviceCommandGenerator.liquidMotorStop(); + deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidMotorStopDeviceCommandBundle); + //蠕动泵 + DeviceCommandBundle liquidPumpStopDeviceCommandBundle = DeviceCommandGenerator.liquidPumpStop(); + deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidPumpStopDeviceCommandBundle); + }); } } diff --git a/src/main/java/com/iflytop/sgs/app/service/device/StepCommandService.java b/src/main/java/com/iflytop/sgs/app/service/device/StepCommandService.java deleted file mode 100644 index 0474696..0000000 --- a/src/main/java/com/iflytop/sgs/app/service/device/StepCommandService.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.iflytop.sgs.app.service.device; - -import com.iflytop.sgs.app.model.bo.Point3D; -import com.iflytop.sgs.app.service.device.module.TransferModuleService; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; - -/** - * 单步运动调试服务 - */ -@Service -@RequiredArgsConstructor -public class StepCommandService { - private final TransferModuleService transferModuleService; - - public void gantryToPoint3D(Point3D point3D) throws Exception { - transferModuleService.transferMove(point3D); - } -} diff --git a/src/main/java/com/iflytop/sgs/app/ws/client/DeviceEmergencyStopConfig.java b/src/main/java/com/iflytop/sgs/app/ws/client/DeviceEmergencyStopConfig.java index 649c0ce..d533107 100644 --- a/src/main/java/com/iflytop/sgs/app/ws/client/DeviceEmergencyStopConfig.java +++ b/src/main/java/com/iflytop/sgs/app/ws/client/DeviceEmergencyStopConfig.java @@ -2,7 +2,6 @@ package com.iflytop.sgs.app.ws.client; import com.iflytop.sgs.app.core.CommandPoolManager; import com.iflytop.sgs.app.service.device.DeviceStateService; -import com.iflytop.sgs.app.service.device.StepCommandService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -15,7 +14,6 @@ import java.net.URI; @Configuration @RequiredArgsConstructor public class DeviceEmergencyStopConfig { - private final StepCommandService stepCommandService; private final DeviceStateService deviceStateService; private final CommandPoolManager commandPoolManager; diff --git a/src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java b/src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java index 656f852..8b7c71b 100644 --- a/src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java +++ b/src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java @@ -33,6 +33,7 @@ public class DeviceCommandGenerator { return controlMotorCmd(CmdDevice.door_motor, CmdAction.move_by, params, "门 相对移动"); } + /** * 门 停止动作 */ @@ -57,6 +58,20 @@ public class DeviceCommandGenerator { params.setSpeed(speed); return setInfoCmd(CmdDevice.door_motor, CmdAction.set, params, "门 设置参数"); } + /** + * 门 失能 + * + */ + public static DeviceCommandBundle doorDisable() { + return controlMotorCmd(CmdDevice.door_motor, CmdAction.disable, null, "门 失能"); + } + /** + * 门 使能 + * + */ + public static DeviceCommandBundle doorEnable() { + return controlMotorCmd(CmdDevice.door_motor, CmdAction.enable, null, "门 使能"); + } /** * x轴设置参数 @@ -100,7 +115,20 @@ public class DeviceCommandGenerator { return controlMotorCmd(CmdDevice.x_motor, CmdAction.origin, null, "x轴回原点"); } - + /** + * z轴 失能 + * + */ + public static DeviceCommandBundle transferZDisable() { + return controlMotorCmd(CmdDevice.z_motor, CmdAction.disable, null, "z轴 失能"); + } + /** + * z轴 使能 + * + */ + public static DeviceCommandBundle transferZEnable() { + return controlMotorCmd(CmdDevice.z_motor, CmdAction.enable, null, "z轴 使能"); + } /** * z轴回原点 */ @@ -166,7 +194,20 @@ public class DeviceCommandGenerator { public static DeviceCommandBundle transferXStop() { return controlMotorCmd(CmdDevice.x_motor, CmdAction.stop, null, "x轴停止"); } - + /** + * x轴 失能 + * + */ + public static DeviceCommandBundle transferXDisable() { + return controlMotorCmd(CmdDevice.x_motor, CmdAction.disable, null, "x轴 失能"); + } + /** + * x轴 使能 + * + */ + public static DeviceCommandBundle transferXEnable() { + return controlMotorCmd(CmdDevice.x_motor, CmdAction.enable, null, "x轴 使能"); + } /** * z轴停止 @@ -203,6 +244,20 @@ public class DeviceCommandGenerator { params.setPosition(position); return controlCmd(CmdDevice.liquid_motor, CmdAction.move_by, params, "加液机械臂 相对移动"); } + /** + * 加液机械臂 失能 + * + */ + public static DeviceCommandBundle liquidMotorDisable() { + return controlMotorCmd(CmdDevice.liquid_motor, CmdAction.disable, null, "加液机械臂 失能"); + } + /** + * 加液机械臂 使能 + * + */ + public static DeviceCommandBundle liquidMotorEnable() { + return controlMotorCmd(CmdDevice.liquid_motor, CmdAction.enable, null, "加液机械臂 使能"); + } /** * 加液泵设置参数 @@ -244,6 +299,20 @@ public class DeviceCommandGenerator { return controlCmd(CmdDevice.liquid_pump, CmdAction.stop, params, "加液泵 停止"); } /** + * 加液泵 失能 + * + */ + public static DeviceCommandBundle liquidPumpDisable() { + return controlMotorCmd(CmdDevice.liquid_pump, CmdAction.disable, null, "z轴 失能"); + } + /** + * 加液泵 使能 + * + */ + public static DeviceCommandBundle liquidPumpEnable() { + return controlMotorCmd(CmdDevice.liquid_pump, CmdAction.enable, null, "z轴 使能"); + } + /** * 加液泵 开始旋转 */ public static DeviceCommandBundle liquidPumpStart(CmdDirection direction) { @@ -266,10 +335,16 @@ public class DeviceCommandGenerator { * 四路电磁控制阀关闭 */ public static DeviceCommandBundle valveClose() { - return controlCmd(CmdDevice.liquid_valve, CmdAction.close, null, "电磁转换阀 转换"); + return controlCmd(CmdDevice.liquid_valve, CmdAction.close, null, "电磁转换阀 关闭"); } /** + * 四路电磁控制阀转获取状态 + */ + public static DeviceCommandBundle getValveInfo(Integer channel) { + return controlCmd(CmdDevice.liquid_valve, CmdAction.get, null, "电磁转换阀 获取状态"); + } + /** * 风扇 1打开 */ public static DeviceCommandBundle fan1Open() { @@ -430,17 +505,16 @@ public class DeviceCommandGenerator { /** * 蜂鸣器 开 * - * @param */ public static DeviceCommandBundle beepOpen() { - return controlCmd(CmdDevice.beep, CmdAction.open, null, "三色灯 开启"); + return controlCmd(CmdDevice.beep, CmdAction.open, null, "蜂鸣器 开启"); } /** * 蜂鸣器 关 */ public static DeviceCommandBundle beepClose() { - return controlCmd(CmdDevice.beep, CmdAction.close, null, "三色灯 关闭"); + return controlCmd(CmdDevice.beep, CmdAction.close, null, "蜂鸣器 关闭"); } /** @@ -462,11 +536,11 @@ public class DeviceCommandGenerator { } /** - * 获取托盘状态 todo 文档action是heater_tray + * 获取传感器状态 * */ public static DeviceCommandBundle getTrayStatus() { - return getInfoCmd(CmdDevice.sensor, "获取托盘状态"); + return getInfoCmd(CmdDevice.sensor, "获取传感器状态"); } /** diff --git a/src/main/java/com/iflytop/sgs/common/enums/cmd/CmdAction.java b/src/main/java/com/iflytop/sgs/common/enums/cmd/CmdAction.java index ee1ee71..aa3eb4a 100644 --- a/src/main/java/com/iflytop/sgs/common/enums/cmd/CmdAction.java +++ b/src/main/java/com/iflytop/sgs/common/enums/cmd/CmdAction.java @@ -6,5 +6,5 @@ public enum CmdAction { open, close, stop, start, set, get, open_power, close_power, open_circle, close_circle, open_heart, close_heart, open_cool, close_cool, take_photo, - heater_tray, + enable,disable } diff --git a/src/main/java/com/iflytop/sgs/common/enums/cmd/CmdDevice.java b/src/main/java/com/iflytop/sgs/common/enums/cmd/CmdDevice.java index 76dfc17..d3495c2 100644 --- a/src/main/java/com/iflytop/sgs/common/enums/cmd/CmdDevice.java +++ b/src/main/java/com/iflytop/sgs/common/enums/cmd/CmdDevice.java @@ -15,8 +15,6 @@ public enum CmdDevice { heat_rod_2, heat_rod_3, heat_rod_4, - liquid_motor_clamp,//机械臂抱闸 - z_motor_clamp,//z轴抱闸 tricolor_light,//三色灯 beep,//蜂鸣器 heater_tray,//加热位托盘