From 89ac757e93142b91d167745939011a503d08e9b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Thu, 12 Jun 2025 01:36:45 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=B7=A5=E8=89=BA=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E4=BC=98=E5=8C=96=EF=BC=8C=E5=B7=A5=E8=89=BA=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/command/control/MoveToHeatAreaCommand.java | 2 +- .../command/control/MoveToSolutionAreaCommand.java | 10 +--- .../gd/app/command/control/TrayUpCommand.java | 7 +-- .../command/debug/step/DebugShowSmogCommand.java | 8 +-- .../gd/app/command/selftest/TrayOutCommand.java | 8 +-- .../gd/app/service/crafts/CraftsStepService.java | 57 +++++++++++++++------- .../device/DeviceCommandTempUtilService.java | 25 ++-------- .../service/device/module/GantryModuleService.java | 9 +--- 8 files changed, 51 insertions(+), 75 deletions(-) diff --git a/src/main/java/com/iflytop/gd/app/command/control/MoveToHeatAreaCommand.java b/src/main/java/com/iflytop/gd/app/command/control/MoveToHeatAreaCommand.java index d845fc2..db97ec3 100644 --- a/src/main/java/com/iflytop/gd/app/command/control/MoveToHeatAreaCommand.java +++ b/src/main/java/com/iflytop/gd/app/command/control/MoveToHeatAreaCommand.java @@ -121,7 +121,7 @@ public class MoveToHeatAreaCommand extends BaseCommandHandler { gantryModuleService.gantryZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//抬升z轴 gantryModuleService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatAreaCapClawPointPoint3D);//将携带拍子的机械臂移动至加热模块拍子上方 capModuleService.capUpBalanceNoWait(cmdDTO.getCommandId(), cmdDTO.getCommand()); //提升拍子存放区 - deviceCommandTempUtilService.moveTrayHeatModuleAvoidUpNoWait(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode);Thread.sleep(4000);//TODO 结构有问题临时避让 完毕,可以升起了,顺带提升目标加热模块 + deviceCommandTempUtilService.moveTrayHeatModuleAvoidUpNoWait(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode);Thread.sleep(2500);//TODO 结构有问题临时避让 完毕,可以升起了,顺带提升目标加热模块 gantryModuleService.gantryZMove(heatModuleCapMoveHeight);//下降z轴,使夹拍子落入加热模块 gantryModuleService.clawMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawCapPick);//将夹爪打开,释放拍子 deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setCapExist(true);//加热模块是否存在拍子 diff --git a/src/main/java/com/iflytop/gd/app/command/control/MoveToSolutionAreaCommand.java b/src/main/java/com/iflytop/gd/app/command/control/MoveToSolutionAreaCommand.java index 626b7bb..efd5097 100644 --- a/src/main/java/com/iflytop/gd/app/command/control/MoveToSolutionAreaCommand.java +++ b/src/main/java/com/iflytop/gd/app/command/control/MoveToSolutionAreaCommand.java @@ -103,20 +103,14 @@ public class MoveToSolutionAreaCommand extends BaseCommandHandler { capModuleService.capUpBalanceNoWait(cmdDTO.getCommandId(), cmdDTO.getCommand()); //提升拍子存放区至拍子夹取的高度 gantryModuleService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatAreaCapClawPointPoint3D);//将机械臂移动至加热模块拍子上方 deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayUp(1);//将加热模块托盘状态改为抬起 - - double newTrayLift = trayLift; //TODO 临时调整位置 - if(HeatModuleCode.heat_module_05.equals(heatModuleCode)){ - newTrayLift = trayLift - 10; - } - - heatModuleService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, newTrayLift);//抬升指定加热位托盘 + heatModuleService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, trayLift);//抬升指定加热位托盘 gantryModuleService.clawMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawCapPick);//将夹爪打开,准备夹取拍子 gantryModuleService.gantryZMove(heatModuleCapMoveHeight);//下降z轴,使夹爪落入加热模块拍子孔位 gantryModuleService.clawMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawCapGrip);//将夹爪收紧,夹住拍子 deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setCapExist(false);//加热模块是否存在拍子 capModuleService.capMotorMoveByNumNoWait(cmdDTO.getCommandId(), cmdDTO.getCommand(), -1);//拍子存放模块下降1个拍子位置 deviceCommandTempUtilService.moveTrayHeatModuleAvoidDownNoWait(cmdDTO.getCommandId(), cmdDTO.getCommand(), null);//TODO 结构有问题临时避让 开始,移动托盘之前先降下所有加热模块 - gantryModuleService.gantryZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0); Thread.sleep(4000);//抬升z轴 + gantryModuleService.gantryZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0); Thread.sleep(2000);//抬升z轴 gantryModuleService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), capStorageCapClawPoint3D);//将携带拍子的机械臂移动至存放区上方 deviceCommandTempUtilService.moveTrayHeatModuleAvoidUpNoWait(cmdDTO.getCommandId(), cmdDTO.getCommand(), null);//TODO 临时避 恢复抬起状态 gantryModuleService.gantryZMove(capModuleCapMoveHeight);//下降z轴,使夹拍子落入存放区 diff --git a/src/main/java/com/iflytop/gd/app/command/control/TrayUpCommand.java b/src/main/java/com/iflytop/gd/app/command/control/TrayUpCommand.java index d555ddc..09df4f0 100644 --- a/src/main/java/com/iflytop/gd/app/command/control/TrayUpCommand.java +++ b/src/main/java/com/iflytop/gd/app/command/control/TrayUpCommand.java @@ -46,12 +46,7 @@ public class TrayUpCommand extends BaseCommandHandler { double trayLift = devicePositionService.getPosition(DevicePositionCode.trayLift).getDistance(); return runAsync(() -> { try { - //抬升加热位托盘 - double newTrayLift = trayLift; //TODO 临时调整位置 - if (HeatModuleCode.heat_module_05.equals(heatModuleCode)) { - newTrayLift = trayLift - 10; - } - heatModuleService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, newTrayLift); + heatModuleService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, trayLift); deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayUp(1); } catch (Exception e) { log.error("抬起托盘失败", e); diff --git a/src/main/java/com/iflytop/gd/app/command/debug/step/DebugShowSmogCommand.java b/src/main/java/com/iflytop/gd/app/command/debug/step/DebugShowSmogCommand.java index 0236045..6a6c88e 100644 --- a/src/main/java/com/iflytop/gd/app/command/debug/step/DebugShowSmogCommand.java +++ b/src/main/java/com/iflytop/gd/app/command/debug/step/DebugShowSmogCommand.java @@ -48,13 +48,7 @@ public class DebugShowSmogCommand extends BaseCommandHandler { Point3D heatAreaCapClawPointPoint3D = heatModuleService.getHeatAreaCapClawPointPoint3D(heatModuleCode);//获取指定加热模块拍子上方点位 return runAsync(() -> { gantryModuleService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatAreaCapClawPointPoint3D);//将机械臂移动至加热模块拍子上方 - - double newTrayLift = trayLift; //TODO 临时调整位置 - if(HeatModuleCode.heat_module_05.equals(heatModuleCode)){ - newTrayLift = trayLift - 10; - } - - heatModuleService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, newTrayLift);//抬升指定加热位托盘 + heatModuleService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, trayLift);//抬升指定加热位托盘 gantryModuleService.clawMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawCapPick);//将夹爪打开,准备夹取拍子 gantryModuleService.gantryZMove(heatModuleCapMoveHeight);//下降z轴,使夹爪落入加热模块拍子孔位 gantryModuleService.clawMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawCapGrip);//将夹爪收紧,夹住拍子 diff --git a/src/main/java/com/iflytop/gd/app/command/selftest/TrayOutCommand.java b/src/main/java/com/iflytop/gd/app/command/selftest/TrayOutCommand.java index 8bd32bd..3bd38d7 100644 --- a/src/main/java/com/iflytop/gd/app/command/selftest/TrayOutCommand.java +++ b/src/main/java/com/iflytop/gd/app/command/selftest/TrayOutCommand.java @@ -67,13 +67,7 @@ public class TrayOutCommand extends BaseCommandHandler { solutionModuleService.requestSolutionModule();//申请使用加液区并等待 capModuleService.capUpBalance(cmdDTO.getCommandId(), cmdDTO.getCommand()); //提升拍子存放区至拍子夹取的高度 gantryModuleService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatAreaCapClawPointPoint3D);//将机械臂移动至加热模块拍子上方 - - double newTrayLift = trayLift; //TODO 临时调整位置 - if(HeatModuleCode.heat_module_05.equals(heatModuleCode)){ - newTrayLift = trayLift - 10; - } - - heatModuleService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, newTrayLift);//抬升指定加热位托盘 + heatModuleService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, trayLift);//抬升指定加热位托盘 gantryModuleService.clawMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawCapPick);//将夹爪打开,准备夹取拍子 gantryModuleService.gantryZMove(heatModuleCapMoveHeight);//下降z轴,使夹爪落入加热模块拍子孔位 gantryModuleService.clawMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawCapGrip);//将夹爪收紧,夹住拍子 diff --git a/src/main/java/com/iflytop/gd/app/service/crafts/CraftsStepService.java b/src/main/java/com/iflytop/gd/app/service/crafts/CraftsStepService.java index 2ff3442..5f206a9 100644 --- a/src/main/java/com/iflytop/gd/app/service/crafts/CraftsStepService.java +++ b/src/main/java/com/iflytop/gd/app/service/crafts/CraftsStepService.java @@ -29,6 +29,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @@ -118,20 +119,26 @@ public class CraftsStepService { && deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).getTrayStatus() == 1) { moveToSolutionModule(heatModuleCode); } - JSONArray addLiquidList = params.getJSONArray("addLiquidList"); + JSONArray addLiquidList = params.getJSONArray("list"); TrayState trayState = deviceStateService.getDeviceState().getTrayStateByHeatModuleCode(heatModuleCode); TubeState[] tubeArray = trayState.getTubes(); - for (TubeState tubeState : tubeArray) { - int tubeNum = tubeState.getTubeNum(); - if (tubeNum > 0) { - log.info("工艺{},移动加液机械臂到指定试管", heatModuleCode); + for (int i = 0; i < addLiquidList.size(); i++) { + JSONObject addLiquidObject = addLiquidList.getJSONObject(i); + int tubeNum = addLiquidObject.getInt("tubeNum"); + TubeState tubeState = tubeArray[tubeNum - 1]; + if (tubeState.isNeedAddSolution()) { + log.info("工艺{},移动加液机械臂到指定试管({})", heatModuleCode, tubeNum); solutionModuleService.dualRobotMovePoint(tubeNum);//移动加液机械臂到指定试管 List futuresList = new ArrayList<>(); - for (int i = 0; i < addLiquidList.size(); i++) { - JSONObject addLiquid = addLiquidList.getJSONObject(i); - Long containerId = addLiquid.getLong("containerId"); + for (int j = 0; j < addLiquidList.size(); j++) { + JSONObject addLiquid = addLiquidList.getJSONObject(j); + Long solutionId = addLiquid.getLong("solutionId"); Double volume = addLiquid.getDouble("volume"); - Container container = containerService.getById(containerId); + Double offset = addLiquid.getDouble("offset"); + if(offset != null){ + volume += offset; + } + Container container = containerService.getContainerBySolutionId(solutionId); if (container == null) { throw new AppException(ResultCode.CONTAINER_NOT_FOUND);//未找到对应溶液容器 } @@ -172,10 +179,13 @@ public class CraftsStepService { double trayLower = devicePositionService.getPosition(DevicePositionCode.trayLower).getDistance(); //获取托盘升降下降距离位置 moveToHeatModule(heatModuleCode); + Double inTemperature = params.getDouble("inTemperature"); Double targetTemperature = params.getDouble("temperature"); Integer second = params.getInt("second"); - + deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTargetTime(second); + Integer coolingSecond = params.getInt("coolingSecond"); Double temperature = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).getTemperature(); + if (temperature > targetTemperature) { log.info("工艺{},开启风扇降温中", heatModuleCode); heatModuleService.fanStart(heatModuleCode); @@ -191,6 +201,15 @@ public class CraftsStepService { heatModuleService.heatRodOpen(heatModuleCode, targetTemperature); deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.warm_up); log.info("工艺{},等待升温", heatModuleCode); + if (inTemperature != null) { + while (deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).getTemperature() + 10 < inTemperature) { + delay(1); + } + log.info("工艺{},温度达到可以放入的温度,下降加热模块托盘", heatModuleCode); + heatModuleService.heaterMotorMove(heatModuleCode, trayLower);//下降加热模块托盘 + deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayUp(0);//加热模块托盘升降状态 + deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setStartHeatTime(LocalDateTime.now()); + } while (deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).getTemperature() + 1 < targetTemperature) { delay(1); } @@ -201,10 +220,18 @@ public class CraftsStepService { log.info("工艺{},温度合适,下降加热模块托盘", heatModuleCode); heatModuleService.heaterMotorMove(heatModuleCode, trayLower);//下降加热模块托盘 deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayUp(0);//加热模块托盘升降状态 - delay(second); + if (deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).getStartHeatTime() == null) { + deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setStartHeatTime(LocalDateTime.now()); + } + LocalDateTime startHeatTime = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).getStartHeatTime(); + LocalDateTime endHeatTime = startHeatTime.plusSeconds(second); + while (LocalDateTime.now().isBefore(endHeatTime)) { + delay(1); + } log.info("工艺{},加热完成", heatModuleCode); log.info("工艺{},抬升加热位托盘", heatModuleCode); heatModuleService.heaterMotorMove(heatModuleCode, trayLift);//抬升加热位托盘 + delay(coolingSecond); return true; } @@ -351,13 +378,7 @@ public class CraftsStepService { gantryModuleService.gantryMove(heatAreaCapClawPointPoint3D);//将机械臂移动至加热模块拍子上方 deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayUp(1);//将加热模块托盘状态改为抬起 log.info("工艺{},抬升指定加热位托盘", heatModuleCode); - - double newTrayLift = trayLift; //TODO 临时调整位置 - if(HeatModuleCode.heat_module_05.equals(heatModuleCode)){ - newTrayLift = trayLift - 10; - } - - heatModuleService.heaterMotorMove(heatModuleCode, newTrayLift);//抬升指定加热位托盘 + heatModuleService.heaterMotorMove(heatModuleCode, trayLift);//抬升指定加热位托盘 log.info("工艺{},将夹爪打开,准备夹取拍子", heatModuleCode); gantryModuleService.clawMove(clawCapPick);//将夹爪打开,准备夹取拍子 log.info("工艺{},下降z轴,使夹爪落入加热模块拍子孔位", heatModuleCode); diff --git a/src/main/java/com/iflytop/gd/app/service/device/DeviceCommandTempUtilService.java b/src/main/java/com/iflytop/gd/app/service/device/DeviceCommandTempUtilService.java index 2ddd2c2..5067273 100644 --- a/src/main/java/com/iflytop/gd/app/service/device/DeviceCommandTempUtilService.java +++ b/src/main/java/com/iflytop/gd/app/service/device/DeviceCommandTempUtilService.java @@ -58,21 +58,14 @@ public class DeviceCommandTempUtilService { public void moveTrayHeatModuleAvoidUpNoWait(String cmdId, String cmdCode, HeatModuleCode targetHeatModuleCode, HeatModuleCode... exceptionHeatModuleCodes) throws Exception { double trayLift = devicePositionService.getPosition(DevicePositionCode.trayLift).getDistance(); //托盘升降抬升距离 for (HeatModuleCode heatModuleCode : moveTrayHeatModuleAvoidUpStateList) { - double newTrayLift = trayLift; //TODO 临时调整位置 - if(HeatModuleCode.heat_module_05.equals(heatModuleCode)){ - newTrayLift = trayLift - 10; - } if (!Arrays.stream(exceptionHeatModuleCodes).toList().contains(heatModuleCode)) { - DeviceCommandBundle deviceCommand = getHeaterMotorMoveDeviceCommand(heatModuleCode, newTrayLift); + DeviceCommandBundle deviceCommand = getHeaterMotorMoveDeviceCommand(heatModuleCode, trayLift); deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); } } if (targetHeatModuleCode != null) { - double newTrayLift = trayLift; //TODO 临时调整位置 - if(HeatModuleCode.heat_module_05.equals(targetHeatModuleCode)){ - newTrayLift = trayLift - 10; - } - DeviceCommandBundle deviceCommand = getHeaterMotorMoveDeviceCommand(targetHeatModuleCode, newTrayLift); + + DeviceCommandBundle deviceCommand = getHeaterMotorMoveDeviceCommand(targetHeatModuleCode, trayLift); deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); } for (HeatModuleCode heatModuleCode : moveTrayHeatModuleAvoidUpStateList) { @@ -89,22 +82,14 @@ public class DeviceCommandTempUtilService { double trayLift = devicePositionService.getPosition(DevicePositionCode.trayLift).getDistance(); //托盘升降抬升距离 List futuresList = new ArrayList<>(); for (HeatModuleCode heatModuleCode : moveTrayHeatModuleAvoidUpStateList) { - double newTrayLift = trayLift; //TODO 临时调整位置 - if(HeatModuleCode.heat_module_05.equals(heatModuleCode)){ - newTrayLift = trayLift - 10; - } if (!Arrays.stream(exceptionHeatModuleCodes).toList().contains(heatModuleCode)) { - DeviceCommandBundle deviceCommand = getHeaterMotorMoveDeviceCommand(heatModuleCode, newTrayLift); + DeviceCommandBundle deviceCommand = getHeaterMotorMoveDeviceCommand(heatModuleCode, trayLift); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); futuresList.add(deviceCommandFuture); } } if (targetHeatModuleCode != null) { - double newTrayLift = trayLift; //TODO 临时调整位置 - if(HeatModuleCode.heat_module_05.equals(targetHeatModuleCode)){ - newTrayLift = trayLift - 10; - } - DeviceCommandBundle deviceCommand = getHeaterMotorMoveDeviceCommand(targetHeatModuleCode, newTrayLift); + DeviceCommandBundle deviceCommand = getHeaterMotorMoveDeviceCommand(targetHeatModuleCode, trayLift); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); futuresList.add(deviceCommandFuture); } diff --git a/src/main/java/com/iflytop/gd/app/service/device/module/GantryModuleService.java b/src/main/java/com/iflytop/gd/app/service/device/module/GantryModuleService.java index 5d33199..4e0f6d0 100644 --- a/src/main/java/com/iflytop/gd/app/service/device/module/GantryModuleService.java +++ b/src/main/java/com/iflytop/gd/app/service/device/module/GantryModuleService.java @@ -395,14 +395,7 @@ public class GantryModuleService { List futuresList = new ArrayList<>(); for(HeatModuleCode heatModuleCode : HeatModuleCode.values()){ - - double newTrayLift = trayLift; //TODO 临时调整位置 - if(HeatModuleCode.heat_module_05.equals(heatModuleCode)){ - newTrayLift = trayLift - 10; - } - - - DeviceCommandBundle deviceCommand = getHeaterMotorMoveDeviceCommand(heatModuleCode, newTrayLift); + DeviceCommandBundle deviceCommand = getHeaterMotorMoveDeviceCommand(heatModuleCode, trayLift); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); futuresList.add(deviceCommandFuture); }