From 4c61f30772939ca45a05457f392d27903c8427fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=A2=A6=E8=BF=9C?= <1063331231@qq.com> Date: Thu, 29 May 2025 18:10:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=B5=8B=E8=AF=95=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sgs/app/cmd/control/CleanStartCommand.java | 11 +++-- .../sgs/app/cmd/control/LiquidAddCommand.java | 24 ++++++----- .../app/cmd/control/LiquidPreFillStartCommand.java | 15 +++---- .../sgs/app/cmd/control/LiquidReduceCommand.java | 8 ++-- .../app/cmd/control/MoveToAnnealAreaCommand.java | 19 ++++++--- .../sgs/app/cmd/control/MoveToFeedAreaCommand.java | 18 ++++----- .../sgs/app/cmd/control/MoveToHeatAreaCommand.java | 17 +++++--- .../app/cmd/control/MoveToLiquidAreaCommand.java | 47 ++++++++++++---------- .../device/module/SolutionModuleService.java | 20 +++++++++ .../iflytop/sgs/common/enums/DeviceSensorCode.java | 3 +- .../com/iflytop/sgs/common/result/ResultCode.java | 2 +- 11 files changed, 111 insertions(+), 73 deletions(-) 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 10cce7d..23a78a9 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 @@ -43,10 +43,9 @@ public class CleanStartCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) { - //Assert.isTrue(deviceStateService.getDeviceState().getTransferModule().isTrayStatus(), () -> new AppException(ResultCode.TRANSFER_MODULE_NO_TRAY));//判断转运模块托盘状态 double cleanWaterVolume = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.volume_clean);//清洁时加水的量 double waterScale = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.scale_water);//水转换系数 - double pumpPosition = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.number_reduce);//抽液时蠕动泵移动 + double pumpPosition = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.number_reduce);//抽液时蠕动泵移动 todo 值需要测试 Double solutionModuleMotorDownInTubeExtPositon = devicePositionService.getPosition(DevicePositionCode.solutionModuleMotorDownInTubeExtPositon).getPositon();//加液模块电机下降进入试管抽取位置 Integer cycle = cmdDTO.getIntegerParam("cycle");//清洗次数 Integer maxCycles = systemConfigService.getSystemConfigIntegerByCode(SystemConfigCode.cycle_clean_max);//获取最大清洁次数配置 @@ -56,9 +55,9 @@ public class CleanStartCommand extends BaseCommandHandler { List trayStates = deviceStateService.getDeviceState().getTrays();//所有的托盘 TrayState trayState = trayStates.stream().filter(TrayState::isInSolutionPositon).findFirst().get();//加液位的托盘 return runAsync(() -> { - transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX());//将X轴移动至加液时托盘位置点 - boolean LIQUID_TRAY_EXIST=deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//监测加液位是否有托盘 - // Assert.isTrue(LIQUID_TRAY_EXIST, () -> new AppException(ResultCode.TARGET_HEAT_MODULE_NO_TRAY));//机械臂是否有托盘 + 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));//夹爪必须有托盘 solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), ValveStateCode.waste);//电磁阀对应通道打开 solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeExtPositon);//加液模块下降进入试管抽取位置 solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), pumpPosition); @@ -75,7 +74,7 @@ public class CleanStartCommand extends BaseCommandHandler { } } } - solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//加液模块上升至最高,移出试管 + solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液模块上升至最高,移出试管 }); } } 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 4d42d98..1ba102d 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 @@ -14,6 +14,7 @@ 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.ValveStateCode; import com.iflytop.sgs.common.enums.data.DevicePositionCode; import com.iflytop.sgs.common.exception.AppException; @@ -57,15 +58,18 @@ public class LiquidAddCommand extends BaseCommandHandler { deviceStateService.getDeviceState().getSolutionModule().setIdle(false);//设置占用 deviceStateService.getDeviceState().getSolutionModule().setPumping(true);//设置正在加液 solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液机械臂上升至0 - 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);//移动至加液位置 - // boolean liquidTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取传感器状态 - //Assert.isTrue(liquidTrayExist, () -> new AppException(ResultCode.SOLUTION_MODULE_NO_TRAY));//判断机械臂是否有托盘 todo 正式放开 + 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轴移动至上料区托盘夹取点 + 进出卡槽移动距离 + 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 currentChannel = deviceSensorService.readLiquidValvePosition();//获取当前阀门的状态 ValveStateCode oldValveState = ValveStateCode.thick.getByChannel(currentChannel);//获取当前电磁阀的值 - double preFillDistance = 0; if (!oldValveState.equals(valveStateCode)) {//判断是否与当前加酸的通道一致 不一致排空 double drainDistance = 0; @@ -98,16 +102,16 @@ public class LiquidAddCommand extends BaseCommandHandler { } } double scale = systemConfigService.getSystemConfigDoubleByCode(valveStateCode.getSystemConfigCode());//根据溶液获取转换比 - double position = volume * scale * 8 + preFillDistance;// + double position = volume * scale * 8 + preFillDistance;//todo 需要测试加液量是否准确 solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), valveStateCode);//电磁阀对应通道打开 deviceStateService.getDeviceState().getSolutionModule().setValveState(valveStateCode);//设置阀门状态 for (int i = 0; i < jsonArray.size(); i++) { int column = jsonArray.getInt(i); if (column > 0 && column < 6) { double distance = (column - 1) * trayTubeHorizontalSpacingDistance;//机械臂右移距离 - transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint.getX()+distance);//机械臂移动到试管位置 - solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 10);//加液机械臂下降 solutionModuleMotorDownInTubeAddPositon - solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0.5);//加液 position设置固定值 todo 正式要改这个 + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint.getX() + distance);//机械臂移动到试管位置 + solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 10);//加液机械臂下降 todo 未测量 测量后要改成 solutionModuleMotorDownInTubeAddPositon + solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0.5);//加液 position设置固定值 todo 未测量 测量后要改成distance solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液机械臂上升 } } 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 3a84114..14281cb 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 @@ -7,12 +7,10 @@ import com.iflytop.sgs.app.model.dto.CmdDTO; import com.iflytop.sgs.app.model.entity.Solutions; import com.iflytop.sgs.app.service.api.DevicePositionService; import com.iflytop.sgs.app.service.api.SolutionsService; -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.ValveStateCode; import com.iflytop.sgs.common.enums.data.DevicePositionCode; import com.iflytop.sgs.common.exception.AppException; @@ -24,7 +22,7 @@ import org.springframework.stereotype.Component; import java.util.concurrent.CompletableFuture; /** - * 预充溶液 + * 预充开始 */ @Slf4j @Component @@ -39,21 +37,20 @@ public class LiquidPreFillStartCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) { - Assert.isTrue(deviceStateService.getDeviceState().getSolutionModule().isIdle(), () -> new AppException(ResultCode.SOLUTION_MODULE_IS_BUSY));//判断当前加液区状态 + Assert.isTrue(deviceStateService.getDeviceState().getSolutionModule().isIdle(), () -> new AppException(ResultCode.SOLUTION_MODULE_IS_BUSY));//判断当前加液区空闲状态 true空闲 Integer solutionId = cmdDTO.getIntegerParam("solutionId");//解析参数酸液Id Solutions solutions = solutionsService.getById(solutionId);//数据库获取酸液信息 Assert.notNull(solutions, () -> new AppException(ResultCode.OPERATION_NOT_ALLOWED));//检验参数 ValveStateCode valveStateCode = ValveStateCode.valueOf(solutions.getCode());//获取对应的电磁阀通道 - Point3D heatArea1TrayClawPoint = devicePositionService.getPosition(DevicePositionCode.heatArea1TrayClawPoint).getPoint3D(); //加热区1上方点位 - Double liquidAreaPreFillPoint = devicePositionService.getPosition(DevicePositionCode.liquidAreaPreFillPoint).getPositon(); //加液模块电机预充时下降进入试管抽取位置 - double position = devicePositionService.getPosition(DevicePositionCode.solutionPreFillDistance).getDistance();//溶液首次预充距离 + Point3D heatArea1TrayClawPoint = devicePositionService.getPosition(DevicePositionCode.heatArea1TrayClawPoint).getPoint3D(); //加热区1上方点位用于放置转运机械臂 + Double liquidAreaPreFillPoint = devicePositionService.getPosition(DevicePositionCode.liquidAreaPreFillPoint).getPositon(); //预充时加液臂下降位置 return runAsync(() -> { deviceStateService.getDeviceState().getSolutionModule().setIdle(false);//设置占用 deviceStateService.getDeviceState().getSolutionModule().setPumping(true);//设置正在加液 solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), valveStateCode);//电磁阀对应的酸液通道打开 - transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatArea1TrayClawPoint.getX());//移动至加热位1 + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatArea1TrayClawPoint.getX());//转运移动至加热位1 solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),liquidAreaPreFillPoint);//加液机械臂下降至至预充点位 - solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), position);//预充开始 todo 泵一直转 + solutionModuleService.liquidPumpRotateForward(cmdDTO.getCommandId(), cmdDTO.getCommand());//预充开始 todo 测试后改动 需要测试一下 }); } } 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 69b83a1..02c8110 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 @@ -51,8 +51,8 @@ public class LiquidReduceCommand extends BaseCommandHandler { return runAsync(() -> { solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液模块上升 transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//将X轴移动至加液时托盘位置点 - boolean liquidTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取传感器状态 - //Assert.isTrue(liquidTrayExist, () -> new AppException(ResultCode.SOLUTION_MODULE_NO_TRAY));//判断机械臂是否有托盘 + boolean liquidTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST);//获取夹爪是否有托盘 + Assert.isTrue(liquidTrayExist, () -> new AppException(ResultCode.SOLUTION_MODULE_NO_TRAY));//判断转态 deviceStateService.getDeviceState().getSolutionModule().setIdle(false);//设置占用 deviceStateService.getDeviceState().getSolutionModule().setPumping(true);//设置正在加液 solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), ValveStateCode.waste);//电磁阀对应通道打开 @@ -67,8 +67,8 @@ public class LiquidReduceCommand extends BaseCommandHandler { } } solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//加液模块上升至最高,移出试管 - transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//移动至加液时托盘位置点 - deviceStateService.getDeviceState().getSolutionModule().setIdle(false);//设置占用解除 + transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//移动至托盘至加液位置点 + deviceStateService.getDeviceState().getSolutionModule().setIdle(true);//设置占用解除 deviceStateService.getDeviceState().getSolutionModule().setPumping(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 3cb4ad4..4985585 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 @@ -45,7 +45,7 @@ public class MoveToAnnealAreaCommand extends BaseCommandHandler { HeatModuleCode targetHeatModuleCode = HeatModuleCode.heat_module_04; if (heatModuleCodeStr != null) {//目标加热模块非必填,如果没有传递目标加热模块则尝试获取上料区是否有托盘 heatModuleCode = HeatModuleCode.valueOf(heatModuleCodeStr);//目标加热模块 - Assert.isTrue(!heatModuleCode.equals(targetHeatModuleCode), () -> new AppException(ResultCode.HAVE_IN_ANNEAL_MODULE)); + Assert.isTrue(!heatModuleCode.equals(targetHeatModuleCode), () -> new AppException(ResultCode.HAVE_IN_ANNEAL_MODULE));//传参模块和目标模块不能一致 } else { heatModuleCode = null; } @@ -53,14 +53,21 @@ public class MoveToAnnealAreaCommand extends BaseCommandHandler { 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();//获取上料区托盘夹爪位置点 return runAsync(() -> { - //boolean annealTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.HEATER_TRAY_4_EXIST);//获取传感器状态 - //Assert.isTrue(!annealTrayExist, () -> new AppException(ResultCode.ANNEAL_MODULE_EXIST_TRAY));//加热位是否有托盘 + boolean annealTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.HEATER_TRAY_4_EXIST);//获取传感器状态 + Assert.isTrue(!annealTrayExist, () -> new AppException(ResultCode.ANNEAL_MODULE_EXIST_TRAY));//加热位不能有托盘 if (heatModuleCode == null) { solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液机械臂上升 transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);//移动至加液位置 - boolean liquidTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取传感器状态 - Assert.isTrue(liquidTrayExist, () -> new AppException(ResultCode.OPERATION_NOT_ALLOWED));//判断机械臂是否有托盘 + 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轴移动至上料区托盘夹取点 + 进出卡槽移动距离 + transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 + transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽 + } }else{ transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleTrayClawPoint3D.getX() + transferModuleXPickTrayMoveDistance);//将X轴移动至加热区托盘夹取点 + 进出卡槽移动距离 transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleTrayClawPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 @@ -70,7 +77,7 @@ public class MoveToAnnealAreaCommand extends BaseCommandHandler { transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getX());//将X轴移动至目标加热模块托盘夹取点 transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getZ());//Z轴下降至夹取点,使托盘落入石墨加热盘 transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleXPickTrayMoveDistance);//X轴移出卡槽 - transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 todo 不执行 + transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 deviceStateService.getDeviceState().getHeatModuleByCode(targetHeatModuleCode).setTrayStatus(true);//设置目标加热区有托盘 }); } 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 2fecf51..1ac6dd9 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 @@ -40,32 +40,32 @@ public class MoveToFeedAreaCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) throws Exception { + + boolean liquidTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取上料区托盘状态 + Assert.isTrue(!liquidTrayExist, () -> new AppException(ResultCode.OPERATION_NOT_ALLOWED));//上料区不能存在托盘 String targetHeatModuleCodeStr = cmdDTO.getStringParam("heatModuleCode"); HeatModuleCode targetHeatModuleCode;//目标加热模块 if (targetHeatModuleCodeStr != null) {//目标加热模块非必填,如果没有传递目标加热模块则尝试获取加液位是否有托盘 targetHeatModuleCode = HeatModuleCode.valueOf(targetHeatModuleCodeStr); } else { targetHeatModuleCode = null; - boolean liquidTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取传感器状态 - Assert.isTrue(liquidTrayExist, () -> new AppException(ResultCode.OPERATION_NOT_ALLOWED));//判断机械臂是否有托盘 } - - 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();//获取加液区托盘夹爪位置点 return runAsync(() -> { solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液机械臂上升 if (targetHeatModuleCode == null) { - //获取加液位托盘 - deviceStateService.getDeviceState().getTrayByHeatModuleCode(targetHeatModuleCode).setInSolutionPositon(false);//设定托盘不在加液位中 + transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//移动至加液位置 + boolean clawTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST);//获取夹爪位托盘状态 + Assert.isTrue(clawTrayExist, () -> new AppException(ResultCode.OPERATION_NOT_ALLOWED));//夹爪托盘必须存在 + //deviceStateService.getDeviceState().getTrayByHeatModuleCode(targetHeatModuleCode).setInSolutionPositon(false);//设定托盘不在加液位中 todo 报错 transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getX());//将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轴抬升至最高 - } else { - //获取目标加热模块托盘 + Point3D targetHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(targetHeatModuleCode);//获取目标加热模块托盘夹取点 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轴进入卡槽 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 2b15f3f..4191a4a 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 @@ -1,5 +1,6 @@ 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.dto.CmdDTO; @@ -13,6 +14,8 @@ import com.iflytop.sgs.common.annotation.CommandMapping; import com.iflytop.sgs.common.enums.DeviceSensorCode; import com.iflytop.sgs.common.enums.HeatModuleCode; 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; @@ -20,7 +23,7 @@ import org.springframework.stereotype.Component; import java.util.concurrent.CompletableFuture; /** - * 将上料区托盘或者机械臂上的托盘移至目标加热模块 + * 将上料区托盘或者夹爪托盘移至目标加热模块 */ @Slf4j @Component @@ -42,16 +45,18 @@ public class MoveToHeatAreaCommand extends BaseCommandHandler { 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();//获取加液区托盘夹爪位置点 + //目标加热模块有无托盘 return runAsync(() -> { solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液机械臂上升 - boolean liquidTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取传感器状态 - if (!liquidTrayExist) { //判断机械臂上是否有托盘 - //机械臂上无托盘,取上料区托盘 + 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轴移动至上料区托盘夹取点 + 进出卡槽移动距离 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轴移动至目标加热模块托盘夹取点 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 8be9539..7845e37 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 @@ -5,11 +5,13 @@ 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.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.common.annotation.CommandMapping; +import com.iflytop.sgs.common.enums.DeviceSensorCode; import com.iflytop.sgs.common.enums.HeatModuleCode; import com.iflytop.sgs.common.enums.data.DevicePositionCode; import com.iflytop.sgs.common.exception.AppException; @@ -34,6 +36,7 @@ public class MoveToLiquidAreaCommand extends BaseCommandHandler { private final DevicePositionService devicePositionService; private final DeviceStateService deviceStateService; private final SolutionModuleService solutionModuleService; + private final DeviceSensorService deviceSensorService; @Override public CompletableFuture handle(CmdDTO cmdDTO) throws Exception { @@ -43,35 +46,37 @@ public class MoveToLiquidAreaCommand extends BaseCommandHandler { targetHeatModuleCode = HeatModuleCode.valueOf(targetHeatModuleCodeStr); } else { targetHeatModuleCode = null; - //todo 要改成传感器获取 - Assert.isTrue(deviceStateService.getDeviceState().getSolutionModule().isFeedAreaTrayStatus(), () -> new AppException(ResultCode.FEED_AREA_NO_TRAY));//上料区无托盘 } - Point3D targetHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(targetHeatModuleCode);//获取目标加热模块托盘夹取点 - Double transferModuleXPickTrayMoveDistance = devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance();//获取转运模块X轴拿取托盘进出卡槽移动距离 + Double transferModuleXPickTrayMoveDistance = devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance();//获取转运模块X轴拿取托盘进出卡槽移动距离 Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹爪位置点 Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液时托盘位置点 return runAsync(() -> { solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液机械臂上升 - if (targetHeatModuleCode == null) { - //获取上料区托盘 - 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);//设定上料区托盘状态 - deviceStateService.getDeviceState().getTrayByHeatModuleCode(targetHeatModuleCode).setInFeedArea(false);//设定托盘不在上料区中 - } else { - //获取目标加热模块托盘 - 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轴进入卡槽 - transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 - deviceStateService.getDeviceState().getHeatModuleByCode(targetHeatModuleCode).setTrayStatus(false);//设定目标加热模块托盘状态 - //deviceStateService.getDeviceState().getTrayByHeatModuleCode(targetHeatModuleCode).setInHeatModule(false);//设定托盘不在加热模块中 todo 报错 + transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//移动至加液位置 + boolean clawTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST);//获取传感器状态 + 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轴下降至夹取点,使托盘落入石墨加热盘 + transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽 + transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 + deviceStateService.getDeviceState().getSolutionModule().setFeedAreaTrayStatus(false);//设定上料区托盘状态 + //deviceStateService.getDeviceState().getTrayByHeatModuleCode(targetHeatModuleCode).setInFeedArea(false);//设定托盘不在上料区中 todo 报错 + } else {//有加热模块参数 + Point3D targetHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(targetHeatModuleCode);//获取目标加热模块托盘夹取点 + 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轴进入卡槽 + transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 + deviceStateService.getDeviceState().getHeatModuleByCode(targetHeatModuleCode).setTrayStatus(false);//设定目标加热模块托盘状态 + //deviceStateService.getDeviceState().getTrayByHeatModuleCode(targetHeatModuleCode).setInHeatModule(false);//设定托盘不在加热模块中 todo 报错 + } } - transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX());//将X轴移动至加液时托盘位置点 + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX());//x轴移动至加液时托盘位置点 //deviceStateService.getDeviceState().getTrayByHeatModuleCode(targetHeatModuleCode).setInSolutionPositon(true);//设定托盘在加液位中 todo 报错 }); 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 7833137..c3108f0 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 @@ -9,6 +9,7 @@ import com.iflytop.sgs.common.cmd.DeviceCommandBundle; import com.iflytop.sgs.common.cmd.DeviceCommandGenerator; import com.iflytop.sgs.common.constant.CommandStatus; import com.iflytop.sgs.common.enums.ValveStateCode; +import com.iflytop.sgs.common.enums.cmd.CmdDirection; import com.iflytop.sgs.common.utils.CommandUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -128,6 +129,25 @@ public class SolutionModuleService { CommandUtil.wait(deviceCommandFuture); } + + /** + * 加液泵正转 + */ + public void liquidPumpRotateForward(String cmdId, String cmdCode) throws Exception { + DeviceCommandBundle deviceCommandBundle = DeviceCommandGenerator.liquidPumpRotate(CmdDirection.forward); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommandBundle); + CommandUtil.wait(deviceCommandFuture); + + } + /** + * 加液泵倒转 + */ + public void liquidPumpRotateBackward(String cmdId, String cmdCode) throws Exception { + DeviceCommandBundle deviceCommandBundle = DeviceCommandGenerator.liquidPumpRotate(CmdDirection.backward); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommandBundle); + CommandUtil.wait(deviceCommandFuture); + + } /** * 加液泵停止 */ 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 2f3c2a8..316875c 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,8 @@ public enum DeviceSensorCode { HEATER_TRAY_3_EXIST("加热位3托盘存在状态"), HEATER_TRAY_4_EXIST("加热位4托盘存在状态"), WASTE_EXIST("废液桶是否存在"), - LIQUID_TRAY_EXIST("加液区托盘是否存在"), + CLAW_TRAY_EXIST("夹爪位托盘存在状态"), + LIQUID_TRAY_EXIST("上料区托盘存在状态"), THIN_LOW_LEVEL("稀硝酸低液位"), THICK_LOW_LEVEL("浓硝酸低液位"), WATER_LOW_LEVEL("水低液位"), 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 1042cde..1db462d 100644 --- a/src/main/java/com/iflytop/sgs/common/result/ResultCode.java +++ b/src/main/java/com/iflytop/sgs/common/result/ResultCode.java @@ -56,7 +56,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", "加液模块正忙"),