From c962e425152fd215da8f2ba40ee24316b38b91a5 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 16:14:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=A2=9E=E5=8A=A0=E4=B8=9A=E5=8A=A1?= =?UTF-8?q?=E6=8C=87=E4=BB=A4=E6=89=A7=E8=A1=8C=E8=BF=87=E7=A8=8B=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E6=A8=A1=E5=9D=97=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iflytop/sgs/app/cmd/control/FanStartCommand.java | 13 ++++++++++--- .../iflytop/sgs/app/cmd/control/FanStopCommand.java | 4 ++-- .../iflytop/sgs/app/cmd/control/HeatStartCommand.java | 10 +++++++--- .../iflytop/sgs/app/cmd/control/HeatStopCommand.java | 4 ++-- .../iflytop/sgs/app/cmd/control/LiquidAddCommand.java | 19 ++++++++++++++----- .../sgs/app/cmd/control/LiquidReduceCommand.java | 4 ++++ .../sgs/app/cmd/debug/DebugDoorCloseCommand.java | 1 + .../iflytop/sgs/app/controller/HeatController.java | 2 +- 8 files changed, 41 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/FanStartCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/FanStartCommand.java index 44f5999..9b27412 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/FanStartCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/FanStartCommand.java @@ -2,11 +2,13 @@ package com.iflytop.sgs.app.cmd.control; import cn.hutool.json.JSONArray; import com.iflytop.sgs.app.core.BaseCommandHandler; +import com.iflytop.sgs.app.model.bo.status.device.HeatModuleState; import com.iflytop.sgs.app.model.dto.CmdDTO; import com.iflytop.sgs.app.service.device.DeviceStateService; import com.iflytop.sgs.app.service.device.module.HeatModuleService; import com.iflytop.sgs.common.annotation.CommandMapping; import com.iflytop.sgs.common.enums.HeatModuleCode; +import com.iflytop.sgs.common.enums.HeatingType; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -32,9 +34,14 @@ public class FanStartCommand extends BaseCommandHandler { return runAsync(() -> { for (int i = 0; i < heatModuleCodeJsonArray.size(); i++) { String heatModuleCodeStr = heatModuleCodeJsonArray.getStr(i); - HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatModuleCodeStr); - heatModuleService.fanStart(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode); - deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setFanOpen(true); + HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatModuleCodeStr);//加热模块 + HeatModuleState heatModuleState=deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode); + if(!heatModuleState.getHeatingType().equals(HeatingType.stop)){//加热棒不是停止加热状态 + heatModuleService.heatRodClose(cmdDTO.getCommandId(),cmdDTO.getCommand(),heatModuleCode);//关闭加热棒 + deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.stop);//同步状态 + } + heatModuleService.fanStart(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode);//打开风扇 + deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setFanOpen(true);//同步状态 } }); } diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/FanStopCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/FanStopCommand.java index 2ee73d0..1a099f0 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/FanStopCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/FanStopCommand.java @@ -33,8 +33,8 @@ public class FanStopCommand extends BaseCommandHandler { for (int i = 0; i < heatModuleCodeJsonArray.size(); i++) { String heatModuleCodeStr = heatModuleCodeJsonArray.getStr(i); HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatModuleCodeStr); - heatModuleService.fanClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode); - deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setFanOpen(true); + heatModuleService.fanClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode);//关闭风扇 + deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setFanOpen(false);//同步转态 } }); } diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/HeatStartCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/HeatStartCommand.java index 887880f..1a6af15 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/HeatStartCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/HeatStartCommand.java @@ -1,5 +1,6 @@ package com.iflytop.sgs.app.cmd.control; +import cn.hutool.core.lang.Assert; import cn.hutool.json.JSONArray; import com.iflytop.sgs.app.core.BaseCommandHandler; import com.iflytop.sgs.app.model.bo.status.device.HeatModuleState; @@ -9,6 +10,8 @@ import com.iflytop.sgs.app.service.device.module.HeatModuleService; import com.iflytop.sgs.common.annotation.CommandMapping; import com.iflytop.sgs.common.enums.HeatModuleCode; import com.iflytop.sgs.common.enums.HeatingType; +import com.iflytop.sgs.common.exception.AppException; +import com.iflytop.sgs.common.result.ResultCode; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -35,10 +38,11 @@ public class HeatStartCommand extends BaseCommandHandler { for (int i = 0; i < heatModuleCodeJsonArray.size(); i++) { String heatModuleCodeStr = heatModuleCodeJsonArray.getStr(i); HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatModuleCodeStr); - HeatModuleState heatModuleState = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode);//获取设定的加热温度 - double targetTemperature = heatModuleState.getHeatTemperature(); + HeatModuleState heatModuleState = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode);//获取目标加热区 + Assert.isTrue(heatModuleState.isTrayStatus(), ()->new AppException(ResultCode.TARGET_HEAT_MODULE_NO_TRAY));//目标加热区无托盘 + double targetTemperature = heatModuleState.getHeatTemperature();//获取设定的加热温度 heatModuleState.setTargetTemperature(targetTemperature);//将加热温度设定为目标温度 - heatModuleService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, targetTemperature); + heatModuleService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, targetTemperature);//打开加热棒 deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.heating); //设置加热区状态 加热中 } }); diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/HeatStopCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/HeatStopCommand.java index cb5753f..fa5c5b0 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/HeatStopCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/HeatStopCommand.java @@ -34,8 +34,8 @@ public class HeatStopCommand extends BaseCommandHandler { for (int i = 0; i < heatModuleCodeJsonArray.size(); i++) { String heatModuleCodeStr = heatModuleCodeJsonArray.getStr(i); HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatModuleCodeStr); - heatModuleService.heatRodClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode); - deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.stop); + heatModuleService.heatRodClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode);//停止加热棒 + deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.stop);//同步转态 } }); } diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/LiquidAddCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/LiquidAddCommand.java index 8aef498..b6a492a 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/LiquidAddCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/LiquidAddCommand.java @@ -43,14 +43,20 @@ public class LiquidAddCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) { + + return runAsync(() -> { + deviceStateService.getDeviceState().getSolutionModule().setIdle(true);//设置占用 + deviceStateService.getDeviceState().getSolutionModule().setPumping(true);//设置正在加液 JSONArray jsonArray = cmdDTO.getJSONArrayParam("columns");//获取参数 Assert.notNull(jsonArray, () -> new AppException(ResultCode.INVALID_PARAMETER));//解析参数 TransferModuleState transferModuleState = deviceStateService.getDeviceState().getTransferModule();//获取机械臂状态 Assert.isTrue(transferModuleState.isTrayStatus(), () -> new AppException(ResultCode.OPERATION_NOT_ALLOWED));//判断机械臂是否有托盘 Point3D liquidAreaTrayPoint = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D(); //获取加液区上方点位 Double solutionModuleMotorDownInTubeAddPositon = devicePositionService.getPosition(DevicePositionCode.solutionModuleMotorDownInTubeAddPositon).getPositon(); //加液模块电机下降进入试管加液位置 - Double trayTubeHorizontalSpacingDistance = devicePositionService.getPosition(DevicePositionCode.trayTubeHorizontalSpacingDistance).getDistance(); //加液模块电机下降进入试管加液位置 + Double trayTubeHorizontalSpacingDistance = devicePositionService.getPosition(DevicePositionCode.trayTubeHorizontalSpacingDistance).getDistance(); //托盘试管水平间距 + solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//加液机械臂上升 + transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);//移动至加液位置 for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = (JSONObject) jsonArray.get(i); Integer solutionId = jsonObject.getInt("solutionId");//溶液Id @@ -61,17 +67,20 @@ public class LiquidAddCommand extends BaseCommandHandler { double scale = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(valveStateCode.getSystemConfigCode()));//根据溶液获取转换比 double position = volume * scale * 8;//加液泵的转数 solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), valveStateCode);//电磁阀对应通道打开 - solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//加液机械臂上升 - transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);//移动至加液位置 + double distance = (column - 1) * trayTubeHorizontalSpacingDistance;//机械臂左移距离 + transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -distance);//机械臂左移 solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeAddPositon);//加液机械臂下降 solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), position);//加液 - double distance = (column - 1) * trayTubeHorizontalSpacingDistance;//机械臂左移距离 - transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -distance);//机械臂左移试管间距 + solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//加液机械臂上升 + transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);//移动至加液位置 + } solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//加液机械臂上升 transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);//移动至加液位置 + deviceStateService.getDeviceState().getSolutionModule().setIdle(false);//设置占用解除 + deviceStateService.getDeviceState().getSolutionModule().setPumping(false);//设置加液结束 }); } } diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/LiquidReduceCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/LiquidReduceCommand.java index c2ff6e6..c47c9b6 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/LiquidReduceCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/LiquidReduceCommand.java @@ -49,6 +49,8 @@ public class LiquidReduceCommand extends BaseCommandHandler { TrayState trayState = trayStates.stream().filter(TrayState::isInSolutionPositon).findFirst().get();//加液位的托盘 double reduceNumber= Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.number_reduce)); return runAsync(() -> { + deviceStateService.getDeviceState().getSolutionModule().setIdle(true);//设置占用 + deviceStateService.getDeviceState().getSolutionModule().setPumping(true);//设置正在加液 solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0.0);//加液模块上升 transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX());//将X轴移动至加液时托盘位置点 solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), ValveStateCode.waste);//电磁阀对应通道打开 @@ -62,6 +64,8 @@ public class LiquidReduceCommand extends BaseCommandHandler { } solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//加液模块上升至最高,移出试管 transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX());//将X轴移动至加液时托盘位置点 + deviceStateService.getDeviceState().getSolutionModule().setIdle(false);//设置占用解除 + deviceStateService.getDeviceState().getSolutionModule().setPumping(false);//设置加液结束 }); } } diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorCloseCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorCloseCommand.java index 447a942..8408f45 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorCloseCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorCloseCommand.java @@ -36,6 +36,7 @@ public class DebugDoorCloseCommand extends BaseCommandHandler { DeviceCommandBundle doorMoveDeviceCommand = DeviceCommandGenerator.doorMove(0.0); CommandFuture doorMoveDeviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), doorMoveDeviceCommand); CommandUtil.wait(doorMoveDeviceCommandFuture); + }); } } diff --git a/src/main/java/com/iflytop/sgs/app/controller/HeatController.java b/src/main/java/com/iflytop/sgs/app/controller/HeatController.java index d25c3f0..eaf7799 100644 --- a/src/main/java/com/iflytop/sgs/app/controller/HeatController.java +++ b/src/main/java/com/iflytop/sgs/app/controller/HeatController.java @@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** - * 加热模块控制 todo wmy 需要和前端同步参数 加热 烘干 退火 + * 加热模块控制 */ @Tag(name = "加热模块控制") @RestController