Browse Source

update

tags/v0
zhaohe 1 year ago
parent
commit
425cb66142
  1. 24
      src/main/java/a8k/base_hardware/A8kCanBusService.java
  2. 108
      src/main/java/a8k/service/ctrl_service/DeviceInitializationCtrlService.java
  3. 35
      src/main/java/a8k/service/hardware/CommonHardwareOpeartion.java

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

@ -139,6 +139,10 @@ public class A8kCanBusService {
return new A8kPacket(buffer.array()); return new A8kPacket(buffer.array());
} }
// //
// module opeation // module opeation
// //
@ -178,6 +182,26 @@ public class A8kCanBusService {
callcmd(id.toInt(), CmdId.kmodule_active_cfg); callcmd(id.toInt(), CmdId.kmodule_active_cfg);
} }
// public static final int kxymotor_enable = 0x0301;
// public static final int kxymotor_move_by = 0x0302;
// public static final int kxymotor_move_to = 0x0303;
// public static final int kxymotor_move_to_zero = 0x0304;
// public static final int kxymotor_read_pos = 0x0306;
// public static final int kxymotor_read_inio_index_in_stm32 = 0x0307;
// public static final int kxymotor_read_inio = 0x0308;
// public static final int kxymotor_set_pos = 0x0309;
// public static final int kxymotor_motor_move_by_direct = 0x030a;
// public static final int kxymotor_read_enc_direct = 0x030b;
public void hbotEnable(MId mid, int enable) throws HardwareException {
callcmd(mid.toInt(), CmdId.kxymotor_enable, enable);
}
// //
// stepMotor // stepMotor
// //

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

@ -25,12 +25,64 @@ public class DeviceInitializationCtrlService {
A8kCanBusService canBus; A8kCanBusService canBus;
@Resource @Resource
CommonHardwareOpeartion hardwareOpeartion;
CommonHardwareOpeartion commonHardOpera;
@Resource @Resource
SamplesPreProcessModuleCtrlParamsService samplesPreProcessModuleCtrlParams; SamplesPreProcessModuleCtrlParamsService samplesPreProcessModuleCtrlParams;
public AppEcode initializeDevice() {
logger.info("Initializing device ...");
try {
/*
* 复位思路
* 硬件初始化:
* 检查
* 复位
* 清空耗材
*/
AppEcode ecode;
//硬件光电初始化
ecode = hardwareStaticInit();
if (!ecode.isOk()) {
return ecode;
}
//检查设备状态
ecode = checkDeviceState();
if (!ecode.isOk()) {
return ecode;
}
//复位设备
// ecode = moveMotorToZero();
// if (!ecode.isOk()) {
// return ecode;
// }
//清空耗材
} catch (HardwareException e) {
logger.error("HardwareException %s", e);
throw new RuntimeException(e);
} catch (InterruptedException e) {
logger.error("InterruptedException", e);
throw new RuntimeException(e);
} finally {
try {
canBus.stepMotorEnable(MId.ShakeModClampingM, 1);
canBus.stepMotorEasyMoveBy(MId.ShakeModClampingM, 2);
canBus.waitForMod(MId.ShakeModClampingM, actionOvertime);
commonHardOpera.forceStopAndDisableAllMOtor();
} catch (HardwareException | InterruptedException ignored) {
}
}
return new AppEcode(A8kEcode.Success);
}
private AppEcode hardwareStaticInit() throws HardwareException, InterruptedException { private AppEcode hardwareStaticInit() throws HardwareException, InterruptedException {
/* /*
* 硬件初始化: * 硬件初始化:
@ -39,7 +91,7 @@ public class DeviceInitializationCtrlService {
* 3.使能所有电机 * 3.使能所有电机
*/ */
hardwareOpeartion.enableAllMotor();
commonHardOpera.enableAllMotor();
//打开必要的电源 //打开必要的电源
canBus.setIOState(IOId.RecycleBinOverflowPPSPowerCtrl, true); canBus.setIOState(IOId.RecycleBinOverflowPPSPowerCtrl, true);
@ -145,56 +197,4 @@ public class DeviceInitializationCtrlService {
} }
public AppEcode initializeDevice() {
logger.info("Initializing device ...");
try {
/*
* 复位思路
* 硬件初始化:
* 检查
* 复位
* 清空耗材
*/
AppEcode ecode;
//硬件光电初始化
ecode = hardwareStaticInit();
if (!ecode.isOk()) {
return ecode;
}
//检查设备状态
ecode = checkDeviceState();
if (!ecode.isOk()) {
return ecode;
}
//复位设备
ecode = moveMotorToZero();
if (!ecode.isOk()) {
return ecode;
}
//清空耗材
} catch (HardwareException e) {
logger.error("HardwareException %s", e);
throw new RuntimeException(e);
} catch (InterruptedException e) {
logger.error("InterruptedException", e);
throw new RuntimeException(e);
} finally {
try {
canBus.stepMotorEnable(MId.ShakeModClampingM, 1);
canBus.stepMotorEasyMoveBy(MId.ShakeModClampingM, 2);
canBus.waitForMod(MId.ShakeModClampingM, actionOvertime);
} catch (HardwareException | InterruptedException ignored) {
}
}
return new AppEcode(A8kEcode.Success);
}
} }

