|
|
@ -2,8 +2,6 @@ package com.iflytop.sgs.app.cmd.control; |
|
|
|
|
|
|
|
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.dto.CmdDTO; |
|
|
|
import com.iflytop.sgs.app.service.api.DevicePositionService; |
|
|
|
import com.iflytop.sgs.app.service.device.DeviceStateService; |
|
|
@ -13,8 +11,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; |
|
|
@ -30,7 +26,6 @@ import java.util.concurrent.CompletableFuture; |
|
|
|
@CommandMapping("move_to_liquid_area")//业务指令注解 |
|
|
|
public class MoveToLiquidAreaCommand extends BaseCommandHandler { |
|
|
|
private final HeatModuleService heatModuleService; |
|
|
|
private final SolutionModuleService solutionModuleService; |
|
|
|
private final TransferModuleService transferModuleService; |
|
|
|
|
|
|
|
private final DevicePositionService devicePositionService; |
|
|
@ -38,45 +33,42 @@ public class MoveToLiquidAreaCommand extends BaseCommandHandler { |
|
|
|
|
|
|
|
@Override |
|
|
|
public CompletableFuture<Void> handle(CmdDTO cmdDTO) throws Exception { |
|
|
|
if (deviceStateService.getCommandMutexState().get().isMoveToSolutionAreaCommandExecuting()) { |
|
|
|
throw new AppException(ResultCode.COMMAND_ALREADY_EXECUTING); |
|
|
|
String targetHeatModuleCodeStr = cmdDTO.getStringParam("heatModuleCode"); |
|
|
|
HeatModuleCode targetHeatModuleCode;//目标加热模块 |
|
|
|
if (targetHeatModuleCodeStr != null) {//目标加热模块非必填,如果没有传递目标加热模块则尝试获取上料区是否有托盘 |
|
|
|
targetHeatModuleCode = HeatModuleCode.valueOf(targetHeatModuleCodeStr); |
|
|
|
}else{ |
|
|
|
targetHeatModuleCode = null; |
|
|
|
//TODO 尝试获取上料区是否有托盘,如果没有托盘则提示错误 |
|
|
|
} |
|
|
|
if (deviceStateService.getCommandMutexState().get().isMoveToHeatAreaCommandExecuting()) { |
|
|
|
throw new AppException(ResultCode.CMD_BUSY); |
|
|
|
} |
|
|
|
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(); |
|
|
|
|
|
|
|
Point3D targetHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(targetHeatModuleCode);//获取目标加热模块托盘夹取点 |
|
|
|
Double transferModuleXPickTrayMoveDistance = devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance();//获取转运模块X轴拿取托盘进出卡槽移动距离 |
|
|
|
Double transferModuleZPickTrayDownPositon = devicePositionService.getPosition(DevicePositionCode.transferModuleZPickTrayDownPositon).getPositon();//获取转运模块Z轴拿取托盘时下降的高度位置 |
|
|
|
Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹爪位置点 |
|
|
|
Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液时托盘位置点 |
|
|
|
|
|
|
|
return runAsync(() -> { |
|
|
|
try { |
|
|
|
//升高加液电机高度 回0点 |
|
|
|
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0); |
|
|
|
//移动机械臂到加热区上方 此时机械臂夹着托盘 |
|
|
|
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatAreaTrayPoint3D); |
|
|
|
//下降z轴 |
|
|
|
transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),transferModuleZPickTrayDownPositon.getZ()); |
|
|
|
//移动x轴向左托起托盘 |
|
|
|
transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleXPickTrayMoveDistance); |
|
|
|
//z轴返回0点 |
|
|
|
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),0); |
|
|
|
//移动到建邺区 |
|
|
|
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint); |
|
|
|
//设置加液区有托盘 todo |
|
|
|
//deviceStateService.getDeviceState().getSolutionModule().setTrayStatus(1); |
|
|
|
} finally { |
|
|
|
deviceStateService.getCommandMutexState().get().setMoveToHeatAreaCommandExecuting(false); |
|
|
|
if(targetHeatModuleCode == null){ |
|
|
|
//获取上料区托盘 |
|
|
|
transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.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轴抬升至最高 |
|
|
|
deviceStateService.getDeviceState().getSolutionModule().setFeedAreaTrayStatus(false);//设定上料区托盘状态 |
|
|
|
deviceStateService.getDeviceState().getTrayByHeatModuleCode(targetHeatModuleCode).setInFeedArea(false);//设定托盘不在上料区中 |
|
|
|
}else{ |
|
|
|
//获取目标加热模块托盘 |
|
|
|
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轴抬升至最高 |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(targetHeatModuleCode).setTrayStatus(false);//设定目标加热模块托盘状态 |
|
|
|
deviceStateService.getDeviceState().getTrayByHeatModuleCode(targetHeatModuleCode).setInHeatModule(false);//设定托盘不在加热模块中 |
|
|
|
} |
|
|
|
transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX());//将X轴移动至加液时托盘位置点 |
|
|
|
deviceStateService.getDeviceState().getTrayByHeatModuleCode(targetHeatModuleCode).setInSolutionPositon(true);//设定托盘在加液位中 |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|