|
|
@ -1,11 +1,9 @@ |
|
|
|
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.HeatModuleState; |
|
|
|
import com.iflytop.sgs.app.model.bo.status.device.SolutionModuleState; |
|
|
|
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.device.DeviceStateService; |
|
|
@ -15,8 +13,6 @@ 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.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; |
|
|
@ -34,60 +30,47 @@ 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; |
|
|
|
|
|
|
|
@Override |
|
|
|
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { |
|
|
|
//清洗次数 |
|
|
|
Integer cycle = cmdDTO.getIntegerParam("cycle"); |
|
|
|
String targetHeatModuleCodeStr = cmdDTO.getStringParam("heatModuleCode"); |
|
|
|
HeatModuleCode targetHeatModuleCode = HeatModuleCode.valueOf(targetHeatModuleCodeStr);//目标加热模块 |
|
|
|
//TODO 判断目标加热模块传感器是否有托盘,如果没有托盘的话提示错误 |
|
|
|
|
|
|
|
JSONArray jsonArray=cmdDTO.getJSONArrayParam("index"); |
|
|
|
String heatId = cmdDTO.getStringParam("heatId"); |
|
|
|
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId); |
|
|
|
HeatModuleState heatModuleState=deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId); |
|
|
|
SolutionModuleState solutionModuleState=deviceStateService.getDeviceState().getSolutionModule(); |
|
|
|
//转运模块Z轴拿取托盘时起下降的高度位置 |
|
|
|
Point3D transferModuleZPickTrayDownPositon = devicePositionService.getPosition(DevicePositionCode.transferModuleZPickTrayDownPositon).getPoint3D(); |
|
|
|
//转运模块Z轴移动托盘时起托盘的高度位置 |
|
|
|
Point3D transferModuleZTrayUpMovePositon = devicePositionService.getPosition(DevicePositionCode.transferModuleZTrayUpMovePositon).getPoint3D(); |
|
|
|
//转运模块X轴拿取托盘进出卡槽移动距离 |
|
|
|
double transferModuleXPickTrayMoveDistance=devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance(); |
|
|
|
//获取指定加热模块上方点位 |
|
|
|
Point3D heatAreaTrayPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(heatModuleId); |
|
|
|
//获取加液区上方点位 |
|
|
|
Point3D liquidAreaTrayPoint = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D(); |
|
|
|
//判断加热区有无托盘 |
|
|
|
Assert.isTrue(heatModuleState.getTrayStatus(),new AppException(ResultCode.TARGET_HEAT_MODULE_NO_TRAY,ResultCode.TARGET_HEAT_MODULE_NO_TRAY.getMsg())); |
|
|
|
|
|
|
|
return runAsync(() -> { |
|
|
|
//机械臂移动到加液区位置 |
|
|
|
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D); |
|
|
|
//加液臂z下降 |
|
|
|
transferModuleService.transferZMoveBy(clawTrayHeight); |
|
|
|
//加液臂x左移 夹紧托盘 |
|
|
|
transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawTrayGrip); |
|
|
|
//加液臂z上移动 |
|
|
|
transferModuleService.transferZMoveBy(-clawTrayHeight); |
|
|
|
for (int i=0;i<jsonArray.size();i++) { |
|
|
|
//x z 移动到index1位置 todo 坐标位置 |
|
|
|
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), new Point3D()); |
|
|
|
//加液臂下降 至加液位置 todo 坐标位置 |
|
|
|
solutionModuleService.motorLiquidMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 100); |
|
|
|
//抽液 |
|
|
|
|
|
|
|
|
|
|
|
//加水 todo |
|
|
|
|
|
|
|
Point3D targetHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(targetHeatModuleCode);//获取目标加热模块托盘夹取点 |
|
|
|
Double transferModuleXPickTrayMoveDistance = devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance();//获取转运模块X轴拿取托盘进出卡槽移动距离 |
|
|
|
Double transferModuleZPickTrayDownPositon = devicePositionService.getPosition(DevicePositionCode.transferModuleZPickTrayDownPositon).getPositon();//获取转运模块Z轴拿取托盘时下降的高度位置 |
|
|
|
Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液时托盘位置点 |
|
|
|
Double trayTubeHorizontalSpacingDistance = devicePositionService.getPosition(DevicePositionCode.trayTubeHorizontalSpacingDistance).getDistance();//获取托盘试管水平间距 |
|
|
|
Double solutionModuleMotorDownInTubeAddPositon = devicePositionService.getPosition(DevicePositionCode.solutionModuleMotorDownInTubeAddPositon).getPositon();//加液模块电机下降进入试管加液位置 |
|
|
|
|
|
|
|
//抽液 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//加液臂抬升至安全距离 todo 坐标位置 |
|
|
|
solutionModuleService.motorLiquidMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 100); |
|
|
|
TrayState trayState = deviceStateService.getDeviceState().getTrayByHeatModuleCode(targetHeatModuleCode); |
|
|
|
|
|
|
|
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轴移动至加液时托盘位置点 |
|
|
|
for (int i = 0; i < cycle; i++) { |
|
|
|
for(TubeState tubeState : trayState.getTubes()){ //TODO 切换阀门、加液、取等操作,没完成以后再考虑,应该是先对所有列进行加液,然后从头再依次抽取 |
|
|
|
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(),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轴抬升至最高 |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|