|
@ -49,14 +49,26 @@ public class MotorTubeRackMoveCtrlService { |
|
|
// |
|
|
// |
|
|
// 电机基础控制 |
|
|
// 电机基础控制 |
|
|
// |
|
|
// |
|
|
public void moveToZeroWhenDeviceSetup() throws HardwareException, InterruptedException { |
|
|
|
|
|
canBus.stepMotorEasyMoveToZero(MId.FeedingModXM); |
|
|
|
|
|
canBus.waitForMod(MId.FeedingModXM, paramDao.getMoveToZeroOvertime()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 电机归零,设备初始化时调用,特点是直接调用MoveToZero |
|
|
|
|
|
* @throws HardwareException 硬件异常 |
|
|
|
|
|
* @throws InterruptedException 打断异常 |
|
|
|
|
|
*/ |
|
|
|
|
|
public void moveToZeroWhenDeviceSetup() throws HardwareException, InterruptedException { |
|
|
canBus.miniServoMoveTo(MId.ShakeModTubeScanerClampingSV, paramDao.getScanCodeReleasePos()); |
|
|
canBus.miniServoMoveTo(MId.ShakeModTubeScanerClampingSV, paramDao.getScanCodeReleasePos()); |
|
|
canBus.waitForMod(MId.ShakeModTubeScanerClampingSV, paramDao.getMoveToZeroOvertime()); |
|
|
|
|
|
|
|
|
canBus.waitForMod(MId.ShakeModTubeScanerClampingSV, paramDao.getActionOvertime()); |
|
|
|
|
|
|
|
|
|
|
|
canBus.stepMotorEasyMoveToZero(MId.FeedingModXM); |
|
|
|
|
|
canBus.waitForMod(MId.FeedingModXM, paramDao.getActionOvertime()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 电机归零,电机运行时归零,特点是通过归零判断设备是否丢步 |
|
|
|
|
|
* @throws HardwareException |
|
|
|
|
|
* @throws InterruptedException |
|
|
|
|
|
*/ |
|
|
public void moveToZero() throws HardwareException, InterruptedException { |
|
|
public void moveToZero() throws HardwareException, InterruptedException { |
|
|
//先通过move_to 指令移动到零点 |
|
|
//先通过move_to 指令移动到零点 |
|
|
//再通过 move_to_zero 进行归零(设置超时时间),超时时间,来源MotorParameterDao |
|
|
//再通过 move_to_zero 进行归零(设置超时时间),超时时间,来源MotorParameterDao |
|
@ -66,17 +78,16 @@ public class MotorTubeRackMoveCtrlService { |
|
|
//3.读取电机运行完成后所在的位置 |
|
|
//3.读取电机运行完成后所在的位置 |
|
|
//4.比较dpos和上面两个位置的差值 相差多少,如果超过2mm,即超过20则认为发生过阻转。 |
|
|
//4.比较dpos和上面两个位置的差值 相差多少,如果超过2mm,即超过20则认为发生过阻转。 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var params = this.paramDao; |
|
|
var params = this.paramDao; |
|
|
var beforePos = canBus.stepMotorReadPos(MId.FeedingModXM); |
|
|
var beforePos = canBus.stepMotorReadPos(MId.FeedingModXM); |
|
|
|
|
|
|
|
|
canBus.stepMotorEasyMoveToZero(MId.FeedingModXM); |
|
|
canBus.stepMotorEasyMoveToZero(MId.FeedingModXM); |
|
|
canBus.waitForMod(MId.FeedingModXM, paramDao.getMoveToZeroOvertime()); |
|
|
|
|
|
|
|
|
canBus.waitForMod(MId.FeedingModXM, paramDao.getActionOvertime()); |
|
|
|
|
|
|
|
|
var afterPos = canBus.stepMotorReadPos(MId.FeedingModXM); |
|
|
var afterPos = canBus.stepMotorReadPos(MId.FeedingModXM); |
|
|
var distance = beforePos - afterPos; |
|
|
var distance = beforePos - afterPos; |
|
|
|
|
|
|
|
|
var dval = canBus.module_read_reg(MId.FeedingModXM.toInt(), RegIndex.kreg_step_motor_dpos); |
|
|
|
|
|
|
|
|
var dval = canBus.module_read_reg(MId.FeedingModXM.toInt(), RegIndex.kreg_step_motor_dpos); |
|
|
if (Math.abs(dval - distance) > params.getHorizontalMotorLostStepThresholdVal()) { |
|
|
if (Math.abs(dval - distance) > params.getHorizontalMotorLostStepThresholdVal()) { |
|
|
throw new HardwareException(MId.FeedingModXM, A8kEcode.MotorLostStep); |
|
|
throw new HardwareException(MId.FeedingModXM, A8kEcode.MotorLostStep); |
|
|
} |
|
|
} |
|
@ -92,37 +103,50 @@ public class MotorTubeRackMoveCtrlService { |
|
|
* 移动试管架到入口位置 |
|
|
* 移动试管架到入口位置 |
|
|
*/ |
|
|
*/ |
|
|
public void moveTubeRackToEnterPos() throws HardwareException, InterruptedException { |
|
|
public void moveTubeRackToEnterPos() throws HardwareException, InterruptedException { |
|
|
var params = this.paramDao; |
|
|
|
|
|
this.canBus.callblockcmd(MId.FeedingModXM.toInt(), CmdId.step_motor_easy_move_to.toInt(), params.getTubeRackEnterPos(), params.getActionOvertime()); |
|
|
|
|
|
|
|
|
canBus.miniServoMoveTo(MId.ShakeModTubeScanerClampingSV, paramDao.getScanCodeReleasePos()); |
|
|
|
|
|
canBus.waitForMod(MId.ShakeModTubeScanerClampingSV, paramDao.getActionOvertime()); |
|
|
|
|
|
|
|
|
|
|
|
canBus.stepMotorEasyMoveTo(MId.FeedingModXM, paramDao.getTubeRackEnterPos()); |
|
|
|
|
|
canBus.waitForMod(MId.FeedingModXM, paramDao.getActionOvertime()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 移动试管架到出口位置 |
|
|
* 移动试管架到出口位置 |
|
|
*/ |
|
|
*/ |
|
|
public void moveTubeRackToExitPos() throws HardwareException, InterruptedException { |
|
|
public void moveTubeRackToExitPos() throws HardwareException, InterruptedException { |
|
|
var params = this.paramDao; |
|
|
|
|
|
this.canBus.callblockcmd(MId.FeedingModXM.toInt(), CmdId.step_motor_easy_move_to.toInt(), params.getTubeRackExitPos(), params.getActionOvertime()); |
|
|
|
|
|
|
|
|
canBus.miniServoMoveTo(MId.ShakeModTubeScanerClampingSV, paramDao.getScanCodeReleasePos()); |
|
|
|
|
|
canBus.waitForMod(MId.ShakeModTubeScanerClampingSV, paramDao.getActionOvertime()); |
|
|
|
|
|
|
|
|
|
|
|
canBus.stepMotorEasyMoveTo(MId.FeedingModXM, paramDao.getTubeRackExitPos()); |
|
|
|
|
|
canBus.waitForMod(MId.FeedingModXM, paramDao.getActionOvertime()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 移动试管架到试管架扫码位置 |
|
|
* 移动试管架到试管架扫码位置 |
|
|
*/ |
|
|
*/ |
|
|
public void moveTubeRackToScanPos() throws HardwareException, InterruptedException { |
|
|
public void moveTubeRackToScanPos() throws HardwareException, InterruptedException { |
|
|
var params = this.paramDao; |
|
|
|
|
|
this.canBus.callblockcmd(MId.FeedingModXM.toInt(), CmdId.step_motor_easy_move_to.toInt(), params.getTubeRackScanCodePos(), params.getActionOvertime()); |
|
|
|
|
|
|
|
|
canBus.miniServoMoveTo(MId.ShakeModTubeScanerClampingSV, paramDao.getScanCodeReleasePos()); |
|
|
|
|
|
canBus.waitForMod(MId.ShakeModTubeScanerClampingSV, paramDao.getActionOvertime()); |
|
|
|
|
|
|
|
|
|
|
|
canBus.stepMotorEasyMoveTo(MId.FeedingModXM, paramDao.getTubeRackScanCodePos()); |
|
|
|
|
|
canBus.waitForMod(MId.FeedingModXM, paramDao.getActionOvertime()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 移动试管架到试管架扫码并扫码 |
|
|
* 移动试管架到试管架扫码并扫码 |
|
|
*/ |
|
|
*/ |
|
|
public String moveTubeRackToScanPosAndScan() throws HardwareException, InterruptedException { |
|
|
public String moveTubeRackToScanPosAndScan() throws HardwareException, InterruptedException { |
|
|
this.moveTubeRackToScanPos(); |
|
|
|
|
|
this.canBus.callcmd(MId.FeedingModScannerMod.toInt(), CmdId.code_scaner_start_scan.toInt()); |
|
|
|
|
|
|
|
|
moveTubeRackToScanPos(); |
|
|
|
|
|
canBus.callcmd(MId.FeedingModScannerMod.toInt(), CmdId.code_scaner_start_scan.toInt()); |
|
|
Thread.sleep(5000); |
|
|
Thread.sleep(5000); |
|
|
var response = this.canBus.callcmd(MId.FeedingModScannerMod.toInt(), CmdId.code_scaner_read_scaner_result.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()); |
|
|
this.canBus.callcmd(MId.FeedingModScannerMod.toInt(), CmdId.code_scaner_stop_scan.toInt()); |
|
|
var contentBytes = response.getCmdContent(); |
|
|
var contentBytes = response.getCmdContent(); |
|
|
return new String(contentBytes); |
|
|
return new String(contentBytes); |
|
|
|
|
|
// this.moveTubeRackToScanPos(); |
|
|
|
|
|
// moveTubeRackToScanPos(); |
|
|
|
|
|
// canBus. |
|
|
|
|
|
// return ""; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// |
|
|
// |
|
@ -223,7 +247,6 @@ public class MotorTubeRackMoveCtrlService { |
|
|
// 其他辅助组件 |
|
|
// 其他辅助组件 |
|
|
// |
|
|
// |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 扫描夹紧机构夹紧 |
|
|
* 扫描夹紧机构夹紧 |
|
|
*/ |
|
|
*/ |
|
|