Browse Source

update

tags/v0
zhaohe 9 months ago
parent
commit
e1635ccd0a
  1. 28
      src/main/java/a8k/service/app/appctrl/mainflowctrl/action/SEQ5_PROCESS.java
  2. 15
      src/main/java/a8k/service/app/appctrl/mainflowctrl/processer/MainFlowStateChangeProcesser.java
  3. 5
      src/main/java/a8k/service/app/appstate/statemgr/ProjectContextMgrService.java
  4. 19
      src/main/java/a8k/service/app/appstate/statemgr/TubeStateMgrService.java
  5. 2
      src/main/java/a8k/service/app/background/SensorDataUpdateService.java
  6. 4
      src/main/java/a8k/service/app/devicectrl/ctrlservice/TubeFeedingCtrlService.java
  7. 132
      src/main/java/a8k/service/app/devicectrl/exdriver/HbotBaseMoveExDriver.java
  8. 10
      src/main/java/a8k/service/dao/DeviceStatisticDao.java
  9. 13
      src/main/java/a8k/service/test/MainflowCtrlTestService.java

28
src/main/java/a8k/service/app/appctrl/mainflowctrl/action/SEQ5_PROCESS.java

@ -29,6 +29,7 @@ import a8k.service.test.state.TestModeState;
import a8k.service.test.state.VirtualDevice; import a8k.service.test.state.VirtualDevice;
import a8k.type.ConsumableGroup; import a8k.type.ConsumableGroup;
import a8k.type.IncubatorPos; import a8k.type.IncubatorPos;
import a8k.type.ecode.AECodeError;
import a8k.type.ecode.AppError; import a8k.type.ecode.AppError;
import a8k.type.exception.AppException; import a8k.type.exception.AppException;
import a8k.type.exception.ZAppInterruptException; import a8k.type.exception.ZAppInterruptException;
@ -78,14 +79,14 @@ public class SEQ5_PROCESS extends A8kStepAction {
@Resource @Resource
PublicAreaResourceMgr publicAreaResourceMgr; PublicAreaResourceMgr publicAreaResourceMgr;
@Resource @Resource
TubeStateMgrService tubeStateMgrService;
TubeStateMgrService tubeStateMgrService;
// //
// CtrlService // CtrlService
// //
@Resource @Resource
PipeGunCtrlScripter pipeGunCtrlScripter;
PipeGunCtrlScripter pipeGunCtrlScripter;
@Resource @Resource
PlateBoxCtrlService plateBoxCtrlService;
PlateBoxCtrlService plateBoxCtrlService;
@Resource @Resource
TubePreProcesCtrlService tubePreProcesCtrlService; TubePreProcesCtrlService tubePreProcesCtrlService;
@Resource @Resource
@ -313,11 +314,10 @@ public class SEQ5_PROCESS extends A8kStepAction {
try ( try (
var ignored = publicAreaResourceMgr.apply(this.getClass(), PublicAreaResource.HbotArea); var ignored = publicAreaResourceMgr.apply(this.getClass(), PublicAreaResource.HbotArea);
) { ) {
doSampleProcess(cxt);
Boolean cxtIsFinal = cxt.equals(cxts.get(cxts.size() - 1));
doSampleProcess(cxt, cxtIsFinal);
} }
} }
sampleProcessFinished.set(); sampleProcessFinished.set();
} }
@ -363,7 +363,8 @@ public class SEQ5_PROCESS extends A8kStepAction {
} }
void doSampleProcess(ProjectTaskContext cxt) throws AppException, ZAppInterruptException {
void doSampleProcess(ProjectTaskContext cxt, Boolean finalCxt) throws AppException, ZAppInterruptException {
log.info("开始处理样本 cxtid:{} sampleId:{}", cxt.cxtId, cxt.sampleInfo.sampleId);
A8kReactionFlowType type = cxt.getProjBuildinInfo().projBaseInfo.reactionFlowType; A8kReactionFlowType type = cxt.getProjBuildinInfo().projBaseInfo.reactionFlowType;
Consumable consumable = cxt.getConsumable(); Consumable consumable = cxt.getConsumable();
ConsumableGroup consumableGroup = consumable.getGroup(); ConsumableGroup consumableGroup = consumable.getGroup();
@ -373,7 +374,9 @@ public class SEQ5_PROCESS extends A8kStepAction {
// 1. 在取tip之后就让移液枪移动到lldprepare的位置新增一条指令,这条指令在单片机端也是非阻塞的到lld位置时在执行lldprepare的指令这样即不破坏现有框架也可以提速 // 1. 在取tip之后就让移液枪移动到lldprepare的位置新增一条指令,这条指令在单片机端也是非阻塞的到lld位置时在执行lldprepare的指令这样即不破坏现有框架也可以提速
// //
//
// 初步反应准备
//
if (type.equals(A8kReactionFlowType.FlowType1)) { if (type.equals(A8kReactionFlowType.FlowType1)) {
log.info("FlowType1:"); log.info("FlowType1:");
doSampleFlowType1PreProcess(cxt); doSampleFlowType1PreProcess(cxt);
@ -409,8 +412,14 @@ public class SEQ5_PROCESS extends A8kStepAction {
} }
} }
if (finalCxt) {
// 在这里之后就不再需要样本了摇匀模组就可以回收样本了
sampleProcessFinished.set();
}
//
// 初步反应处理 // 初步反应处理
//
{ {
Integer sampleul = ProjProcessContextUtils.getSampleVol(cxt); Integer sampleul = ProjProcessContextUtils.getSampleVol(cxt);
Integer reactionul = ProjProcessContextUtils.getReactionPlateDropletVolUl(cxt); Integer reactionul = ProjProcessContextUtils.getReactionPlateDropletVolUl(cxt);
@ -420,7 +429,9 @@ public class SEQ5_PROCESS extends A8kStepAction {
pipeGunCtrlScripter.mix(PipetteGunBindActionType.MIX_REACTION_LIQUOR, cxt, sampleul, ProjProcessContextUtils.getBSMixingCnt(cxt)); pipeGunCtrlScripter.mix(PipetteGunBindActionType.MIX_REACTION_LIQUOR, cxt, sampleul, ProjProcessContextUtils.getBSMixingCnt(cxt));
} }
//
// 取初步反应混合液到反应板 // 取初步反应混合液到反应板
//
try ( try (
var ignored11 = publicAreaResourceMgr.apply(this.getClass(), PublicAreaResource.IncubationPlateArea); var ignored11 = publicAreaResourceMgr.apply(this.getClass(), PublicAreaResource.IncubationPlateArea);
) { ) {
@ -509,6 +520,7 @@ public class SEQ5_PROCESS extends A8kStepAction {
log.warn("{} catch 中断", actionTaskMarker); log.warn("{} catch 中断", actionTaskMarker);
} catch (Exception e) { } catch (Exception e) {
log.error("{} catch 异常", actionTaskMarker, e); log.error("{} catch 异常", actionTaskMarker, e);
error = new AECodeError(e);
} }
Thread.currentThread().setName(oldName); Thread.currentThread().setName(oldName);
return error; return error;

15
src/main/java/a8k/service/app/appctrl/mainflowctrl/processer/MainFlowStateChangeProcesser.java

@ -4,6 +4,7 @@ import a8k.service.app.appctrl.mainflowctrl.MainFlowCtrlScheduler;
import a8k.service.app.appctrl.mainflowctrl.base.IMainFlowStateChangeProcesser; import a8k.service.app.appctrl.mainflowctrl.base.IMainFlowStateChangeProcesser;
import a8k.service.app.appctrl.mainflowctrl.base.MainFlowProcesser; import a8k.service.app.appctrl.mainflowctrl.base.MainFlowProcesser;
import a8k.service.app.appstate.statemgr.IncubationPlateStateMgrService; import a8k.service.app.appstate.statemgr.IncubationPlateStateMgrService;
import a8k.service.app.appstate.statemgr.ProjectContextMgrService;
import a8k.service.app.appstate.statemgr.TubeStateMgrService; import a8k.service.app.appstate.statemgr.TubeStateMgrService;
import a8k.service.app.appstate.type.IncubationSubTank; import a8k.service.app.appstate.type.IncubationSubTank;
import a8k.service.app.appstate.type.state.IncubationSubTankState; import a8k.service.app.appstate.type.state.IncubationSubTankState;
@ -25,18 +26,18 @@ public class MainFlowStateChangeProcesser implements IMainFlowStateChangeProcess
VirtualDevice virtualDevice; VirtualDevice virtualDevice;
@Resource @Resource
TubeFeedingCtrlService tubeFeedingCtrlService;
TubeFeedingCtrlService tubeFeedingCtrlService;
@Resource @Resource
HbotCtrlService hbotCtrlService;
HbotCtrlService hbotCtrlService;
@Resource @Resource
OptScanModuleCtrlService optScanModuleCtrlService;
OptScanModuleCtrlService optScanModuleCtrlService;
@Resource @Resource
IncubationPlateStateMgrService incubationPlateStateMgrService;
IncubationPlateStateMgrService incubationPlateStateMgrService;
@Resource @Resource
TubeStateMgrService tubeStateMgrService;
TubeStateMgrService tubeStateMgrService;
@Resource @Resource
MainFlowCtrlScheduler mainFlowCtrlScheduler;
ProjectContextMgrService projectContextMgrService;
void ejectAllPlates() throws AppException { void ejectAllPlates() throws AppException {
var tanks = incubationPlateStateMgrService.get().subtanks; var tanks = incubationPlateStateMgrService.get().subtanks;
@ -69,6 +70,7 @@ public class MainFlowStateChangeProcesser implements IMainFlowStateChangeProcess
@Override @Override
public void onStop() throws AppException { public void onStop() throws AppException {
doClearDevice(); doClearDevice();
projectContextMgrService.clearCxts();
} }
@Override @Override
@ -81,5 +83,6 @@ public class MainFlowStateChangeProcesser implements IMainFlowStateChangeProcess
@Override @Override
public void onStart() throws AppException { public void onStart() throws AppException {
} }
} }

5
src/main/java/a8k/service/app/appstate/statemgr/ProjectContextMgrService.java

@ -24,8 +24,6 @@ import java.util.List;
@Component @Component
@Slf4j @Slf4j
public class ProjectContextMgrService { public class ProjectContextMgrService {
@Resource
ConsumablesMgrService consumablesMgrService;
List<ProjectTaskContext> contexts = new ArrayList<>(); List<ProjectTaskContext> contexts = new ArrayList<>();
@ -106,4 +104,7 @@ public class ProjectContextMgrService {
return ret; return ret;
} }
synchronized public void clearCxts() {
contexts.clear();
}
} }

19
src/main/java/a8k/service/app/appstate/statemgr/TubeStateMgrService.java

@ -58,21 +58,18 @@ public class TubeStateMgrService {
private String priGenerateSampleId(Integer tubePos, Boolean isEmergency) { private String priGenerateSampleId(Integer tubePos, Boolean isEmergency) {
String sampleid = "";
Integer cnt = 0;
Date date = new Date();
if (isEmergency) {
cnt = deviceStatisticDao.get(StatisticType.EmergencyTubeCnt);
} else {
cnt = deviceStatisticDao.get(StatisticType.TubeHolderCnt);
}
SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
String sampleid = "";
Integer cnt = 0;
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
if (isEmergency) { if (isEmergency) {
cnt = deviceStatisticDao.get(StatisticType.EmergencyTubeCnt, date);
sampleid = String.format("%s_%sE", sdf.format(date), cnt); sampleid = String.format("%s_%sE", sdf.format(date), cnt);
deviceStatisticDao.setCnt(StatisticType.EmergencyTubeCnt, date, cnt + 1);
} else { } else {
cnt = deviceStatisticDao.get(StatisticType.TubeHolderCnt, date);
sampleid = String.format("%s_%d%02d", sdf.format(date), cnt, tubePos + 1); sampleid = String.format("%s_%d%02d", sdf.format(date), cnt, tubePos + 1);
deviceStatisticDao.setCnt(StatisticType.TubeHolderCnt, date, cnt + 1);
} }
return sampleid; return sampleid;
} }

2
src/main/java/a8k/service/app/background/SensorDataUpdateService.java

@ -59,7 +59,7 @@ public class SensorDataUpdateService {
gStateService.getSensorState().setPboxTemperature((int) (pbtemp + 0.5)); gStateService.getSensorState().setPboxTemperature((int) (pbtemp + 0.5));
log.info("IncubateBoxTemperature: {}, PlateBoxTemperature: {}, WasteBinFullFlag: {}", incubateBoxTemp, pbtemp, wasteBinFullFlag);
log.debug("IncubateBoxTemperature: {}, PlateBoxTemperature: {}, WasteBinFullFlag: {}", incubateBoxTemp, pbtemp, wasteBinFullFlag);
} catch (InterruptedException e) { } catch (InterruptedException e) {
break; break;
} catch (AppException e) { } catch (AppException e) {

4
src/main/java/a8k/service/app/devicectrl/ctrlservice/TubeFeedingCtrlService.java

@ -166,14 +166,14 @@ public class TubeFeedingCtrlService {
moveTubeRackToExitPos(); moveTubeRackToExitPos();
try { try {
stepMotorCtrlDriver.stepMotorEasyRotate(StepMotorMId.FeedingModOutfeedM, 1); stepMotorCtrlDriver.stepMotorEasyRotate(StepMotorMId.FeedingModOutfeedM, 1);
OS.hsleep(2500);
for (int i = 0; i < outfeedOvertime / 100; i++) { for (int i = 0; i < outfeedOvertime / 100; i++) {
OS.hsleep(100); OS.hsleep(100);
logger.info("getTHchInterPPS:{} getTHchOuterPPS:{}", getTHchInterPPS(), getTHchOuterPPS());
logger.info("等待试管架弹出 PPS-IN:{} PPS1-Ext:{}", getTHchInterPPS(), getTHchOuterPPS());
if (!getTHchInterPPS() && !getTHchOuterPPS()) { if (!getTHchInterPPS() && !getTHchOuterPPS()) {
break; break;
} }
} }
OS.hsleep(1000);
stepMotorCtrlDriver.stepMotorStop(StepMotorMId.FeedingModOutfeedM); stepMotorCtrlDriver.stepMotorStop(StepMotorMId.FeedingModOutfeedM);
if (getTHchInterPPS() || getTHchOuterPPS()) { if (getTHchInterPPS() || getTHchOuterPPS()) {
throw new AppException(A8kEcode.APPE_EJECT_TUBEHOLDER_TIMEOUT); throw new AppException(A8kEcode.APPE_EJECT_TUBEHOLDER_TIMEOUT);

132
src/main/java/a8k/service/app/devicectrl/exdriver/HbotBaseMoveExDriver.java

@ -47,12 +47,12 @@ public class HbotBaseMoveExDriver {
} }
public void enable(int enable) throws AppException { public void enable(int enable) throws AppException {
hbotDriver.enable(enable);
hbotDriver.enable(enable);
} }
public void hbotMoveTo(Pos3d targetPos) throws AppException { public void hbotMoveTo(Pos3d targetPos) throws AppException {
logger.info("hbotCheckAndMoveTo:{}", targetPos);
logger.debug("hbotCheckAndMoveTo:{}", targetPos);
checkBeforeMove(); checkBeforeMove();
boolean zEnable = true; boolean zEnable = true;
boolean hbotEnable = canBus.moduleGetReg(MId.HbotM, RegIndex.kreg_xyrobot_is_enable) == 1; boolean hbotEnable = canBus.moduleGetReg(MId.HbotM, RegIndex.kreg_xyrobot_is_enable) == 1;
@ -93,132 +93,4 @@ public class HbotBaseMoveExDriver {
} }
// public String scan2dCode(Integer waittime) throws AppException {
// try {
// canBus.codeScanerStartScan(MId.PipetteModCodeScanner);
// String result = canBus.codeScanerWaittingForResult(MId.PipetteModCodeScanner, waittime);
// canBus.codeScanerStopScan(MId.PipetteModCodeScanner);
// return result;
// } catch (AppException e) {
// return "";
// }
// }
//
//
// public void zMoveTo(Integer z) throws AppException {
// if (z == 0) {
// pipetteCtrlModule.zMotorMoveToZeroPointQuickBlock();
// } else {
// pipetteCtrlModule.zMotorMoveToBlock(z);
// }
// }
//
// private void hbotCheckAndMoveTo(Pos2d targetPos) throws AppException {
// hbotMoveTo(new Pos3d(targetPos.x, targetPos.y, 0));
// }
// private void modGroupMoveToZero() throws AppException {
// if (!canBus.getIOState(IOId.PlateBoxCoverClosurePPS)) {
// throw new AppException(A8kEcode.APPE_PLATE_BOX_NOT_COVER);
// }
//
// pipetteCtrlModule.zMotorEnable(1);
// hbotModule.enable(1);
//
// hbotModule.moveToZeroBlock(timep.getHbotRuntoZeroActionOvertime());
//
// // 丢弃tip
// Pos3d dropPos = pp.getTipDropPos();
// hbotMoveTo(dropPos);
// // TODO: canBus.pipetteCtrlInitDeviceBlock(MId.PipetteMod, timep.getActionOvertime());
//
// // 快速归零
// modGroupMoveToZeroQuick();
// }
// private void modGroupMoveToZeroQuick() throws AppException {
// hbotCheckAndMoveTo(new Pos2d(0, 0));
// }
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// 单步测试
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// @ExtApiFn(name = "丢Tip", group = "单步测试")
// public void dropTip() throws AppException {
// Pos3d pos = pp.getTipDropPos();
// hbotMoveTo(pos.x, pos.y);
// zMoveTo(pos.z);
// pipetteCtrlModule.putTipBlock();
// zMoveTo(0);
// }
//
// @ExtApiFn(name = "取Tip", group = "单步测试")
// public Boolean takeTip(TipGroup tipGroup, Integer index) throws AppException {
// logger.info("takeTip groupId:{} index:{}", tipGroup.ordinal(), index);
//
// if (index > TipPickUpPosInfo.cgetTipNum() || index < 0) {
// throw new AppException(A8kEcode.CODEERROR_PARAM_OUT_OF_RANGE);
// }
//
// TipPickUpPosInfo tipPos = pp.getTipPickUpPosInfo();
// Pos2d pos = tipPos.getTipPos(tipGroup.ordinal(), index);
// hbotMoveTo(pos.x, pos.y);
//
// //TODO: 补偿group大于1时z轴需要补偿0.2mm
// Integer zCompensate = 0;
// if (tipGroup.ordinal() > 1) {
// zCompensate = 2;
// }
//
// pipetteCtrlModule.zMotorMoveToBlock(tipPos.getPickUpZPos(tipGroup.ordinal()) + zCompensate);
// pipetteCtrlModule.zMotorMoveToZeroPointQuickBlock();
//
// Boolean isGetTip = canBus.moduleGetReg(MId.PipetteMod, RegIndex.kreg_pipette_tip_state) == 1;
// if (!isGetTip) {
// logger.error("takeTip fail");
// }
// return isGetTip;
// }
// @ExtApiFn(name = "HBot移动到", group = "单步测试")
// public void hbotMoveTo(Integer x, Integer y) throws AppException {
// hbotCheckAndMoveTo(new Pos2d(x, y));
// }
// @ExtApiFn(name = "HBot移动到小瓶缓冲液X孔", group = "单步测试")
// public void hbotMoveToSmallBottleGroup(ConsumableGroup group, Integer Xhole)
// throws AppException {
// BottleGroupsPosInfo posInfo = pp.getBottleBufferPosInfo();
// if (Xhole < 0 || Xhole > BottlesPosInfo.cgetMAX()) {
// throw new AppException(A8kEcode.CODEERROR_PARAM_OUT_OF_RANGE);
// }
// Pos2d pos = posInfo.cgetSmallBottleBufferPos(group.off, Xhole);
// hbotCheckAndMoveTo(pos);
// }
//
// @ExtApiFn(name = "HBot移动到探测物质X孔", group = "单步测试")
// public void hbotMoveToDetectMaterialPos(ConsumableGroup group, Integer Xhole)
// throws AppException {
// BottleGroupsPosInfo posInfo = pp.getBottleBufferPosInfo();
// if (Xhole < 0 || Xhole > BottlesPosInfo.cgetMAX()) {
// throw new AppException(A8kEcode.CODEERROR_PARAM_OUT_OF_RANGE);
// }
// Pos2d pos = posInfo.cgetDetectMaterialPos(group.off, Xhole);
// hbotCheckAndMoveTo(pos);
// }
//
// @ExtApiFn(name = "HBot移动到大瓶缓冲液X孔", group = "单步测试")
// public void hbotMoveToLargeBottleGroup(ConsumableGroup ch) throws AppException {
// LargeBottleBufferPos posInfo = pp.getLargeBottleBufferPosInfo();
// Pos2d pos = posInfo.cgetBottlePos(ch.off);
// hbotCheckAndMoveTo(pos);
// }
//
// @ExtApiFn(name = "HBot移动到急诊位", group = "单步测试")
// public void hbotMoveToEmergencyPos() throws AppException {
// hbotMoveTo(pp.getEmergencyPos());
// }
} }

10
src/main/java/a8k/service/dao/DeviceStatisticDao.java

@ -49,10 +49,9 @@ public class DeviceStatisticDao {
} }
} }
public void add(StatisticType statisticType, Integer cnt) {
Date now = new Date();
public void setCnt(StatisticType statisticType, Date date, Integer cnt) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
String today = sdf.format(now);
String today = sdf.format(date);
List<DeviceStatistic> statisticList = jdbcTemplate.query("select * from " + tableName + " where statisticDate = ? and statisticType = ?", this::rowMapper, today, statisticType); List<DeviceStatistic> statisticList = jdbcTemplate.query("select * from " + tableName + " where statisticDate = ? and statisticType = ?", this::rowMapper, today, statisticType);
@ -69,10 +68,9 @@ public class DeviceStatisticDao {
} }
} }
public Integer get(StatisticType type) {
Date now = new Date();
public Integer get(StatisticType type, Date date) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
String today = sdf.format(now);
String today = sdf.format(date);
List<DeviceStatistic> statisticList = jdbcTemplate.query("select * from " + tableName + " where statisticDate = ? and statisticType = ?", this::rowMapper, today, type); List<DeviceStatistic> statisticList = jdbcTemplate.query("select * from " + tableName + " where statisticDate = ? and statisticType = ?", this::rowMapper, today, type);
if (statisticList.isEmpty()) { if (statisticList.isEmpty()) {

13
src/main/java/a8k/service/test/MainflowCtrlTestService.java

@ -327,19 +327,6 @@ public class MainflowCtrlTestService {
} }
@ExtApiFn(name = "执行一次简单的测试(虚拟测试.流程1)", order = 400)
public String doSimpleVirtualTest(Boolean isHTube, Integer tubeNum) throws AppException {
regFakeProjInfo();
//设置虚拟耗材,只有一个高试管,无校验模式,无光学检查
testModeState.resetAll();
testModeState.setVirtualTubeScanResult(createScanResult(A8kTubeHolderType.BloodTube, isHTube, tubeNum));
testModeState.setNoCheckMode(true);
testModeState.setDisableOptScan(true);
doOnceSimpleTest(new FAKE_PROJ_01_FLOW1(), ConsumableGroup.GROUP0, tubeNum);
return "开始测试";
}
@ExtApiFn(name = "执行一次简单的测试(无试管测试.流程1)", order = 400) @ExtApiFn(name = "执行一次简单的测试(无试管测试.流程1)", order = 400)
public String doSimpleTest(Boolean isHTube, Integer tubeNum) throws AppException { public String doSimpleTest(Boolean isHTube, Integer tubeNum) throws AppException {
regFakeProjInfo(); regFakeProjInfo();

Loading…
Cancel
Save