Browse Source

update

tags/v0
zhaohe 1 year ago
parent
commit
4cd1ca3013
  1. 16
      src/main/java/a8k/a8k_can_protocol/ModuleId.java
  2. 53
      src/main/java/a8k/base_hardware/A8kCanBusService.java
  3. 101
      src/main/java/a8k/service/ctrl_service/DeviceInitializationCtrlService.java
  4. 12
      src/main/java/a8k/service/hardware/MotorTubeRackMoveCtrlService.java
  5. 4
      src/main/java/a8k/service/hardware/SamplesPreProcessModuleCtrlService.java

16
src/main/java/a8k/a8k_can_protocol/ModuleId.java

@ -22,7 +22,7 @@ public class ModuleId {
public static final int PlatesBoxTCMBoard = 40;//反应板夹温度控制板 public static final int PlatesBoxTCMBoard = 40;//反应板夹温度控制板
public static final int PlatesBoxTCM = 41;//反应板夹温度控制模块 public static final int PlatesBoxTCM = 41;//反应板夹温度控制模块
public static final int WbTubeFanModule = 42;//气溶胶风扇
public static final int WbTubeFanMod = 42;//气溶胶风扇
public static final int IncubatorTCMBoard = 50;//温度控制 public static final int IncubatorTCMBoard = 50;//温度控制
public static final int IncubatorTCM = 51;//温度控制 public static final int IncubatorTCM = 51;//温度控制
@ -31,18 +31,18 @@ public class ModuleId {
public static final int FeedingModInfeedM = 61;//入料电机 public static final int FeedingModInfeedM = 61;//入料电机
public static final int FeedingModXM = 62;//试管架平移电机 public static final int FeedingModXM = 62;//试管架平移电机
public static final int FeedingModOutfeedM = 63;//出料电机 public static final int FeedingModOutfeedM = 63;//出料电机
public static final int FeedingModScannerM = 64;//试管架扫码器
public static final int FeedingModScannerMod = 64;//试管架扫码器
public static final int IncubatorRotateBoard = 70;//孵育盘旋转板 public static final int IncubatorRotateBoard = 70;//孵育盘旋转板
public static final int IncubatorRotateCtrlM = 71;//孵育盘旋转 public static final int IncubatorRotateCtrlM = 71;//孵育盘旋转
public static final int PipetteModBoard = 80;//机械臂Z轴板 public static final int PipetteModBoard = 80;//机械臂Z轴板
public static final int PipetteModZMotor = 81;//机械臂Z
public static final int PipetteModZM = 81;//机械臂Z
public static final int PipetteMod = 82;//移液枪 public static final int PipetteMod = 82;//移液枪
public static final int PipetteModCodeScanner = 83;//物料扫码器 public static final int PipetteModCodeScanner = 83;//物料扫码器
public static final int OptModBoard = 90;//光学模组板 public static final int OptModBoard = 90;//光学模组板
public static final int OptModScannerMotor = 91;//板卡扫描电机
public static final int OptModScannerM = 91;//板卡扫描电机
public static final int OptModPullM = 92;//板卡推杆电机 public static final int OptModPullM = 92;//板卡推杆电机
public static final int OptMod = 93;//扫描仪 public static final int OptMod = 93;//扫描仪
@ -68,22 +68,22 @@ public class ModuleId {
case ShakeModTubeScanerRotateSV -> "ShakeModTubeScanerRotateSV"; case ShakeModTubeScanerRotateSV -> "ShakeModTubeScanerRotateSV";
case PlatesBoxTCMBoard -> "PlatesBoxTCMBoard"; case PlatesBoxTCMBoard -> "PlatesBoxTCMBoard";
case PlatesBoxTCM -> "PlatesBoxTCM"; case PlatesBoxTCM -> "PlatesBoxTCM";
case WbTubeFanModule -> "WbTubeFanModule";
case WbTubeFanMod -> "WbTubeFanMod";
case IncubatorTCMBoard -> "IncubatorTCMBoard"; case IncubatorTCMBoard -> "IncubatorTCMBoard";
case IncubatorTCM -> "IncubatorTCM"; case IncubatorTCM -> "IncubatorTCM";
case FeedingModBoard -> "FeedingModBoard"; case FeedingModBoard -> "FeedingModBoard";
case FeedingModInfeedM -> "FeedingModInfeedM"; case FeedingModInfeedM -> "FeedingModInfeedM";
case FeedingModXM -> "FeedingModXM"; case FeedingModXM -> "FeedingModXM";
case FeedingModOutfeedM -> "FeedingModOutfeedM"; case FeedingModOutfeedM -> "FeedingModOutfeedM";
case FeedingModScannerM -> "FeedingModScannerM";
case FeedingModScannerMod -> "FeedingModScannerMod";
case IncubatorRotateBoard -> "IncubatorRotateBoard"; case IncubatorRotateBoard -> "IncubatorRotateBoard";
case IncubatorRotateCtrlM -> "IncubatorRotateCtrlM"; case IncubatorRotateCtrlM -> "IncubatorRotateCtrlM";
case PipetteModBoard -> "PipetteModBoard"; case PipetteModBoard -> "PipetteModBoard";
case PipetteModZMotor -> "PipetteModZMotor";
case PipetteModZM -> "PipetteModZM";
case PipetteMod -> "PipetteMod"; case PipetteMod -> "PipetteMod";
case PipetteModCodeScanner -> "PipetteModCodeScanner"; case PipetteModCodeScanner -> "PipetteModCodeScanner";
case OptModBoard -> "OptModBoard"; case OptModBoard -> "OptModBoard";
case OptModScannerMotor -> "OptModScannerMotor";
case OptModScannerM -> "OptModScannerM";
case OptModPullM -> "OptModPullM"; case OptModPullM -> "OptModPullM";
case OptMod -> "OptMod"; case OptMod -> "OptMod";
case A8kIdCardReaderBoard -> "A8kIdCardReaderBoard"; case A8kIdCardReaderBoard -> "A8kIdCardReaderBoard";

53
src/main/java/a8k/base_hardware/A8kCanBusService.java

@ -111,8 +111,7 @@ public class A8kCanBusService {
client.connect(); client.connect();
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
} }
} else if (client.getReadyState().equals(ReadyState.CLOSING)
|| client.getReadyState().equals(ReadyState.CLOSED)) {
} else if (client.getReadyState().equals(ReadyState.CLOSING) || client.getReadyState().equals(ReadyState.CLOSED)) {
client.reconnect(); client.reconnect();
} }
} }
@ -296,6 +295,28 @@ public class A8kCanBusService {
} }
} }
public void waitForMod(Integer moduleId, Integer acitionOvertime) throws InterruptedException, HardwareException {
long startedAt = System.currentTimeMillis();
do {
try {
var status = getModuleStatus(moduleId);
if (status == ModuleStatus.IDLE) {
break;
} else if (status == ModuleStatus.ERROR) {
throw new HardwareException(moduleId, moduleGetError(moduleId));
}
} catch (HardwareException ignored) {
}
long now = System.currentTimeMillis();
if (now - startedAt > acitionOvertime) {
throw new HardwareException(moduleId, Errorcode.kovertime);
}
Thread.sleep(100);
} while (true);
}
public A8kPacket callcmd(Integer moduleId, Integer cmdId) throws HardwareException { public A8kPacket callcmd(Integer moduleId, Integer cmdId) throws HardwareException {
return this.callcmd(moduleId, cmdId, new Integer[]{}); return this.callcmd(moduleId, cmdId, new Integer[]{});
} }
@ -308,38 +329,32 @@ public class A8kCanBusService {
return this.callcmd(moduleId, cmdId, new Integer[]{p0, p1}); return this.callcmd(moduleId, cmdId, new Integer[]{p0, p1});
} }
public A8kPacket callcmd(Integer moduleId, Integer cmdId, Integer p0, Integer p1, Integer p2)
throws HardwareException {
public A8kPacket callcmd(Integer moduleId, Integer cmdId, Integer p0, Integer p1, Integer p2) throws HardwareException {
return this.callcmd(moduleId, cmdId, new Integer[]{p0, p1, p2}); return this.callcmd(moduleId, cmdId, new Integer[]{p0, p1, p2});
} }
public A8kPacket callcmd(Integer moduleId, Integer cmdId, Integer p0, Integer p1, Integer p2, Integer p3)
throws HardwareException {
public A8kPacket callcmd(Integer moduleId, Integer cmdId, Integer p0, Integer p1, Integer p2, Integer p3) throws HardwareException {
return this.callcmd(moduleId, cmdId, new Integer[]{p0, p1, p2, p3}); return this.callcmd(moduleId, cmdId, new Integer[]{p0, p1, p2, p3});
} }
public void callblockcmd(Integer moduleId, Integer cmdId, Integer p0, Integer p1, Integer p2, Integer p3,
Integer acitionOvertime) throws HardwareException, InterruptedException {
public void callblockcmd(Integer moduleId, Integer cmdId, Integer p0, Integer p1, Integer p2, Integer p3, Integer acitionOvertime) throws HardwareException, InterruptedException {
this.callblockcmd(moduleId, cmdId, new Integer[]{p0, p1, p2, p3}, acitionOvertime); this.callblockcmd(moduleId, cmdId, new Integer[]{p0, p1, p2, p3}, acitionOvertime);
} }
public void callblockcmd(Integer moduleId, Integer cmdId, Integer p0, Integer p1, Integer p2,
Integer acitionOvertime) throws HardwareException, InterruptedException {
public void callblockcmd(Integer moduleId, Integer cmdId, Integer p0, Integer p1, Integer p2, Integer acitionOvertime) throws HardwareException, InterruptedException {
this.callblockcmd(moduleId, cmdId, new Integer[]{p0, p1, p2}, acitionOvertime); this.callblockcmd(moduleId, cmdId, new Integer[]{p0, p1, p2}, acitionOvertime);
} }
public void callblockcmd(Integer moduleId, Integer cmdId, Integer p0, Integer p1, Integer acitionOvertime)
throws HardwareException, InterruptedException {
public void callblockcmd(Integer moduleId, Integer cmdId, Integer p0, Integer p1, Integer acitionOvertime) throws HardwareException, InterruptedException {
this.callblockcmd(moduleId, cmdId, new Integer[]{p0, p1}, acitionOvertime); this.callblockcmd(moduleId, cmdId, new Integer[]{p0, p1}, acitionOvertime);
} }
public void callblockcmd(Integer moduleId, Integer cmdId, Integer p0, Integer acitionOvertime)
throws HardwareException, InterruptedException {
public void callblockcmd(Integer moduleId, Integer cmdId, Integer p0, Integer acitionOvertime) throws HardwareException, InterruptedException {
this.callblockcmd(moduleId, cmdId, new Integer[]{p0}, acitionOvertime); this.callblockcmd(moduleId, cmdId, new Integer[]{p0}, acitionOvertime);
} }
public void callblockcmd(Integer moduleId, Integer cmdId, Integer acitionOvertime)
throws HardwareException, InterruptedException {
public void callblockcmd(Integer moduleId, Integer cmdId, Integer acitionOvertime) throws HardwareException, InterruptedException {
this.callblockcmd(moduleId, cmdId, new Integer[]{}, acitionOvertime); this.callblockcmd(moduleId, cmdId, new Integer[]{}, acitionOvertime);
} }
@ -374,8 +389,7 @@ public class A8kCanBusService {
return null; return null;
} }
public void callblockcmd(Integer moduleId, Integer cmdId, Integer[] params, int acitionOvertime)
throws HardwareException, InterruptedException {
public void callblockcmd(Integer moduleId, Integer cmdId, Integer[] params, int acitionOvertime) throws HardwareException, InterruptedException {
var packet = this.packParamsToPacket(moduleId, cmdId, params); var packet = this.packParamsToPacket(moduleId, cmdId, params);
this.sendCmdAutoResend(packet, A8kPacket.CMD_OVERTIME); this.sendCmdAutoResend(packet, A8kPacket.CMD_OVERTIME);
@ -458,8 +472,7 @@ public class A8kCanBusService {
logger.info("RX {}:({})", packet, rx); logger.info("RX {}:({})", packet, rx);
} }
if (packet.getPacketType() == A8kPacket.PACKET_TYPE_ACK
|| packet.getPacketType() == A8kPacket.PACKET_TYPE_ERROR_ACK) {
if (packet.getPacketType() == A8kPacket.PACKET_TYPE_ACK || packet.getPacketType() == A8kPacket.PACKET_TYPE_ERROR_ACK) {
if (isWaitingReceipt) { if (isWaitingReceipt) {
if (waitingReceiptIndex == packet.getPacketIndex()) { if (waitingReceiptIndex == packet.getPacketIndex()) {
receiptQueue.add(packet); receiptQueue.add(packet);

101
src/main/java/a8k/service/ctrl_service/DeviceInitializationCtrlService.java

@ -48,9 +48,11 @@ public class DeviceInitializationCtrlService {
* 7. 试管架平移电机复位 * 7. 试管架平移电机复位
* 8. 板夹仓平移电机复位 * 8. 板夹仓平移电机复位
* 9. 板夹仓推杆电机复位 * 9. 板夹仓推杆电机复位
* 10.
* *
*/ */
final Integer actionOvertime = 5000;
@Resource @Resource
A8kCanBusService canBus; A8kCanBusService canBus;
@ -58,49 +60,78 @@ public class DeviceInitializationCtrlService {
SamplesPreProcessModuleCtrlParamsService samplesPreProcessModuleCtrlParams; SamplesPreProcessModuleCtrlParamsService samplesPreProcessModuleCtrlParams;
private void hardwareStaticInit() {
/*
* 复位思路
* 硬件初始化:
* 1.使能所有舵机
* 2.打开必要的电源
* 3.使能所有电机
*/
// public static final int HbotM = 11;//机械臂XY
// public static final int PlatesBoxYM = 21;//板夹仓移动电机
// public static final int PlatesBoxPusherM = 22;//板夹仓推杆电机
// public static final int ShakeModClampingM = 31;//试管固定夹爪电机
// public static final int ShakeModGripperZM = 32;//摇匀升降电机
// public static final int ShakeModShakeM = 33;//试管摇匀电机
// public static final int ShakeModGripperYM = 34;//摇匀前后电机
// public static final int FeedingModInfeedM = 61;//入料电机
// public static final int FeedingModXM = 62;//试管架平移电机
// public static final int FeedingModOutfeedM = 63;//出料电机
// public static final int FeedingModScannerM = 64;//试管架扫码器
// public static final int IncubatorRotateCtrlM = 71;//孵育盘旋转
// public static final int PipetteModZMotor = 81;//机械臂Z
// public static final int OptModScannerMotor = 91;//板卡扫描电机
// public static final int OptModPullM = 92;//板卡推杆电机
//
// public static final int ShakeModGripperSV = 35;//摇匀试管帽夹爪
// public static final int ShakeModTubeScanerClampingSV = 36;//试管架旋转固定舵机
// public static final int ShakeModTubeScanerRotateSV = 37;//试管架旋转舵机
}
public AppErrorCode initializeDevice() { public AppErrorCode initializeDevice() {
logger.info("Initializing device ..."); logger.info("Initializing device ...");
try { try {
// canBus.getIOState(IOId.THChDetecterOuter,);
/*
* 复位思路
* 硬件初始化:
* 1.使能所有舵机
* 2.打开必要的电源
* 3.使能所有电机
*
* 检查
* 1.试管平移通道是否有障碍
* 2.板夹仓盖子是否盖上
* 3.推杆卡板光电是否触发
* 4.拉杆卡板光电是否触发
* 5.回收站光电是否被触发
*
*
* 复位
* 1.
*
*
* 清空设备
*
*
*
*/
canBus.stepMotorEasyMoveToZero(ModuleId.ShakeModGripperZM); canBus.stepMotorEasyMoveToZero(ModuleId.ShakeModGripperZM);
canBus.waitForMod(ModuleId.ShakeModGripperZM, actionOvertime);
} catch (HardwareException e) { } catch (HardwareException e) {
logger.error("HardwareException");
throw new RuntimeException(e);
} catch (InterruptedException e) {
logger.error("InterruptedException");
throw new RuntimeException(e); throw new RuntimeException(e);
} }
// this.a8kCanBusService.callblockcmd(
// ModuleId.ServoTubeCapClipModule,
// CmdId.kmini_servo_move_to,
// params.getGripperServo_standbyPos(),
// params.getActionOvertime()
// );
//
// this.a8kCanBusService.callblockcmd(
// ModuleId.MotorTubeMoveUpDownModule,
// CmdId.kstep_motor_easy_move_to_zero,
// params.getMoveToZeroOvertime()
// );
//
// this.a8kCanBusService.callblockcmd(
// ModuleId.ServoTubeMoveFrontBackModule,
// CmdId.kmini_servo_move_to,
// params.getHorizontalMotor_standbyPos(),
// params.getActionOvertime()
// );
//
// this.a8kCanBusService.callblockcmd(
// ModuleId.MotorTubeShakeModule,
// CmdId.kstep_motor_easy_move_to_zero,
// params.getMoveToZeroOvertime()
// );
//
// this.a8kCanBusService.callblockcmd(
// ModuleId.MotorTubeScanClampModule,
// CmdId.kstep_motor_easy_move_to_zero,
// params.getMoveToZeroOvertime()
// );
//
return AppErrorCode.Success; return AppErrorCode.Success;
} }

12
src/main/java/a8k/service/hardware/MotorTubeRackMoveCtrlService.java

@ -116,10 +116,10 @@ public class MotorTubeRackMoveCtrlService {
*/ */
public String moveTubeRackToScanPosAndScan() throws HardwareException, InterruptedException { public String moveTubeRackToScanPosAndScan() throws HardwareException, InterruptedException {
this.moveTubeRackToScanPos(); this.moveTubeRackToScanPos();
this.a8kCanBusService.callcmd(ModuleId.FeedingModScannerM, CmdId.kcode_scaner_start_scan, new Integer[]{});
this.a8kCanBusService.callcmd(ModuleId.FeedingModScannerMod, CmdId.kcode_scaner_start_scan, new Integer[]{});
Thread.sleep(500); Thread.sleep(500);
var response = this.a8kCanBusService.callcmd(ModuleId.FeedingModScannerM, CmdId.kcode_scaner_read_scaner_result, new Integer[]{});
this.a8kCanBusService.callcmd(ModuleId.FeedingModScannerM, CmdId.kcode_scaner_stop_scan, new Integer[]{});
var response = this.a8kCanBusService.callcmd(ModuleId.FeedingModScannerMod, CmdId.kcode_scaner_read_scaner_result, new Integer[]{});
this.a8kCanBusService.callcmd(ModuleId.FeedingModScannerMod, CmdId.kcode_scaner_stop_scan, new Integer[]{});
var contentBytes = response.getCmdContent(); var contentBytes = response.getCmdContent();
return new String(contentBytes); return new String(contentBytes);
} }
@ -149,10 +149,10 @@ public class MotorTubeRackMoveCtrlService {
public String moveTubeToScanPosAndScan(String tubeType, Integer tubeIndex) throws HardwareException, InterruptedException { public String moveTubeToScanPosAndScan(String tubeType, Integer tubeIndex) throws HardwareException, InterruptedException {
this.moveTubeToScanPos(tubeType, tubeIndex); this.moveTubeToScanPos(tubeType, tubeIndex);
this.a8kCanBusService.callcmd(ModuleId.FeedingModScannerM, CmdId.kcode_scaner_start_scan, new Integer[]{});
this.a8kCanBusService.callcmd(ModuleId.FeedingModScannerMod, CmdId.kcode_scaner_start_scan, new Integer[]{});
Thread.sleep(500); Thread.sleep(500);
var response = this.a8kCanBusService.callcmd(ModuleId.FeedingModScannerM, CmdId.kcode_scaner_read_scaner_result, new Integer[]{});
this.a8kCanBusService.callcmd(ModuleId.FeedingModScannerM, CmdId.kcode_scaner_stop_scan, new Integer[]{});
var response = this.a8kCanBusService.callcmd(ModuleId.FeedingModScannerMod, CmdId.kcode_scaner_read_scaner_result, new Integer[]{});
this.a8kCanBusService.callcmd(ModuleId.FeedingModScannerMod, CmdId.kcode_scaner_stop_scan, new Integer[]{});
var contentBytes = response.getCmdContent(); var contentBytes = response.getCmdContent();
return new String(contentBytes); return new String(contentBytes);
} }

4
src/main/java/a8k/service/hardware/SamplesPreProcessModuleCtrlService.java

@ -358,14 +358,14 @@ public class SamplesPreProcessModuleCtrlService {
*/ */
public void openAerosolFan() throws HardwareException { public void openAerosolFan() throws HardwareException {
var params = this.samplesPreProcessModuleCtrlParamsService; var params = this.samplesPreProcessModuleCtrlParamsService;
this.a8kCanBusService.callcmd(ModuleId.WbTubeFanModule, CmdId.kfan_controler_set_speed, params.getAerosolFanLevel());
this.a8kCanBusService.callcmd(ModuleId.WbTubeFanMod, CmdId.kfan_controler_set_speed, params.getAerosolFanLevel());
} }
/** /**
* 关闭气溶胶风扇 * 关闭气溶胶风扇
*/ */
public void closeAerosolFan() throws HardwareException { public void closeAerosolFan() throws HardwareException {
this.a8kCanBusService.callcmd(ModuleId.WbTubeFanModule, CmdId.kfan_controler_set_speed, 0);
this.a8kCanBusService.callcmd(ModuleId.WbTubeFanMod, CmdId.kfan_controler_set_speed, 0);
} }
/** /**

Loading…
Cancel
Save