|
|
@ -5,21 +5,20 @@ import cn.hutool.json.JSONObject; |
|
|
|
import com.iflytop.gd.app.core.CraftsDebugGenerator; |
|
|
|
import com.iflytop.gd.app.model.bo.CraftsStep; |
|
|
|
import com.iflytop.gd.app.model.bo.Point3D; |
|
|
|
import com.iflytop.gd.app.model.entity.Container; |
|
|
|
import com.iflytop.gd.app.service.api.ContainerService; |
|
|
|
import com.iflytop.gd.app.service.api.DevicePositionService; |
|
|
|
import com.iflytop.gd.app.service.device.DeviceCommandTempUtilService; |
|
|
|
import com.iflytop.gd.app.service.device.DeviceStateService; |
|
|
|
import com.iflytop.gd.app.service.device.module.*; |
|
|
|
import com.iflytop.gd.app.service.device.module.CapModuleService; |
|
|
|
import com.iflytop.gd.app.service.device.module.GantryModuleService; |
|
|
|
import com.iflytop.gd.app.service.device.module.HeatModuleService; |
|
|
|
import com.iflytop.gd.app.service.device.module.SolutionModuleService; |
|
|
|
import com.iflytop.gd.app.ws.server.WebSocketSender; |
|
|
|
import com.iflytop.gd.common.command.CommandFuture; |
|
|
|
import com.iflytop.gd.common.enums.AcidPumpDeviceCode; |
|
|
|
import com.iflytop.gd.common.enums.HeatModuleCode; |
|
|
|
import com.iflytop.gd.common.enums.HeatingType; |
|
|
|
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.common.utils.CommandUtil; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -41,13 +40,12 @@ public class CraftsStepService { |
|
|
|
private final DevicePositionService devicePositionService; |
|
|
|
private final DeviceStateService deviceStateService; |
|
|
|
private final DeviceCommandTempUtilService deviceCommandTempUtilService; |
|
|
|
private final OtherModuleService otherModuleService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 执行单个工艺步骤 |
|
|
|
* |
|
|
|
* @param heatModuleCode 加热区 ID |
|
|
|
* @param step 工艺步骤,包括 method 和 params |
|
|
|
* @param step 工艺步骤,包括 method 和 params |
|
|
|
* @return true 表示执行成功,false 表示失败 |
|
|
|
*/ |
|
|
|
public boolean executeStep(HeatModuleCode heatModuleCode, CraftsStep step) throws Exception { |
|
|
@ -67,23 +65,7 @@ public class CraftsStepService { |
|
|
|
*/ |
|
|
|
private boolean addLiquid(HeatModuleCode heatModuleCode, JSONObject params) throws Exception { |
|
|
|
//TODO 判断加液区是否有托盘,如果没有托盘的话,判断加热区是否有托盘,然后将其移动至加液区 |
|
|
|
if((deviceStateService.getDeviceState().getSolutionModule().getTrayStatus() == 0 ) |
|
|
|
&& deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).getTrayStatus() == 0) { |
|
|
|
throw new AppException(ResultCode.CRAFT_NO_TRAY); |
|
|
|
} |
|
|
|
if((deviceStateService.getDeviceState().getSolutionModule().getTrayStatus() == 0 ) |
|
|
|
&& deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).getTrayStatus() == 1) { |
|
|
|
moveToSolutionModule(heatModuleCode); |
|
|
|
} |
|
|
|
|
|
|
|
JSONArray tubeNums = params.getJSONArray("tubeNums"); |
|
|
|
for (int i = 0; i < tubeNums.size(); i++) { |
|
|
|
JSONObject tubeSol = tubeNums.getJSONObject(i); |
|
|
|
Integer tubeNum = tubeSol.getInt("tubeNum"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
moveToSolutionModule(heatModuleCode); |
|
|
|
JSONArray tubeSolList = params.getJSONArray("tubeSolList"); |
|
|
|
for (int i = 0; i < tubeSolList.size(); i++) { |
|
|
|
JSONObject tubeSol = tubeSolList.getJSONObject(i); |
|
|
@ -93,15 +75,14 @@ public class CraftsStepService { |
|
|
|
JSONObject addLiquid = addLiquidList.getJSONObject(j); |
|
|
|
Long solId = addLiquid.getLong("solId"); |
|
|
|
Double volume = addLiquid.getDouble("volume"); |
|
|
|
Container container = containerService.getContainerBySolutionId(solId); |
|
|
|
if (container == null) { |
|
|
|
throw new AppException(ResultCode.CONTAINER_NOT_FOUND);//未找到对应溶液容器 |
|
|
|
AcidPumpDeviceCode acidPumpDevice = containerService.getPumpBySolutionId(solId); |
|
|
|
if (acidPumpDevice == null) { |
|
|
|
throw new AppException(ResultCode.CRAFT_CONTAINER_NOT_FOUND); |
|
|
|
} |
|
|
|
AcidPumpDeviceCode acidPumpDevice = AcidPumpDeviceCode.valueOf(container.getPumpId());//泵 |
|
|
|
int scale = container.getScale() == null ? 120 : container.getScale();//系数 |
|
|
|
webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatModuleCode.toString(), "移动加液机械臂到指定试管", tubeNum)); |
|
|
|
solutionModuleService.dualRobotMovePoint(tubeNum);//移动加液机械臂到指定试管 |
|
|
|
CommandFuture deviceCommandFuture = solutionModuleService.acidPumpMoveBy(acidPumpDevice, volume * ((double) scale /100));//添加溶液 |
|
|
|
CommandUtil.wait(deviceCommandFuture); |
|
|
|
webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatModuleCode.toString(), "添加溶液", addLiquid)); |
|
|
|
solutionModuleService.acidPumpMoveBy(acidPumpDevice, volume);//添加溶液 |
|
|
|
} |
|
|
|
} |
|
|
|
solutionModuleService.dualRobotOrigin(); |
|
|
@ -133,15 +114,8 @@ public class CraftsStepService { |
|
|
|
Double temperature = params.getDouble("temperature"); |
|
|
|
Integer second = params.getInt("second"); |
|
|
|
heatModuleService.heatRodOpen(heatModuleCode, temperature);//开始加热 |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.thermostatic); |
|
|
|
//达到目标温度后才算开始加热 |
|
|
|
while (deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).getTemperature() + 1 < temperature) { |
|
|
|
delay(1); |
|
|
|
} |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.constant); |
|
|
|
delay(second); |
|
|
|
heatModuleService.heatRodClose(heatModuleCode);//停止加热 |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.finish); |
|
|
|
heatModuleService.heaterMotorMove(heatModuleCode, trayLift);//抬升加热位托盘 |
|
|
|
return true; |
|
|
|
} |
|
|
@ -175,15 +149,6 @@ public class CraftsStepService { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 工艺执行完毕 |
|
|
|
*/ |
|
|
|
public void finish(HeatModuleCode heatModuleCode) throws Exception { |
|
|
|
moveToSolutionModule(heatModuleCode); |
|
|
|
//蜂鸣器提示 |
|
|
|
// otherModuleService.craftsFinishBeepRemind(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 将托盘移至加热 |
|
|
|
*/ |
|
|
|
private void moveToHeatModule(HeatModuleCode heatModuleCode) throws Exception { |
|
|
@ -204,30 +169,29 @@ public class CraftsStepService { |
|
|
|
Point3D heatAreaCapClawPointPoint3D = heatModuleService.getHeatAreaCapClawPointPoint3D(heatModuleCode);//获取指定加热模块拍子上方点位 |
|
|
|
Point3D capStorageCapClawPoint3D = devicePositionService.getPosition(DevicePositionCode.capStorageCapClawPoint).getPoint3D();//获取拍子存放区上方点位; |
|
|
|
|
|
|
|
capModuleService.capUpBalanceNoWait();//提升拍子存放区至拍子夹取的高度 |
|
|
|
gantryModuleService.gantryMove(liquidAreaTrayPoint3D); //将机械臂移动至加液模块上方 |
|
|
|
gantryModuleService.clawMove(clawTrayPick);//将夹爪打开,准备夹取托盘 |
|
|
|
gantryModuleService.gantryZMove(solutionModuleTrayMoveHeight);//下降z轴,使夹爪落入托盘孔位 |
|
|
|
gantryModuleService.clawMove(clawTrayGrip);//将夹爪收紧,夹住托盘 |
|
|
|
gantryModuleService.gantryZMove(0);//抬升z轴 |
|
|
|
deviceStateService.getDeviceState().getSolutionModule().setTrayStatus(0);//加液模块是否有托盘 |
|
|
|
// deviceCommandTempUtilService.moveTrayHeatModuleAvoidDown(null);//TODO 结构有问题临时避让 开始,移动托盘之前先降下所有加热模块 |
|
|
|
deviceCommandTempUtilService.moveTrayHeatModuleAvoidDown(null);//TODO 结构有问题临时避让 开始,移动托盘之前先降下所有加热模块 |
|
|
|
gantryModuleService.gantryMove(heatArea4TrayClawPoint3D);//将携带托盘的机械臂移动至4号加热模块上方 |
|
|
|
gantryModuleService.gantryMove(heatAreaTrayClawPoint3D);//将携带托盘的机械臂移动至加热模块上方 |
|
|
|
// deviceCommandUtilService.heaterMotorMove( heatModuleId, trayLift);//抬升加热位托盘 TODO 结构有问题临时避让 屏蔽 |
|
|
|
deviceCommandTempUtilService.moveTrayHeatModuleAvoidUpNoWait(heatModuleCode);Thread.sleep(3200);//TODO 结构有问题临时避让 完毕,可以升起了,顺带提升目标加热模块 |
|
|
|
deviceCommandTempUtilService.moveTrayHeatModuleAvoidUp(heatModuleCode);//TODO 结构有问题临时避让 完毕,可以升起了,顺带提升目标加热模块 |
|
|
|
gantryModuleService.gantryZMove(heatModuleTrayMoveHeight);//下降z轴,使托盘落入加热模块 |
|
|
|
gantryModuleService.clawMove(clawTrayPick);//将夹爪打开,释放托盘 |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayStatus(1);//加热模块是否存在托盘 |
|
|
|
gantryModuleService.gantryZMove(0);//抬升z轴 |
|
|
|
|
|
|
|
capModuleService.capUpBalance();//提升拍子存放区至拍子夹取的高度 |
|
|
|
gantryModuleService.gantryMove(capStorageCapClawPoint3D);//移动机械臂至拍子存放区上方 |
|
|
|
gantryModuleService.clawMove(clawCapPick);//将夹爪打开,准备夹取拍子 |
|
|
|
gantryModuleService.gantryZMove(capModuleCapMoveHeight);//下降z轴,使夹爪落入拍子升降模块拍子孔位 |
|
|
|
gantryModuleService.clawMove(clawCapGrip);//将夹爪收紧,夹住拍子 |
|
|
|
gantryModuleService.gantryZMove(0);//抬升z轴 |
|
|
|
gantryModuleService.gantryMove(heatAreaCapClawPointPoint3D);//将携带拍子的机械臂移动至加热模块拍子上方 |
|
|
|
capModuleService.capUpBalanceNoWait(); //提升拍子存放区 |
|
|
|
gantryModuleService.gantryZMove(heatModuleCapMoveHeight);//下降z轴,使夹拍子落入加热模块 |
|
|
|
gantryModuleService.clawMove(clawCapPick);//将夹爪打开,释放拍子 |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setCapExist(true);//加热模块是否存在拍子 |
|
|
@ -236,8 +200,11 @@ public class CraftsStepService { |
|
|
|
// trayState.setInHeatModule(true); |
|
|
|
heatModuleService.heaterMotorMove(heatModuleCode, trayLower);//下降加热模块托盘 |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayUp(0);//加热模块托盘升降状态 |
|
|
|
capModuleService.capUpBalance(); //提升拍子存放区 |
|
|
|
gantryModuleService.gantryMove(capStorageCapClawPoint3D);//移动机械臂至拍子存放区上方 |
|
|
|
|
|
|
|
heatModuleService.heaterMotorMove(heatModuleCode, trayLower);//下降加热位托盘 |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayStatus(1); |
|
|
|
solutionModuleService.releaseSolutionModule();//释放加液区 |
|
|
|
} |
|
|
|
|
|
|
@ -265,15 +232,15 @@ public class CraftsStepService { |
|
|
|
|
|
|
|
// TrayState trayState = deviceStateService.getTrayInSolutionModule(); |
|
|
|
solutionModuleService.requestSolutionModule();//申请使用加液区并等待 |
|
|
|
capModuleService.capUpBalanceNoWait(); //提升拍子存放区至拍子夹取的高度 |
|
|
|
capModuleService.capUpBalance(); //提升拍子存放区至拍子夹取的高度 |
|
|
|
gantryModuleService.gantryMove(heatAreaCapClawPointPoint3D);//将机械臂移动至加热模块拍子上方 |
|
|
|
heatModuleService.heaterMotorMove(heatModuleCode, trayLift);//抬升指定加热位托盘 |
|
|
|
gantryModuleService.clawMove(clawCapPick);//将夹爪打开,准备夹取拍子 |
|
|
|
gantryModuleService.gantryZMove(heatModuleCapMoveHeight);//下降z轴,使夹爪落入加热模块拍子孔位 |
|
|
|
gantryModuleService.clawMove(clawCapGrip);//将夹爪收紧,夹住拍子 |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setCapExist(false);//加热模块是否存在拍子 |
|
|
|
capModuleService.capMotorMoveByNumNoWait(-1);//拍子存放模块下降1个拍子位置 |
|
|
|
gantryModuleService.gantryZMove(0); Thread.sleep(2000);//抬升z轴 |
|
|
|
gantryModuleService.gantryZMove(0);//抬升z轴 |
|
|
|
capModuleService.capMotorMoveByNum(-1);//拍子存放模块下降1个拍子位置 |
|
|
|
gantryModuleService.gantryMove(capStorageCapClawPoint3D);//将携带拍子的机械臂移动至存放区上方 |
|
|
|
gantryModuleService.gantryZMove(capModuleCapMoveHeight);//下降z轴,使夹拍子落入存放区 |
|
|
|
gantryModuleService.clawMove(clawCapPick);//将夹爪打开,释放夹取的拍子 |
|
|
@ -286,16 +253,16 @@ public class CraftsStepService { |
|
|
|
gantryModuleService.clawMove(clawTrayGrip);//将夹爪收紧,夹住托盘 |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayStatus(0);//加热模块是否存在托盘 |
|
|
|
// trayState.setInHeatModule(false);//托盘是否在加热模块中 |
|
|
|
deviceCommandTempUtilService.moveTrayHeatModuleAvoidDownNoWait(heatModuleCode);//TODO 临时避让下降 |
|
|
|
gantryModuleService.gantryZMove(0);Thread.sleep(2500);//抬升z轴 |
|
|
|
gantryModuleService.gantryZMove(0);//抬升z轴 |
|
|
|
// deviceCommandUtilService.heaterMotorMove( heatModuleId, trayLower);//下降加热模块托盘 |
|
|
|
// deviceStateService.setHeatModuleStateTrayUp(heatModuleId, 0);//加热模块托盘升降状态 |
|
|
|
deviceCommandTempUtilService.moveTrayHeatModuleAvoidDown(heatModuleCode);//TODO 临时避让下降 |
|
|
|
gantryModuleService.gantryMove(heatArea4TrayClawPoint3D);//将携带托盘的机械臂移动至4号加热模块上方 |
|
|
|
gantryModuleService.gantryMove(liquidAreaTrayPoint3D); //将携带托盘的机械臂移动至加液模块上方 |
|
|
|
deviceCommandTempUtilService.moveTrayHeatModuleAvoidUp(null, heatModuleCode);//TODO 临时避 恢复抬起状态 |
|
|
|
deviceCommandTempUtilService.moveTrayHeatModuleAvoidDown(null);//TODO 临时避 恢复抬起状态 |
|
|
|
gantryModuleService.gantryZMove(solutionModuleTrayMoveHeight);//下降z轴,使托盘落入加液模块 |
|
|
|
// trayState.setInSolutionModule(true);//托盘是否在加液模块中 |
|
|
|
deviceStateService.getDeviceState().getSolutionModule().setTrayStatus(1);//加液模块是否存在托盘 |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayStatus(1);//加液模块是否存在托盘 |
|
|
|
gantryModuleService.clawMove(clawTrayPick);//将夹爪打开,释放托盘 |
|
|
|
gantryModuleService.gantryZMove(0);//抬升z轴 |
|
|
|
gantryModuleService.gantryMove(capStorageCapClawPoint3D);//移动机械臂至拍子存放区上方 |
|
|
|