diff --git a/src/main/java/a8k/a8k_can_protocol/MId.java b/src/main/java/a8k/a8k_can_protocol/MId.java index 6802035..8b02e4b 100644 --- a/src/main/java/a8k/a8k_can_protocol/MId.java +++ b/src/main/java/a8k/a8k_can_protocol/MId.java @@ -14,7 +14,7 @@ public enum MId { ShakeModClampingM(31, "试管固定夹爪电机"),// ShakeModGripperZM(32, "摇匀升降电机"),// ShakeModShakeM(33, "试管摇匀电机"),// - ShakeModGripperYM(34, "摇匀前后移动舵机"),// + ShakeModGripperYSV(34, "摇匀前后移动舵机"),// ShakeModGripperSV(35, "摇匀试管帽夹爪舵机"),// ShakeModTubeScanerClampingSV(36, "试管架扫码夹紧舵机"),// ShakeModTubeScanerRotateSV(37, "试管架旋转舵机"),// diff --git a/src/main/java/a8k/service/ctrl_service/DeviceInitializationCtrlService.java b/src/main/java/a8k/service/ctrl_service/DeviceInitializationCtrlService.java index b5e3f73..006f762 100644 --- a/src/main/java/a8k/service/ctrl_service/DeviceInitializationCtrlService.java +++ b/src/main/java/a8k/service/ctrl_service/DeviceInitializationCtrlService.java @@ -1,7 +1,6 @@ package a8k.service.ctrl_service; import a8k.a8k_can_protocol.A8kEcode; -import a8k.a8k_can_protocol.CmdId; import a8k.a8k_can_protocol.IOId; import a8k.a8k_can_protocol.MId; import a8k.appbean.HardwareException; @@ -12,7 +11,6 @@ import a8k.service.hardware.CommonHardwareOpeartion; import jakarta.annotation.Resource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.ResponseBody; @@ -169,8 +167,8 @@ public class DeviceInitializationCtrlService { canBus.waitForMod(MId.ShakeModTubeScanerClampingSV, actionOvertime); canBus.miniServoMoveTo(MId.ShakeModGripperSV, 1800); canBus.waitForMod(MId.ShakeModGripperSV, actionOvertime); - canBus.miniServoMoveTo(MId.ShakeModGripperYM, 200); - canBus.waitForMod(MId.ShakeModGripperYM, actionOvertime); + canBus.miniServoMoveTo(MId.ShakeModGripperYSV, 200); + canBus.waitForMod(MId.ShakeModGripperYSV, actionOvertime); canBus.stepMotorEasyMoveToZero(MId.ShakeModClampingM); canBus.waitForMod(MId.ShakeModClampingM, actionOvertime); diff --git a/src/main/java/a8k/service/ctrl_service/DeviceShutdownCtrlService.java b/src/main/java/a8k/service/ctrl_service/DeviceShutdownCtrlService.java new file mode 100644 index 0000000..b5484c2 --- /dev/null +++ b/src/main/java/a8k/service/ctrl_service/DeviceShutdownCtrlService.java @@ -0,0 +1,9 @@ +package a8k.service.ctrl_service; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DeviceShutdownCtrlService { + public static final Logger logger = LoggerFactory.getLogger(DeviceInitializationCtrlService.class); + +} diff --git a/src/main/java/a8k/service/hardware/CommonHardwareOpeartion.java b/src/main/java/a8k/service/hardware/CommonHardwareOpeartion.java index cf6957f..02b8055 100644 --- a/src/main/java/a8k/service/hardware/CommonHardwareOpeartion.java +++ b/src/main/java/a8k/service/hardware/CommonHardwareOpeartion.java @@ -6,15 +6,19 @@ import a8k.appbean.HardwareException; import a8k.appbean.ecode.AppEcode; import a8k.base_hardware.A8kCanBusService; import jakarta.annotation.Resource; -import org.springframework.stereotype.Component; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.ResponseBody; -@Component +@Controller public class CommonHardwareOpeartion { @Resource A8kCanBusService canBus; + @PostMapping("/api/CommonHardwareOpeartion/enableAllMotorNoExcep") + @ResponseBody public AppEcode enableAllMotorNoExcep() { try { enableAllMotor(); @@ -24,6 +28,8 @@ public class CommonHardwareOpeartion { return new AppEcode(A8kEcode.Success); } + @PostMapping("/api/CommonHardwareOpeartion/disableAllMotorNoExcep") + @ResponseBody public AppEcode disableAllMotorNoExcep() { try { enableAllMotor(); @@ -33,71 +39,90 @@ public class CommonHardwareOpeartion { return new AppEcode(A8kEcode.Success); } - public void enableAllMotor() throws HardwareException { + public void enableAllMotor(Boolean enable) throws HardwareException { //进出料初始化 - canBus.stepMotorEnable(MId.FeedingModInfeedM, 1); - canBus.stepMotorEnable(MId.FeedingModXM, 1); - canBus.stepMotorEnable(MId.FeedingModOutfeedM, 1); + 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, 1); - canBus.stepMotorEnable(MId.ShakeModGripperZM, 1); - canBus.stepMotorEnable(MId.ShakeModShakeM, 1); - canBus.miniServoEnable(MId.ShakeModGripperYM, 1); - canBus.miniServoEnable(MId.ShakeModGripperSV, 1); - canBus.miniServoEnable(MId.ShakeModTubeScanerClampingSV, 1); - canBus.miniServoEnable(MId.ShakeModTubeScanerRotateSV, 1); + 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, 1); - canBus.stepMotorEnable(MId.PlatesBoxPusherM, 1); + canBus.stepMotorEnable(MId.PlatesBoxYM, enable ? 1 : 0); + canBus.stepMotorEnable(MId.PlatesBoxPusherM, enable ? 1 : 0); //光学模组初始化 - canBus.stepMotorEnable(MId.OptModPullM, 1); - canBus.stepMotorEnable(MId.OptModScannerM, 1); + canBus.stepMotorEnable(MId.OptModPullM, enable ? 1 : 0); + canBus.stepMotorEnable(MId.OptModScannerM, enable ? 1 : 0); //HBot初始化 - canBus.hbotEnable(MId.HbotM, 1); - canBus.stepMotorEnable(MId.PipetteModZM, 1); + canBus.hbotEnable(MId.HbotM, enable ? 1 : 0); + canBus.stepMotorEnable(MId.PipetteModZM, enable ? 1 : 0); //转盘归零 - canBus.stepMotorEnable(MId.IncubatorRotateCtrlM, 1); + canBus.stepMotorEnable(MId.IncubatorRotateCtrlM, enable ? 1 : 0); + } + + @PostMapping("/api/CommonHardwareOpeartion/enableAllMotor") + @ResponseBody + public void enableAllMotor() throws HardwareException { + enableAllMotor(true); } + @PostMapping("/api/CommonHardwareOpeartion/disableAllMotor") + @ResponseBody public void disableAllMotor() throws HardwareException { + enableAllMotor(false); + } + + @PostMapping("/api/CommonHardwareOpeartion/forceStopAndDisableAllMOtor") + @ResponseBody + public void forceStopAndDisableAllMOtor() { + forceStopAllMOtor(); + forceDisableAllMOtor(); + } + + public void forceDisableAllMOtor() { + //Disable all motor //进出料初始化 - canBus.stepMotorEnable(MId.FeedingModInfeedM, 0); - canBus.stepMotorEnable(MId.FeedingModXM, 0); - canBus.stepMotorEnable(MId.FeedingModOutfeedM, 0); + try {canBus.stepMotorEnable(MId.FeedingModInfeedM, 0);} catch (HardwareException ignored) {} + try {canBus.stepMotorEnable(MId.FeedingModXM, 0);} catch (HardwareException ignored) {} + try {canBus.stepMotorEnable(MId.FeedingModOutfeedM, 0);} catch (HardwareException ignored) {} //摇匀模组初始化 - canBus.stepMotorEnable(MId.ShakeModClampingM, 0); - canBus.stepMotorEnable(MId.ShakeModGripperZM, 0); - canBus.stepMotorEnable(MId.ShakeModShakeM, 0); - canBus.miniServoEnable(MId.ShakeModGripperYM, 0); - canBus.miniServoEnable(MId.ShakeModGripperSV, 0); - canBus.miniServoEnable(MId.ShakeModTubeScanerClampingSV, 0); - canBus.miniServoEnable(MId.ShakeModTubeScanerRotateSV, 0); + try {canBus.stepMotorEnable(MId.ShakeModClampingM, 0);} catch (HardwareException ignored) {} + try {canBus.stepMotorEnable(MId.ShakeModGripperZM, 0);} catch (HardwareException ignored) {} + try {canBus.stepMotorEnable(MId.ShakeModShakeM, 0);} catch (HardwareException ignored) {} + try {canBus.miniServoEnable(MId.ShakeModGripperYSV, 0);} catch (HardwareException ignored) {} + try {canBus.miniServoEnable(MId.ShakeModGripperSV, 0);} catch (HardwareException ignored) {} + try {canBus.miniServoEnable(MId.ShakeModTubeScanerClampingSV, 0);} catch (HardwareException ignored) {} + try {canBus.miniServoEnable(MId.ShakeModTubeScanerRotateSV, 0);} catch (HardwareException ignored) {} //板夹仓初始化 - canBus.stepMotorEnable(MId.PlatesBoxYM, 0); - canBus.stepMotorEnable(MId.PlatesBoxPusherM, 0); + try {canBus.stepMotorEnable(MId.PlatesBoxYM, 0);} catch (HardwareException ignored) {} + try {canBus.stepMotorEnable(MId.PlatesBoxPusherM, 0);} catch (HardwareException ignored) {} //光学模组初始化 - canBus.stepMotorEnable(MId.OptModPullM, 0); - canBus.stepMotorEnable(MId.OptModScannerM, 0); + try {canBus.stepMotorEnable(MId.OptModPullM, 0);} catch (HardwareException ignored) {} + try {canBus.stepMotorEnable(MId.OptModScannerM, 0);} catch (HardwareException ignored) {} //HBot初始化 - canBus.hbotEnable(MId.HbotM, 0); - canBus.stepMotorEnable(MId.PipetteModZM, 0); + try {canBus.hbotEnable(MId.HbotM, 0);} catch (HardwareException ignored) {} + try {canBus.stepMotorEnable(MId.PipetteModZM, 0);} catch (HardwareException ignored) {} //转盘归零 - canBus.stepMotorEnable(MId.IncubatorRotateCtrlM, 0); - + try {canBus.stepMotorEnable(MId.IncubatorRotateCtrlM, 0);} catch (HardwareException ignored) {} } - public void forceStopAndDisableAllMOtor() { + public void forceStopAllMOtor() { //StopAllMotor //进出料初始化 try {canBus.moduleStop(MId.FeedingModInfeedM);} catch (HardwareException ignored) {} @@ -107,7 +132,7 @@ public class CommonHardwareOpeartion { try {canBus.moduleStop(MId.ShakeModClampingM);} catch (HardwareException ignored) {} try {canBus.moduleStop(MId.ShakeModGripperZM);} catch (HardwareException ignored) {} try {canBus.moduleStop(MId.ShakeModShakeM);} catch (HardwareException ignored) {} - try {canBus.moduleStop(MId.ShakeModGripperYM);} catch (HardwareException ignored) {} + try {canBus.moduleStop(MId.ShakeModGripperYSV);} catch (HardwareException ignored) {} try {canBus.moduleStop(MId.ShakeModGripperSV);} catch (HardwareException ignored) {} try {canBus.moduleStop(MId.ShakeModTubeScanerClampingSV);} catch (HardwareException ignored) {} try {canBus.moduleStop(MId.ShakeModTubeScanerRotateSV);} catch (HardwareException ignored) {} @@ -122,38 +147,6 @@ public class CommonHardwareOpeartion { try {canBus.moduleStop(MId.PipetteModZM);} catch (HardwareException ignored) {} //转盘归零 try {canBus.moduleStop(MId.IncubatorRotateCtrlM);} catch (HardwareException ignored) {} - - //Disable all motor - //进出料初始化 - try {canBus.stepMotorEnable(MId.FeedingModInfeedM, 0);} catch (HardwareException ignored) {} - try {canBus.stepMotorEnable(MId.FeedingModXM, 0);} catch (HardwareException ignored) {} - try {canBus.stepMotorEnable(MId.FeedingModOutfeedM, 0);} catch (HardwareException ignored) {} - - //摇匀模组初始化 - try {canBus.stepMotorEnable(MId.ShakeModClampingM, 0);} catch (HardwareException ignored) {} - try {canBus.stepMotorEnable(MId.ShakeModGripperZM, 0);} catch (HardwareException ignored) {} - try {canBus.stepMotorEnable(MId.ShakeModShakeM, 0);} catch (HardwareException ignored) {} - try {canBus.miniServoEnable(MId.ShakeModGripperYM, 0);} catch (HardwareException ignored) {} - try {canBus.miniServoEnable(MId.ShakeModGripperSV, 0);} catch (HardwareException ignored) {} - try {canBus.miniServoEnable(MId.ShakeModTubeScanerClampingSV, 0);} catch (HardwareException ignored) {} - try {canBus.miniServoEnable(MId.ShakeModTubeScanerRotateSV, 0);} catch (HardwareException ignored) {} - - //板夹仓初始化 - try {canBus.stepMotorEnable(MId.PlatesBoxYM, 0);} catch (HardwareException ignored) {} - try {canBus.stepMotorEnable(MId.PlatesBoxPusherM, 0);} catch (HardwareException ignored) {} - - //光学模组初始化 - try {canBus.stepMotorEnable(MId.OptModPullM, 0);} catch (HardwareException ignored) {} - try {canBus.stepMotorEnable(MId.OptModScannerM, 0);} catch (HardwareException ignored) {} - - //HBot初始化 - try {canBus.hbotEnable(MId.HbotM, 0);} catch (HardwareException ignored) {} - try {canBus.stepMotorEnable(MId.PipetteModZM, 0);} catch (HardwareException ignored) {} - - //转盘归零 - try {canBus.stepMotorEnable(MId.IncubatorRotateCtrlM, 0);} catch (HardwareException ignored) {} - } - } diff --git a/src/main/java/a8k/service/hardware/MotorTubeRackMoveCtrlService.java b/src/main/java/a8k/service/hardware/MotorTubeRackMoveCtrlService.java index 9f133b2..a79b724 100644 --- a/src/main/java/a8k/service/hardware/MotorTubeRackMoveCtrlService.java +++ b/src/main/java/a8k/service/hardware/MotorTubeRackMoveCtrlService.java @@ -26,119 +26,38 @@ public class MotorTubeRackMoveCtrlService { * 2. 扫码时试管夹紧夹紧 */ - // MotorTubeRackMotor_tubeScanPos - // MotorTubeRackMotor_tubeHeighJudgmentPos - // MotorTubeRackMotor_tubePreProcessPos - // MotorTubeRackMotor_tubeExistJudgmentPos - // - // MotorTubeRackMotor_tubeRackEnterPos - // MotorTubeRackMotor_tubeRackExitPos - // MotorTubeRackMotor_tubeRackScanCodePos - // MotorTubeScanClampModule_clampPos - // MotorTubeScanClampModule_releasePos - @Autowired A8kTubeInfoDao tubeInfoDao; @Resource - private A8kCanBusService a8kCanBusService; + private A8kCanBusService canBus; + @Resource + MotorTubeRackMoveCtrlServiceParameterDao paramDao; + @Resource - MotorTubeRackMoveCtrlServiceParameterDao serviceParameterDao; - - public void setEnable( Boolean enable ) throws HardwareException { - this.a8kCanBusService.callcmd( - MId.FeedingModXM.toInt(), - CmdId.step_motor_enable.toInt(), - enable ? 1 : 0 - ); - this.a8kCanBusService.callcmd( - MId.FeedingModInfeedM.toInt(), - CmdId.step_motor_enable.toInt(), - enable ? 1 : 0 - ); - this.a8kCanBusService.callcmd( - MId.FeedingModOutfeedM.toInt(), - CmdId.step_motor_enable.toInt(), - enable ? 1 : 0 - ); - this.a8kCanBusService.callcmd( - MId.ShakeModTubeScanerClampingSV.toInt(), - CmdId.mini_servo_enable.toInt(), - enable ? 1 : 0 - ); - this.a8kCanBusService.callcmd( - MId.ShakeModTubeScanerRotateSV.toInt(), - CmdId.mini_servo_enable.toInt(), - enable ? 1 : 0 - ); + private CommonHardwareOpeartion comHardwareOpear; + + public void setEnable(Boolean enable) throws HardwareException { + comHardwareOpear.enableAllMotor(enable); } public void stop() throws HardwareException { - this.a8kCanBusService.callcmd( - MId.FeedingModXM.toInt(), - CmdId.step_motor_stop.toInt(), - 1 - ); - this.a8kCanBusService.callcmd( - MId.FeedingModInfeedM.toInt(), - CmdId.step_motor_stop.toInt(), - 1 - ); - this.a8kCanBusService.callcmd( - MId.FeedingModOutfeedM.toInt(), - CmdId.step_motor_stop.toInt(), - 1 - ); - this.a8kCanBusService.callcmd( - MId.ShakeModTubeScanerClampingSV.toInt(), - CmdId.mini_servo_stop.toInt(), - 1 - ); - this.a8kCanBusService.callcmd( - MId.ShakeModTubeScanerRotateSV.toInt(), - CmdId.mini_servo_stop.toInt(), - 1 - ); + comHardwareOpear.forceStopAllMOtor(); } - // // 电机基础控制 // - public void moveToZeroWhenDeviceSetup() throws HardwareException, InterruptedException { - var params = this.serviceParameterDao; - this.a8kCanBusService.callblockcmd( - MId.FeedingModXM.toInt(), - CmdId.step_motor_easy_move_to_zero.toInt(), - params.getMoveToZeroOvertime() - ); - this.a8kCanBusService.callblockcmd( - MId.ShakeModTubeScanerClampingSV.toInt(), - CmdId.mini_servo_move_to.toInt(), - params.getScanCodeReleasePos(), - params.getMoveToZeroOvertime() - ); - } + canBus.stepMotorEasyMoveToZero(MId.FeedingModXM); + canBus.waitForMod(MId.FeedingModXM, paramDao.getMoveToZeroOvertime()); + canBus.miniServoMoveTo(MId.ShakeModTubeScanerClampingSV, paramDao.getScanCodeReleasePos()); + canBus.waitForMod(MId.ShakeModTubeScanerClampingSV, paramDao.getMoveToZeroOvertime()); + } public void moveToZero() throws HardwareException, InterruptedException { - var params = this.serviceParameterDao; - var beforePosResponse = this.a8kCanBusService.callcmd(MId.FeedingModXM.toInt(), CmdId.step_motor_read_pos.toInt()); - var beforePos = beforePosResponse.getContentI32(0); - this.a8kCanBusService.callblockcmd(MId.FeedingModXM.toInt(), CmdId.step_motor_easy_move_to_zero.toInt(), params.getMoveToZeroOvertime()); - var afterPosResponse = this.a8kCanBusService.callcmd(MId.FeedingModXM.toInt(), CmdId.step_motor_read_pos.toInt()); - var afterPos = afterPosResponse.getContentI32(0); - var distance = beforePos - afterPos; - - - var dval = a8kCanBusService.module_read_reg(MId.FeedingModXM.toInt(), RegIndex.kreg_step_motor_dpos); - - if (Math.abs(dval - distance) > params.getHorizontalMotorLostStepThresholdVal() ) { - throw new HardwareException(MId.FeedingModXM, A8kEcode.MotorLostStep); - } - //先通过move_to 指令移动到零点 //再通过 move_to_zero 进行归零(设置超时时间),超时时间,来源MotorParameterDao //最后读取 寄存器dval,判断move_to_zero移动了多少距离,如果dval过大,则抛出电机丢步异常。 @@ -147,6 +66,21 @@ public class MotorTubeRackMoveCtrlService { //3.读取电机运行完成后所在的位置 //4.比较dpos和上面两个位置的差值 相差多少,如果超过2mm,即超过20则认为发生过阻转。 + + var params = this.paramDao; + var beforePos = canBus.stepMotorReadPos(MId.FeedingModXM); + + canBus.stepMotorEasyMoveToZero(MId.FeedingModXM); + canBus.waitForMod(MId.FeedingModXM, paramDao.getMoveToZeroOvertime()); + + var afterPos = canBus.stepMotorReadPos(MId.FeedingModXM); + var distance = beforePos - afterPos; + + var dval = canBus.module_read_reg(MId.FeedingModXM.toInt(), RegIndex.kreg_step_motor_dpos); + if (Math.abs(dval - distance) > params.getHorizontalMotorLostStepThresholdVal()) { + throw new HardwareException(MId.FeedingModXM, A8kEcode.MotorLostStep); + } + } @@ -158,39 +92,24 @@ public class MotorTubeRackMoveCtrlService { * 移动试管架到入口位置 */ public void moveTubeRackToEnterPos() throws HardwareException, InterruptedException { - var params = this.serviceParameterDao; - this.a8kCanBusService.callblockcmd( - MId.FeedingModXM.toInt(), - CmdId.step_motor_easy_move_to.toInt(), - params.getTubeRackEnterPos(), - params.getActionOvertime() - ); + var params = this.paramDao; + this.canBus.callblockcmd(MId.FeedingModXM.toInt(), CmdId.step_motor_easy_move_to.toInt(), params.getTubeRackEnterPos(), params.getActionOvertime()); } /** * 移动试管架到出口位置 */ public void moveTubeRackToExitPos() throws HardwareException, InterruptedException { - var params = this.serviceParameterDao; - this.a8kCanBusService.callblockcmd( - MId.FeedingModXM.toInt(), - CmdId.step_motor_easy_move_to.toInt(), - params.getTubeRackExitPos(), - params.getActionOvertime() - ); + var params = this.paramDao; + this.canBus.callblockcmd(MId.FeedingModXM.toInt(), CmdId.step_motor_easy_move_to.toInt(), params.getTubeRackExitPos(), params.getActionOvertime()); } /** * 移动试管架到试管架扫码位置 */ public void moveTubeRackToScanPos() throws HardwareException, InterruptedException { - var params = this.serviceParameterDao; - this.a8kCanBusService.callblockcmd( - MId.FeedingModXM.toInt(), - CmdId.step_motor_easy_move_to.toInt(), - params.getTubeRackScanCodePos(), - params.getActionOvertime() - ); + var params = this.paramDao; + this.canBus.callblockcmd(MId.FeedingModXM.toInt(), CmdId.step_motor_easy_move_to.toInt(), params.getTubeRackScanCodePos(), params.getActionOvertime()); } /** @@ -198,10 +117,10 @@ public class MotorTubeRackMoveCtrlService { */ public String moveTubeRackToScanPosAndScan() throws HardwareException, InterruptedException { this.moveTubeRackToScanPos(); - this.a8kCanBusService.callcmd(MId.FeedingModScannerMod.toInt(), CmdId.code_scaner_start_scan.toInt()); + this.canBus.callcmd(MId.FeedingModScannerMod.toInt(), CmdId.code_scaner_start_scan.toInt()); Thread.sleep(5000); - var response = this.a8kCanBusService.callcmd(MId.FeedingModScannerMod.toInt(), CmdId.code_scaner_read_scaner_result.toInt()); - this.a8kCanBusService.callcmd(MId.FeedingModScannerMod.toInt(), CmdId.code_scaner_stop_scan.toInt()); + var response = this.canBus.callcmd(MId.FeedingModScannerMod.toInt(), CmdId.code_scaner_read_scaner_result.toInt()); + this.canBus.callcmd(MId.FeedingModScannerMod.toInt(), CmdId.code_scaner_stop_scan.toInt()); var contentBytes = response.getCmdContent(); return new String(contentBytes); } @@ -217,14 +136,9 @@ public class MotorTubeRackMoveCtrlService { * @param tubeIndex */ public void moveTubeToScanPos(String tubeType, Integer tubeIndex) throws HardwareException, InterruptedException { - var params = this.serviceParameterDao; - var scanPos = params.getTubeScanPos() + tubeIndex * params.getTubeSpacing(); - this.a8kCanBusService.callblockcmd( - MId.FeedingModXM.toInt(), - CmdId.step_motor_easy_move_to.toInt(), - scanPos, - params.getActionOvertime() - ); + var params = this.paramDao; + var scanPos = params.getTubeScanPos() + tubeIndex * params.getTubeSpacing(); + this.canBus.callblockcmd(MId.FeedingModXM.toInt(), CmdId.step_motor_easy_move_to.toInt(), scanPos, params.getActionOvertime()); } /** @@ -234,18 +148,18 @@ public class MotorTubeRackMoveCtrlService { */ public String moveTubeToScanPosAndScan(String tubeType, Integer tubeIndex) throws HardwareException, InterruptedException { this.moveTubeToScanPos(tubeType, tubeIndex); - this.a8kCanBusService.callcmd(MId.FeedingModScannerMod.toInt(), CmdId.code_scaner_start_scan.toInt()); - this.a8kCanBusService.callcmd(MId.ShakeModTubeScanerRotateSV.toInt(),CmdId.mini_servo_rotate_with_torque.toInt(), 200); - for ( int i=0; i<10; i++ ) { - var resIsReady = this.a8kCanBusService.callcmd(MId.FeedingModScannerMod.toInt(), CmdId.code_scaner_result_is_ready.toInt()); - if ( 1 == resIsReady.getContentI32(0) ) { - break ; + this.canBus.callcmd(MId.FeedingModScannerMod.toInt(), CmdId.code_scaner_start_scan.toInt()); + this.canBus.callcmd(MId.ShakeModTubeScanerRotateSV.toInt(), CmdId.mini_servo_rotate_with_torque.toInt(), 200); + for (int i = 0; i < 10; i++) { + var resIsReady = this.canBus.callcmd(MId.FeedingModScannerMod.toInt(), CmdId.code_scaner_result_is_ready.toInt()); + if (1 == resIsReady.getContentI32(0)) { + break; } UfCommon.delay(500); } - this.a8kCanBusService.callcmd(MId.ShakeModTubeScanerRotateSV.toInt(), CmdId.mini_servo_stop.toInt(), 1); - var response = this.a8kCanBusService.callcmd(MId.FeedingModScannerMod.toInt(), CmdId.code_scaner_read_scaner_result.toInt()); - this.a8kCanBusService.callcmd(MId.FeedingModScannerMod.toInt(), CmdId.code_scaner_stop_scan.toInt()); + this.canBus.callcmd(MId.ShakeModTubeScanerRotateSV.toInt(), CmdId.mini_servo_stop.toInt(), 1); + var response = this.canBus.callcmd(MId.FeedingModScannerMod.toInt(), CmdId.code_scaner_read_scaner_result.toInt()); + this.canBus.callcmd(MId.FeedingModScannerMod.toInt(), CmdId.code_scaner_stop_scan.toInt()); var contentBytes = response.getCmdContent(); return new String(contentBytes); } @@ -256,14 +170,9 @@ public class MotorTubeRackMoveCtrlService { * @param tubeIndex */ public void moveTubeToHeighJudgmentPos(String tubeType, Integer tubeIndex) throws HardwareException, InterruptedException { - var params = this.serviceParameterDao; + var params = this.paramDao; var detectPos = params.getTubeHeighJudgmentPos() + tubeIndex * params.getTubeSpacing(); - this.a8kCanBusService.callblockcmd( - MId.FeedingModXM.toInt(), - CmdId.step_motor_easy_move_to.toInt(), - detectPos, - params.getActionOvertime() - ); + this.canBus.callblockcmd(MId.FeedingModXM.toInt(), CmdId.step_motor_easy_move_to.toInt(), detectPos, params.getActionOvertime()); } /** @@ -272,14 +181,9 @@ public class MotorTubeRackMoveCtrlService { * @param tubeIndex */ public void moveTubeToPreProcessPos(String tubeType, Integer tubeIndex) throws HardwareException, InterruptedException { - var params = this.serviceParameterDao; - var pos = params.getTubePreProcessPos() + tubeIndex * params.getTubeSpacing(); - this.a8kCanBusService.callblockcmd( - MId.FeedingModXM.toInt(), - CmdId.step_motor_easy_move_to.toInt(), - pos, - params.getActionOvertime() - ); + var params = this.paramDao; + var pos = params.getTubePreProcessPos() + tubeIndex * params.getTubeSpacing(); + this.canBus.callblockcmd(MId.FeedingModXM.toInt(), CmdId.step_motor_easy_move_to.toInt(), pos, params.getActionOvertime()); } // @@ -292,17 +196,17 @@ public class MotorTubeRackMoveCtrlService { * @param tubeIndex */ public void moveTubeToExistJudgmentPos(String tubeType, Integer tubeIndex) throws HardwareException, InterruptedException { - var params = this.serviceParameterDao; - var pos = params.getTubeExistJudgmentPos() + tubeIndex * params.getTubeSpacing(); - this.a8kCanBusService.callblockcmd(MId.FeedingModXM.toInt(), CmdId.step_motor_easy_move_to.toInt(), new Integer[]{pos}, params.getActionOvertime()); + var params = this.paramDao; + var pos = params.getTubeExistJudgmentPos() + tubeIndex * params.getTubeSpacing(); + this.canBus.callblockcmd(MId.FeedingModXM.toInt(), CmdId.step_motor_easy_move_to.toInt(), new Integer[]{pos}, params.getActionOvertime()); } public boolean isTubeRackInEnterPos() throws HardwareException { - return this.a8kCanBusService.getIOState(IOId.InfeedPPS); + return this.canBus.getIOState(IOId.InfeedPPS); } public boolean isTubeRackInExitPos() throws HardwareException { - return this.a8kCanBusService.getIOState(IOId.OutfeedPPS); + return this.canBus.getIOState(IOId.OutfeedPPS); } /** @@ -312,7 +216,7 @@ public class MotorTubeRackMoveCtrlService { */ public boolean getMoveChannelPhotoelectricState(Integer photoelectricIndex) throws HardwareException { var io = 0 == photoelectricIndex ? IOId.THChOuterPPS : IOId.THChInterPPS; - return this.a8kCanBusService.getIOState(io); + return this.canBus.getIOState(io); } // @@ -324,26 +228,16 @@ public class MotorTubeRackMoveCtrlService { * 扫描夹紧机构夹紧 */ public void scanClampModuleCompress() throws HardwareException, InterruptedException { - var params = this.serviceParameterDao; - this.a8kCanBusService.callblockcmd( - MId.ShakeModTubeScanerClampingSV.toInt(), - CmdId.mini_servo_move_to.toInt(), - new Integer[]{params.getScanCodeClampPos()}, - params.getActionOvertime() - ); + var params = this.paramDao; + this.canBus.callblockcmd(MId.ShakeModTubeScanerClampingSV.toInt(), CmdId.mini_servo_move_to.toInt(), new Integer[]{params.getScanCodeClampPos()}, params.getActionOvertime()); } /** * 扫描夹紧机构复位 */ public void scanClampModuleReset() throws HardwareException, InterruptedException { - var params = this.serviceParameterDao; - this.a8kCanBusService.callblockcmd( - MId.ShakeModTubeScanerClampingSV.toInt(), - CmdId.mini_servo_move_to.toInt(), - new Integer[]{params.getScanCodeReleasePos()}, - params.getActionOvertime() - ); + var params = this.paramDao; + this.canBus.callblockcmd(MId.ShakeModTubeScanerClampingSV.toInt(), CmdId.mini_servo_move_to.toInt(), new Integer[]{params.getScanCodeReleasePos()}, params.getActionOvertime()); } diff --git a/src/main/java/a8k/service/hardware/ReactionPlatesTransmitCtrlService.java b/src/main/java/a8k/service/hardware/ReactionPlatesTransmitCtrlService.java index 08c83da..c07038b 100644 --- a/src/main/java/a8k/service/hardware/ReactionPlatesTransmitCtrlService.java +++ b/src/main/java/a8k/service/hardware/ReactionPlatesTransmitCtrlService.java @@ -163,5 +163,11 @@ public class ReactionPlatesTransmitCtrlService { */ } + void emptyTurntable() { + /* + 清空转盘 + */ + } + } diff --git a/src/main/java/a8k/service/hardware/SamplesPreProcessModuleCtrlService.java b/src/main/java/a8k/service/hardware/SamplesPreProcessModuleCtrlService.java index 340dcd6..9c875cc 100644 --- a/src/main/java/a8k/service/hardware/SamplesPreProcessModuleCtrlService.java +++ b/src/main/java/a8k/service/hardware/SamplesPreProcessModuleCtrlService.java @@ -48,7 +48,7 @@ public class SamplesPreProcessModuleCtrlService { ); this.a8kCanBusService.callblockcmd( - MId.ShakeModGripperYM.toInt(), + MId.ShakeModGripperYSV.toInt(), CmdId.mini_servo_move_to.toInt(), params.getHorizontalMotor_standbyPos(), params.getActionOvertime() @@ -93,7 +93,7 @@ public class SamplesPreProcessModuleCtrlService { enable ? 1 : 0 ); this.a8kCanBusService.callcmd( - MId.ShakeModGripperYM.toInt(), + MId.ShakeModGripperYSV.toInt(), CmdId.mini_servo_enable.toInt(), enable ? 1 : 0 ); @@ -122,7 +122,7 @@ public class SamplesPreProcessModuleCtrlService { public A8kEcode takeTube(String tubeType,boolean judgeCapExist) throws HardwareException, InterruptedException { var params = this.samplesPreProcessModuleCtrlParamsService; this.a8kCanBusService.callblockcmd( - MId.ShakeModGripperYM.toInt(), + MId.ShakeModGripperYSV.toInt(), CmdId.step_motor_easy_move_to.toInt(), params.getHorizontalMotor_takeCapPos(), params.getActionOvertime() @@ -175,7 +175,7 @@ public class SamplesPreProcessModuleCtrlService { ); this.a8kCanBusService.callblockcmd( - MId.ShakeModGripperYM.toInt(), + MId.ShakeModGripperYSV.toInt(), CmdId.mini_servo_move_to.toInt(), params.getHorizontalMotor_takePushCapPos(), params.getActionOvertime() @@ -203,7 +203,7 @@ public class SamplesPreProcessModuleCtrlService { ); this.a8kCanBusService.callblockcmd( - MId.ShakeModGripperYM.toInt(), + MId.ShakeModGripperYSV.toInt(), CmdId.step_motor_easy_move_to.toInt(), params.getHorizontalMotor_standbyPos(), params.getActionOvertime() @@ -227,7 +227,7 @@ public class SamplesPreProcessModuleCtrlService { public A8kEcode takeTubeCap( String tubeType ) throws HardwareException, InterruptedException { var params = this.samplesPreProcessModuleCtrlParamsService; this.a8kCanBusService.callblockcmd( - MId.ShakeModGripperYM.toInt(), + MId.ShakeModGripperYSV.toInt(), CmdId.step_motor_easy_move_to.toInt(), params.getHorizontalMotor_takePushCapPos(), params.getActionOvertime() @@ -267,7 +267,7 @@ public class SamplesPreProcessModuleCtrlService { ); this.a8kCanBusService.callblockcmd( - MId.ShakeModGripperYM.toInt(), + MId.ShakeModGripperYSV.toInt(), CmdId.step_motor_easy_move_to.toInt(), params.getHorizontalMotor_standbyPos(), params.getActionOvertime() @@ -281,7 +281,7 @@ public class SamplesPreProcessModuleCtrlService { public void pushBackTubeCapAndTakeBakTube(String tubeType) throws HardwareException, InterruptedException { var params = this.samplesPreProcessModuleCtrlParamsService; this.a8kCanBusService.callblockcmd( - MId.ShakeModGripperYM.toInt(), + MId.ShakeModGripperYSV.toInt(), CmdId.step_motor_easy_move_to.toInt(), params.getHorizontalMotor_takePushCapPos(), params.getActionOvertime() @@ -321,7 +321,7 @@ public class SamplesPreProcessModuleCtrlService { ); this.a8kCanBusService.callblockcmd( - MId.ShakeModGripperYM.toInt(), + MId.ShakeModGripperYSV.toInt(), CmdId.step_motor_easy_move_to.toInt(), params.getHorizontalMotor_standbyPos(), params.getActionOvertime() @@ -385,7 +385,7 @@ public class SamplesPreProcessModuleCtrlService { params.getMoveToZeroOvertime() ); this.a8kCanBusService.callblockcmd( - MId.ShakeModGripperYM.toInt(), + MId.ShakeModGripperYSV.toInt(), CmdId.mini_servo_move_to.toInt(), params.getHorizontalMotor_standbyPos(), params.getActionOvertime() @@ -424,7 +424,7 @@ public class SamplesPreProcessModuleCtrlService { params.getMoveToZeroOvertime() ); this.a8kCanBusService.callblockcmd( - MId.ShakeModGripperYM.toInt(), + MId.ShakeModGripperYSV.toInt(), CmdId.mini_servo_move_to.toInt(), params.getHorizontalMotor_standbyPos(), params.getActionOvertime() diff --git a/zhaohe_app.db b/zhaohe_app.db index 8ea61ec..56c73d1 100644 Binary files a/zhaohe_app.db and b/zhaohe_app.db differ