From 78d439e12681d118498172a781621898f5bee696 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Tue, 31 Dec 2024 14:08:08 +0800 Subject: [PATCH] update --- .../service/lowerctrl/TubeFeedingCtrlService.java | 17 +- .../java/a8k/extui/mgr/ExtApiPageGroupCfgMgr.java | 1 + .../pos_calibration/HbotSamplePosCalibration.java | 153 ---------------- .../HbotSamplePosCalibration.java | 199 +++++++++++++++++++++ 4 files changed, 215 insertions(+), 155 deletions(-) delete mode 100644 src/main/java/a8k/extui/page/pos_calibration/HbotSamplePosCalibration.java create mode 100644 src/main/java/a8k/extui/page/pos_calibration_h/HbotSamplePosCalibration.java diff --git a/src/main/java/a8k/app/service/lowerctrl/TubeFeedingCtrlService.java b/src/main/java/a8k/app/service/lowerctrl/TubeFeedingCtrlService.java index f9842ce..26272c9 100644 --- a/src/main/java/a8k/app/service/lowerctrl/TubeFeedingCtrlService.java +++ b/src/main/java/a8k/app/service/lowerctrl/TubeFeedingCtrlService.java @@ -1,6 +1,7 @@ package a8k.app.service.lowerctrl; import a8k.OS; +import a8k.app.a8ktype.device.A8kTubeHolderType; import a8k.app.hardware.driver.CodeScanerDriver; import a8k.app.hardware.driver.MiniServoDriver; import a8k.app.hardware.driver.StepMotorCtrlDriver; @@ -209,6 +210,13 @@ public class TubeFeedingCtrlService { return null; } logger.info("扫描试管架类型成功,{}", tubeType); + A8kTubeHolderType tubeHolderType = A8kTubeHolderType.of(tubeType); + if (tubeHolderType == null) { + logger.error("试管架类型不支持"); + ebus.pushEvent(new AppWarningNotifyEvent(A8kEcode.APPE_TUBE_HOLDER_TYPE_IS_NOT_SUPPORT)); + return null; + } + //逐个扫描试管 TubesScanResult[] tubesScanResult = new TubesScanResult[10]; boolean hasTube = false; @@ -218,8 +226,13 @@ public class TubeFeedingCtrlService { if (isTubeExist) { hasTube = true; tubesScanResult[i].isTubeExist = true; - tubesScanResult[i].isHighTube = moveAndJudgeTubeAltit(i); - tubesScanResult[i].tubeCode = moveTubeToScanPosAndScan(i); + if (tubeHolderType == A8kTubeHolderType.BloodTube) { + tubesScanResult[i].isHighTube = moveAndJudgeTubeAltit(i); + tubesScanResult[i].tubeCode = moveTubeToScanPosAndScan(i); + } else { + tubesScanResult[i].isHighTube = false; + tubesScanResult[i].tubeCode = ""; + } } else { tubesScanResult[i].isTubeExist = false; } diff --git a/src/main/java/a8k/extui/mgr/ExtApiPageGroupCfgMgr.java b/src/main/java/a8k/extui/mgr/ExtApiPageGroupCfgMgr.java index 29c8798..db0fe4a 100644 --- a/src/main/java/a8k/extui/mgr/ExtApiPageGroupCfgMgr.java +++ b/src/main/java/a8k/extui/mgr/ExtApiPageGroupCfgMgr.java @@ -16,6 +16,7 @@ import a8k.extui.page.frond_end_test.FakeReactionRecordGeneratorPage; import a8k.extui.page.frond_end_test.VirtualEventGeneratorPage; import a8k.extui.page.opt_calibration.OptModuleParamCalibration; +import a8k.extui.page.pos_calibration_h.HbotSamplePosCalibration; import a8k.extui.page.stress_test.PipetteGunStressTest; import a8k.extui.page.verification.P01PipetteGunVerification; import a8k.extui.page.verification.P02A8kTemperaturaVerfication; diff --git a/src/main/java/a8k/extui/page/pos_calibration/HbotSamplePosCalibration.java b/src/main/java/a8k/extui/page/pos_calibration/HbotSamplePosCalibration.java deleted file mode 100644 index 9fd5d2a..0000000 --- a/src/main/java/a8k/extui/page/pos_calibration/HbotSamplePosCalibration.java +++ /dev/null @@ -1,153 +0,0 @@ -package a8k.extui.page.pos_calibration; - - -import a8k.extui.mgr.ExtApiPageMgr; -import a8k.app.service.lowerctrl.TubePreProcesModuleExCtrlService; -import a8k.app.service.lowerctrl.HbotMoveCtrlService; -import a8k.app.hardware.extdriver.MotorMoveZeroExDriver; -import a8k.app.a8ktype.param.HbotSamplePos; -import a8k.app.hardware.driver.HbotDriver; -import a8k.app.hardware.driver.PipetteCtrlDriver; -import a8k.app.service.lowerctrl.HbotMoveExCtrlService; -import a8k.app.hardware.driver.StepMotorCtrlDriver; -import a8k.app.hardware.driver.type.StepMotorMId; -import a8k.app.hardware.extdriver.MotorEnableExDriver; -import a8k.app.service.lowerctrl.TubePreProcesModuleCtrlService; -import a8k.app.service.param.HbotSamplePosParamMgr; -import a8k.app.a8ktype.device.Pos2d; -import a8k.app.a8ktype.device.Pos3d; -import a8k.app.a8ktype.exception.AppException; -import jakarta.annotation.PostConstruct; -import jakarta.annotation.Resource; -import lombok.extern.slf4j.Slf4j; -import org.slf4j.Logger; -import org.springframework.stereotype.Component; - -@Component -@Slf4j -public class HbotSamplePosCalibration { - static Logger logger = org.slf4j.LoggerFactory.getLogger(HbotSamplePosCalibration.class); - - @Resource - PipetteCtrlDriver pipetteCtrlDriver; - @Resource - MotorEnableExDriver motorEnableExDriver; - @Resource - HbotDriver hbotDriver; - @Resource - TubePreProcesModuleCtrlService tubePreProcesModuleCtrlService; - @Resource - HbotMoveCtrlService hbotMoveCtrlService; - @Resource - TubePreProcesModuleExCtrlService tubePreProcesCtrlService; - @Resource - MotorMoveZeroExDriver motorMoveZeroExDriver; - - - @Resource - HbotMoveExCtrlService hbotMoveExCtrlService; - @Resource - HbotSamplePosParamMgr hbotSamplePosParamMgr; - - - @Resource - StepMotorCtrlDriver stepMotorCtrlDriver; - - - public Object getPoss() throws AppException { - return hbotSamplePosParamMgr.getParams(); - } - - // 测试工具 - - public void moveToZero() throws AppException { - enableModule(); - - motorEnableExDriver.preProcessRelatedModuleEnable(true); - // motorEnableExDriver.tubeFeedRelatedModuleEnable(true); - - motorMoveZeroExDriver.preProcessModuleMoveToZero(); - pipetteCtrlDriver.zMotorMoveZeroBlock(); - hbotMoveCtrlService.moveToZero(); - // motorMoveZeroExDriver.tubeFeeddingModuleMoveToZero(); - } - - - public void enableModule() throws AppException { - pipetteCtrlDriver.zMotorEnable(1); - hbotMoveCtrlService.enable(1); - } - - - public void disableModule() throws AppException { - stepMotorCtrlDriver.stepMotorEnable(StepMotorMId.ShakeModClampingM, 1); - stepMotorCtrlDriver.stepMotorEasyMoveByBlock(StepMotorMId.ShakeModClampingM, 10, 3000); - - pipetteCtrlDriver.zMotorEnable(0); - hbotMoveCtrlService.enable(0); - motorEnableExDriver.forceDisableAllMotor(); - } - - - - public void takeTubeToShakePos(Boolean isHtube) throws AppException { - tubePreProcesCtrlService.takeTubeFromTubeholderToShakePos(isHtube); - tubePreProcesCtrlService.takeTubeCap(); - } - - - // - // 标定Z轴 - // - public Pos3d readPos() throws AppException { - enableModule(); - Pos2d xypos = hbotDriver.readPos(); - pipetteCtrlDriver.zMotorMeasureDistance(); - Integer z = pipetteCtrlDriver.zMotorReadMeasureDistanceResult(); - Pos3d var = new Pos3d(xypos.x, xypos.y, z); - disableModule(); - return var; - } - - - public void calibrationSamplePos(HbotSamplePos posType) throws AppException { - Pos3d pos3d = readPos(); - hbotSamplePosParamMgr.setSamplePos(posType, pos3d); - } - - // - // 校验 - // - - public void testSamplePos(HbotSamplePos posType) throws AppException { - hbotMoveExCtrlService.moveToSamplePos(posType); - } - - @Resource - ExtApiPageMgr extApiPageMgr; - - @PostConstruct - public void init() { - var page = extApiPageMgr.newPage(this); - - page.newGroup("基础"); - page.addFunction("获取坐标", this::getPoss); - - page.newGroup("测试工具"); - page.addFunction("归零", this::moveToZero); - page.addFunction("使能相关模块", this::enableModule); - page.addFunction("失能相关模块", this::disableModule); - - page.newGroup("辅助工具"); - page.addFunction("取试管到试管摇匀位", this::takeTubeToShakePos); - - page.newGroup("标定"); - page.addFunction("校准.采样位置", this::calibrationSamplePos); - - page.newGroup("校验"); - page.addFunction("校验坐标", this::testSamplePos); - - extApiPageMgr.addPage(page); - } - -} diff --git a/src/main/java/a8k/extui/page/pos_calibration_h/HbotSamplePosCalibration.java b/src/main/java/a8k/extui/page/pos_calibration_h/HbotSamplePosCalibration.java new file mode 100644 index 0000000..a2dcf95 --- /dev/null +++ b/src/main/java/a8k/extui/page/pos_calibration_h/HbotSamplePosCalibration.java @@ -0,0 +1,199 @@ +package a8k.extui.page.pos_calibration_h; + + +import a8k.app.hardware.type.a8kcanprotocol.A8kEcode; +import a8k.app.service.lowerctrl.*; +import a8k.extui.mgr.ExtApiPageMgr; +import a8k.app.hardware.extdriver.MotorMoveZeroExDriver; +import a8k.app.a8ktype.param.HbotSamplePos; +import a8k.app.hardware.driver.HbotDriver; +import a8k.app.hardware.driver.PipetteCtrlDriver; +import a8k.app.hardware.driver.StepMotorCtrlDriver; +import a8k.app.hardware.driver.type.StepMotorMId; +import a8k.app.hardware.extdriver.MotorEnableExDriver; +import a8k.app.service.param.HbotSamplePosParamMgr; +import a8k.app.a8ktype.device.Pos2d; +import a8k.app.a8ktype.device.Pos3d; +import a8k.app.a8ktype.exception.AppException; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class HbotSamplePosCalibration { + + // @Resource + // PipetteCtrlDriver pipetteCtrlDriver; + // @Resource + // MotorEnableExDriver motorEnableExDriver; + // @Resource + // HbotDriver hbotDriver; + // @Resource + // TubePreProcesModuleCtrlService tubePreProcesModuleCtrlService; + // @Resource + // HbotMoveCtrlService hbotMoveCtrlService; + // @Resource + // TubePreProcesModuleExCtrlService tubePreProcesCtrlService; + // @Resource + // MotorMoveZeroExDriver motorMoveZeroExDriver; + // + // + // @Resource + // HbotMoveExCtrlService hbotMoveExCtrlService; + // @Resource + // HbotSamplePosParamMgr hbotSamplePosParamMgr; + // + // + // @Resource + // StepMotorCtrlDriver stepMotorCtrlDriver; + // + // + // public Object getPoss() throws AppException { + // return hbotSamplePosParamMgr.getParams(); + // } + // + // // 测试工具 + // + // public void moveToZero() throws AppException { + // enableModule(); + // + // motorEnableExDriver.preProcessRelatedModuleEnable(true); + // // motorEnableExDriver.tubeFeedRelatedModuleEnable(true); + // + // motorMoveZeroExDriver.preProcessModuleMoveToZero(); + // pipetteCtrlDriver.zMotorMoveZeroBlock(); + // hbotMoveCtrlService.moveToZero(); + // // motorMoveZeroExDriver.tubeFeeddingModuleMoveToZero(); + // } + // + // + // public void enableModule() throws AppException { + // pipetteCtrlDriver.zMotorEnable(1); + // hbotMoveCtrlService.enable(1); + // } + // + // + // public void disableModule() throws AppException { + // stepMotorCtrlDriver.stepMotorEnable(StepMotorMId.ShakeModClampingM, 1); + // stepMotorCtrlDriver.stepMotorEasyMoveByBlock(StepMotorMId.ShakeModClampingM, 10, 3000); + // + // pipetteCtrlDriver.zMotorEnable(0); + // hbotMoveCtrlService.enable(0); + // motorEnableExDriver.forceDisableAllMotor(); + // } + // + // + // + // public void takeTubeToShakePos(Boolean isHtube) throws AppException { + // tubePreProcesCtrlService.takeTubeFromTubeholderToShakePos(isHtube); + // tubePreProcesCtrlService.takeTubeCap(); + // } + // + // + // // + // // 标定Z轴 + // // + // public Pos3d readPos() throws AppException { + // enableModule(); + // Pos2d xypos = hbotDriver.readPos(); + // pipetteCtrlDriver.zMotorMeasureDistance(); + // Integer z = pipetteCtrlDriver.zMotorReadMeasureDistanceResult(); + // Pos3d var = new Pos3d(xypos.x, xypos.y, z); + // disableModule(); + // return var; + // } + // + // + // public void calibrationSamplePos(HbotSamplePos posType) throws AppException { + // Pos3d pos3d = readPos(); + // hbotSamplePosParamMgr.setSamplePos(posType, pos3d); + // } + // + // // + // // 校验 + // // + // + // public void testSamplePos(HbotSamplePos posType) throws AppException { + // hbotMoveExCtrlService.moveToSamplePos(posType); + // } + + @Resource + TubeFeedingCtrlService tubeFeedingCtrlService; + + @Resource + DeviceInitCtrlService deviceInitCtrlService; + + @Resource + HbotDriver hbotDriver; + + @Resource + PipetteCtrlDriver pipetteCtrlDriver; + + @Resource + HbotSamplePosParamMgr hbotSamplePosParamMgr; + + public void prepareMeasureEnv() throws AppException { + Boolean suc = tubeFeedingCtrlService.enterTubeHolder(); + if (suc) { + tubeFeedingCtrlService.moveTubeToPreProcessPos(0); + } else { + throw AppException.of(A8kEcode.CODEERROR, "未检测到试管架"); + } + hbotDriver.enable(0); + pipetteCtrlDriver.zMotorEnable(0); + } + + + public Pos3d measure() throws AppException { + Pos2d pos2d = hbotDriver.readPos(); + pipetteCtrlDriver.zMotorEnable(1); + pipetteCtrlDriver.zMotorMeasureDistance(); + Integer z = pipetteCtrlDriver.zMotorReadMeasureDistanceResult(); + pipetteCtrlDriver.zMotorEnable(0); + return new Pos3d(pos2d.x, pos2d.y, z); + } + + public void setPos(HbotSamplePos posType, Integer x, Integer y, Integer z) throws AppException { + Pos3d pos = new Pos3d(x, y, z); + hbotSamplePosParamMgr.setSamplePos(posType, pos); + } + + @Resource + ExtApiPageMgr extApiPageMgr; + + @PostConstruct + public void init() { + var page = extApiPageMgr.newPage(this); + + + // page.newGroup("基础"); + // page.addFunction("获取坐标", this::getPoss); + // + // page.newGroup("测试工具"); + // page.addFunction("归零", this::moveToZero); + // page.addFunction("使能相关模块", this::enableModule); + // page.addFunction("失能相关模块", this::disableModule); + // + // page.newGroup("辅助工具"); + // page.addFunction("取试管到试管摇匀位", this::takeTubeToShakePos); + // + // page.newGroup("标定"); + // page.addFunction("校准.采样位置", this::calibrationSamplePos); + // + // page.newGroup("校验"); + // page.addFunction("校验坐标", this::testSamplePos); + + page.newGroup("控制"); + page.addFunction("准备测量环境", this::prepareMeasureEnv); + page.addFunction("测量", this::measure); + + page.newGroup("参数"); + page.addFunction("设置位置", this::setPos); + + extApiPageMgr.addPage(page); + } + +}