|
|
@ -1,11 +1,8 @@ |
|
|
|
package com.iflytop.gd.app.service.crafts; |
|
|
|
|
|
|
|
import cn.hutool.json.JSONArray; |
|
|
|
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.bo.status.device.TrayState; |
|
|
|
import com.iflytop.gd.app.service.api.ContainerService; |
|
|
|
import com.iflytop.gd.app.service.api.DevicePositionService; |
|
|
|
import com.iflytop.gd.app.service.device.DeviceCommandTempUtilService; |
|
|
@ -15,17 +12,16 @@ 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.enums.AcidPumpDeviceCode; |
|
|
|
import com.iflytop.gd.common.enums.HeatModuleCode; |
|
|
|
import com.iflytop.gd.common.enums.data.DevicePositionCode; |
|
|
|
import com.iflytop.gd.common.exception.AppException; |
|
|
|
import com.iflytop.gd.common.result.ResultCode; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
/** |
|
|
|
* 工艺步骤执行服务 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class CraftsStepService { |
|
|
@ -63,28 +59,33 @@ public class CraftsStepService { |
|
|
|
* 将托盘从加热区移动至加液区并且添加溶液 |
|
|
|
*/ |
|
|
|
private boolean addLiquid(String heatId, JSONObject params) throws Exception { |
|
|
|
HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId); |
|
|
|
moveToSolutionModule(heatModuleCode); |
|
|
|
JSONArray tubeSolList = params.getJSONArray("tubeSolList"); |
|
|
|
for (int i = 0; i < tubeSolList.size(); i++) { |
|
|
|
JSONObject tubeSol = tubeSolList.getJSONObject(i); |
|
|
|
Integer tubeNum = tubeSol.getInt("tubeNum"); |
|
|
|
JSONArray addLiquidList = tubeSol.getJSONArray("addLiquidList"); |
|
|
|
for (int j = 0; j < addLiquidList.size(); j++) { |
|
|
|
JSONObject addLiquid = addLiquidList.getJSONObject(j); |
|
|
|
Long solId = addLiquid.getLong("solId"); |
|
|
|
Double volume = addLiquid.getDouble("volume"); |
|
|
|
AcidPumpDeviceCode acidPumpDevice = containerService.getPumpBySolutionId(solId); |
|
|
|
if (acidPumpDevice == null) { |
|
|
|
throw new AppException(ResultCode.CRAFT_CONTAINER_NOT_FOUND); |
|
|
|
} |
|
|
|
webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatId, "移动加液机械臂到指定试管", tubeNum)); |
|
|
|
solutionModuleService.dualRobotMovePoint(tubeNum);//移动加液机械臂到指定试管 |
|
|
|
webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatId, "添加溶液", addLiquid)); |
|
|
|
solutionModuleService.acidPumpMoveBy(acidPumpDevice, volume);//添加溶液 |
|
|
|
} |
|
|
|
} |
|
|
|
solutionModuleService.dualRobotOrigin(); |
|
|
|
// HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId); |
|
|
|
// moveToSolutionModule(heatModuleCode); |
|
|
|
// JSONArray tubeSolList = params.getJSONArray("tubeSolList"); |
|
|
|
// for (int i = 0; i < tubeSolList.size(); i++) { |
|
|
|
// JSONObject tubeSol = tubeSolList.getJSONObject(i); |
|
|
|
// Integer tubeNum = tubeSol.getInt("tubeNum"); |
|
|
|
// JSONArray addLiquidList = tubeSol.getJSONArray("addLiquidList"); |
|
|
|
// for (int j = 0; j < addLiquidList.size(); j++) { |
|
|
|
// JSONObject addLiquid = addLiquidList.getJSONObject(j); |
|
|
|
// Long solId = addLiquid.getLong("solId"); |
|
|
|
// Double volume = addLiquid.getDouble("volume"); |
|
|
|
// AcidPumpDeviceCode acidPumpDevice = containerService.getPumpBySolutionId(solId); |
|
|
|
// if (acidPumpDevice == null) { |
|
|
|
// throw new AppException(ResultCode.CRAFT_CONTAINER_NOT_FOUND); |
|
|
|
// } |
|
|
|
// webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatId, "移动加液机械臂到指定试管", tubeNum)); |
|
|
|
// solutionModuleService.dualRobotMovePoint(tubeNum);//移动加液机械臂到指定试管 |
|
|
|
// webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatId, "添加溶液", addLiquid)); |
|
|
|
// solutionModuleService.acidPumpMoveBy(acidPumpDevice, volume);//添加溶液 |
|
|
|
// } |
|
|
|
// } |
|
|
|
// solutionModuleService.dualRobotOrigin(); |
|
|
|
|
|
|
|
log.info("{}--申请使用加液区并等待", heatId); |
|
|
|
solutionModuleService.requestSolutionModule();//申请使用加液区并等待 |
|
|
|
log.info("{}--申请到加液区,将托盘从加热区移动至加液区并且添加溶液", heatId); |
|
|
|
delay(5); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
@ -92,16 +93,19 @@ public class CraftsStepService { |
|
|
|
* 摇匀操作 |
|
|
|
*/ |
|
|
|
private boolean shaking(String heatId, JSONObject params) throws Exception { |
|
|
|
HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId); |
|
|
|
if(deviceStateService.getDeviceState().getSolutionModule().getTrayStatus() == 0){ |
|
|
|
moveToSolutionModule(heatModuleCode); |
|
|
|
} |
|
|
|
Integer second = params.getInt("second"); |
|
|
|
webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatId, "开始摇匀", params)); |
|
|
|
solutionModuleService.shakeStart();//开始摇匀 |
|
|
|
delay(second); |
|
|
|
webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatId, "停止摇匀", null)); |
|
|
|
solutionModuleService.shakeStop();//停止摇匀 |
|
|
|
// HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId); |
|
|
|
// if(deviceStateService.getDeviceState().getSolutionModule().getTrayStatus() == 0){ |
|
|
|
// moveToSolutionModule(heatModuleCode); |
|
|
|
// } |
|
|
|
// Integer second = params.getInt("second"); |
|
|
|
// webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatId, "开始摇匀", params)); |
|
|
|
// solutionModuleService.shakeStart();//开始摇匀 |
|
|
|
// delay(second); |
|
|
|
// webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatId, "停止摇匀", null)); |
|
|
|
// solutionModuleService.shakeStop();//停止摇匀 |
|
|
|
|
|
|
|
log.info("{}--摇匀", heatId); |
|
|
|
delay(5); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
@ -109,15 +113,20 @@ public class CraftsStepService { |
|
|
|
* 将托盘从加液区移动至加热区并开启加热 |
|
|
|
*/ |
|
|
|
private boolean heating(String heatId, JSONObject params) throws Exception { |
|
|
|
HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId); |
|
|
|
double trayLift = devicePositionService.getPosition(DevicePositionCode.trayLift).getDistance(); //获取加热位抬升托盘位置 |
|
|
|
moveToHeatModule(heatModuleCode); |
|
|
|
Double temperature = params.getDouble("temperature"); |
|
|
|
Integer second = params.getInt("second"); |
|
|
|
heatModuleService.heatRodOpen(heatModuleCode, temperature);//开始加热 |
|
|
|
delay(second); |
|
|
|
heatModuleService.heatRodClose(heatModuleCode);//停止加热 |
|
|
|
heatModuleService.heaterMotorMove(heatModuleCode, trayLift);//抬升加热位托盘 |
|
|
|
// HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId); |
|
|
|
// double trayLift = devicePositionService.getPosition(DevicePositionCode.trayLift).getDistance(); //获取加热位抬升托盘位置 |
|
|
|
// moveToHeatModule(heatModuleCode); |
|
|
|
// Double temperature = params.getDouble("temperature"); |
|
|
|
// Integer second = params.getInt("second"); |
|
|
|
// heatModuleService.heatRodOpen(heatModuleCode, temperature);//开始加热 |
|
|
|
// delay(second); |
|
|
|
// heatModuleService.heatRodClose(heatModuleCode);//停止加热 |
|
|
|
// heatModuleService.heaterMotorMove(heatModuleCode, trayLift);//抬升加热位托盘 |
|
|
|
|
|
|
|
log.info("{}--将托盘从加液区移动至加热区并开启加热", heatId); |
|
|
|
delay(5); |
|
|
|
solutionModuleService.releaseSolutionModule();//释放加液区 |
|
|
|
log.info("{}--释放加液区", heatId); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
@ -125,16 +134,19 @@ public class CraftsStepService { |
|
|
|
* 拍照操作· |
|
|
|
*/ |
|
|
|
private boolean takePhoto(String heatId) throws Exception { |
|
|
|
HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId); |
|
|
|
if(deviceStateService.getDeviceState().getSolutionModule().getTrayStatus() == 0){ |
|
|
|
moveToSolutionModule(heatModuleCode); |
|
|
|
} |
|
|
|
webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatId, "开启补光灯", 100.0)); |
|
|
|
solutionModuleService.fillLightOpen(100.0);//TODO 开启补光灯 亮度从数据库获取 |
|
|
|
webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatId, "拍照", null)); |
|
|
|
solutionModuleService.takePhoto();//拍照 |
|
|
|
webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatId, "关闭补光灯", null)); |
|
|
|
solutionModuleService.fillLightClose();//关闭补光灯 |
|
|
|
// HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId); |
|
|
|
// if(deviceStateService.getDeviceState().getSolutionModule().getTrayStatus() == 0){ |
|
|
|
// moveToSolutionModule(heatModuleCode); |
|
|
|
// } |
|
|
|
// webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatId, "开启补光灯", 100.0)); |
|
|
|
// solutionModuleService.fillLightOpen(100.0);//TODO 开启补光灯 亮度从数据库获取 |
|
|
|
// webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatId, "拍照", null)); |
|
|
|
// solutionModuleService.takePhoto();//拍照 |
|
|
|
// webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatId, "关闭补光灯", null)); |
|
|
|
// solutionModuleService.fillLightClose();//关闭补光灯 |
|
|
|
|
|
|
|
log.info("{}--拍照", heatId); |
|
|
|
delay(5); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
@ -207,6 +219,7 @@ public class CraftsStepService { |
|
|
|
|
|
|
|
heatModuleService.heaterMotorMove(heatModuleCode, trayLower);//下降加热位托盘 |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayStatus(1); |
|
|
|
solutionModuleService.releaseSolutionModule();//释放加液区 |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|