Browse Source

update

tags/v0
zhaohe 1 year ago
parent
commit
ddaa89adba
  1. 13
      src/main/java/a8k/appbean/cfg/TipPickUpPosInfo.java
  2. 15
      src/main/java/a8k/canbus/A8kCanBusService.java
  3. 64
      src/main/java/a8k/service/hardware/HbotControlService.java

13
src/main/java/a8k/appbean/cfg/TipPickUpPosInfo.java

@ -11,8 +11,11 @@ public class TipPickUpPosInfo {
public Integer pickUpZPos; //拾取高度 public Integer pickUpZPos; //拾取高度
final public static Integer ROW_MAX = 10;
final public static Integer COL_MAX = 12;
static public Integer cgetTipNum() {return 12 * 10;}
static public Integer cgetCOL_MAX() {return 12;}
static public Integer cgetROW_MAX() {return 10;}
public TipPickUpPosInfo() { public TipPickUpPosInfo() {
g0tl = new Pos2d(0, 0); g0tl = new Pos2d(0, 0);
@ -48,10 +51,12 @@ public class TipPickUpPosInfo {
int row; // int row; //
int col; // int col; //
row = index / COL_MAX;
col = index % COL_MAX;
row = index / cgetCOL_MAX();
col = index % cgetCOL_MAX();
Pos2d topleft = getTopLeft(group); Pos2d topleft = getTopLeft(group);
return new Pos2d((int) (topleft.x + col * xSpacing), (int) (topleft.y + row * ySpacing)); return new Pos2d((int) (topleft.x + col * xSpacing), (int) (topleft.y + row * ySpacing));
} }
} }

15
src/main/java/a8k/canbus/A8kCanBusService.java

