|
@ -7,7 +7,6 @@ import com.iflytop.gd.app.model.dto.CmdDTO; |
|
|
import com.iflytop.gd.app.service.DeviceCommandUtilService; |
|
|
import com.iflytop.gd.app.service.DeviceCommandUtilService; |
|
|
import com.iflytop.gd.app.service.DevicePositionService; |
|
|
import com.iflytop.gd.app.service.DevicePositionService; |
|
|
import com.iflytop.gd.app.service.DeviceStateService; |
|
|
import com.iflytop.gd.app.service.DeviceStateService; |
|
|
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; |
|
@ -18,7 +17,6 @@ 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; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 移至加液 |
|
|
* 移至加液 |
|
@ -30,15 +28,16 @@ import java.util.concurrent.atomic.AtomicBoolean; |
|
|
public class MoveToSolutionAreaCommand extends BaseCommandHandler { |
|
|
public class MoveToSolutionAreaCommand extends BaseCommandHandler { |
|
|
private final DeviceCommandUtilService deviceCommandUtilService; |
|
|
private final DeviceCommandUtilService deviceCommandUtilService; |
|
|
private final DevicePositionService devicePositionService; |
|
|
private final DevicePositionService devicePositionService; |
|
|
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) throws Exception { |
|
|
public CompletableFuture<Void> handle(CmdDTO cmdDTO) throws Exception { |
|
|
if (isExecuting.get()) { |
|
|
|
|
|
|
|
|
if (deviceStateService.getCommandState().get().isMoveToSolutionAreaCommandExecuting()) { |
|
|
throw new AppException(ResultCode.COMMAND_ALREADY_EXECUTING); |
|
|
throw new AppException(ResultCode.COMMAND_ALREADY_EXECUTING); |
|
|
} |
|
|
} |
|
|
|
|
|
if (deviceStateService.getCommandState().get().isMoveToHeatAreaCommandExecuting()) { |
|
|
|
|
|
throw new AppException(ResultCode.CMD_BUSY); |
|
|
|
|
|
} |
|
|
String heatId = cmdDTO.getStringParam("heatId"); |
|
|
String heatId = cmdDTO.getStringParam("heatId"); |
|
|
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId); |
|
|
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId); |
|
|
double clawCapPick = devicePositionService.getPosition(DevicePositionCode.clawCapPick).getDistance(); //获取拍子夹取距离 |
|
|
double clawCapPick = devicePositionService.getPosition(DevicePositionCode.clawCapPick).getDistance(); //获取拍子夹取距离 |
|
@ -54,58 +53,94 @@ public class MoveToSolutionAreaCommand extends BaseCommandHandler { |
|
|
|
|
|
|
|
|
Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液模块上方点位 |
|
|
Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液模块上方点位 |
|
|
Point3D heatAreaTrayClawPoint3D = deviceCommandUtilService.getHeatAreaTrayClawPoint3D(heatModuleId);//获取指定加热模块上方点位 |
|
|
Point3D heatAreaTrayClawPoint3D = deviceCommandUtilService.getHeatAreaTrayClawPoint3D(heatModuleId);//获取指定加热模块上方点位 |
|
|
|
|
|
Point3D heatArea4TrayClawPoint3D = deviceCommandUtilService.getHeatAreaTrayClawPoint3D(HeatModuleCode.heat_module_04);//获取指定加热模块上方点位 |
|
|
|
|
|
Point3D heatAreaCapClawPointPoint3D = deviceCommandUtilService.getHeatAreaCapClawPointPoint3D(heatModuleId);//获取指定加热模块拍子上方点位 |
|
|
Point3D capStorageCapClawPoint3D = devicePositionService.getPosition(DevicePositionCode.capStorageCapClawPoint).getPoint3D();//获取拍子存放区上方点位; |
|
|
Point3D capStorageCapClawPoint3D = devicePositionService.getPosition(DevicePositionCode.capStorageCapClawPoint).getPoint3D();//获取拍子存放区上方点位; |
|
|
|
|
|
|
|
|
//校验目标加热位是否有托盘 |
|
|
//校验目标加热位是否有托盘 |
|
|
try { |
|
|
try { |
|
|
deviceStateService.setGantryArmStateIdle(false); |
|
|
|
|
|
isExecuting.set(true); |
|
|
|
|
|
Boolean heatModuleTray = deviceCommandUtilService.heatModuleSensorState(heatModuleId); |
|
|
|
|
|
if (!heatModuleTray) { |
|
|
|
|
|
throw new AppException(ResultCode.TARGET_HEAT_MODULE_OCCUPIED); |
|
|
|
|
|
} |
|
|
|
|
|
} finally { |
|
|
|
|
|
deviceStateService.setGantryArmStateIdle(true); |
|
|
|
|
|
isExecuting.set(false); |
|
|
|
|
|
|
|
|
deviceStateService.getCommandState().get().setMoveToSolutionAreaCommandExecuting(true); |
|
|
|
|
|
// Boolean heatModuleTray = deviceCommandUtilService.heatModuleSensorState(heatModuleId); |
|
|
|
|
|
// if (!heatModuleTray) { |
|
|
|
|
|
// throw new AppException(ResultCode.TARGET_HEAT_MODULE_OCCUPIED); |
|
|
|
|
|
// } |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
deviceStateService.getCommandState().get().setMoveToSolutionAreaCommandExecuting(false); |
|
|
|
|
|
throw e; |
|
|
} |
|
|
} |
|
|
return runAsync(() -> { |
|
|
return runAsync(() -> { |
|
|
try { |
|
|
try { |
|
|
TrayState trayState = deviceStateService.getTrayInSolutionModule(); |
|
|
TrayState trayState = deviceStateService.getTrayInSolutionModule(); |
|
|
// gantryArmService.waitLiquidIdle();//等待加液区空闲 |
|
|
// gantryArmService.waitLiquidIdle();//等待加液区空闲 |
|
|
// gantryArmService.setLiquidIdleFalse();//锁定加液区 |
|
|
// gantryArmService.setLiquidIdleFalse();//锁定加液区 |
|
|
deviceCommandUtilService.capUpBalance(cmdDTO.getCommandId(), cmdDTO.getCommand()); //提升拍子存放区至拍子夹取的高度 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// deviceCommandUtilService.capUpBalance(cmdDTO.getCommandId(), cmdDTO.getCommand()); //提升拍子存放区至拍子夹取的高度 |
|
|
|
|
|
deviceCommandUtilService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatAreaCapClawPointPoint3D);//将机械臂移动至加热模块拍子上方 |
|
|
deviceCommandUtilService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId, trayLift);//抬升指定加热位托盘 |
|
|
deviceCommandUtilService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId, trayLift);//抬升指定加热位托盘 |
|
|
deviceStateService.setHeatModuleStateTrayUp(heatModuleId, 1);//将加热模块托盘状态改为抬起 |
|
|
|
|
|
deviceCommandUtilService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatAreaTrayClawPoint3D);//将机械臂移动至加热模块上方 |
|
|
|
|
|
deviceCommandUtilService.clawMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawCapPick);//将夹爪打开,准备夹取拍子 |
|
|
deviceCommandUtilService.clawMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawCapPick);//将夹爪打开,准备夹取拍子 |
|
|
deviceCommandUtilService.gantryZMove(heatModuleCapMoveHeight);//下降z轴,使夹爪落入加热模块拍子孔位 |
|
|
deviceCommandUtilService.gantryZMove(heatModuleCapMoveHeight);//下降z轴,使夹爪落入加热模块拍子孔位 |
|
|
deviceCommandUtilService.clawMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawCapGrip);//将夹爪收紧,夹住拍子 |
|
|
deviceCommandUtilService.clawMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawCapGrip);//将夹爪收紧,夹住拍子 |
|
|
deviceStateService.setHeatModuleStateCapExist(heatModuleId, false);//加热模块是否存在拍子 |
|
|
deviceStateService.setHeatModuleStateCapExist(heatModuleId, false);//加热模块是否存在拍子 |
|
|
deviceCommandUtilService.gantryZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//抬升z轴 |
|
|
deviceCommandUtilService.gantryZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//抬升z轴 |
|
|
|
|
|
// deviceCommandUtilService.capMotorMoveByNum(-1);//拍子存放模块下降1个拍子位置 |
|
|
deviceCommandUtilService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), capStorageCapClawPoint3D);//将携带拍子的机械臂移动至存放区上方 |
|
|
deviceCommandUtilService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), capStorageCapClawPoint3D);//将携带拍子的机械臂移动至存放区上方 |
|
|
deviceCommandUtilService.capMotorMoveByNum(-1);//拍子存放模块下降1个拍子位置 |
|
|
|
|
|
deviceCommandUtilService.gantryZMove(capModuleCapMoveHeight);//下降z轴,使夹拍子落入存放区 |
|
|
deviceCommandUtilService.gantryZMove(capModuleCapMoveHeight);//下降z轴,使夹拍子落入存放区 |
|
|
deviceCommandUtilService.clawMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawCapPick);//将夹爪打开,释放夹取的拍子 |
|
|
deviceCommandUtilService.clawMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawCapPick);//将夹爪打开,释放夹取的拍子 |
|
|
deviceCommandUtilService.gantryZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//抬升z轴 |
|
|
deviceCommandUtilService.gantryZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//抬升z轴 |
|
|
|
|
|
|
|
|
deviceCommandUtilService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatAreaTrayClawPoint3D);//将机械臂移动至加热模块上方 |
|
|
deviceCommandUtilService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatAreaTrayClawPoint3D);//将机械臂移动至加热模块上方 |
|
|
|
|
|
deviceStateService.setHeatModuleStateTrayUp(heatModuleId, 1);//将加热模块托盘状态改为抬起 |
|
|
deviceCommandUtilService.clawMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawTrayPick);//将夹爪打开,准备夹取托盘 |
|
|
deviceCommandUtilService.clawMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawTrayPick);//将夹爪打开,准备夹取托盘 |
|
|
deviceCommandUtilService.gantryZMove(heatModuleTrayMoveHeight);//下降z轴,使夹爪落入托盘孔位 |
|
|
deviceCommandUtilService.gantryZMove(heatModuleTrayMoveHeight);//下降z轴,使夹爪落入托盘孔位 |
|
|
deviceCommandUtilService.clawMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawTrayGrip);//将夹爪收紧,夹住托盘 |
|
|
deviceCommandUtilService.clawMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawTrayGrip);//将夹爪收紧,夹住托盘 |
|
|
deviceStateService.setHeatModuleStateTrayStatus(heatModuleId, 0);//加热模块是否存在托盘 |
|
|
deviceStateService.setHeatModuleStateTrayStatus(heatModuleId, 0);//加热模块是否存在托盘 |
|
|
trayState.setInHeatModule(false);//托盘是否在加热模块中 |
|
|
|
|
|
|
|
|
// trayState.setInHeatModule(false);//托盘是否在加热模块中 |
|
|
deviceCommandUtilService.gantryZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//抬升z轴 |
|
|
deviceCommandUtilService.gantryZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//抬升z轴 |
|
|
|
|
|
deviceCommandUtilService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId, trayLower);//下降加热模块托盘 |
|
|
|
|
|
deviceStateService.setHeatModuleStateTrayUp(heatModuleId, 0);//加热模块托盘升降状态 |
|
|
|
|
|
deviceCommandUtilService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatArea4TrayClawPoint3D);//将携带托盘的机械臂移动至4号加热模块上方 |
|
|
deviceCommandUtilService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D); //将携带托盘的机械臂移动至加液模块上方 |
|
|
deviceCommandUtilService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D); //将携带托盘的机械臂移动至加液模块上方 |
|
|
deviceCommandUtilService.gantryZMove(solutionModuleTrayMoveHeight);//下降z轴,使托盘落入加液模块 |
|
|
deviceCommandUtilService.gantryZMove(solutionModuleTrayMoveHeight);//下降z轴,使托盘落入加液模块 |
|
|
deviceCommandUtilService.clawMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawTrayPick);//将夹爪打开,释放托盘 |
|
|
|
|
|
trayState.setInSolutionModule(true);//托盘是否在加液模块中 |
|
|
|
|
|
|
|
|
// trayState.setInSolutionModule(true);//托盘是否在加液模块中 |
|
|
deviceStateService.setSolutionModuleStateTrayStatus(1);//加液模块是否存在托盘 |
|
|
deviceStateService.setSolutionModuleStateTrayStatus(1);//加液模块是否存在托盘 |
|
|
|
|
|
deviceCommandUtilService.clawMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawTrayPick);//将夹爪打开,释放托盘 |
|
|
deviceCommandUtilService.gantryZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//抬升z轴 |
|
|
deviceCommandUtilService.gantryZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//抬升z轴 |
|
|
deviceCommandUtilService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId, trayLower);//下降加热模块托盘 |
|
|
|
|
|
deviceCommandUtilService.gantryMoveZero();//将机械臂移动至0点 |
|
|
|
|
|
|
|
|
deviceCommandUtilService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), capStorageCapClawPoint3D);//移动机械臂至拍子存放区上方 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// deviceCommandUtilService.capUpBalance(cmdDTO.getCommandId(), cmdDTO.getCommand()); //提升拍子存放区至拍子夹取的高度 |
|
|
|
|
|
// deviceCommandUtilService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId, trayLift);//抬升指定加热位托盘 |
|
|
|
|
|
// deviceStateService.setHeatModuleStateTrayUp(heatModuleId, 1);//将加热模块托盘状态改为抬起 |
|
|
|
|
|
// deviceCommandUtilService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatAreaTrayClawPoint3D);//将机械臂移动至加热模块上方 |
|
|
|
|
|
// deviceCommandUtilService.clawMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawCapPick);//将夹爪打开,准备夹取拍子 |
|
|
|
|
|
// deviceCommandUtilService.gantryZMove(heatModuleCapMoveHeight);//下降z轴,使夹爪落入加热模块拍子孔位 |
|
|
|
|
|
// deviceCommandUtilService.clawMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawCapGrip);//将夹爪收紧,夹住拍子 |
|
|
|
|
|
// deviceStateService.setHeatModuleStateCapExist(heatModuleId, false);//加热模块是否存在拍子 |
|
|
|
|
|
// deviceCommandUtilService.gantryZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//抬升z轴 |
|
|
|
|
|
// deviceCommandUtilService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), capStorageCapClawPoint3D);//将携带拍子的机械臂移动至存放区上方 |
|
|
|
|
|
// deviceCommandUtilService.capMotorMoveByNum(-1);//拍子存放模块下降1个拍子位置 |
|
|
|
|
|
// deviceCommandUtilService.gantryZMove(capModuleCapMoveHeight);//下降z轴,使夹拍子落入存放区 |
|
|
|
|
|
// deviceCommandUtilService.clawMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawCapPick);//将夹爪打开,释放夹取的拍子 |
|
|
|
|
|
// deviceCommandUtilService.gantryZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//抬升z轴 |
|
|
|
|
|
// deviceCommandUtilService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatAreaTrayClawPoint3D);//将机械臂移动至加热模块上方 |
|
|
|
|
|
// deviceCommandUtilService.clawMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawTrayPick);//将夹爪打开,准备夹取托盘 |
|
|
|
|
|
// deviceCommandUtilService.gantryZMove(heatModuleTrayMoveHeight);//下降z轴,使夹爪落入托盘孔位 |
|
|
|
|
|
// deviceCommandUtilService.clawMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawTrayGrip);//将夹爪收紧,夹住托盘 |
|
|
|
|
|
// deviceStateService.setHeatModuleStateTrayStatus(heatModuleId, 0);//加热模块是否存在托盘 |
|
|
|
|
|
// trayState.setInHeatModule(false);//托盘是否在加热模块中 |
|
|
|
|
|
// deviceCommandUtilService.gantryZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//抬升z轴 |
|
|
|
|
|
// deviceCommandUtilService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D); //将携带托盘的机械臂移动至加液模块上方 |
|
|
|
|
|
// deviceCommandUtilService.gantryZMove(solutionModuleTrayMoveHeight);//下降z轴,使托盘落入加液模块 |
|
|
|
|
|
// deviceCommandUtilService.clawMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawTrayPick);//将夹爪打开,释放托盘 |
|
|
|
|
|
// trayState.setInSolutionModule(true);//托盘是否在加液模块中 |
|
|
|
|
|
// deviceStateService.setSolutionModuleStateTrayStatus(1);//加液模块是否存在托盘 |
|
|
|
|
|
// deviceCommandUtilService.gantryZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//抬升z轴 |
|
|
|
|
|
// deviceCommandUtilService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId, trayLower);//下降加热模块托盘 |
|
|
|
|
|
// deviceCommandUtilService.gantryMoveZero();//将机械臂移动至0点 |
|
|
|
|
|
|
|
|
} finally { |
|
|
} finally { |
|
|
deviceStateService.setGantryArmStateIdle(true); |
|
|
deviceStateService.setGantryArmStateIdle(true); |
|
|
isExecuting.set(false); |
|
|
|
|
|
|
|
|
deviceStateService.getCommandState().get().setMoveToSolutionAreaCommandExecuting(false); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|