From d9c7c94ee40b7af7ab5be5e48a76f6b93b9b24a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=A2=A6=E8=BF=9C?= <1063331231@qq.com> Date: Fri, 20 Jun 2025 20:57:36 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E9=92=88=E9=AB=98=E5=BA=A6=20?= =?UTF-8?q?=E6=B8=A9=E5=BA=A6=E5=8F=AF=E9=85=8D=E7=BD=AE=202=E3=80=81?= =?UTF-8?q?=E6=8A=BD=E6=B6=B2=E8=B7=9D=E7=A6=BB=E6=A0=B9=E6=8D=AE=E6=BA=B6?= =?UTF-8?q?=E6=B6=B2=E5=88=86=E5=BC=80=203=E3=80=81=E6=89=8B=E5=8A=A8?= =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E6=8C=87=E4=BB=A4=E4=B8=8D=E5=86=8D=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E9=94=81=E6=9C=BA=E6=A2=B0=E8=87=82=204=E3=80=81?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=81=9C=E6=AD=A2=E9=80=80=E7=81=AB=20?= =?UTF-8?q?=E5=81=9C=E6=AD=A2=E7=83=98=E5=B9=B2=205=E3=80=81sleep=E6=94=B9?= =?UTF-8?q?=E4=B8=BATimeunit=20=E6=9B=B4=E6=98=93=E8=AF=BB=206=E3=80=81?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=B6=88=E8=A7=A3=E4=BB=AA=E7=9A=84=E9=83=A8?= =?UTF-8?q?=E5=88=86=E4=BB=A3=E7=A0=81=207=E3=80=81=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E5=85=88=E5=88=9D=E5=A7=8B=E5=8C=96=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=20=E5=86=8D=E7=9B=91=E5=90=AC=E8=BF=9E=E6=8E=A5=208=E3=80=81?= =?UTF-8?q?=E6=B3=B5=E6=8A=BD=E6=B6=B2=20=E5=92=8C=E5=8A=A0=E6=B6=B2?= =?UTF-8?q?=E9=80=9F=E5=BA=A6=E5=8F=AF=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sgs/app/cmd/control/AnnealStopCommand.java | 37 ------ .../sgs/app/cmd/control/CleanStartCommand.java | 96 +++++++++++---- .../sgs/app/cmd/control/DryStopCommand.java | 37 ------ .../sgs/app/cmd/control/LiquidAddCommand.java | 84 ++++++++----- .../app/cmd/control/LiquidPreFillStartCommand.java | 40 ++++-- .../sgs/app/cmd/control/LiquidReduceCommand.java | 84 +++++++++---- .../app/cmd/control/MoveToAnnealAreaCommand.java | 103 +++++++++++----- .../sgs/app/cmd/control/MoveToFeedAreaCommand.java | 96 +++++++++------ .../sgs/app/cmd/control/MoveToHeatAreaCommand.java | 75 +++++++----- .../app/cmd/control/MoveToLiquidAreaCommand.java | 62 +++++----- .../sgs/app/cmd/control/OutTrayCommand.java | 68 +++++++---- .../sgs/app/cmd/control/XOriginCommand.java | 39 +++--- .../sgs/app/cmd/control/ZOriginCommand.java | 26 +--- .../sgs/app/cmd/selftest/LiquidPreFillCommand.java | 84 ------------- .../selftest/LiquidPreFillWhenLaunchCommand.java | 88 ++++++++++++++ .../sgs/app/cmd/selftest/MoveTestCommand.java | 33 ++--- .../sgs/app/cmd/selftest/TrayOutCommand.java | 2 +- .../iflytop/sgs/app/controller/HeatController.java | 15 +++ .../sgs/app/model/bo/status/CommandMutexState.java | 38 ++---- .../model/bo/status/device/DoorModuleState.java | 5 + .../sgs/app/model/vo/SetTargetTemperatureVO.java | 9 +- .../iflytop/sgs/app/service/api/HeatService.java | 2 + .../sgs/app/service/crafts/CraftsStepService.java | 134 +++++++++++---------- .../sgs/app/service/device/DeviceInitService.java | 2 +- .../service/device/module/DoorModuleService.java | 38 +++--- .../service/device/module/HeatModuleService.java | 2 +- .../device/module/SolutionModuleService.java | 26 ++++ .../device/module/TransferModuleService.java | 5 +- .../sgs/common/constant/WebSocketMessageType.java | 5 + .../iflytop/sgs/common/enums/DeviceSensorCode.java | 2 +- .../sgs/common/enums/data/DevicePositionCode.java | 26 ++-- .../com/iflytop/sgs/common/result/ResultCode.java | 4 +- src/main/resources/sql/init.sql | 54 ++++++++- 33 files changed, 803 insertions(+), 618 deletions(-) delete mode 100644 src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStopCommand.java delete mode 100644 src/main/java/com/iflytop/sgs/app/cmd/control/DryStopCommand.java delete mode 100644 src/main/java/com/iflytop/sgs/app/cmd/selftest/LiquidPreFillCommand.java create mode 100644 src/main/java/com/iflytop/sgs/app/cmd/selftest/LiquidPreFillWhenLaunchCommand.java diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStopCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStopCommand.java deleted file mode 100644 index 6537d4d..0000000 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStopCommand.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.iflytop.sgs.app.cmd.control; - -import com.iflytop.sgs.app.core.BaseCommandHandler; -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; - -import java.util.concurrent.CompletableFuture; - -/** - * 停止退火 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("anneal_stop")//业务指令注解 -public class AnnealStopCommand extends BaseCommandHandler { - private final HeatModuleService heatModuleService; - private final DeviceStateService deviceStateService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - String heatModuleCodeStr = cmdDTO.getStringParam("heatModuleCode"); - HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatModuleCodeStr); - return runAsync(() -> { - 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/CleanStartCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/CleanStartCommand.java index 7f4a525..8f2946b 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/CleanStartCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/CleanStartCommand.java @@ -6,7 +6,6 @@ import com.iflytop.sgs.app.core.BaseCommandHandler; import com.iflytop.sgs.app.model.bo.Point3D; import com.iflytop.sgs.app.model.dto.CmdDTO; import com.iflytop.sgs.app.model.entity.Solutions; -import com.iflytop.sgs.app.service.api.CraftsService; import com.iflytop.sgs.app.service.api.DevicePositionService; import com.iflytop.sgs.app.service.api.SolutionsService; import com.iflytop.sgs.app.service.api.SystemConfigService; @@ -14,7 +13,9 @@ import com.iflytop.sgs.app.service.device.DeviceSensorService; import com.iflytop.sgs.app.service.device.DeviceStateService; import com.iflytop.sgs.app.service.device.module.SolutionModuleService; import com.iflytop.sgs.app.service.device.module.TransferModuleService; +import com.iflytop.sgs.app.ws.server.WebSocketSender; import com.iflytop.sgs.common.annotation.CommandMapping; +import com.iflytop.sgs.common.constant.WebSocketMessageType; import com.iflytop.sgs.common.enums.CraftsTransferTypeCode; import com.iflytop.sgs.common.enums.DeviceSensorCode; import com.iflytop.sgs.common.enums.SolutionCode; @@ -43,7 +44,7 @@ public class CleanStartCommand extends BaseCommandHandler { private final SystemConfigService systemConfigService; private final DeviceSensorService deviceSensorService; private final SolutionsService solutionsService; - private final CraftsService craftsService; + private final WebSocketSender webSocketService; @Override public CompletableFuture handle(CmdDTO cmdDTO) { @@ -56,7 +57,8 @@ public class CleanStartCommand extends BaseCommandHandler { Double height = cmdDTO.getDoubleParam("height");//针头下降高度 Double volume = cmdDTO.getDoubleParam("volume") == null ? 2.0 : cmdDTO.getDoubleParam("volume");//加水的量 Integer maxCycles = systemConfigService.getSystemConfigIntegerByCode(SystemConfigCode.cycle_clean_max);//获取最大清洁次数配置 - Assert.isTrue(cycle != null && cycle > 0 && cycle < maxCycles && height < 55 && volume != null, () -> new AppException(ResultCode.INVALID_PARAMETER));//清洁次数不为空 切清洁次数大于0 + Double needleDropHeight = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.needle_drop_height);//抽液时针下降高度 + Assert.isTrue(cycle != null && cycle > 0 && cycle <= maxCycles && height <= needleDropHeight && volume != null, () -> new AppException(ResultCode.PARAMETER_OUT_OF_RANGE));//清洁次数不为空 切清洁次数大于0 Solutions solutions = solutionsService.getByCode(SolutionCode.water.name()); double waterScale = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.valueOf(solutions.getCode()));//水转换系数 double cleanWaterVolume = volume * waterScale;//清洁时加水的量 @@ -65,41 +67,83 @@ public class CleanStartCommand extends BaseCommandHandler { Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液时托盘位置点 Double trayTubeHorizontalSpacingDistance = devicePositionService.getPosition(DevicePositionCode.trayTubeHorizontalSpacingDistance).getDistance();//获取托盘试管水平间距 Double backFlowDistance = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.back_flow_distance);//防低落距离 + Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹取位置点 + Double transferModuleXPickTrayMoveDistance = devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance();//获取转运模块X轴拿取托盘进出卡槽移动距离 + double pumpNormalSpeed = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.pump_normal_speed);//蠕动泵正常转速 + double pumpReduceSpeed = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.pump_reduce_speed);//蠕动泵抽取转速 boolean moduleIdle = deviceStateService.getDeviceState().getTransferModule().isIdle(); if (!moduleIdle) { throw new AppException(ResultCode.CMD_BUSY);//设备忙 } - boolean requestResult = transferModuleService.requestTransferModule(CraftsTransferTypeCode.move_by_manual);//申请使用转运模块 - if (!requestResult) { - throw new AppException(ResultCode.CMD_BUSY);//设备忙 - } return runAsync(() -> { try { + boolean requestResult = transferModuleService.requestTransferModule(CraftsTransferTypeCode.move_by_manual);//申请使用转运模块 + if (!requestResult) { + throw new AppException(ResultCode.CMD_BUSY);//设备忙 + } deviceStateService.getCommandMutexState().get().setTransferCommandExecuting(true); deviceStateService.getDeviceState().getSolutionModule().setPumping(true);//设置正在加液 solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液模块上升 transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//移动至加液时托盘位置点 - boolean clawTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST);//监测夹爪是否有托盘 - Assert.isTrue(clawTrayExist, () -> new AppException(ResultCode.TARGET_HEAT_MODULE_NO_TRAY));//夹爪必须有托盘 - for (int i = 0; i < cycle; i++) { - for (int j = 0; j < jsonArray.size(); j++) { - int column = jsonArray.getInt(j); - double distance = Math.abs(column - 5) * trayTubeHorizontalSpacingDistance;//x轴移动距离 - transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX() + distance);//机械臂移动到试管位置 - solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeExtPositon);//加液模块下降进入试管抽取位置 + boolean clawTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST);//监测机械臂是否有托盘 + if (clawTrayExist) {//机械臂托盘存在 + for (int i = 0; i < cycle; i++) { solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), SolutionCode.water);//电磁阀对应通道打开 - solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), cleanWaterVolume);//八通道蠕动泵 cleanWaterVolume * waterScale * 8 - solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液模块上升至最高,移出试管 - } - solutionModuleService.liquidPumpMove(-backFlowDistance);//倒吸 - for (int j = 0; j < jsonArray.size(); j++) { - int column = jsonArray.getInt(j); - double distance = Math.abs(column - 5) * trayTubeHorizontalSpacingDistance;//x轴移动距离 - transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX() + distance);//机械臂移动到试管位置 - solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeExtPositon);//加液模块下降进入试管抽取位置 + solutionModuleService.liquidPumpSetSpeed(cmdDTO.getCommandId(), cmdDTO.getCommand(), pumpNormalSpeed);//设置泵的正常转速 + for (int j = 0; j < jsonArray.size(); j++) { + int column = jsonArray.getInt(j); + double distance = Math.abs(column - 5) * trayTubeHorizontalSpacingDistance;//x轴移动距离 + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX() + distance);//机械臂移动到试管位置 + solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeExtPositon);//加液模块下降进入试管抽取位置 + solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), cleanWaterVolume);//加水 + solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液模块上升至最高,移出试管 + } + solutionModuleService.liquidPumpMove(-backFlowDistance);//倒吸 solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), SolutionCode.waste);//电磁阀对应通道打开 - solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), -reduceDistance);//八通道蠕动泵 - solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液模块上升至最高,移出试管 + solutionModuleService.liquidPumpSetSpeed(cmdDTO.getCommandId(), cmdDTO.getCommand(), pumpReduceSpeed);//设置泵的抽取转速 + for (int j = 0; j < jsonArray.size(); j++) { + int column = jsonArray.getInt(j); + double distance = Math.abs(column - 5) * trayTubeHorizontalSpacingDistance;//x轴移动距离 + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX() + distance);//机械臂移动到试管位置 + solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeExtPositon + height);//加液模块下降进入试管抽取位置 + solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), -reduceDistance);//八通道蠕动泵 + solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液模块上升至最高,移出试管 + } + } + transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//移动至加液时托盘位置点 + } else {//机械臂托盘不存在 + boolean feedTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取上料位托盘状态 + if (feedTrayExist) {//上料区存在托盘 + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getX() + transferModuleXPickTrayMoveDistance);//将X轴移动至上料区托盘夹取点 + 进出卡槽移动距离 + transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 + transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽 + transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//移动至加液位置 + for (int i = 0; i < cycle; i++) { + solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), SolutionCode.water);//电磁阀对应通道打开 + solutionModuleService.liquidPumpSetSpeed(cmdDTO.getCommandId(), cmdDTO.getCommand(), pumpNormalSpeed);//设置泵的正常转速 + for (int j = 0; j < jsonArray.size(); j++) { + int column = jsonArray.getInt(j); + double distance = Math.abs(column - 5) * trayTubeHorizontalSpacingDistance;//x轴移动距离 + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX() + distance);//机械臂移动到试管位置 + solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeExtPositon);//加液模块下降进入试管抽取位置 + solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), cleanWaterVolume);//加水 + solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液模块上升至最高,移出试管 + } + solutionModuleService.liquidPumpMove(-backFlowDistance);//倒吸 + solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), SolutionCode.waste);//电磁阀对应通道打开 + solutionModuleService.liquidPumpSetSpeed(cmdDTO.getCommandId(), cmdDTO.getCommand(), pumpReduceSpeed);//设置泵的抽取转速 + for (int j = 0; j < jsonArray.size(); j++) { + int column = jsonArray.getInt(j); + double distance = Math.abs(column - 5) * trayTubeHorizontalSpacingDistance;//x轴移动距离 + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX() + distance);//机械臂移动到试管位置 + solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeExtPositon + height);//加液模块下降进入试管抽取位置 + solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), -reduceDistance);//八通道蠕动泵 + solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液模块上升至最高,移出试管 + } + } + transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//移动至加液时托盘位置点 + } else { + webSocketService.push(WebSocketMessageType.WARN, "请先把托盘放置上料位!"); } } transferModuleService.releaseTransferModule();//释放转运模组 diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/DryStopCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/DryStopCommand.java deleted file mode 100644 index 5d66004..0000000 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/DryStopCommand.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.iflytop.sgs.app.cmd.control; - -import com.iflytop.sgs.app.core.BaseCommandHandler; -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; - -import java.util.concurrent.CompletableFuture; - -/** - * 结束烘干 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("dry_stop")//业务指令注解 -public class DryStopCommand extends BaseCommandHandler { - private final HeatModuleService heatModuleService; - private final DeviceStateService deviceStateService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - String heatModuleCodeStr = cmdDTO.getStringParam("heatModuleCode"); - HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatModuleCodeStr); - return runAsync(() -> { - 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 15120d5..0aca239 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 @@ -7,12 +7,15 @@ import com.iflytop.sgs.app.model.bo.Point3D; import com.iflytop.sgs.app.model.dto.CmdDTO; import com.iflytop.sgs.app.model.entity.Container; import com.iflytop.sgs.app.model.entity.Solutions; +import com.iflytop.sgs.app.model.entity.SystemConfig; import com.iflytop.sgs.app.service.api.*; import com.iflytop.sgs.app.service.device.DeviceSensorService; import com.iflytop.sgs.app.service.device.DeviceStateService; import com.iflytop.sgs.app.service.device.module.SolutionModuleService; import com.iflytop.sgs.app.service.device.module.TransferModuleService; +import com.iflytop.sgs.app.ws.server.WebSocketSender; import com.iflytop.sgs.common.annotation.CommandMapping; +import com.iflytop.sgs.common.constant.WebSocketMessageType; import com.iflytop.sgs.common.enums.CraftsTransferTypeCode; import com.iflytop.sgs.common.enums.DeviceSensorCode; import com.iflytop.sgs.common.enums.SystemConfigCode; @@ -41,7 +44,7 @@ public class LiquidAddCommand extends BaseCommandHandler { private final DeviceSensorService deviceSensorService; private final ContainerService containerService; private final SystemConfigService systemConfigService; - private final CraftsService craftsService; + private final WebSocketSender webSocketService; @Override public CompletableFuture handle(CmdDTO cmdDTO) { @@ -52,59 +55,78 @@ public class LiquidAddCommand extends BaseCommandHandler { Point3D liquidAreaTrayPoint = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D(); //获取加液区上方托盘点位 Double solutionModuleMotorDownInTubeAddPositon = devicePositionService.getPosition(DevicePositionCode.solutionModuleMotorDownInTubeAddPositon).getPositon(); //加液模块电机下降进入试管加液位置 Double trayTubeHorizontalSpacingDistance = devicePositionService.getPosition(DevicePositionCode.trayTubeHorizontalSpacingDistance).getDistance(); //托盘试管水平间距 - Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹爪位置点 + Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹取位置点 Double transferModuleXPickTrayMoveDistance = devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance();//获取转运模块X轴拿取托盘进出卡槽移动距离 + Double pumpNormalSpeed = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.pump_normal_speed);//蠕动泵正常转速 JSONArray jsonArray = cmdDTO.getJSONArrayParam("columns");//获取参数 Integer containerId = cmdDTO.getIntegerParam("containerId");//溶液ID double volume = cmdDTO.getDoubleParam("volume");//量 Container container = containerService.getById(containerId); Solutions solutions = solutionsService.getById(container.getSolutionId());//获取溶液 + Integer channel = container.getChannel();//获取通道 + double scale = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.valueOf(solutions.getCode()));//根据溶液获取转换比 + double position = volume * scale;//加液距离 Assert.isTrue(!jsonArray.isEmpty(), () -> new AppException(ResultCode.INVALID_PARAMETER));//确定选中了列 boolean moduleIdle = deviceStateService.getDeviceState().getTransferModule().isIdle(); - if(!moduleIdle){ - throw new AppException(ResultCode.CMD_BUSY);//设备忙 - } - boolean requestResult=transferModuleService.requestTransferModule(CraftsTransferTypeCode.move_by_manual);//申请使用转运模块 - if(!requestResult) { + if (!moduleIdle) { throw new AppException(ResultCode.CMD_BUSY);//设备忙 } return runAsync(() -> { try { + boolean requestResult = transferModuleService.requestTransferModule(CraftsTransferTypeCode.move_by_manual);//申请使用转运模块 + if (!requestResult) { + throw new AppException(ResultCode.CMD_BUSY);//设备忙 + } deviceStateService.getCommandMutexState().get().setTransferCommandExecuting(true); deviceStateService.getDeviceState().getSolutionModule().setPumping(true);//设置正在加液 - solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液机械臂上升至0 + solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液机械臂上升 transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);//移动至加液位置 boolean clawTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST);//获取传感器状态 - - if (!clawTrayExist) {//夹爪托盘不存在 尝试取上料位托盘 + if (!clawTrayExist) {//机械臂托盘不存在 尝试取上料位托盘 boolean feedTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取上料位托盘状态 - Assert.isTrue(feedTrayExist, () -> new AppException(ResultCode.FEED_AREA_NO_TRAY));//上料区无托盘 - transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getX() + transferModuleXPickTrayMoveDistance);//将X轴移动至上料区托盘夹取点 + 进出卡槽移动距离 - transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 - transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽 - transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);//移动至加液位置 - } - Integer channel = container.getChannel();//获取通道 - double scale = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.valueOf(solutions.getCode()));//根据溶液获取转换比 - double position = volume * scale;//加液距离 - solutionModuleService.liquidValveSwitchByChannel(cmdDTO.getCommandId(), cmdDTO.getCommand(), channel);//电磁阀对应通道打开 - for (int i = 0; i < jsonArray.size(); i++) { - int column = jsonArray.getInt(i); - if (column > 0 && column < 6) { - double distance = Math.abs(column - 5) * trayTubeHorizontalSpacingDistance;//机械臂右移距离 - transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint.getX() + distance);//机械臂移动到试管位置 - solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeAddPositon);//加液机械臂下降 - solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), position);//加液 position设置固定值 - solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液机械臂上升 + if (feedTrayExist) {//上料区存在托盘 + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getX() + transferModuleXPickTrayMoveDistance);//将X轴移动至上料区托盘夹取点 + 进出卡槽移动距离 + transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 + transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽 + transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);//移动至加液位置 + solutionModuleService.liquidValveSwitchByChannel(cmdDTO.getCommandId(), cmdDTO.getCommand(), channel);//电磁阀对应通道打开 + solutionModuleService.liquidPumpSetSpeed(cmdDTO.getCommandId(), cmdDTO.getCommand(), pumpNormalSpeed);//设置泵的转速 + for (int i = 0; i < jsonArray.size(); i++) { + int column = jsonArray.getInt(i); + if (column > 0 && column < 6) { + double distance = Math.abs(column - 5) * trayTubeHorizontalSpacingDistance;//机械臂右移距离 + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint.getX() + distance);//机械臂移动到试管位置 + solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeAddPositon);//加液机械臂下降 + solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), position);//加液 + solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液机械臂上升 + } + } + solutionModuleService.liquidPumpMove(-backFlowDistance);//倒吸 + transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);//移动至加液位置 + } else { + webSocketService.push(WebSocketMessageType.WARN, "请先把托盘放置上料位或移至加液位!"); + } + } else {//机械臂存在托盘 + solutionModuleService.liquidValveSwitchByChannel(cmdDTO.getCommandId(), cmdDTO.getCommand(), channel);//电磁阀对应通道打开 + solutionModuleService.liquidPumpSetSpeed(cmdDTO.getCommandId(), cmdDTO.getCommand(), pumpNormalSpeed);//设置泵的转速 + for (int i = 0; i < jsonArray.size(); i++) { + int column = jsonArray.getInt(i); + if (column > 0 && column < 6) { + double distance = Math.abs(column - 5) * trayTubeHorizontalSpacingDistance;//机械臂右移距离 + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint.getX() + distance);//机械臂移动到试管位置 + solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeAddPositon);//加液机械臂下降 + solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), position);//加液 + solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液机械臂上升 + } } + solutionModuleService.liquidPumpMove(-backFlowDistance);//倒吸 + transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);//移动至加液位置 } - solutionModuleService.liquidPumpMove(-backFlowDistance);//倒吸 - transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);//移动至加液位置 transferModuleService.releaseTransferModule();//释放转运模组 } catch (Exception e) { log.error("加液指令执行异常:{}", e.getMessage()); throw new Exception(e); - }finally { + } finally { deviceStateService.getDeviceState().getSolutionModule().setPumping(false);//设置加液结束 deviceStateService.getCommandMutexState().get().setTransferCommandExecuting(false); } diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/LiquidPreFillStartCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/LiquidPreFillStartCommand.java index 63e33ae..5bdb25b 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/LiquidPreFillStartCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/LiquidPreFillStartCommand.java @@ -5,18 +5,24 @@ import com.iflytop.sgs.app.core.BaseCommandHandler; import com.iflytop.sgs.app.model.bo.Point3D; import com.iflytop.sgs.app.model.dto.CmdDTO; import com.iflytop.sgs.app.model.entity.Solutions; -import com.iflytop.sgs.app.service.api.CraftsService; import com.iflytop.sgs.app.service.api.DevicePositionService; import com.iflytop.sgs.app.service.api.SolutionsService; +import com.iflytop.sgs.app.service.api.SystemConfigService; +import com.iflytop.sgs.app.service.device.DeviceSensorService; import com.iflytop.sgs.app.service.device.DeviceStateService; import com.iflytop.sgs.app.service.device.module.SolutionModuleService; import com.iflytop.sgs.app.service.device.module.TransferModuleService; +import com.iflytop.sgs.app.ws.server.WebSocketSender; import com.iflytop.sgs.common.annotation.CommandMapping; +import com.iflytop.sgs.common.constant.WebSocketMessageType; import com.iflytop.sgs.common.enums.CraftsTransferTypeCode; +import com.iflytop.sgs.common.enums.DeviceSensorCode; import com.iflytop.sgs.common.enums.SolutionCode; +import com.iflytop.sgs.common.enums.SystemConfigCode; import com.iflytop.sgs.common.enums.data.DevicePositionCode; import com.iflytop.sgs.common.exception.AppException; import com.iflytop.sgs.common.result.ResultCode; +import com.iflytop.sgs.hardware.exception.HardwareException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -36,35 +42,51 @@ public class LiquidPreFillStartCommand extends BaseCommandHandler { private final DevicePositionService devicePositionService; private final TransferModuleService transferModuleService; private final SolutionsService solutionsService; - private final CraftsService craftsService; + private final SystemConfigService systemConfigService; + private final DeviceSensorService deviceSensorService; + private final WebSocketSender webSocketService; @Override - public CompletableFuture handle(CmdDTO cmdDTO) { + public CompletableFuture handle(CmdDTO cmdDTO) throws HardwareException { if (deviceStateService.getCommandMutexState().get().isSolutionAddCommandExecuting()) { throw new AppException(ResultCode.CMD_BUSY); } + boolean feedTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST); + if (feedTrayExist) { + throw new AppException(ResultCode.FEED_AREA_EXIST_TRAY);//上料区存在托盘 + } Integer solutionId = cmdDTO.getIntegerParam("solutionId");//解析参数酸液Id Solutions solutions = solutionsService.getById(solutionId);//数据库获取酸液信息 Assert.notNull(solutions, () -> new AppException(ResultCode.OPERATION_NOT_ALLOWED));//检验参数 SolutionCode solutionCode = SolutionCode.valueOf(solutions.getCode());//获取对应的电磁阀通道 Point3D heatArea1TrayClawPoint = devicePositionService.getPosition(DevicePositionCode.heatArea1TrayClawPoint).getPoint3D(); //加热区1上方点位用于放置转运机械臂 Double liquidAreaPreFillPoint = devicePositionService.getPosition(DevicePositionCode.liquidAreaPreFillPoint).getPositon(); //预充时加液臂下降位置 + double pumpNormalSpeed = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.pump_normal_speed);//蠕动泵正常转速 + Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液时托盘位置点 boolean moduleIdle = deviceStateService.getDeviceState().getTransferModule().isIdle(); if (!moduleIdle) { throw new AppException(ResultCode.CMD_BUSY);//设备忙 } - boolean requestResult = transferModuleService.requestTransferModule(CraftsTransferTypeCode.move_by_manual);//申请使用转运模块 - if (!requestResult) { - throw new AppException(ResultCode.CMD_BUSY);//设备忙 - } return runAsync(() -> { try { + boolean requestResult = transferModuleService.requestTransferModule(CraftsTransferTypeCode.move_by_manual);//申请使用转运模块 + if (!requestResult) { + throw new AppException(ResultCode.CMD_BUSY);//设备忙 + } deviceStateService.getCommandMutexState().get().setSolutionAddCommandExecuting(true); deviceStateService.getDeviceState().getSolutionModule().setPumping(true);//设置正在加液 + transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//移动至加液时托盘位置点 solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionCode);//电磁阀对应的酸液通道打开 + solutionModuleService.liquidPumpSetSpeed(cmdDTO.getCommandId(), cmdDTO.getCommand(), pumpNormalSpeed);//设置泵的转速 transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatArea1TrayClawPoint.getX());//转运模块移动至加热位1 - solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaPreFillPoint);//加液机械臂下降至至预充点位 - solutionModuleService.liquidPumpRotateForward(cmdDTO.getCommandId(), cmdDTO.getCommand());//预充开始 + boolean feedTrayExistAgain = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST); + if (!feedTrayExistAgain) { + solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaPreFillPoint);//加液机械臂下降至至预充点位 + solutionModuleService.liquidPumpRotateForward(cmdDTO.getCommandId(), cmdDTO.getCommand());//预充开始 + } else { + webSocketService.push(WebSocketMessageType.WARN, "请先把上料区托盘取出!"); + } + transferModuleService.releaseTransferModule();//释放转运模组 } catch (Exception e) { log.error("预充指令执行异常:{}", e.getMessage()); 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 52faae7..2a8ebf4 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 @@ -5,14 +5,15 @@ import cn.hutool.json.JSONArray; import com.iflytop.sgs.app.core.BaseCommandHandler; import com.iflytop.sgs.app.model.bo.Point3D; import com.iflytop.sgs.app.model.dto.CmdDTO; -import com.iflytop.sgs.app.service.api.CraftsService; import com.iflytop.sgs.app.service.api.DevicePositionService; import com.iflytop.sgs.app.service.api.SystemConfigService; import com.iflytop.sgs.app.service.device.DeviceSensorService; import com.iflytop.sgs.app.service.device.DeviceStateService; import com.iflytop.sgs.app.service.device.module.SolutionModuleService; import com.iflytop.sgs.app.service.device.module.TransferModuleService; +import com.iflytop.sgs.app.ws.server.WebSocketSender; import com.iflytop.sgs.common.annotation.CommandMapping; +import com.iflytop.sgs.common.constant.WebSocketMessageType; import com.iflytop.sgs.common.enums.CraftsTransferTypeCode; import com.iflytop.sgs.common.enums.DeviceSensorCode; import com.iflytop.sgs.common.enums.SolutionCode; @@ -40,7 +41,7 @@ public class LiquidReduceCommand extends BaseCommandHandler { private final TransferModuleService transferModuleService; private final SystemConfigService systemConfigService; private final DeviceSensorService deviceSensorService; - private final CraftsService craftsService; + private final WebSocketSender webSocketService; @Override public CompletableFuture handle(CmdDTO cmdDTO) { @@ -48,50 +49,83 @@ public class LiquidReduceCommand extends BaseCommandHandler { throw new AppException(ResultCode.CMD_BUSY); } JSONArray jsonArray = cmdDTO.getJSONArrayParam("columns");//获取参数 - Double height=cmdDTO.getDoubleParam("height");//抽液针头下降高度 - if(height>55){ + Double height = cmdDTO.getDoubleParam("height");//抽液针头下降高度 + Double needleDropHeight = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.needle_drop_height);//抽液时针下降高度 + if (height > needleDropHeight) { throw new AppException(ResultCode.PARAMETER_OUT_OF_RANGE); } Assert.isTrue(!jsonArray.isEmpty(), () -> new AppException(ResultCode.INVALID_PARAMETER));//参数校验 Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液时托盘位置点 Double trayTubeHorizontalSpacingDistance = devicePositionService.getPosition(DevicePositionCode.trayTubeHorizontalSpacingDistance).getDistance();//获取托盘试管水平间距 Double solutionModuleMotorDownInTubeExtPositon = devicePositionService.getPosition(DevicePositionCode.solutionModuleMotorDownInTubeExtPositon).getPositon();//加液模块电机下降进入试管抽取位置 - double reduceNumber = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.reduce_distance);//抽液volume配置 + Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹取位置点 + Double transferModuleXPickTrayMoveDistance = devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance();//获取转运模块X轴拿取托盘进出卡槽移动距离 + double reduceDistance = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.reduce_distance);//抽液volume配置 + double pumpReduceSpeed = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.pump_reduce_speed);//蠕动泵抽取转速 boolean moduleIdle = deviceStateService.getDeviceState().getTransferModule().isIdle(); if (!moduleIdle) { throw new AppException(ResultCode.CMD_BUSY);//设备忙 } - boolean requestResult = transferModuleService.requestTransferModule(CraftsTransferTypeCode.move_by_manual);//申请使用转运模块 - if (!requestResult) { - throw new AppException(ResultCode.CMD_BUSY);//设备忙 - } return runAsync(() -> { try { + boolean requestResult = transferModuleService.requestTransferModule(CraftsTransferTypeCode.move_by_manual);//申请使用转运模块 + if (!requestResult) { + throw new AppException(ResultCode.CMD_BUSY);//设备忙 + } deviceStateService.getCommandMutexState().get().setTransferCommandExecuting(true); solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液模块上升 transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//移动至加液时托盘位置点 - boolean liquidTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST);//获取夹爪是否有托盘 - Assert.isTrue(liquidTrayExist, () -> new AppException(ResultCode.SOLUTION_MODULE_NO_TRAY));//判断转态 - deviceStateService.getDeviceState().getSolutionModule().setPumping(true);//设置正在加液 - solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), SolutionCode.waste);//电磁阀对应通道打开 - for (int i = 0; i < jsonArray.size(); i++) { - int column = jsonArray.getInt(i); - if (column > 0 && column < 6) { - double distance = Math.abs(column - 5) * trayTubeHorizontalSpacingDistance; - transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX() + distance);//机械臂移动到试管位置 - solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeExtPositon+height);//加液模块下降进入试管 - solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), -reduceNumber);//抽液 - solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液模块上升 + boolean liquidTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST);//获取机械臂是否有托盘 + if (liquidTrayExist) { + deviceStateService.getDeviceState().getSolutionModule().setPumping(true);//设置正在加液 + solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), SolutionCode.waste);//电磁阀对应通道打开 + solutionModuleService.liquidPumpSetSpeed(cmdDTO.getCommandId(), cmdDTO.getCommand(), pumpReduceSpeed);//设置泵的转速 + for (int i = 0; i < jsonArray.size(); i++) { + int column = jsonArray.getInt(i); + if (column > 0 && column < 6) { + double distance = Math.abs(column - 5) * trayTubeHorizontalSpacingDistance; + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX() + distance);//机械臂移动到试管位置 + solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeExtPositon + height);//加液模块下降进入试管 + solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), -reduceDistance);//抽液 + solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液模块上升 + } } + solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液模块上升至最高,移出试管 + transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//移动至托盘至加液位置点 + deviceStateService.getDeviceState().getSolutionModule().setPumping(false);//设置加液结束 + } else { + boolean feedTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取上料位托盘状态 + if (feedTrayExist) {//上料区存在托盘 + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getX() + transferModuleXPickTrayMoveDistance);//将X轴移动至上料区托盘夹取点 + 进出卡槽移动距离 + transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 + transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽 + transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//移动至加液位置 + deviceStateService.getDeviceState().getSolutionModule().setPumping(true);//设置正在加液 + solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), SolutionCode.waste);//电磁阀对应通道打开 + solutionModuleService.liquidPumpSetSpeed(cmdDTO.getCommandId(), cmdDTO.getCommand(), pumpReduceSpeed);//设置泵的转速 + for (int i = 0; i < jsonArray.size(); i++) { + int column = jsonArray.getInt(i); + if (column > 0 && column < 6) { + double distance = Math.abs(column - 5) * trayTubeHorizontalSpacingDistance; + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX() + distance);//机械臂移动到试管位置 + solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeExtPositon + height);//加液模块下降进入试管 + solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), -reduceDistance);//抽液 + solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液模块上升 + } + } + solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液模块上升至最高,移出试管 + transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//移动至托盘至加液位置点 + deviceStateService.getDeviceState().getSolutionModule().setPumping(false);//设置加液结束 + } else { + webSocketService.push(WebSocketMessageType.WARN, "请先把托盘放置上料位!"); + } + } - solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液模块上升至最高,移出试管 - transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//移动至托盘至加液位置点 - deviceStateService.getDeviceState().getSolutionModule().setPumping(false);//设置加液结束 transferModuleService.releaseTransferModule();//释放转运模组 } catch (Exception e) { log.error("抽液指令执行异常:{}", e.getMessage()); throw new Exception(e); - }finally { + } finally { deviceStateService.getCommandMutexState().get().setTransferCommandExecuting(false); } diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToAnnealAreaCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToAnnealAreaCommand.java index eb007eb..a0c1830 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToAnnealAreaCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToAnnealAreaCommand.java @@ -4,14 +4,15 @@ import cn.hutool.core.lang.Assert; import com.iflytop.sgs.app.core.BaseCommandHandler; import com.iflytop.sgs.app.model.bo.Point3D; import com.iflytop.sgs.app.model.dto.CmdDTO; -import com.iflytop.sgs.app.service.api.CraftsService; import com.iflytop.sgs.app.service.api.DevicePositionService; import com.iflytop.sgs.app.service.device.DeviceSensorService; import com.iflytop.sgs.app.service.device.DeviceStateService; import com.iflytop.sgs.app.service.device.module.HeatModuleService; import com.iflytop.sgs.app.service.device.module.SolutionModuleService; import com.iflytop.sgs.app.service.device.module.TransferModuleService; +import com.iflytop.sgs.app.ws.server.WebSocketSender; import com.iflytop.sgs.common.annotation.CommandMapping; +import com.iflytop.sgs.common.constant.WebSocketMessageType; import com.iflytop.sgs.common.enums.CraftsTransferTypeCode; import com.iflytop.sgs.common.enums.DeviceSensorCode; import com.iflytop.sgs.common.enums.HeatModuleCode; @@ -39,7 +40,7 @@ public class MoveToAnnealAreaCommand extends BaseCommandHandler { private final DeviceStateService deviceStateService; private final DeviceSensorService deviceSensorService; private final SolutionModuleService solutionModuleService; - private final CraftsService craftsService; + private final WebSocketSender webSocketService; @Override public CompletableFuture handle(CmdDTO cmdDTO) throws Exception { @@ -52,62 +53,98 @@ public class MoveToAnnealAreaCommand extends BaseCommandHandler { if (heatModuleCodeStr != null) {//目标加热模块非必填,如果没有传递目标加热模块则尝试获取上料区是否有托盘 heatModuleCode = HeatModuleCode.valueOf(heatModuleCodeStr);//目标加热模块 Assert.isTrue(!heatModuleCode.equals(targetHeatModuleCode), () -> new AppException(ResultCode.HAVE_IN_ANNEAL_MODULE));//传参模块和目标模块不能一致 + boolean heatTrayExist = deviceSensorService.getTrayStateByHeatModuleCode(heatModuleCode);//获取传感器状态 + Assert.isTrue(heatTrayExist, () -> new AppException(ResultCode.TARGET_HEAT_MODULE_NO_TRAY));//加热模块无托盘 } else { heatModuleCode = null; } Point3D targetHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(targetHeatModuleCode);//获取目标加热模块托盘夹取点 Double transferModuleXPickTrayMoveDistance = devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance();//获取转运模块X轴拿取托盘进出卡槽移动距离 Point3D liquidAreaTrayPoint = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D(); //获取加液区上方点位 - Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹爪位置点 + Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹取位置点 + Point3D heatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(heatModuleCode);//获取加热模块托盘夹取点 boolean annealTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.HEATER_TRAY_4_EXIST);//获取传感器状态 Assert.isTrue(!annealTrayExist, () -> new AppException(ResultCode.ANNEAL_MODULE_EXIST_TRAY));//退火位不能有托盘 boolean moduleIdle = deviceStateService.getDeviceState().getTransferModule().isIdle(); if (!moduleIdle) { throw new AppException(ResultCode.CMD_BUSY);//设备忙 } - boolean requestResult = transferModuleService.requestTransferModule(CraftsTransferTypeCode.move_by_manual);//申请使用转运模块 - if (!requestResult) { - throw new AppException(ResultCode.CMD_BUSY);//设备忙 - } return runAsync(() -> { try { + boolean requestResult = transferModuleService.requestTransferModule(CraftsTransferTypeCode.move_by_manual);//申请使用转运模块 + if (!requestResult) { + throw new AppException(ResultCode.CMD_BUSY);//设备忙 + } deviceStateService.getCommandMutexState().get().setTransferCommandExecuting(true); solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液机械臂上升 - if (heatModuleCode == null) { + if (heatModuleCode == null) {//未选择加热区 transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);//移动至加液位置 - boolean liquidTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST);//获取夹爪是否有托盘 + boolean liquidTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST);//获取机械臂是否有托盘 if (!liquidTrayExist) { - boolean feedTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//上料区是否有托盘 - Assert.isTrue(feedTrayExist, () -> new AppException(ResultCode.FEED_AREA_NO_TRAY));//上料区必须有托盘 transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getX() + transferModuleXPickTrayMoveDistance);//将X轴移动至上料区托盘夹取点 + 进出卡槽移动距离 - feedTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//上料区是否有托盘 - Assert.isTrue(feedTrayExist, () -> new AppException(ResultCode.FEED_AREA_NO_TRAY));//上料区必须有托盘 - transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 - transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽 + boolean feedTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//上料区是否有托盘 + if (feedTrayExist) { + transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 + transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽 + transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getX());//将X轴移动至目标加热模块托盘夹取点 + boolean annealTrayExistAgain = deviceSensorService.getSensorStatus(DeviceSensorCode.HEATER_TRAY_4_EXIST);//获取传感器状态 + if (!annealTrayExistAgain) { + transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 + transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleXPickTrayMoveDistance);//X轴移出卡槽 + transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 + }else{ + webSocketService.push(WebSocketMessageType.WARN, "退火区存在托盘!"); + } + } else { + webSocketService.push(WebSocketMessageType.WARN, "上料区无托盘!"); + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getX());//将X轴移动至目标加热模块托盘夹取点 + } + } else {//机械臂存在托盘 + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getX());//将X轴移动至目标加热模块托盘夹取点 + boolean annealTrayExistAgain = deviceSensorService.getSensorStatus(DeviceSensorCode.HEATER_TRAY_4_EXIST);//获取传感器状态 + if (!annealTrayExistAgain) { + transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 + transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleXPickTrayMoveDistance);//X轴移出卡槽 + transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 + }else{ + webSocketService.push(WebSocketMessageType.WARN, "退火区存在托盘!"); + } } - } else { - boolean heatTrayExist = deviceSensorService.getTrayStateByHeatModuleCode(heatModuleCode);//获取转移加热区的传感器状态 - Assert.isTrue(heatTrayExist, () -> new AppException(ResultCode.TARGET_HEAT_MODULE_NO_TRAY));//加热模块无托盘 - Point3D heatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(heatModuleCode);//获取加热模块托盘夹取点 - transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleTrayClawPoint3D.getX() + transferModuleXPickTrayMoveDistance);//将X轴移动至加热区托盘夹取点 + 进出卡槽移动距离 - heatTrayExist = deviceSensorService.getTrayStateByHeatModuleCode(heatModuleCode);//获取转移加热区的传感器状态 - Assert.isTrue(heatTrayExist, () -> new AppException(ResultCode.TARGET_HEAT_MODULE_NO_TRAY));//加热模块无托盘 - transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleTrayClawPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 - transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽 - deviceStateService.getDeviceState().getHeatModuleByCode(targetHeatModuleCode).setTrayStatus(false);//设定目标加热模块托盘状态 + } else {//选择了加热区 + transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);//移动至加液位置 + boolean liquidTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST);//获取机械臂是否有托盘 + if (!liquidTrayExist) { + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleTrayClawPoint3D.getX() + transferModuleXPickTrayMoveDistance);//将X轴移动至加热区托盘夹取点 + 进出卡槽移动距离 + boolean heatTrayExist = deviceSensorService.getTrayStateByHeatModuleCode(heatModuleCode);//获取转移加热区的传感器状态 + if (heatTrayExist) { + transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleTrayClawPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 + transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽 + deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayStatus(false);//设定目标加热模块托盘状态 + transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getX());//将X轴移动至目标加热模块托盘夹取点 + boolean annealTrayExistAgain = deviceSensorService.getSensorStatus(DeviceSensorCode.HEATER_TRAY_4_EXIST);//获取传感器状态 + if (!annealTrayExistAgain) { + transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 + transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleXPickTrayMoveDistance);//X轴移出卡槽 + transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 + }else{ + webSocketService.push(WebSocketMessageType.WARN, "退火区存在托盘!"); + } + } else { + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getX());//将X轴移动至目标加热模块托盘夹取点 + webSocketService.push(WebSocketMessageType.WARN, "目标加热区存在托盘!"); + } + } else { + webSocketService.push(WebSocketMessageType.WARN, "请先取出机械臂托盘!"); + } + } - transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 - transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getX());//将X轴移动至目标加热模块托盘夹取点 - boolean annealTrayExistAgain = deviceSensorService.getSensorStatus(DeviceSensorCode.HEATER_TRAY_4_EXIST);//获取传感器状态 - Assert.isTrue(!annealTrayExistAgain, () -> new AppException(ResultCode.ANNEAL_MODULE_EXIST_TRAY));//退火位不能有托盘 - transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 - transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleXPickTrayMoveDistance);//X轴移出卡槽 - transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 transferModuleService.releaseTransferModule();//释放转运模组 } catch (Exception e) { log.error("移动至退火区指令执行异常:{}", e.getMessage()); throw new Exception(e); - }finally { + } finally { deviceStateService.getCommandMutexState().get().setTransferCommandExecuting(false); } }); diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToFeedAreaCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToFeedAreaCommand.java index 188035c..ab45b25 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToFeedAreaCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToFeedAreaCommand.java @@ -4,14 +4,15 @@ import cn.hutool.core.lang.Assert; import com.iflytop.sgs.app.core.BaseCommandHandler; import com.iflytop.sgs.app.model.bo.Point3D; import com.iflytop.sgs.app.model.dto.CmdDTO; -import com.iflytop.sgs.app.service.api.CraftsService; import com.iflytop.sgs.app.service.api.DevicePositionService; import com.iflytop.sgs.app.service.device.DeviceSensorService; import com.iflytop.sgs.app.service.device.DeviceStateService; import com.iflytop.sgs.app.service.device.module.HeatModuleService; import com.iflytop.sgs.app.service.device.module.SolutionModuleService; import com.iflytop.sgs.app.service.device.module.TransferModuleService; +import com.iflytop.sgs.app.ws.server.WebSocketSender; import com.iflytop.sgs.common.annotation.CommandMapping; +import com.iflytop.sgs.common.constant.WebSocketMessageType; import com.iflytop.sgs.common.enums.CraftsTransferTypeCode; import com.iflytop.sgs.common.enums.DeviceSensorCode; import com.iflytop.sgs.common.enums.HeatModuleCode; @@ -39,7 +40,7 @@ public class MoveToFeedAreaCommand extends BaseCommandHandler { private final DeviceStateService deviceStateService; private final DeviceSensorService deviceSensorService; private final SolutionModuleService solutionModuleService; - private final CraftsService craftsService; + private final WebSocketSender webSocketService; @Override public CompletableFuture handle(CmdDTO cmdDTO) throws Exception { @@ -59,51 +60,70 @@ public class MoveToFeedAreaCommand extends BaseCommandHandler { targetHeatModuleCode = null; } Double transferModuleXPickTrayMoveDistance = devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance();//获取转运模块X轴拿取托盘进出卡槽移动距离 - Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹爪位置点 - Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液区托盘夹爪位置点 + Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘机械臂位置点 + Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液区托盘机械臂位置点 + Point3D targetHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(targetHeatModuleCode);//获取目标加热模块托盘夹取点 + Point3D liquidAreaTrayPoint = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D(); //获取加液区上方点位 boolean moduleIdle = deviceStateService.getDeviceState().getTransferModule().isIdle(); if (!moduleIdle) { throw new AppException(ResultCode.CMD_BUSY);//设备忙 } - boolean requestResult = transferModuleService.requestTransferModule(CraftsTransferTypeCode.move_by_manual);//申请使用转运模块 - if (!requestResult) { - throw new AppException(ResultCode.CMD_BUSY);//设备忙 - } return runAsync(() -> { try { + boolean requestResult = transferModuleService.requestTransferModule(CraftsTransferTypeCode.move_by_manual);//申请使用转运模块 + if (!requestResult) { + throw new AppException(ResultCode.CMD_BUSY);//设备忙 + } deviceStateService.getCommandMutexState().get().setTransferCommandExecuting(true); solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液机械臂上升 - if (targetHeatModuleCode == null) { + if (targetHeatModuleCode == null) {//未选择加热区 transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//移动至加液位置 - boolean clawTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST);//获取夹爪位托盘状态 - Assert.isTrue(clawTrayExist, () -> new AppException(ResultCode.OPERATION_NOT_ALLOWED));//夹爪托盘必须存在 - transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getX());//将X轴移动至上料区位置点 - boolean feedTrayExistAgain = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取上料区位托盘状态 - Assert.isTrue(!feedTrayExistAgain, () -> new AppException(ResultCode.FEED_AREA_EXIST_TRAY));//上料区存在托盘 - transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getZ());//Z轴下降至夹取点,使托盘落入上料区 - transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleXPickTrayMoveDistance);//X轴移出卡槽 - transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 - deviceStateService.getDeviceState().getSolutionModule().setFeedAreaTrayStatus(true);//设定上料区托盘状态 - } else { - boolean heatTrayExist = deviceSensorService.getTrayStateByHeatModuleCode(targetHeatModuleCode);//获取传感器状态 - Assert.isTrue(heatTrayExist, () -> new AppException(ResultCode.TARGET_HEAT_MODULE_NO_TRAY));//加热区无托盘 - Point3D targetHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(targetHeatModuleCode);//获取目标加热模块托盘夹取点 - transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getX() + transferModuleXPickTrayMoveDistance);//将X轴移动至目标加热模块托盘夹取点 + 进出卡槽移动距离 - heatTrayExist = deviceSensorService.getTrayStateByHeatModuleCode(targetHeatModuleCode);//获取传感器状态 - Assert.isTrue(heatTrayExist, () -> new AppException(ResultCode.TARGET_HEAT_MODULE_NO_TRAY));//加热区无托盘 - transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 - transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽 - deviceStateService.getDeviceState().getTransferModule().setTrayStatus(true);//设定托盘在机械臂上 - transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 - transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getX());//将X轴移动至上料区位置点 - boolean feedTrayExistAgain = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取上料区位托盘状态 - Assert.isTrue(!feedTrayExistAgain, () -> new AppException(ResultCode.FEED_AREA_EXIST_TRAY));//上料区存在托盘 - transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getZ());//Z轴下降至夹取点,使托盘落入上料区 - transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleXPickTrayMoveDistance);//X轴移出卡槽 - transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 - deviceStateService.getDeviceState().getTransferModule().setTrayStatus(false);//设定托盘夹爪为FALSE - deviceStateService.getDeviceState().getHeatModuleByCode(targetHeatModuleCode).setTrayStatus(false);//设定目标加热模块托盘状态 - deviceStateService.getDeviceState().getSolutionModule().setFeedAreaTrayStatus(true);//设定上料区托盘状态 + boolean clawTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST);//获取机械臂位托盘状态 + if (clawTrayExist) {//机械臂存在托盘 + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getX());//将X轴移动至上料区位置点 + boolean feedTrayExistAgain = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取上料区位托盘状态 + if (!feedTrayExistAgain) { + transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getZ());//Z轴下降至夹取点,使托盘落入上料区 + transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleXPickTrayMoveDistance);//X轴移出卡槽 + transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 + deviceStateService.getDeviceState().getSolutionModule().setFeedAreaTrayStatus(true);//设定上料区托盘状态 + }else{ + webSocketService.push(WebSocketMessageType.WARN, "上料区存在托盘!"); + } + } else {//机械臂不存在托盘 + webSocketService.push(WebSocketMessageType.WARN, "机械臂不存在托盘!"); + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getX());//将X轴移动至上料区位置点 + } + } else {//选择了加热区 + transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);//移动至加液位置 + boolean liquidTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST);//获取机械臂是否有托盘 + if (!liquidTrayExist) { + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getX() + transferModuleXPickTrayMoveDistance);//将X轴移动至目标加热模块托盘夹取点 + 进出卡槽移动距离 + boolean heatTrayExist = deviceSensorService.getTrayStateByHeatModuleCode(targetHeatModuleCode);//获取传感器状态 + if (heatTrayExist) {//目标加热位有托盘 + transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 + transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽 + deviceStateService.getDeviceState().getTransferModule().setTrayStatus(true);//设定托盘在机械臂上 + transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getX());//将X轴移动至上料区位置点 + boolean feedTrayExistAgain = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取上料区位托盘状态 + if (!feedTrayExistAgain) { + transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getZ());//Z轴下降至夹取点,使托盘落入上料区 + transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleXPickTrayMoveDistance);//X轴移出卡槽 + transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 + deviceStateService.getDeviceState().getTransferModule().setTrayStatus(false);//设定托盘夹取为FALSE + deviceStateService.getDeviceState().getHeatModuleByCode(targetHeatModuleCode).setTrayStatus(false);//设定目标加热模块托盘状态 + deviceStateService.getDeviceState().getSolutionModule().setFeedAreaTrayStatus(true);//设定上料区托盘状态 + }else{ + webSocketService.push(WebSocketMessageType.WARN, "上料区存在托盘!"); + } + } else {//目标加热位无托盘 + webSocketService.push(WebSocketMessageType.WARN, "目标加热区无托盘!"); + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getX());//将X轴移动至上料区位置点 + } + } else { + webSocketService.push(WebSocketMessageType.WARN, "请先放置机械臂托盘!"); + } } transferModuleService.releaseTransferModule();//释放转运模组 } catch (Exception e) { diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToHeatAreaCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToHeatAreaCommand.java index f189287..987f375 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToHeatAreaCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToHeatAreaCommand.java @@ -4,14 +4,15 @@ import cn.hutool.core.lang.Assert; import com.iflytop.sgs.app.core.BaseCommandHandler; import com.iflytop.sgs.app.model.bo.Point3D; import com.iflytop.sgs.app.model.dto.CmdDTO; -import com.iflytop.sgs.app.service.api.CraftsService; import com.iflytop.sgs.app.service.api.DevicePositionService; import com.iflytop.sgs.app.service.device.DeviceSensorService; import com.iflytop.sgs.app.service.device.DeviceStateService; import com.iflytop.sgs.app.service.device.module.HeatModuleService; import com.iflytop.sgs.app.service.device.module.SolutionModuleService; import com.iflytop.sgs.app.service.device.module.TransferModuleService; +import com.iflytop.sgs.app.ws.server.WebSocketSender; import com.iflytop.sgs.common.annotation.CommandMapping; +import com.iflytop.sgs.common.constant.WebSocketMessageType; import com.iflytop.sgs.common.enums.CraftsTransferTypeCode; import com.iflytop.sgs.common.enums.DeviceSensorCode; import com.iflytop.sgs.common.enums.HeatModuleCode; @@ -25,7 +26,7 @@ import org.springframework.stereotype.Component; import java.util.concurrent.CompletableFuture; /** - * 将上料区托盘或者夹爪托盘移至目标加热模块 + * 将上料区托盘或者机械臂托盘移至目标加热模块 */ @Slf4j @Component @@ -39,7 +40,7 @@ public class MoveToHeatAreaCommand extends BaseCommandHandler { private final DeviceStateService deviceStateService; private final DeviceSensorService deviceSensorService; private final SolutionModuleService solutionModuleService; - private final CraftsService craftsService; + private final WebSocketSender webSocketService; @Override public CompletableFuture handle(CmdDTO cmdDTO) throws Exception { @@ -49,49 +50,65 @@ public class MoveToHeatAreaCommand extends BaseCommandHandler { HeatModuleCode targetHeatModuleCode = HeatModuleCode.valueOf(targetHeatModuleCodeStr);//目标加热模块 Point3D targetHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(targetHeatModuleCode);//获取目标加热模块托盘夹取点 Double transferModuleXPickTrayMoveDistance = devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance();//获取转运模块X轴拿取托盘进出卡槽移动距离 - Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹爪位置点 - Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液区托盘夹爪位置点 + Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹取位置点 + Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液区托盘夹取位置点 + - boolean heatModuleTrayExist = deviceSensorService.getTrayStateByHeatModuleCode(targetHeatModuleCode);//目标加热模块有无托盘 - Assert.isTrue(!heatModuleTrayExist, () -> new AppException(ResultCode.TARGET_HEAT_MODULE_OCCUPIED));//提示被占用 - deviceStateService.getCommandMutexState().get().setTransferCommandExecuting(true); boolean heatTrayExist = deviceSensorService.getTrayStateByHeatModuleCode(targetHeatModuleCode);//获取传感器状态 Assert.isTrue(!heatTrayExist, () -> new AppException(ResultCode.TARGET_HEAT_MODULE_OCCUPIED));//加热区存在托盘 + deviceStateService.getCommandMutexState().get().setTransferCommandExecuting(true); boolean moduleIdle = deviceStateService.getDeviceState().getTransferModule().isIdle(); if (!moduleIdle) { throw new AppException(ResultCode.CMD_BUSY);//设备忙 } - boolean requestResult = transferModuleService.requestTransferModule(CraftsTransferTypeCode.move_by_manual);//申请使用转运模块 - if (!requestResult) { - throw new AppException(ResultCode.CMD_BUSY);//设备忙 - } return runAsync(() -> { try { + boolean requestResult = transferModuleService.requestTransferModule(CraftsTransferTypeCode.move_by_manual);//申请使用转运模块 + if (!requestResult) { + throw new AppException(ResultCode.CMD_BUSY);//设备忙 + } solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液机械臂上升 transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//移动至加液位置 boolean clawTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST);//获取传感器状态 - if (!clawTrayExist) { //夹爪不存在托盘 - boolean feedTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取上料区传感器状态 - Assert.isTrue(feedTrayExist, () -> new AppException(ResultCode.FEED_AREA_NO_TRAY));//上料区必须存在托盘 - transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getX() + transferModuleXPickTrayMoveDistance);//将X轴移动至上料区托盘夹取点 + 进出卡槽移动距离 - feedTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取上料区传感器状态 - Assert.isTrue(feedTrayExist, () -> new AppException(ResultCode.FEED_AREA_NO_TRAY));//上料区必须存在托盘 - transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 - transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽 - transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 + if (!clawTrayExist) { //机械臂不存在托盘 + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getX() + transferModuleXPickTrayMoveDistance);//将X轴移动至上料区托盘夹取点 + 进出卡槽移动距离 + boolean feedTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取上料区传感器状态 + if (feedTrayExist) {//上料区存在托盘 + transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 + transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽 + transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getX());//将X轴移动至目标加热模块托盘夹取点 + boolean heatTrayExistAgain = deviceSensorService.getTrayStateByHeatModuleCode(targetHeatModuleCode);//获取传感器状态 + if (!heatTrayExistAgain) { + transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 + transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleXPickTrayMoveDistance);//X轴移出卡槽 + transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 + deviceStateService.getDeviceState().getHeatModuleByCode(targetHeatModuleCode).setTrayStatus(true);//设置目标加热区有托盘 + }else{ + webSocketService.push(WebSocketMessageType.WARN, "目标加热区存在托盘!"); + } + }else{//上料区无托盘 + webSocketService.push(WebSocketMessageType.WARN, "上料区无托盘!"); + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getX());//将X轴移动至目标加热模块托盘夹取点 + } + + } else { + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getX());//将X轴移动至目标加热模块托盘夹取点 + boolean heatTrayExistAgain = deviceSensorService.getTrayStateByHeatModuleCode(targetHeatModuleCode);//获取传感器状态 + if(!heatTrayExistAgain){ + transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 + transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleXPickTrayMoveDistance);//X轴移出卡槽 + transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 + deviceStateService.getDeviceState().getHeatModuleByCode(targetHeatModuleCode).setTrayStatus(true);//设置目标加热区有托盘 + }else{ + webSocketService.push(WebSocketMessageType.WARN, "目标加热区存在托盘!"); + } } - transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getX());//将X轴移动至目标加热模块托盘夹取点 - boolean heatTrayExistAgain = deviceSensorService.getTrayStateByHeatModuleCode(targetHeatModuleCode);//获取传感器状态 - Assert.isTrue(!heatTrayExistAgain, () -> new AppException(ResultCode.TARGET_HEAT_MODULE_OCCUPIED));//加热区存在托盘 - transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 - transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleXPickTrayMoveDistance);//X轴移出卡槽 - transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 - deviceStateService.getDeviceState().getHeatModuleByCode(targetHeatModuleCode).setTrayStatus(true);//设置目标加热区有托盘 transferModuleService.releaseTransferModule();//释放转运模组 } catch (Exception e) { log.error("移动至加热区指令执行异常:{}", e.getMessage()); throw new Exception(e); - }finally { + } finally { deviceStateService.getCommandMutexState().get().setTransferCommandExecuting(false); } }); diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToLiquidAreaCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToLiquidAreaCommand.java index 8f5f64a..ff25301 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToLiquidAreaCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToLiquidAreaCommand.java @@ -4,14 +4,15 @@ import cn.hutool.core.lang.Assert; import com.iflytop.sgs.app.core.BaseCommandHandler; import com.iflytop.sgs.app.model.bo.Point3D; import com.iflytop.sgs.app.model.dto.CmdDTO; -import com.iflytop.sgs.app.service.api.CraftsService; import com.iflytop.sgs.app.service.api.DevicePositionService; import com.iflytop.sgs.app.service.device.DeviceSensorService; import com.iflytop.sgs.app.service.device.DeviceStateService; import com.iflytop.sgs.app.service.device.module.HeatModuleService; import com.iflytop.sgs.app.service.device.module.SolutionModuleService; import com.iflytop.sgs.app.service.device.module.TransferModuleService; +import com.iflytop.sgs.app.ws.server.WebSocketSender; import com.iflytop.sgs.common.annotation.CommandMapping; +import com.iflytop.sgs.common.constant.WebSocketMessageType; import com.iflytop.sgs.common.enums.CraftsTransferTypeCode; import com.iflytop.sgs.common.enums.DeviceSensorCode; import com.iflytop.sgs.common.enums.HeatModuleCode; @@ -39,7 +40,7 @@ public class MoveToLiquidAreaCommand extends BaseCommandHandler { private final DeviceStateService deviceStateService; private final SolutionModuleService solutionModuleService; private final DeviceSensorService deviceSensorService; - private final CraftsService craftsService; + private final WebSocketSender webSocketService; @Override @@ -51,56 +52,59 @@ public class MoveToLiquidAreaCommand extends BaseCommandHandler { HeatModuleCode targetHeatModuleCode;//目标加热模块 if (targetHeatModuleCodeStr != null) {//目标加热模块非必填,如果没有传递目标加热模块则尝试获取上料区是否有托盘 targetHeatModuleCode = HeatModuleCode.valueOf(targetHeatModuleCodeStr); + boolean headTrayExist = deviceSensorService.getTrayStateByHeatModuleCode(targetHeatModuleCode);//获取传感器状态 + if (!headTrayExist) { + throw new AppException(ResultCode.TARGET_HEAT_MODULE_NO_TRAY); + } } else { targetHeatModuleCode = null; } Double transferModuleXPickTrayMoveDistance = devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance();//获取转运模块X轴拿取托盘进出卡槽移动距离 - Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹爪位置点 + Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹取位置点 Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液时托盘位置点 - Assert.isTrue(deviceStateService.getDeviceState().getSolutionModule().isIdle(), () -> new AppException(ResultCode.SOLUTION_MODULE_IS_BUSY));//判断加液模块状态 + Point3D targetHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(targetHeatModuleCode);//获取目标加热模块托盘夹取点 boolean moduleIdle = deviceStateService.getDeviceState().getTransferModule().isIdle(); if (!moduleIdle) { throw new AppException(ResultCode.CMD_BUSY);//设备忙 } - boolean requestResult = transferModuleService.requestTransferModule(CraftsTransferTypeCode.move_by_manual);//申请使用转运模块 - if (!requestResult) { - throw new AppException(ResultCode.CMD_BUSY);//设备忙 - } return runAsync(() -> { try { + boolean requestResult = transferModuleService.requestTransferModule(CraftsTransferTypeCode.move_by_manual);//申请使用转运模块 + if (!requestResult) { + throw new AppException(ResultCode.CMD_BUSY);//设备忙 + } deviceStateService.getCommandMutexState().get().setTransferCommandExecuting(true); solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液机械臂上升 transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//移动至加液位置 boolean clawTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST);//获取传感器状态 - if (!clawTrayExist) {//夹爪无托盘 + if (!clawTrayExist) {//机械臂无托盘 if (targetHeatModuleCode == null) {//无加热模块参数 boolean feedTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取传感器状态 - Assert.isTrue(feedTrayExist, () -> new AppException(ResultCode.FEED_AREA_NO_TRAY));//上料区必须存在托盘 - transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getX() + transferModuleXPickTrayMoveDistance);//将X轴移动至上料区托盘夹取点 + 进出卡槽移动距离 - transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 - feedTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取传感器状态 - Assert.isTrue(feedTrayExist, () -> new AppException(ResultCode.FEED_AREA_NO_TRAY));//上料区必须存在托盘 - transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽 - transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 - deviceStateService.getDeviceState().getSolutionModule().setFeedAreaTrayStatus(false);//设定上料区托盘状态 + if (feedTrayExist) { + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getX() + transferModuleXPickTrayMoveDistance);//将X轴移动至上料区托盘夹取点 + 进出卡槽移动距离 + transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 + transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽 + transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 + deviceStateService.getDeviceState().getSolutionModule().setFeedAreaTrayStatus(false);//设定上料区托盘状态 + } else { + webSocketService.push(WebSocketMessageType.WARN, "上料区无托盘!"); + } } else {//有加热模块参数 - boolean headTrayExist = deviceSensorService.getTrayStateByHeatModuleCode(targetHeatModuleCode);//获取传感器状态 - Assert.isTrue(headTrayExist, () -> new AppException(ResultCode.TARGET_HEAT_MODULE_NO_TRAY));//加热区无托盘 - Point3D targetHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(targetHeatModuleCode);//获取目标加热模块托盘夹取点 transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getX() + transferModuleXPickTrayMoveDistance);//将X轴移动至目标加热模块托盘夹取点 + 进出卡槽移动距离 - headTrayExist = deviceSensorService.getTrayStateByHeatModuleCode(targetHeatModuleCode);//获取传感器状态 - Assert.isTrue(headTrayExist, () -> new AppException(ResultCode.TARGET_HEAT_MODULE_NO_TRAY));//加热区无托盘 - transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 - transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽 - transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 - deviceStateService.getDeviceState().getHeatModuleByCode(targetHeatModuleCode).setTrayStatus(false);//设定目标加热模块托盘状态 + boolean headTrayExistAgain = deviceSensorService.getTrayStateByHeatModuleCode(targetHeatModuleCode);//获取传感器状态 + if (headTrayExistAgain) { + transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 + transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽 + transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 + deviceStateService.getDeviceState().getHeatModuleByCode(targetHeatModuleCode).setTrayStatus(false);//设定目标加热模块托盘状态 + } else { + webSocketService.push(WebSocketMessageType.WARN, "选择的加热区无托盘!"); + } + } transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//移动至加液时托盘位置点 } - /*else { - throw new AppException(ResultCode.TRANSFER_MODULE_YES_TRAY);//夹爪存在托盘 - }*/ transferModuleService.releaseTransferModule();//释放转运模组 } catch (Exception e) { log.error("移动至加液区指令执行异常:{}", e.getMessage()); diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/OutTrayCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/OutTrayCommand.java index c574774..ba417bb 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/OutTrayCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/OutTrayCommand.java @@ -5,14 +5,16 @@ import com.iflytop.sgs.app.core.BaseCommandHandler; import com.iflytop.sgs.app.model.bo.Point3D; import com.iflytop.sgs.app.model.bo.status.device.TrayState; import com.iflytop.sgs.app.model.dto.CmdDTO; -import com.iflytop.sgs.app.service.api.CraftsService; import com.iflytop.sgs.app.service.api.DevicePositionService; import com.iflytop.sgs.app.service.device.DeviceSensorService; import com.iflytop.sgs.app.service.device.DeviceStateService; +import com.iflytop.sgs.app.service.device.module.DoorModuleService; import com.iflytop.sgs.app.service.device.module.HeatModuleService; import com.iflytop.sgs.app.service.device.module.SolutionModuleService; import com.iflytop.sgs.app.service.device.module.TransferModuleService; +import com.iflytop.sgs.app.ws.server.WebSocketSender; import com.iflytop.sgs.common.annotation.CommandMapping; +import com.iflytop.sgs.common.constant.WebSocketMessageType; import com.iflytop.sgs.common.enums.CraftsTransferTypeCode; import com.iflytop.sgs.common.enums.DeviceSensorCode; import com.iflytop.sgs.common.enums.HeatModuleCode; @@ -41,51 +43,67 @@ public class OutTrayCommand extends BaseCommandHandler { private final DeviceStateService deviceStateService; private final DeviceSensorService deviceSensorService; private final SolutionModuleService solutionModuleService; - private final CraftsService craftsService; + private final DoorModuleService doorModuleService; + private final WebSocketSender webSocketService; @Override public CompletableFuture handle(CmdDTO cmdDTO) throws Exception { String targetHeatModuleCodeStr = cmdDTO.getStringParam("heatModuleCode"); Double transferModuleXPickTrayMoveDistance = devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance();//获取转运模块X轴拿取托盘进出卡槽移动距离 - Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹爪位置点 + Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹取位置点 HeatModuleCode targetHeatModuleCode = HeatModuleCode.valueOf(targetHeatModuleCodeStr);//目标加热模块 Point3D targetHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(targetHeatModuleCode);//获取目标加热模块托盘夹取点 Point3D heat1ModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(HeatModuleCode.heat_module_01);//获取加热模块1托盘夹取点 + Point3D liquidAreaTrayPoint = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D(); //获取加液区上方托盘点位 if (targetHeatModuleCode == HeatModuleCode.heat_module_04) { throw new AppException(ResultCode.NOT_ALLOWED_HEAT_MODULE);//不允许的加热模块 } boolean feedTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取上料区托盘状态 - Assert.isTrue(!feedTrayExist, () -> new AppException(ResultCode. FEED_AREA_EXIST_TRAY));//上料区不能存在托盘 + Assert.isTrue(!feedTrayExist, () -> new AppException(ResultCode.FEED_AREA_EXIST_TRAY));//上料区不能存在托盘 boolean heatTrayExist = deviceSensorService.getTrayStateByHeatModuleCode(targetHeatModuleCode);//获取传感器状态 Assert.isTrue(heatTrayExist, () -> new AppException(ResultCode.TARGET_HEAT_MODULE_NO_TRAY));//加热区无托盘 boolean moduleIdle = deviceStateService.getDeviceState().getTransferModule().isIdle(); if (!moduleIdle) { throw new AppException(ResultCode.CMD_BUSY);//设备忙 } - boolean requestResult = transferModuleService.requestTransferModule(CraftsTransferTypeCode.move_by_manual);//申请使用转运模块 - if (!requestResult) { - throw new AppException(ResultCode.CMD_BUSY);//设备忙 - } return runAsync(() -> { try { - solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液机械臂上升 - transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getX() + transferModuleXPickTrayMoveDistance);//将X轴移动至目标加热模块托盘夹取点 + 进出卡槽移动距离 - transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 - transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽 - deviceStateService.getDeviceState().getTransferModule().setTrayStatus(true);//设定托盘在机械臂上 - transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 - transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getX());//将X轴移动至上料区位置点 - boolean feedTrayExistAgain = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取上料区托盘状态 - Assert.isTrue(!feedTrayExistAgain, () -> new AppException(ResultCode.OPERATION_NOT_ALLOWED));//上料区不能存在托盘 - transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getZ());//Z轴下降至夹取点,使托盘落入上料区 - transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleXPickTrayMoveDistance);//X轴移出卡槽 - transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 - transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heat1ModuleTrayClawPoint3D.getX());//将X轴移动至加热区1上方 - deviceStateService.getDeviceState().getTransferModule().setTrayStatus(false);//设定托盘夹爪为FALSE - deviceStateService.getDeviceState().getHeatModuleByCode(targetHeatModuleCode).setTrayStatus(false);//设定目标加热模块托盘状态 - List trayList = deviceStateService.getDeviceState().getTrays(); - trayList.removeIf((tray) -> tray.getHeatModuleCode() != null && tray.getHeatModuleCode().equals(targetHeatModuleCode)); + boolean requestResult = transferModuleService.requestTransferModule(CraftsTransferTypeCode.move_by_manual);//申请使用转运模块 + if (!requestResult) { + throw new AppException(ResultCode.CMD_BUSY);//设备忙 + } + transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);//移动至加液位置 + boolean clawTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST);//获取传感器状态 + if (!clawTrayExist) { + solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液机械臂上升 + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getX() + transferModuleXPickTrayMoveDistance);//将X轴移动至目标加热模块托盘夹取点 + 进出卡槽移动距离 + boolean heatTrayExistAgain = deviceSensorService.getTrayStateByHeatModuleCode(targetHeatModuleCode);//获取传感器状态 + if (heatTrayExistAgain) { + transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 + transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽 + transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getX());//将X轴移动至上料区位置点 + boolean feedTrayExistAgain = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取上料区托盘状态 + if (!feedTrayExistAgain) { + transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getZ());//Z轴下降至夹取点,使托盘落入上料区 + transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleXPickTrayMoveDistance);//X轴移出卡槽 + transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heat1ModuleTrayClawPoint3D.getX());//将X轴移动至加热区1上方 + deviceStateService.getDeviceState().getTransferModule().setTrayStatus(false);//设定托盘夹取为FALSE + deviceStateService.getDeviceState().getHeatModuleByCode(targetHeatModuleCode).setTrayStatus(false);//设定目标加热模块托盘状态 + doorModuleService.doorOpen();//开门 + List trayList = deviceStateService.getDeviceState().getTrays(); + trayList.removeIf((tray) -> tray.getHeatModuleCode() != null && tray.getHeatModuleCode().equals(targetHeatModuleCode)); + } else { + webSocketService.push(WebSocketMessageType.WARN, "请取出上料区托盘!"); + } + } else { + webSocketService.push(WebSocketMessageType.WARN, "加热区托盘不存在!"); + } + } else { + webSocketService.push(WebSocketMessageType.WARN, "请先放置机械臂托盘!"); + } transferModuleService.releaseTransferModule();//释放转运模组 } catch (Exception e) { log.error("工艺执行中异常:{}", e.getMessage()); diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/XOriginCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/XOriginCommand.java index 1fe1afb..9010907 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/XOriginCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/XOriginCommand.java @@ -1,22 +1,17 @@ package com.iflytop.sgs.app.cmd.control; -import cn.hutool.core.lang.Assert; import com.iflytop.sgs.app.core.BaseCommandHandler; import com.iflytop.sgs.app.model.dto.CmdDTO; -import com.iflytop.sgs.app.service.api.CraftsService; -import com.iflytop.sgs.app.service.device.DeviceCommandService; import com.iflytop.sgs.app.service.device.DeviceSensorService; import com.iflytop.sgs.app.service.device.DeviceStateService; import com.iflytop.sgs.app.service.device.module.TransferModuleService; +import com.iflytop.sgs.app.ws.server.WebSocketSender; import com.iflytop.sgs.common.annotation.CommandMapping; -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.constant.WebSocketMessageType; import com.iflytop.sgs.common.enums.CraftsTransferTypeCode; import com.iflytop.sgs.common.enums.DevicePartId; import com.iflytop.sgs.common.exception.AppException; import com.iflytop.sgs.common.result.ResultCode; -import com.iflytop.sgs.common.utils.CommandUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -31,40 +26,34 @@ import java.util.concurrent.CompletableFuture; @RequiredArgsConstructor @CommandMapping("x_origin") public class XOriginCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; private final DeviceSensorService deviceSensorService; private final DeviceStateService deviceStateService; private final TransferModuleService transferModuleService; - private final CraftsService craftsService; + private final WebSocketSender webSocketService; @Override public CompletableFuture handle(CmdDTO cmdDTO) { - if (deviceStateService.getCommandMutexState().get().isGantryXOriginCommandExecuting()) { - throw new AppException(ResultCode.CMD_BUSY); - } boolean moduleIdle = deviceStateService.getDeviceState().getTransferModule().isIdle(); if (!moduleIdle) { throw new AppException(ResultCode.CMD_BUSY);//设备忙 } - boolean requestResult = transferModuleService.requestTransferModule(CraftsTransferTypeCode.move_by_manual);//申请使用转运模块 - if (!requestResult) { - throw new AppException(ResultCode.CMD_BUSY);//设备忙 - } return runAsync(() -> { try { - deviceStateService.getCommandMutexState().get().setGantryXOriginCommandExecuting(true); + boolean requestResult = transferModuleService.requestTransferModule(CraftsTransferTypeCode.move_by_manual);//申请使用转运模块 + if (!requestResult) { + throw new AppException(ResultCode.CMD_BUSY);//设备忙 + } //确保z轴的高度 Double zPosition = deviceSensorService.getMotorPosition(DevicePartId.ZM); - Assert.isTrue(zPosition < 10, () -> new AppException(ResultCode.Z_HEIGHT_NO_ALLOWED)); - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferXOrigin(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - CommandUtil.wait(deviceCommandFuture); + if (zPosition != null && zPosition < 10) { + transferModuleService.transferXMoveOrigin(cmdDTO.getCommandId(), cmdDTO.getCommand()); + } else { + webSocketService.push(WebSocketMessageType.WARN, "请先把z轴回原点!"); + } transferModuleService.releaseTransferModule();//释放转运模组 - }catch (Exception e) { + } catch (Exception e) { log.error("x轴电机回原点指令执行异常:{}", e.getMessage()); - throw new Exception(e); - } finally { - deviceStateService.getCommandMutexState().get().setGantryXOriginCommandExecuting(false); + throw new Exception(e); } }); } diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/ZOriginCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/ZOriginCommand.java index 1a7cb84..cff6153 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/ZOriginCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/ZOriginCommand.java @@ -2,18 +2,12 @@ package com.iflytop.sgs.app.cmd.control; import com.iflytop.sgs.app.core.BaseCommandHandler; import com.iflytop.sgs.app.model.dto.CmdDTO; -import com.iflytop.sgs.app.service.api.CraftsService; -import com.iflytop.sgs.app.service.device.DeviceCommandService; import com.iflytop.sgs.app.service.device.DeviceStateService; import com.iflytop.sgs.app.service.device.module.TransferModuleService; import com.iflytop.sgs.common.annotation.CommandMapping; -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.enums.CraftsTransferTypeCode; import com.iflytop.sgs.common.exception.AppException; import com.iflytop.sgs.common.result.ResultCode; -import com.iflytop.sgs.common.utils.CommandUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -28,36 +22,26 @@ import java.util.concurrent.CompletableFuture; @RequiredArgsConstructor @CommandMapping("z_origin") public class ZOriginCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; private final DeviceStateService deviceStateService; private final TransferModuleService transferModuleService; - private final CraftsService craftsService; @Override public CompletableFuture handle(CmdDTO cmdDTO) { - if (deviceStateService.getCommandMutexState().get().isGantryXOriginCommandExecuting()) { - throw new AppException(ResultCode.CMD_BUSY); - } boolean moduleIdle = deviceStateService.getDeviceState().getTransferModule().isIdle(); if (!moduleIdle) { throw new AppException(ResultCode.CMD_BUSY);//设备忙 } - boolean requestResult = transferModuleService.requestTransferModule(CraftsTransferTypeCode.move_by_manual);//申请使用转运模块 - if (!requestResult) { - throw new AppException(ResultCode.CMD_BUSY);//设备忙 - } return runAsync(() -> { try { - deviceStateService.getCommandMutexState().get().setGantryZOriginCommandExecuting(true); - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZOrigin(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - CommandUtil.wait(deviceCommandFuture); + boolean requestResult = transferModuleService.requestTransferModule(CraftsTransferTypeCode.move_by_manual);//申请使用转运模块 + if (!requestResult) { + throw new AppException(ResultCode.CMD_BUSY);//设备忙 + } + transferModuleService.transferZMoveOrigin(cmdDTO.getCommandId(), cmdDTO.getCommand()); transferModuleService.releaseTransferModule();//释放转运模组 } catch (Exception e) { log.error("z轴电机回原点指令执行异常:{}", e.getMessage()); throw new Exception(e); - }finally { - deviceStateService.getCommandMutexState().get().setGantryZOriginCommandExecuting(false); } }); } diff --git a/src/main/java/com/iflytop/sgs/app/cmd/selftest/LiquidPreFillCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/selftest/LiquidPreFillCommand.java deleted file mode 100644 index 257b6b9..0000000 --- a/src/main/java/com/iflytop/sgs/app/cmd/selftest/LiquidPreFillCommand.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.iflytop.sgs.app.cmd.selftest; - -import com.iflytop.sgs.app.core.BaseCommandHandler; -import com.iflytop.sgs.app.model.bo.Point3D; -import com.iflytop.sgs.app.model.dto.CmdDTO; -import com.iflytop.sgs.app.service.api.DevicePositionService; -import com.iflytop.sgs.app.service.api.SystemConfigService; -import com.iflytop.sgs.app.service.device.DeviceSensorService; -import com.iflytop.sgs.app.service.device.DeviceStateService; -import com.iflytop.sgs.app.service.device.module.SolutionModuleService; -import com.iflytop.sgs.app.service.device.module.TransferModuleService; -import com.iflytop.sgs.common.annotation.CommandMapping; -import com.iflytop.sgs.common.enums.DeviceSensorCode; -import com.iflytop.sgs.common.enums.SolutionCode; -import com.iflytop.sgs.common.enums.SystemConfigCode; -import com.iflytop.sgs.common.enums.data.DevicePositionCode; -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; - -import java.util.concurrent.CompletableFuture; - -/** - * 自检后 开机预充 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("liquid_pre_fill_when_launch")//业务指令注解 -public class LiquidPreFillCommand extends BaseCommandHandler { - private final SolutionModuleService solutionModuleService; - private final TransferModuleService transferModuleService; - private final DevicePositionService devicePositionService; - private final DeviceStateService deviceStateService; - private final SystemConfigService systemConfigService; - private final DeviceSensorService deviceSensorService; - - @Override - public CompletableFuture handle(CmdDTO cmdDTO) { - if (deviceStateService.getCommandMutexState().get().isMoveTest()) { - throw new AppException(ResultCode.COMMAND_ALREADY_EXECUTING); - } - deviceStateService.getCommandMutexState().get().setMoveTest(true); - return runAsync(() -> { - try { - boolean clawTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST); - if (clawTrayExist) { - throw new AppException(ResultCode.TRANSFER_MODULE_YES_TRAY);//夹爪存在托盘 - } - boolean feedTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST); - if (feedTrayExist) { - throw new AppException(ResultCode.FEED_AREA_EXIST_TRAY);//上料区存在托盘 - } - Point3D heatArea1TrayClawPoint = devicePositionService.getPosition(DevicePositionCode.heatArea1TrayClawPoint).getPoint3D();//加热位1坐标 - Double liquidAreaPreFillPoint = devicePositionService.getPosition(DevicePositionCode.liquidAreaPreFillPoint).getPositon(); //预充时加液臂下降位置 - Double preFillDistance = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.pre_fill_distance_when_open_service);//预充距离 - transferModuleService.transferXMove(heatArea1TrayClawPoint.getX());//转运模块移动至加热位1 - clawTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST); - if (clawTrayExist) { - throw new AppException(ResultCode.TRANSFER_MODULE_YES_TRAY);//夹爪存在托盘 - } - feedTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST); - if (feedTrayExist) { - throw new AppException(ResultCode.FEED_AREA_EXIST_TRAY);//上料区存在托盘 - } - solutionModuleService.solutionMotorMove(liquidAreaPreFillPoint);//加液机械臂下降至至预充点位 - solutionModuleService.liquidValveSwitch(SolutionCode.waste);//电磁阀对应通道打开 - solutionModuleService.liquidPumpMove(-preFillDistance);//排空 - solutionModuleService.liquidValveSwitch(SolutionCode.thin);//电磁阀对应通道打开 - solutionModuleService.liquidPumpMove(preFillDistance);//预充 - solutionModuleService.liquidValveSwitch(SolutionCode.thick);//电磁阀对应通道打开 - solutionModuleService.liquidPumpMove(preFillDistance);//预充 - solutionModuleService.liquidValveSwitch(SolutionCode.water);//电磁阀对应通道打开 - solutionModuleService.liquidPumpMove(preFillDistance);//预充 - solutionModuleService.solutionMotorMoveZero();//回原点 - } finally { - deviceStateService.getCommandMutexState().get().setMoveTest(false); - } - }); - } -} - diff --git a/src/main/java/com/iflytop/sgs/app/cmd/selftest/LiquidPreFillWhenLaunchCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/selftest/LiquidPreFillWhenLaunchCommand.java new file mode 100644 index 0000000..a8b91e2 --- /dev/null +++ b/src/main/java/com/iflytop/sgs/app/cmd/selftest/LiquidPreFillWhenLaunchCommand.java @@ -0,0 +1,88 @@ +package com.iflytop.sgs.app.cmd.selftest; + +import com.iflytop.sgs.app.core.BaseCommandHandler; +import com.iflytop.sgs.app.model.bo.Point3D; +import com.iflytop.sgs.app.model.dto.CmdDTO; +import com.iflytop.sgs.app.service.api.DevicePositionService; +import com.iflytop.sgs.app.service.api.SystemConfigService; +import com.iflytop.sgs.app.service.device.DeviceSensorService; +import com.iflytop.sgs.app.service.device.DeviceStateService; +import com.iflytop.sgs.app.service.device.module.SolutionModuleService; +import com.iflytop.sgs.app.service.device.module.TransferModuleService; +import com.iflytop.sgs.app.ws.server.WebSocketSender; +import com.iflytop.sgs.common.annotation.CommandMapping; +import com.iflytop.sgs.common.constant.WebSocketMessageType; +import com.iflytop.sgs.common.enums.DeviceSensorCode; +import com.iflytop.sgs.common.enums.SolutionCode; +import com.iflytop.sgs.common.enums.SystemConfigCode; +import com.iflytop.sgs.common.enums.data.DevicePositionCode; +import com.iflytop.sgs.common.exception.AppException; +import com.iflytop.sgs.common.result.ResultCode; +import com.iflytop.sgs.hardware.exception.HardwareException; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 自检后 开机预充 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("liquid_pre_fill_when_launch")//业务指令注解 +public class LiquidPreFillWhenLaunchCommand extends BaseCommandHandler { + private final SolutionModuleService solutionModuleService; + private final TransferModuleService transferModuleService; + private final DevicePositionService devicePositionService; + private final DeviceStateService deviceStateService; + private final SystemConfigService systemConfigService; + private final DeviceSensorService deviceSensorService; + private final WebSocketSender webSocketService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) throws HardwareException { + if (deviceStateService.getCommandMutexState().get().isSolutionAddCommandExecuting()) { + throw new AppException(ResultCode.COMMAND_ALREADY_EXECUTING); + } + boolean feedTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST); + if (feedTrayExist) { + throw new AppException(ResultCode.FEED_AREA_EXIST_TRAY);//上料区存在托盘 + } + Point3D heatArea1TrayClawPoint = devicePositionService.getPosition(DevicePositionCode.heatArea1TrayClawPoint).getPoint3D();//加热位1坐标 + Double liquidAreaPreFillPoint = devicePositionService.getPosition(DevicePositionCode.liquidAreaPreFillPoint).getPositon(); //预充时加液臂下降位置 + Double preFillDistance = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.pre_fill_distance_when_open_service);//预充距离 + Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液时托盘位置点 + return runAsync(() -> { + try { + deviceStateService.getCommandMutexState().get().setSolutionAddCommandExecuting(true); + transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//移动至加液时托盘位置点 + boolean clawTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST); + if (clawTrayExist) { + webSocketService.push(WebSocketMessageType.WARN, "机械臂存在托盘!"); + } else { + transferModuleService.transferXMove(heatArea1TrayClawPoint.getX());//转运模块移动至加热位1 + boolean feedTrayExistAgain = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST); + if (!feedTrayExistAgain) { + solutionModuleService.solutionMotorMove(liquidAreaPreFillPoint);//加液机械臂下降至至预充点位 + solutionModuleService.liquidValveSwitch(SolutionCode.waste);//电磁阀对应通道打开 + solutionModuleService.liquidPumpMove(-preFillDistance);//排空 + solutionModuleService.liquidValveSwitch(SolutionCode.thin);//电磁阀对应通道打开 + solutionModuleService.liquidPumpMove(preFillDistance);//预充 + solutionModuleService.liquidValveSwitch(SolutionCode.thick);//电磁阀对应通道打开 + solutionModuleService.liquidPumpMove(preFillDistance);//预充 + solutionModuleService.liquidValveSwitch(SolutionCode.water);//电磁阀对应通道打开 + solutionModuleService.liquidPumpMove(preFillDistance);//预充 + solutionModuleService.solutionMotorMoveZero();//回原点 + } else { + webSocketService.push(WebSocketMessageType.WARN, "请把上料位托盘移出!"); + } + } + } finally { + deviceStateService.getCommandMutexState().get().setSolutionAddCommandExecuting(false); + } + }); + } +} + diff --git a/src/main/java/com/iflytop/sgs/app/cmd/selftest/MoveTestCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/selftest/MoveTestCommand.java index 8b5aa2f..aed7fdc 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/selftest/MoveTestCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/selftest/MoveTestCommand.java @@ -49,18 +49,13 @@ public class MoveTestCommand extends BaseCommandHandler { Point3D annealHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(annealHeatModuleCode);//获取退火加热模块托盘夹取点 Double solutionModuleMotorDownInTubeExtPositon = devicePositionService.getPosition(DevicePositionCode.solutionModuleMotorDownInTubeExtPositon).getPositon();//加液模块电机下降进入试管抽取位置 Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液时托盘位置点 - Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹爪位置点 + Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹取位置点 deviceStateService.getCommandMutexState().get().setMoveTest(true); return runAsync(() -> { try { - boolean clawTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST); - if (clawTrayExist) { - webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(cmdDTO.getCommandId(), cmdDTO.getCommand(), "机械臂夹爪存在试管架,请取出!", 0, "error")); - throw new AppException(ResultCode.TRANSFER_MODULE_YES_TRAY);//夹爪存在托盘 - } boolean feedTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST); if (feedTrayExist) { - webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(cmdDTO.getCommandId(), cmdDTO.getCommand(), "上料区存在试管架,请取出!", 0, "error")); + webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(cmdDTO.getCommandId(), cmdDTO.getCommand(), "上料区存在托盘,请取出!", 0, "error")); throw new AppException(ResultCode.FEED_AREA_EXIST_TRAY);//上料区存在托盘 } deviceSensorService.collectSensorState();//收集传感器转态 @@ -68,32 +63,18 @@ public class MoveTestCommand extends BaseCommandHandler { solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液机械臂抬升至最高 transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//转移至加液区托盘点位 - transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), annealHeatModuleTrayClawPoint3D.getX());//将X轴移动至托盘夹取点 - clawTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST); + boolean clawTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST); if (clawTrayExist) { - webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(cmdDTO.getCommandId(), cmdDTO.getCommand(), "机械臂夹爪存在试管架,请取出!", 0, "error")); - throw new AppException(ResultCode.TRANSFER_MODULE_YES_TRAY);//夹爪存在托盘 - } - feedTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST); - if (feedTrayExist) { - webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(cmdDTO.getCommandId(), cmdDTO.getCommand(), "上料区存在试管架,请取出!", 0, "error")); - throw new AppException(ResultCode.FEED_AREA_EXIST_TRAY);//上料区存在托盘 + webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(cmdDTO.getCommandId(), cmdDTO.getCommand(), "机械臂存在托盘,请取出!", 0, "error")); + throw new AppException(ResultCode.TRANSFER_MODULE_YES_TRAY);//机械臂存在托盘 } + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), annealHeatModuleTrayClawPoint3D.getX());//将X轴移动至托盘夹取点 solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeExtPositon);//加液模块下降进入试管抽取位置 solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液机械臂抬升至最高 webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(cmdDTO.getCommandId(), cmdDTO.getCommand(), "2、加液模块升降电机检测完毕", 50, "success")); transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX());//将X轴移动至加液时托盘位置点 transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getX());//将X轴移动至上料区位置点 webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(cmdDTO.getCommandId(), cmdDTO.getCommand(), "3、x轴电机检测完毕", 75, "success")); - if (clawTrayExist) { - webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(cmdDTO.getCommandId(), cmdDTO.getCommand(), "机械臂夹爪存在试管架,请取出!", 0, "error")); - throw new AppException(ResultCode.TRANSFER_MODULE_YES_TRAY);//夹爪存在托盘 - } - feedTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST); - if (feedTrayExist) { - webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(cmdDTO.getCommandId(), cmdDTO.getCommand(), "上料区存在试管架,请取出!", 0, "error")); - throw new AppException(ResultCode.FEED_AREA_EXIST_TRAY);//上料区存在托盘 - } transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getZ());//Z轴下降至夹取点,使托盘落入上料区 transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(cmdDTO.getCommandId(), cmdDTO.getCommand(), "4、z轴电机检测完毕", 100, "success")); @@ -101,7 +82,7 @@ public class MoveTestCommand extends BaseCommandHandler { Arrays.stream(heatModuleCodes).toList().forEach(heatModuleCode -> {//关闭所有的加热和风扇 try { heatModuleService.fanClose(heatModuleCode);//关闭风扇 - heatModuleService.heatRodClose(heatModuleCode);//打开加热棒 + heatModuleService.heatRodClose(heatModuleCode);//关闭加热棒 } catch (Exception e) { log.error("自检关闭风扇和加热棒{},{}", heatModuleCode, e.getMessage()); } diff --git a/src/main/java/com/iflytop/sgs/app/cmd/selftest/TrayOutCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/selftest/TrayOutCommand.java index c96fb9e..a3105f9 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/selftest/TrayOutCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/selftest/TrayOutCommand.java @@ -51,7 +51,7 @@ public class TrayOutCommand extends BaseCommandHandler { HeatModuleCode targetHeatModuleCode = HeatModuleCode.valueOf(targetHeatModuleCodeStr); Point3D targetHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(targetHeatModuleCode);//获取目标加热模块托盘夹取点 Double transferModuleXPickTrayMoveDistance = devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance();//获取转运模块X轴拿取托盘进出卡槽移动距离 - Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹爪位置点 + Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹取位置点 return runAsync(() -> { try{ deviceStateService.getCommandMutexState().get().setTrayOut(true); 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 eaf7799..dd5b32b 100644 --- a/src/main/java/com/iflytop/sgs/app/controller/HeatController.java +++ b/src/main/java/com/iflytop/sgs/app/controller/HeatController.java @@ -3,6 +3,8 @@ package com.iflytop.sgs.app.controller; import com.iflytop.sgs.app.model.vo.SetHeatModuleEnableVO; import com.iflytop.sgs.app.model.vo.SetTargetTemperatureVO; import com.iflytop.sgs.app.service.api.HeatService; +import com.iflytop.sgs.app.service.api.SystemConfigService; +import com.iflytop.sgs.common.enums.SystemConfigCode; import com.iflytop.sgs.common.result.Result; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -24,10 +26,23 @@ import org.springframework.web.bind.annotation.RestController; @Slf4j public class HeatController { private final HeatService heatModuleService; + private final SystemConfigService systemConfigService; @Operation(summary = "加热模块设定目标温度") @PostMapping("/target-temperature") public Result setTargetTemperature(@Valid @RequestBody SetTargetTemperatureVO setTargetTemperatureVO) { + Double annealTemperature = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.anneal_temperature);//抽液时针下降高度 + Double dryTemperature = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.dry_temperature);//抽液时针下降高度 + Double heatTemperature = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.heat_temperature);//抽液时针下降高度 + if(setTargetTemperatureVO.getHeatTemperature()>heatTemperature){ + return Result.failed("加热温度超过设定值!"); + } + if(setTargetTemperatureVO.getDryTemperature()>dryTemperature){ + return Result.failed("烘干温度超过设定值!"); + } + if(setTargetTemperatureVO.getAnnealTemperature()>annealTemperature){ + return Result.failed("退火温度超过设定值"); + } heatModuleService.setTargetTemperature(setTargetTemperatureVO); return Result.success(); } diff --git a/src/main/java/com/iflytop/sgs/app/model/bo/status/CommandMutexState.java b/src/main/java/com/iflytop/sgs/app/model/bo/status/CommandMutexState.java index 65ffe76..e7612e8 100644 --- a/src/main/java/com/iflytop/sgs/app/model/bo/status/CommandMutexState.java +++ b/src/main/java/com/iflytop/sgs/app/model/bo/status/CommandMutexState.java @@ -7,22 +7,19 @@ import lombok.Data; */ @Data public class CommandMutexState { + //关门 private boolean doorCloseCommandExecuting = false; + //开门 private boolean doorOpenCommandExecuting = false; + //门回原点 private boolean doorOriginCommandExecuting = false; - private boolean fanStartCommandExecuting = false; - private boolean fanStopCommandExecuting = false; - private boolean filledSolutionStartCommandExecuting = false; - private boolean filledSolutionStopCommandExecuting = false; - private boolean gantryXOriginCommandExecuting = false; - private boolean gantryZOriginCommandExecuting = false; - private boolean liquidMotorOriginOriginCommandExecuting = false; - private boolean heatStartCommandExecuting = false; - private boolean heatStopCommandExecuting = false; - private boolean moveToHeatAreaCommandExecuting = false; - private boolean moveToSolutionAreaCommandExecuting = false; + //加液 private boolean solutionAddCommandExecuting = false; - private boolean moveTest = false; + //加液臂回原点 + private boolean liquidMotorOriginOriginCommandExecuting=false; + //自检 + private boolean moveTest=false; + //取出托盘 private boolean trayOut = false; @@ -32,19 +29,10 @@ public class CommandMutexState { this.doorCloseCommandExecuting = false; this.doorOpenCommandExecuting = false; this.doorOriginCommandExecuting = false; - this.fanStartCommandExecuting = false; - this.fanStopCommandExecuting = false; - this.filledSolutionStartCommandExecuting = false; - this.filledSolutionStopCommandExecuting = false; - this.gantryXOriginCommandExecuting = false; - this.gantryZOriginCommandExecuting = false; - this.heatStartCommandExecuting = false; - this.heatStopCommandExecuting = false; - this.moveToHeatAreaCommandExecuting = false; - this.moveToSolutionAreaCommandExecuting = false; this.solutionAddCommandExecuting = false; - this.moveTest = false; - this.trayOut = false; - this.liquidMotorOriginOriginCommandExecuting = false; + this.liquidMotorOriginOriginCommandExecuting=false; + this.moveTest=false; + this.trayOut=false; + this.transferCommandExecuting=false; } } diff --git a/src/main/java/com/iflytop/sgs/app/model/bo/status/device/DoorModuleState.java b/src/main/java/com/iflytop/sgs/app/model/bo/status/device/DoorModuleState.java index 10b6caa..5f71cae 100644 --- a/src/main/java/com/iflytop/sgs/app/model/bo/status/device/DoorModuleState.java +++ b/src/main/java/com/iflytop/sgs/app/model/bo/status/device/DoorModuleState.java @@ -14,4 +14,9 @@ import org.springframework.stereotype.Component; public class DoorModuleState { @Schema(description = "是否开门,true为开启状态,false为关闭状态") private boolean open = false; + + + @Schema(description = "是否可操作,true为可操作,false为禁止操作") + private boolean actionable = true; + } diff --git a/src/main/java/com/iflytop/sgs/app/model/vo/SetTargetTemperatureVO.java b/src/main/java/com/iflytop/sgs/app/model/vo/SetTargetTemperatureVO.java index 4f9e44f..832cf86 100644 --- a/src/main/java/com/iflytop/sgs/app/model/vo/SetTargetTemperatureVO.java +++ b/src/main/java/com/iflytop/sgs/app/model/vo/SetTargetTemperatureVO.java @@ -13,20 +13,17 @@ public class SetTargetTemperatureVO { @Schema(description = "加热模块code") private HeatModuleCode moduleCode; - @Max(value = 120, message = "加热温度不能超过120度") - @Min(value = 50, message = "加热温度不能低于50度") + @Min(value = 50, message = "温度不能低于50度") @Schema(description = "加热温度") private Double heatTemperature; - @Max(value = 135, message = "烘干温度不能超过135度") - @Min(value = 50, message = "烘干温度不能低于50度") + @Min(value = 50, message = "温度不能低于50度") @Schema(description = "烘干温度") private Double dryTemperature; - @Max(value = 400, message = "退火温度不能超过400度") - @Min(value = 200, message = "退火温度不能低于200度") + @Min(value = 50, message = "温度不能低于50度") @Schema(description = "退火温度") private Double annealTemperature; } diff --git a/src/main/java/com/iflytop/sgs/app/service/api/HeatService.java b/src/main/java/com/iflytop/sgs/app/service/api/HeatService.java index 9a76994..d583d1a 100644 --- a/src/main/java/com/iflytop/sgs/app/service/api/HeatService.java +++ b/src/main/java/com/iflytop/sgs/app/service/api/HeatService.java @@ -4,6 +4,8 @@ import com.iflytop.sgs.app.model.bo.status.device.HeatModuleState; import com.iflytop.sgs.app.model.vo.SetHeatModuleEnableVO; import com.iflytop.sgs.app.model.vo.SetTargetTemperatureVO; import com.iflytop.sgs.app.service.device.DeviceStateService; +import com.iflytop.sgs.app.service.device.module.HeatModuleService; +import com.iflytop.sgs.common.enums.SystemConfigCode; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; diff --git a/src/main/java/com/iflytop/sgs/app/service/crafts/CraftsStepService.java b/src/main/java/com/iflytop/sgs/app/service/crafts/CraftsStepService.java index 29ca8ef..6674534 100644 --- a/src/main/java/com/iflytop/sgs/app/service/crafts/CraftsStepService.java +++ b/src/main/java/com/iflytop/sgs/app/service/crafts/CraftsStepService.java @@ -16,6 +16,7 @@ import com.iflytop.sgs.app.service.api.*; import com.iflytop.sgs.app.service.device.DeviceLightSoundService; import com.iflytop.sgs.app.service.device.DeviceSensorService; import com.iflytop.sgs.app.service.device.DeviceStateService; +import com.iflytop.sgs.app.service.device.module.DoorModuleService; import com.iflytop.sgs.app.service.device.module.HeatModuleService; import com.iflytop.sgs.app.service.device.module.SolutionModuleService; import com.iflytop.sgs.app.service.device.module.TransferModuleService; @@ -26,11 +27,9 @@ import com.iflytop.sgs.common.enums.cmd.CmdBeepMode; import com.iflytop.sgs.common.enums.data.DevicePositionCode; import com.iflytop.sgs.common.exception.AppException; import com.iflytop.sgs.common.result.ResultCode; +import com.iflytop.sgs.hardware.exception.HardwareException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; import org.springframework.stereotype.Service; import java.time.LocalDateTime; @@ -38,7 +37,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; /** * 工艺步骤执行服务 @@ -46,8 +45,7 @@ import java.util.concurrent.Future; @Slf4j @Service @RequiredArgsConstructor -public class CraftsStepService implements ApplicationContextAware { - private ApplicationContext applicationContext; +public class CraftsStepService { private final ContainerService containerService; private final WebSocketSender webSocketService; private final HeatModuleService heatModuleService; @@ -60,22 +58,7 @@ public class CraftsStepService implements ApplicationContextAware { private final SystemConfigService systemConfigService; private final DeviceLightSoundService deviceLightSoundService; private final CraftMonitorService craftMonitorService; - - @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - this.applicationContext = applicationContext; - } - - public synchronized void stopAllCrafts() { - CraftsService craftsService = applicationContext.getBean(CraftsService.class); - craftsService.getContextMap().forEach((key, ctx) -> { - Future future = craftsService.getFutureMap().remove(key); - if (ctx != null && future != null) { - ctx.stop(); - future.cancel(true); - } - }); - } + private DoorModuleService doorModuleService; /** * 执行单个工艺步骤 @@ -117,10 +100,32 @@ public class CraftsStepService implements ApplicationContextAware { } /* + * 执行加稀硝酸 浓硝酸 清洗前关门 前端开门按钮设置为不可操作 + * */ + public void doorClose() throws HardwareException, InterruptedException { + doorModuleService.doorClose(); + deviceLightSoundService.openBeep(CmdBeepMode.info); + TimeUnit.SECONDS.sleep(1); + deviceLightSoundService.closeBeep(); + deviceStateService.getDeviceState().getDoorModule().setOpen(false); + deviceStateService.getDeviceState().getDoorModule().setActionable(false); + } + + /* + * 执行加稀硝酸 浓硝酸 清洗后关门 前端开门按钮设置为可操作 + * */ + public void doorAble() { + deviceStateService.getDeviceState().getDoorModule().setActionable(true); + } + + /* * 加稀硝酸 * */ public boolean addThin(HeatModuleCode heatModuleCode, JSONObject params, CraftMonitor craftMonitor) throws Exception { try { + + /*关门*/ + doorClose(); log.info("工艺{},-------------------------------------加稀硝酸-------------------------------------", heatModuleCode); /*工艺监控*/ log.info("工艺{},工艺监控", heatModuleCode); @@ -133,7 +138,7 @@ public class CraftsStepService implements ApplicationContextAware { log.info("工艺{},获取配置信息", heatModuleCode); deviceStateService.getDeviceState().getSolutionModule().setPumping(true); Double transferModuleXPickTrayMoveDistance = devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance();//获取转运模块X轴拿取托盘进出卡槽移动距离 - Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹爪位置点 + Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹取位置点 Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液时托盘位置点 Point3D heatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(heatModuleCode);//获取目标加热模块托盘夹取点 Double drainDistance = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.drain_distance);//排空距离 @@ -150,6 +155,7 @@ public class CraftsStepService implements ApplicationContextAware { Point3D heatArea1TrayClawPoint = devicePositionService.getPosition(DevicePositionCode.heatArea1TrayClawPoint).getPoint3D();//加热位1坐标 Double liquidAreaPreFillPoint = devicePositionService.getPosition(DevicePositionCode.liquidAreaPreFillPoint).getPositon(); //预充时加液臂下降位置 Double backFlowDistance = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.back_flow_distance);//防低落距离 + double pumpNormalSpeed = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.pump_normal_speed);//蠕动泵正常转速 /*获取参数结束*/ log.info("工艺{},申请转运模组并等待", heatModuleCode); @@ -196,6 +202,7 @@ public class CraftsStepService implements ApplicationContextAware { solutionModuleService.solutionMotorMove(liquidAreaPreFillPoint);//加液机械臂下降至至预充点位 log.info("工艺{},电磁阀对应通道打开", heatModuleCode); solutionModuleService.liquidValveSwitch(SolutionCode.waste);//电磁阀对应通道打开 + solutionModuleService.liquidPumpSetSpeed(pumpNormalSpeed);//设置泵的正常转速 log.info("工艺{},排空", heatModuleCode); solutionModuleService.liquidPumpMove(-drainDistance);//排空 log.info("工艺{},电磁阀对应通道打开", heatModuleCode); @@ -266,6 +273,7 @@ public class CraftsStepService implements ApplicationContextAware { deviceStateService.getDeviceState().getTrayByHeatModuleCode(heatModuleCode).setInSolutionPositon(false);//托盘状态 deviceStateService.getDeviceState().getSolutionModule().setPumping(false); deviceStateService.getDeviceState().getTrayByHeatModuleCode(heatModuleCode).setUseArm(false);//使用机械臂标志 + doorAble();//可开门 transferModuleService.releaseTransferModule();//释放转运模组 return true; } catch (Exception e) { @@ -282,7 +290,10 @@ public class CraftsStepService implements ApplicationContextAware { * */ public boolean addThick(HeatModuleCode heatModuleCode, JSONObject params, CraftMonitor craftMonitor) throws Exception { try { + log.info("工艺{},------------------------------加浓硝酸---------------------------", heatModuleCode); + /*关门*/ + doorClose(); /*工艺监控*/ log.info("工艺{},工艺监控", heatModuleCode); List finishColumns = new ArrayList<>(); @@ -303,7 +314,8 @@ public class CraftsStepService implements ApplicationContextAware { Double volume = params.getDouble("volume");//量 JSONArray jsonArray = params.getJSONArray("columns");//列数 Double height = params.getDouble("height");//下降进入试管的高度 - if (height > 55) {//到达试管底部的最大距离 + Double needleDropHeight = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.needle_drop_height);//抽液时针下降高度 + if (height > needleDropHeight) {//到达试管底部的最大距离 throw new AppException(ResultCode.CRAFT_PARAMS_MISTAKE); } Integer channel = container.getChannel();//获取阀门通道 @@ -312,17 +324,19 @@ public class CraftsStepService implements ApplicationContextAware { Double solutionModuleMotorDownInTubeAddPositon = devicePositionService.getPosition(DevicePositionCode.solutionModuleMotorDownInTubeAddPositon).getPositon(); //加液模块电机下降进入试管加液位置 Double solutionModuleMotorDownInTubeExtPositon = devicePositionService.getPosition(DevicePositionCode.solutionModuleMotorDownInTubeExtPositon).getPositon(); //加液模块电机下降进入试管加液位置 double addLiquidDistance = volume * scale; - Double reduceDistance = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.reduce_distance);//抽液距离 + Double reduceDistance = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.thin_reduce_distance);//抽液距离 Point3D heatArea1TrayClawPoint = devicePositionService.getPosition(DevicePositionCode.heatArea1TrayClawPoint).getPoint3D(); Double liquidAreaPreFillPoint = devicePositionService.getPosition(DevicePositionCode.liquidAreaPreFillPoint).getPositon(); //预充时加液臂下降位置 Double backFlowDistance = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.back_flow_distance);//防低落距离 + Double pumpNormalSpeed = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.pump_normal_speed);//蠕动泵正常转速 + Double pumpReduceSpeed = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.pump_reduce_speed);//蠕动泵抽取转速 /*获取参数结束*/ while (deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST)) {//上料区存在托盘 deviceLightSoundService.openBeep(CmdBeepMode.alarm); - delay(2); + TimeUnit.SECONDS.sleep(2); deviceLightSoundService.closeBeep(); webSocketService.push(WebSocketMessageType.ALARM, "请取出上料区托盘!"); - delay(10); + TimeUnit.SECONDS.sleep(10); } @@ -332,7 +346,7 @@ public class CraftsStepService implements ApplicationContextAware { /*移动至加液区*/ - boolean heatTrayExist = deviceSensorService.getTrayStateByHeatModuleCode(heatModuleCode);//获取加热区试管架 + boolean heatTrayExist = deviceSensorService.getTrayStateByHeatModuleCode(heatModuleCode);//获取加热区托盘 Assert.isTrue(heatTrayExist, () -> new AppException(ResultCode.CRAFT_HEAT_NO_TRAY));//目标加热区无托盘 log.info("工艺{},加热区存在托盘", heatModuleCode); log.info("工艺{},机械臂移动至加热区", heatModuleCode); @@ -340,7 +354,7 @@ public class CraftsStepService implements ApplicationContextAware { log.info("工艺{},将X轴移动至目标加热模块托盘夹取点 + 进出卡槽移动距离", heatModuleCode); transferModuleService.transferXMove(heatModuleTrayClawPoint3D.getX() + transferModuleXPickTrayMoveDistance);//将X轴移动至目标加热模块托盘夹取点 + 进出卡槽移动距离 log.info("工艺{},Z轴下降至夹取点", heatModuleCode); - heatTrayExist = deviceSensorService.getTrayStateByHeatModuleCode(heatModuleCode);//获取加热区试管架 + heatTrayExist = deviceSensorService.getTrayStateByHeatModuleCode(heatModuleCode);//获取加热区托盘 Assert.isTrue(heatTrayExist, () -> new AppException(ResultCode.CRAFT_HEAT_NO_TRAY));//目标加热区无托盘 transferModuleService.transferZMove(heatModuleTrayClawPoint3D.getZ());//Z轴下降至夹取点 log.info("工艺{},X轴进入卡槽", heatModuleCode); @@ -361,6 +375,7 @@ public class CraftsStepService implements ApplicationContextAware { /*开始抽液*/ log.info("工艺{},开始抽液", heatModuleCode); solutionModuleService.liquidValveSwitch(SolutionCode.waste);//电磁阀转换到废液 + solutionModuleService.liquidPumpSetSpeed(pumpReduceSpeed);//设置泵的抽取转速 List reduceColumns = new ArrayList<>(); TubeState[] tubes = deviceStateService.getDeviceState().getTrayByHeatModuleCode(heatModuleCode).getTubes(); for (TubeState tube : tubes) { @@ -400,6 +415,7 @@ public class CraftsStepService implements ApplicationContextAware { solutionModuleService.solutionMotorMove(liquidAreaPreFillPoint);//加液机械臂下降至至预充点位 log.info("工艺{},电磁阀对应通道打开", heatModuleCode); solutionModuleService.liquidValveSwitch(SolutionCode.waste);//电磁阀对应通道打开 + solutionModuleService.liquidPumpSetSpeed(pumpNormalSpeed);//设置泵的正常转速 log.info("工艺{},排空", heatModuleCode); solutionModuleService.liquidPumpMove(-drainDistance);//排空 log.info("工艺{},电磁阀对应通道打开", heatModuleCode); @@ -471,6 +487,7 @@ public class CraftsStepService implements ApplicationContextAware { deviceStateService.getDeviceState().getTrayByHeatModuleCode(heatModuleCode).setInHeatModule(true);//托盘状态 deviceStateService.getDeviceState().getSolutionModule().setPumping(false);//正在加液 deviceStateService.getDeviceState().getTrayByHeatModuleCode(heatModuleCode).setInSolutionPositon(false);//托盘状态 + doorAble();//可开门 transferModuleService.releaseTransferModule();//释放转运模组 return true; } catch (Exception e) { @@ -503,7 +520,7 @@ public class CraftsStepService implements ApplicationContextAware { deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setFanOpen(false); //设置加热区风扇关闭 heatModuleService.heatRodOpen(heatModuleCode, temperature);//打开加热棒 while (!heatIsSuitable(heatModuleCode, temperature)) {//判断温度是否到达 - delay(1); + TimeUnit.SECONDS.sleep(1); } log.info("工艺{},温度达到", heatModuleCode); log.info("工艺{},恒温时间", time); @@ -518,7 +535,7 @@ public class CraftsStepService implements ApplicationContextAware { log.info("工艺{},恒温时间秒数:", seconds); while (cycle > 0) { log.info("工艺,恒温第{}分:", cycle); - delay(60); + TimeUnit.SECONDS.sleep(60); cycle--; clock = clock + 60; /*保存到工艺监控*/ @@ -527,7 +544,7 @@ public class CraftsStepService implements ApplicationContextAware { craftMonitorService.saveMonitor(craftMonitor); /*保存到工艺监控*/ } - delay(seconds); + TimeUnit.SECONDS.sleep(seconds); log.info("工艺,恒温结束:"); deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setStartHeatTime(null);//开始加热时间 deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTargetTime(null);//加热器目标加热时间 @@ -548,6 +565,8 @@ public class CraftsStepService implements ApplicationContextAware { public boolean clean(HeatModuleCode heatModuleCode, JSONObject params, CraftMonitor craftMonitor) throws Exception { try { log.info("工艺{},----------------------------------清洗---------------------------------------------", heatModuleCode); + /*关门*/ + doorClose(); /*保存到监控开始*/ craftMonitor.setDeviceState(JSONUtil.toJsonStr(deviceStateService.getDeviceState())); craftMonitor.setCurrentStepResult(CraftsMonitorResultCode.clean_cycle.getDescription() + ":0"); @@ -559,7 +578,8 @@ public class CraftsStepService implements ApplicationContextAware { Double volume = params.getDouble("volume");//加水量 Integer cycle = params.getInt("cycle");//次数 Double height = params.getDouble("height");//下降进入试管的高度 - if (height > 55) { + Double needleDropHeight = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.needle_drop_height);//抽液时针下降高度 + if (height > needleDropHeight) { throw new AppException(ResultCode.CRAFT_PARAMS_MISTAKE); } boolean heatModuleTrayExist = deviceSensorService.getTrayStateByHeatModuleCode(heatModuleCode);//目标加热模块有无托盘 @@ -572,13 +592,15 @@ public class CraftsStepService implements ApplicationContextAware { Double solutionModuleMotorDownInTubeAddPositon = devicePositionService.getPosition(DevicePositionCode.solutionModuleMotorDownInTubeAddPositon).getPositon();//加液模块电机下降进入试管加液位置 Double waterScale = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.water);//蒸馏水的系数 double cleanWaterDistance = volume * waterScale;//清洁时泵的移动距离 - Double reduceDistance = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.reduce_distance);//抽液距离 + Double reduceThickDistance = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.thick_reduce_distance);//抽液距离 + Double reduceWaterDistance = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.water_reduce_distance);//抽液距离 Double drainDistance = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.drain_distance);//排空距离 Double preFillDistance = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.pre_fill_distance);//过量预充距离 - Double preFillPosition = devicePositionService.getPosition(DevicePositionCode.solutionModuleMotorDownPreFillPositon).getPositon();//机械臂预充时下降距离 Point3D heatArea1TrayClawPoint = devicePositionService.getPosition(DevicePositionCode.heatArea1TrayClawPoint).getPoint3D(); Double liquidAreaPreFillPoint = devicePositionService.getPosition(DevicePositionCode.liquidAreaPreFillPoint).getPositon(); //预充时加液臂下降位置 Double backFlowDistance = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.back_flow_distance);//防低落距离 + Double pumpNormalSpeed = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.pump_normal_speed);//蠕动泵正常转速 + Double pumpReduceSpeed = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.pump_reduce_speed);//蠕动泵抽取转速 webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatModuleCode.toString(), "机械臂移动至加热区", heatModuleTrayClawPoint3D)); /*获取参数结束*/ @@ -618,6 +640,7 @@ public class CraftsStepService implements ApplicationContextAware { /*抽液开始*/ solutionModuleService.liquidValveSwitch(SolutionCode.waste);//电磁阀对应通道打开 + solutionModuleService.liquidPumpSetSpeed(pumpReduceSpeed);//设置泵的抽取转速 for (int j = 0; j < columns.size(); j++) { double distance = Math.abs(columns.get(j) - 5) * trayTubeHorizontalSpacingDistance;//x轴移动距离 webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatModuleCode.toString(), "机械臂移动到试管位置", j)); @@ -628,7 +651,7 @@ public class CraftsStepService implements ApplicationContextAware { log.info("工艺{},电磁阀对应通道打开", heatModuleCode); log.info("工艺{},蠕动泵抽水", heatModuleCode); - solutionModuleService.liquidPumpMove(-reduceDistance);//蠕动泵抽水 + solutionModuleService.liquidPumpMove(-reduceThickDistance);//蠕动泵抽浓硝酸 log.info("工艺{},加液模块上升至最高,移出试管", heatModuleCode); solutionModuleService.solutionMotorMoveZero();//加液模块上升至最高,移出试管 } @@ -650,6 +673,7 @@ public class CraftsStepService implements ApplicationContextAware { feedTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取传感器状态 Assert.isTrue(!feedTrayExist, () -> new AppException(ResultCode.FEED_AREA_EXIST_TRAY));//上料区有托盘 solutionModuleService.solutionMotorMove(liquidAreaPreFillPoint);//加液机械臂下降至至预充点位 + solutionModuleService.liquidPumpSetSpeed(pumpNormalSpeed);//设置泵的正常转速 solutionModuleService.liquidPumpMove(-drainDistance);//排空 solutionModuleService.liquidValveSwitch(SolutionCode.water);//电磁阀对应通道打开 solutionModuleService.liquidPumpMove(preFillDistance);//预充 @@ -675,10 +699,10 @@ public class CraftsStepService implements ApplicationContextAware { } solutionModuleService.liquidPumpMove(-backFlowDistance);//防滴落 log.info("工艺{},电磁阀废液通道打开", heatModuleCode); - Thread.sleep(1000); + TimeUnit.SECONDS.sleep(1);//当前线程休眠1秒 /*抽*/ solutionModuleService.liquidValveSwitch(SolutionCode.waste);//电磁阀对应通道打开 - //transferModuleService.transferMove(liquidAreaTrayPoint3D);//移动至加液时托盘位置点 + solutionModuleService.liquidPumpSetSpeed(pumpReduceSpeed);//设置泵的抽取转速 for (int j = 0; j < columns.size(); j++) { double distance = Math.abs(columns.get(j) - 5) * trayTubeHorizontalSpacingDistance;//x轴移动距离 webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatModuleCode.toString(), "机械臂移动到试管位置", j)); @@ -689,7 +713,7 @@ public class CraftsStepService implements ApplicationContextAware { log.info("工艺{},电磁阀对应通道打开", heatModuleCode); log.info("工艺{},蠕动泵抽水", heatModuleCode); - solutionModuleService.liquidPumpMove(-reduceDistance);//抽水 + solutionModuleService.liquidPumpMove(-reduceWaterDistance);//抽水 log.info("工艺{},加液模块上升至最高,移出试管", heatModuleCode); solutionModuleService.solutionMotorMoveZero();//加液模块上升至最高,移出试管 } @@ -714,6 +738,7 @@ public class CraftsStepService implements ApplicationContextAware { deviceStateService.getDeviceState().getTrayByHeatModuleCode(heatModuleCode).setInHeatModule(true);//托盘状态 deviceStateService.getDeviceState().getSolutionModule().setPumping(false);//正在加液 deviceStateService.getDeviceState().getTrayByHeatModuleCode(heatModuleCode).setInSolutionPositon(false);//托盘状态 + doorAble();//开门 log.info("工艺{},释放转运模组", heatModuleCode); transferModuleService.releaseTransferModule();//释放转运模组 return true; @@ -749,7 +774,7 @@ public class CraftsStepService implements ApplicationContextAware { heatModuleService.heatRodOpen(heatModuleCode, temperature); log.info("工艺{},判断当前温度是否在设置温度范围内", heatModuleCode); while (!heatIsSuitable(heatModuleCode, temperature)) { //判断当前温度是否在设置温度范围内 - delay(1); + TimeUnit.SECONDS.sleep(1); } deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.drying); //烘干中 deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setStartHeatTime(LocalDateTime.now());//开始加热时间 @@ -758,7 +783,7 @@ public class CraftsStepService implements ApplicationContextAware { int cycle = time / 60; int seconds = time % 60; while (cycle > 0) { - delay(60); + TimeUnit.SECONDS.sleep(60); cycle--; clock = clock + 60; craftMonitor.setDeviceState(JSONUtil.toJsonStr(deviceStateService.getDeviceState())); @@ -766,7 +791,7 @@ public class CraftsStepService implements ApplicationContextAware { craftMonitorService.saveMonitor(craftMonitor); } log.info("工艺{},恒温中", heatModuleCode); - delay(seconds); + TimeUnit.SECONDS.sleep(seconds); log.info("工艺{},关闭加热棒", heatModuleCode); webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatModuleCode.toString(), "关闭加热棒", "")); heatModuleService.heatRodClose(heatModuleCode);//关闭加热棒 @@ -774,7 +799,7 @@ public class CraftsStepService implements ApplicationContextAware { try { heatModuleService.fanStart(heatModuleCode);//散热打开 deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setFanOpen(true); //设置加热区风扇打开 - delay(keepTime); + TimeUnit.SECONDS.sleep(keepTime); heatModuleService.fanClose(heatModuleCode);//散热打开 deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setFanOpen(false); //设置加热区风扇打开 } catch (Exception e) { @@ -808,7 +833,7 @@ public class CraftsStepService implements ApplicationContextAware { boolean heatModuleTrayExist = deviceSensorService.getTrayStateByHeatModuleCode(heatModuleCode); Assert.isTrue(heatModuleTrayExist, () -> new AppException(ResultCode.CRAFT_TARGET_HEAT_NO_TRAY));//提示加热模块无托盘 while (deviceSensorService.getTrayStateByHeatModuleCode(HeatModuleCode.heat_module_04)) {//判断退火区是否被占用 - delay(1);//等待1秒 + TimeUnit.SECONDS.sleep(1);//等待1秒 } log.info("工艺{},机械臂移动至加热区", heatModuleCode); webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatModuleCode.toString(), "机械臂移动至加热区", heatModuleCode)); @@ -852,7 +877,7 @@ public class CraftsStepService implements ApplicationContextAware { heatModuleService.heatRodOpen(HeatModuleCode.heat_module_04, temperature);//打开加热棒 //判断当前温度是否在设置温度范围内 while (!heatIsSuitable(HeatModuleCode.heat_module_04, temperature)) { - delay(1); + TimeUnit.SECONDS.sleep(1); } deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_04).setHeatingType(HeatingType.annealing); //设置加热区状态退火中 deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_04).setStartHeatTime(LocalDateTime.now());//开始加热时间 @@ -861,7 +886,7 @@ public class CraftsStepService implements ApplicationContextAware { int cycle = time / 60; int seconds = time % 60; while (cycle > 0) { - delay(60); + TimeUnit.SECONDS.sleep(60); cycle--; clock = clock + 60; craftMonitor.setDeviceState(JSONUtil.toJsonStr(deviceStateService.getDeviceState())); @@ -869,7 +894,7 @@ public class CraftsStepService implements ApplicationContextAware { craftMonitorService.saveMonitor(craftMonitor); } log.info("工艺{},恒温中", HeatModuleCode.heat_module_04); - delay(seconds); + TimeUnit.SECONDS.sleep(seconds); deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_04).setStartHeatTime(null);//开始加热时间 deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_04).setTargetTime(null);//加热器目标加热时间 @@ -935,25 +960,12 @@ public class CraftsStepService implements ApplicationContextAware { return currentTemperature < (temperature + 3); } - - /** - * 延时等待 - */ - private boolean delay(int seconds) { - try { - Thread.sleep(seconds * 1000L); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - return true; - } - /** * 工艺执行完毕 */ public void finish(HeatModuleCode heatModuleCode, CraftMonitor craftMonitor) throws Exception { deviceLightSoundService.openBeep(CmdBeepMode.info); - delay(2); + TimeUnit.SECONDS.sleep(2);//当前线程休眠2秒 deviceLightSoundService.closeBeep(); craftMonitorService.remove(new LambdaQueryWrapper().eq(CraftMonitor::getHeatId, heatModuleCode)); } diff --git a/src/main/java/com/iflytop/sgs/app/service/device/DeviceInitService.java b/src/main/java/com/iflytop/sgs/app/service/device/DeviceInitService.java index 224b9e2..d50dcf6 100644 --- a/src/main/java/com/iflytop/sgs/app/service/device/DeviceInitService.java +++ b/src/main/java/com/iflytop/sgs/app/service/device/DeviceInitService.java @@ -45,6 +45,7 @@ public class DeviceInitService { @PostConstruct public void init() throws InterruptedException { + initDeviceState(); eventBus.regListener(this::onAppEvent); } @@ -59,7 +60,6 @@ public class DeviceInitService { log.error("设备初始化灯光失败,CmdColor.blue"); } }); - initDeviceState(); initDeviceSetData(); canBusService.initOvertime(); initEnable(); diff --git a/src/main/java/com/iflytop/sgs/app/service/device/module/DoorModuleService.java b/src/main/java/com/iflytop/sgs/app/service/device/module/DoorModuleService.java index 0091ac9..ee1f4b7 100644 --- a/src/main/java/com/iflytop/sgs/app/service/device/module/DoorModuleService.java +++ b/src/main/java/com/iflytop/sgs/app/service/device/module/DoorModuleService.java @@ -19,35 +19,27 @@ public class DoorModuleService { private final DeviceCommandService deviceCommandService; /** - * 门电机回原点 + * 门电机回原点 关门 */ - public void doorOrigin(String cmdId, String cmdCode) throws Exception { + public void doorOrigin(String cmdId, String cmdCode) { DeviceCommandBundle deviceCommand = DeviceCommandGenerator.doorOrigin(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); - CommandUtil.wait(deviceCommandFuture); - } - /** - * 门电机回原点 - */ - public void doorClose(String cmdId, String cmdCode) throws Exception { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.doorClose(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); - CommandUtil.wait(deviceCommandFuture); - } + deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); + } - /** - * 门电机移动 - */ - public void doorMove(String cmdId, String cmdCode, double position) throws Exception { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.doorMove(position); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); - CommandUtil.wait(deviceCommandFuture); + public void doorClose() { + doorOrigin(null, null); } - public void doorMoveToEnd(String cmdId, String cmdCode) throws Exception { + /* + * 开门 + * */ + public void doorMoveToEnd(String cmdId, String cmdCode) { DeviceCommandBundle deviceCommand = DeviceCommandGenerator.doorMoveToEnd(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); - CommandUtil.wait(deviceCommandFuture); + deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); + } + + public void doorOpen() { + doorMoveToEnd(null, null); } } diff --git a/src/main/java/com/iflytop/sgs/app/service/device/module/HeatModuleService.java b/src/main/java/com/iflytop/sgs/app/service/device/module/HeatModuleService.java index 17d02e9..8c48dea 100644 --- a/src/main/java/com/iflytop/sgs/app/service/device/module/HeatModuleService.java +++ b/src/main/java/com/iflytop/sgs/app/service/device/module/HeatModuleService.java @@ -71,7 +71,7 @@ public class HeatModuleService { } /** - * 获取指定加热区托盘夹爪点位 + * 获取指定加热区托盘夹取点位 */ public Point3D getHeatModuleTrayClawPoint3D(HeatModuleCode heatModuleId) { if (heatModuleId == null) { diff --git a/src/main/java/com/iflytop/sgs/app/service/device/module/SolutionModuleService.java b/src/main/java/com/iflytop/sgs/app/service/device/module/SolutionModuleService.java index d23bd02..abffb00 100644 --- a/src/main/java/com/iflytop/sgs/app/service/device/module/SolutionModuleService.java +++ b/src/main/java/com/iflytop/sgs/app/service/device/module/SolutionModuleService.java @@ -1,11 +1,16 @@ package com.iflytop.sgs.app.service.device.module; +import cn.hutool.core.lang.Assert; +import com.iflytop.sgs.app.service.api.SystemConfigService; import com.iflytop.sgs.app.service.device.DeviceCommandService; 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.enums.SolutionCode; +import com.iflytop.sgs.common.enums.SystemConfigCode; import com.iflytop.sgs.common.enums.cmd.CmdDirection; +import com.iflytop.sgs.common.exception.AppException; +import com.iflytop.sgs.common.result.ResultCode; import com.iflytop.sgs.common.utils.CommandUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -19,6 +24,7 @@ import org.springframework.stereotype.Service; @RequiredArgsConstructor public class SolutionModuleService { private final DeviceCommandService deviceCommandService; + private final SystemConfigService systemConfigService; /** * 加液机械臂移动到指定点 @@ -62,6 +68,24 @@ public class SolutionModuleService { } /** + * 加液泵设置转速 + */ + public void liquidPumpSetSpeed(String cmdId, String cmdCode, double speed) throws Exception { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpSet(speed); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); + CommandUtil.wait(deviceCommandFuture); + + } + + /** + * 加液泵设置转速 + */ + public void liquidPumpSetSpeed(double speed) throws Exception { + liquidPumpSetSpeed(null, null, speed); + + } + + /** * 加液泵加液 */ public void liquidPumpMove(String cmdId, String cmdCode, double position) throws Exception { @@ -129,6 +153,7 @@ public class SolutionModuleService { CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(null, null, deviceCommand); CommandUtil.wait(deviceCommandFuture); } + /** * 电磁阀转换通道 */ @@ -137,6 +162,7 @@ public class SolutionModuleService { CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(null, null, deviceCommand); CommandUtil.wait(deviceCommandFuture); } + /** * 电磁阀转换通道 */ diff --git a/src/main/java/com/iflytop/sgs/app/service/device/module/TransferModuleService.java b/src/main/java/com/iflytop/sgs/app/service/device/module/TransferModuleService.java index f9fbe81..a4d1d6c 100644 --- a/src/main/java/com/iflytop/sgs/app/service/device/module/TransferModuleService.java +++ b/src/main/java/com/iflytop/sgs/app/service/device/module/TransferModuleService.java @@ -49,7 +49,6 @@ public class TransferModuleService { boolean moduleIdle = deviceStateService.getDeviceState().getTransferModule().isIdle(); if (!moduleIdle) { return false; - //throw new RuntimeException("转运模块当前正忙,请稍后操作!"); } else { deviceStateService.getDeviceState().getTransferModule().setIdle(false); return true; @@ -85,12 +84,12 @@ public class TransferModuleService { Thread head = null; if (!feedQueue.isEmpty()) { head = feedQueue.peek(); + } else if (!thinQueue.isEmpty()) { + head = thinQueue.peek(); } else if (!heatQueue.isEmpty()) { head = heatQueue.peek(); } else if (!annealQueue.isEmpty()) { head = annealQueue.peek(); - } else if (!thinQueue.isEmpty()) { - head = thinQueue.peek(); } else if (!thickQueue.isEmpty()) { head = thickQueue.peek(); } diff --git a/src/main/java/com/iflytop/sgs/common/constant/WebSocketMessageType.java b/src/main/java/com/iflytop/sgs/common/constant/WebSocketMessageType.java index 84e9fb0..f89ef01 100644 --- a/src/main/java/com/iflytop/sgs/common/constant/WebSocketMessageType.java +++ b/src/main/java/com/iflytop/sgs/common/constant/WebSocketMessageType.java @@ -10,6 +10,11 @@ public class WebSocketMessageType { */ public static final String ALARM = "alarm"; /** + * 设备警告 + */ + public static final String WARN = "warn"; + + /** * 自检移动电机测试 */ public static final String SELF_MOVE_TEST = "self_move_test"; diff --git a/src/main/java/com/iflytop/sgs/common/enums/DeviceSensorCode.java b/src/main/java/com/iflytop/sgs/common/enums/DeviceSensorCode.java index 0905ba6..e9f5b12 100644 --- a/src/main/java/com/iflytop/sgs/common/enums/DeviceSensorCode.java +++ b/src/main/java/com/iflytop/sgs/common/enums/DeviceSensorCode.java @@ -14,7 +14,7 @@ public enum DeviceSensorCode { HEATER_TRAY_3_EXIST("加热位3托盘存在状态"), HEATER_TRAY_4_EXIST("加热位4托盘存在状态"), WASTE_EXIST("废液桶是否存在"), - CLAW_TRAY_EXIST("夹爪位托盘存在状态"), + CLAW_TRAY_EXIST("机械臂托盘存在状态"), LIQUID_TRAY_EXIST("上料区托盘存在状态"), THIN_LOW_LEVEL("稀硝酸低液位"), THICK_LOW_LEVEL("浓硝酸低液位"), diff --git a/src/main/java/com/iflytop/sgs/common/enums/data/DevicePositionCode.java b/src/main/java/com/iflytop/sgs/common/enums/data/DevicePositionCode.java index 85aa60f..df1e9b8 100644 --- a/src/main/java/com/iflytop/sgs/common/enums/data/DevicePositionCode.java +++ b/src/main/java/com/iflytop/sgs/common/enums/data/DevicePositionCode.java @@ -19,10 +19,6 @@ public enum DevicePositionCode { ////////////////位置 /** - * 加液模块电机下降进入试管预充位置 - */ - solutionModuleMotorDownPreFillPositon(DevicePositionType.POSITION, "加液模块电机下降进入预充位置"), - /** * 加液模块电机下降进入试管加液位置 */ solutionModuleMotorDownInTubeAddPositon(DevicePositionType.POSITION, "加液模块电机下降进入试管加液位置"), @@ -33,7 +29,7 @@ public enum DevicePositionCode { /** * 加液模块电机预充时下降位置 30mm * */ - liquidAreaPreFillPoint(DevicePositionType.POSITION,"加液模块电机预充时下降取位置" ), + liquidAreaPreFillPoint(DevicePositionType.POSITION,"加液模块电机预充时下降位置" ), /** * 开门位置 */ @@ -45,29 +41,29 @@ public enum DevicePositionCode { ////////////////////////点 /** - * 上料区托盘夹爪位置点 + * 上料区托盘夹取位置点 */ - feedAreaTrayPoint(DevicePositionType.POINT_3D, "上料区托盘夹爪位置点"), + feedAreaTrayPoint(DevicePositionType.POINT_3D, "上料区托盘夹取位置点"), /** * 加液时托盘位置点 */ liquidAreaTrayPoint(DevicePositionType.POINT_3D, "加液时托盘位置点"), /** - * 加热区1托盘夹爪位置点 + * 加热区1托盘夹取位置点 */ - heatArea1TrayClawPoint(DevicePositionType.POINT_3D, "加热区1托盘夹爪位置点"), + heatArea1TrayClawPoint(DevicePositionType.POINT_3D, "加热区1托盘夹取位置点"), /** - * 加热区2托盘夹爪位置点 + * 加热区2托盘夹取位置点 */ - heatArea2TrayClawPoint(DevicePositionType.POINT_3D, "加热区2托盘夹爪位置点"), + heatArea2TrayClawPoint(DevicePositionType.POINT_3D, "加热区2托盘夹取位置点"), /** - * 加热区3托盘夹爪位置点 + * 加热区3托盘夹取位置点 */ - heatArea3TrayClawPoint(DevicePositionType.POINT_3D, "加热区3托盘夹爪位置点"), + heatArea3TrayClawPoint(DevicePositionType.POINT_3D, "加热区3托盘夹取位置点"), /** - * 加热区4托盘夹爪位置点 + * 加热区4托盘夹取位置点 */ - heatArea4TrayClawPoint(DevicePositionType.POINT_3D, "加热区4托盘夹爪位置点"); + heatArea4TrayClawPoint(DevicePositionType.POINT_3D, "加热区4托盘夹取位置点"); private final DevicePositionType type; private final String name; diff --git a/src/main/java/com/iflytop/sgs/common/result/ResultCode.java b/src/main/java/com/iflytop/sgs/common/result/ResultCode.java index 05b0cc9..1a7a4aa 100644 --- a/src/main/java/com/iflytop/sgs/common/result/ResultCode.java +++ b/src/main/java/com/iflytop/sgs/common/result/ResultCode.java @@ -62,7 +62,7 @@ public enum ResultCode implements IResultCode, Serializable { CAP_LIFT_ERROR("6023", "拍子升降错误"), CMD_BUSY("6024", "设备忙,请稍后"), TARGET_HEAT_MODULE_NOT_ANNEAL("6025", "目标加热区不是退火状态"), - TRANSFER_MODULE_NO_TRAY("6026", "夹爪无托盘"), + TRANSFER_MODULE_NO_TRAY("6026", "机械臂无托盘"), SOLUTION_MODULE_NO_TRAY("6027", "加液模块无托盘"), FEED_AREA_NO_TRAY("6028", "上料区无托盘"), SOLUTION_MODULE_IS_BUSY("6029", "加液模块正忙"), @@ -70,7 +70,7 @@ public enum ResultCode implements IResultCode, Serializable { HAVE_IN_ANNEAL_MODULE("6031", "已经在退热模块"), Z_IS_NOT_SAFE("6032", "Z轴位置不安全"), HEAT_MODULE_NO_IDLE("6033", "加热模块无空闲"), - TRANSFER_MODULE_YES_TRAY("6034", "夹爪存在托盘"), + TRANSFER_MODULE_YES_TRAY("6034", "机械臂存在托盘"), NOT_ALLOWED_HEAT_MODULE("6035", "不允许选择的加热区"), FEED_AREA_EXIST_TRAY("6036", "上料区存在托盘"), FAN_START_FAIL("6037", "散热打开失败"), diff --git a/src/main/resources/sql/init.sql b/src/main/resources/sql/init.sql index 8af5767..9a34729 100644 --- a/src/main/resources/sql/init.sql +++ b/src/main/resources/sql/init.sql @@ -51,11 +51,11 @@ VALUES (5, '过量预充距离', 'pre_fill_distance', '17.0', '2025-05-28 13:30: INSERT OR IGNORE INTO system_config ("id", "name", "code", "value", "create_time", "update_time") VALUES (6, '过量排空距离', 'drain_distance', '17.0', '2025-05-28 13:30:45', '2025-05-28 13:30:45'); INSERT OR IGNORE INTO system_config ("id", "name", "code", "value", "create_time", "update_time") -VALUES (7, '过量抽液距离', 'number_reduce', '7.0', '2025-05-28 13:30:45', '2025-05-28 13:30:45'); +VALUES (7, '过量抽液距离', 'reduce_distance', '7.0', '2025-05-28 13:30:45', '2025-05-28 13:30:45'); INSERT OR IGNORE INTO system_config ("id", "name", "code", "value", "create_time", "update_time") VALUES (8, '允许的最大清洁次数', 'cycle_clean_max', '5', '2025-05-28 13:30:45', '2025-05-28 13:30:45'); INSERT OR IGNORE INTO system_config ("id", "name", "code", "value", "create_time", "update_time") -VALUES (9, '蠕动泵最大转速限制', 'liquid_max_speed', '150', '2025-05-28 13:30:45', '2025-05-28 13:30:45'); +VALUES (9, '蠕动泵最大转速限制', 'liquid_max_speed', '400', '2025-05-28 13:30:45', '2025-05-28 13:30:45'); INSERT OR IGNORE INTO system_config ("id", "name", "code", "value", "create_time", "update_time") VALUES (10, '忽略门自检', 'door_origin_is_ignore', 'true', '2025-05-29T14:23:48', '2025-05-29T14:23:48'); INSERT OR IGNORE INTO system_config ("id", "name", "code", "value", "create_time", "update_time") @@ -77,7 +77,33 @@ VALUES (16, 'x轴正常移动速度 标准100', 'x_move_in_normal_speed', '100.0 INSERT OR IGNORE INTO system_config ("id", "name", "code", "value", "create_time", "update_time") VALUES (17, '烘干后风扇开启开始降温的时间(秒)', 'fan_start_keep_time', '60', '2025-06-04 19:06:55.000', '2025-06-04 19:06:56.000'); - +INSERT OR IGNORE INTO system_config ("id", "name", "code", "value", "create_time", "update_time") +VALUES (18, '蠕动泵抽液速度', 'pump_reduce_speed', '150', '2025-06-04 19:06:55.000', + '2025-06-04 19:06:56.000'); +INSERT OR IGNORE INTO system_config ("id", "name", "code", "value", "create_time", "update_time") +VALUES (19, '蠕动泵正常速度', 'pump_normal_speed', '300', '2025-06-04 19:06:55.000', + '2025-06-04 19:06:56.000'); +INSERT OR IGNORE INTO system_config ("id", "name", "code", "value", "create_time", "update_time") +VALUES (20, '稀硝酸过量抽液距离', 'thin_reduce_distance', '7.0', '2025-05-28 13:30:45', + '2025-05-28 13:30:45'); +INSERT OR IGNORE INTO system_config ("id", "name", "code", "value", "create_time", "update_time") +VALUES (21, '浓硝酸过量抽液距离', 'thick_reduce_distance', '7.0', '2025-05-28 13:30:45', + '2025-05-28 13:30:45'); +INSERT OR IGNORE INTO system_config ("id", "name", "code", "value", "create_time", "update_time") +VALUES (22, '蒸馏水过量抽液距离', 'water_reduce_distance', '7.0', '2025-05-28 13:30:45', + '2025-05-28 13:30:45'); +INSERT OR IGNORE INTO system_config ("id", "name", "code", "value", "create_time", "update_time") +VALUES (23, '退火温度 标准值400', 'anneal_temperature', '400.0', '2025-05-28 13:30:45', + '2025-05-28 13:30:45'); +INSERT OR IGNORE INTO system_config ("id", "name", "code", "value", "create_time", "update_time") +VALUES (24, '烘干温度 标准值135', 'dry_temperature', '135.0', '2025-05-28 13:30:45', + '2025-05-28 13:30:45'); +INSERT OR IGNORE INTO system_config ("id", "name", "code", "value", "create_time", "update_time") +VALUES (25, '加热温度 标准值100', 'heat_temperature', '100.0', '2025-05-28 13:30:45', + '2025-05-28 13:30:45'); +INSERT OR IGNORE INTO system_config ("id", "name", "code", "value", "create_time", "update_time") +VALUES (26, '抽液针下降高度 标准55', 'needle_drop_height', '55.0', '2025-05-28 13:30:45', + '2025-05-28 13:30:45'); -- 系统日志 表 CREATE TABLE IF NOT EXISTS system_log @@ -184,4 +210,24 @@ INSERT OR IGNORE INTO solutions (id, name, code, scale, pre_distance, create_tim VALUES (1, '稀硝酸', 'thin', 1, 1, '2025-02-18 02:44:07', '2025-02-18 02:44:07'), (2, '浓硝酸', 'thick', 1, 1, '2025-02-18 02:44:07', '2025-02-18 02:44:07'), (3, '蒸馏水', 'water', 1, 1, '2025-02-18 02:44:07', '2025-02-18 02:44:07'), - (4, '废液', 'waste', 1, 1, '2025-02-18 02:46:23', '2025-02-18 02:46:23'); \ No newline at end of file + (4, '废液', 'waste', 1, 1, '2025-02-18 02:46:23', '2025-02-18 02:46:23'); + + +-- update 2025-06-20 +-- update system_config set value='400' where id = 9; +-- delete from device_position where id=23; +-- UPDATE "device_position" SET "name" = '加液模块电机预充时下降位置' WHERE "id" = 36; + + + + + + + + + + + + + +