|
|
@ -10,6 +10,9 @@ import a8k.app.service.lowerctrl.TubeFeedingCtrlService; |
|
|
|
import a8k.app.service.lowerctrl.TubePreProcessModuleCtrlService; |
|
|
|
import a8k.app.service.statemgr.DeviceWorkStateMgrService; |
|
|
|
import a8k.app.type.appevent.AppDeviceInitSucEvent; |
|
|
|
import a8k.app.type.deviceinit.CheckResult; |
|
|
|
import a8k.app.type.deviceinit.Checkpoint; |
|
|
|
import a8k.app.type.deviceinit.DeviceInitState; |
|
|
|
import a8k.app.type.exception.AppException; |
|
|
|
import a8k.app.type.ui.ZAppPromopt; |
|
|
|
import a8k.app.type.ui.ZAppPromptFormsItem; |
|
|
@ -18,6 +21,7 @@ import a8k.app.factory.ZAppPromptFactory; |
|
|
|
|
|
|
|
import a8k.app.teststate.VirtualDevice; |
|
|
|
import a8k.app.service.statemgr.GStateMgrService; |
|
|
|
import a8k.app.utils.ZList; |
|
|
|
import jakarta.annotation.PostConstruct; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
@ -33,49 +37,6 @@ public class AppDeviceInitCtrlService { |
|
|
|
private final AppEventBusService appEventBusService; |
|
|
|
private final GStateMgrService gStateMgrService; |
|
|
|
|
|
|
|
public static class Checkpoint { |
|
|
|
public enum Type { |
|
|
|
CHECK_TUBE_X_CHANNEL_IS_EMPTY,//入料通道是否为空 |
|
|
|
CHECK_PLATE_BOX_IS_COVER,//板夹仓盖子是否盖着 |
|
|
|
CHECK_PLATE_STUCK_DETECTOR_SENSOR1_IS_TRIGGER,//板夹仓卡板检测 |
|
|
|
CHECK_PLATE_STUCK_DETECTOR_SENSOR2_IS_TRIGGER,//板夹仓卡板检测 |
|
|
|
CHECK_PULLER_MOTOR_IS_IN_ZERO_POS,//检查拉杆电机是否在零点位置 |
|
|
|
CHECK_PUSHER_MOTOR_IN_IN_ZERO_POS,//检查推杆电机是否在零点位置 |
|
|
|
CHECK_RECYCLE_BIN_IS_OVERFLOW,//检查垃圾箱是否满 |
|
|
|
CHECK_TUBE_CLAMPING_MOTOR_IS_IN_ZERO_POS,//检查试管夹紧电机是否在零点位置 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@FunctionalInterface |
|
|
|
public interface CheckFn { |
|
|
|
Boolean check() throws AppException; |
|
|
|
} |
|
|
|
|
|
|
|
public Type type; |
|
|
|
public String typechinfo; |
|
|
|
public CheckFn checkfn; |
|
|
|
|
|
|
|
public Checkpoint(String typechinfo, Type type, CheckFn checkfn) { |
|
|
|
this.typechinfo = typechinfo; |
|
|
|
this.type = type; |
|
|
|
this.checkfn = checkfn; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public static class CheckResult { |
|
|
|
public Checkpoint.Type type; |
|
|
|
public String info; |
|
|
|
public Boolean pass; |
|
|
|
} |
|
|
|
|
|
|
|
public static class State { |
|
|
|
public Boolean deviceInited = false; //设备是否已经被初始化 |
|
|
|
public Boolean isBusy = false; //是否正在初始化 |
|
|
|
public Boolean passed = false; //设备自检是否通过 |
|
|
|
public ZAppPromopt promopt; //设备初始化报告 |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private final GStateMgrService gstate; |
|
|
|
private final VirtualDevice virtualDevice; |
|
|
@ -100,14 +61,26 @@ public class AppDeviceInitCtrlService { |
|
|
|
private final DeviceWorkStateMgrService deviceWorkStateMgrService; |
|
|
|
|
|
|
|
|
|
|
|
private final List<Checkpoint> checkPoints = new ArrayList<>(); |
|
|
|
private final State state = new State(); |
|
|
|
private final List<Checkpoint> checkPoints = ZList.of(); |
|
|
|
private final DeviceInitState deviceInitState = new DeviceInitState(); |
|
|
|
private Thread workThread; |
|
|
|
public List<CheckResult> checkResults; |
|
|
|
|
|
|
|
@PostConstruct |
|
|
|
private void init() { |
|
|
|
checkPoints.add(new Checkpoint("检查板夹仓盖子是否盖上",// |
|
|
|
Checkpoint.Type.CHECK_PLATE_BOX_IS_COVER, () -> inputDetectDriver.getIOState(InputIOId.PlateBoxCoverClosurePPS))); |
|
|
|
checkPoints.add(new Checkpoint("检测孵育盘入口是否卡板",// |
|
|
|
Checkpoint.Type.CHECK_PLATE_STUCK_DETECTOR_SENSOR1_IS_TRIGGER, () -> !inputDetectDriver.getIOState(InputIOId.IncubationPlateInletStuckPPS))); |
|
|
|
checkPoints.add(new Checkpoint("检测孵育盘出口是否卡板",// |
|
|
|
Checkpoint.Type.CHECK_PLATE_STUCK_DETECTOR_SENSOR2_IS_TRIGGER, () -> !inputDetectDriver.getIOState(InputIOId.IncubationPlateOutletStuckPPS))); |
|
|
|
checkPoints.add(new Checkpoint("检查试管夹紧电机是否在零位",// |
|
|
|
Checkpoint.Type.CHECK_TUBE_CLAMPING_MOTOR_IS_IN_ZERO_POS, () -> stepMotorCtrlDriver.stepMotorReadIoState(StepMotorMId.ShakeModClampingM, 0))); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
synchronized public State getState() { |
|
|
|
return state; |
|
|
|
synchronized public DeviceInitState getDeviceInitState() { |
|
|
|
return deviceInitState; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -168,10 +141,9 @@ public class AppDeviceInitCtrlService { |
|
|
|
|
|
|
|
workThread = new Thread(() -> { |
|
|
|
log.info("设备初始化开始"); |
|
|
|
state.isBusy = true; |
|
|
|
state.passed = false; |
|
|
|
state.deviceInited = false; |
|
|
|
|
|
|
|
deviceInitState.isBusy = true; |
|
|
|
deviceInitState.passed = false; |
|
|
|
deviceInitState.deviceInited = false; |
|
|
|
|
|
|
|
try { |
|
|
|
checkResults = initDevice(); |
|
|
@ -180,20 +152,20 @@ public class AppDeviceInitCtrlService { |
|
|
|
throw AppException.of(A8kEcode.APPE_DEVICE_INIT_CHECK_FAIL); |
|
|
|
} |
|
|
|
} |
|
|
|
state.passed = true; |
|
|
|
state.deviceInited = true; |
|
|
|
state.promopt = ZAppPromptFactory.buildNotifyPrompt("设备初始化成功"); |
|
|
|
deviceInitState.passed = true; |
|
|
|
deviceInitState.deviceInited = true; |
|
|
|
deviceInitState.promopt = ZAppPromptFactory.buildNotifyPrompt("设备初始化成功"); |
|
|
|
|
|
|
|
} catch (AppException e) { |
|
|
|
state.passed = false; |
|
|
|
state.deviceInited = false; |
|
|
|
deviceInitState.passed = false; |
|
|
|
deviceInitState.deviceInited = false; |
|
|
|
if (e.getError().code.equals(A8kEcode.APPE_DEVICE_INIT_CHECK_FAIL)) { |
|
|
|
state.promopt = buildAppPrompt(checkResults); |
|
|
|
deviceInitState.promopt = buildAppPrompt(checkResults); |
|
|
|
} else { |
|
|
|
state.promopt = ZAppPromptFactory.buildAppPrompt(e); |
|
|
|
deviceInitState.promopt = ZAppPromptFactory.buildAppPrompt(e); |
|
|
|
} |
|
|
|
} |
|
|
|
state.isBusy = false; |
|
|
|
deviceInitState.isBusy = false; |
|
|
|
log.info("设备初始化结束"); |
|
|
|
}); |
|
|
|
workThread.start(); |
|
|
@ -214,19 +186,6 @@ public class AppDeviceInitCtrlService { |
|
|
|
//****************************************************************************************** |
|
|
|
|
|
|
|
|
|
|
|
@PostConstruct |
|
|
|
private void init() { |
|
|
|
checkPoints.add(new Checkpoint("检查板夹仓盖子是否盖上",// |
|
|
|
Checkpoint.Type.CHECK_PLATE_BOX_IS_COVER, () -> inputDetectDriver.getIOState(InputIOId.PlateBoxCoverClosurePPS))); |
|
|
|
checkPoints.add(new Checkpoint("检测孵育盘入口是否卡板",// |
|
|
|
Checkpoint.Type.CHECK_PLATE_STUCK_DETECTOR_SENSOR1_IS_TRIGGER, () -> !inputDetectDriver.getIOState(InputIOId.IncubationPlateInletStuckPPS))); |
|
|
|
checkPoints.add(new Checkpoint("检测孵育盘出口是否卡板",// |
|
|
|
Checkpoint.Type.CHECK_PLATE_STUCK_DETECTOR_SENSOR2_IS_TRIGGER, () -> !inputDetectDriver.getIOState(InputIOId.IncubationPlateOutletStuckPPS))); |
|
|
|
checkPoints.add(new Checkpoint("检查试管夹紧电机是否在零位",// |
|
|
|
Checkpoint.Type.CHECK_TUBE_CLAMPING_MOTOR_IS_IN_ZERO_POS, () -> stepMotorCtrlDriver.stepMotorReadIoState(StepMotorMId.ShakeModClampingM, 0))); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private List<CheckResult> doDeviceInit() throws AppException { |
|
|
|
|
|
|
|
a8kSubModuleRegInitService.initAllInputIOConfig(); |
|
|
|