From ffcccb14ce23641730223dcc008aa6e9e70a327f 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, 30 May 2025 13:55:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=8A=A0=E6=B6=B2=E5=8C=BA=E6=89=98?= =?UTF-8?q?=E7=9B=98=E4=BC=A0=E6=84=9F=E5=99=A8=E5=92=8C=E4=B8=8A=E6=96=99?= =?UTF-8?q?=E5=8C=BA=E6=89=98=E7=9B=98=E4=BC=A0=E6=84=9F=E5=99=A8=E6=AC=A1?= =?UTF-8?q?=E5=BA=8F=E4=BA=92=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sgs/app/cmd/control/CleanStartCommand.java | 38 +++++++++++++--------- .../iflytop/sgs/hardware/type/IO/InputIOMId.java | 4 +-- 2 files changed, 24 insertions(+), 18 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 23a78a9..6c97ba6 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 @@ -1,6 +1,7 @@ package com.iflytop.sgs.app.cmd.control; import cn.hutool.core.lang.Assert; +import cn.hutool.json.JSONArray; import com.iflytop.sgs.app.core.BaseCommandHandler; import com.iflytop.sgs.app.model.bo.Point3D; import com.iflytop.sgs.app.model.bo.status.device.TrayState; @@ -43,38 +44,43 @@ public class CleanStartCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) { + JSONArray jsonArray = cmdDTO.getJSONArrayParam("columns"); + Assert.notEmpty(jsonArray, () -> new AppException(ResultCode.INVALID_PARAMETER)); + Integer cycle = cmdDTO.getIntegerParam("cycle");//清洗次数 + Integer maxCycles = systemConfigService.getSystemConfigIntegerByCode(SystemConfigCode.cycle_clean_max);//获取最大清洁次数配置 + Assert.isTrue(cycle != null && cycle > 0 && cycle < maxCycles, () -> new AppException(ResultCode.INVALID_PARAMETER));//清洁次数不为空 切清洁次数大于0 double cleanWaterVolume = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.volume_clean);//清洁时加水的量 double waterScale = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.scale_water);//水转换系数 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);//获取最大清洁次数配置 - Assert.isTrue(cycle > 0 && cycle < maxCycles, () -> new AppException(ResultCode.INVALID_PARAMETER));//cycle参数校验 Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液时托盘位置点 Double trayTubeHorizontalSpacingDistance = devicePositionService.getPosition(DevicePositionCode.trayTubeHorizontalSpacingDistance).getDistance();//获取托盘试管水平间距 - List trayStates = deviceStateService.getDeviceState().getTrays();//所有的托盘 - TrayState trayState = trayStates.stream().filter(TrayState::isInSolutionPositon).findFirst().get();//加液位的托盘 return runAsync(() -> { + deviceStateService.getDeviceState().getSolutionModule().setIdle(false);//设置占用 + deviceStateService.getDeviceState().getSolutionModule().setPumping(true);//设置正在加液 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); + solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0.1);//todo 测试准确后打开 pumpPosition solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液模块上升 - solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), ValveStateCode.water);//电磁阀对应通道打开 for (int i = 0; i < cycle; i++) { - for (TubeState tubeState : trayState.getTubes()) { - if (tubeState.isAddSolution() && tubeState.isExists()) { - solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeExtPositon);//加液模块下降进入试管抽取位置 - solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), cleanWaterVolume * waterScale * 8);//八通道蠕动泵 - solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), -cleanWaterVolume * waterScale * 8);//八通道蠕动泵 - double distance = (tubeState.getColumnNum() - 1) * trayTubeHorizontalSpacingDistance;//x轴移动距离 - transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -distance);//X轴依次按照试管间距移动 - } + for (int j = 0; j < jsonArray.size(); j++) { + int column = jsonArray.getInt(i); + solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeExtPositon);//加液模块下降进入试管抽取位置 + solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), ValveStateCode.water);//电磁阀对应通道打开 + solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0.1);//八通道蠕动泵 cleanWaterVolume * waterScale * 8 + solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), ValveStateCode.waste);//电磁阀对应通道打开 + solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0.1);//八通道蠕动泵 + double distance = (column - 1) * trayTubeHorizontalSpacingDistance;//x轴移动距离 + transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX() + distance);//机械臂移动到试管位置 + } + } solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液模块上升至最高,移出试管 + deviceStateService.getDeviceState().getSolutionModule().setIdle(true);//设置占用解除 + deviceStateService.getDeviceState().getSolutionModule().setPumping(false);//设置加液结束 }); } } diff --git a/src/main/java/com/iflytop/sgs/hardware/type/IO/InputIOMId.java b/src/main/java/com/iflytop/sgs/hardware/type/IO/InputIOMId.java index b4a8206..e5b8b9d 100644 --- a/src/main/java/com/iflytop/sgs/hardware/type/IO/InputIOMId.java +++ b/src/main/java/com/iflytop/sgs/hardware/type/IO/InputIOMId.java @@ -8,8 +8,8 @@ public enum InputIOMId { HEATER_TRAY_2_EXIST("HEATER_TRAY_2_EXIST [ 加热模块拍子2到位 ]", MId.IO1_IO, 2, false), HEATER_TRAY_3_EXIST("HEATER_TRAY_3_EXIST [ 加热模块拍子3到位 ]", MId.IO1_IO, 3, false), HEATER_TRAY_4_EXIST("HEATER_TRAY_4_EXIST [ 加热模块拍子4到位 ]", MId.IO1_IO, 4, false), - CLAW_TRAY_EXIST("CLAW_TRAY_EXIST [ 夹爪位托盘存在 ]", MId.IO1_IO, 5, false), - LIQUID_TRAY_EXIST("LIQUID_TRAY_EXIST [ 加液位托盘存在 ]", MId.IO1_IO, 6, false), + CLAW_TRAY_EXIST("CLAW_TRAY_EXIST [ 夹爪位托盘存在 ]", MId.IO1_IO, 6, false), + LIQUID_TRAY_EXIST("LIQUID_TRAY_EXIST [ 加液位托盘存在 ]", MId.IO1_IO, 5, false), THIN_LOW_LEVEL("THIN_LOW_LEVEL [ 稀硝酸低液位检测 ]", MId.IO1_IO, 7, false), THICK_LOW_LEVEL("THICK_LOW_LEVEL [ 浓硝酸低液位检测 ]", MId.IO1_IO, 8, false), WATER_LOW_LEVEL("WATER_LOW_LEVEL [ 蒸馏水低液位检测 ]", MId.IO1_IO, 9, false),