35
src/main/java/a8k/service/hardware/CommonHardwareOpeartion.java

@ -97,7 +97,8 @@ public class CommonHardwareOpeartion {
} }
public void stopAllMOtor() {
public void forceStopAndDisableAllMOtor() {
//StopAllMotor
//进出料初始化 //进出料初始化
try {canBus.moduleStop(MId.FeedingModInfeedM);} catch (HardwareException ignored) {} try {canBus.moduleStop(MId.FeedingModInfeedM);} catch (HardwareException ignored) {}
try {canBus.moduleStop(MId.FeedingModXM);} catch (HardwareException ignored) {} try {canBus.moduleStop(MId.FeedingModXM);} catch (HardwareException ignored) {}
@ -122,5 +123,37 @@ public class CommonHardwareOpeartion {
//转盘归零 //转盘归零
try {canBus.moduleStop(MId.IncubatorRotateCtrlM);} catch (HardwareException ignored) {} try {canBus.moduleStop(MId.IncubatorRotateCtrlM);} catch (HardwareException ignored) {}
//Disable all motor
//进出料初始化
try {canBus.stepMotorEnable(MId.FeedingModInfeedM, 0);} catch (HardwareException ignored) {}
try {canBus.stepMotorEnable(MId.FeedingModXM, 0);} catch (HardwareException ignored) {}
try {canBus.stepMotorEnable(MId.FeedingModOutfeedM, 0);} catch (HardwareException ignored) {}
//摇匀模组初始化
try {canBus.stepMotorEnable(MId.ShakeModClampingM, 0);} catch (HardwareException ignored) {}
try {canBus.stepMotorEnable(MId.ShakeModGripperZM, 0);} catch (HardwareException ignored) {}
try {canBus.stepMotorEnable(MId.ShakeModShakeM, 0);} catch (HardwareException ignored) {}
try {canBus.miniServoEnable(MId.ShakeModGripperYM, 0);} catch (HardwareException ignored) {}
try {canBus.miniServoEnable(MId.ShakeModGripperSV, 0);} catch (HardwareException ignored) {}
try {canBus.miniServoEnable(MId.ShakeModTubeScanerClampingSV, 0);} catch (HardwareException ignored) {}
try {canBus.miniServoEnable(MId.ShakeModTubeScanerRotateSV, 0);} catch (HardwareException ignored) {}
//板夹仓初始化
try {canBus.stepMotorEnable(MId.PlatesBoxYM, 0);} catch (HardwareException ignored) {}
try {canBus.stepMotorEnable(MId.PlatesBoxPusherM, 0);} catch (HardwareException ignored) {}
//光学模组初始化
try {canBus.stepMotorEnable(MId.OptModPullM, 0);} catch (HardwareException ignored) {}
try {canBus.stepMotorEnable(MId.OptModScannerM, 0);} catch (HardwareException ignored) {}
//HBot初始化
try {canBus.stepMotorEnable(MId.HbotM, 0);} catch (HardwareException ignored) {}
try {canBus.stepMotorEnable(MId.PipetteModZM, 0);} catch (HardwareException ignored) {}
//转盘归零
try {canBus.stepMotorEnable(MId.IncubatorRotateCtrlM, 0);} catch (HardwareException ignored) {}
} }
} }
Loading…
Cancel
Save