|
|
@ -1,5 +1,6 @@ |
|
|
|
package a8k.service.hardware; |
|
|
|
|
|
|
|
import a8k.appbean.TargetPosMeasureDirection; |
|
|
|
import a8k.canbus.protocol.*; |
|
|
|
import a8k.appbean.HardwareException; |
|
|
|
import a8k.appbean.ecode.AppRet; |
|
|
@ -52,7 +53,7 @@ public class MotorTubeRackMoveCtrlService implements HardwareCtrlModule { |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "出料X位置", group = "试管架位置信息") |
|
|
|
public Integer getTRExitXPos() { |
|
|
|
return 4001; |
|
|
|
return 3980; |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "试管架扫码X位置", group = "试管架位置信息") |
|
|
@ -127,12 +128,10 @@ public class MotorTubeRackMoveCtrlService implements HardwareCtrlModule { |
|
|
|
@Override |
|
|
|
@HardwareServiceAction(name = "模块归零", group = "基础操作") |
|
|
|
public void modGroupMoveToZero() throws HardwareException, InterruptedException { |
|
|
|
// if (!canBus.stepMotorReadIoState(MId.ShakeModGripperZM, 0)) { |
|
|
|
// throw new HardwareException(A8kEcode.ShakeModGripperZMNotInZeroPos); |
|
|
|
// } |
|
|
|
canBus.miniServoEnable(MId.ShakeModTubeScanerClampingSV, 1); |
|
|
|
canBus.miniServoMoveTo(MId.ShakeModTubeScanerClampingSV, 0); |
|
|
|
canBus.waitForMod(MId.ShakeModTubeScanerClampingSV, getActionOvertime()); |
|
|
|
if (!canBus.stepMotorReadIoState(MId.ShakeModGripperZM, 0)) { |
|
|
|
throw new HardwareException(A8kEcode.ShakeModGripperZMNotInZeroPos); |
|
|
|
} |
|
|
|
scanClampModRelease(); |
|
|
|
|
|
|
|
canBus.stepMotorEnable(MId.FeedingModXM, 1); |
|
|
|
canBus.stepMotorEasyMoveToZero(MId.FeedingModXM); |
|
|
@ -142,10 +141,7 @@ public class MotorTubeRackMoveCtrlService implements HardwareCtrlModule { |
|
|
|
@Override |
|
|
|
@HardwareServiceAction(name = "模块快速归零", group = "基础操作") |
|
|
|
public void modGroupMoveToZeroQuick() throws HardwareException, InterruptedException { |
|
|
|
moveTubeRackTo(0); |
|
|
|
canBus.stepMotorEasyMoveToZero(MId.FeedingModXM); |
|
|
|
canBus.waitForMod(MId.FeedingModXM, getActionOvertime()); |
|
|
|
|
|
|
|
canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.FeedingModXM, getActionOvertime()); |
|
|
|
} |
|
|
|
|
|
|
|
/*========================================================================================= |
|
|
@ -159,14 +155,32 @@ public class MotorTubeRackMoveCtrlService implements HardwareCtrlModule { |
|
|
|
* @throws InterruptedException 打断异常 |
|
|
|
*/ |
|
|
|
@HardwareServiceAction(name = "移动到X", group = "模块基础动作") |
|
|
|
public void moveTubeRackTo(Integer pos) throws HardwareException, InterruptedException { |
|
|
|
public void moveTubeRackTo(Integer pos, TargetPosMeasureDirection moveDiretion, Boolean moveToZero) throws HardwareException, InterruptedException { |
|
|
|
if (!canBus.stepMotorReadIoState(MId.ShakeModGripperZM, 0)) { |
|
|
|
throw new HardwareException(A8kEcode.ShakeModGripperZMNotInZeroPos); |
|
|
|
} |
|
|
|
//打开扫码夹具 |
|
|
|
scanClampModRelease(); |
|
|
|
|
|
|
|
//使能电机 |
|
|
|
canBus.stepMotorEnable(MId.FeedingModXM, 1); |
|
|
|
canBus.stepMotorEasyMoveTo(MId.FeedingModXM, pos); |
|
|
|
canBus.waitForMod(MId.FeedingModXM, getActionOvertime()); |
|
|
|
if (moveToZero) { |
|
|
|
canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.FeedingModXM, getActionOvertime()); |
|
|
|
} |
|
|
|
|
|
|
|
// 处理试管架和试管架之间的间隙导致的运行位置误差 |
|
|
|
Integer nowPos = canBus.stepMotorReadPos(MId.FeedingModXM); |
|
|
|
if (TargetPosMeasureDirection.POSITIVE.equals(moveDiretion)) { |
|
|
|
if (nowPos > (pos + 1)) { |
|
|
|
canBus.stepMotorEasyMoveToBlock(MId.FeedingModXM, pos + 30, getActionOvertime()); |
|
|
|
} |
|
|
|
} else if (TargetPosMeasureDirection.NEGATIVE.equals(moveDiretion)) { |
|
|
|
if (nowPos < (pos - 1)) { |
|
|
|
canBus.stepMotorEasyMoveToBlock(MId.FeedingModXM, pos - 30, getActionOvertime()); |
|
|
|
} |
|
|
|
} |
|
|
|
canBus.stepMotorEasyMoveToBlock(MId.FeedingModXM, pos, getActionOvertime()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -217,13 +231,12 @@ public class MotorTubeRackMoveCtrlService implements HardwareCtrlModule { |
|
|
|
|
|
|
|
@HardwareServiceAction(name = "通过归零读取当前电机位置", group = "模块基础动作") |
|
|
|
public AppRet<Integer> readXPosByMoveZero() throws HardwareException, InterruptedException { |
|
|
|
|
|
|
|
|
|
|
|
canBus.stepMotorEnable(MId.FeedingModXM, 1); |
|
|
|
canBus.stepMotorEasyMoveToZero(MId.FeedingModXM); |
|
|
|
canBus.waitForMod(MId.FeedingModXM, getActionOvertime()); |
|
|
|
canBus.stepMotorEasyMoveToZeroBlock(MId.FeedingModXM, getActionOvertime()); |
|
|
|
Integer nowpos = canBus.stepMotorReadPos(MId.FeedingModXM); |
|
|
|
Integer measurepos = -canBus.moduleGetReg(MId.FeedingModXM, RegIndex.kreg_step_motor_dpos) + nowpos; |
|
|
|
canBus.stepMotorEnable(MId.FeedingModXM, 0); |
|
|
|
return AppRet.success(-canBus.moduleGetReg(MId.FeedingModXM, RegIndex.kreg_step_motor_dpos)); |
|
|
|
return AppRet.success(measurepos); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -238,8 +251,7 @@ public class MotorTubeRackMoveCtrlService implements HardwareCtrlModule { |
|
|
|
*/ |
|
|
|
@HardwareServiceAction(name = "移动<试管架>到入口位置", group = "片段") |
|
|
|
public void tubeRackMoveToEnterPos() throws HardwareException, InterruptedException { |
|
|
|
|
|
|
|
moveTubeRackTo(getTREnterXPos()); |
|
|
|
moveTubeRackTo(getTREnterXPos(), TargetPosMeasureDirection.NOTCARE, true); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -247,14 +259,16 @@ public class MotorTubeRackMoveCtrlService implements HardwareCtrlModule { |
|
|
|
*/ |
|
|
|
@HardwareServiceAction(name = "移动<试管架>到出口位置", group = "片段") |
|
|
|
public void moveTubeRackToExitPos() throws HardwareException, InterruptedException { |
|
|
|
moveTubeRackTo(getTRExitXPos()); |
|
|
|
moveTubeRackTo(getTRExitXPos(), TargetPosMeasureDirection.NOTCARE, false); |
|
|
|
moveTubeRackTo(getTRExitXPos() - 10, TargetPosMeasureDirection.NOTCARE, false); |
|
|
|
// moveTubeRackTo(getTRExitXPos(), TargetPosMeasureDirection.NOTCARE, false); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 移动<试管架>到试管架扫码位置 |
|
|
|
*/ |
|
|
|
private void moveTubeRackToScanPos() throws HardwareException, InterruptedException { |
|
|
|
moveTubeRackTo(getTRScanXPos()); |
|
|
|
moveTubeRackTo(getTRScanXPos(), TargetPosMeasureDirection.POSITIVE, false); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -279,11 +293,10 @@ public class MotorTubeRackMoveCtrlService implements HardwareCtrlModule { |
|
|
|
* 移动试管到扫码位置 |
|
|
|
* @param tubeIndex 试管索引 |
|
|
|
*/ |
|
|
|
private AppRet<Object> moveTubeToScanPos(Integer tubeIndex) throws HardwareException, InterruptedException { |
|
|
|
private void moveTubeToScanPos(Integer tubeIndex) throws HardwareException, InterruptedException { |
|
|
|
var scanPos = getTScanXPos() + tubeIndex * getTubeSpacing(); |
|
|
|
canBus.stepMotorEasyMoveTo(MId.FeedingModXM, scanPos); |
|
|
|
canBus.waitForMod(MId.FeedingModXM, getActionOvertime()); |
|
|
|
return AppRet.success(); |
|
|
|
scanClampModClamp(); |
|
|
|
moveTubeRackTo(scanPos, TargetPosMeasureDirection.NEGATIVE, false); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -292,11 +305,10 @@ public class MotorTubeRackMoveCtrlService implements HardwareCtrlModule { |
|
|
|
*/ |
|
|
|
@HardwareServiceAction(name = "扫描<试管X>编码", group = "片段") |
|
|
|
public AppRet<String> moveTubeToScanPosAndScan(Integer tubeIndex) throws HardwareException, InterruptedException { |
|
|
|
var ret = this.moveTubeToScanPos(tubeIndex); |
|
|
|
if (!ret.isSuccess()) {return AppRet.fail(ret);} |
|
|
|
|
|
|
|
moveTubeToScanPos(tubeIndex); |
|
|
|
try { |
|
|
|
scanClampModClamp(); |
|
|
|
|
|
|
|
canBus.codeScanerStartScan(MId.FeedingModScannerMod); |
|
|
|
canBus.miniServoRotateWithTorque(MId.ShakeModTubeScanerClampingSV, getTubeScanServoTorque()); |
|
|
|
String result = canBus.codeScanerWaittingForResult(MId.FeedingModScannerMod, getTubeScanOvertime()); |
|
|
@ -314,7 +326,7 @@ public class MotorTubeRackMoveCtrlService implements HardwareCtrlModule { |
|
|
|
*/ |
|
|
|
@HardwareServiceAction(name = "判断<试管N>高低", group = "片段") |
|
|
|
public AppRet<Boolean> moveTubeToAltitJudgXPos(Integer tubeIndex) throws HardwareException, InterruptedException { |
|
|
|
moveTubeRackTo(getTAltitJudgXPos() + tubeIndex * getTubeSpacing()); |
|
|
|
moveTubeRackTo(getTAltitJudgXPos() + tubeIndex * getTubeSpacing(), TargetPosMeasureDirection.NEGATIVE, false); |
|
|
|
return AppRet.success(isHighTube()); |
|
|
|
} |
|
|
|
|
|
|
@ -324,7 +336,7 @@ public class MotorTubeRackMoveCtrlService implements HardwareCtrlModule { |
|
|
|
*/ |
|
|
|
@HardwareServiceAction(name = "移动<试管N>摇匀位", group = "片段") |
|
|
|
public void moveTubeToPreProcessPos(Integer tubeIndex) throws HardwareException, InterruptedException { |
|
|
|
moveTubeRackTo(getTPreProcessXPos() + tubeIndex * getTubeSpacing()); |
|
|
|
moveTubeRackTo(getTPreProcessXPos() + tubeIndex * getTubeSpacing(), TargetPosMeasureDirection.POSITIVE, false); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -333,7 +345,7 @@ public class MotorTubeRackMoveCtrlService implements HardwareCtrlModule { |
|
|
|
*/ |
|
|
|
@HardwareServiceAction(name = "判断<试管N>是否存在", group = "片段") |
|
|
|
public AppRet<Boolean> judgeTubeExist(Integer tubeIndex) throws HardwareException, InterruptedException { |
|
|
|
moveTubeRackTo(getTExistJudgXPos() + tubeIndex * getTubeSpacing()); |
|
|
|
moveTubeRackTo(getTExistJudgXPos() + tubeIndex * getTubeSpacing(), TargetPosMeasureDirection.NEGATIVE, false); |
|
|
|
return AppRet.success(isTubeExist()); |
|
|
|
} |
|
|
|
|
|
|
|