From cc388fe752f2048bcaaf60b37d225b6b91e04cb2 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Wed, 24 Jul 2024 11:06:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SamplesPreProcessModuleCtrlService.java | 289 ++++++--------------- 1 file changed, 81 insertions(+), 208 deletions(-) diff --git a/src/main/java/a8k/service/hardware/SamplesPreProcessModuleCtrlService.java b/src/main/java/a8k/service/hardware/SamplesPreProcessModuleCtrlService.java index 273e011..258bf14 100644 --- a/src/main/java/a8k/service/hardware/SamplesPreProcessModuleCtrlService.java +++ b/src/main/java/a8k/service/hardware/SamplesPreProcessModuleCtrlService.java @@ -47,15 +47,15 @@ public class SamplesPreProcessModuleCtrlService implements HardwareCtrlModule { } public Integer getGripperTakeCapPos() { - return 60;// + return 55;// } public Integer getGripperTakeTubeYPos() { - return 2717; + return 2735; } public Integer getGripperShakeYPos() { - return 1778; + return 1828; } public Integer getGripperZeroYPos() { @@ -68,7 +68,7 @@ public class SamplesPreProcessModuleCtrlService implements HardwareCtrlModule { } public Integer getGripperTakeSTubeZPos() { - return 977; + return 985; } //JudgeTubeCapZ @@ -301,6 +301,10 @@ public class SamplesPreProcessModuleCtrlService implements HardwareCtrlModule { //Y轴移动到摇匀位 logger.info("Y轴移动到摇匀位"); + + canBus.miniServoMoveTo(MId.ShakeModGripperYSV, getGripperShakeYPos() - 50); //该动作是为了消除齿轮间隙 + canBus.waitForMod(MId.ShakeModGripperYSV, getActionOvertime()); + canBus.miniServoMoveTo(MId.ShakeModGripperYSV, getGripperShakeYPos()); canBus.waitForMod(MId.ShakeModGripperYSV, getActionOvertime()); actionDelay(); @@ -370,7 +374,7 @@ public class SamplesPreProcessModuleCtrlService implements HardwareCtrlModule { //Z下移动到取试管帽位置 logger.info("Z下移动到取试管帽位置"); - canBus.stepMotorEasyMoveTo(MId.ShakeModGripperZM, getGripperTakeCapZPos() + 10); + canBus.stepMotorEasyMoveTo(MId.ShakeModGripperZM, getGripperTakeCapZPos() + 3); canBus.waitForMod(MId.ShakeModGripperZM, getActionOvertime()); actionDelay(); @@ -390,209 +394,78 @@ public class SamplesPreProcessModuleCtrlService implements HardwareCtrlModule { canBus.waitForMods(new MId[]{MId.ShakeModGripperYSV}, getActionOvertime()); } - // /* ======================================================================================= - // 主要服务 - // =======================================================================================*/ - // - // - // /* - // * 整体流程: - // * 1.试管(只有全血试管,才取试管) - // * 2.GripperYSM移动到取试管的位置 - // * 3.打开夹爪 - // * 4.ZM下移动到试管帽有无检测位,检测试管帽有无 - // * 5.ZM下移动到取试管位置,取试管 - // * 6.ZM上移到零位,同时判断是否发生丢步 - // * 7.YSM移动到摇匀位 - // * 8.ZM下移动到摇匀位放试管的位置 - // * 9.放置试管 - // * - // * 夹爪打开(夹爪打开为待机位),ZM,YSM,回零, - // */ - // - // - // /** - // * 取试管帽,如果试管帽存在, - // * @param tubeType HighBlood,ShortBlood,Mini,MiniBlood,BulletTube1P5,BulletTube0P5 - // * @param judgeCapExist 是否判断试管帽子存在与否 - // */ - // public A8kEcode takeTube(String tubeType, Boolean judgeCapExist) throws HardwareException, InterruptedException { - // logger.info("takeTube {} {}", tubeType, judgeCapExist); - // - // /* - // * check: - // * 1.当前摇匀模组设计到的电机是否都处于待机位 - // * - // * step: - // * - // * - // * - // * - // */ - // - // - // var params = this.paramDao; - // this.canBus.callblockcmd(MId.ShakeModGripperYSV.toInt(), CmdId.mini_servo_move_to.toInt(), params.getHorizontalMotor_takeCapPos(), params.getActionOvertime()); - // - // this.canBus.callblockcmd(MId.ShakeModClampingM.toInt(), CmdId.step_motor_easy_move_to.toInt(), params.getTubeClampMotor_standbyPos(), params.getActionOvertime()); - // - // var motorUdTubeTaskPos = params.getZMotor_ShortBloodTakeTubeHeight(); - // var tubeTypeValue = A8kTubeType.valueOf(tubeType); - // if (tubeTypeValue.equals(A8kTubeType.HighBlood)) { - // motorUdTubeTaskPos = params.getZMotor_HighBloodTakeTubeHeight(); - // } - // this.canBus.callblockcmd(MId.ShakeModGripperZM.toInt(), CmdId.step_motor_easy_move_to.toInt(), motorUdTubeTaskPos, params.getActionOvertime()); - // - // if (judgeCapExist) { - // this.canBus.callblockcmd(MId.ShakeModClampingM.toInt(), CmdId.mini_servo_rotate_with_torque.toInt(), params.getGripperServo_takeCapTorque(), params.getActionOvertime()); - // this.canBus.callcmd(MId.ShakeModGripperSV.toInt(), CmdId.mini_servo_stop.toInt()); - // var pos = this.canBus.callcmd(MId.ShakeModGripperSV.toInt(), CmdId.mini_servo_read_pos.toInt()); - // if (pos.getContentI32(0) > params.getGripperServo_hatDeterminesPosThres()) { - // return A8kEcode.TubeNotHasHat; - // } - // } - // - // this.canBus.callcmd(MId.ShakeModGripperSV.toInt(), CmdId.mini_servo_rotate_with_torque.toInt(), params.getGripperServo_takeCapTorque()); - // UfCommon.delay(2000); - // - // this.canBus.callblockcmd(MId.ShakeModGripperZM.toInt(), CmdId.step_motor_easy_move_to.toInt(), 0, params.getActionOvertime()); - // this.canBus.callblockcmd(MId.ShakeModGripperYSV.toInt(), CmdId.mini_servo_move_to.toInt(), params.getHorizontalMotor_takePushCapPos(), params.getActionOvertime()); - // this.canBus.callblockcmd(MId.ShakeModGripperZM.toInt(), CmdId.step_motor_easy_move_to.toInt(), params.getZMotor_placeShakeHeight(), params.getActionOvertime()); - // this.canBus.callblockcmd(MId.ShakeModClampingM.toInt(), CmdId.step_motor_easy_move_to.toInt(), params.getTubeClampMotor_ClampPos(), params.getActionOvertime()); - // this.canBus.callblockcmd(MId.ShakeModGripperSV.toInt(), CmdId.mini_servo_move_to.toInt(), params.getGripperServo_standbyPos(), params.getActionOvertime()); - // this.canBus.callblockcmd(MId.ShakeModGripperZM.toInt(), CmdId.step_motor_easy_move_to.toInt(), 0, params.getActionOvertime()); - // this.canBus.callblockcmd(MId.ShakeModGripperYSV.toInt(), CmdId.mini_servo_move_to.toInt(), params.getHorizontalMotor_standbyPos(), params.getActionOvertime()); - // /* - // 注意事项: - // 1. 取试管并将试管放在试管夹紧位置,同时升降电机和平移电机移动到待机位 - // 2. 试管放置的水平高度和其在试管架中的高度保持一直 - // 3. 取试管前,先通过试管夹紧功能判断一下试管帽是否存在(在试管没帽的边沿位置,抓手扭矩抓紧,如果等待一定时间后,抓手位置接近极限位置,则认为没有帽子,返回TubeNotHasHat错误) - // 4. 无论是否抓取成功,只要不向外抛出异常,方法结束时,该模块涉及到组件均需要返回待机位置。 - // */ - // return A8kEcode.Success; - // } - // - // /** - // * 取试管帽 - // */ - // public A8kEcode takeTubeCap(String tubeType) throws HardwareException, InterruptedException { - // var params = this.paramDao; - // this.canBus.callblockcmd(MId.ShakeModGripperYSV.toInt(), CmdId.mini_servo_move_to.toInt(), params.getHorizontalMotor_takePushCapPos(), params.getActionOvertime()); - // - // this.canBus.callblockcmd(MId.ShakeModGripperSV.toInt(), CmdId.mini_servo_move_to.toInt(), params.getGripperServo_standbyPos(), params.getActionOvertime()); - // - // var motorUdTakeCapPos = params.getZMotor_ShortBloodTakeCapHeight(); - // var tubeTypeValue = A8kTubeType.valueOf(tubeType); - // if (tubeTypeValue.equals(A8kTubeType.HighBlood)) { - // motorUdTakeCapPos = params.getZMotor_HighBloodTakeCapHeight(); - // } - // this.canBus.callblockcmd(MId.ShakeModGripperZM.toInt(), CmdId.step_motor_easy_move_to.toInt(), motorUdTakeCapPos, params.getActionOvertime()); - // - // this.canBus.callblockcmd(MId.ShakeModGripperSV.toInt(), CmdId.mini_servo_move_to.toInt(), params.getGripperServo_takeTubePos(), params.getActionOvertime()); - // - // this.canBus.callblockcmd(MId.ShakeModGripperZM.toInt(), CmdId.step_motor_easy_move_to.toInt(), 0, params.getActionOvertime()); - // - // this.canBus.callblockcmd(MId.ShakeModGripperYSV.toInt(), CmdId.mini_servo_move_to.toInt(), params.getHorizontalMotor_standbyPos(), params.getActionOvertime()); - // return A8kEcode.Success; - // } - // - // /** - // * 盖试管帽,并将试管移动回试管架中 - // */ - // public void pushBackTubeCapAndTakeBakTube(String tubeType) throws HardwareException, InterruptedException { - // var params = this.paramDao; - // this.canBus.callblockcmd(MId.ShakeModGripperYSV.toInt(), CmdId.step_motor_easy_move_to.toInt(), params.getHorizontalMotor_takePushCapPos(), params.getActionOvertime()); - // - // this.canBus.callblockcmd(MId.ShakeModGripperSV.toInt(), CmdId.step_motor_easy_move_to.toInt(), params.getGripperServo_standbyPos(), params.getActionOvertime()); - // - // var motorUdTakeCapPos = params.getZMotor_ShortBloodTakeCapHeight(); - // var tubeTypeValue = A8kTubeType.valueOf(tubeType); - // if (tubeTypeValue.equals(A8kTubeType.HighBlood)) { - // motorUdTakeCapPos = params.getZMotor_HighBloodTakeCapHeight(); - // } - // this.canBus.callblockcmd(MId.ShakeModGripperZM.toInt(), CmdId.step_motor_easy_move_to.toInt(), motorUdTakeCapPos, params.getActionOvertime()); - // - // this.canBus.callblockcmd(MId.ShakeModGripperSV.toInt(), CmdId.step_motor_easy_move_to.toInt(), params.getGripperServo_standbyPos(), params.getActionOvertime()); - // - // this.canBus.callblockcmd(MId.ShakeModGripperZM.toInt(), CmdId.step_motor_easy_move_to.toInt(), 0, params.getActionOvertime()); - // - // this.canBus.callblockcmd(MId.ShakeModGripperYSV.toInt(), CmdId.step_motor_easy_move_to.toInt(), params.getHorizontalMotor_standbyPos(), params.getActionOvertime()); - // } - // - // - // /* ======================================================================================= - // 辅助操作 - // =======================================================================================*/ - // - // /** - // * 摇匀试管 - // * @param tubeType HighBlood,ShortBlood,Mini,MiniBlood,BulletTube1P5,BulletTube0P5 - // * @param times 摇匀次数 - // * @param shakeDegree 摇匀角度 - // */ - // public void ShakeTube(String tubeType, Integer times, Integer shakeDegree) throws HardwareException, InterruptedException { - // var params = this.paramDao; - // var standByPos = params.getShakeMotor_standbyPos(); - // var startPos = standByPos - shakeDegree / 2; - // var endPos = standByPos + shakeDegree / 2; - // this.canBus.callblockcmd(MId.ShakeModShakeM.toInt(), CmdId.step_motor_easy_reciprocating_motion.toInt(), startPos, endPos, times, params.getActionOvertime()); - // } - // - // /** - // * 打开气溶胶风扇 - // */ - // public void openAerosolFan() throws HardwareException { - // var params = this.paramDao; - // this.canBus.callcmd(MId.WbTubeFanMod.toInt(), CmdId.fan_controler_set_speed.toInt(), params.getAerosolFanLevel()); - // } - // - // /** - // * 关闭气溶胶风扇 - // */ - // public void closeAerosolFan() throws HardwareException { - // this.canBus.callcmd(MId.WbTubeFanMod.toInt(), CmdId.fan_controler_set_speed.toInt(), 0); - // } - // - // /** - // * 设备初始化时复位 - // */ - // public void moduleResetWhenPowerOn() throws HardwareException, InterruptedException { - // var params = this.paramDao; - // this.canBus.callblockcmd(MId.ShakeModGripperSV.toInt(), CmdId.mini_servo_move_to.toInt(), params.getGripperServo_standbyPos(), params.getActionOvertime()); - // this.canBus.callblockcmd(MId.ShakeModGripperZM.toInt(), CmdId.step_motor_easy_move_to_zero.toInt(), params.getMoveToZeroOvertime()); - // this.canBus.callblockcmd(MId.ShakeModGripperYSV.toInt(), CmdId.mini_servo_move_to.toInt(), params.getHorizontalMotor_standbyPos(), params.getActionOvertime()); - // this.canBus.callblockcmd(MId.ShakeModClampingM.toInt(), CmdId.step_motor_easy_move_to_zero.toInt(), params.getMoveToZeroOvertime()); - // this.canBus.callblockcmd(MId.ShakeModShakeM.toInt(), CmdId.step_motor_easy_move_to_zero.toInt(), params.getMoveToZeroOvertime()); - // this.canBus.stepMotorEasyMoveTo(MId.ShakeModClampingM, params.getTubeClampMotor_standbyPos()); - // this.canBus.waitForMod(MId.ShakeModClampingM, params.getActionOvertime()); - // this.canBus.stepMotorEasyMoveTo(MId.ShakeModShakeM, params.getShakeMotor_standbyPos()); - // this.canBus.waitForMod(MId.ShakeModShakeM, params.getActionOvertime()); - // } - // - // /** - // * 设备运行时复位 - // */ - // public void moduleRuntimeReset() throws HardwareException, InterruptedException { - // var params = this.paramDao; - // this.canBus.callblockcmd(MId.ShakeModGripperSV.toInt(), CmdId.mini_servo_move_to.toInt(), params.getGripperServo_standbyPos(), params.getActionOvertime()); - // this.canBus.callblockcmd(MId.ShakeModGripperZM.toInt(), CmdId.step_motor_easy_move_to.toInt(), 0, params.getMoveToZeroOvertime()); - // this.canBus.callblockcmd(MId.ShakeModGripperZM.toInt(), CmdId.step_motor_easy_move_to_zero.toInt(), params.getMoveToZeroOvertime()); - // this.canBus.callblockcmd(MId.ShakeModGripperYSV.toInt(), CmdId.mini_servo_move_to.toInt(), params.getHorizontalMotor_standbyPos(), params.getActionOvertime()); - // this.canBus.callblockcmd(MId.ShakeModClampingM.toInt(), CmdId.step_motor_easy_move_to.toInt(), 0, params.getMoveToZeroOvertime()); - // this.canBus.callblockcmd(MId.ShakeModClampingM.toInt(), CmdId.step_motor_easy_move_to_zero.toInt(), params.getMoveToZeroOvertime()); - // this.canBus.callblockcmd(MId.ShakeModShakeM.toInt(), CmdId.step_motor_easy_move_to.toInt(), 0, params.getMoveToZeroOvertime()); - // this.canBus.callblockcmd(MId.ShakeModShakeM.toInt(), CmdId.step_motor_easy_move_to_zero.toInt(), params.getMoveToZeroOvertime()); - // this.canBus.stepMotorEasyMoveTo(MId.ShakeModClampingM, params.getTubeClampMotor_standbyPos()); - // this.canBus.waitForMod(MId.ShakeModClampingM, params.getActionOvertime()); - // this.canBus.stepMotorEasyMoveTo(MId.ShakeModShakeM, params.getShakeMotor_standbyPos()); - // this.canBus.waitForMod(MId.ShakeModShakeM, params.getActionOvertime()); - // } - // - // public void openTubeClip() throws HardwareException, InterruptedException { - // var params = this.paramDao; - // this.canBus.stepMotorEasyMoveBy(MId.ShakeModClampingM, 10); - // this.canBus.waitForMod(MId.ShakeModClampingM, params.getActionOvertime()); - // } + + /** + * 盖试管帽,并将试管移动回试管架中 + */ + @PostMapping(value = "/api/SamplesPreProcessModuleCtrlService/pushBackTubeCapAndTakeBakTube") + @ResponseBody + public void pushBackTubeCapAndTakeBakTube(String tubeType) throws HardwareException, InterruptedException { + //移动Y轴到取试管帽位置 + logger.info("移动Y轴到取试管帽位置"); + canBus.miniServoMoveTo(MId.ShakeModGripperYSV, getGripperShakeYPos()); + canBus.waitForMod(MId.ShakeModGripperYSV, getActionOvertime()); + actionDelay(); + + //移动Z轴盖帽 + logger.info("移动Z轴盖帽"); + canBus.stepMotorEasyMoveTo(MId.ShakeModGripperZM, getGripperTakeCapZPos() + 10); + canBus.waitForMod(MId.ShakeModGripperZM, getActionOvertime()); + actionDelay(); + + //打开试管夹 + logger.info("打开试管夹"); + canBus.stepMotorEasyMoveTo(MId.ShakeModClampingM, 70); + canBus.waitForMod(MId.ShakeModClampingM, getActionOvertime()); + + //移动Z轴到零位 + logger.info("移动Z轴到零位"); + canBus.stepMotorEasyMoveTo(MId.ShakeModGripperZM, 0); + canBus.waitForMod(MId.ShakeModGripperZM, getActionOvertime()); + + //移动Y轴到方式管的位置 + logger.info("移动Y轴到方式管的位置"); + canBus.miniServoMoveTo(MId.ShakeModGripperYSV, getGripperTakeTubeYPos()); + canBus.waitForMod(MId.ShakeModGripperYSV, getActionOvertime()); + actionDelay(); + + //移动Z轴到取试管位置 + logger.info("移动Z轴到取试管位置"); + canBus.stepMotorEasyMoveTo(MId.ShakeModGripperZM, getGripperTakeHTubeZPos()-20); + canBus.waitForMod(MId.ShakeModGripperZM, getActionOvertime()); + actionDelay(); + + //打开夹爪 + logger.info("打开夹爪"); + canBus.miniServoMoveTo(MId.ShakeModGripperSV, getGripperOpenPos()); + canBus.waitForMod(MId.ShakeModGripperSV, getActionOvertime()); + actionDelay(); + + //Z轴上移动到零位 + logger.info("Z轴上移动到零位"); + canBus.stepMotorEasyMoveTo(MId.ShakeModGripperZM, 0); + canBus.waitForMod(MId.ShakeModGripperZM, getActionOvertime()); + + //设备快速归零 + modGroupMoveToZeroQuick(); + + } + + + /** + * 打开气溶胶风扇 + */ + public void openAerosolFan() throws HardwareException { + // var params = this.paramDao; + // this.canBus.callcmd(MId.WbTubeFanMod.toInt(), CmdId.fan_controler_set_speed.toInt(), params.getAerosolFanLevel()); + } + + /** + * 关闭气溶胶风扇 + */ + public void closeAerosolFan() throws HardwareException { + // this.canBus.callcmd(MId.WbTubeFanMod.toInt(), CmdId.fan_controler_set_speed.toInt(), 0); + } }