|
|
@ -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; |
|
|
|
private CommonHardwareOpeartion comHardwareOpear; |
|
|
|
|
|
|
|
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 |
|
|
|
); |
|
|
|
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() |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
canBus.stepMotorEasyMoveToZero(MId.FeedingModXM); |
|
|
|
canBus.waitForMod(MId.FeedingModXM, paramDao.getMoveToZeroOvertime()); |
|
|
|
|
|
|
|
if (Math.abs(dval - distance) > params.getHorizontalMotorLostStepThresholdVal() ) { |
|
|
|
throw new HardwareException(MId.FeedingModXM, A8kEcode.MotorLostStep); |
|
|
|
canBus.miniServoMoveTo(MId.ShakeModTubeScanerClampingSV, paramDao.getScanCodeReleasePos()); |
|
|
|
canBus.waitForMod(MId.ShakeModTubeScanerClampingSV, paramDao.getMoveToZeroOvertime()); |
|
|
|
} |
|
|
|
|
|
|
|
public void moveToZero() throws HardwareException, InterruptedException { |
|
|
|
//先通过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 params = this.paramDao; |
|
|
|
var scanPos = params.getTubeScanPos() + tubeIndex * params.getTubeSpacing(); |
|
|
|
this.a8kCanBusService.callblockcmd( |
|
|
|
MId.FeedingModXM.toInt(), |
|
|
|
CmdId.step_motor_easy_move_to.toInt(), |
|
|
|
scanPos, |
|
|
|
params.getActionOvertime() |
|
|
|
); |
|
|
|
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); |
|
|
|
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.a8kCanBusService.callcmd(MId.FeedingModScannerMod.toInt(), CmdId.code_scaner_result_is_ready.toInt()); |
|
|
|
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 params = this.paramDao; |
|
|
|
var pos = params.getTubePreProcessPos() + tubeIndex * params.getTubeSpacing(); |
|
|
|
this.a8kCanBusService.callblockcmd( |
|
|
|
MId.FeedingModXM.toInt(), |
|
|
|
CmdId.step_motor_easy_move_to.toInt(), |
|
|
|
pos, |
|
|
|
params.getActionOvertime() |
|
|
|
); |
|
|
|
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 params = this.paramDao; |
|
|
|
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()); |
|
|
|
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()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|