From 075df4f0add847d8c92ac0994ec491fa65e724d7 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Mon, 14 Oct 2024 15:07:51 +0800 Subject: [PATCH] update --- app.db | Bin 225280 -> 225280 bytes .../pagecontrol/ExtApiTabConfig.java | 4 + src/main/java/a8k/hardware/A8kCanBusService.java | 63 ----- .../java/a8k/hardware/A8kPipetteCtrlModule.java | 314 -------------------- .../hardware/type/regindex/PipetteRegIndex.java | 79 ------ .../service/app/appctrl/DeviceInitCtrlService.java | 6 +- .../calibration/Hbot2DCodeScanPosCalibration.java | 79 ++++++ .../calibration/PositionCalibration.java | 208 +++++++------- .../commonctrl/HardwareCommonCtrl.java | 250 ++++++++-------- .../service/app/devicedriver/ctrl/CodeScaner.java | 36 +++ .../app/devicedriver/ctrl/ConsumablesScanCtrl.java | 6 +- .../app/devicedriver/ctrl/HbotControlService.java | 36 +-- .../app/devicedriver/ctrl/basic/HbotModule.java | 89 ++++++ .../devicedriver/ctrl/basic/PipetteCtrlModule.java | 315 +++++++++++++++++++++ .../app/devicedriver/ctrl/type/HbotRegIndex.java | 51 ++++ .../devicedriver/ctrl/type/PipetteRegIndex.java | 79 ++++++ .../app/devicedriver/param/Hbot2DCodeScanPos.java | 200 ++++--------- .../app/devicedriver/status/DeviceStatus.java | 16 +- .../java/a8k/service/db/PosParameterDBService.java | 96 +++++++ .../java/a8k/service/db/type/PosParameter.java | 9 + .../a8k/service/db/utils/PosParameterReader.java | 30 ++ 21 files changed, 1113 insertions(+), 853 deletions(-) delete mode 100644 src/main/java/a8k/hardware/A8kPipetteCtrlModule.java delete mode 100644 src/main/java/a8k/hardware/type/regindex/PipetteRegIndex.java create mode 100644 src/main/java/a8k/service/app/devicedriver/calibration/Hbot2DCodeScanPosCalibration.java create mode 100644 src/main/java/a8k/service/app/devicedriver/ctrl/CodeScaner.java create mode 100644 src/main/java/a8k/service/app/devicedriver/ctrl/basic/HbotModule.java create mode 100644 src/main/java/a8k/service/app/devicedriver/ctrl/basic/PipetteCtrlModule.java create mode 100644 src/main/java/a8k/service/app/devicedriver/ctrl/type/HbotRegIndex.java create mode 100644 src/main/java/a8k/service/app/devicedriver/ctrl/type/PipetteRegIndex.java create mode 100644 src/main/java/a8k/service/db/PosParameterDBService.java create mode 100644 src/main/java/a8k/service/db/type/PosParameter.java create mode 100644 src/main/java/a8k/service/db/utils/PosParameterReader.java diff --git a/app.db b/app.db index d44b0b5df7e2666c6f13f65967a23e9cd43cd2ca..d20effbc257d07a4c30192c5d804ec3daf4a945f 100644 GIT binary patch delta 1337 zcmZp8z}xVEcY?IwMFs{2b09VYVs-`wmdJ@Z#*7ym6Iv4(wR>Ik3i8&#a1qeAH zfAWL(3M@_0EuP!c1DWC&89lZi3u0Q&%;-M7ER5+OqucZkp-j!&cZY-IT(?U_GKsTr zxU-9!n=`iaPqz{4b`O(jU4zi215fe z@fk1>E!crd6~zrP5>S8>G$lb25!e=8BLi?S8d(@w)>^O;(uow3aGj=RCbbrU}9gO$ObF`O@P=4h(QIS9uS)X Ru^|v^0I}+JjR58w@&E}3iN62< delta 1150 zcmaKsO=uHA7>0LdHrY+Gf2}d8$%<4Eii%`68{+ ze^-Ui5h&rC)9?+j@!k|%_BU(6H_Ojmfmu;5O4)K5+|%*t8qE0aEZi79l@nG3eO~*Z zmDP1Mq1;GqrOqUuB?l9?}fcHW&hTOXZp-La|3s%1M?!E)-BU9fReL)XCp{9Ys6Y?O1lT9S|bpUFE4CTOO{8U8;@goH_pt+wpSEFkST^B2Gz6LXCybVc{N)+ss z#s)%dnBK>%-6&Y>?&vVrX$nV zruTybQb#ESzjMG{ s(rG|A%|{MMrfI!;0j2d}iM%2XiA@r`Dkn&ekys=pk`aHTg0>F*2Ojt;5dZ)H diff --git a/src/main/java/a8k/extapi_controler/pagecontrol/ExtApiTabConfig.java b/src/main/java/a8k/extapi_controler/pagecontrol/ExtApiTabConfig.java index a69dbd5..77b36f3 100644 --- a/src/main/java/a8k/extapi_controler/pagecontrol/ExtApiTabConfig.java +++ b/src/main/java/a8k/extapi_controler/pagecontrol/ExtApiTabConfig.java @@ -13,6 +13,10 @@ public enum ExtApiTabConfig { AppProjInfoMgrService("应用数据.项目与ID卡管理", true), //OK AppReactionResultMgrService("应用数据.反应结果管理", true), //OK + + Hbot2DCodeScanPosCalibration("校准.耗材扫描二维码坐标校准",true), + + ActionReactorService("底层调试.单步调试", false),//OK Hbot2DCodeScanPos("参数.Hbot二维码扫描坐标参数", false), //底层硬件 diff --git a/src/main/java/a8k/hardware/A8kCanBusService.java b/src/main/java/a8k/hardware/A8kCanBusService.java index 01b2b48..cdc83d3 100644 --- a/src/main/java/a8k/hardware/A8kCanBusService.java +++ b/src/main/java/a8k/hardware/A8kCanBusService.java @@ -325,69 +325,6 @@ public class A8kCanBusService { } - public void hbotEnable(MId mid, int enable) throws AppException { - callcmd(mid.toInt(), CmdId.xymotor_enable.toInt(), enable); - } - - public void hbotMoveBy(MId mid, int x, int y) throws AppException { - callcmd(mid.toInt(), CmdId.xymotor_move_by.toInt(), x, y); - } - - public void hbotMoveByBlock(MId mid, int x, int y, Integer actionOvertime) throws AppException { - hbotMoveBy(mid, x, y); - waitForMod(mid, actionOvertime); - } - - public void hbotMoveTo(MId mid, int x, int y) throws AppException { - callcmd(mid.toInt(), CmdId.xymotor_move_to.toInt(), x, y); - } - - public void hbotMoveToBlock(MId mid, int x, int y, Integer actionOvertime) throws AppException { - hbotMoveTo(mid, x, y); - waitForMod(mid, actionOvertime); - } - - public void hbotMoveToZero(MId mid) throws AppException { - callcmd(mid.toInt(), CmdId.xymotor_move_to_zero.toInt()); - } - - public void hbotMoveToZeroBlock(MId mid, Integer actionOvertime) throws AppException { - hbotMoveToZero(mid); - waitForMod(mid, actionOvertime); - } - - public Pos2d hbotReadPos(MId mid) throws AppException { - Pos2d pos = new Pos2d(0, 0); - var packet = callcmd(mid.toInt(), CmdId.xymotor_read_pos.toInt()); - pos.x = packet.getContentI32(0); - pos.y = packet.getContentI32(1); - return pos; - } - - public Boolean hbotReadInio(MId mid, int ioIndex) throws AppException { - var packet = callcmd(mid.toInt(), CmdId.xymotor_read_inio.toInt(), ioIndex); - return packet.getContentI32(0) != 0; - } - - public void hbotSetPos(MId mid, int x, int y) throws AppException { - callcmd(mid.toInt(), CmdId.xymotor_set_pos.toInt(), x, y); - } - - - public void hbotMoveByDirect(MId mid, int motor1_dpos, int motor2_dpos) throws AppException { - callcmd(mid.toInt(), CmdId.xymotor_motor_move_by_direct.toInt(), motor1_dpos, motor2_dpos); - } - - public int hbotReadEncDirect(MId mid) throws AppException { - var packet = callcmd(mid.toInt(), CmdId.xymotor_read_enc_direct.toInt()); - return packet.getContentI32(0); - } - - public int hbotReadInioIndexInStm32(MId mid, int ioIndex) throws AppException { - var packet = callcmd(mid.toInt(), CmdId.xymotor_read_inio_index_in_stm32.toInt(), ioIndex); - return packet.getContentI32(0); - } - // // stepMotor diff --git a/src/main/java/a8k/hardware/A8kPipetteCtrlModule.java b/src/main/java/a8k/hardware/A8kPipetteCtrlModule.java deleted file mode 100644 index 776858a..0000000 --- a/src/main/java/a8k/hardware/A8kPipetteCtrlModule.java +++ /dev/null @@ -1,314 +0,0 @@ -package a8k.hardware; - -import a8k.extapi_controler.pagecontrol.ExtApiTabConfig; -import a8k.extapi_controler.utils.ExtApiTab; -import a8k.extapi_controler.utils.ExtApiFn; -import a8k.hardware.type.LldType; -import a8k.hardware.type.a8kcanprotocol.CmdId; -import a8k.hardware.type.a8kcanprotocol.MId; -import a8k.hardware.type.regindex.PipetteRegIndex; -import a8k.hardware.type.regindex.RegIndex; -import a8k.type.exception.AppException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; -import jakarta.annotation.PostConstruct; -import jakarta.annotation.Resource; -import org.springframework.stereotype.Component; - -import java.util.List; - -/** - * 液面探测参数标定 - * 电容值标定: - * 1.失能z轴电机 - * 2.移动tip头分别处于液体中和液体外 - * 3.读取两次电容值 - * 4.取电容值差值的3/4作为阈值 - * 5.lld采用clld测试阈值是否工作正常 - * - * - */ - -@Component -@ExtApiTab(cfg = ExtApiTabConfig.A8kPipetteCtrlModule) -public class A8kPipetteCtrlModule { - - @Resource - A8kCanBusService canBusService; - - final Integer overtime = 10000; - - static class FnOrder { - public static final int zMotorEnable = 1; - public static final int moduleStop = 2; - public static final int zMotorMoveZeroBlock = 3; - public static final int zMotorMoveToZeroPointQuickBlock = 4; - public static final int zMotorMoveByBlock = 5; - public static final int zMotorMoveToBlock = 6; - public static final int zMotorMeasureDistance = 7; - public static final int zMotorReadMeasureDistanceResult = 8; - public static final int initDeviceBlock = 9; - public static final int putTipBlock = 10; - public static final int lldPrepareBlock = 11; - public static final int lldBlock = 12; - public static final int lldCalibrationBlock = 12; - public static final int lldIsDetectLiquid = 13; - public static final int getSensorSampleData = 14; - public static final int readCapacitance = 15; - public static final int aspiratePrepareBlock = 16; - public static final int aspirateSetLlfVelocity = 17; - public static final int aspirateSetOperationVerifPThre = 18; - public static final int aspirateSetOperationVerifEigenTime = 19; - public static final int aspirateSetOperationVerifTolerance = 20; - public static final int aspirateBlock = 21; - public static final int aspirateAndVerifyBlock = 22; - public static final int shakeUpBlock = 23; - public static final int aspirateInferPressureBlock = 24; - public static final int aspirateInferEigenTimeBlock = 25; - public static final int getAspirateInferPressureResult = 26; - public static final int getAspirateInferEigenTimeResultBlock = 27; - public static final int zAixsZeroPointIsTrigger = 27; - public static final int setReg = 28; - public static final int getReg = 29; - public static final int getAllRegs = 30; - } - - @PostConstruct - public void init() { - - } - - @ExtApiFn(name = "z轴电机使能", order = FnOrder.zMotorEnable) - public void zMotorEnable(Integer enable) throws AppException { - canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_zmotor_enable.toInt(), enable); - } - - //stop - @ExtApiFn(name = "模块停止", order = FnOrder.moduleStop) - public void moduleStop() throws AppException { - canBusService.moduleStop(MId.PipetteMod); - } - - @ExtApiFn(name = "z轴电机归零", order = FnOrder.zMotorMoveZeroBlock) - public void zMotorMoveZeroBlock() throws AppException { - canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_zmotor_move_zero.toInt()); - canBusService.waitForMod(MId.PipetteMod, overtime); - } - - @ExtApiFn(name = "z轴电机快速归零", order = FnOrder.zMotorMoveToZeroPointQuickBlock) - public void zMotorMoveToZeroPointQuickBlock() throws AppException { - canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_zmotor_move_to_zero_point_quick.toInt()); - canBusService.waitForMod(MId.PipetteMod, overtime); - } - - @ExtApiFn(name = "z轴电机相对移动", order = FnOrder.zMotorMoveByBlock) - public void zMotorMoveByBlock(Integer distance) throws AppException { - canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_zmotor_move_by.toInt(), distance); - canBusService.waitForMod(MId.PipetteMod, overtime); - } - - @ExtApiFn(name = "z轴电机绝对移动", order = FnOrder.zMotorMoveToBlock) - public void zMotorMoveToBlock(Integer position) throws AppException { - canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_zmotor_move_to.toInt(), position); - canBusService.waitForMod(MId.PipetteMod, overtime); - } - //kpipette_zmotor_measure_distance - //kpipette_zmotor_read_measure_distance_result - - @ExtApiFn(name = "z轴电机测量距离", order = FnOrder.zMotorMeasureDistance) - public void zMotorMeasureDistance() throws AppException { - canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_zmotor_measure_distance.toInt()); - canBusService.waitForMod(MId.PipetteMod, overtime); - } - - @ExtApiFn(name = "z轴电机读取测量距离结果", order = FnOrder.zMotorReadMeasureDistanceResult) - public Integer zMotorReadMeasureDistanceResult() throws AppException { - var receipt = canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_zmotor_read_measure_distance_result.toInt()); - return receipt.getContentI32(0); - } - - - @ExtApiFn(name = "初始化设备", order = FnOrder.initDeviceBlock) - public void initDeviceBlock() throws AppException { - canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_init_device.toInt()); - canBusService.waitForMod(MId.PipetteMod, overtime); - } - - @ExtApiFn(name = "放置吸头", order = FnOrder.putTipBlock) - public void putTipBlock() throws AppException { - canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_put_tip.toInt()); - canBusService.waitForMod(MId.PipetteMod, overtime); - } - - @ExtApiFn(name = "LLD.准备", order = FnOrder.lldPrepareBlock) - public void lldPrepareBlock(Integer startPos) throws AppException { - canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_lld_prepare.toInt()); - canBusService.waitForMod(MId.PipetteMod, overtime); - - zMotorMoveToBlock(startPos); - } - - @ExtApiFn(name = "LLD.Do", order = FnOrder.lldBlock) - public void lldBlock(LldType lldtype, Integer startPos, Integer zdpos, Integer c_threshold, Integer p_threshold) - throws AppException { - canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_lld.toInt(), lldtype.getIndex(), startPos, zdpos, c_threshold, - p_threshold); - canBusService.waitForMod(MId.PipetteMod, overtime); - } - - @ExtApiFn(name = "LLD.参数标定", order = FnOrder.lldCalibrationBlock) - public void lldCalibrationBlock(Integer startPos, Integer zdpos) - throws AppException { - canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_lld_test.toInt(), startPos, zdpos); - canBusService.waitForMod(MId.PipetteMod, overtime); - } - - // kpipette_lld_is_detect_liquid - @ExtApiFn(name = "LLD.读取是否检测到液体", order = FnOrder.lldIsDetectLiquid) - public Boolean lldIsDetectLiquid() throws AppException { - var receipt = canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_lld_is_detect_liquid.toInt()); - return receipt.getContentI32(0) == 1; - } - - - public static class SensorSampleData { - public Integer motorPos; - public Integer cval; - public Integer pval; - } - - @ExtApiFn(name = "LLD.获取传感器采样数据", order = FnOrder.getSensorSampleData) - public List getSensorSampleData() throws AppException { - - List dataList = new java.util.ArrayList<>(); - int dataNUm = // - canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_get_sensor_sample_data_num.toInt()).getContentI32(0); - - for (int i = 0; i < dataNUm; i++) { - var receipt = canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_get_sensor_sample_data.toInt(), i); - var data = new SensorSampleData(); - data.motorPos = receipt.getContentI32(0); - data.cval = receipt.getContentI32(1); - data.pval = receipt.getContentI32(2); - dataList.add(data); - } - return dataList; - } - - @ExtApiFn(name = "LLD.读取电容值", order = FnOrder.readCapacitance) - public Integer readCapacitance() throws AppException { - return getReg(PipetteRegIndex.kreg_pipette_capactitance_val); - } - - - @ExtApiFn(name = "吸液准备", order = FnOrder.aspiratePrepareBlock) - public void aspiratePrepareBlock() throws AppException { - canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_aspirate_prepare.toInt()); - canBusService.waitForMod(MId.PipetteMod, overtime); - } - - @ExtApiFn(name = "设置LLF速度", order = FnOrder.aspirateSetLlfVelocity) - public void aspirateSetLlfVelocity(Integer llf_zm_rpm) throws AppException { - canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_aspirate_set_llf_velocity.toInt(), llf_zm_rpm); - } - - @ExtApiFn(name = "设置操作验证压力阈值", order = FnOrder.aspirateSetOperationVerifPThre) - public void aspirateSetOperationVerifPThre(Integer p_thre) throws AppException { - canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_aspirate_set_operation_verifi_p_thre.toInt(), - p_thre); - } - - @ExtApiFn(name = "设置操作验证时间", order = FnOrder.aspirateSetOperationVerifEigenTime) - public void aspirateSetOperationVerifEigenTime(Integer eigen_time) throws AppException { - canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_aspirate_set_operation_verifi_eigen_time.toInt(), - eigen_time); - } - - @ExtApiFn(name = "设置操作验证容忍度", order = FnOrder.aspirateSetOperationVerifTolerance) - public void aspirateSetOperationVerifTolerance(Integer tolerance) throws AppException { - canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_aspirate_set_operation_verifi_tolerance.toInt(), - tolerance); - } - - @ExtApiFn(name = "吸液", order = FnOrder.aspirateBlock) - public void aspirateBlock(Integer ul) throws AppException { - canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_aspirate.toInt(), ul); - canBusService.waitForMod(MId.PipetteMod, overtime); - } - - @ExtApiFn(name = "吸液并验证", order = FnOrder.aspirateAndVerifyBlock) - public void aspirateAndVerifyBlock(Integer ul) throws AppException { - canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_aspirate_and_verify.toInt(), ul); - canBusService.waitForMod(MId.PipetteMod, overtime); - } - - @ExtApiFn(name = "振荡", order = FnOrder.shakeUpBlock) - public void shakeUpBlock(Integer ul, Integer times) throws AppException { - canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_shake_up.toInt(), ul, times); - canBusService.waitForMod(MId.PipetteMod, overtime + times * 3000); - } - - @ExtApiFn(name = "吸液推算压力", order = FnOrder.aspirateInferPressureBlock) - public void aspirateInferPressureBlock(Integer ul) throws AppException { - canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_aspirate_infer_pressure.toInt(), ul); - canBusService.waitForMod(MId.PipetteMod, overtime); - } - - @ExtApiFn(name = "吸液推算时间", order = FnOrder.aspirateInferEigenTimeBlock) - public void aspirateInferEigenTimeBlock(Integer ul) throws AppException { - canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_aspirate_infer_eigen_time.toInt(), ul); - canBusService.waitForMod(MId.PipetteMod, overtime); - } - - @ExtApiFn(name = "获取吸液推算压力结果", order = FnOrder.getAspirateInferPressureResult) - public Integer getAspirateInferPressureResult() throws AppException { - var receipt = canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_get_aspirate_infer_pressure_result.toInt()); - return receipt.getContentI32(0); - } - - @ExtApiFn(name = "获取吸液推算时间结果", order = FnOrder.getAspirateInferEigenTimeResultBlock) - public Integer getAspirateInferEigenTimeResultBlock() throws AppException { - var receipt = canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_get_aspirate_infer_eigen_time_result.toInt()); - return receipt.getContentI32(0); - } - - @ExtApiFn(name = "z轴零点是否触发", order = FnOrder.zAixsZeroPointIsTrigger) - public Boolean zAixsZeroPointIsTrigger() throws AppException { - return canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_zmotor_read_zero_point_state.toInt()).getContentI32(0) == 1; - } - - - // @EnginnerPageAction(name = "获取传感器采样数据数量", order = FnOrder.getSensorSampleDataNum) - // public Integer getSensorSampleDataNum() throws HardwareException { - // return canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_get_sensor_sample_data_num.toInt()).getContentI32(0); - // } - - @ExtApiFn(name = "设置寄存器", order = FnOrder.setReg) - public void setReg(PipetteRegIndex regIndex, Integer val) throws AppException { - RegIndex regindex = RegIndex.valueOf(regIndex.index); - assert regindex != null; - canBusService.moduleSetReg(MId.PipetteMod, regindex, val); - } - - @ExtApiFn(name = "获取寄存器", order = FnOrder.getReg) - public Integer getReg(PipetteRegIndex regIndex) throws AppException { - RegIndex regindex = RegIndex.valueOf(regIndex.index); - assert regindex != null; - return canBusService.moduleGetReg(MId.PipetteMod, regindex); - } - - @ExtApiFn(name = "获取所有寄存器", order = FnOrder.getAllRegs) - public ObjectNode getAllRegs() throws AppException { - ObjectMapper mapper = new ObjectMapper(); - ObjectNode json = mapper.createObjectNode(); - - // 遍历所有 PipetteRegIndex - for (PipetteRegIndex regIndex : PipetteRegIndex.values()) { - RegIndex regindex = RegIndex.valueOf(regIndex.index); - assert regindex != null; - Integer val = canBusService.moduleGetReg(MId.PipetteMod, regindex); - json.put(regIndex.name(), val); - } - return json; - } -} diff --git a/src/main/java/a8k/hardware/type/regindex/PipetteRegIndex.java b/src/main/java/a8k/hardware/type/regindex/PipetteRegIndex.java deleted file mode 100644 index ab11e17..0000000 --- a/src/main/java/a8k/hardware/type/regindex/PipetteRegIndex.java +++ /dev/null @@ -1,79 +0,0 @@ -package a8k.hardware.type.regindex; - -public enum PipetteRegIndex { - kreg_module_version(0), // 模块版本 - kreg_module_type(1), // 模块类型 - kreg_module_status(2), // 0idle,1busy,2error - kreg_module_errorcode(3), // inited_flag - - kreg_pipette_pos_ul(4000), // 移液枪位置 - kreg_pipette_capactitance_val(4001), // 移液枪电容值 - kreg_pipette_tip_state(4002, false), // 移动液枪tip状态 - - kreg_pipette_limit_ul(4051), // - kreg_pipette_pump_acc(4052), // - kreg_pipette_pump_dec(4053), // - kreg_pipette_pump_vstart(4054), // - kreg_pipette_pump_vstop(4055), // - kreg_pipette_pump_vmax(4056), // - kreg_pipette_aspirate_distribut_pump_vel(4057), // - kreg_pipette_lld_pump_vel(4058), // - kreg_pipette_lld_motor_vel_rpm(4059), // - kreg_pipette_lld_detect_period_ms(4060), // - kreg_pipette_lld_prepare_pos(4061), // - kreg_pipette_lld_prepare_distribut_pos(4062), // - - kreg_pipette_zm_pos(4101), - kreg_pipette_zm_is_enable(4102), - kreg_pipette_zm_dpos(4103), - //kreg_pipette_zm_shift(4105), - kreg_pipette_zm_shaft(4106), - kreg_pipette_zm_one_circle_pulse(4107), - kreg_pipette_zm_one_circle_pulse_denominator(4108), - kreg_pipette_zm_default_velocity(4109), - kreg_pipette_zm_ihold(4110), - kreg_pipette_zm_irun(4111), - kreg_pipette_zm_iholddelay(4112), - kreg_pipette_zm_iglobalscaler(4113), - kreg_pipette_zm_run_to_zero_speed(4114), - kreg_pipette_zm_look_zero_edge_speed(4115), - kreg_pipette_zm_max_d(4116), - kreg_pipette_zm_min_d(4117), -// kreg_pipette_zm_in_debug_mode(4118), - kreg_pipette_zm_vstart(4119), - kreg_pipette_zm_a1(4120), - kreg_pipette_zm_amax(4121), - kreg_pipette_zm_v1(4122), - kreg_pipette_zm_dmax(4123), - kreg_pipette_zm_d1(4124), - kreg_pipette_zm_vstop(4125), - kreg_pipette_zm_tzerowait(4126), - kreg_pipette_zm_enc_resolution(4127), - kreg_pipette_zm_enable_enc(4128), - kreg_pipette_zm_dzero(4129), - kreg_pipette_zm_pos_devi_tolerance(4130), - kreg_pipette_zm_io_trigger_append_distance(4131); - - public final int index; - public final Boolean trace; - - PipetteRegIndex(int regIndex) { - this.index = regIndex; - this.trace = true; - } - - PipetteRegIndex(int regIndex, Boolean trace) { - this.index = regIndex; - this.trace = trace; - } - - public static PipetteRegIndex valueOf(int val) { - PipetteRegIndex[] values = PipetteRegIndex.values(); - for (PipetteRegIndex regindex : values) { - if (regindex.index == val) { - return regindex; - } - } - return null; - } -} diff --git a/src/main/java/a8k/service/app/appctrl/DeviceInitCtrlService.java b/src/main/java/a8k/service/app/appctrl/DeviceInitCtrlService.java index 068a001..a303f9c 100644 --- a/src/main/java/a8k/service/app/appctrl/DeviceInitCtrlService.java +++ b/src/main/java/a8k/service/app/appctrl/DeviceInitCtrlService.java @@ -9,6 +9,7 @@ import a8k.service.debug.AppDebugHelperService; import a8k.type.checkpoint.CheckResult; import a8k.type.checkpoint.Checkpoint; import a8k.service.app.appstate.GStateService; +import a8k.service.app.devicedriver.ctrl.basic.HbotModule; import a8k.type.exception.AppException; import jakarta.annotation.PostConstruct; import jakarta.annotation.Resource; @@ -30,6 +31,9 @@ public class DeviceInitCtrlService { A8kCanBusService canBus; @Resource + HbotModule hbotModule; + + @Resource GStateService gstate; @Resource @@ -113,7 +117,7 @@ public class DeviceInitCtrlService { ar.dosome("光学模组-扫码电机回零", () -> canBus.stepMotorEasyMoveToZeroBlock(MId.OptModScannerM, actionOvertime)); //HBot初始化 - ar.dosome("HBot回零", () -> canBus.hbotMoveToZero(MId.HbotM)); + ar.dosome("HBot回零", () -> hbotModule.moveToZero()); //转盘归零 ar.dosome("转盘回零", () -> canBus.stepMotorEasyMoveToZeroBlock(MId.IncubatorRotateCtrlM, actionOvertime)); diff --git a/src/main/java/a8k/service/app/devicedriver/calibration/Hbot2DCodeScanPosCalibration.java b/src/main/java/a8k/service/app/devicedriver/calibration/Hbot2DCodeScanPosCalibration.java new file mode 100644 index 0000000..de8c496 --- /dev/null +++ b/src/main/java/a8k/service/app/devicedriver/calibration/Hbot2DCodeScanPosCalibration.java @@ -0,0 +1,79 @@ +package a8k.service.app.devicedriver.calibration; + + +import a8k.extapi_controler.pagecontrol.ExtApiTabConfig; +import a8k.extapi_controler.utils.ExtApiFn; +import a8k.extapi_controler.utils.ExtApiTab; +import a8k.hardware.A8kCanBusService; +import a8k.service.app.devicedriver.ctrl.basic.PipetteCtrlModule; +import a8k.service.app.devicedriver.ctrl.CodeScaner; +import a8k.service.app.devicedriver.param.Hbot2DCodeScanPos; +import a8k.type.exception.AppException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import jakarta.annotation.Resource; + +@ExtApiTab(cfg = ExtApiTabConfig.Hbot2DCodeScanPosCalibration) +public class Hbot2DCodeScanPosCalibration { + + @Resource + Hbot2DCodeScanPos hbot2DCodeScanPos; + + @Resource + A8kCanBusService canBus; + @Resource + CodeScaner codeScaner; + @Resource + PipetteCtrlModule pipetteCtrlModule; + + + @ExtApiFn(name = "扫码测试(全部位置)", group = "测试工具", order = 0) + public void deviceReset() throws AppException { + pipetteCtrlModule.zMotorEnable(1); + } + + public void disableMotor() throws AppException { + + } + + @ExtApiFn(name = "扫码测试(当前位置)", group = "测试工具", order = 0) + public String openCodeTryScaner() throws AppException { + return codeScaner.pipetteModCodeScannerScanCode(); + } + + @ExtApiFn(name = "扫码测试(全部位置)", group = "测试工具", order = 0) + public String scanAll() throws AppException { + return codeScaner.pipetteModCodeScannerScanCode(); + } + + + @ExtApiFn(name = "获取所有坐标", order = 1) + public ObjectNode getPoss() throws AppException { + ObjectMapper mapper = new ObjectMapper(); + + ObjectNode node = new ObjectMapper().createObjectNode(); + ArrayNode PBScanPos = node.putArray("PBScanPos"); + ArrayNode LittBSScanPos = node.putArray("LittBSScanPos"); + ArrayNode LarBSScanPos = node.putArray("LarBSScanPos"); + + for (int i = 0; i < 6; i++) { + PBScanPos.add(mapper.valueToTree(hbot2DCodeScanPos.getPBScanPosX(i).toString())); + } + + for (int i = 0; i < 6; i++) { + LittBSScanPos.add(mapper.valueToTree(hbot2DCodeScanPos.getLittBSX(i).toString())); + } + + for (int i = 0; i < 6; i++) { + LarBSScanPos.add(mapper.valueToTree(hbot2DCodeScanPos.getLarBSX(i).toString())); + } + return node; + } + + @ExtApiFn(name = "扫码", order = 2) + public void scan(String pos) throws AppException { + } + + +} diff --git a/src/main/java/a8k/service/app/devicedriver/calibration/PositionCalibration.java b/src/main/java/a8k/service/app/devicedriver/calibration/PositionCalibration.java index d9c394c..4ff5a91 100644 --- a/src/main/java/a8k/service/app/devicedriver/calibration/PositionCalibration.java +++ b/src/main/java/a8k/service/app/devicedriver/calibration/PositionCalibration.java @@ -14,107 +14,107 @@ import a8k.service.app.devicedriver.param.TimeParam; import jakarta.annotation.Resource; import org.springframework.stereotype.Component; -@Component -@ExtApiTab(cfg = ExtApiTabConfig.PositionCalibration) -public class PositionCalibration { - - @Resource - A8kCanBusService canBus; - @Resource - TimeParam timep; - @Resource - PosParam pp; - @Resource - DebugParam dp; - - @ExtApiFn(name = "试管夹平移电机-使能", group = "电机使能") - public void FeedingModXMEnable(Boolean enable) throws AppException { - canBus.stepMotorEnable(MId.FeedingModXM, enable ? 1 : 0); - } - - @ExtApiFn(name = "板夹仓Y轴-使能", group = "电机使能") - public void platesBoxYMEndble(Boolean enable) throws AppException { - canBus.stepMotorEnable(MId.PlatesBoxYM, enable ? 1 : 0); - } - - @ExtApiFn(name = "板夹仓推杆-使能", group = "电机使能") - public void platesBoxPusherMEndble(Boolean enable) throws AppException { - canBus.stepMotorEnable(MId.PlatesBoxPusherM, enable ? 1 : 0); - } - - @ExtApiFn(name = "拉杆-使能", group = "电机使能") - public void optModPullMEndble(Boolean enable) throws AppException { - canBus.stepMotorEnable(MId.OptModPullM, enable ? 1 : 0); - } - - @ExtApiFn(name = "光学模组扫描器-使能", group = "电机使能") - public void optModScannerMEndble(Boolean enable) throws AppException { - canBus.stepMotorEnable(MId.OptModScannerM, enable ? 1 : 0); - } - - @ExtApiFn(name = "转盘-使能", group = "电机使能") - public void incubatorRotateCtrlMEndble(Boolean enable) throws AppException { - canBus.stepMotorEnable(MId.IncubatorRotateCtrlM, enable ? 1 : 0); - - } - - - @ExtApiFn(name = "试管夹平移电机-读取位置", group = "通过归零测量位置") - public Integer readXPosByMoveZero() throws AppException { - return (canBus.stepMotorReadPosByMoveToZeroBlock(MId.FeedingModXM, timep.getActionOvertime())); - } - - - @ExtApiFn(name = "通过归零读取<板夹仓>位置", group = "通过归零测量位置") - public Integer readPlatesBoxYMPosByMoveToZero() throws AppException { - return (canBus.stepMotorReadPosByMoveToZeroBlock(MId.PlatesBoxYM, timep.getActionOvertime())); - } - - @ExtApiFn(name = "通过归零读取<推杆>位置", group = "通过归零测量位置") - public Integer readPlatesBoxPusherMPosByMoveToZero() throws AppException { - return (canBus.stepMotorReadPosByMoveToZeroBlock(MId.PlatesBoxPusherM, timep.getActionOvertime())); - } - - @ExtApiFn(name = "通过归零读取<拉杆>位置", group = "通过归零测量位置") - public Integer readOptModPullMPosByMoveToZero() throws AppException { - return (canBus.stepMotorReadPosByMoveToZeroBlock(MId.OptModPullM, timep.getActionOvertime())); - } - - @ExtApiFn(name = "通过归零读取<光学模组扫描器>位置", group = "通过归零测量位置") - public Integer readOptModScannerMPosByMoveToZero() throws AppException { - return (canBus.stepMotorReadPosByMoveToZeroBlock(MId.OptModScannerM, timep.getActionOvertime())); - } - - @ExtApiFn(name = "通过归零读取<摇匀模组Z轴>位置", group = "通过归零测量位置") - public Integer readShakeModGripperZMPosByMoveToZero() throws AppException { - return (canBus.stepMotorReadPosByMoveToZeroBlock(MId.ShakeModGripperZM, timep.getActionOvertime())); - } - - - @ExtApiStatu(name = "HbotPos", group = "Hbot") - public String getHbotPos() throws AppException { - Pos2d pos = canBus.hbotReadPos(MId.HbotM); - return pos.toString(); - } - - - @ExtApiStatu(name = "转盘位置") - public String getIncubatorRotateCtrlMPos() throws AppException { - Integer pos = canBus.stepMotorReadPos(MId.IncubatorRotateCtrlM); - return pos.toString(); - } - - @ExtApiStatu(name = "抓手Y轴位置", group = "摇匀模组") - public String getShakeModGripperYPos() throws AppException { - Integer pos = canBus.miniServoReadPos(MId.ShakeModGripperYSV); - return pos.toString(); - } - - @ExtApiStatu(name = "抓手位置", group = "摇匀模组") - public String getGripperPos() throws AppException { - Integer pos = canBus.miniServoReadPos(MId.ShakeModGripperSV); - return pos.toString(); - } - - -} +//@Component +//@ExtApiTab(cfg = ExtApiTabConfig.PositionCalibration) +//public class PositionCalibration { +// +// @Resource +// A8kCanBusService canBus; +// @Resource +// TimeParam timep; +// @Resource +// PosParam pp; +// @Resource +// DebugParam dp; +// +// @ExtApiFn(name = "试管夹平移电机-使能", group = "电机使能") +// public void FeedingModXMEnable(Boolean enable) throws AppException { +// canBus.stepMotorEnable(MId.FeedingModXM, enable ? 1 : 0); +// } +// +// @ExtApiFn(name = "板夹仓Y轴-使能", group = "电机使能") +// public void platesBoxYMEndble(Boolean enable) throws AppException { +// canBus.stepMotorEnable(MId.PlatesBoxYM, enable ? 1 : 0); +// } +// +// @ExtApiFn(name = "板夹仓推杆-使能", group = "电机使能") +// public void platesBoxPusherMEndble(Boolean enable) throws AppException { +// canBus.stepMotorEnable(MId.PlatesBoxPusherM, enable ? 1 : 0); +// } +// +// @ExtApiFn(name = "拉杆-使能", group = "电机使能") +// public void optModPullMEndble(Boolean enable) throws AppException { +// canBus.stepMotorEnable(MId.OptModPullM, enable ? 1 : 0); +// } +// +// @ExtApiFn(name = "光学模组扫描器-使能", group = "电机使能") +// public void optModScannerMEndble(Boolean enable) throws AppException { +// canBus.stepMotorEnable(MId.OptModScannerM, enable ? 1 : 0); +// } +// +// @ExtApiFn(name = "转盘-使能", group = "电机使能") +// public void incubatorRotateCtrlMEndble(Boolean enable) throws AppException { +// canBus.stepMotorEnable(MId.IncubatorRotateCtrlM, enable ? 1 : 0); +// +// } +// +// +// @ExtApiFn(name = "试管夹平移电机-读取位置", group = "通过归零测量位置") +// public Integer readXPosByMoveZero() throws AppException { +// return (canBus.stepMotorReadPosByMoveToZeroBlock(MId.FeedingModXM, timep.getActionOvertime())); +// } +// +// +// @ExtApiFn(name = "通过归零读取<板夹仓>位置", group = "通过归零测量位置") +// public Integer readPlatesBoxYMPosByMoveToZero() throws AppException { +// return (canBus.stepMotorReadPosByMoveToZeroBlock(MId.PlatesBoxYM, timep.getActionOvertime())); +// } +// +// @ExtApiFn(name = "通过归零读取<推杆>位置", group = "通过归零测量位置") +// public Integer readPlatesBoxPusherMPosByMoveToZero() throws AppException { +// return (canBus.stepMotorReadPosByMoveToZeroBlock(MId.PlatesBoxPusherM, timep.getActionOvertime())); +// } +// +// @ExtApiFn(name = "通过归零读取<拉杆>位置", group = "通过归零测量位置") +// public Integer readOptModPullMPosByMoveToZero() throws AppException { +// return (canBus.stepMotorReadPosByMoveToZeroBlock(MId.OptModPullM, timep.getActionOvertime())); +// } +// +// @ExtApiFn(name = "通过归零读取<光学模组扫描器>位置", group = "通过归零测量位置") +// public Integer readOptModScannerMPosByMoveToZero() throws AppException { +// return (canBus.stepMotorReadPosByMoveToZeroBlock(MId.OptModScannerM, timep.getActionOvertime())); +// } +// +// @ExtApiFn(name = "通过归零读取<摇匀模组Z轴>位置", group = "通过归零测量位置") +// public Integer readShakeModGripperZMPosByMoveToZero() throws AppException { +// return (canBus.stepMotorReadPosByMoveToZeroBlock(MId.ShakeModGripperZM, timep.getActionOvertime())); +// } +// +// +// @ExtApiStatu(name = "HbotPos", group = "Hbot") +// public String getHbotPos() throws AppException { +// Pos2d pos = canBus.hbotReadPos(MId.HbotM); +// return pos.toString(); +// } +// +// +// @ExtApiStatu(name = "转盘位置") +// public String getIncubatorRotateCtrlMPos() throws AppException { +// Integer pos = canBus.stepMotorReadPos(MId.IncubatorRotateCtrlM); +// return pos.toString(); +// } +// +// @ExtApiStatu(name = "抓手Y轴位置", group = "摇匀模组") +// public String getShakeModGripperYPos() throws AppException { +// Integer pos = canBus.miniServoReadPos(MId.ShakeModGripperYSV); +// return pos.toString(); +// } +// +// @ExtApiStatu(name = "抓手位置", group = "摇匀模组") +// public String getGripperPos() throws AppException { +// Integer pos = canBus.miniServoReadPos(MId.ShakeModGripperSV); +// return pos.toString(); +// } +// +// +//} diff --git a/src/main/java/a8k/service/app/devicedriver/commonctrl/HardwareCommonCtrl.java b/src/main/java/a8k/service/app/devicedriver/commonctrl/HardwareCommonCtrl.java index 5b28d16..f285fd1 100644 --- a/src/main/java/a8k/service/app/devicedriver/commonctrl/HardwareCommonCtrl.java +++ b/src/main/java/a8k/service/app/devicedriver/commonctrl/HardwareCommonCtrl.java @@ -1,6 +1,7 @@ package a8k.service.app.devicedriver.commonctrl; +import a8k.service.app.devicedriver.ctrl.basic.HbotModule; import a8k.type.exception.AppException; import a8k.type.appret.AppRet; import a8k.extapi_controler.utils.ExtApiTab; @@ -40,6 +41,9 @@ public class HardwareCommonCtrl { Boolean workState = false; + @Resource + HbotModule hbotModule; + // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // CHECK // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -103,7 +107,7 @@ public class HardwareCommonCtrl { canBus.stepMotorEasyMoveToZeroBlock(MId.OptModPullM, timep.getRuntoZeroActionOvertime()); canBus.stepMotorEasyMoveToZeroBlock(MId.OptModScannerM, timep.getRuntoZeroActionOvertime()); //HBot初始化 - canBus.hbotMoveToZero(MId.HbotM); + hbotModule.moveToZero(); // TODO canBus.stepMotorEasyMoveToZeroBlock(MId.PipetteModZM, timep.getRuntoZeroActionOvertime()); //转盘归零 @@ -234,128 +238,128 @@ public class HardwareCommonCtrl { } - @ExtApiFn(name = "设备强制使能所有电机", order = ORDER.forceDisableAllMOtor) - public void forceDisableAllMOtor() { - //Disable all motor - //进出料初始化 - try { - canBus.stepMotorEnable(MId.FeedingModInfeedM, 0); - } catch (AppException ignored) { - } - try { - canBus.stepMotorEnable(MId.FeedingModXM, 0); - } catch (AppException ignored) { - } - try { - canBus.stepMotorEnable(MId.FeedingModOutfeedM, 0); - } catch (AppException ignored) { - } - - //摇匀模组初始化 - try { - canBus.stepMotorEnable(MId.ShakeModClampingM, 0); - } catch (AppException ignored) { - } - try { - canBus.stepMotorEnable(MId.ShakeModGripperZM, 0); - } catch (AppException ignored) { - } - try { - canBus.stepMotorEnable(MId.ShakeModShakeM, 0); - } catch (AppException ignored) { - } - try { - canBus.miniServoEnable(MId.ShakeModGripperYSV, 0); - } catch (AppException ignored) { - } - try { - canBus.miniServoEnable(MId.ShakeModGripperSV, 0); - } catch (AppException ignored) { - } - try { - canBus.miniServoEnable(MId.ShakeModTubeScanerClampingSV, 0); - } catch (AppException ignored) { - } - try { - canBus.miniServoEnable(MId.ShakeModTubeScanerRotateSV, 0); - } catch (AppException ignored) { - } - - //板夹仓初始化 - try { - canBus.stepMotorEnable(MId.PlatesBoxYM, 0); - } catch (AppException ignored) { - } - try { - canBus.stepMotorEnable(MId.PlatesBoxPusherM, 0); - } catch (AppException ignored) { - } - - //光学模组初始化 - try { - canBus.stepMotorEnable(MId.OptModPullM, 0); - } catch (AppException ignored) { - } - try { - canBus.stepMotorEnable(MId.OptModScannerM, 0); - } catch (AppException ignored) { - } - - //HBot初始化 - try { - canBus.hbotEnable(MId.HbotM, 0); - } catch (AppException ignored) { - } - // try { - //TODO canBus.stepMotorEnable(MId.PipetteModZM, 0); - // } catch (HardwareException ignored) { - // } - - //转盘归零 - try { - canBus.stepMotorEnable(MId.IncubatorRotateCtrlM, 0); - } catch (AppException ignored) { - } - } - - @ExtApiFn(name = "设备使能", order = ORDER.deviceEnable) - public void deviceEnable(Boolean enable) throws AppException { - //进出料初始化 - canBus.stepMotorEnable(MId.FeedingModInfeedM, enable ? 1 : 0); - canBus.stepMotorEnable(MId.FeedingModXM, enable ? 1 : 0); - canBus.stepMotorEnable(MId.FeedingModOutfeedM, enable ? 1 : 0); - - //摇匀模组初始化 - canBus.stepMotorEnable(MId.ShakeModClampingM, enable ? 1 : 0); - canBus.stepMotorEnable(MId.ShakeModGripperZM, enable ? 1 : 0); - canBus.stepMotorEnable(MId.ShakeModShakeM, enable ? 1 : 0); - canBus.miniServoEnable(MId.ShakeModGripperYSV, enable ? 1 : 0); - canBus.miniServoEnable(MId.ShakeModGripperSV, enable ? 1 : 0); - canBus.miniServoEnable(MId.ShakeModTubeScanerClampingSV, enable ? 1 : 0); - canBus.miniServoEnable(MId.ShakeModTubeScanerRotateSV, enable ? 1 : 0); - - //板夹仓初始化 - canBus.stepMotorEnable(MId.PlatesBoxYM, enable ? 1 : 0); - canBus.stepMotorEnable(MId.PlatesBoxPusherM, enable ? 1 : 0); - - //光学模组初始化 - canBus.stepMotorEnable(MId.OptModPullM, enable ? 1 : 0); - canBus.stepMotorEnable(MId.OptModScannerM, enable ? 1 : 0); - - //HBot初始化 - canBus.hbotEnable(MId.HbotM, enable ? 1 : 0); - // TODO canBus.stepMotorEnable(MId.PipetteModZM, enable ? 1 : 0); - - //转盘归零 - canBus.stepMotorEnable(MId.IncubatorRotateCtrlM, enable ? 1 : 0); - } - - public void checkBeforeMove(MId mId) throws AppException { - //板夹仓盖子是否盖上 - if (!canBus.getIOState(IOId.PlateBoxCoverClosurePPS)) { - throw new AppException(A8kEcode.APPE_PLATE_BOX_NOT_COVER); - } - } +// @ExtApiFn(name = "设备强制使能所有电机", order = ORDER.forceDisableAllMOtor) +// public void forceDisableAllMOtor() { +// //Disable all motor +// //进出料初始化 +// try { +// canBus.stepMotorEnable(MId.FeedingModInfeedM, 0); +// } catch (AppException ignored) { +// } +// try { +// canBus.stepMotorEnable(MId.FeedingModXM, 0); +// } catch (AppException ignored) { +// } +// try { +// canBus.stepMotorEnable(MId.FeedingModOutfeedM, 0); +// } catch (AppException ignored) { +// } +// +// //摇匀模组初始化 +// try { +// canBus.stepMotorEnable(MId.ShakeModClampingM, 0); +// } catch (AppException ignored) { +// } +// try { +// canBus.stepMotorEnable(MId.ShakeModGripperZM, 0); +// } catch (AppException ignored) { +// } +// try { +// canBus.stepMotorEnable(MId.ShakeModShakeM, 0); +// } catch (AppException ignored) { +// } +// try { +// canBus.miniServoEnable(MId.ShakeModGripperYSV, 0); +// } catch (AppException ignored) { +// } +// try { +// canBus.miniServoEnable(MId.ShakeModGripperSV, 0); +// } catch (AppException ignored) { +// } +// try { +// canBus.miniServoEnable(MId.ShakeModTubeScanerClampingSV, 0); +// } catch (AppException ignored) { +// } +// try { +// canBus.miniServoEnable(MId.ShakeModTubeScanerRotateSV, 0); +// } catch (AppException ignored) { +// } +// +// //板夹仓初始化 +// try { +// canBus.stepMotorEnable(MId.PlatesBoxYM, 0); +// } catch (AppException ignored) { +// } +// try { +// canBus.stepMotorEnable(MId.PlatesBoxPusherM, 0); +// } catch (AppException ignored) { +// } +// +// //光学模组初始化 +// try { +// canBus.stepMotorEnable(MId.OptModPullM, 0); +// } catch (AppException ignored) { +// } +// try { +// canBus.stepMotorEnable(MId.OptModScannerM, 0); +// } catch (AppException ignored) { +// } +// +// //HBot初始化 +// try { +// canBus.hbotEnable(MId.HbotM, 0); +// } catch (AppException ignored) { +// } +// // try { +// //TODO canBus.stepMotorEnable(MId.PipetteModZM, 0); +// // } catch (HardwareException ignored) { +// // } +// +// //转盘归零 +// try { +// canBus.stepMotorEnable(MId.IncubatorRotateCtrlM, 0); +// } catch (AppException ignored) { +// } +// } + +// @ExtApiFn(name = "设备使能", order = ORDER.deviceEnable) +// public void deviceEnable(Boolean enable) throws AppException { +// //进出料初始化 +// canBus.stepMotorEnable(MId.FeedingModInfeedM, enable ? 1 : 0); +// canBus.stepMotorEnable(MId.FeedingModXM, enable ? 1 : 0); +// canBus.stepMotorEnable(MId.FeedingModOutfeedM, enable ? 1 : 0); +// +// //摇匀模组初始化 +// canBus.stepMotorEnable(MId.ShakeModClampingM, enable ? 1 : 0); +// canBus.stepMotorEnable(MId.ShakeModGripperZM, enable ? 1 : 0); +// canBus.stepMotorEnable(MId.ShakeModShakeM, enable ? 1 : 0); +// canBus.miniServoEnable(MId.ShakeModGripperYSV, enable ? 1 : 0); +// canBus.miniServoEnable(MId.ShakeModGripperSV, enable ? 1 : 0); +// canBus.miniServoEnable(MId.ShakeModTubeScanerClampingSV, enable ? 1 : 0); +// canBus.miniServoEnable(MId.ShakeModTubeScanerRotateSV, enable ? 1 : 0); +// +// //板夹仓初始化 +// canBus.stepMotorEnable(MId.PlatesBoxYM, enable ? 1 : 0); +// canBus.stepMotorEnable(MId.PlatesBoxPusherM, enable ? 1 : 0); +// +// //光学模组初始化 +// canBus.stepMotorEnable(MId.OptModPullM, enable ? 1 : 0); +// canBus.stepMotorEnable(MId.OptModScannerM, enable ? 1 : 0); +// +// //HBot初始化 +// canBus.hbotEnable(MId.HbotM, enable ? 1 : 0); +// // TODO canBus.stepMotorEnable(MId.PipetteModZM, enable ? 1 : 0); +// +// //转盘归零 +// canBus.stepMotorEnable(MId.IncubatorRotateCtrlM, enable ? 1 : 0); +// } +// +// public void checkBeforeMove(MId mId) throws AppException { +// //板夹仓盖子是否盖上 +// if (!canBus.getIOState(IOId.PlateBoxCoverClosurePPS)) { +// throw new AppException(A8kEcode.APPE_PLATE_BOX_NOT_COVER); +// } +// } public void stop() { workState = false; diff --git a/src/main/java/a8k/service/app/devicedriver/ctrl/CodeScaner.java b/src/main/java/a8k/service/app/devicedriver/ctrl/CodeScaner.java new file mode 100644 index 0000000..f16a597 --- /dev/null +++ b/src/main/java/a8k/service/app/devicedriver/ctrl/CodeScaner.java @@ -0,0 +1,36 @@ +package a8k.service.app.devicedriver.ctrl; + +import a8k.hardware.A8kCanBusService; +import a8k.hardware.type.a8kcanprotocol.MId; +import a8k.type.exception.AppException; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Component; + +@Component +public class CodeScaner { + + @Resource + A8kCanBusService canBus; + + public String pipetteModCodeScannerScanCode() throws AppException { + try { + canBus.codeScanerStartScan(MId.PipetteModCodeScanner); + String result = canBus.codeScanerWaittingForResult(MId.PipetteModCodeScanner, 300); + canBus.codeScanerStopScan(MId.PipetteModCodeScanner); + return result; + } catch (AppException e) { + return ""; + } + } + + public String feedingModScannerModCodeScannerScanCode(Integer waittime) { + try { + canBus.codeScanerStartScan(MId.FeedingModScannerMod); + String result = canBus.codeScanerWaittingForResult(MId.FeedingModScannerMod, waittime); + canBus.codeScanerStopScan(MId.FeedingModScannerMod); + return result; + } catch (AppException e) { + return ""; + } + } +} diff --git a/src/main/java/a8k/service/app/devicedriver/ctrl/ConsumablesScanCtrl.java b/src/main/java/a8k/service/app/devicedriver/ctrl/ConsumablesScanCtrl.java index 973aff8..2ff0e50 100644 --- a/src/main/java/a8k/service/app/devicedriver/ctrl/ConsumablesScanCtrl.java +++ b/src/main/java/a8k/service/app/devicedriver/ctrl/ConsumablesScanCtrl.java @@ -42,20 +42,20 @@ public class ConsumablesScanCtrl { private String scanPB(int ch) throws AppException { - Pos2d pos = hbotScanPos.getPBScanPos(ch); + Pos2d pos = hbotScanPos.getPBScanPosX(ch); hbotMoveTo(pos); return scan2dCode(100); } private String scanLittBS(int ch) throws AppException { - Pos2d pos = hbotScanPos.getLittBS(ch); + Pos2d pos = hbotScanPos.getLittBSX(ch); hbotMoveTo(pos); return scan2dCode(100); } private String scanLarBS(int ch) throws AppException { - Pos2d pos = hbotScanPos.getLarBS(ch); + Pos2d pos = hbotScanPos.getLarBSX(ch); hbotMoveTo(pos); return scan2dCode(100); } diff --git a/src/main/java/a8k/service/app/devicedriver/ctrl/HbotControlService.java b/src/main/java/a8k/service/app/devicedriver/ctrl/HbotControlService.java index 54d155c..8967690 100644 --- a/src/main/java/a8k/service/app/devicedriver/ctrl/HbotControlService.java +++ b/src/main/java/a8k/service/app/devicedriver/ctrl/HbotControlService.java @@ -3,8 +3,9 @@ package a8k.service.app.devicedriver.ctrl; import a8k.extapi_controler.pagecontrol.ExtApiTabConfig; import a8k.extapi_controler.utils.ExtApiFn; import a8k.extapi_controler.utils.ExtApiTab; -import a8k.hardware.A8kPipetteCtrlModule; -import a8k.hardware.type.regindex.PipetteRegIndex; +import a8k.service.app.devicedriver.ctrl.basic.PipetteCtrlModule; +import a8k.service.app.devicedriver.ctrl.basic.HbotModule; +import a8k.service.app.devicedriver.ctrl.type.PipetteRegIndex; import a8k.service.app.devicedriver.param.PosParam; import a8k.service.app.devicedriver.param.TimeParam; import a8k.type.ConsumableGroup; @@ -33,7 +34,10 @@ public class HbotControlService { A8kCanBusService canBus; @Resource - A8kPipetteCtrlModule pipetteCtrlModule; + PipetteCtrlModule pipetteCtrlModule; + + @Resource + HbotModule hbotModule; @Resource PosParam pp; @@ -71,10 +75,10 @@ public class HbotControlService { } // HBot移动 - canBus.hbotEnable(MId.HbotM, 1); - canBus.hbotMoveToBlock(MId.HbotM, targetPos.x - 20, targetPos.y - 20, ao); - canBus.hbotMoveToBlock(MId.HbotM, targetPos.x, targetPos.y, ao); - canBus.hbotMoveToBlock(MId.HbotM, targetPos.x, targetPos.y, ao); + hbotModule.enable( 1); + hbotModule.moveToBlock( targetPos.x - 20, targetPos.y - 20, ao); + hbotModule.moveToBlock( targetPos.x, targetPos.y, ao); + hbotModule.moveToBlock( targetPos.x, targetPos.y, ao); // Z轴移动 if (targetPos.z != 0) { @@ -83,7 +87,7 @@ public class HbotControlService { pipetteCtrlModule.zMotorMoveToBlock(targetPos.z); } pipetteCtrlModule.zMotorEnable(zEnable ? 1 : 0); - canBus.hbotEnable(MId.HbotM, hbotEnable ? 1 : 0); + hbotModule.enable( hbotEnable ? 1 : 0); } public void hbotMoveTo(Pos2d tpos) throws AppException { @@ -134,9 +138,9 @@ public class HbotControlService { } pipetteCtrlModule.zMotorEnable(1); - canBus.hbotEnable(MId.HbotM, 1); + hbotModule.enable( 1); - canBus.hbotMoveToZeroBlock(MId.HbotM, timep.getHbotRuntoZeroActionOvertime()); + hbotModule.moveToZeroBlock( timep.getHbotRuntoZeroActionOvertime()); // 丢弃tip Pos3d dropPos = pp.getTipDropPos(); @@ -238,12 +242,12 @@ public class HbotControlService { @ExtApiFn(name = "Hbot使能", group = "坐标获取工具") public void hBotEnable() throws AppException { - canBus.hbotEnable(MId.HbotM, 1); + hbotModule.enable( 1); } @ExtApiFn(name = "Hbot失能", group = "坐标获取工具") public void hBotDisable() throws AppException { - canBus.hbotEnable(MId.HbotM, 0); + hbotModule.enable(0); } @ExtApiFn(name = "Z轴使能", group = "坐标获取工具") @@ -285,11 +289,11 @@ public class HbotControlService { // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public Boolean getXPPS() throws AppException { - return canBus.hbotReadInio(MId.HbotM, 0); + return hbotModule.readInIO(0); } public Boolean getYPPS() throws AppException { - return canBus.hbotReadInio(MId.HbotM, 1); + return hbotModule.readInIO(1); } public Boolean getTipPPS() throws AppException { @@ -297,12 +301,12 @@ public class HbotControlService { } public String getPos() throws AppException { - Pos2d pos = canBus.hbotReadPos(MId.HbotM); + Pos2d pos = hbotModule.readPos(); return pos.toString(); } // public String getHbotRelaPos() throws AppException { - // Pos2d pos = canBus.hbotReadPos(MId.HbotM); + // Pos2d pos = hbotModule.hbotReadPos(MId.HbotM); // pos.x -= hbotRefPos.x; // pos.y -= hbotRefPos.y; // return pos.toString(); diff --git a/src/main/java/a8k/service/app/devicedriver/ctrl/basic/HbotModule.java b/src/main/java/a8k/service/app/devicedriver/ctrl/basic/HbotModule.java new file mode 100644 index 0000000..a2f6871 --- /dev/null +++ b/src/main/java/a8k/service/app/devicedriver/ctrl/basic/HbotModule.java @@ -0,0 +1,89 @@ +package a8k.service.app.devicedriver.ctrl.basic; + +import a8k.hardware.A8kCanBusService; +import a8k.hardware.type.a8kcanprotocol.CmdId; +import a8k.hardware.type.a8kcanprotocol.MId; +import a8k.service.app.devicedriver.ctrl.type.HbotRegIndex; +import a8k.type.cfg.Pos2d; +import a8k.type.exception.AppException; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Component; + +@Component +public class HbotModule { + + @Resource + A8kCanBusService canBus; + + public void enable(Integer enable) throws AppException { + canBus.callcmd(MId.HbotM.toInt(), CmdId.xymotor_enable.toInt(), enable); + } + + public void moveBy(Integer x, Integer y) throws AppException { + canBus.callcmd(MId.HbotM.toInt(), CmdId.xymotor_move_by.toInt(), x, y); + } + + public void moveByBlock(Integer x, Integer y, Integer actionOvertime) throws AppException { + moveBy(x, y); + canBus.waitForMod(MId.HbotM, actionOvertime); + } + + public void moveTo(Integer x, Integer y) throws AppException { + canBus.callcmd(MId.HbotM.toInt(), CmdId.xymotor_move_to.toInt(), x, y); + } + + public void moveToBlock(Integer x, Integer y, Integer actionOvertime) throws AppException { + moveTo(x, y); + canBus.waitForMod(MId.HbotM, actionOvertime); + } + + public void moveToZero() throws AppException { + canBus.callcmd(MId.HbotM.toInt(), CmdId.xymotor_move_to_zero.toInt()); + } + + public void moveToZeroBlock(Integer actionOvertime) throws AppException { + moveToZero(); + canBus.waitForMod(MId.HbotM, actionOvertime); + } + + public Pos2d readPos() throws AppException { + Pos2d pos = new Pos2d(0, 0); + var packet = canBus.callcmd(MId.HbotM.toInt(), CmdId.xymotor_read_pos.toInt()); + pos.x = packet.getContentI32(0); + pos.y = packet.getContentI32(1); + return pos; + } + + public Boolean readInIO(Integer ioIndex) throws AppException { + var packet = canBus.callcmd(MId.HbotM.toInt(), CmdId.xymotor_read_inio.toInt(), ioIndex); + return packet.getContentI32(0) != 0; + } + + public void setPos(Integer x, Integer y) throws AppException { + canBus.callcmd(MId.HbotM.toInt(), CmdId.xymotor_set_pos.toInt(), x, y); + } + + public void moveByDirect(Integer motor1_dpos, Integer motor2_dpos) throws AppException { + canBus.callcmd(MId.HbotM.toInt(), CmdId.xymotor_motor_move_by_direct.toInt(), motor1_dpos, motor2_dpos); + } + + public Integer readEncDirect() throws AppException { + var packet = canBus.callcmd(MId.HbotM.toInt(), CmdId.xymotor_read_enc_direct.toInt()); + return packet.getContentI32(0); + } + + public Integer hbotReadInioIndexInStm32(Integer ioIndex) throws AppException { + var packet = canBus.callcmd(MId.HbotM.toInt(), CmdId.xymotor_read_inio_index_in_stm32.toInt(), ioIndex); + return packet.getContentI32(0); + } + + public void setReg(HbotRegIndex regIndex, Integer value) throws AppException { + canBus.moduleSetReg(MId.HbotM, regIndex.regIndex, value); + } + + public Integer getReg(HbotRegIndex regIndex) throws AppException { + return canBus.moduleGetReg(MId.HbotM, regIndex.regIndex); + } + + +} diff --git a/src/main/java/a8k/service/app/devicedriver/ctrl/basic/PipetteCtrlModule.java b/src/main/java/a8k/service/app/devicedriver/ctrl/basic/PipetteCtrlModule.java new file mode 100644 index 0000000..68c2d6e --- /dev/null +++ b/src/main/java/a8k/service/app/devicedriver/ctrl/basic/PipetteCtrlModule.java @@ -0,0 +1,315 @@ +package a8k.service.app.devicedriver.ctrl.basic; + +import a8k.extapi_controler.pagecontrol.ExtApiTabConfig; +import a8k.extapi_controler.utils.ExtApiTab; +import a8k.extapi_controler.utils.ExtApiFn; +import a8k.hardware.A8kCanBusService; +import a8k.hardware.type.LldType; +import a8k.hardware.type.a8kcanprotocol.CmdId; +import a8k.hardware.type.a8kcanprotocol.MId; +import a8k.service.app.devicedriver.ctrl.type.PipetteRegIndex; +import a8k.hardware.type.regindex.RegIndex; +import a8k.type.exception.AppException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * 液面探测参数标定 + * 电容值标定: + * 1.失能z轴电机 + * 2.移动tip头分别处于液体中和液体外 + * 3.读取两次电容值 + * 4.取电容值差值的3/4作为阈值 + * 5.lld采用clld测试阈值是否工作正常 + * + * + */ + +@Component +@ExtApiTab(cfg = ExtApiTabConfig.A8kPipetteCtrlModule) +public class PipetteCtrlModule { + + @Resource + A8kCanBusService canBusService; + + final Integer overtime = 10000; + + static class FnOrder { + public static final int zMotorEnable = 1; + public static final int moduleStop = 2; + public static final int zMotorMoveZeroBlock = 3; + public static final int zMotorMoveToZeroPointQuickBlock = 4; + public static final int zMotorMoveByBlock = 5; + public static final int zMotorMoveToBlock = 6; + public static final int zMotorMeasureDistance = 7; + public static final int zMotorReadMeasureDistanceResult = 8; + public static final int initDeviceBlock = 9; + public static final int putTipBlock = 10; + public static final int lldPrepareBlock = 11; + public static final int lldBlock = 12; + public static final int lldCalibrationBlock = 12; + public static final int lldIsDetectLiquid = 13; + public static final int getSensorSampleData = 14; + public static final int readCapacitance = 15; + public static final int aspiratePrepareBlock = 16; + public static final int aspirateSetLlfVelocity = 17; + public static final int aspirateSetOperationVerifPThre = 18; + public static final int aspirateSetOperationVerifEigenTime = 19; + public static final int aspirateSetOperationVerifTolerance = 20; + public static final int aspirateBlock = 21; + public static final int aspirateAndVerifyBlock = 22; + public static final int shakeUpBlock = 23; + public static final int aspirateInferPressureBlock = 24; + public static final int aspirateInferEigenTimeBlock = 25; + public static final int getAspirateInferPressureResult = 26; + public static final int getAspirateInferEigenTimeResultBlock = 27; + public static final int zAixsZeroPointIsTrigger = 27; + public static final int setReg = 28; + public static final int getReg = 29; + public static final int getAllRegs = 30; + } + + @PostConstruct + public void init() { + + } + + @ExtApiFn(name = "z轴电机使能", order = FnOrder.zMotorEnable) + public void zMotorEnable(Integer enable) throws AppException { + canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_zmotor_enable.toInt(), enable); + } + + //stop + @ExtApiFn(name = "模块停止", order = FnOrder.moduleStop) + public void moduleStop() throws AppException { + canBusService.moduleStop(MId.PipetteMod); + } + + @ExtApiFn(name = "z轴电机归零", order = FnOrder.zMotorMoveZeroBlock) + public void zMotorMoveZeroBlock() throws AppException { + canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_zmotor_move_zero.toInt()); + canBusService.waitForMod(MId.PipetteMod, overtime); + } + + @ExtApiFn(name = "z轴电机快速归零", order = FnOrder.zMotorMoveToZeroPointQuickBlock) + public void zMotorMoveToZeroPointQuickBlock() throws AppException { + canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_zmotor_move_to_zero_point_quick.toInt()); + canBusService.waitForMod(MId.PipetteMod, overtime); + } + + @ExtApiFn(name = "z轴电机相对移动", order = FnOrder.zMotorMoveByBlock) + public void zMotorMoveByBlock(Integer distance) throws AppException { + canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_zmotor_move_by.toInt(), distance); + canBusService.waitForMod(MId.PipetteMod, overtime); + } + + @ExtApiFn(name = "z轴电机绝对移动", order = FnOrder.zMotorMoveToBlock) + public void zMotorMoveToBlock(Integer position) throws AppException { + canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_zmotor_move_to.toInt(), position); + canBusService.waitForMod(MId.PipetteMod, overtime); + } + //kpipette_zmotor_measure_distance + //kpipette_zmotor_read_measure_distance_result + + @ExtApiFn(name = "z轴电机测量距离", order = FnOrder.zMotorMeasureDistance) + public void zMotorMeasureDistance() throws AppException { + canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_zmotor_measure_distance.toInt()); + canBusService.waitForMod(MId.PipetteMod, overtime); + } + + @ExtApiFn(name = "z轴电机读取测量距离结果", order = FnOrder.zMotorReadMeasureDistanceResult) + public Integer zMotorReadMeasureDistanceResult() throws AppException { + var receipt = canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_zmotor_read_measure_distance_result.toInt()); + return receipt.getContentI32(0); + } + + + @ExtApiFn(name = "初始化设备", order = FnOrder.initDeviceBlock) + public void initDeviceBlock() throws AppException { + canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_init_device.toInt()); + canBusService.waitForMod(MId.PipetteMod, overtime); + } + + @ExtApiFn(name = "放置吸头", order = FnOrder.putTipBlock) + public void putTipBlock() throws AppException { + canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_put_tip.toInt()); + canBusService.waitForMod(MId.PipetteMod, overtime); + } + + @ExtApiFn(name = "LLD.准备", order = FnOrder.lldPrepareBlock) + public void lldPrepareBlock(Integer startPos) throws AppException { + canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_lld_prepare.toInt()); + canBusService.waitForMod(MId.PipetteMod, overtime); + + zMotorMoveToBlock(startPos); + } + + @ExtApiFn(name = "LLD.Do", order = FnOrder.lldBlock) + public void lldBlock(LldType lldtype, Integer startPos, Integer zdpos, Integer c_threshold, Integer p_threshold) + throws AppException { + canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_lld.toInt(), lldtype.getIndex(), startPos, zdpos, c_threshold, + p_threshold); + canBusService.waitForMod(MId.PipetteMod, overtime); + } + + @ExtApiFn(name = "LLD.参数标定", order = FnOrder.lldCalibrationBlock) + public void lldCalibrationBlock(Integer startPos, Integer zdpos) + throws AppException { + canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_lld_test.toInt(), startPos, zdpos); + canBusService.waitForMod(MId.PipetteMod, overtime); + } + + // kpipette_lld_is_detect_liquid + @ExtApiFn(name = "LLD.读取是否检测到液体", order = FnOrder.lldIsDetectLiquid) + public Boolean lldIsDetectLiquid() throws AppException { + var receipt = canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_lld_is_detect_liquid.toInt()); + return receipt.getContentI32(0) == 1; + } + + + public static class SensorSampleData { + public Integer motorPos; + public Integer cval; + public Integer pval; + } + + @ExtApiFn(name = "LLD.获取传感器采样数据", order = FnOrder.getSensorSampleData) + public List getSensorSampleData() throws AppException { + + List dataList = new java.util.ArrayList<>(); + int dataNUm = // + canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_get_sensor_sample_data_num.toInt()).getContentI32(0); + + for (int i = 0; i < dataNUm; i++) { + var receipt = canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_get_sensor_sample_data.toInt(), i); + var data = new SensorSampleData(); + data.motorPos = receipt.getContentI32(0); + data.cval = receipt.getContentI32(1); + data.pval = receipt.getContentI32(2); + dataList.add(data); + } + return dataList; + } + + @ExtApiFn(name = "LLD.读取电容值", order = FnOrder.readCapacitance) + public Integer readCapacitance() throws AppException { + return getReg(PipetteRegIndex.kreg_pipette_capactitance_val); + } + + + @ExtApiFn(name = "吸液准备", order = FnOrder.aspiratePrepareBlock) + public void aspiratePrepareBlock() throws AppException { + canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_aspirate_prepare.toInt()); + canBusService.waitForMod(MId.PipetteMod, overtime); + } + + @ExtApiFn(name = "设置LLF速度", order = FnOrder.aspirateSetLlfVelocity) + public void aspirateSetLlfVelocity(Integer llf_zm_rpm) throws AppException { + canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_aspirate_set_llf_velocity.toInt(), llf_zm_rpm); + } + + @ExtApiFn(name = "设置操作验证压力阈值", order = FnOrder.aspirateSetOperationVerifPThre) + public void aspirateSetOperationVerifPThre(Integer p_thre) throws AppException { + canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_aspirate_set_operation_verifi_p_thre.toInt(), + p_thre); + } + + @ExtApiFn(name = "设置操作验证时间", order = FnOrder.aspirateSetOperationVerifEigenTime) + public void aspirateSetOperationVerifEigenTime(Integer eigen_time) throws AppException { + canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_aspirate_set_operation_verifi_eigen_time.toInt(), + eigen_time); + } + + @ExtApiFn(name = "设置操作验证容忍度", order = FnOrder.aspirateSetOperationVerifTolerance) + public void aspirateSetOperationVerifTolerance(Integer tolerance) throws AppException { + canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_aspirate_set_operation_verifi_tolerance.toInt(), + tolerance); + } + + @ExtApiFn(name = "吸液", order = FnOrder.aspirateBlock) + public void aspirateBlock(Integer ul) throws AppException { + canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_aspirate.toInt(), ul); + canBusService.waitForMod(MId.PipetteMod, overtime); + } + + @ExtApiFn(name = "吸液并验证", order = FnOrder.aspirateAndVerifyBlock) + public void aspirateAndVerifyBlock(Integer ul) throws AppException { + canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_aspirate_and_verify.toInt(), ul); + canBusService.waitForMod(MId.PipetteMod, overtime); + } + + @ExtApiFn(name = "振荡", order = FnOrder.shakeUpBlock) + public void shakeUpBlock(Integer ul, Integer times) throws AppException { + canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_shake_up.toInt(), ul, times); + canBusService.waitForMod(MId.PipetteMod, overtime + times * 3000); + } + + @ExtApiFn(name = "吸液推算压力", order = FnOrder.aspirateInferPressureBlock) + public void aspirateInferPressureBlock(Integer ul) throws AppException { + canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_aspirate_infer_pressure.toInt(), ul); + canBusService.waitForMod(MId.PipetteMod, overtime); + } + + @ExtApiFn(name = "吸液推算时间", order = FnOrder.aspirateInferEigenTimeBlock) + public void aspirateInferEigenTimeBlock(Integer ul) throws AppException { + canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_aspirate_infer_eigen_time.toInt(), ul); + canBusService.waitForMod(MId.PipetteMod, overtime); + } + + @ExtApiFn(name = "获取吸液推算压力结果", order = FnOrder.getAspirateInferPressureResult) + public Integer getAspirateInferPressureResult() throws AppException { + var receipt = canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_get_aspirate_infer_pressure_result.toInt()); + return receipt.getContentI32(0); + } + + @ExtApiFn(name = "获取吸液推算时间结果", order = FnOrder.getAspirateInferEigenTimeResultBlock) + public Integer getAspirateInferEigenTimeResultBlock() throws AppException { + var receipt = canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_get_aspirate_infer_eigen_time_result.toInt()); + return receipt.getContentI32(0); + } + + @ExtApiFn(name = "z轴零点是否触发", order = FnOrder.zAixsZeroPointIsTrigger) + public Boolean zAixsZeroPointIsTrigger() throws AppException { + return canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_zmotor_read_zero_point_state.toInt()).getContentI32(0) == 1; + } + + + // @EnginnerPageAction(name = "获取传感器采样数据数量", order = FnOrder.getSensorSampleDataNum) + // public Integer getSensorSampleDataNum() throws HardwareException { + // return canBusService.callcmd(MId.PipetteMod.toInt(), CmdId.pipette_get_sensor_sample_data_num.toInt()).getContentI32(0); + // } + + @ExtApiFn(name = "设置寄存器", order = FnOrder.setReg) + public void setReg(PipetteRegIndex regIndex, Integer val) throws AppException { + RegIndex regindex = RegIndex.valueOf(regIndex.index); + assert regindex != null; + canBusService.moduleSetReg(MId.PipetteMod, regindex, val); + } + + @ExtApiFn(name = "获取寄存器", order = FnOrder.getReg) + public Integer getReg(PipetteRegIndex regIndex) throws AppException { + RegIndex regindex = RegIndex.valueOf(regIndex.index); + assert regindex != null; + return canBusService.moduleGetReg(MId.PipetteMod, regindex); + } + + @ExtApiFn(name = "获取所有寄存器", order = FnOrder.getAllRegs) + public ObjectNode getAllRegs() throws AppException { + ObjectMapper mapper = new ObjectMapper(); + ObjectNode json = mapper.createObjectNode(); + + // 遍历所有 PipetteRegIndex + for (PipetteRegIndex regIndex : PipetteRegIndex.values()) { + RegIndex regindex = RegIndex.valueOf(regIndex.index); + assert regindex != null; + Integer val = canBusService.moduleGetReg(MId.PipetteMod, regindex); + json.put(regIndex.name(), val); + } + return json; + } +} diff --git a/src/main/java/a8k/service/app/devicedriver/ctrl/type/HbotRegIndex.java b/src/main/java/a8k/service/app/devicedriver/ctrl/type/HbotRegIndex.java new file mode 100644 index 0000000..4ce2c1f --- /dev/null +++ b/src/main/java/a8k/service/app/devicedriver/ctrl/type/HbotRegIndex.java @@ -0,0 +1,51 @@ +package a8k.service.app.devicedriver.ctrl.type; + +import a8k.hardware.type.regindex.RegIndex; + +public enum HbotRegIndex { + kreg_module_version(RegIndex.kreg_module_version), // 模块版本 + kreg_module_type(RegIndex.kreg_module_type), // 模块类型 + kreg_module_status(RegIndex.kreg_module_status), // 0idle,1busy,2error + kreg_module_errorcode(RegIndex.kreg_module_errorcode), // inited_flag + kreg_extboard_resetflag(RegIndex.kreg_extboard_resetflag), + + kreg_xyrobot_io_state(RegIndex.kreg_xyrobot_io_state), // + kreg_xyrobot_is_enable(RegIndex.kreg_xyrobot_is_enable), // + kreg_xyrobot_robot_type(RegIndex.kreg_xyrobot_robot_type), // + kreg_xyrobot_one_circle_pulse(RegIndex.kreg_xyrobot_one_circle_pulse), // + kreg_xyrobot_one_circle_pulse_denominator(RegIndex.kreg_xyrobot_one_circle_pulse_denominator), // + kreg_xyrobot_ihold(RegIndex.kreg_xyrobot_ihold), // + kreg_xyrobot_irun(RegIndex.kreg_xyrobot_irun), // + kreg_xyrobot_iholddelay(RegIndex.kreg_xyrobot_iholddelay), // + kreg_xyrobot_iglobalscaler(RegIndex.kreg_xyrobot_iglobalscaler), // + kreg_xyrobot_vstart(RegIndex.kreg_xyrobot_vstart), // + kreg_xyrobot_a1(RegIndex.kreg_xyrobot_a1), // + kreg_xyrobot_amax(RegIndex.kreg_xyrobot_amax), // + kreg_xyrobot_v1(RegIndex.kreg_xyrobot_v1), // + kreg_xyrobot_dmax(RegIndex.kreg_xyrobot_dmax), // + kreg_xyrobot_d1(RegIndex.kreg_xyrobot_d1), // + kreg_xyrobot_vstop(RegIndex.kreg_xyrobot_vstop), // + kreg_xyrobot_tzerowait(RegIndex.kreg_xyrobot_tzerowait), // + kreg_xyrobot_enc_resolution(RegIndex.kreg_xyrobot_enc_resolution), // + kreg_xyrobot_enable_enc(RegIndex.kreg_xyrobot_enable_enc), // + kreg_xyrobot_x_shaft(RegIndex.kreg_xyrobot_x_shaft), // + kreg_xyrobot_y_shaft(RegIndex.kreg_xyrobot_y_shaft), // + kreg_xyrobot_min_x(RegIndex.kreg_xyrobot_min_x), // + kreg_xyrobot_min_y(RegIndex.kreg_xyrobot_min_y), // + kreg_xyrobot_max_x(RegIndex.kreg_xyrobot_max_x), // + kreg_xyrobot_max_y(RegIndex.kreg_xyrobot_max_y), // + kreg_xyrobot_run_to_zero_speed(RegIndex.kreg_xyrobot_run_to_zero_speed), // + kreg_xyrobot_look_zero_edge_speed(RegIndex.kreg_xyrobot_look_zero_edge_speed), // + kreg_xyrobot_shift_x(RegIndex.kreg_xyrobot_shift_x), // + kreg_xyrobot_shift_y(RegIndex.kreg_xyrobot_shift_y), // + kreg_xyrobot_pos_devi_tolerance(RegIndex.kreg_xyrobot_pos_devi_tolerance), // + kreg_xyrobot_io_trigger_append_distance(RegIndex.kreg_xyrobot_io_trigger_append_distance), // + kreg_xyrobot_default_velocity(RegIndex.kreg_xyrobot_default_velocity), // + ; + + public final RegIndex regIndex; + HbotRegIndex(RegIndex regIndex) { + this.regIndex = regIndex; + } + +} diff --git a/src/main/java/a8k/service/app/devicedriver/ctrl/type/PipetteRegIndex.java b/src/main/java/a8k/service/app/devicedriver/ctrl/type/PipetteRegIndex.java new file mode 100644 index 0000000..ac3547d --- /dev/null +++ b/src/main/java/a8k/service/app/devicedriver/ctrl/type/PipetteRegIndex.java @@ -0,0 +1,79 @@ +package a8k.service.app.devicedriver.ctrl.type; + +public enum PipetteRegIndex { + kreg_module_version(0), // 模块版本 + kreg_module_type(1), // 模块类型 + kreg_module_status(2), // 0idle,1busy,2error + kreg_module_errorcode(3), // inited_flag + + kreg_pipette_pos_ul(4000), // 移液枪位置 + kreg_pipette_capactitance_val(4001), // 移液枪电容值 + kreg_pipette_tip_state(4002, false), // 移动液枪tip状态 + + kreg_pipette_limit_ul(4051), // + kreg_pipette_pump_acc(4052), // + kreg_pipette_pump_dec(4053), // + kreg_pipette_pump_vstart(4054), // + kreg_pipette_pump_vstop(4055), // + kreg_pipette_pump_vmax(4056), // + kreg_pipette_aspirate_distribut_pump_vel(4057), // + kreg_pipette_lld_pump_vel(4058), // + kreg_pipette_lld_motor_vel_rpm(4059), // + kreg_pipette_lld_detect_period_ms(4060), // + kreg_pipette_lld_prepare_pos(4061), // + kreg_pipette_lld_prepare_distribut_pos(4062), // + + kreg_pipette_zm_pos(4101), + kreg_pipette_zm_is_enable(4102), + kreg_pipette_zm_dpos(4103), + //kreg_pipette_zm_shift(4105), + kreg_pipette_zm_shaft(4106), + kreg_pipette_zm_one_circle_pulse(4107), + kreg_pipette_zm_one_circle_pulse_denominator(4108), + kreg_pipette_zm_default_velocity(4109), + kreg_pipette_zm_ihold(4110), + kreg_pipette_zm_irun(4111), + kreg_pipette_zm_iholddelay(4112), + kreg_pipette_zm_iglobalscaler(4113), + kreg_pipette_zm_run_to_zero_speed(4114), + kreg_pipette_zm_look_zero_edge_speed(4115), + kreg_pipette_zm_max_d(4116), + kreg_pipette_zm_min_d(4117), +// kreg_pipette_zm_in_debug_mode(4118), + kreg_pipette_zm_vstart(4119), + kreg_pipette_zm_a1(4120), + kreg_pipette_zm_amax(4121), + kreg_pipette_zm_v1(4122), + kreg_pipette_zm_dmax(4123), + kreg_pipette_zm_d1(4124), + kreg_pipette_zm_vstop(4125), + kreg_pipette_zm_tzerowait(4126), + kreg_pipette_zm_enc_resolution(4127), + kreg_pipette_zm_enable_enc(4128), + kreg_pipette_zm_dzero(4129), + kreg_pipette_zm_pos_devi_tolerance(4130), + kreg_pipette_zm_io_trigger_append_distance(4131); + + public final int index; + public final Boolean trace; + + PipetteRegIndex(int regIndex) { + this.index = regIndex; + this.trace = true; + } + + PipetteRegIndex(int regIndex, Boolean trace) { + this.index = regIndex; + this.trace = trace; + } + + public static PipetteRegIndex valueOf(int val) { + PipetteRegIndex[] values = PipetteRegIndex.values(); + for (PipetteRegIndex regindex : values) { + if (regindex.index == val) { + return regindex; + } + } + return null; + } +} diff --git a/src/main/java/a8k/service/app/devicedriver/param/Hbot2DCodeScanPos.java b/src/main/java/a8k/service/app/devicedriver/param/Hbot2DCodeScanPos.java index 75786d4..7412b52 100644 --- a/src/main/java/a8k/service/app/devicedriver/param/Hbot2DCodeScanPos.java +++ b/src/main/java/a8k/service/app/devicedriver/param/Hbot2DCodeScanPos.java @@ -2,13 +2,15 @@ package a8k.service.app.devicedriver.param; import a8k.extapi_controler.pagecontrol.ExtApiTabConfig; import a8k.extapi_controler.utils.*; -import a8k.hardware.type.a8kcanprotocol.A8kEcode; +import a8k.service.db.PosParameterDBService; +import a8k.service.db.utils.PosParameterReader; import a8k.type.cfg.Pos2d; import a8k.type.exception.AppException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import jakarta.annotation.PostConstruct; +import jakarta.annotation.Resource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -20,27 +22,56 @@ import org.springframework.stereotype.Component; @ExtApiTab(cfg = ExtApiTabConfig.Hbot2DCodeScanPos) @ExtApiParamsTab(service = Hbot2DCodeScanPos.class) public class Hbot2DCodeScanPos { - Logger logger = LoggerFactory.getLogger(Hbot2DCodeScanPos.class); - EnginnerParamReader hpReader = new EnginnerParamReader(Hbot2DCodeScanPos.class); + static final Logger logger = LoggerFactory.getLogger(Hbot2DCodeScanPos.class); - static Integer nowParaVersion = 5; + @Resource + PosParameterDBService posParameterDBService; - //板夹仓扫码位置 - //小缓冲液扫码位置 - //大缓冲扫码位置 + PosParameterReader posReader = null; + static Integer nowParaVersion = 0; @PostConstruct void initialize() { - Integer paraVersion = hpReader.getInteger("paramVersion", 0); + posReader = posParameterDBService.getReader(this.getClass()); + Integer paraVersion = posReader.getVersion(); if (!nowParaVersion.equals(paraVersion)) { paramReset(); } } + public void setPBScanPosX(Integer X, Pos2d pos) { + logger.info("setPBScanPos{} {}", X, pos); + posReader.updatePos("PBScanPos" + X, pos); + } + + public void setLittBSX(Integer X, Pos2d pos) { + logger.info("setLittBS{} {}", X, pos); + posReader.updatePos("LittBS" + X, pos); + } + + public void setLarBSX(Integer X, Pos2d pos) { + logger.info("setLarBS{} {}", X, pos); + posReader.updatePos("LarBS" + X, pos); + } + + public Pos2d getPBScanPosX(Integer X) { + return posReader.getPos("PBScanPos" + X, Pos2d.class); + } + + public Pos2d getLittBSX(Integer X) { + return posReader.getPos("LittBS" + X, Pos2d.class); + } + + public Pos2d getLarBSX(Integer X) { + return posReader.getPos("LarBS" + X, Pos2d.class); + } + + public void paramReset() { - hpReader.setInteger("paramVersion", nowParaVersion); + logger.info("init param"); + posReader.setVersion(nowParaVersion); { @@ -48,12 +79,12 @@ public class Hbot2DCodeScanPos { Pos2d pos0 = new Pos2d(-20, 1504); int scanYSpacing = 265; - hpReader.setObject("PBScanPos0", pos0); - hpReader.setObject("PBScanPos1", pos0.add(0, scanYSpacing)); - hpReader.setObject("PBScanPos2", pos0.add(0, scanYSpacing * 2)); - hpReader.setObject("PBScanPos3", pos0.add(0, scanYSpacing * 3)); - hpReader.setObject("PBScanPos4", pos0.add(0, scanYSpacing * 4)); - hpReader.setObject("PBScanPos5", pos0.add(0, scanYSpacing * 5)); + setPBScanPosX(0, pos0); + setPBScanPosX(1, pos0.add(0, scanYSpacing)); + setPBScanPosX(2, pos0.add(0, scanYSpacing * 2)); + setPBScanPosX(3, pos0.add(0, scanYSpacing * 3)); + setPBScanPosX(4, pos0.add(0, scanYSpacing * 4)); + setPBScanPosX(5, pos0.add(0, scanYSpacing * 5)); } @@ -63,12 +94,12 @@ public class Hbot2DCodeScanPos { int xSpacing = 1230; int ySpacing = 1250; - hpReader.setObject("LittBS0", pos0.add(0, 0)); - hpReader.setObject("LittBS1", pos0.add(xSpacing, 0)); - hpReader.setObject("LittBS2", pos0.add(xSpacing * 2, 0)); - hpReader.setObject("LittBS3", pos0.add(0, ySpacing)); - hpReader.setObject("LittBS4", pos0.add(xSpacing, ySpacing)); - hpReader.setObject("LittBS5", pos0.add(xSpacing * 2, ySpacing)); + setLittBSX(0, pos0.add(0, 0)); + setLittBSX(1, pos0.add(xSpacing, 0)); + setLittBSX(2, pos0.add(xSpacing * 2, 0)); + setLittBSX(3, pos0.add(0, ySpacing)); + setLittBSX(4, pos0.add(xSpacing, ySpacing)); + setLittBSX(5, pos0.add(xSpacing * 2, ySpacing)); } { @@ -77,133 +108,18 @@ public class Hbot2DCodeScanPos { int xSpacing = 280; int ySpacing = 580; - hpReader.setObject("LarBS0", LarBSPos0.add(0, 0)); - hpReader.setObject("LarBS1", LarBSPos0.add(xSpacing, 0)); - hpReader.setObject("LarBS2", LarBSPos0.add(xSpacing * 2, 0)); - hpReader.setObject("LarBS3", LarBSPos0.add(0, ySpacing)); - hpReader.setObject("LarBS4", LarBSPos0.add(xSpacing, ySpacing)); - hpReader.setObject("LarBS5", LarBSPos0.add(xSpacing * 2, ySpacing)); + setLarBSX(0, LarBSPos0.add(0, 0)); + setLarBSX(1, LarBSPos0.add(xSpacing, 0)); + setLarBSX(2, LarBSPos0.add(xSpacing * 2, 0)); + setLarBSX(3, LarBSPos0.add(0, ySpacing)); + setLarBSX(4, LarBSPos0.add(xSpacing, ySpacing)); + setLarBSX(5, LarBSPos0.add(xSpacing * 2, ySpacing)); } } - @ExtApiParam(name = "板夹仓-扫码-POS0", group = "板夹仓", order = 0) - public Pos2d getPBScanPos0() throws AppException {return hpReader.getObject("PBScanPos0", Pos2d.class);} - - @ExtApiParam(name = "板夹仓-扫码-POS1", group = "板夹仓", order = 1) - public Pos2d getPBScanPos1() throws AppException {return hpReader.getObject("PBScanPos1", Pos2d.class);} - - @ExtApiParam(name = "板夹仓-扫码-POS2", group = "板夹仓", order = 2) - public Pos2d getPBScanPos2() throws AppException {return hpReader.getObject("PBScanPos2", Pos2d.class);} - - @ExtApiParam(name = "板夹仓-扫码-POS3", group = "板夹仓", order = 3) - public Pos2d getPBScanPos3() throws AppException {return hpReader.getObject("PBScanPos3", Pos2d.class);} - - @ExtApiParam(name = "板夹仓-扫码-POS4", group = "板夹仓", order = 4) - public Pos2d getPBScanPos4() throws AppException {return hpReader.getObject("PBScanPos4", Pos2d.class);} - - @ExtApiParam(name = "板夹仓-扫码-POS5", group = "板夹仓", order = 5) - public Pos2d getPBScanPos5() throws AppException {return hpReader.getObject("PBScanPos5", Pos2d.class);} - - - public Pos2d getPBScanPos(int ch) throws AppException { - return switch (ch) { - case 0 -> getPBScanPos0(); - case 1 -> getPBScanPos1(); - case 2 -> getPBScanPos2(); - case 3 -> getPBScanPos3(); - case 4 -> getPBScanPos4(); - case 5 -> getPBScanPos5(); - default -> throw new AppException(A8kEcode.CODEERROR); - }; - } - - @ExtApiParam(name = "小瓶缓冲液(LittBS)-扫码-POS0", group = "小瓶缓冲液(LittBS)", order = 0) - public Pos2d getLittBS0() throws AppException {return hpReader.getObject("LittBS0", Pos2d.class);} - - @ExtApiParam(name = "小瓶缓冲液(LittBS)-扫码-POS1", group = "小瓶缓冲液(LittBS)", order = 1) - public Pos2d getLittBS1() throws AppException {return hpReader.getObject("LittBS1", Pos2d.class);} - - @ExtApiParam(name = "小瓶缓冲液(LittBS)-扫码-POS2", group = "小瓶缓冲液(LittBS)", order = 2) - public Pos2d getLittBS2() throws AppException {return hpReader.getObject("LittBS2", Pos2d.class);} - - @ExtApiParam(name = "小瓶缓冲液(LittBS)-扫码-POS3", group = "小瓶缓冲液(LittBS)", order = 3) - public Pos2d getLittBS3() throws AppException {return hpReader.getObject("LittBS3", Pos2d.class);} - - @ExtApiParam(name = "小瓶缓冲液(LittBS)-扫码-POS4", group = "小瓶缓冲液(LittBS)", order = 4) - public Pos2d getLittBS4() throws AppException {return hpReader.getObject("LittBS4", Pos2d.class);} - - @ExtApiParam(name = "小瓶缓冲液(LittBS)-扫码-POS5", group = "小瓶缓冲液(LittBS)", order = 5) - public Pos2d getLittBS5() throws AppException {return hpReader.getObject("LittBS5", Pos2d.class);} - - public Pos2d getLittBS(int ch) throws AppException { - return switch (ch) { - case 0 -> getLittBS0(); - case 1 -> getLittBS1(); - case 2 -> getLittBS2(); - case 3 -> getLittBS3(); - case 4 -> getLittBS4(); - case 5 -> getLittBS5(); - default -> throw new AppException(A8kEcode.CODEERROR); - }; - } - - @ExtApiParam(name = "大瓶缓冲液(LarBS)", group = "大瓶缓冲液(LarBS)", order = 0) - public Pos2d getLarBS0() throws AppException {return hpReader.getObject("LarBS0", Pos2d.class);} - - @ExtApiParam(name = "大瓶缓冲液(LarBS)", group = "大瓶缓冲液(LarBS)", order = 1) - public Pos2d getLarBS1() throws AppException {return hpReader.getObject("LarBS1", Pos2d.class);} - - @ExtApiParam(name = "大瓶缓冲液(LarBS)", group = "大瓶缓冲液(LarBS)", order = 2) - public Pos2d getLarBS2() throws AppException {return hpReader.getObject("LarBS2", Pos2d.class);} - - @ExtApiParam(name = "大瓶缓冲液(LarBS)", group = "大瓶缓冲液(LarBS)", order = 3) - public Pos2d getLarBS3() throws AppException {return hpReader.getObject("LarBS3", Pos2d.class);} - - @ExtApiParam(name = "大瓶缓冲液(LarBS)", group = "大瓶缓冲液(LarBS)", order = 4) - public Pos2d getLarBS4() throws AppException {return hpReader.getObject("LarBS4", Pos2d.class);} - - @ExtApiParam(name = "大瓶缓冲液(LarBS)", group = "大瓶缓冲液(LarBS)", order = 5) - public Pos2d getLarBS5() throws AppException {return hpReader.getObject("LarBS5", Pos2d.class);} - - public Pos2d getLarBS(int ch) throws AppException { - return switch (ch) { - case 0 -> getLarBS0(); - case 1 -> getLarBS1(); - case 2 -> getLarBS2(); - case 3 -> getLarBS3(); - case 4 -> getLarBS4(); - case 5 -> getLarBS5(); - default -> throw new AppException(A8kEcode.CODEERROR); - }; - } - - @ExtApiFn(name = "获取所有坐标", order = 1) - public ObjectNode getPoss() throws AppException { - ObjectMapper mapper = new ObjectMapper(); - - ObjectNode node = new ObjectMapper().createObjectNode(); - ArrayNode PBScanPos = node.putArray("PBScanPos"); - ArrayNode LittBSScanPos = node.putArray("LittBSScanPos"); - ArrayNode LarBSScanPos = node.putArray("LarBSScanPos"); - - for (int i = 0; i < 6; i++) { - PBScanPos.add(mapper.valueToTree(getPBScanPos(i).toString())); - } - - for (int i = 0; i < 6; i++) { - LittBSScanPos.add(mapper.valueToTree(getLittBS(i).toString())); - } - - for (int i = 0; i < 6; i++) { - LarBSScanPos.add(mapper.valueToTree(getLarBS(i).toString())); - } - - - return node; - } } diff --git a/src/main/java/a8k/service/app/devicedriver/status/DeviceStatus.java b/src/main/java/a8k/service/app/devicedriver/status/DeviceStatus.java index fc76f6a..9cdcdb7 100644 --- a/src/main/java/a8k/service/app/devicedriver/status/DeviceStatus.java +++ b/src/main/java/a8k/service/app/devicedriver/status/DeviceStatus.java @@ -63,15 +63,15 @@ public class DeviceStatus { return canBus.getIOState(IOId.THChInterPPS); } - @ExtApiStatu(name = "X轴光电➡", group = "HBOT", order = ORDER.getXPPS) - public Boolean getXPPS() throws AppException { - return canBus.hbotReadInio(MId.HbotM, 0); - } + // @ExtApiStatu(name = "X轴光电➡", group = "HBOT", order = ORDER.getXPPS) + // public Boolean getXPPS() throws AppException { + // return canBus.hbotReadInio(MId.HbotM, 0); + // } - @ExtApiStatu(name = "Y轴光电⬇", group = "HBOT", order = ORDER.getYPPS) - public Boolean getYPPS() throws AppException { - return canBus.hbotReadInio(MId.HbotM, 1); - } + // @ExtApiStatu(name = "Y轴光电⬇", group = "HBOT", order = ORDER.getYPPS) + // public Boolean getYPPS() throws AppException { + // return canBus.hbotReadInio(MId.HbotM, 1); + // } // @EnginnerPageStatu(name = "Z轴光电⬆", group = "HBOT", order = ORDER.getZPPS) // public Boolean getZPPS() throws HardwareException { diff --git a/src/main/java/a8k/service/db/PosParameterDBService.java b/src/main/java/a8k/service/db/PosParameterDBService.java new file mode 100644 index 0000000..30388c7 --- /dev/null +++ b/src/main/java/a8k/service/db/PosParameterDBService.java @@ -0,0 +1,96 @@ +package a8k.service.db; + +import a8k.service.app.appdata.UtilsProjectColorAllocer; +import a8k.service.db.type.PosParameter; +import a8k.service.db.utils.PosParameterReader; +import a8k.service.debug.AppDebugHelperService; +import a8k.utils.ZSqliteJdbcHelper; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jsr310.ser.ZoneIdSerializer; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.Resource; +import lombok.SneakyThrows; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Component; + +import java.sql.ResultSet; +import java.util.List; + +@Component +public class PosParameterDBService { + private static final Logger logger = LoggerFactory.getLogger(PosParameterDBService.class); + private static final String tableName = "zapp_a8k_pos_parameter"; + private static final Class tClass = PosParameter.class; + + + @Resource + JdbcTemplate jdbcTemplate; + + @PostConstruct + void init() { + if (!ZSqliteJdbcHelper.isTableExist(jdbcTemplate, tableName)) { + ZSqliteJdbcHelper.createTable(jdbcTemplate, tableName, tClass); + } + } + + @SneakyThrows private PosParameter rowMapper(ResultSet rs, int rowNum) { + return (PosParameter) ZSqliteJdbcHelper.rowMapper(rs, tClass); + } + + + public T getParam(String service, String key, Class tClass) { + List list = jdbcTemplate.query("select * from " + tableName + " where service = ? and key = ?;", this::rowMapper, service, key); + if (list.isEmpty()) { + return null; + } + + PosParameter posParameter = list.get(0); + try { + return new ObjectMapper().readValue(posParameter.val, tClass); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + + public void updateParam(String service, String key, Object pos) { + try { + ObjectMapper objectMapper = new ObjectMapper(); + List list = jdbcTemplate.query("select * from " + tableName + " where service = ? and key = ?;", this::rowMapper, service, key); + if (list.isEmpty()) { + PosParameter posParameter = new PosParameter(); + posParameter.service = service; + posParameter.key = key; + posParameter.val = objectMapper.writeValueAsString(pos); + posParameter.valType = pos.getClass().getSimpleName(); + ZSqliteJdbcHelper.addObj(jdbcTemplate, tableName, tClass, posParameter); + return; + } + + PosParameter posParameter = list.get(0); + posParameter.val = objectMapper.writeValueAsString(pos); + posParameter.service = service; + posParameter.key = key; + posParameter.valType = pos.getClass().getSimpleName(); + ZSqliteJdbcHelper.updateObj(jdbcTemplate, tableName, tClass, posParameter); + + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + + public Integer getParamVersion(String service) { + return getParam(service, "VERSION", Integer.class); + } + + public void setParamVersion(String service, Integer version) { + updateParam(service, "VERSION", 0); + } + + public PosParameterReader getReader(Class type) { + return new PosParameterReader(this, type); + } + +} diff --git a/src/main/java/a8k/service/db/type/PosParameter.java b/src/main/java/a8k/service/db/type/PosParameter.java new file mode 100644 index 0000000..7eb5bbf --- /dev/null +++ b/src/main/java/a8k/service/db/type/PosParameter.java @@ -0,0 +1,9 @@ +package a8k.service.db.type; + +public class PosParameter { + public int id; + public String service; + public String key; + public String valType; + public String val; +} diff --git a/src/main/java/a8k/service/db/utils/PosParameterReader.java b/src/main/java/a8k/service/db/utils/PosParameterReader.java new file mode 100644 index 0000000..c9544fa --- /dev/null +++ b/src/main/java/a8k/service/db/utils/PosParameterReader.java @@ -0,0 +1,30 @@ +package a8k.service.db.utils; + +import a8k.service.db.PosParameterDBService; +import jakarta.annotation.Resource; + +public class PosParameterReader { + Class tClass; + PosParameterDBService posParameterDBService; + + public PosParameterReader(PosParameterDBService dbservice, Class tClass) { + posParameterDBService = dbservice; + this.tClass = tClass; + } + + public T getPos(String key, Class tClass) { + return posParameterDBService.getParam(tClass.getSimpleName(), key, tClass); + } + + public void updatePos(String key, Object pos) { + posParameterDBService.updateParam(tClass.getSimpleName(), key, pos); + } + + public Integer getVersion() { + return posParameterDBService.getParamVersion(tClass.getSimpleName()); + } + + public void setVersion(Integer version) { + posParameterDBService.setParamVersion(tClass.getSimpleName(), version); + } +}