|
|
@ -6,6 +6,7 @@ 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.model.entity.SystemConfig; |
|
|
|
import com.iflytop.sgs.app.service.api.DevicePositionService; |
|
|
|
import com.iflytop.sgs.app.service.api.SystemConfigService; |
|
|
|
import com.iflytop.sgs.app.service.device.DeviceStateService; |
|
|
@ -41,38 +42,39 @@ public class CleanStartCommand extends BaseCommandHandler { |
|
|
|
|
|
|
|
@Override |
|
|
|
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { |
|
|
|
//TODO 需要先更新一下传感器状态 |
|
|
|
|
|
|
|
//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));//抽液时蠕动泵移动 |
|
|
|
Assert.isTrue(deviceStateService.getDeviceState().getTransferModule().isTrayStatus(), () -> new AppException(ResultCode.TRANSFER_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");//清洗次数 |
|
|
|
Integer maxCycles = Integer.valueOf(systemConfigService.getSystemConfigValueByCode(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();//加液位的托盘 |
|
|
|
List<TrayState> trayStates = deviceStateService.getDeviceState().getTrays();//所有的托盘 |
|
|
|
TrayState trayState = trayStates.stream().filter(TrayState::isInSolutionPositon).findFirst().get();//加液位的托盘 |
|
|
|
return runAsync(() -> { |
|
|
|
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.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeExtPositon);//加液模块下降进入试管抽取位置 |
|
|
|
solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), pumpPosition); |
|
|
|
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),0.0);//加液模块上升 |
|
|
|
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()){ |
|
|
|
if(tubeState.isAddSolution() && tubeState.isExists()){ |
|
|
|
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; |
|
|
|
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轴依次按照试管间距移动 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),0);//加液模块上升至最高,移出试管 |
|
|
|
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//加液模块上升至最高,移出试管 |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|