|
|
@ -7,16 +7,13 @@ import a8k.appbean.HardwareException; |
|
|
|
import a8k.base_hardware.A8kCanBusService; |
|
|
|
import a8k.service.db.dao.A8kDirectCtrlPosDao; |
|
|
|
import a8k.service.db.dao.A8kTubeInfoDao; |
|
|
|
import a8k.service.db.dao.MotorTubeRackMoveCtrlServiceParameterDao; |
|
|
|
import a8k.service.db.dao.MotorParameterDao; |
|
|
|
import a8k.service.db.entity.A8kDirectCtrlPos; |
|
|
|
import jakarta.annotation.Resource; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
@Component |
|
|
|
public class MotorTubeRackMoveCtrlService { |
|
|
|
private static final Integer MOVE_TO_ZERO_MAX_DPOS = 10; |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* 主要用来控制试管架的平移动作控制 |
|
|
@ -42,14 +39,17 @@ public class MotorTubeRackMoveCtrlService { |
|
|
|
// MotorTubeScanClampModule_clampPos |
|
|
|
// MotorTubeScanClampModule_releasePos |
|
|
|
|
|
|
|
@Autowired |
|
|
|
A8kDirectCtrlPosDao directCtrlPosTableDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
A8kTubeInfoDao tubeInfoDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
MotorParameterDao motorParameterDao; |
|
|
|
@Resource |
|
|
|
private A8kCanBusService a8kCanBusService; |
|
|
|
@Resource |
|
|
|
MotorTubeRackMoveCtrlServiceParameterDao serviceParameterDao; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// |
|
|
@ -62,8 +62,6 @@ public class MotorTubeRackMoveCtrlService { |
|
|
|
|
|
|
|
|
|
|
|
public void moveToZero() throws HardwareException, InterruptedException { |
|
|
|
var motorParams = this.motorParameterDao.getMotorParameter(ModuleId.MotorTubeRackMoveModule); |
|
|
|
|
|
|
|
var beforePosResponse = this.a8kCanBusService.callcmd(ModuleId.MotorTubeRackMoveModule, CmdId.kstep_motor_read_pos, new Integer[]{0}); |
|
|
|
var beforePos = beforePosResponse.getContentI32(0); |
|
|
|
this.a8kCanBusService.callblockcmd(ModuleId.MotorTubeRackMoveModule, CmdId.kstep_motor_easy_move_to_zero, new Integer[]{}, motorParams.moveToZeroOvertime); |
|
|
@ -96,24 +94,24 @@ public class MotorTubeRackMoveCtrlService { |
|
|
|
* 移动试管架到入口位置 |
|
|
|
*/ |
|
|
|
public void moveTubeRackToEnterPos() throws HardwareException, InterruptedException { |
|
|
|
var pos = this.directCtrlPosTableDao.getPos(A8kDirectCtrlPosDao.MotorTubeRackMotor_tubeRackEnterPos); |
|
|
|
this.a8kCanBusService.callblockcmd(ModuleId.MotorTubeRackMoveModule, CmdId.kstep_motor_easy_move_to, new Integer[]{pos.posX}, 30*1000); |
|
|
|
var params = this.serviceParameterDao.getParameter(); |
|
|
|
this.a8kCanBusService.callblockcmd(ModuleId.MotorTubeRackMoveModule, CmdId.kstep_motor_easy_move_to, new Integer[]{params.tubeRackEnterPos}, params.actionOvertime); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 移动试管架到出口位置 |
|
|
|
*/ |
|
|
|
public void moveTubeRackToExitPos() throws HardwareException, InterruptedException { |
|
|
|
var pos = this.directCtrlPosTableDao.getPos(A8kDirectCtrlPosDao.MotorTubeRackMotor_tubeRackExitPos); |
|
|
|
this.a8kCanBusService.callblockcmd(ModuleId.MotorTubeRackMoveModule, CmdId.kstep_motor_easy_move_to, new Integer[]{pos.posX}, 30*1000); |
|
|
|
var params = this.serviceParameterDao.getParameter(); |
|
|
|
this.a8kCanBusService.callblockcmd(ModuleId.MotorTubeRackMoveModule, CmdId.kstep_motor_easy_move_to, new Integer[]{params.tubeExistJudgmentPos}, params.actionOvertime); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 移动试管架到试管架扫码位置 |
|
|
|
*/ |
|
|
|
public void moveTubeRackToScanPos() throws HardwareException, InterruptedException { |
|
|
|
var pos = this.directCtrlPosTableDao.getPos(A8kDirectCtrlPosDao.MotorTubeRackMotor_tubeRackScanCodePos); |
|
|
|
this.a8kCanBusService.callblockcmd(ModuleId.MotorTubeRackMoveModule, CmdId.kstep_motor_easy_move_to, new Integer[]{pos.posX}, 30*1000); |
|
|
|
var params = this.serviceParameterDao.getParameter(); |
|
|
|
this.a8kCanBusService.callblockcmd(ModuleId.MotorTubeRackMoveModule, CmdId.kstep_motor_easy_move_to, new Integer[]{params.tubeRackScanCodePos}, params.actionOvertime); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -139,13 +137,11 @@ public class MotorTubeRackMoveCtrlService { |
|
|
|
* @param tubeType |
|
|
|
* @param tubeIndex |
|
|
|
*/ |
|
|
|
public void moveTubeToScanPos(String tubeType, Integer tubeIndex) { |
|
|
|
public void moveTubeToScanPos(String tubeType, Integer tubeIndex) throws HardwareException, InterruptedException { |
|
|
|
var params = this.serviceParameterDao.getParameter(); |
|
|
|
var tubeInfo = this.tubeInfoDao.getTubeInfo(tubeType); |
|
|
|
var startPosInfo = this.directCtrlPosTableDao.getPos(A8kDirectCtrlPosDao.MotorTubeRackMotor_tubeScanPos); |
|
|
|
var scanPos = startPosInfo.posX + tubeIndex * tubeInfo.tubeSpacing; |
|
|
|
|
|
|
|
var motorParams = this.motorParameterDao.getMotorParameter(ModuleId.MotorTubeRackMoveModule); |
|
|
|
this.a8kCanBusService.callblockcmd(ModuleId.MotorTubeRackMoveModule, CmdId.kstep_motor_easy_move_to, new Integer[]{scanPos}, motorParams.actionOvertime); |
|
|
|
var scanPos = params.tubeScanPos + tubeIndex * tubeInfo.tubeSpacing; |
|
|
|
this.a8kCanBusService.callblockcmd(ModuleId.MotorTubeRackMoveModule, CmdId.kstep_motor_easy_move_to, new Integer[]{scanPos}, params.actionOvertime); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -153,8 +149,15 @@ public class MotorTubeRackMoveCtrlService { |
|
|
|
* @param tubeType |
|
|
|
* @param tubeIndex |
|
|
|
*/ |
|
|
|
public String moveTubeToScanPosAndScan(String tubeType, Integer tubeIndex) { |
|
|
|
return null; |
|
|
|
public String moveTubeToScanPosAndScan(String tubeType, Integer tubeIndex) throws HardwareException, InterruptedException { |
|
|
|
this.moveTubeToScanPos(tubeType, tubeIndex); |
|
|
|
|
|
|
|
this.a8kCanBusService.callcmd(ModuleId.TubeRackScannerModule, CmdId.kcode_scaner_start_scan, new Integer[]{}); |
|
|
|
Thread.sleep(500); |
|
|
|
var response = this.a8kCanBusService.callcmd(ModuleId.TubeRackScannerModule, CmdId.kcode_scaner_read_scaner_result, new Integer[]{}); |
|
|
|
this.a8kCanBusService.callcmd(ModuleId.TubeRackScannerModule, CmdId.kcode_scaner_stop_scan, new Integer[]{}); |
|
|
|
var contentBytes = response.getCmdContent(); |
|
|
|
return new String(contentBytes); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -162,7 +165,11 @@ public class MotorTubeRackMoveCtrlService { |
|
|
|
* @param tubeType |
|
|
|
* @param tubeIndex |
|
|
|
*/ |
|
|
|
public void moveTubeToHeighJudgmentPos(String tubeType, Integer tubeIndex) { |
|
|
|
public void moveTubeToHeighJudgmentPos(String tubeType, Integer tubeIndex) throws HardwareException, InterruptedException { |
|
|
|
var params = this.serviceParameterDao.getParameter(); |
|
|
|
var tubeInfo = this.tubeInfoDao.getTubeInfo(tubeType); |
|
|
|
var detectPos = params.tubeHeighJudgmentPos + tubeIndex * tubeInfo.tubeSpacing; |
|
|
|
this.a8kCanBusService.callblockcmd(ModuleId.MotorTubeRackMoveModule, CmdId.kstep_motor_easy_move_to, new Integer[]{detectPos}, params.actionOvertime); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -170,7 +177,11 @@ public class MotorTubeRackMoveCtrlService { |
|
|
|
* @param tubeType |
|
|
|
* @param tubeIndex |
|
|
|
*/ |
|
|
|
public void moveTubeToPreProcessPos(String tubeType, Integer tubeIndex) { |
|
|
|
public void moveTubeToPreProcessPos(String tubeType, Integer tubeIndex) throws HardwareException, InterruptedException { |
|
|
|
var params = this.serviceParameterDao.getParameter(); |
|
|
|
var tubeInfo = this.tubeInfoDao.getTubeInfo(tubeType); |
|
|
|
var pos = params.tubePreProcessPos + tubeIndex * tubeInfo.tubeSpacing; |
|
|
|
this.a8kCanBusService.callblockcmd(ModuleId.MotorTubeRackMoveModule, CmdId.kstep_motor_easy_move_to, new Integer[]{pos}, params.actionOvertime); |
|
|
|
} |
|
|
|
|
|
|
|
// |
|
|
@ -182,15 +193,21 @@ public class MotorTubeRackMoveCtrlService { |
|
|
|
* @param tubeType |
|
|
|
* @param tubeIndex |
|
|
|
*/ |
|
|
|
public void moveTubeToExistJudgmentPos(String tubeType, Integer tubeIndex) { |
|
|
|
public void moveTubeToExistJudgmentPos(String tubeType, Integer tubeIndex) throws HardwareException, InterruptedException { |
|
|
|
var params = this.serviceParameterDao.getParameter(); |
|
|
|
var tubeInfo = this.tubeInfoDao.getTubeInfo(tubeType); |
|
|
|
var pos = params.tubeRackExitPos + tubeIndex * tubeInfo.tubeSpacing; |
|
|
|
this.a8kCanBusService.callblockcmd(ModuleId.MotorTubeRackMoveModule, CmdId.kstep_motor_easy_move_to, new Integer[]{pos}, params.actionOvertime); |
|
|
|
} |
|
|
|
|
|
|
|
public boolean isTubeRackExitInEnterPos() { |
|
|
|
return false; |
|
|
|
public boolean isTubeRackInEnterPos() throws HardwareException { |
|
|
|
var response = this.a8kCanBusService.callcmd(ModuleId.FeederBoard, CmdId.kxymotor_read_inio, new Integer[]{3}); |
|
|
|
return response.getContentI32(0) == 1; |
|
|
|
} |
|
|
|
|
|
|
|
public boolean isTubeRackExitInExitPos() { |
|
|
|
return false; |
|
|
|
public boolean isTubeRackInExitPos() throws HardwareException { |
|
|
|
var response = this.a8kCanBusService.callcmd(ModuleId.FeederBoard, CmdId.kxymotor_read_inio, new Integer[]{5}); |
|
|
|
return response.getContentI32(0) == 1; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -198,8 +215,10 @@ public class MotorTubeRackMoveCtrlService { |
|
|
|
* @param photoelectricIndex 0:里光电,1:外光电 |
|
|
|
* @return true, 光电触发 false,光电没有触发 |
|
|
|
*/ |
|
|
|
public boolean getMoveChannelPhotoelectricState(int photoelectricIndex) { |
|
|
|
return false; |
|
|
|
public boolean getMoveChannelPhotoelectricState(int photoelectricIndex) throws HardwareException { |
|
|
|
var index = 0 == photoelectricIndex ? 2 : 1; |
|
|
|
var response = this.a8kCanBusService.callcmd(ModuleId.FeederBoard, CmdId.kxymotor_read_inio, new Integer[]{index}); |
|
|
|
return response.getContentI32(0) == 1; |
|
|
|
} |
|
|
|
|
|
|
|
// |
|
|
@ -207,4 +226,31 @@ public class MotorTubeRackMoveCtrlService { |
|
|
|
// |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 扫描夹紧机构夹紧 |
|
|
|
*/ |
|
|
|
public void scanClampModuleCompress() throws HardwareException, InterruptedException { |
|
|
|
var params = this.serviceParameterDao.getParameter(); |
|
|
|
this.a8kCanBusService.callblockcmd( |
|
|
|
ModuleId.ServoTubeRackTubePushModule, |
|
|
|
CmdId.kmini_servo_move_to, |
|
|
|
new Integer[]{0}, |
|
|
|
params.actionOvertime |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 扫描夹紧机构复位 |
|
|
|
*/ |
|
|
|
public void scanClampModuleReset() throws HardwareException, InterruptedException { |
|
|
|
var params = this.serviceParameterDao.getParameter(); |
|
|
|
this.a8kCanBusService.callblockcmd( |
|
|
|
ModuleId.ServoTubeRackTubePushModule, |
|
|
|
CmdId.kmini_servo_move_to, |
|
|
|
new Integer[]{0}, |
|
|
|
params.actionOvertime |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |