From f40f1d1e75e64a2c9300e6327096598a88014931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Wed, 16 Jul 2025 10:53:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4=E8=87=AA=E6=A3=80?= =?UTF-8?q?=E8=BF=90=E5=8A=A8=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ms/app/front/cmd/business/MoveTestCommand.java | 70 ++++++++++++++++++++++ .../ms/app/front/cmd/test/MoveTestCommand.java | 70 ---------------------- 2 files changed, 70 insertions(+), 70 deletions(-) create mode 100644 src/main/java/com/qyft/ms/app/front/cmd/business/MoveTestCommand.java delete mode 100644 src/main/java/com/qyft/ms/app/front/cmd/test/MoveTestCommand.java diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/MoveTestCommand.java b/src/main/java/com/qyft/ms/app/front/cmd/business/MoveTestCommand.java new file mode 100644 index 0000000..bfee72b --- /dev/null +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/MoveTestCommand.java @@ -0,0 +1,70 @@ +package com.qyft.ms.app.front.cmd.business; + +import com.qyft.ms.app.core.SelfMoveTestGenerator; +import com.qyft.ms.app.device.status.DeviceStatus; +import com.qyft.ms.system.common.annotation.CommandMapping; +import com.qyft.ms.system.common.device.command.CommandFuture; +import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; +import com.qyft.ms.system.core.handler.BaseCommandHandler; +import com.qyft.ms.system.model.bo.DeviceCommand; +import com.qyft.ms.system.model.form.FrontCmdControlForm; +import com.qyft.ms.system.service.WebSocketService; +import com.qyft.ms.system.service.device.DeviceCommandService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 自检移动测试 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("move_test")//业务指令注解 +public class MoveTestCommand extends BaseCommandHandler { + private final WebSocketService webSocketService; + private final DeviceCommandService deviceCommandService; + private final DeviceStatus deviceStatus; + + @Override + public CompletableFuture handle(FrontCmdControlForm form) { + return runAsync(() -> { + try { + //deviceSensorService.collectSensorState();//收集传感器转态 + webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(form.getCmdId(), form.getCmdCode(), "1、各项传感器正常", 25, "success")); + DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(200.0, 20.0); //移动到200mm处 + CommandFuture motorXPositionSetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorXPositionSetCommand); + commandWait(motorXPositionSetCommandFuture); + + DeviceCommand motorXOriginCommand = DeviceCommandGenerator.motorXOrigin();//x轴回原点 + CommandFuture motorXOriginCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorXOriginCommand); + commandWait(motorXOriginCommandFuture); + webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(form.getCmdId(), form.getCmdCode(), "2、x轴电机检测完毕", 50, "success")); + + + DeviceCommand motorYPositionSetCommand = DeviceCommandGenerator.motorYPositionSet(100.0, 20.0);//y轴移动100mm + CommandFuture motorYPositionSetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorYPositionSetCommand); + commandWait(motorYPositionSetCommandFuture); + + DeviceCommand motorYOriginCommand = DeviceCommandGenerator.motorYOrigin();//y轴回原点 + CommandFuture motorYOriginCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorYOriginCommand); + commandWait(motorYOriginCommandFuture); + webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(form.getCmdId(), form.getCmdCode(), "3、y轴电机检测完毕", 75, "success")); + + DeviceCommand motorZPositionCommand = DeviceCommandGenerator.motorZPositionSet(50.0, 20.0);//z轴50mm处 + CommandFuture motorZPositionCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorZPositionCommand); + commandWait(motorZPositionCommandFuture); + + DeviceCommand motorZOriginCommand = DeviceCommandGenerator.motorZOrigin();//z轴回原点 + CommandFuture motorZOriginCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorZOriginCommand); + commandWait(motorZOriginCommandFuture); + webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(form.getCmdId(), form.getCmdCode(), "4、z轴电机检测完毕", 100, "success")); + } finally { + // deviceStatus.setSelfTestCompleted(true); + } + }); + } +} + diff --git a/src/main/java/com/qyft/ms/app/front/cmd/test/MoveTestCommand.java b/src/main/java/com/qyft/ms/app/front/cmd/test/MoveTestCommand.java deleted file mode 100644 index 2dcca47..0000000 --- a/src/main/java/com/qyft/ms/app/front/cmd/test/MoveTestCommand.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.qyft.ms.app.front.cmd.test; - -import com.qyft.ms.app.core.SelfMoveTestGenerator; -import com.qyft.ms.app.device.status.DeviceStatus; -import com.qyft.ms.system.common.annotation.CommandMapping; -import com.qyft.ms.system.common.device.command.CommandFuture; -import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; -import com.qyft.ms.system.core.handler.BaseCommandHandler; -import com.qyft.ms.system.model.bo.DeviceCommand; -import com.qyft.ms.system.model.form.FrontCmdControlForm; -import com.qyft.ms.system.service.WebSocketService; -import com.qyft.ms.system.service.device.DeviceCommandService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.concurrent.CompletableFuture; - -/** - * 自检移动测试 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("move_test")//业务指令注解 -public class MoveTestCommand extends BaseCommandHandler { - private final WebSocketService webSocketService; - private final DeviceCommandService deviceCommandService; - private final DeviceStatus deviceStatus; - - @Override - public CompletableFuture handle(FrontCmdControlForm form) { - return runAsync(() -> { - try { - //deviceSensorService.collectSensorState();//收集传感器转态 - webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(form.getCmdId(), form.getCmdCode(), "1、各项传感器正常", 25, "success")); - DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(200.0); //移动到200mm处 - CommandFuture motorXPositionSetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorXPositionSetCommand); - commandWait(motorXPositionSetCommandFuture); - - DeviceCommand motorXOriginCommand = DeviceCommandGenerator.motorXOrigin();//x轴回原点 - CommandFuture motorXOriginCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorXOriginCommand); - commandWait(motorXOriginCommandFuture); - webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(form.getCmdId(), form.getCmdCode(), "2、x轴电机检测完毕", 50, "success")); - - - DeviceCommand motorYPositionSetCommand = DeviceCommandGenerator.motorYPositionSet(100.0);//y轴移动100mm - CommandFuture motorYPositionSetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorYPositionSetCommand); - commandWait(motorYPositionSetCommandFuture); - - DeviceCommand motorYOriginCommand = DeviceCommandGenerator.motorYOrigin();//y轴回原点 - CommandFuture motorYOriginCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorYOriginCommand); - commandWait(motorYOriginCommandFuture); - webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(form.getCmdId(), form.getCmdCode(), "3、y轴电机检测完毕", 75, "success")); - - DeviceCommand motorZPositionCommand = DeviceCommandGenerator.motorZPositionSet(50.0);//z轴50mm处 - CommandFuture motorZPositionCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorZPositionCommand); - commandWait(motorZPositionCommandFuture); - - DeviceCommand motorZOriginCommand = DeviceCommandGenerator.motorZOrigin();//z轴回原点 - CommandFuture motorZOriginCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorZOriginCommand); - commandWait(motorZOriginCommandFuture); - webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(form.getCmdId(), form.getCmdCode(), "4、z轴电机检测完毕", 100, "success")); - } finally { - // deviceStatus.setSelfTestCompleted(true); - } - }); - } -} -