|
|
@ -1,12 +1,22 @@ |
|
|
|
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.dto.CmdDTO; |
|
|
|
import com.iflytop.sgs.app.service.api.DevicePositionService; |
|
|
|
import com.iflytop.sgs.app.service.device.DeviceStateService; |
|
|
|
import com.iflytop.sgs.app.service.device.module.HeatModuleService; |
|
|
|
import com.iflytop.sgs.app.service.device.module.SolutionModuleService; |
|
|
|
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; |
|
|
@ -21,13 +31,60 @@ import java.util.concurrent.CompletableFuture; |
|
|
|
@RequiredArgsConstructor |
|
|
|
@CommandMapping("heat_start")//业务指令注解 |
|
|
|
public class CleanStartCommand extends BaseCommandHandler { |
|
|
|
private final HeatModuleService heatModuleService; |
|
|
|
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) { |
|
|
|
JSONArray heatIdJsonArray = cmdDTO.getJSONArrayParam("heatId"); |
|
|
|
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.getHeatAreaTrayClawPoint3D(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 |
|
|
|
|
|
|
|
|
|
|
|
//抽液 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//加液臂抬升至安全距离 todo 坐标位置 |
|
|
|
solutionModuleService.motorLiquidMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 100); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|