diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStartCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStartCommand.java index 7909479..9490a49 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStartCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStartCommand.java @@ -1,13 +1,17 @@ package com.iflytop.sgs.app.cmd.control; import com.iflytop.sgs.app.core.BaseCommandHandler; +import com.iflytop.sgs.app.model.bo.Point3D; import com.iflytop.sgs.app.model.bo.status.device.HeatModuleState; import com.iflytop.sgs.app.model.dto.CmdDTO; +import com.iflytop.sgs.app.service.api.DevicePositionService; 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.TransferModuleService; import com.iflytop.sgs.common.annotation.CommandMapping; import com.iflytop.sgs.common.enums.HeatModuleCode; import com.iflytop.sgs.common.enums.HeatingType; +import com.iflytop.sgs.common.enums.data.DevicePositionCode; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -22,18 +26,37 @@ import java.util.concurrent.CompletableFuture; @RequiredArgsConstructor @CommandMapping("anneal_start")//业务指令注解 public class AnnealStartCommand extends BaseCommandHandler { + private final TransferModuleService transferModuleService; private final HeatModuleService heatModuleService; private final DeviceStateService deviceStateService; + private final DevicePositionService devicePositionService; @Override public CompletableFuture handle(CmdDTO cmdDTO) { - HeatModuleCode heatModuleCode = HeatModuleCode.heat_module_04; + //TODO 判断退火加热模块传感器是否有托盘 + String targetHeatModuleCodeStr = cmdDTO.getStringParam("heatModuleCode"); + HeatModuleCode targetHeatModuleCode = HeatModuleCode.valueOf(targetHeatModuleCodeStr); + //TODO 判断目标加热模块传感器是否有托盘 + HeatModuleCode annealHeatModuleCode = HeatModuleCode.heat_module_04; + + Point3D targetHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(targetHeatModuleCode);//获取目标加热模块托盘夹取点 + Double transferModuleXPickTrayMoveDistance = devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance();//获取转运模块X轴拿取托盘进出卡槽移动距离 + Double transferModuleZPickTrayDownPositon = devicePositionService.getPosition(DevicePositionCode.transferModuleZPickTrayDownPositon).getPositon();//获取转运模块Z轴拿取托盘时下降的高度位置 + Point3D annealHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(annealHeatModuleCode);//获取退火加热模块托盘夹取点 + HeatModuleState heatModuleState = deviceStateService.getDeviceState().getHeatModuleByCode(annealHeatModuleCode);//获取设定的退火温度 + double targetTemperature = heatModuleState.getAnnealTemperature(); + heatModuleState.setTargetTemperature(targetTemperature);//将退火温度设定为目标温度 return runAsync(() -> { - HeatModuleState heatModuleState = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode); - double targetTemperature = heatModuleState.getAnnealTemperature(); - heatModuleState.setTargetTemperature(targetTemperature); - heatModuleService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, targetTemperature); - deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.annealing); + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getX() + transferModuleXPickTrayMoveDistance);//将X轴移动至夹取点 + 移动距离 + transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleZPickTrayDownPositon);//将Z轴下降至托盘夹取点高度 + transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽 + transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), annealHeatModuleTrayClawPoint3D.getX());//将X轴移动至托盘夹取点 + transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleZPickTrayDownPositon);//Z轴下降至夹取点,使托盘落入石墨加热盘 + transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleXPickTrayMoveDistance);//X轴移出卡槽 + transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 + heatModuleService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), annealHeatModuleCode, targetTemperature);//开启加热 + deviceStateService.getDeviceState().getHeatModuleByCode(annealHeatModuleCode).setHeatingType(HeatingType.annealing);//状态修改为退火中 }); } } 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 fdeef95..fdb1308 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 @@ -53,7 +53,7 @@ public class CleanStartCommand extends BaseCommandHandler { //转运模块X轴拿取托盘进出卡槽移动距离 double transferModuleXPickTrayMoveDistance=devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance(); //获取指定加热模块上方点位 - Point3D heatAreaTrayPoint3D = heatModuleService.getHeatAreaTrayClawPoint3D(heatModuleId); + Point3D heatAreaTrayPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(heatModuleId); //获取加液区上方点位 Point3D liquidAreaTrayPoint = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D(); //判断加热区有无托盘 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 18ee698..6d20603 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 @@ -13,7 +13,6 @@ 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.HeatModuleCode; -import com.iflytop.sgs.common.enums.PumpStateCode; import com.iflytop.sgs.common.enums.data.DevicePositionCode; import com.iflytop.sgs.common.exception.AppException; import com.iflytop.sgs.common.result.ResultCode; @@ -65,7 +64,7 @@ public class MoveToHeatAreaCommand extends BaseCommandHandler { //转运模块X轴拿取托盘进出卡槽移动距离 double transferModuleXPickTrayMoveDistance=devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance(); //获取指定加热模块上方点位 - Point3D heatAreaTrayPoint3D = heatModuleService.getHeatAreaTrayClawPoint3D(heatModuleId); + Point3D heatAreaTrayPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(heatModuleId); return runAsync(() -> { try { //升高加液电机高度 回0点 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 18b9f0d..85b5e3d 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 @@ -1,6 +1,5 @@ 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.bo.Point3D; import com.iflytop.sgs.app.model.bo.status.device.HeatModuleState; @@ -56,7 +55,7 @@ public class MoveToLiquidAreaCommand extends BaseCommandHandler { //转运模块X轴拿取托盘进出卡槽移动距离 double transferModuleXPickTrayMoveDistance=devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance(); //获取指定加热模块上方点位 - Point3D heatAreaTrayPoint3D = heatModuleService.getHeatAreaTrayClawPoint3D(heatModuleId); + Point3D heatAreaTrayPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(heatModuleId); //获取加液区上方点位 Point3D liquidAreaTrayPoint = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D(); return runAsync(() -> { 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 ff37153..55eeae4 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 @@ -69,7 +69,7 @@ public class HeatModuleService { /** * 获取指定加热区托盘夹爪点位 */ - public Point3D getHeatAreaTrayClawPoint3D(HeatModuleCode heatModuleId) { + public Point3D getHeatModuleTrayClawPoint3D(HeatModuleCode heatModuleId) { DevicePosition devicePosition = switch (heatModuleId) { case heat_module_01 -> devicePositionService.getPosition(DevicePositionCode.heatArea1TrayClawPoint); case heat_module_02 -> devicePositionService.getPosition(DevicePositionCode.heatArea2TrayClawPoint); 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 661e3c5..3c3531d 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 @@ -1,7 +1,6 @@ package com.iflytop.sgs.app.service.device.module; import com.iflytop.sgs.app.model.bo.Point3D; -import com.iflytop.sgs.app.service.api.DevicePositionService; import com.iflytop.sgs.app.service.device.DeviceCommandService; import com.iflytop.sgs.common.cmd.CommandFuture; import com.iflytop.sgs.common.cmd.DeviceCommandBundle; @@ -96,6 +95,23 @@ public class TransferModuleService { } /** + * 转运机械臂Z轴移动到0点 + */ + public void transferZMoveZero() throws Exception { + transferZMoveZero(null, null); + } + + + /** + * 转运机械臂Z轴移动到0点 + */ + public void transferZMoveZero(String cmdId, String cmdCode) throws Exception { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZMove(0.0); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); + CommandUtil.wait(deviceCommandFuture); + } + + /** * 转运机械臂Z轴移动到指定点 */ public void transferZMove(double position) throws Exception { 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 830844f..445d586 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 @@ -36,11 +36,7 @@ public enum DevicePositionCode { */ transferModuleZMotorUpInTubePositon(DevicePositionType.POSITION, "转运模块Z轴电机上升进入试管位置"), /** - * 转运模块Z轴移动托盘时起托盘的高度位置 - */ - transferModuleZTrayUpMovePositon(DevicePositionType.POSITION, "转运模块Z轴移动托盘时起托盘的高度位置"), - /** - * 转运模块Z轴拿取托盘时起下降的高度位置 + * 转运模块Z轴拿取托盘时下降的高度位置 */ transferModuleZPickTrayDownPositon(DevicePositionType.POSITION, "转运模块Z轴拿取托盘时起下降的高度位置"), /**