From 4f1df0be1d1b9aab514dcba16e5d6d246b33c99d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Tue, 18 Mar 2025 20:25:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=AE=9E=E7=8E=B0=E5=96=B7=E6=B6=82?= =?UTF-8?q?=E8=BF=87=E7=A8=8B=E4=B8=AD=E5=8F=82=E6=95=B0=E5=AE=9E=E6=97=B6?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/qyft/ms/app/device/status/SprayTask.java | 14 +++-- .../front/cmd/business/MatrixSprayChangeParam.java | 72 ++++++++++++++++++++++ 2 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayChangeParam.java diff --git a/src/main/java/com/qyft/ms/app/device/status/SprayTask.java b/src/main/java/com/qyft/ms/app/device/status/SprayTask.java index 03d247b..2746fc3 100644 --- a/src/main/java/com/qyft/ms/app/device/status/SprayTask.java +++ b/src/main/java/com/qyft/ms/app/device/status/SprayTask.java @@ -20,11 +20,6 @@ public class SprayTask { private volatile boolean paused = false; /** - * 当前状态是否可以暂停 - */ - private volatile boolean suspendable = false; - - /** * 设备是否正在进行的喷涂任务 */ private volatile boolean spraying = false; @@ -56,6 +51,15 @@ public class SprayTask { spraySteps.add(Arrays.asList(steps)); } + public void setChangeSprayParam(Double motorZHeight, + Double gasPressure, + Double volume, + Boolean highVoltage, + Double highVoltageValue, + Double movingSpeed){ + + } + public void setSprayParam(String matrixPathType, Double motorZHeight, Double gasPressure, diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayChangeParam.java b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayChangeParam.java new file mode 100644 index 0000000..48b9035 --- /dev/null +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayChangeParam.java @@ -0,0 +1,72 @@ +package com.qyft.ms.app.front.cmd.business; + +import com.qyft.ms.app.device.status.SprayTask; +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.device.DeviceCommandService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; + +import java.util.concurrent.CompletableFuture; + +/** + * 喷涂_喷涂过程中参数实时调整 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("matrix_spray_change_param")//业务指令注解 +public class MatrixSprayChangeParam extends BaseCommandHandler { + + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) { + return runAsync(() -> { + SprayTask sprayTask = SprayTask.getInstance(); + Double motorZHeight = form.getDoubleParam("motorZHeight"); + Double gasPressure = form.getDoubleParam("gasPressure"); + Double volume = form.getDoubleParam("volume"); + Boolean highVoltage = form.getBooleanParam("highVoltage"); + Double highVoltageValue = form.getDoubleParam("highVoltageValue"); + Double movingSpeed = form.getDoubleParam("movingSpeed"); + sprayTask.setChangeSprayParam(motorZHeight, gasPressure, volume, highVoltage, highVoltageValue, movingSpeed); + if (!sprayTask.isPaused()) { + //1.速度 + DeviceCommand motorXSpeedSetCmdToDeviceCommand = DeviceCommandGenerator.motorXSpeedSet(movingSpeed);//x轴电机速度设置 + DeviceCommand motorYSpeedSetCmdToDeviceCommand = DeviceCommandGenerator.motorYSpeedSet(movingSpeed);//y轴电机速度设置 + DeviceCommand motorZSpeedSetCmdToDeviceCommand = DeviceCommandGenerator.motorZSpeedSet(movingSpeed);//z轴电机速度设置 + CommandFuture motorXSpeedSetCmdToDeviceCommandFuture = deviceCommandService.sendCommand(motorXSpeedSetCmdToDeviceCommand, form, emitter); + CommandFuture motorYSpeedSetCmdToDeviceCommandFuture = deviceCommandService.sendCommand(motorYSpeedSetCmdToDeviceCommand, form, emitter); + CommandFuture motorZSpeedSetCmdToDeviceCommandFuture = deviceCommandService.sendCommand(motorZSpeedSetCmdToDeviceCommand, form, emitter); + commandWait(motorXSpeedSetCmdToDeviceCommandFuture, motorYSpeedSetCmdToDeviceCommandFuture, motorZSpeedSetCmdToDeviceCommandFuture); + //2.流速 + DeviceCommand syringePumpVolumeSetCommand = DeviceCommandGenerator.syringePumpVolumeSet(volume);//注射泵流速设置 + CommandFuture syringePumpVolumeSetCommandFuture = deviceCommandService.sendCommand(syringePumpVolumeSetCommand, form, emitter); + commandWait(syringePumpVolumeSetCommandFuture); + //3.z轴高度 + Double height = 101.2 - motorZHeight;//TODO 101.2是玻片高度,这个应该从数据库中获取 + DeviceCommand smotorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(height);//移动z轴到指定位置 + CommandFuture smotorZPositionSetCommandFuture = deviceCommandService.sendCommand(smotorZPositionSetCommand, form, emitter); + commandWait(smotorZPositionSetCommandFuture); + //4.是否打开高压 + if (highVoltage) {//打开高压 + DeviceCommand highVoltageOpenCommand = DeviceCommandGenerator.highVoltageOpen(highVoltageValue);//开启高压 + CommandFuture highVoltageOpenCommandFuture = deviceCommandService.sendCommand(highVoltageOpenCommand, form, emitter); + commandWait(highVoltageOpenCommandFuture); + } else {//关闭高压 + DeviceCommand highVoltageCloseCommand = DeviceCommandGenerator.highVoltageClose();//关闭高压 + CommandFuture highVoltageCloseCommandFuture = deviceCommandService.sendCommand(highVoltageCloseCommand, form, emitter); + commandWait(highVoltageCloseCommandFuture); + } + } + }); + + } +}