From ddaa89adbacde6cf1555d5c80adb9e31b9f923bf Mon Sep 17 00:00:00 2001 From: zhaohe Date: Mon, 29 Jul 2024 13:26:24 +0800 Subject: [PATCH] update --- .../java/a8k/appbean/cfg/TipPickUpPosInfo.java | 13 +++-- src/main/java/a8k/canbus/A8kCanBusService.java | 15 ++++- .../a8k/service/hardware/HbotControlService.java | 64 ++++++++++++---------- 3 files changed, 59 insertions(+), 33 deletions(-) diff --git a/src/main/java/a8k/appbean/cfg/TipPickUpPosInfo.java b/src/main/java/a8k/appbean/cfg/TipPickUpPosInfo.java index 73593f4..888c434 100644 --- a/src/main/java/a8k/appbean/cfg/TipPickUpPosInfo.java +++ b/src/main/java/a8k/appbean/cfg/TipPickUpPosInfo.java @@ -11,8 +11,11 @@ public class TipPickUpPosInfo { public Integer pickUpZPos; //拾取高度 - final public static Integer ROW_MAX = 10; - final public static Integer COL_MAX = 12; + static public Integer cgetTipNum() {return 12 * 10;} + + static public Integer cgetCOL_MAX() {return 12;} + + static public Integer cgetROW_MAX() {return 10;} public TipPickUpPosInfo() { g0tl = new Pos2d(0, 0); @@ -48,10 +51,12 @@ public class TipPickUpPosInfo { int row; //行 int col; //列 - row = index / COL_MAX; - col = index % COL_MAX; + row = index / cgetCOL_MAX(); + col = index % cgetCOL_MAX(); Pos2d topleft = getTopLeft(group); return new Pos2d((int) (topleft.x + col * xSpacing), (int) (topleft.y + row * ySpacing)); } + + } diff --git a/src/main/java/a8k/canbus/A8kCanBusService.java b/src/main/java/a8k/canbus/A8kCanBusService.java index 42b263c..efffc37 100644 --- a/src/main/java/a8k/canbus/A8kCanBusService.java +++ b/src/main/java/a8k/canbus/A8kCanBusService.java @@ -672,7 +672,7 @@ public class A8kCanBusService { } while (true); } - public Boolean getIOState(IOId ioid) throws HardwareException { + public Boolean priGetIOState(IOId ioid) throws HardwareException { if (ioid.mtype == ModuleType.kboard) { return callcmd(ioid.mid.toInt(), CmdId.extboard_read_inio.toInt(), ioid.ioIndex).getContentI32(0) != 0; } else if (ioid.mtype == ModuleType.ktmc_step_motor) { @@ -684,6 +684,19 @@ public class A8kCanBusService { } } + public Boolean getIOState(IOId ioid) throws HardwareException { + while (true) { + Boolean firstReadIO = priGetIOState(ioid); + Boolean secondReadIO = priGetIOState(ioid); + if(firstReadIO == secondReadIO){ + return firstReadIO; + }else{ + logger.warn("getIOState {} not match, retry", ioid); + } + } + } + + public void setIOState(IOId ioid, boolean val) throws HardwareException { if (ioid.mtype == ModuleType.kboard) { callcmd(ioid.mid.toInt(), CmdId.extboard_write_outio.toInt(), ioid.ioIndex, val ? 1 : 0); diff --git a/src/main/java/a8k/service/hardware/HbotControlService.java b/src/main/java/a8k/service/hardware/HbotControlService.java index 3c25e05..c701274 100644 --- a/src/main/java/a8k/service/hardware/HbotControlService.java +++ b/src/main/java/a8k/service/hardware/HbotControlService.java @@ -1,6 +1,7 @@ package a8k.service.hardware; import a8k.appbean.HardwareException; +import a8k.appbean.PlateBoxCh; import a8k.appbean.cfg.*; import a8k.appbean.ecode.AppRet; import a8k.canbus.A8kCanBusService; @@ -284,7 +285,7 @@ public class HbotControlService implements HardwareCtrlModule { throw new HardwareException(A8kEcode.ParamOutOfRange); } - if (index > TipPickUpPosInfo.ROW_MAX * TipPickUpPosInfo.COL_MAX || index < 0) { + if (index > TipPickUpPosInfo.cgetTipNum() || index < 0) { throw new HardwareException(A8kEcode.ParamOutOfRange); } @@ -337,13 +338,44 @@ public class HbotControlService implements HardwareCtrlModule { return AppRet.success(canBus.stepMotorReadPosByMoveToZeroBlock(MId.PipetteModZM, getActionOvertime())); } + // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // hbot移动到并扫码 + // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + private AppRet hBotMoveToAndScan(Pos2d pos) throws HardwareException, InterruptedException { + hbotCheckAndMoveTo(pos); + canBus.codeScanerStartScan(MId.PipetteModCodeScanner); + String result = canBus.codeScanerWaittingForResult(MId.PipetteModCodeScanner, getScancodeOvertime()); + return AppRet.success(result); + } + + //扫描板夹仓二维码 + public AppRet scanPlatesCode(PlateBoxCh ch) throws HardwareException, InterruptedException { + var posInfo = getPlates2dCodeScanPosInfo(); + return hBotMoveToAndScan(new Pos2d(posInfo.ch0ScanPos.x, posInfo.ch0ScanPos.y + posInfo.scanYSpacing * ch.off)); + } + + //扫描小缓冲液二维码 + public AppRet scanSmallBottleBufferCode(Integer group) { + var posInfo = getSmallBottleBufferPosInfo(); + + + return null; + } + + //扫描大缓冲液二维码 + public String scanBigBottleBufferCode(Integer index) { + return ""; + } + // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // 测试 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Boolean testTakeTipFlag; - private AppRet takeTipTestStep(Integer groupId, Integer index) throws HardwareException, InterruptedException { + @HardwareServiceAction(name = "取放Tip", group = "测试脚本") + public AppRet takeTipTestStep(Integer groupId, Integer index) throws HardwareException, InterruptedException { var ret = takeTip(groupId, index); TipPickUpPosInfo tipPos = getTipPickUpPosInfo(); @@ -358,7 +390,7 @@ public class HbotControlService implements HardwareCtrlModule { // ObjectMapper mapper = new ObjectMapper(); testTakeTipFlag = true; Map result = new HashMap<>(); - for (int i = startFrom; i < TipPickUpPosInfo.COL_MAX * TipPickUpPosInfo.ROW_MAX; i++) { + for (int i = startFrom; i < TipPickUpPosInfo.cgetTipNum(); i++) { var ret = takeTipTestStep(groupId, i); result.put("Tip" + i, ret.getData() ? "suc" : "fail"); logger.info("Take Tip {}-{} => {}", groupId, i, ret.getData()); @@ -369,37 +401,13 @@ public class HbotControlService implements HardwareCtrlModule { return AppRet.success(result); } + @HardwareServiceAction(name = "停止取全部Tip", group = "测试脚本") public void testTakeAllTipStop() throws HardwareException, InterruptedException { testTakeTipFlag = false; } - private AppRet hBotMoveToAndScan(Pos2d pos) throws HardwareException, InterruptedException { - hbotMoveTo(pos.x, pos.y); - canBus.codeScanerStartScan(MId.PipetteModCodeScanner); - String result = canBus.codeScanerWaittingForResult(MId.PipetteModCodeScanner, getScancodeOvertime()); - return AppRet.success(result); - } - - //扫描板夹仓二维码 - public AppRet scanPlatesCode(Integer index) throws HardwareException, InterruptedException { - var posInfo = getPlates2dCodeScanPosInfo(); - return hBotMoveToAndScan(new Pos2d(posInfo.ch0ScanPos.x, posInfo.ch0ScanPos.y + posInfo.scanYSpacing * index)); - } - - //扫描小缓冲液二维码 - public AppRet scanSmallBottleBufferCode(Integer index) { - - - return null; - } - - //扫描大缓冲液二维码 - public String scanBigBottleBufferCode(Integer index) { - return ""; - } - //在试管架的位置取样品 public boolean takeSampleFromPos0(Integer ul) { return false;