|
|
@ -7,8 +7,10 @@ import com.iflytop.a800.device.Device; |
|
|
|
import com.iflytop.a800.model.MdbIdChip; |
|
|
|
import com.iflytop.a800.model.MdbProject; |
|
|
|
import com.iflytop.a800.model.MdbTest; |
|
|
|
import com.iflytop.a800.model.MdbTubeRackTestTaskTube; |
|
|
|
import com.iflytop.a800.resource.*; |
|
|
|
import com.iflytop.a800.utils.ScanResultAnalysisAlgo; |
|
|
|
import com.iflytop.uf.UfActiveRecord; |
|
|
|
import com.iflytop.uf.UfActuatorCmdExecutor; |
|
|
|
import com.iflytop.uf.UfCmdSnippetExecutor; |
|
|
|
import com.iflytop.uf.model.UfMdbDictItem; |
|
|
@ -24,18 +26,28 @@ public class TubeTestTask extends TaskBase { |
|
|
|
public TestTube tube; |
|
|
|
// 测试项目 |
|
|
|
public MdbProject project; |
|
|
|
// 测试试管 |
|
|
|
public MdbTubeRackTestTaskTube tubeModel; |
|
|
|
|
|
|
|
// 测试记录 |
|
|
|
private MdbTest test; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public TestTubeRack tubeRack; |
|
|
|
public String status; |
|
|
|
|
|
|
|
// 测试记录 |
|
|
|
private MdbTest test; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 缓冲液试管 |
|
|
|
private BufferTube bufferTube; |
|
|
|
// 大容量缓冲液试管 |
|
|
|
private LargeBufferTube largeBufferTube; |
|
|
|
// 测试卡 |
|
|
|
private TestCard testCard; |
|
|
|
private TestCard testCard = null; |
|
|
|
// id chip |
|
|
|
private MdbIdChip idChip; |
|
|
|
// 孵育槽位 |
|
|
@ -46,7 +58,7 @@ public class TubeTestTask extends TaskBase { |
|
|
|
var device = Device.getInstance(); |
|
|
|
|
|
|
|
// 申请测试卡 |
|
|
|
this.testCard = device.testCard.alloc(this.project); |
|
|
|
this.prepareTestcard(); |
|
|
|
|
|
|
|
// 缓冲液/探测物质 |
|
|
|
this.bufferTube = device.bufferTube.alloc(this.testCard); |
|
|
@ -58,8 +70,10 @@ public class TubeTestTask extends TaskBase { |
|
|
|
|
|
|
|
// 测试记录 |
|
|
|
this.test = new MdbTest(); |
|
|
|
this.test.tubeId = this.tubeModel.id; |
|
|
|
this.test.projectCode = this.project.code; |
|
|
|
this.test.materialLotCode = this.testCard.lotCode; |
|
|
|
this.test.isSamplingFinished = "no"; |
|
|
|
this.test.save(); |
|
|
|
|
|
|
|
// 移动试管架 |
|
|
@ -85,14 +99,35 @@ public class TubeTestTask extends TaskBase { |
|
|
|
))); |
|
|
|
} |
|
|
|
|
|
|
|
// 申请测试卡 |
|
|
|
private void prepareTestcard() { |
|
|
|
var device = Device.getInstance(); |
|
|
|
this.testCard = device.testCard.alloc(this.project); |
|
|
|
this.log("测试卡:Box={}; Lot={}", this.testCard.boxIndex, this.testCard.lotCode); |
|
|
|
|
|
|
|
var threadPushCardToSlot = new Thread(() -> { |
|
|
|
this.log("测试卡推送至孵育盘 :开始"); |
|
|
|
this.incubatorSlot = device.incubator.pushNewCard(this.testCard); |
|
|
|
this.testCard.incubatorSlotIndex = this.incubatorSlot.index; |
|
|
|
this.log("测试卡推送至孵育盘 : 完成 -> Slot={}", this.testCard.incubatorSlotIndex); |
|
|
|
synchronized ( this.testCard ) { |
|
|
|
this.testCard.notifyAll(); |
|
|
|
} |
|
|
|
}); |
|
|
|
threadPushCardToSlot.start(); |
|
|
|
} |
|
|
|
|
|
|
|
// 记录日志 |
|
|
|
private void log(String message, Object ... args ) { |
|
|
|
message = String.format("[TubeTestTask:T%d-P%s] %s", this.tube.index, this.test.projectCode, message); |
|
|
|
message = String.format("[TubeTestTask:T%d-P%s] %s", this.tube.index, this.project.code, message); |
|
|
|
LOG.info(message, args); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
this.tubeModel.status = UfMdbDictItem.getValue("TUBE_STATUS", "EXECUTING"); |
|
|
|
this.tubeModel.save(); |
|
|
|
|
|
|
|
this.prepare(); |
|
|
|
|
|
|
|
ObjectMapper jsonMapper = new ObjectMapper(); |
|
|
@ -109,23 +144,45 @@ public class TubeTestTask extends TaskBase { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
var stepAction = stepNode.get("action").asText(); |
|
|
|
switch ( stepAction ) { |
|
|
|
case "shaking" : this.shake(stepNode); break; |
|
|
|
case "uncap" : this.uncap(); break; |
|
|
|
case "cap" : this.cap(); break; |
|
|
|
case "puncture" : this.executeStepPuncture(stepNode); break; |
|
|
|
case "aspirate" : this.executeStepAspirate(stepNode); break; |
|
|
|
case "mixing" : this.executeStepMixing(stepNode); break; |
|
|
|
case "drop-tip" : this.executeStepDropTip(stepNode); break; |
|
|
|
case "incubate" : this.executeStepIncubate(stepNode); break; |
|
|
|
case "analysis" : this.executeStepAnalysis(stepNode); break; |
|
|
|
try { |
|
|
|
var stepAction = stepNode.get("action").asText(); |
|
|
|
switch ( stepAction ) { |
|
|
|
case "shaking" : this.shake(stepNode); break; |
|
|
|
case "uncap" : this.uncap(); break; |
|
|
|
case "cap" : this.cap(); break; |
|
|
|
case "puncture" : this.executeStepPuncture(stepNode); break; |
|
|
|
case "aspirate" : this.executeStepAspirate(stepNode); break; |
|
|
|
case "mixing" : this.executeStepMixing(stepNode); break; |
|
|
|
case "drop-tip" : this.executeStepDropTip(stepNode); break; |
|
|
|
case "incubate" : this.executeStepIncubate(stepNode); break; |
|
|
|
case "analysis" : this.executeStepAnalysis(stepNode); break; |
|
|
|
case "sampling-done" : this.executeStepSamplingDone(stepNode); break; |
|
|
|
} |
|
|
|
} catch ( InterruptedException e ) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this.taskFinish(); |
|
|
|
} |
|
|
|
|
|
|
|
// 采样完成 |
|
|
|
private void executeStepSamplingDone(JsonNode stepNode) { |
|
|
|
this.log("采样完成"); |
|
|
|
this.test.isSamplingFinished = "yes"; |
|
|
|
this.test.save(); |
|
|
|
|
|
|
|
var doneSamplingCount = UfActiveRecord.count(MdbTest.class, Map.of( |
|
|
|
"isSamplingFinished","yes", |
|
|
|
"tubeId", this.tubeModel.id |
|
|
|
)); |
|
|
|
if ( doneSamplingCount == this.tubeModel.getProjectIdList().size() ) { |
|
|
|
this.log("试管采样结束"); |
|
|
|
this.tubeModel.status = UfMdbDictItem.getValue("TUBE_STATUS", "FINISHED"); |
|
|
|
this.tubeModel.save(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 摇匀 |
|
|
|
private void shake( JsonNode stepNode ) { |
|
|
|
int count = stepNode.get("count").asInt(); |
|
|
@ -207,10 +264,16 @@ public class TubeTestTask extends TaskBase { |
|
|
|
} |
|
|
|
|
|
|
|
// 孵育 |
|
|
|
private void executeStepIncubate( JsonNode stepNode ) { |
|
|
|
Device device = Device.getInstance(); |
|
|
|
this.incubatorSlot = device.incubator.pushNewCard(this.testCard); |
|
|
|
private void executeStepIncubate( JsonNode stepNode ) throws InterruptedException { |
|
|
|
if ( -1 == this.testCard.incubatorSlotIndex ) { |
|
|
|
synchronized ( this.testCard ) { |
|
|
|
this.log("测试卡就绪等待"); |
|
|
|
this.testCard.wait(); |
|
|
|
this.log("测试卡就绪等待完成"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Device device = Device.getInstance(); |
|
|
|
var pipette = device.pipette; |
|
|
|
pipette.tipPickUp(); |
|
|
|
|
|
|
|