Browse Source

update

tags/v0
zhaohe 1 year ago
parent
commit
ce4c074818
  1. 4
      src/main/java/a8k/appbean/cfg/Pos2d.java
  2. 36
      src/main/java/a8k/appbean/cfg/TipPickUpPosInfo.java
  3. 122
      src/main/java/a8k/canbus/A8kCanBusService.java
  4. 16
      src/main/java/a8k/canbus/A8kModParamInitializer.java
  5. 7
      src/main/java/a8k/canbus/data/PipetteSampleData.java
  6. 33
      src/main/java/a8k/canbus/protocol/A8kPacket.java
  7. 26
      src/main/java/a8k/canbus/protocol/CmdId.java
  8. 202
      src/main/java/a8k/service/hardware/HbotControlService.java

4
src/main/java/a8k/appbean/cfg/Pos2d.java

@ -15,4 +15,8 @@ public class Pos2d {
this.y = 0;
}
public String toString() {
return String.format("(%d, %d)", x, y);
}
}

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

@ -6,21 +6,24 @@ public class TipPickUpPosInfo {
public Pos2d g1tl;
public Pos2d g2tl;
public Integer xSpacing; //x间隔
public Integer ySpacing; //y间隔
public Double xSpacing; //x间隔
public Double ySpacing; //y间隔
public Integer pickUpZPos; //拾取高度
final public static Integer ROW_MAX = 10;
final public static Integer COL_MAX = 12;
public TipPickUpPosInfo() {
g0tl = new Pos2d(0, 0);
g1tl = new Pos2d(0, 0);
g2tl = new Pos2d(0, 0);
xSpacing = 0;
ySpacing = 0;
xSpacing = 0.0;
ySpacing = 0.0;
pickUpZPos = 0;
}
public TipPickUpPosInfo(Pos2d g0tl, Pos2d g1tl, Pos2d g2tl, Integer xSpacing, Integer ySpacing, Integer pickUpZPos) {
public TipPickUpPosInfo(Pos2d g0tl, Pos2d g1tl, Pos2d g2tl, Double xSpacing, Double ySpacing, Integer pickUpZPos) {
this.g0tl = g0tl;
this.g1tl = g1tl;
this.g2tl = g2tl;
@ -28,4 +31,27 @@ public class TipPickUpPosInfo {
this.ySpacing = ySpacing;
this.pickUpZPos = pickUpZPos;
}
Pos2d getTopLeft(Integer group) {
if (group == 0) {
return g0tl;
} else if (group == 1) {
return g1tl;
} else if (group == 2) {
return g2tl;
} else {
return new Pos2d(0, 0);
}
}
public Pos2d getTipPos(Integer group, Integer index) {
int row; //
int col; //
row = index / COL_MAX;
col = index % COL_MAX;
Pos2d topleft = getTopLeft(group);
return new Pos2d((int) (topleft.x + col * xSpacing), (int) (topleft.y + row * ySpacing));
}
}

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

@ -4,6 +4,7 @@ import a8k.app_eventbus.appevent.A8kCanBusOnConnectEvent;
import a8k.appbean.OptScanDirection;
import a8k.appbean.PlateInfo;
import a8k.canbus.custom_param_mgr.A8kModCustomParamMgr;
import a8k.canbus.data.PipetteSampleData;
import a8k.canbus.protocol.*;
import a8k.canbus.protocol.MId;
import a8k.appbean.HardwareException;
@ -62,6 +63,7 @@ public class A8kCanBusService {
public String uri; // assign by application.yml
private WebSocketClient client;
private A8kPacket txPacketContext;
// 接收回执上下文
public BlockingQueue<A8kPacket> receiptQueue = new LinkedBlockingQueue<A8kPacket>(); //
@ -154,6 +156,108 @@ public class A8kCanBusService {
return new A8kPacket(buffer.array());
}
private void setTxPacketContext(A8kPacket packet) {
txPacketContext = packet;
}
synchronized private A8kPacket getTxPacketContext() {
return txPacketContext;
}
// virtual int32_t pipette_ctrl_move_to_ul(int32_t ul) override; // 丢弃
//
// virtual int32_t pipette_ctrl_init_device() override;
// virtual int32_t pipette_ctrl_put_tip() override;
// virtual int32_t pipette_lld_prepare() override;
// virtual int32_t pipette_plld(int32_t zdpos, int32_t p_threshold) override;
// virtual int32_t pipette_clld(int32_t zdpos, int32_t c_threshold) override;
// virtual int32_t pipette_mlld(int32_t zdpos, int32_t c_threshold, int32_t p_threshold) override;
// virtual int32_t pipette_lld_is_detect_liquid(int32_t *liquid) override;
//
// virtual int32_t pipette_aspirate(int32_t ul) override;
// virtual int32_t pipette_distribut(int32_t ul) override;
// virtual int32_t pipette_shake_up(int32_t ul, int32_t times) override;
//
// virtual int32_t pipette_aspirate_llf(int32_t ul, int32_t zmotor_v) override;
// virtual int32_t pipette_distribut_llf(int32_t ul, int32_t zmotor_v) override;
// virtual int32_t pipette_shake_up_llf(int32_t ul, int32_t zmotor_v, int32_t times) override;
//
// virtual int32_t pipette_enable_zmotor(int32_t enable);
// virtual int32_t pipette_write_cmd_direct(uint8_t *tx, int32_t len, uint8_t *rx, int32_t *rxlen) override;
// virtual int32_t pipette_get_sensor_sample_data(int32_t index, int32_t *motor_pos, int32_t *cval, int32_t *pval) override; //
// virtual int32_t pipette_get_sensor_sample_data_num(int32_t *num) override;
//
public void pipetteCtrlInitDevice(MId id) throws HardwareException {
callcmd(id.toInt(), CmdId.pipette_ctrl_init_device.toInt());
}
public void pipetteCtrlPutTip(MId id) throws HardwareException {
callcmd(id.toInt(), CmdId.pipette_ctrl_put_tip.toInt());
}
public void pipetteCtrlPrepare(MId id) throws HardwareException {
callcmd(id.toInt(), CmdId.pipette_lld_prepare.toInt());
}
public void pipetteCtrlPlld(MId id, int zdpos, int p_threshold) throws HardwareException {
callcmd(id.toInt(), CmdId.pipette_plld.toInt(), zdpos, p_threshold);
}
public void pipetteCtrlClld(MId id, int zdpos, int c_threshold) throws HardwareException {
callcmd(id.toInt(), CmdId.pipette_clld.toInt(), zdpos, c_threshold);
}
public void pipetteCtrlMlld(MId id, int zdpos, int c_threshold, int p_threshold) throws HardwareException {
callcmd(id.toInt(), CmdId.pipette_mlld.toInt(), zdpos, c_threshold, p_threshold);
}
public Integer pipetteCtrlLldIsDetectLiquid(MId id) throws HardwareException {
var packet = callcmd(id.toInt(), CmdId.pipette_lld_is_detect_liquid.toInt());
return packet.getContentI32(0);
}
public void pipetteAspirate(MId id, int ul) throws HardwareException {
callcmd(id.toInt(), CmdId.pipette_aspirate.toInt(), ul);
}
public void pipetteDistribut(MId id, int ul) throws HardwareException {
callcmd(id.toInt(), CmdId.pipette_distribut.toInt(), ul);
}
public void pipetteShakeUp(MId id, int ul, int times) throws HardwareException {
callcmd(id.toInt(), CmdId.pipette_shake_up.toInt(), ul, times);
}
public void pipetteAspirateLlf(MId id, int ul, int zmotor_v) throws HardwareException {
callcmd(id.toInt(), CmdId.pipette_aspirate_llf.toInt(), ul, zmotor_v);
}
public void pipetteDistributLlf(MId id, int ul, int zmotor_v) throws HardwareException {
callcmd(id.toInt(), CmdId.pipette_distribut_llf.toInt(), ul, zmotor_v);
}
public void pipetteShakeUpLlf(MId id, int ul, int zmotor_v, int times) throws HardwareException {
callcmd(id.toInt(), CmdId.pipette_shake_up_llf.toInt(), ul, zmotor_v, times);
}
public void pipetteEnableZmotor(MId id, int enable) throws HardwareException {
callcmd(id.toInt(), CmdId.pipette_enable_zmotor.toInt(), enable);
}
public PipetteSampleData pipetteGetSensorSampleData(MId id, int index) throws HardwareException {
var packet = callcmd(id.toInt(), CmdId.pipette_get_sensor_sample_data.toInt(), index);
if (packet.getCmdContent().length == 0) {
return null;
}
PipetteSampleData sampleData = new PipetteSampleData();
sampleData.motorPos = packet.getContentI32(0);
sampleData.cval = packet.getContentI32(1);
sampleData.pval = packet.getContentI32(2);
return sampleData;
}
public void optTStartScan(MId id, OptScanDirection scanDirection, Integer lasterGain, Integer scanGain) throws HardwareException, InterruptedException {
callcmd(id.toInt(), CmdId.a8k_opt_v2_t_start_scan.toInt(), scanDirection.getInteger(), lasterGain, scanGain);
}
@ -687,7 +791,7 @@ public class A8kCanBusService {
lastCmdMapPut(MId.valueOf(pack.getModuleId()), CmdId.valueOf(pack.getCmdId()));
}
txPacketContext = pack;
client.send(txpacket);
A8kPacket receipt;
try {
@ -728,17 +832,25 @@ public class A8kCanBusService {
A8kPacket packet = new A8kPacket(rx);
if (!packet.isSupportPacket()) {
logger.warn("Rx packet not support: {}", packet);
return;
}
if (debugFlag && packet.isTrace()) {
logger.info("RX |RAW:{}| {}", s, packet);
A8kPacket tpCxt = this.txPacketContext;
if (debugFlag) {
if (packet.getPacketType() == A8kPacket.PACKET_TYPE_ACK) {
if (tpCxt != null && tpCxt.getPacketIndex() == packet.getPacketIndex()) {
if (tpCxt.isTrace()) {
logger.info("RX-ACK |RAW:{}| {}", s, packet);
}
}
} else {
logger.info("RX |RAW:{}| {}", s, packet);
}
}
if (packet.getPacketType() == A8kPacket.PACKET_TYPE_ACK || packet.getPacketType() == A8kPacket.PACKET_TYPE_ERROR_ACK) {
if (isWaitingReceipt) {
if (waitingReceiptIndex == packet.getPacketIndex()) {

16
src/main/java/a8k/canbus/A8kModParamInitializer.java

@ -83,7 +83,23 @@ public class A8kModParamInitializer implements AppEventListener {
canBus.moduleSetReg(MId.HbotM, RegIndex.kreg_xyrobot_pos_devi_tolerance, 5);
canBus.moduleSetReg(MId.HbotM, RegIndex.kreg_xyrobot_io_trigger_append_distance, 10);
canBus.moduleSetReg(MId.HbotM, RegIndex.kreg_xyrobot_min_x, -100);
canBus.moduleSetReg(MId.HbotM, RegIndex.kreg_xyrobot_min_y, -100);
canBus.moduleSetReg(MId.HbotM, RegIndex.kreg_xyrobot_min_x, -100);
canBus.moduleSetReg(MId.HbotM, RegIndex.kreg_xyrobot_min_y, -100);
canBus.moduleSetReg(MId.HbotM, RegIndex.kreg_xyrobot_vstart, 1);
canBus.moduleSetReg(MId.HbotM, RegIndex.kreg_xyrobot_a1, 5);
canBus.moduleSetReg(MId.HbotM, RegIndex.kreg_xyrobot_amax, 10);
canBus.moduleSetReg(MId.HbotM, RegIndex.kreg_xyrobot_v1, 300);
canBus.moduleSetReg(MId.HbotM, RegIndex.kreg_xyrobot_dmax, 10);
canBus.moduleSetReg(MId.HbotM, RegIndex.kreg_xyrobot_d1, 5);
canBus.moduleSetReg(MId.HbotM, RegIndex.kreg_xyrobot_vstop, 1);
canBus.moduleSetReg(MId.HbotM, RegIndex.kreg_xyrobot_tzerowait, 300);
canBus.moduleSetReg(MId.HbotM, RegIndex.kreg_xyrobot_one_circle_pulse, 7215);
// canBus.moduleSetReg(MId.OptModPullM, RegIndex.kreg_step_motor_run_to_zero_speed, 500);
}

7
src/main/java/a8k/canbus/data/PipetteSampleData.java

@ -0,0 +1,7 @@
package a8k.canbus.data;
public class PipetteSampleData {
public Integer motorPos;
public Integer cval;
public Integer pval;
}

33
src/main/java/a8k/canbus/protocol/A8kPacket.java

@ -22,7 +22,6 @@ public class A8kPacket {
*/
public static final Logger logger = LoggerFactory.getLogger(A8kPacket.class);
byte[] raw;
public static final int PACKET_MIN_LEN = 8;
@ -82,12 +81,25 @@ public class A8kPacket {
public String toString() {
int packetType = getPacketType(); String ret = "";
CmdId cmdId = CmdId.valueOf(getCmdId()); assert cmdId != null; if (packetType == PACKET_TYPE_CMD) {
if (cmdId.cmdAttachType == CmdId.ATTACH_IS_INT32) {
ret = String.format("[CMD ] index:[%d] (%s %s(%d) :param:[%s])", getPacketIndex(), cmdId, MId.valueOf(getModuleId()), getModuleId(), formatInt32ATTACH(getCmdContent()));
CmdId cmdId = CmdId.valueOf(getCmdId());
assert cmdId != null;
if (packetType == PACKET_TYPE_CMD) {
if (cmdId.equals(CmdId.module_get_reg) || cmdId.equals(CmdId.module_set_reg)) {
RegIndex regIndex = RegIndex.valueOf(getContentI32(0));
if (regIndex != null) {
ret = String.format("[CMD ] index:[%d] %s %s(%d) %d", getPacketIndex(), cmdId, regIndex, regIndex.index, getContentI32(1));
} else {
ret = String.format("[CMD ] index:[%d] %s unkown_index(%d) %d", getPacketIndex(), cmdId, getContentI32(0), getContentI32(1));
}
} else {
ret = String.format("[CMD ] index:[%d] (%s %s(%d) :param:[%s])", getPacketIndex(), cmdId, MId.valueOf(getModuleId()), getModuleId(), ByteArray.toByteString(getCmdContent()));
if (cmdId.cmdAttachType == CmdId.ATTACH_IS_INT32) {
ret = String.format("[CMD ] index:[%d] (%s %s(%d) :param:[%s])", getPacketIndex(), cmdId, MId.valueOf(getModuleId()), getModuleId(), formatInt32ATTACH(getCmdContent()));
} else {
ret = String.format("[CMD ] index:[%d] (%s %s(%d) :param:[%s])", getPacketIndex(), cmdId, MId.valueOf(getModuleId()), getModuleId(), ByteArray.toByteString(getCmdContent()));
}
}
} else if (packetType == PACKET_TYPE_ACK) {
if (cmdId.receiptAttachType == CmdId.ATTACH_IS_INT32) {
ret = String.format("[ACK ] index:[%d] (%s :[%s])", getPacketIndex(), cmdId, formatInt32ATTACH(getCmdContent()));
@ -132,21 +144,16 @@ public class A8kPacket {
if (!isSupportPacket()) {
return false;
}
CmdId cmdid = CmdId.valueOf(getCmdId());
assert cmdid != null;
if (!cmdid.notTrace) {
return true;
}
if (CmdId.module_get_reg.equals(cmdid) || CmdId.module_set_reg.equals(cmdid)) {
RegIndex regIndex = RegIndex.valueOf(getContentI32(0));
assert regIndex != null;
if (!regIndex.trace) {
return false;
}
return regIndex.trace;
} else {
return cmdid.trace;
}
return false;
}
}

26
src/main/java/a8k/canbus/protocol/CmdId.java

@ -9,11 +9,11 @@ public enum CmdId {
event_bus_reg_change_report(0x0064, "event_bus_reg_change_report"),//
//
module_ping(0x0100, "module_ping"),//
module_get_status(0x0104, "module_get_status", true),//
module_get_status(0x0104, "module_get_status", false),//
module_stop(0x0101, "module_stop"),//
module_set_reg(0x0105, "module_set_reg"),//
module_get_reg(0x0106, "module_get_reg"),//
module_get_error(0x010a, "module_get_error", true),//
module_get_error(0x010a, "module_get_error", false),//
module_clear_error(0x010b, "module_clear_error"),//
module_active_cfg(0x0110, "module_active_cfg"),//
//
@ -21,9 +21,9 @@ public enum CmdId {
xymotor_move_by(0x0302, "xymotor_move_by"),//
xymotor_move_to(0x0303, "xymotor_move_to"),//
xymotor_move_to_zero(0x0304, "xymotor_move_to_zero"),//
xymotor_read_pos(0x0306, "xymotor_read_pos"),//
xymotor_read_pos(0x0306, "xymotor_read_pos",false),//
xymotor_read_inio_index_in_stm32(0x0307, "xymotor_read_inio_index_in_stm32"),//
xymotor_read_inio(0x0308, "xymotor_read_inio", true),//
xymotor_read_inio(0x0308, "xymotor_read_inio", false),//
xymotor_set_pos(0x0309, "xymotor_set_pos"),//
xymotor_motor_move_by_direct(0x030a, "xymotor_motor_move_by_direct"),//
xymotor_read_enc_direct(0x030b, "xymotor_read_enc_direct"),//
@ -69,7 +69,7 @@ public enum CmdId {
step_motor_easy_move_to_io(0x0216, "step_motor_easy_move_to_io"),//
step_motor_stop(0x0228, "step_motor_stop"),//
step_motor_active_cfg(0x0229, "step_motor_active_cfg"),//
step_motor_read_io_state(0x022a, "step_motor_read_io_state", true),//
step_motor_read_io_state(0x022a, "step_motor_read_io_state", false),//
step_motor_easy_move_to_end_point(0x022c, "step_motor_easy_move_to_end_point"),//
step_motor_read_tmc5130_status(0x0232, "step_motor_read_tmc5130_status"),//
step_motor_read_tmc5130_state(0x0233, "step_motor_read_tmc5130_state"),//
@ -90,9 +90,9 @@ public enum CmdId {
mini_servo_rotate_with_torque(0x660b, "mini_servo_rotate_with_torque"),//
mini_servo_set_cur_pos(0x660c, "mini_servo_set_cur_pos"),//
//
extboard_read_inio(0x6701, "extboard_read_inio", true),//
extboard_read_inio(0x6701, "extboard_read_inio", false),//
extboard_write_outio(0x6702, "extboard_write_outio"),//
extboard_read_muti_inio(0x6703, "extboard_read_muti_inio", true),//
extboard_read_muti_inio(0x6703, "extboard_read_muti_inio", false),//
extboard_read_inio_index_in_stm32(0x6704, "extboard_read_inio_index_in_stm32"),//
extboard_read_outio_index_in_stm32(0x6705, "extboard_read_outio_index_in_stm32"),//
extboard_read_outio(0x6706, "extboard_read_outio"),//
@ -136,7 +136,7 @@ public enum CmdId {
public String chName;
public int cmdAttachType = ATTACH_IS_INT32;
public int receiptAttachType = ATTACH_IS_INT32;
public boolean notTrace = false;
public boolean trace = true;
public boolean actionCmd = true;
CmdId(int index, String chname) {
@ -144,11 +144,11 @@ public enum CmdId {
this.chName = chname;
}
CmdId(int index, String chname, boolean notTrace) {
CmdId(int index, String chname, boolean trace) {
this.index = index;
this.chName = chname;
this.notTrace = notTrace;
this.actionCmd = !notTrace;
this.trace = trace;
this.actionCmd = trace;
}
CmdId(int index, String chname, int cmdAttachType, int receiptAttachType) {
@ -158,12 +158,12 @@ public enum CmdId {
this.receiptAttachType = receiptAttachType;
}
CmdId(int index, String chname, int cmdAttachType, int receiptAttachType, boolean notTrace) {
CmdId(int index, String chname, int cmdAttachType, int receiptAttachType, boolean trace) {
this.index = index;
this.chName = chname;
this.cmdAttachType = cmdAttachType;
this.receiptAttachType = receiptAttachType;
this.notTrace = notTrace;
this.trace = trace;
}

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

@ -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();
}
}
Loading…
Cancel
Save