|
|
@ -1,22 +1,28 @@ |
|
|
|
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.TrayState; |
|
|
|
import com.iflytop.sgs.app.model.bo.status.device.TubeState; |
|
|
|
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.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.HeatModuleCode; |
|
|
|
import com.iflytop.sgs.common.enums.SystemConfigCode; |
|
|
|
import com.iflytop.sgs.common.enums.ValveStateCode; |
|
|
|
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.List; |
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
|
|
|
|
/** |
|
|
@ -30,47 +36,43 @@ public class CleanStartCommand extends BaseCommandHandler { |
|
|
|
private final SolutionModuleService solutionModuleService; |
|
|
|
private final DevicePositionService devicePositionService; |
|
|
|
private final TransferModuleService transferModuleService; |
|
|
|
|
|
|
|
private final DeviceStateService deviceStateService; |
|
|
|
private final HeatModuleService heatModuleService; |
|
|
|
private final SystemConfigService systemConfigService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { |
|
|
|
//清洗次数 |
|
|
|
Integer cycle = cmdDTO.getIntegerParam("cycle"); |
|
|
|
String targetHeatModuleCodeStr = cmdDTO.getStringParam("heatModuleCode"); |
|
|
|
HeatModuleCode targetHeatModuleCode = HeatModuleCode.valueOf(targetHeatModuleCodeStr);//目标加热模块 |
|
|
|
//TODO 判断目标加热模块传感器是否有托盘,如果没有托盘的话提示错误 |
|
|
|
|
|
|
|
Point3D targetHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(targetHeatModuleCode);//获取目标加热模块托盘夹取点 |
|
|
|
Double transferModuleXPickTrayMoveDistance = devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance();//获取转运模块X轴拿取托盘进出卡槽移动距离 |
|
|
|
Double transferModuleZPickTrayDownPositon = devicePositionService.getPosition(DevicePositionCode.transferModuleZPickTrayDownPositon).getPositon();//获取转运模块Z轴拿取托盘时下降的高度位置 |
|
|
|
//TODO 需要先更新一下托盘状态 状态码新增转运模块是否有托盘 |
|
|
|
Assert.isTrue(deviceStateService.getDeviceState().getTransferModule().isTrayStatus(),()->new AppException(ResultCode.TARGET_HEAT_MODULE_NO_TRAY)); |
|
|
|
double cleanWaterVolume= Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.volume_clean));//清洁时加水的量 |
|
|
|
double waterScale= Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.scale_water));//水转换系数 |
|
|
|
double pumpPosition= Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.number_reduce));//抽液时蠕动泵移动 |
|
|
|
Double solutionModuleMotorDownInTubeExtPositon = devicePositionService.getPosition(DevicePositionCode.solutionModuleMotorDownInTubeExtPositon).getPositon();//加液模块电机下降进入试管抽取位置 |
|
|
|
Integer cycle = cmdDTO.getIntegerParam("cycle");//清洗次数 |
|
|
|
Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液时托盘位置点 |
|
|
|
Double trayTubeHorizontalSpacingDistance = devicePositionService.getPosition(DevicePositionCode.trayTubeHorizontalSpacingDistance).getDistance();//获取托盘试管水平间距 |
|
|
|
Double solutionModuleMotorDownInTubeAddPositon = devicePositionService.getPosition(DevicePositionCode.solutionModuleMotorDownInTubeAddPositon).getPositon();//加液模块电机下降进入试管加液位置 |
|
|
|
|
|
|
|
TrayState trayState = deviceStateService.getDeviceState().getTrayByHeatModuleCode(targetHeatModuleCode); |
|
|
|
|
|
|
|
List<TrayState> trayStates=deviceStateService.getDeviceState().getTrays();//所有的托盘 |
|
|
|
TrayState trayState=trayStates.stream().filter(TrayState::isInSolutionPositon).findFirst().get();//加液位的托盘 |
|
|
|
return runAsync(() -> { |
|
|
|
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(), liquidAreaTrayPoint3D.getX());//将X轴移动至加液时托盘位置点 |
|
|
|
solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), ValveStateCode.waste);//电磁阀对应通道打开 |
|
|
|
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),solutionModuleMotorDownInTubeExtPositon);//加液模块下降进入试管抽取位置 |
|
|
|
solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), pumpPosition); |
|
|
|
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),0.0);//加液模块上升 |
|
|
|
solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), ValveStateCode.water);//电磁阀对应通道打开 |
|
|
|
for (int i = 0; i < cycle; i++) { |
|
|
|
for(TubeState tubeState : trayState.getTubes()){ //TODO 切换阀门、加液、取等操作,没完成以后再考虑,应该是先对所有列进行加液,然后从头再依次抽取 |
|
|
|
for(TubeState tubeState : trayState.getTubes()){ |
|
|
|
if(tubeState.isAddSolution() && tubeState.isExists()){ |
|
|
|
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),solutionModuleMotorDownInTubeAddPositon);//加液模块下降进入试管 |
|
|
|
//TODO |
|
|
|
transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -trayTubeHorizontalSpacingDistance);//X轴依次按照试管间距移动 |
|
|
|
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),solutionModuleMotorDownInTubeExtPositon);//加液模块下降进入试管抽取位置 |
|
|
|
solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), cleanWaterVolume*waterScale); |
|
|
|
//todo 线程sleep指定时间 |
|
|
|
solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), -cleanWaterVolume*waterScale); |
|
|
|
double distance=(tubeState.getColumnNum()-1)*trayTubeHorizontalSpacingDistance; |
|
|
|
transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -distance);//X轴依次按照试管间距移动 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),0);//加液模块上升至最高,移出试管 |
|
|
|
transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.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轴抬升至最高 |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|