From dd0ade539587f6dfb8252f4517a2247574a76cc6 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Mon, 29 Jul 2024 18:28:10 +0800 Subject: [PATCH] update --- README.md | 1 + .../java/a8k/appbean/cfg/BottleGroupsPosInfo.java | 8 ++- .../java/a8k/appbean/cfg/LargeBottleBufferPos.java | 11 +--- src/main/java/a8k/canbus/protocol/RegIndex.java | 4 ++ .../a8k/service/hardware/HbotControlService.java | 76 ++++++++++++++++++---- 5 files changed, 76 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 40b253e..5ea5fdc 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ TODO: 1. 数据库文件是否被破坏检查 2. 数据库文件如果被破坏,自动恢复默认配置 + 3. 添加归零保护,底层检测,如果电机未归零就执行moveTo,则报错。 坐标XY方向约定: 0 -----------------------> diff --git a/src/main/java/a8k/appbean/cfg/BottleGroupsPosInfo.java b/src/main/java/a8k/appbean/cfg/BottleGroupsPosInfo.java index 096bbbd..628b14a 100644 --- a/src/main/java/a8k/appbean/cfg/BottleGroupsPosInfo.java +++ b/src/main/java/a8k/appbean/cfg/BottleGroupsPosInfo.java @@ -4,9 +4,9 @@ import a8k.utils.HbotScanerPosComputer; public class BottleGroupsPosInfo { - static public Integer cgetMAX_GROUP_COL() {return 2;} + static public Integer cgetMAX_GROUP_COL() {return 3;} - static public Integer cgetMAX_GROUP_ROW() {return 3;} + static public Integer cgetMAX_GROUP_ROW() {return 2;} static public Integer cgetMAX_GROUP() {return cgetMAX_GROUP_COL() * cgetMAX_GROUP_ROW();} @@ -17,6 +17,8 @@ public class BottleGroupsPosInfo { public Pos2d scanCodeRelaPos; //扫码相对位置 + public Integer posTestZ; + public BottlesPosInfo smallBottleBufferPos; //小瓶缓冲液位置信息 public BottlesPosInfo detectMaterialPos; //探测物质位置信息 @@ -36,6 +38,7 @@ public class BottleGroupsPosInfo { Integer groupXSpacing, Integer groupYSpacing, Pos2d scanCodeRelaPos, + Integer posTestZ, BottlesPosInfo smallBottleBufferPos, BottlesPosInfo detectMaterialPos) { this.topLelf = topLelf; @@ -44,6 +47,7 @@ public class BottleGroupsPosInfo { this.scanCodeRelaPos = scanCodeRelaPos; this.smallBottleBufferPos = smallBottleBufferPos; this.detectMaterialPos = detectMaterialPos; + this.posTestZ = posTestZ; } Pos2d cgetTopLelf(Integer group) { diff --git a/src/main/java/a8k/appbean/cfg/LargeBottleBufferPos.java b/src/main/java/a8k/appbean/cfg/LargeBottleBufferPos.java index 5f84810..68c945b 100644 --- a/src/main/java/a8k/appbean/cfg/LargeBottleBufferPos.java +++ b/src/main/java/a8k/appbean/cfg/LargeBottleBufferPos.java @@ -14,8 +14,7 @@ public class LargeBottleBufferPos { public Integer ySpacing; //y间隔 public Integer scancodeRelaPos; //扫码相对每个大屏缓冲液的位置,第一排 -dy,第二排dy - public Integer sampleZPos; //取样开始位置 - public Integer sampleZDepth; //取样深度 + public Integer cgetCOL() { return 3; @@ -34,17 +33,13 @@ public class LargeBottleBufferPos { xSpacing = 0; ySpacing = 0; scancodeRelaPos = 0; - sampleZPos = 0; - sampleZDepth = 0; } - public LargeBottleBufferPos(Pos2d topLelf, Integer xSpacing, Integer ySpacing, Integer relaPos, Integer sampleZPos, Integer sampleZDepth) { + public LargeBottleBufferPos(Pos2d topLelf, Integer xSpacing, Integer ySpacing, Integer scancodeRelaPos) { this.topLelf = topLelf; this.xSpacing = xSpacing; this.ySpacing = ySpacing; - this.scancodeRelaPos = 0; - this.sampleZPos = sampleZPos; - this.sampleZDepth = sampleZDepth; + this.scancodeRelaPos = scancodeRelaPos; } public Pos2d cgetBottlePos(Integer bottleIndex) { diff --git a/src/main/java/a8k/canbus/protocol/RegIndex.java b/src/main/java/a8k/canbus/protocol/RegIndex.java index 8c838d2..f7c288d 100644 --- a/src/main/java/a8k/canbus/protocol/RegIndex.java +++ b/src/main/java/a8k/canbus/protocol/RegIndex.java @@ -10,6 +10,8 @@ public enum RegIndex { kreg_module_status(2), // 0idle,1busy,2error kreg_module_errorcode(3), // inited_flag + kreg_extboard_resetflag(100), + /*********************************************************************************************************************** * 水冷温度控制器 * ***********************************************************************************************************************/ @@ -80,6 +82,7 @@ public enum RegIndex { ***********************************************************************************************************************/ kreg_xyrobot_io_state(9900, false), // + kreg_xyrobot_is_enable(9901), // kreg_xyrobot_robot_type(9950), // kreg_xyrobot_one_circle_pulse(9951), // kreg_xyrobot_one_circle_pulse_denominator(9952), // @@ -116,6 +119,7 @@ public enum RegIndex { ***********************************************************************************************************************/ kreg_step_motor_pos(10101), // 机器人x坐标 + kreg_step_motor_is_enable(10102), // 是否使能 kreg_step_motor_dpos(10103), // 执行完上一条指令后的相对位移 kreg_step_motor_shift(10150), // x偏移 kreg_step_motor_shaft(10151), // x轴是否反转 diff --git a/src/main/java/a8k/service/hardware/HbotControlService.java b/src/main/java/a8k/service/hardware/HbotControlService.java index a93db4f..9e2f85e 100644 --- a/src/main/java/a8k/service/hardware/HbotControlService.java +++ b/src/main/java/a8k/service/hardware/HbotControlService.java @@ -108,6 +108,7 @@ public class HbotControlService implements HardwareCtrlModule { 1230, 1250, new Pos2d(579, 1097), + 283, new BottlesPosInfo/*大孔*/( new Pos2d(160, 160), 210, @@ -137,12 +138,10 @@ public class HbotControlService implements HardwareCtrlModule { public LargeBottleBufferPos getLargeBottleBufferPosInfo() { return settingReader.getObject("LargeBottleBufferPosInfo", LargeBottleBufferPos.class, new LargeBottleBufferPos( - new Pos2d(4583, 1363), + new Pos2d(4594, 1350), 280, 280, - 0, - 0, - 0 + 165 )); } @@ -182,6 +181,14 @@ public class HbotControlService implements HardwareCtrlModule { throw new HardwareException(A8kEcode.PlateBoxNotCover); } + boolean zEnable = true; + boolean hbotEnable = canBus.moduleGetReg(MId.HbotM, RegIndex.kreg_xyrobot_is_enable) == 1; + if (canBus.moduleGetReg(MId.PipetteModZM, RegIndex.kreg_step_motor_is_enable) == 0) { + canBus.stepMotorEnable(MId.PipetteModZM, 1); + canBus.stepMotorEasyMoveToZeroBlock(MId.PipetteModZM, getActionOvertime()); + zEnable = false; + } + //Z轴归零 if (!getZPPS()) { canBus.stepMotorEnable(MId.PipetteModZM, 1); @@ -212,6 +219,8 @@ public class HbotControlService implements HardwareCtrlModule { canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PipetteModZM, getActionOvertime()); zMoveTo(targetPos.z); } + canBus.stepMotorEnable(MId.PipetteModZM, zEnable ? 1 : 0); + canBus.hbotEnable(MId.HbotM, hbotEnable ? 1 : 0); } @@ -323,17 +332,31 @@ public class HbotControlService implements HardwareCtrlModule { @HardwareServiceAction(name = "HBot移动到小瓶缓冲液X孔", group = "单步测试") public void hbotMoveToSmallBottleGroup(ConsumableGroup group, Integer Xhole) throws HardwareException, InterruptedException { BottleGroupsPosInfo posInfo = getBottleBufferPosInfo(); - Pos2d pos = posInfo.cgetSmallBottleBufferPos(group.off, Xhole); + if (Xhole < 0 || Xhole > BottlesPosInfo.cgetMAX()) { + throw new HardwareException(A8kEcode.ParamOutOfRange); + } + Pos2d pos = posInfo.cgetSmallBottleBufferPos(group.off, Xhole); hbotCheckAndMoveTo(pos); } + + @HardwareServiceAction(name = "HBot移动到探测物质X孔", group = "单步测试") public void hbotMoveToDetectMaterialPos(ConsumableGroup group, Integer Xhole) throws HardwareException, InterruptedException { BottleGroupsPosInfo posInfo = getBottleBufferPosInfo(); - Pos2d pos = posInfo.cgetDetectMaterialPos(group.off, Xhole); + if (Xhole < 0 || Xhole > BottlesPosInfo.cgetMAX()) { + throw new HardwareException(A8kEcode.ParamOutOfRange); + } + Pos2d pos = posInfo.cgetDetectMaterialPos(group.off, Xhole); hbotCheckAndMoveTo(pos); } + @HardwareServiceAction(name = "HBot移动到大瓶缓冲液X孔", group = "单步测试") + public void hbotMoveToLargeBottleGroup(ConsumableGroup ch) throws HardwareException, InterruptedException { + LargeBottleBufferPos posInfo = getLargeBottleBufferPosInfo(); + Pos2d pos = posInfo.cgetBottlePos( ch.off); + hbotCheckAndMoveTo(pos); + } // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // 坐标获取工具 @@ -447,14 +470,14 @@ public class HbotControlService implements HardwareCtrlModule { // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // 测试 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - Boolean testTakeTipFlag; + Boolean testScriptWorkFlag = false; @HardwareServiceAction(name = "取放Tip", group = "测试脚本") - public AppRet takeTipTestStep(Integer groupId, Integer index) throws HardwareException, InterruptedException { - var ret = takeTip(groupId, index); + public AppRet takeTipTestStep(Integer tipgroup, Integer index) throws HardwareException, InterruptedException { + var ret = takeTip(tipgroup, index); TipPickUpPosInfo tipPos = getTipPickUpPosInfo(); - canBus.stepMotorEasyMoveToBlock(MId.PipetteModZM, tipPos.getPickUpZPos(groupId) - 100, getActionOvertime()); + canBus.stepMotorEasyMoveToBlock(MId.PipetteModZM, tipPos.getPickUpZPos(tipgroup) - 100, getActionOvertime()); canBus.pipetteCtrlPutTipBlock(MId.PipetteMod); if (canBus.moduleGetReg(MId.PipetteMod, RegIndex.kreg_pipette_tip_state) == 1) { @@ -468,7 +491,7 @@ public class HbotControlService implements HardwareCtrlModule { @HardwareServiceAction(name = "取全部Tip", group = "测试脚本") public AppRet> testTakeAllTip(Integer groupId, Integer startFrom) throws HardwareException, InterruptedException { // ObjectMapper mapper = new ObjectMapper(); - testTakeTipFlag = true; + testScriptWorkFlag = true; Map result = new HashMap<>(); for (int i = startFrom; i < TipPickUpPosInfo.cgetTipNum(); i++) { var ret = takeTipTestStep(groupId, i); @@ -478,17 +501,42 @@ public class HbotControlService implements HardwareCtrlModule { result.put("Tip" + i, ret.getData() ? "suc" : "fail"); logger.info("Take Tip {}-{} => {}", groupId, i, ret.getData()); - if (!testTakeTipFlag) { + if (!testScriptWorkFlag) { break; } } return AppRet.success(result); } + @HardwareServiceAction(name = "测试所有小瓶缓冲液位置", group = "测试脚本") + public void testAllLittleBottleBufferPos(ConsumableGroup group) throws HardwareException, InterruptedException { + testScriptWorkFlag = true; + BottleGroupsPosInfo posInfo = getBottleBufferPosInfo(); + for (int i = 0; i < BottlesPosInfo.cgetMAX(); i++) { + Pos2d pos = posInfo.cgetSmallBottleBufferPos(group.off, i); + hbotCheckAndMoveTo(new Pos3d(pos.x, pos.y, posInfo.posTestZ)); + if (!testScriptWorkFlag) { + break; + } + } + } + + @HardwareServiceAction(name = "测试所有探测物质位置", group = "测试脚本") + public void testAllDetectMaterialPos(ConsumableGroup group) throws HardwareException, InterruptedException { + testScriptWorkFlag = true; + BottleGroupsPosInfo posInfo = getBottleBufferPosInfo(); + for (int i = 0; i < BottlesPosInfo.cgetMAX(); i++) { + Pos2d pos = posInfo.cgetDetectMaterialPos(group.off, i); + hbotCheckAndMoveTo(new Pos3d(pos.x, pos.y, posInfo.posTestZ)); + if (!testScriptWorkFlag) { + break; + } + } + } - @HardwareServiceAction(name = "停止取全部Tip", group = "测试脚本") + @HardwareServiceAction(name = "停止测试脚本", group = "测试脚本") public void testTakeAllTipStop() throws HardwareException, InterruptedException { - testTakeTipFlag = false; + testScriptWorkFlag = false; }