|
|
@ -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<Void> 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<TrayState> 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);//设置加液结束 |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|