diff --git a/src/main/java/a8k/appbean/cfg/BottleGroupsPosInfo.java b/src/main/java/a8k/appbean/cfg/BottleGroupsPosInfo.java index 0d928b3..096bbbd 100644 --- a/src/main/java/a8k/appbean/cfg/BottleGroupsPosInfo.java +++ b/src/main/java/a8k/appbean/cfg/BottleGroupsPosInfo.java @@ -62,12 +62,13 @@ public class BottleGroupsPosInfo { return HbotScanerPosComputer.getScanPos(new Pos2d(topLelf.x + scanCodeRelaPos.x, topLelf.y + scanCodeRelaPos.y)); } - Pos2d cgetSamllBottlePos(Integer group, Integer bottleIndex) { + + public Pos2d cgetSmallBottleBufferPos(Integer group, Integer bottleIndex) { Pos2d topLelf = cgetTopLelf(group); return smallBottleBufferPos.cgetBotPos(topLelf, bottleIndex); } - Pos2d cgetDetectMaterialPos(Integer group, Integer bottleIndex) { + public Pos2d cgetDetectMaterialPos(Integer group, Integer bottleIndex) { Pos2d topLelf = cgetTopLelf(group); return detectMaterialPos.cgetBotPos(topLelf, bottleIndex); } diff --git a/src/main/java/a8k/appbean/cfg/Pos3d.java b/src/main/java/a8k/appbean/cfg/Pos3d.java index 23c24a9..0975e6a 100644 --- a/src/main/java/a8k/appbean/cfg/Pos3d.java +++ b/src/main/java/a8k/appbean/cfg/Pos3d.java @@ -17,4 +17,8 @@ public class Pos3d { public Pos2d getXYPos() { return new Pos2d(x, y); } + + public String toString() { + return String.format("(%d, %d, %d)", x, y, z); + } } diff --git a/src/main/java/a8k/service/hardware/HbotControlService.java b/src/main/java/a8k/service/hardware/HbotControlService.java index 6f1a9a7..a93db4f 100644 --- a/src/main/java/a8k/service/hardware/HbotControlService.java +++ b/src/main/java/a8k/service/hardware/HbotControlService.java @@ -107,15 +107,15 @@ public class HbotControlService implements HardwareCtrlModule { new Pos2d(741, 937), 1230, 1250, - new Pos2d(577, 1097), + new Pos2d(579, 1097), new BottlesPosInfo/*大孔*/( - new Pos2d(175, 175), + new Pos2d(160, 160), 210, 210, 0 ), new BottlesPosInfo/*小孔*/( - new Pos2d(220, 220), + new Pos2d(215, 205), 187, 187, 0 @@ -177,13 +177,17 @@ public class HbotControlService implements HardwareCtrlModule { * @throws InterruptedException e */ private void hbotCheckAndMoveTo(Pos3d targetPos) throws HardwareException, InterruptedException { + logger.info("hbotCheckAndMoveTo:{}", targetPos); if (!canBus.getIOState(IOId.PlateBoxCoverClosurePPS)) { throw new HardwareException(A8kEcode.PlateBoxNotCover); } //Z轴归零 - canBus.stepMotorEnable(MId.PipetteModZM, 1); - canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PipetteModZM, getActionOvertime()); + if (!getZPPS()) { + canBus.stepMotorEnable(MId.PipetteModZM, 1); + canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PipetteModZM, getActionOvertime()); + } + if (!getZPPS()) { throw new HardwareException(A8kEcode.ZMNotAtZPosWhenHbotTryMove); @@ -203,8 +207,11 @@ public class HbotControlService implements HardwareCtrlModule { canBus.hbotMoveToBlock(MId.HbotM, targetPos.x, targetPos.y, getActionOvertime()); //Z轴移动 - if (targetPos.z != 0) + if (targetPos.z != 0) { + canBus.stepMotorEnable(MId.PipetteModZM, 1); + canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PipetteModZM, getActionOvertime()); zMoveTo(targetPos.z); + } } @@ -313,6 +320,20 @@ public class HbotControlService implements HardwareCtrlModule { hbotCheckAndMoveTo(new Pos2d(x, y)); } + @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); + 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); + hbotCheckAndMoveTo(pos); + } + // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // 坐标获取工具 @@ -352,6 +373,14 @@ public class HbotControlService implements HardwareCtrlModule { } } + Pos2d hbotRefPos = new Pos2d(0, 0); + + @HardwareServiceAction(name = "设置HBOT参考坐标", group = "坐标获取工具") + public void openCodeScaner(Integer x, Integer y) throws HardwareException, InterruptedException { + hbotRefPos.x = x; + hbotRefPos.y = y; + } + // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // hbot移动到并扫码 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -489,5 +518,12 @@ public class HbotControlService implements HardwareCtrlModule { return pos.toString(); } + @HardwareServiceStatus(name = "HbotRelaPos") + public String getHbotRelaPos() throws HardwareException { + Pos2d pos = canBus.hbotReadPos(MId.HbotM); + pos.x -= hbotRefPos.x; + pos.y -= hbotRefPos.y; + return pos.toString(); + } }