|
@ -11,11 +11,16 @@ import com.iflytop.gd.app.service.GantryArmService; |
|
|
import com.iflytop.gd.common.annotation.CommandMapping; |
|
|
import com.iflytop.gd.common.annotation.CommandMapping; |
|
|
import com.iflytop.gd.common.enums.HeatModuleCode; |
|
|
import com.iflytop.gd.common.enums.HeatModuleCode; |
|
|
import com.iflytop.gd.common.enums.data.DevicePositionCode; |
|
|
import com.iflytop.gd.common.enums.data.DevicePositionCode; |
|
|
|
|
|
import com.iflytop.gd.common.exception.AppException; |
|
|
|
|
|
import com.iflytop.gd.common.result.ResultCode; |
|
|
|
|
|
import com.iflytop.gd.hardware.service.GDDeviceStatusService; |
|
|
|
|
|
import com.iflytop.gd.hardware.type.IO.InputIOMId; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.stereotype.Component; |
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
|
|
import java.util.concurrent.atomic.AtomicBoolean; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 移至加热 |
|
|
* 移至加热 |
|
@ -29,15 +34,27 @@ public class MoveToHeatAreaCommand extends BaseCommandHandler { |
|
|
private final DevicePositionService devicePositionService; |
|
|
private final DevicePositionService devicePositionService; |
|
|
private final GantryArmService gantryArmService; |
|
|
private final GantryArmService gantryArmService; |
|
|
private final DeviceStateService deviceStateService; |
|
|
private final DeviceStateService deviceStateService; |
|
|
|
|
|
private final AtomicBoolean isExecuting = new AtomicBoolean(false); |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { |
|
|
|
|
|
|
|
|
public CompletableFuture<Void> handle(CmdDTO cmdDTO) throws Exception { |
|
|
|
|
|
if (isExecuting.get()) { |
|
|
|
|
|
throw new AppException(ResultCode.COMMAND_ALREADY_EXECUTING); |
|
|
|
|
|
} |
|
|
|
|
|
isExecuting.set(true); |
|
|
String heatId = cmdDTO.getStringParam("heatId"); |
|
|
String heatId = cmdDTO.getStringParam("heatId"); |
|
|
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId); |
|
|
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId); |
|
|
//TODO 需要校验目标加热位是否有托盘,加液位置是否有托盘 |
|
|
|
|
|
//TODO 有的指令不能并行,前端也应该友好提示,机械臂是否繁忙 |
|
|
|
|
|
//TODO 简单的前端确认弹窗是否有托盘即可 |
|
|
|
|
|
|
|
|
//校验目标加热位是否有托盘 |
|
|
|
|
|
try{ |
|
|
|
|
|
Boolean heatModuleTray = deviceCommandUtilService.heatModuleTray(heatModuleId); |
|
|
|
|
|
if (!heatModuleTray) { |
|
|
|
|
|
throw new AppException(ResultCode.TARGET_HEAT_MODULE_NO_TRAY); |
|
|
|
|
|
} |
|
|
|
|
|
}finally { |
|
|
|
|
|
isExecuting.set(false); |
|
|
|
|
|
} |
|
|
return runAsync(() -> { |
|
|
return runAsync(() -> { |
|
|
|
|
|
try { |
|
|
TrayState trayState = deviceStateService.getTrayInSolutionModule(); |
|
|
TrayState trayState = deviceStateService.getTrayInSolutionModule(); |
|
|
|
|
|
|
|
|
Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液区托盘夹爪点 |
|
|
Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液区托盘夹爪点 |
|
@ -52,8 +69,7 @@ public class MoveToHeatAreaCommand extends BaseCommandHandler { |
|
|
deviceCommandUtilService.gantryZMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -traySafetyHeight);//机械臂提升至移动托盘的安全高度 |
|
|
deviceCommandUtilService.gantryZMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -traySafetyHeight);//机械臂提升至移动托盘的安全高度 |
|
|
deviceStateService.setSolutionModuleStateTrayStatus(0); |
|
|
deviceStateService.setSolutionModuleStateTrayStatus(0); |
|
|
Point3D heatAreaTrayClawPoint3D = deviceCommandUtilService.getHeatAreaTrayClawPoint3D(heatModuleId);//获取指定托盘上方点位 |
|
|
Point3D heatAreaTrayClawPoint3D = deviceCommandUtilService.getHeatAreaTrayClawPoint3D(heatModuleId);//获取指定托盘上方点位 |
|
|
Point3D heatAreaTrayClawSafetyHeightPoint3D = new Point3D(heatAreaTrayClawPoint3D.getX(), |
|
|
|
|
|
heatAreaTrayClawPoint3D.getY(), heatAreaTrayClawPoint3D.getZ() - traySafetyHeight);//加热区托盘点位上方减去移动托盘的安全高度 |
|
|
|
|
|
|
|
|
Point3D heatAreaTrayClawSafetyHeightPoint3D = new Point3D(heatAreaTrayClawPoint3D.getX(), heatAreaTrayClawPoint3D.getY(), heatAreaTrayClawPoint3D.getZ() - traySafetyHeight);//加热区托盘点位上方减去移动托盘的安全高度 |
|
|
deviceCommandUtilService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatAreaTrayClawSafetyHeightPoint3D);//将携带托盘的机械臂移动至托盘上方 |
|
|
deviceCommandUtilService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatAreaTrayClawSafetyHeightPoint3D);//将携带托盘的机械臂移动至托盘上方 |
|
|
deviceCommandUtilService.gantryZMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), traySafetyHeight);//下降机械臂将托盘与试管落入加热区 |
|
|
deviceCommandUtilService.gantryZMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), traySafetyHeight);//下降机械臂将托盘与试管落入加热区 |
|
|
deviceCommandUtilService.gantryZMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -clawDescend);//将机械臂提升至托盘上方高度 |
|
|
deviceCommandUtilService.gantryZMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -clawDescend);//将机械臂提升至托盘上方高度 |
|
@ -68,8 +84,7 @@ public class MoveToHeatAreaCommand extends BaseCommandHandler { |
|
|
deviceCommandUtilService.gantryZMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -capSafetyHeight);//机械臂提升至移动拍子的安全高度 |
|
|
deviceCommandUtilService.gantryZMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -capSafetyHeight);//机械臂提升至移动拍子的安全高度 |
|
|
deviceCommandUtilService.capUpBalance(cmdDTO.getCommandId(), cmdDTO.getCommand()); //提升拍子存放区 |
|
|
deviceCommandUtilService.capUpBalance(cmdDTO.getCommandId(), cmdDTO.getCommand()); //提升拍子存放区 |
|
|
Point3D heatAreaCapClawPoint3D = deviceCommandUtilService.getHeatAreaCapClawPointPoint3D(heatModuleId);//获取托盘上方拍子点位 |
|
|
Point3D heatAreaCapClawPoint3D = deviceCommandUtilService.getHeatAreaCapClawPointPoint3D(heatModuleId);//获取托盘上方拍子点位 |
|
|
Point3D heatAreaCapClawSafetyHeightPoint3D = new Point3D(heatAreaCapClawPoint3D.getX(), heatAreaCapClawPoint3D.getY(), |
|
|
|
|
|
heatAreaCapClawPoint3D.getZ() - capSafetyHeight);//加热区拍子上方加上移动拍子的安全高度 |
|
|
|
|
|
|
|
|
Point3D heatAreaCapClawSafetyHeightPoint3D = new Point3D(heatAreaCapClawPoint3D.getX(), heatAreaCapClawPoint3D.getY(), heatAreaCapClawPoint3D.getZ() - capSafetyHeight);//加热区拍子上方加上移动拍子的安全高度 |
|
|
deviceCommandUtilService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatAreaCapClawSafetyHeightPoint3D);//将机械臂移动至拍子上方加上移动拍子的安全高度 |
|
|
deviceCommandUtilService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatAreaCapClawSafetyHeightPoint3D);//将机械臂移动至拍子上方加上移动拍子的安全高度 |
|
|
deviceCommandUtilService.gantryZMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), traySafetyHeight); //降下机械臂使拍子盖住托盘试管 |
|
|
deviceCommandUtilService.gantryZMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), traySafetyHeight); //降下机械臂使拍子盖住托盘试管 |
|
|
trayState.setHeatModuleId(heatModuleId); |
|
|
trayState.setHeatModuleId(heatModuleId); |
|
@ -82,6 +97,9 @@ public class MoveToHeatAreaCommand extends BaseCommandHandler { |
|
|
double trayLower = devicePositionService.getPosition(DevicePositionCode.trayLower).getDistance(); //获取加热位下降托盘位置 |
|
|
double trayLower = devicePositionService.getPosition(DevicePositionCode.trayLower).getDistance(); //获取加热位下降托盘位置 |
|
|
deviceCommandUtilService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId, trayLower);//下降加热位托盘 |
|
|
deviceCommandUtilService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId, trayLower);//下降加热位托盘 |
|
|
deviceStateService.setHeatModuleStateTrayStatus(heatModuleId, 1); |
|
|
deviceStateService.setHeatModuleStateTrayStatus(heatModuleId, 1); |
|
|
|
|
|
} finally { |
|
|
|
|
|
isExecuting.set(false); |
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|