From 650627852b6ec6e51f714ce4001a6471d9bdec95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Sun, 15 Jun 2025 13:40:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E7=8E=B0=E5=9C=BA?= =?UTF-8?q?=E9=94=81=E9=97=AE=E9=A2=98=E3=80=81=E5=A2=9E=E5=8A=A0=E7=9C=9F?= =?UTF-8?q?=E7=A9=BA=E6=B3=B5=E9=98=80=E9=97=A8=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/command/control/MoveToHeatAreaCommand.java | 3 +- .../command/control/MoveToSolutionAreaCommand.java | 1 - .../debug/DebugVacuumValveCloseCommand.java | 16 +++- .../command/debug/DebugVacuumValveOpenCommand.java | 17 ++++- .../iflytop/gd/app/service/api/TrayService.java | 2 +- .../gd/app/service/crafts/CraftsStepService.java | 31 +++----- .../app/service/device/ActionCommandService.java | 6 +- .../device/DeviceCommandTempUtilService.java | 3 +- .../service/device/module/HeatModuleService.java | 50 +++++++++++++ .../gd/common/command/DeviceCommandGenerator.java | 85 +++++++++++++++++++++- .../iflytop/gd/common/enums/command/CmdDevice.java | 6 ++ .../hardware/command/handlers/IOCtrlHandler.java | 59 +++++++++++++++ .../gd/hardware/drivers/CameraBaslerDriver.java | 7 +- .../iflytop/gd/hardware/type/IO/OutputIOMId.java | 4 + 14 files changed, 255 insertions(+), 35 deletions(-) create mode 100644 src/main/java/com/iflytop/gd/hardware/command/handlers/IOCtrlHandler.java 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 07f6d63..27b08da 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 @@ -85,10 +85,9 @@ public class MoveToHeatAreaCommand extends BaseCommandHandler { actionCommandService.moveTrayToHeatModule(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode);//将托盘移动至指定加热模块 actionCommandService.heatModuleInstallCap(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode);//指定加热模块安装拍子 gantryModuleService.gantryXYMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), capStorageCapClawPoint3D);//移动机械臂至拍子存放区上方 + solutionModuleService.releaseSolutionModule();//释放加液区等待 } finally { - deviceStateService.getDeviceState().getGantryArm().setIdle(true);//机械臂空闲 deviceStateService.getCommandMutexState().get().setMoveToHeatAreaCommandExecuting(false);//该指令结束 - solutionModuleService.releaseSolutionModule();//释放加液区等待 } }); } 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 1d8a847..2a5bf2c 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 @@ -91,7 +91,6 @@ public class MoveToSolutionAreaCommand extends BaseCommandHandler { actionCommandService.heatModuleRemoveTray(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode);//指定加热模块移除托盘 gantryModuleService.gantryXYMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), capStorageCapClawPoint3D);//移动机械臂至拍子存放区上方 } finally { - deviceStateService.getDeviceState().getGantryArm().setIdle(true);//机械臂空闲 deviceStateService.getCommandMutexState().get().setMoveToSolutionAreaCommandExecuting(false);//该指令结束 } }); diff --git a/src/main/java/com/iflytop/gd/app/command/debug/DebugVacuumValveCloseCommand.java b/src/main/java/com/iflytop/gd/app/command/debug/DebugVacuumValveCloseCommand.java index 00fa23b..f513488 100644 --- a/src/main/java/com/iflytop/gd/app/command/debug/DebugVacuumValveCloseCommand.java +++ b/src/main/java/com/iflytop/gd/app/command/debug/DebugVacuumValveCloseCommand.java @@ -7,6 +7,7 @@ import com.iflytop.gd.common.annotation.CommandMapping; import com.iflytop.gd.common.command.CommandFuture; import com.iflytop.gd.common.command.DeviceCommandBundle; import com.iflytop.gd.common.command.DeviceCommandGenerator; +import com.iflytop.gd.common.enums.HeatModuleCode; import com.iflytop.gd.common.utils.CommandUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -26,9 +27,20 @@ public class DebugVacuumValveCloseCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) { - String heatId = cmdDTO.getStringParam("heatId"); - + HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(cmdDTO.getStringParam("heatId")); return runAsync(() -> { + DeviceCommandBundle deviceCommand; + switch (heatModuleCode) { + case heat_module_01 -> deviceCommand = DeviceCommandGenerator.vacuumPumpValve1Open(); + case heat_module_02 -> deviceCommand = DeviceCommandGenerator.vacuumPumpValve2Open(); + case heat_module_03 -> deviceCommand = DeviceCommandGenerator.vacuumPumpValve3Open(); + case heat_module_04 -> deviceCommand = DeviceCommandGenerator.vacuumPumpValve4Open(); + case heat_module_05 -> deviceCommand = DeviceCommandGenerator.vacuumPumpValve5Open(); + case heat_module_06 -> deviceCommand = DeviceCommandGenerator.vacuumPumpValve6Open(); + default -> throw new RuntimeException("index 未找到"); + } + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + CommandUtil.wait(deviceCommandFuture); }); } } diff --git a/src/main/java/com/iflytop/gd/app/command/debug/DebugVacuumValveOpenCommand.java b/src/main/java/com/iflytop/gd/app/command/debug/DebugVacuumValveOpenCommand.java index b584563..0f740c2 100644 --- a/src/main/java/com/iflytop/gd/app/command/debug/DebugVacuumValveOpenCommand.java +++ b/src/main/java/com/iflytop/gd/app/command/debug/DebugVacuumValveOpenCommand.java @@ -7,6 +7,7 @@ import com.iflytop.gd.common.annotation.CommandMapping; import com.iflytop.gd.common.command.CommandFuture; import com.iflytop.gd.common.command.DeviceCommandBundle; import com.iflytop.gd.common.command.DeviceCommandGenerator; +import com.iflytop.gd.common.enums.HeatModuleCode; import com.iflytop.gd.common.utils.CommandUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -26,10 +27,20 @@ public class DebugVacuumValveOpenCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) { - String heatId = cmdDTO.getStringParam("heatId"); - + HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(cmdDTO.getStringParam("heatId")); return runAsync(() -> { - + DeviceCommandBundle deviceCommand; + switch (heatModuleCode) { + case heat_module_01 -> deviceCommand = DeviceCommandGenerator.vacuumPumpValve1Close(); + case heat_module_02 -> deviceCommand = DeviceCommandGenerator.vacuumPumpValve2Close(); + case heat_module_03 -> deviceCommand = DeviceCommandGenerator.vacuumPumpValve3Close(); + case heat_module_04 -> deviceCommand = DeviceCommandGenerator.vacuumPumpValve4Close(); + case heat_module_05 -> deviceCommand = DeviceCommandGenerator.vacuumPumpValve5Close(); + case heat_module_06 -> deviceCommand = DeviceCommandGenerator.vacuumPumpValve6Close(); + default -> throw new RuntimeException("index 未找到"); + } + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + CommandUtil.wait(deviceCommandFuture); }); } } diff --git a/src/main/java/com/iflytop/gd/app/service/api/TrayService.java b/src/main/java/com/iflytop/gd/app/service/api/TrayService.java index 4a48b73..41fa93d 100644 --- a/src/main/java/com/iflytop/gd/app/service/api/TrayService.java +++ b/src/main/java/com/iflytop/gd/app/service/api/TrayService.java @@ -28,7 +28,7 @@ public class TrayService { * 放入了新托盘 */ public synchronized TrayState trayIn() { - if (deviceStateService.getDeviceState().getSolutionModule().getTrayStatus() == 0) { + if (deviceStateService.getDeviceState().getSolutionModule().isIdle()) { TrayState trayState = trayStateObjectProvider.getObject(); trayState.setInSolutionModule(true); TubeState[] tubes = new TubeState[16]; 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 35b8a69..9e818a4 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 @@ -399,16 +399,11 @@ public class CraftsStepService { */ private void moveToHeatModule(HeatModuleCode heatModuleCode) throws Exception { Point3D capStorageCapClawPoint3D = devicePositionService.getPosition(DevicePositionCode.capStorageCapClawPoint).getPoint3D();//获取拍子存放区上方点位; - try { - capModuleService.capUpBalanceNoWait();//提升拍子存放区至拍子夹取的高度 - actionCommandService.moveTrayToHeatModule(heatModuleCode);//将托盘移动至指定加热模块 - actionCommandService.heatModuleInstallCap(heatModuleCode);//指定加热模块安装拍子 - gantryModuleService.gantryXYMove(capStorageCapClawPoint3D);//移动机械臂至拍子存放区上方 - } finally { - deviceStateService.getDeviceState().getGantryArm().setIdle(true);//机械臂空闲 - deviceStateService.getCommandMutexState().get().setMoveToHeatAreaCommandExecuting(false);//该指令结束 - solutionModuleService.releaseSolutionModule();//释放加液区等待 - } + capModuleService.capUpBalanceNoWait();//提升拍子存放区至拍子夹取的高度 + actionCommandService.moveTrayToHeatModule(heatModuleCode);//将托盘移动至指定加热模块 + actionCommandService.heatModuleInstallCap(heatModuleCode);//指定加热模块安装拍子 + gantryModuleService.gantryXYMove(capStorageCapClawPoint3D);//移动机械臂至拍子存放区上方 + solutionModuleService.releaseSolutionModule();//释放加液区等待 } /** @@ -416,16 +411,10 @@ public class CraftsStepService { */ private void moveToSolutionModule(HeatModuleCode heatModuleCode) throws Exception { Point3D capStorageCapClawPoint3D = devicePositionService.getPosition(DevicePositionCode.capStorageCapClawPoint).getPoint3D();//获取拍子存放区上方点位; - - try { - solutionModuleService.requestSolutionModule();//申请使用加液区并等待 - capModuleService.capUpBalanceNoWait(); //提升拍子存放区至拍子夹取的高度 - actionCommandService.heatModuleRemoveCap(heatModuleCode);//指定加热模块移除拍子 - actionCommandService.heatModuleRemoveTray(heatModuleCode);//指定加热模块移除托盘 - gantryModuleService.gantryXYMove(capStorageCapClawPoint3D);//移动机械臂至拍子存放区上方 - } finally { - deviceStateService.getDeviceState().getGantryArm().setIdle(true);//机械臂空闲 - deviceStateService.getCommandMutexState().get().setMoveToSolutionAreaCommandExecuting(false);//该指令结束 - } + solutionModuleService.requestSolutionModule();//申请使用加液区并等待 + capModuleService.capUpBalanceNoWait(); //提升拍子存放区至拍子夹取的高度 + actionCommandService.heatModuleRemoveCap(heatModuleCode);//指定加热模块移除拍子 + actionCommandService.heatModuleRemoveTray(heatModuleCode);//指定加热模块移除托盘 + gantryModuleService.gantryXYMove(capStorageCapClawPoint3D);//移动机械臂至拍子存放区上方 } } diff --git a/src/main/java/com/iflytop/gd/app/service/device/ActionCommandService.java b/src/main/java/com/iflytop/gd/app/service/device/ActionCommandService.java index e3404f9..9692599 100644 --- a/src/main/java/com/iflytop/gd/app/service/device/ActionCommandService.java +++ b/src/main/java/com/iflytop/gd/app/service/device/ActionCommandService.java @@ -58,7 +58,7 @@ public class ActionCommandService { } heatModuleService.heaterMotorMoveNoWait(commandId, command, heatModuleCode, trayLower);//下降加热模块 gantryModuleService.gantryZMoveZero(commandId, command);//抬升z轴 - Thread.sleep(3800); + Thread.sleep(3000); deviceCommandTempUtilService.carryMoveXYToSolutionManyPoints(commandId, command, heatModuleCode, ClawItemType.tray);//携带托盘移动至加液模块 gantryModuleService.gantryXYMove(commandId, command, liquidAreaTrayPoint3D); //将携带托盘的机械臂移动至加液模块上方 deviceCommandTempUtilService.moveTrayHeatModuleAvoidUpNoWait(commandId, command, heatModuleCode);//移动完毕恢复抬升状态 @@ -94,6 +94,7 @@ public class ActionCommandService { deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayUp(1);//将加热模块托盘状态改为抬起 gantryModuleService.clawMove(commandId, command, clawCapPick);//将夹爪打开,准备夹取拍子 gantryModuleService.gantryZMove(heatModuleCapMoveHeight);//下降z轴,使夹爪落入加热模块拍子孔位 + heatModuleService.vacuumValveClose(commandId, command, heatModuleCode); gantryModuleService.clawMove(commandId, command, clawCapGrip);//将夹爪收紧,夹住拍子 deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setCapExist(false);//加热模块是否存在拍子 capModuleService.capMotorMoveByNumNoWait(commandId, command, -1);//拍子存放模块下降1个拍子位置 @@ -134,11 +135,12 @@ public class ActionCommandService { capModuleService.capUpBalanceNoWait(commandId, command); //提升拍子存放区 deviceCommandTempUtilService.moveTrayHeatModuleAvoidUpNoWait(commandId, command, heatModuleCode); - Thread.sleep(3800); + Thread.sleep(3700); gantryModuleService.gantryZMove(heatModuleCapMoveHeight);//下降z轴,使夹拍子落入加热模块 gantryModuleService.clawMove(commandId, command, clawCapPick);//将夹爪打开,释放拍子 deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setCapExist(true);//加热模块是否存在拍子 + heatModuleService.vacuumValveOpen(commandId, command, heatModuleCode); gantryModuleService.gantryZMoveZero(commandId, command);//抬升z轴 } 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 ae37a69..7c1e965 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 @@ -341,7 +341,8 @@ public class DeviceCommandTempUtilService { HeatModuleCode.heat_module_05, HeatModuleCode.heat_module_06); } else if (ClawItemType.tray.equals(clawItemType)) {//移动托盘 - if(deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_05).getTrayStatus() == 1){ + if(deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_05).getTrayStatus() == 1 + || deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_05).getTrayUp() == 1){ //路线 4、1、3、6 points = new Point3D[]{heatArea4TrayClawPoint3D, heatArea1TrayClawPoint3D, heatArea3TrayClawPoint3D, heatArea6TrayClawPoint3D}; //不避让的模块 diff --git a/src/main/java/com/iflytop/gd/app/service/device/module/HeatModuleService.java b/src/main/java/com/iflytop/gd/app/service/device/module/HeatModuleService.java index fcfec0a..ad6b0aa 100644 --- a/src/main/java/com/iflytop/gd/app/service/device/module/HeatModuleService.java +++ b/src/main/java/com/iflytop/gd/app/service/device/module/HeatModuleService.java @@ -37,6 +37,56 @@ public class HeatModuleService { private final DeviceStateService deviceStateService; /** + * 真空泵阀门关闭 + */ + public void vacuumValveClose(HeatModuleCode heatModuleCode) throws Exception { + vacuumValveClose(null, null, heatModuleCode); + } + + /** + * 真空泵阀门关闭 + */ + public void vacuumValveClose(String commandId, String command, HeatModuleCode heatModuleCode) throws Exception { + DeviceCommandBundle deviceCommand; + switch (heatModuleCode) { + case heat_module_01 -> deviceCommand = DeviceCommandGenerator.vacuumPumpValve1Open(); + case heat_module_02 -> deviceCommand = DeviceCommandGenerator.vacuumPumpValve2Open(); + case heat_module_03 -> deviceCommand = DeviceCommandGenerator.vacuumPumpValve3Open(); + case heat_module_04 -> deviceCommand = DeviceCommandGenerator.vacuumPumpValve4Open(); + case heat_module_05 -> deviceCommand = DeviceCommandGenerator.vacuumPumpValve5Open(); + case heat_module_06 -> deviceCommand = DeviceCommandGenerator.vacuumPumpValve6Open(); + default -> throw new RuntimeException("heatModuleCode 未找到"); + } + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(commandId, command, deviceCommand); + CommandUtil.wait(deviceCommandFuture); + } + + /** + * 真空泵阀门开启 + */ + public void vacuumValveOpen(HeatModuleCode heatModuleCode) throws Exception { + vacuumValveOpen(null, null, heatModuleCode); + } + + /** + * 真空泵阀门开启 + */ + public void vacuumValveOpen(String commandId, String command, HeatModuleCode heatModuleCode) throws Exception { + DeviceCommandBundle deviceCommand; + switch (heatModuleCode) { + case heat_module_01 -> deviceCommand = DeviceCommandGenerator.vacuumPumpValve1Close(); + case heat_module_02 -> deviceCommand = DeviceCommandGenerator.vacuumPumpValve2Close(); + case heat_module_03 -> deviceCommand = DeviceCommandGenerator.vacuumPumpValve3Close(); + case heat_module_04 -> deviceCommand = DeviceCommandGenerator.vacuumPumpValve4Close(); + case heat_module_05 -> deviceCommand = DeviceCommandGenerator.vacuumPumpValve5Close(); + case heat_module_06 -> deviceCommand = DeviceCommandGenerator.vacuumPumpValve6Close(); + default -> throw new RuntimeException("heatModuleCode 未找到"); + } + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(commandId, command, deviceCommand); + CommandUtil.wait(deviceCommandFuture); + } + + /** * 加热模块升降电机移动到指定位置 */ public void heaterMotorMoveOrigin(HeatModuleCode heatModuleId) throws Exception { diff --git a/src/main/java/com/iflytop/gd/common/command/DeviceCommandGenerator.java b/src/main/java/com/iflytop/gd/common/command/DeviceCommandGenerator.java index 261e4d8..0194dda 100644 --- a/src/main/java/com/iflytop/gd/common/command/DeviceCommandGenerator.java +++ b/src/main/java/com/iflytop/gd/common/command/DeviceCommandGenerator.java @@ -9,6 +9,90 @@ import com.iflytop.gd.common.enums.command.*; public class DeviceCommandGenerator { /** + * 真空泵阀门 1 开启 + */ + public static DeviceCommandBundle vacuumPumpValve1Open() { + return controlCmd(CmdDevice.vacuum_pump_valve_1, CmdAction.open, null, "真空泵阀门1 开启"); + } + + /** + * 真空泵阀门 2 开启 + */ + public static DeviceCommandBundle vacuumPumpValve2Open() { + return controlCmd(CmdDevice.vacuum_pump_valve_2, CmdAction.open, null, "真空泵阀门2 开启"); + } + + /** + * 真空泵阀门 3 开启 + */ + public static DeviceCommandBundle vacuumPumpValve3Open() { + return controlCmd(CmdDevice.vacuum_pump_valve_3, CmdAction.open, null, "真空泵阀门3 开启"); + } + + /** + * 真空泵阀门 4 开启 + */ + public static DeviceCommandBundle vacuumPumpValve4Open() { + return controlCmd(CmdDevice.vacuum_pump_valve_4, CmdAction.open, null, "真空泵阀门4 开启"); + } + + /** + * 真空泵阀门 5 开启 + */ + public static DeviceCommandBundle vacuumPumpValve5Open() { + return controlCmd(CmdDevice.vacuum_pump_valve_5, CmdAction.open, null, "真空泵阀门5 开启"); + } + + /** + * 真空泵阀门 6 开启 + */ + public static DeviceCommandBundle vacuumPumpValve6Open() { + return controlCmd(CmdDevice.vacuum_pump_valve_6, CmdAction.open, null, "真空泵阀门6 开启"); + } + + /** + * 真空泵阀门 1 关闭 + */ + public static DeviceCommandBundle vacuumPumpValve1Close() { + return controlCmd(CmdDevice.vacuum_pump_valve_1, CmdAction.close, null, "真空泵阀门1 关闭"); + } + + /** + * 真空泵阀门 2 关闭 + */ + public static DeviceCommandBundle vacuumPumpValve2Close() { + return controlCmd(CmdDevice.vacuum_pump_valve_2, CmdAction.close, null, "真空泵阀门2 关闭"); + } + + /** + * 真空泵阀门 3 关闭 + */ + public static DeviceCommandBundle vacuumPumpValve3Close() { + return controlCmd(CmdDevice.vacuum_pump_valve_3, CmdAction.close, null, "真空泵阀门3 关闭"); + } + + /** + * 真空泵阀门 4 关闭 + */ + public static DeviceCommandBundle vacuumPumpValve4Close() { + return controlCmd(CmdDevice.vacuum_pump_valve_4, CmdAction.close, null, "真空泵阀门4 关闭"); + } + + /** + * 真空泵阀门 5 关闭 + */ + public static DeviceCommandBundle vacuumPumpValve5Close() { + return controlCmd(CmdDevice.vacuum_pump_valve_5, CmdAction.close, null, "真空泵阀门5 关闭"); + } + + /** + * 真空泵阀门 6 关闭 + */ + public static DeviceCommandBundle vacuumPumpValve6Close() { + return controlCmd(CmdDevice.vacuum_pump_valve_6, CmdAction.close, null, "真空泵阀门6 关闭"); + } + + /** * 门 移动 */ public static DeviceCommandBundle doorMoveToEnd() { @@ -759,7 +843,6 @@ public class DeviceCommandGenerator { /** * 加液泵 泵1旋转 - * */ public static DeviceCommandBundle acidPump1Rotate(CmdDirection direction) { DeviceCommandParams params = new DeviceCommandParams(); diff --git a/src/main/java/com/iflytop/gd/common/enums/command/CmdDevice.java b/src/main/java/com/iflytop/gd/common/enums/command/CmdDevice.java index d74ed53..c4238cb 100644 --- a/src/main/java/com/iflytop/gd/common/enums/command/CmdDevice.java +++ b/src/main/java/com/iflytop/gd/common/enums/command/CmdDevice.java @@ -37,6 +37,12 @@ public enum CmdDevice { heat_rod_4, heat_rod_5, heat_rod_6, + vacuum_pump_valve_1, + vacuum_pump_valve_2, + vacuum_pump_valve_3, + vacuum_pump_valve_4, + vacuum_pump_valve_5, + vacuum_pump_valve_6, tricolor_light, fill_light, cold_trap, diff --git a/src/main/java/com/iflytop/gd/hardware/command/handlers/IOCtrlHandler.java b/src/main/java/com/iflytop/gd/hardware/command/handlers/IOCtrlHandler.java new file mode 100644 index 0000000..eb9cf7f --- /dev/null +++ b/src/main/java/com/iflytop/gd/hardware/command/handlers/IOCtrlHandler.java @@ -0,0 +1,59 @@ +package com.iflytop.gd.hardware.command.handlers; + +import com.iflytop.gd.common.command.DeviceCommand; +import com.iflytop.gd.common.enums.command.CmdAction; +import com.iflytop.gd.common.enums.command.CmdDevice; +import com.iflytop.gd.hardware.command.CommandHandler; +import com.iflytop.gd.hardware.drivers.DODriver.OutputIOCtrlDriver; +import com.iflytop.gd.hardware.type.IO.OutputIOMId; +import com.iflytop.gd.hardware.type.MId; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +// + +@Slf4j +@Component +@RequiredArgsConstructor +public class IOCtrlHandler extends CommandHandler { + private final OutputIOCtrlDriver driver_; + private final Map supportCmdDeviceIOOutputMap = Map.ofEntries( + Map.entry(CmdDevice.vacuum_pump_valve_3, OutputIOMId.DO_VACUUM_VALVE3), + Map.entry(CmdDevice.vacuum_pump_valve_4, OutputIOMId.DO_VACUUM_VALVE4), + Map.entry(CmdDevice.vacuum_pump_valve_5, OutputIOMId.DO_VACUUM_VALVE5), + Map.entry(CmdDevice.vacuum_pump_valve_6, OutputIOMId.DO_VACUUM_VALVE6) + ); + + private final Map supportCmdDeviceMIdMap = supportCmdDeviceIOOutputMap.entrySet().stream() + .collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().mid)); + + private final Set supportActions = Set.of(CmdAction.open, CmdAction.close); + + @Override + protected Map getSupportCmdDeviceMIdMap() + { + return supportCmdDeviceMIdMap; + } + + @Override + protected Set getSupportActions() { + return supportActions; + } + + @Override + public void handleCommand(DeviceCommand command) throws Exception { + // 发送命令 + if (command.getAction() == CmdAction.open) { + log.info("open {}", command.getDevice()); + driver_.open(supportCmdDeviceIOOutputMap.get(command.getDevice())); + } else if (command.getAction() == CmdAction.close) { + log.info("close {}", command.getDevice()); + driver_.close(supportCmdDeviceIOOutputMap.get(command.getDevice())); + } + } +} diff --git a/src/main/java/com/iflytop/gd/hardware/drivers/CameraBaslerDriver.java b/src/main/java/com/iflytop/gd/hardware/drivers/CameraBaslerDriver.java index 9009fd3..f0c3dd1 100644 --- a/src/main/java/com/iflytop/gd/hardware/drivers/CameraBaslerDriver.java +++ b/src/main/java/com/iflytop/gd/hardware/drivers/CameraBaslerDriver.java @@ -2,6 +2,7 @@ package com.iflytop.gd.hardware.drivers; import com.iflytop.gd.camera.BaslerCameraWrapper; import lombok.extern.slf4j.Slf4j; +import org.opencv.core.Core; import org.opencv.core.CvType; import org.opencv.core.Mat; import org.opencv.imgcodecs.Imgcodecs; @@ -142,7 +143,11 @@ public class CameraBaslerDriver { Mat colorMat = new Mat(); Imgproc.cvtColor(frameMat, colorMat, Imgproc.COLOR_BayerRG2RGB); - Imgcodecs.imwrite(filePath, colorMat); + // 上下镜像翻转:flipCode = 0 + Mat flippedMat = new Mat(); + Core.flip(colorMat, flippedMat, 0); + + Imgcodecs.imwrite(filePath, flippedMat); log.info("彩色图片已保存到: {}", filePath); } } diff --git a/src/main/java/com/iflytop/gd/hardware/type/IO/OutputIOMId.java b/src/main/java/com/iflytop/gd/hardware/type/IO/OutputIOMId.java index 2b3dc2b..20f12d6 100644 --- a/src/main/java/com/iflytop/gd/hardware/type/IO/OutputIOMId.java +++ b/src/main/java/com/iflytop/gd/hardware/type/IO/OutputIOMId.java @@ -11,6 +11,10 @@ public enum OutputIOMId { DO_FAN6("FAN6", MId.IO1_IO, 5,false), DO_TRAY_MOTOR_CLAMP("TRAY_MOTOR_CLAMP [ 托盘电机 ] ", MId.IO1_IO, 6,false), DO_HBOTZ_MOTOR_CLAMP("HBOTZ_MOTOR_CLAMP [ 龙门架Z轴 ] ", MId.IO1_IO, 7,false), + DO_VACUUM_VALVE3("VACUUM_PUMP_VALVE3 [ 真空阀3 ] ", MId.IO1_IO, 8,false), + DO_VACUUM_VALVE4("VACUUM_PUMP_VALVE4 [ 真空阀4 ] ", MId.IO1_IO, 9,false), + DO_VACUUM_VALVE5("VACUUM_PUMP_VALVE5 [ 真空阀5 ] ", MId.IO1_IO, 10,false), + DO_VACUUM_VALVE6("VACUUM_PUMP_VALVE6 [ 真空阀6 ] ", MId.IO1_IO, 11,false), DO_WATER_PUMP("WATER_PUMP [ 水泵 ] ", MId.IO1_IO, 12,false), DO_VENTILATOR("VENTILATOR [ 风机电源 ]", MId.IO1_IO, 13,false), DO_COLD_TRAP_POWER("COLD_TRAP_POWER[ 冷阱 电源 ]", MId.IO1_IO, 14,false),