@ -672,7 +672,7 @@ public class A8kCanBusService {
} while (true); } while (true);
} }
public Boolean getIOState(IOId ioid) throws HardwareException {
public Boolean priGetIOState(IOId ioid) throws HardwareException {
if (ioid.mtype == ModuleType.kboard) { if (ioid.mtype == ModuleType.kboard) {
return callcmd(ioid.mid.toInt(), CmdId.extboard_read_inio.toInt(), ioid.ioIndex).getContentI32(0) != 0; return callcmd(ioid.mid.toInt(), CmdId.extboard_read_inio.toInt(), ioid.ioIndex).getContentI32(0) != 0;
} else if (ioid.mtype == ModuleType.ktmc_step_motor) { } else if (ioid.mtype == ModuleType.ktmc_step_motor) {
@ -684,6 +684,19 @@ public class A8kCanBusService {
} }
} }
public Boolean getIOState(IOId ioid) throws HardwareException {
while (true) {
Boolean firstReadIO = priGetIOState(ioid);
Boolean secondReadIO = priGetIOState(ioid);
if(firstReadIO == secondReadIO){
return firstReadIO;
}else{
logger.warn("getIOState {} not match, retry", ioid);
}
}
}
public void setIOState(IOId ioid, boolean val) throws HardwareException { public void setIOState(IOId ioid, boolean val) throws HardwareException {
if (ioid.mtype == ModuleType.kboard) { if (ioid.mtype == ModuleType.kboard) {
callcmd(ioid.mid.toInt(), CmdId.extboard_write_outio.toInt(), ioid.ioIndex, val ? 1 : 0); callcmd(ioid.mid.toInt(), CmdId.extboard_write_outio.toInt(), ioid.ioIndex, val ? 1 : 0);

64
src/main/java/a8k/service/hardware/HbotControlService.java

@ -1,6 +1,7 @@
package a8k.service.hardware; package a8k.service.hardware;
import a8k.appbean.HardwareException; import a8k.appbean.HardwareException;
import a8k.appbean.PlateBoxCh;
import a8k.appbean.cfg.*; import a8k.appbean.cfg.*;
import a8k.appbean.ecode.AppRet; import a8k.appbean.ecode.AppRet;
import a8k.canbus.A8kCanBusService; import a8k.canbus.A8kCanBusService;
@ -284,7 +285,7 @@ public class HbotControlService implements HardwareCtrlModule {
throw new HardwareException(A8kEcode.ParamOutOfRange); throw new HardwareException(A8kEcode.ParamOutOfRange);
} }
if (index > TipPickUpPosInfo.ROW_MAX * TipPickUpPosInfo.COL_MAX || index < 0) {
if (index > TipPickUpPosInfo.cgetTipNum() || index < 0) {
throw new HardwareException(A8kEcode.ParamOutOfRange); throw new HardwareException(A8kEcode.ParamOutOfRange);
} }
@ -337,13 +338,44 @@ public class HbotControlService implements HardwareCtrlModule {
return AppRet.success(canBus.stepMotorReadPosByMoveToZeroBlock(MId.PipetteModZM, getActionOvertime())); return AppRet.success(canBus.stepMotorReadPosByMoveToZeroBlock(MId.PipetteModZM, getActionOvertime()));
} }
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// hbot移动到并扫码
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
private AppRet<String> hBotMoveToAndScan(Pos2d pos) throws HardwareException, InterruptedException {
hbotCheckAndMoveTo(pos);
canBus.codeScanerStartScan(MId.PipetteModCodeScanner);
String result = canBus.codeScanerWaittingForResult(MId.PipetteModCodeScanner, getScancodeOvertime());
return AppRet.success(result);
}
//扫描板夹仓二维码
public AppRet<String> scanPlatesCode(PlateBoxCh ch) throws HardwareException, InterruptedException {
var posInfo = getPlates2dCodeScanPosInfo();
return hBotMoveToAndScan(new Pos2d(posInfo.ch0ScanPos.x, posInfo.ch0ScanPos.y + posInfo.scanYSpacing * ch.off));
}
//扫描小缓冲液二维码
public AppRet<String> scanSmallBottleBufferCode(Integer group) {
var posInfo = getSmallBottleBufferPosInfo();
return null;
}
//扫描大缓冲液二维码
public String scanBigBottleBufferCode(Integer index) {
return "";
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// 测试 // 测试
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Boolean testTakeTipFlag; Boolean testTakeTipFlag;
private AppRet<Boolean> takeTipTestStep(Integer groupId, Integer index) throws HardwareException, InterruptedException {
@HardwareServiceAction(name = "取放Tip", group = "测试脚本")
public AppRet<Boolean> takeTipTestStep(Integer groupId, Integer index) throws HardwareException, InterruptedException {
var ret = takeTip(groupId, index); var ret = takeTip(groupId, index);
TipPickUpPosInfo tipPos = getTipPickUpPosInfo(); TipPickUpPosInfo tipPos = getTipPickUpPosInfo();
@ -358,7 +390,7 @@ public class HbotControlService implements HardwareCtrlModule {
// ObjectMapper mapper = new ObjectMapper(); // ObjectMapper mapper = new ObjectMapper();
testTakeTipFlag = true; testTakeTipFlag = true;
Map<String, String> result = new HashMap<>(); Map<String, String> result = new HashMap<>();
for (int i = startFrom; i < TipPickUpPosInfo.COL_MAX * TipPickUpPosInfo.ROW_MAX; i++) {
for (int i = startFrom; i < TipPickUpPosInfo.cgetTipNum(); i++) {
var ret = takeTipTestStep(groupId, i); var ret = takeTipTestStep(groupId, i);
result.put("Tip" + i, ret.getData() ? "suc" : "fail"); result.put("Tip" + i, ret.getData() ? "suc" : "fail");
logger.info("Take Tip {}-{} => {}", groupId, i, ret.getData()); logger.info("Take Tip {}-{} => {}", groupId, i, ret.getData());
@ -369,37 +401,13 @@ public class HbotControlService implements HardwareCtrlModule {
return AppRet.success(result); return AppRet.success(result);
} }
@HardwareServiceAction(name = "停止取全部Tip", group = "测试脚本") @HardwareServiceAction(name = "停止取全部Tip", group = "测试脚本")
public void testTakeAllTipStop() throws HardwareException, InterruptedException { public void testTakeAllTipStop() throws HardwareException, InterruptedException {
testTakeTipFlag = false; testTakeTipFlag = false;
} }
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 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 AppRet<String> scanSmallBottleBufferCode(Integer index) {
return null;
}
//扫描大缓冲液二维码
public String scanBigBottleBufferCode(Integer index) {
return "";
}
//在试管架的位置取样品 //在试管架的位置取样品
public boolean takeSampleFromPos0(Integer ul) { public boolean takeSampleFromPos0(Integer ul) {
return false; return false;

Loading…
Cancel
Save