|
|
@ -2,6 +2,7 @@ package a8k.service.hardware; |
|
|
|
|
|
|
|
import a8k.appbean.HardwareException; |
|
|
|
import a8k.appbean.cfg.*; |
|
|
|
import a8k.appbean.ecode.AppRet; |
|
|
|
import a8k.canbus.A8kCanBusService; |
|
|
|
import a8k.canbus.protocol.A8kEcode; |
|
|
|
import a8k.canbus.protocol.IOId; |
|
|
@ -15,6 +16,7 @@ import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.context.ApplicationContext; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Hbot控制服务 |
|
|
|
*/ |
|
|
@ -37,8 +39,13 @@ public class HbotControlService implements HardwareCtrlModule { |
|
|
|
HardwareParamReader settingReader = new HardwareParamReader(HbotControlService.class); |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "动作超时时间", group = "基础配置") |
|
|
|
public Integer getActionOverTime() { |
|
|
|
return settingReader.getInteger("ActionOverTime", 10000); |
|
|
|
public Integer getActionOvertime() { |
|
|
|
return settingReader.getInteger("ActionOvertime", 10000); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "扫码超时时间", group = "基础配置") |
|
|
|
public Integer getScancodeOvertime() { |
|
|
|
return settingReader.getInteger("ActionOvertime", 1000); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "急诊位", group = "简单位置坐标") |
|
|
@ -50,8 +57,21 @@ public class HbotControlService implements HardwareCtrlModule { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "TIP组位置信息", group = "位置坐标集合") |
|
|
|
public TipPickUpPosInfo getTipPickUpPosInfo() { |
|
|
|
return settingReader.getObject("TipPickUpPosInfo", TipPickUpPosInfo.class, |
|
|
|
new TipPickUpPosInfo( |
|
|
|
new Pos2d(903, -11), |
|
|
|
new Pos2d(0, 0), |
|
|
|
new Pos2d(0, 0), |
|
|
|
92.4, |
|
|
|
92.4, |
|
|
|
0)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@HardwareServiceParam(name = "Tip丢弃位置", group = "简单位置坐标") |
|
|
|
public Pos3d getTipDropPos() throws Exception { |
|
|
|
public Pos3d getTipDropPos() { |
|
|
|
return new Pos3d( |
|
|
|
0, |
|
|
|
0, |
|
|
@ -60,7 +80,7 @@ public class HbotControlService implements HardwareCtrlModule { |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "滴液反应位", group = "简单位置坐标") |
|
|
|
public Pos3d getReactionPos() throws Exception { |
|
|
|
public Pos3d getReactionPos() { |
|
|
|
return settingReader.getObject("ReactionPos", Pos3d.class, |
|
|
|
new Pos3d( |
|
|
|
0, |
|
|
@ -69,20 +89,9 @@ public class HbotControlService implements HardwareCtrlModule { |
|
|
|
)); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "TIP组位置信息", group = "位置坐标集合") |
|
|
|
public TipPickUpPosInfo getTipPickUpPosInfo() throws Exception { |
|
|
|
return settingReader.getObject("TipPickUpPosInfo", TipPickUpPosInfo.class, |
|
|
|
new TipPickUpPosInfo( |
|
|
|
new Pos2d(0, 0), |
|
|
|
new Pos2d(0, 0), |
|
|
|
new Pos2d(0, 0), |
|
|
|
0, |
|
|
|
0, |
|
|
|
0)); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "小瓶缓冲液位置", group = "位置坐标集合") |
|
|
|
public SmallBottleBufferPos getSmallBottleBufferPosInfo() throws Exception { |
|
|
|
public SmallBottleBufferPos getSmallBottleBufferPosInfo() { |
|
|
|
return settingReader.getObject("SmallBottleBufferPosInfo", SmallBottleBufferPos.class, |
|
|
|
new SmallBottleBufferPos( |
|
|
|
new Pos2d(0, 0), |
|
|
@ -103,7 +112,7 @@ public class HbotControlService implements HardwareCtrlModule { |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "板夹仓扫码位置", group = "位置坐标集合") |
|
|
|
public Plates2dCodeScanPos getPlates2dCodeScanPosInfo() throws Exception { |
|
|
|
public Plates2dCodeScanPos getPlates2dCodeScanPosInfo() { |
|
|
|
return settingReader.getObject("Plates2dCodeScanPosInfo", Plates2dCodeScanPos.class,// |
|
|
|
new Plates2dCodeScanPos( |
|
|
|
new Pos2d(0, 0), |
|
|
@ -113,7 +122,7 @@ public class HbotControlService implements HardwareCtrlModule { |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "大瓶缓冲液位置", group = "位置坐标集合") |
|
|
|
public LargeBottleBufferPos getLargeBottleBufferPosInfo() throws Exception { |
|
|
|
public LargeBottleBufferPos getLargeBottleBufferPosInfo() { |
|
|
|
return settingReader.getObject("LargeBottleBufferPosInfo", LargeBottleBufferPos.class, |
|
|
|
new LargeBottleBufferPos( |
|
|
|
new Pos2d(0, 0), |
|
|
@ -163,69 +172,162 @@ public class HbotControlService implements HardwareCtrlModule { |
|
|
|
/** |
|
|
|
* 下面脚本中涉及到的动作,如果正常结束,Z轴均移动的0位置。 |
|
|
|
*/ |
|
|
|
@HardwareServiceAction(name = "Hbot使能", group = "基础控制") |
|
|
|
@HardwareServiceAction(name = "模块使能", group = "基础控制") |
|
|
|
@Override public void modGroupEnable(Boolean enable) throws HardwareException, InterruptedException { |
|
|
|
comHardwareOpera.enableAllMotor(); |
|
|
|
if (enable) { |
|
|
|
comHardwareOpera.enableAllMotor(); |
|
|
|
} else { |
|
|
|
comHardwareOpera.disableAllMotor(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceAction(name = "Hbot停止", group = "基础控制") |
|
|
|
@HardwareServiceAction(name = "模块停止", group = "基础控制") |
|
|
|
@Override public void modGroupStop() throws HardwareException { |
|
|
|
comHardwareOpera.forceStopAndDisableAllMOtor(); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceAction(name = "Hbot归零", group = "基础控制") |
|
|
|
@HardwareServiceAction(name = "模块归零", group = "基础控制") |
|
|
|
@Override public void modGroupMoveToZero() throws HardwareException, InterruptedException { |
|
|
|
checkPublicArea(); |
|
|
|
checkBeforeHbotRun(new Pos2d(0, 0)); |
|
|
|
canBus.stepMotorEnable(MId.PipetteModZM, 1); |
|
|
|
canBus.hbotEnable(MId.HbotM, 1); |
|
|
|
|
|
|
|
canBus.stepMotorEasyMoveToZeroBlock(MId.PipetteModZM, getActionOverTime()); |
|
|
|
canBus.hbotMoveToZeroBlock(MId.HbotM, getActionOverTime()); |
|
|
|
canBus.stepMotorEasyMoveToZeroBlock(MId.PipetteModZM, getActionOvertime()); |
|
|
|
|
|
|
|
checkBeforeHbotRun(new Pos2d(0, 0)); |
|
|
|
canBus.hbotMoveToZeroBlock(MId.HbotM, getActionOvertime()); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceAction(name = "Hbot快速归零", group = "基础控制") |
|
|
|
@HardwareServiceAction(name = "模块快速归零", group = "基础控制") |
|
|
|
@Override public void modGroupMoveToZeroQuick() throws HardwareException, InterruptedException { |
|
|
|
checkPublicArea(); |
|
|
|
canBus.stepMotorEnable(MId.PipetteModZM, 1); |
|
|
|
canBus.hbotEnable(MId.HbotM, 1); |
|
|
|
|
|
|
|
canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PipetteModZM, getActionOvertime()); |
|
|
|
|
|
|
|
checkBeforeHbotRun(new Pos2d(0, 0)); |
|
|
|
canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PipetteModZM, getActionOverTime()); |
|
|
|
canBus.hbotMoveToBlock(MId.HbotM, 0, 0, getActionOverTime()); |
|
|
|
canBus.hbotMoveToZeroBlock(MId.HbotM, getActionOverTime()); |
|
|
|
canBus.hbotMoveToBlock(MId.HbotM, 0, 0, getActionOvertime()); |
|
|
|
canBus.hbotMoveToZeroBlock(MId.HbotM, getActionOvertime()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@HardwareServiceAction(name = "Hbot使能", group = "坐标获取工具") |
|
|
|
public void hBotEnable() throws HardwareException, InterruptedException { |
|
|
|
canBus.hbotEnable(MId.HbotM, 1); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceAction(name = "Hbot失能", group = "坐标获取工具") |
|
|
|
public void hBotDisable() throws HardwareException, InterruptedException { |
|
|
|
canBus.hbotEnable(MId.HbotM, 0); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceAction(name = "Z轴使能", group = "坐标获取工具") |
|
|
|
public void zAxisEnable() throws HardwareException, InterruptedException { |
|
|
|
canBus.stepMotorEnable(MId.PipetteModZM, 1); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceAction(name = "Z轴失能", group = "坐标获取工具") |
|
|
|
public void zAxisDisable() throws HardwareException, InterruptedException { |
|
|
|
canBus.stepMotorEnable(MId.PipetteModZM, 0); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceAction(name = "读取Z轴坐标", group = "坐标获取工具") |
|
|
|
public AppRet<Integer> readZAxisPosByMoveToZero() throws HardwareException, InterruptedException { |
|
|
|
return AppRet.success(canBus.stepMotorReadPosByMoveToZeroBlock(MId.PipetteModZM, getActionOvertime())); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@HardwareServiceAction(name = "HBot移动到", group = "基础控制") |
|
|
|
public void hbotMoveTo(Integer x, Integer y) throws HardwareException, InterruptedException { |
|
|
|
checkPublicArea(); |
|
|
|
checkBeforeHbotRun(new Pos2d(x, y)); |
|
|
|
canBus.hbotMoveToBlock(MId.HbotM, x, y, getActionOverTime()); |
|
|
|
|
|
|
|
canBus.hbotEnable(MId.HbotM, 1); |
|
|
|
|
|
|
|
canBus.hbotMoveToBlock(MId.HbotM, x - 20, y - 20, getActionOvertime()); |
|
|
|
canBus.hbotMoveToBlock(MId.HbotM, x, y - 15, getActionOvertime()); |
|
|
|
// Thread.sleep(200); |
|
|
|
canBus.hbotMoveToBlock(MId.HbotM, x, y, getActionOvertime()); |
|
|
|
} |
|
|
|
|
|
|
|
public void zMoveTo(Integer z) throws HardwareException, InterruptedException { |
|
|
|
canBus.stepMotorEasyMoveToBlock(MId.PipetteModZM, z, getActionOvertime()); |
|
|
|
} |
|
|
|
|
|
|
|
//取tip |
|
|
|
public boolean takeTip(int groupId, int index) { |
|
|
|
return false; |
|
|
|
@HardwareServiceAction(name = "取Tip", group = "单步操作") |
|
|
|
public AppRet<Boolean> takeTip(Integer groupId, Integer index) throws HardwareException, InterruptedException { |
|
|
|
logger.info("takeTip groupId:{} index:{}", groupId, index); |
|
|
|
if (groupId > 2 || groupId < 0) { |
|
|
|
throw new HardwareException(A8kEcode.ParamOutOfRange); |
|
|
|
} |
|
|
|
|
|
|
|
if (index > TipPickUpPosInfo.ROW_MAX * TipPickUpPosInfo.COL_MAX || index < 0) { |
|
|
|
throw new HardwareException(A8kEcode.ParamOutOfRange); |
|
|
|
} |
|
|
|
|
|
|
|
TipPickUpPosInfo tipPos = getTipPickUpPosInfo(); |
|
|
|
Pos2d pos = tipPos.getTipPos(groupId, index); |
|
|
|
hbotMoveTo(pos.x, pos.y); |
|
|
|
|
|
|
|
canBus.stepMotorEasyMoveToBlock(MId.PipetteModZM, tipPos.pickUpZPos, getActionOvertime()); |
|
|
|
canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PipetteModZM, getActionOvertime()); |
|
|
|
|
|
|
|
Boolean isGetTip = canBus.moduleGetReg(MId.PipetteMod, RegIndex.kreg_pipette_tip_state) == 1; |
|
|
|
if (!isGetTip) { |
|
|
|
logger.error("takeTip fail"); |
|
|
|
} |
|
|
|
return AppRet.success(isGetTip); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceAction(name = "取Tip测试", group = "测试") |
|
|
|
public AppRet<Boolean> takeTipTest(Integer groupId, Integer index) throws HardwareException, InterruptedException { |
|
|
|
var ret = takeTip(groupId, index); |
|
|
|
TipPickUpPosInfo tipPos = getTipPickUpPosInfo(); |
|
|
|
|
|
|
|
canBus.stepMotorEasyMoveToBlock(MId.PipetteModZM, tipPos.pickUpZPos, getActionOvertime()); |
|
|
|
canBus.pipetteCtrlPutTip(MId.PipetteMod); |
|
|
|
canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PipetteModZM, getActionOvertime()); |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
//丢tip |
|
|
|
public A8kEcode dropTip() { |
|
|
|
return A8kEcode.Success; |
|
|
|
@HardwareServiceAction(name = "丢Tip", group = "单步操作") |
|
|
|
public void dropTip() throws HardwareException, InterruptedException { |
|
|
|
Pos3d pos = getTipDropPos(); |
|
|
|
hbotMoveTo(pos.x, pos.y); |
|
|
|
zMoveTo(pos.z); |
|
|
|
canBus.pipetteCtrlPutTip(MId.PipetteMod); |
|
|
|
} |
|
|
|
|
|
|
|
private AppRet<String> hBotMoveToAndScan(Pos2d pos) throws HardwareException, InterruptedException { |
|
|
|
hbotMoveTo(pos.x, pos.y); |
|
|
|
canBus.codeScanerStartScan(MId.PipetteModCodeScanner); |
|
|
|
String result = canBus.codeScanerWaittingForResult(MId.PipetteModCodeScanner, getScancodeOvertime()); |
|
|
|
return AppRet.success(result); |
|
|
|
} |
|
|
|
|
|
|
|
//扫描板夹仓二维码 |
|
|
|
public String scanPlatesCode(int index, int overtime) { |
|
|
|
return ""; |
|
|
|
public AppRet<String> scanPlatesCode(Integer index) throws HardwareException, InterruptedException { |
|
|
|
var posInfo = getPlates2dCodeScanPosInfo(); |
|
|
|
return hBotMoveToAndScan(new Pos2d(posInfo.ch0ScanPos.x, posInfo.ch0ScanPos.y + posInfo.scanYSpacing * index)); |
|
|
|
} |
|
|
|
|
|
|
|
//扫描小缓冲液二维码 |
|
|
|
public String scanSmallBottleBufferCode(int index, int overtime) { |
|
|
|
return ""; |
|
|
|
public AppRet<String> scanSmallBottleBufferCode(Integer index) { |
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
//扫描大缓冲液二维码 |
|
|
|
public String scanBigBottleBufferCode(int index, int overtime) { |
|
|
|
public String scanBigBottleBufferCode(Integer index) { |
|
|
|
return ""; |
|
|
|
} |
|
|
|
|
|
|
|
//在试管架的位置取样品 |
|
|
|
public boolean takeSampleFromPos0(int ul) { |
|
|
|
public boolean takeSampleFromPos0(Integer ul) { |
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
@ -251,25 +353,31 @@ public class HbotControlService implements HardwareCtrlModule { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@HardwareServiceStatus(name = "Z轴光电⬆") |
|
|
|
// @HardwareServiceStatus(name = "Z轴光电⬆") |
|
|
|
public Boolean getZPPS() throws HardwareException { |
|
|
|
return canBus.stepMotorReadIoState(MId.PipetteModZM, 0); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceStatus(name = "X轴光电➡") |
|
|
|
// @HardwareServiceStatus(name = "X轴光电➡") |
|
|
|
public Boolean getXPPS() throws HardwareException { |
|
|
|
return canBus.hbotReadInio(MId.HbotM, 0); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceStatus(name = "Y轴光电⬇") |
|
|
|
// @HardwareServiceStatus(name = "Y轴光电⬇") |
|
|
|
public Boolean getYPPS() throws HardwareException { |
|
|
|
return canBus.hbotReadInio(MId.HbotM, 1); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceStatus(name = "TipState") |
|
|
|
public Boolean getTipPPS() throws HardwareException { |
|
|
|
return false; |
|
|
|
// return canBus.moduleGetReg(MId.PipetteMod, RegIndex.kreg_pipette_tip_state) == 1; |
|
|
|
// @HardwareServiceStatus(name = "TipState") |
|
|
|
// public Boolean getTipPPS() throws HardwareException { |
|
|
|
// return canBus.moduleGetReg(MId.PipetteMod, RegIndex.kreg_pipette_tip_state) == 1; |
|
|
|
// } |
|
|
|
|
|
|
|
// @HardwareServiceStatus(name = "HbotPos") |
|
|
|
public String getPos() throws HardwareException { |
|
|
|
Pos2d pos = canBus.hbotReadPos(MId.HbotM); |
|
|
|
return pos.toString(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |