|
|
@ -94,25 +94,38 @@ public class DigestionTaskThread extends Thread { |
|
|
|
public void run() { |
|
|
|
try { |
|
|
|
this.prepare(); |
|
|
|
|
|
|
|
// 解析消解配方并取出首轮和末轮配置 |
|
|
|
var rounds = this.solution.getDigestionRounds(); |
|
|
|
var firstRound = rounds.remove(0); |
|
|
|
var lastRound = rounds.remove(rounds.size() - 1); |
|
|
|
MdbDigestionSolution.DigestionSolutionRound firstRound = null; |
|
|
|
if ( !rounds.isEmpty() && rounds.size() > 1 ) { |
|
|
|
firstRound = rounds.remove(0); |
|
|
|
} |
|
|
|
MdbDigestionSolution.DigestionSolutionRound lastRound = null; |
|
|
|
if ( !rounds.isEmpty() ) { |
|
|
|
lastRound = rounds.remove(rounds.size() - 1); |
|
|
|
} |
|
|
|
|
|
|
|
// 执行第一轮 |
|
|
|
this.executeRound(firstRound); |
|
|
|
if ( null != firstRound ) { |
|
|
|
this.executeRound(firstRound); |
|
|
|
} |
|
|
|
// 执行中间轮 |
|
|
|
for (var round : rounds) { |
|
|
|
this.executeRound(round); |
|
|
|
} |
|
|
|
// 执行最后一轮 |
|
|
|
this.executeLastRound(lastRound); |
|
|
|
if ( null != lastRound ) { |
|
|
|
this.executeLastRound(lastRound); |
|
|
|
} |
|
|
|
|
|
|
|
this.errorProcessThread.join(); |
|
|
|
this.updateTaskStatus("Finish", "消解任务结束"); |
|
|
|
this.finishCallback.callback(this); |
|
|
|
} catch (Exception e) { |
|
|
|
this.updateTaskStatus("Error", e.getMessage()); |
|
|
|
UfMdbNotification.error("消解任务执行失败 : " + e.getMessage()); |
|
|
|
} finally { |
|
|
|
this.finishCallback.callback(this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -123,17 +136,23 @@ public class DigestionTaskThread extends Thread { |
|
|
|
var device = Device.getInstance(); |
|
|
|
|
|
|
|
// 分配加热位 |
|
|
|
this.heatingSlot = device.heatingTurntable.allocSlot(this.taskModel.batchNo); |
|
|
|
if ( "manual".equals(this.taskModel.mode) ) { |
|
|
|
this.heatingSlot = device.heatingTurntable.getSlotByIndex(this.taskModel.heatingSlotIndex); |
|
|
|
} else { |
|
|
|
this.heatingSlot = device.heatingTurntable.allocSlot(this.taskModel.batchNo); |
|
|
|
} |
|
|
|
this.heatingSlot.setTubes(this.taskModel.getTubes()); |
|
|
|
this.taskModel.heatingSlotIndex = this.heatingSlot.index; |
|
|
|
this.taskModel.save(); |
|
|
|
|
|
|
|
// 打开门 |
|
|
|
device.door.open(); |
|
|
|
// 等待放入试管架 |
|
|
|
this.waitForTubeRackPutIn(false); |
|
|
|
// 关闭门 |
|
|
|
device.door.close(); |
|
|
|
if ( "auto".equals(this.taskModel.mode) ) { |
|
|
|
// 打开门 |
|
|
|
device.door.open(); |
|
|
|
// 等待放入试管架 |
|
|
|
this.waitForTubeRackPutIn(); |
|
|
|
// 关闭门 |
|
|
|
device.door.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 检查试管 |
|
|
@ -171,7 +190,7 @@ public class DigestionTaskThread extends Thread { |
|
|
|
if ( !this.errorTubeIndexes.isEmpty() ) { |
|
|
|
var device = Device.getInstance(); |
|
|
|
// 等待放入空试管架 |
|
|
|
this.waitForTubeRackPutIn(true); |
|
|
|
this.waitForEmptyTubeRackPutIn(); |
|
|
|
// 取出剩余异常试管 |
|
|
|
device.transferArm.takeOutTubesFromErrorSlot(this.errorTubeIndexes); |
|
|
|
// 等待取出试管架 |
|
|
@ -268,17 +287,19 @@ public class DigestionTaskThread extends Thread { |
|
|
|
device.liquidAddition.addLiquidToTubes(this.heatingSlot.getExistTubeIndexes(), "water", digestionRound.waterVolume); |
|
|
|
} |
|
|
|
|
|
|
|
// 正常消解结束 |
|
|
|
// 移动到加液盘 |
|
|
|
device.transferArm.moveTubeRackToLiquidPlate(this.heatingSlot.index); |
|
|
|
// 打开门 |
|
|
|
device.door.open(); |
|
|
|
// 等待取出 |
|
|
|
this.waitForTubeRackTakeOut(); |
|
|
|
// 关闭门 |
|
|
|
device.door.close(); |
|
|
|
// 释放加热位 |
|
|
|
this.heatingSlot.setTubeRackNo(null); |
|
|
|
// 正常消解结束; |
|
|
|
if ( "auto".equals(this.taskModel.mode) ) { |
|
|
|
// 移动到加液盘 |
|
|
|
device.transferArm.moveTubeRackToLiquidPlate(this.heatingSlot.index); |
|
|
|
// 打开门 |
|
|
|
device.door.open(); |
|
|
|
// 等待取出 |
|
|
|
this.waitForTubeRackTakeOut(); |
|
|
|
// 关闭门 |
|
|
|
device.door.close(); |
|
|
|
// 释放加热位 |
|
|
|
this.heatingSlot.setTubeRackNo(null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 执行消解异常处理配置 |
|
|
@ -311,7 +332,7 @@ public class DigestionTaskThread extends Thread { |
|
|
|
// 将试管架放入异常处理区域 |
|
|
|
device.transferArm.moveTubeRackToHeatingTurntable(this.heatingSlot.index); |
|
|
|
// 等待放入空试管架 |
|
|
|
this.waitForTubeRackPutIn(true); |
|
|
|
this.waitForEmptyTubeRackPutIn(); |
|
|
|
// 取出消解完成的试管 |
|
|
|
device.transferArm.takeOutTubesFromErrorSlot(this.finishedErrorTubeIndexes); |
|
|
|
// 等待取出试管架 |
|
|
@ -321,14 +342,37 @@ public class DigestionTaskThread extends Thread { |
|
|
|
} |
|
|
|
|
|
|
|
// 等待放入试管架 |
|
|
|
private void waitForTubeRackPutIn( Boolean requestEmptyTubeRack ) { |
|
|
|
if ( requestEmptyTubeRack ) { |
|
|
|
this.manager.sendMessageToTransBot("EmptyTubeRackPutIn", Map.of("batchNo", this.taskModel.batchNo)); |
|
|
|
private void waitForTubeRackPutIn() { |
|
|
|
this.updateTaskStatus("TubeRackPutInWait", "等待放入试管架"); |
|
|
|
|
|
|
|
// 发送放入试管架消息 |
|
|
|
Map<String,Object> message = Map.of("batchNo", this.taskModel.batchNo, "taskId", this.taskModel.outTaskId); |
|
|
|
this.manager.sendMessageToTransBot("TubeRackPutIn", message); |
|
|
|
|
|
|
|
// 等待试管架放入完成 |
|
|
|
synchronized ( this.tubeRackPutInWaitLock ) { |
|
|
|
try { |
|
|
|
this.tubeRackPutInWaitLock.wait(); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
this.updateTaskStatus("TubeRackPutInWaitDone", "试管架已放入"); |
|
|
|
} |
|
|
|
|
|
|
|
// 等待放入试管架 |
|
|
|
private void waitForEmptyTubeRackPutIn() { |
|
|
|
this.updateTaskStatus("TubeRackPutInWait", "等待放入空试管架"); |
|
|
|
|
|
|
|
// 发送放入试管架消息 |
|
|
|
Map<String,Object> message = Map.of("batchNo", this.taskModel.batchNo, "taskId", this.taskModel.outTaskId); |
|
|
|
if ( "auto".equals(this.taskModel.mode) ) { |
|
|
|
this.manager.sendMessageToTransBot("EmptyTubeRackPutIn", message); |
|
|
|
} else { |
|
|
|
this.manager.sendMessageToTransBot("TubeRackPutIn", Map.of("batchNo", this.taskModel.batchNo)); |
|
|
|
UfMdbNotification.action("EmptyTubeRackPutIn", message); |
|
|
|
} |
|
|
|
|
|
|
|
this.updateTaskStatus("TubeRackPutInWait", "等待放入试管架"); |
|
|
|
// 等待试管架放入完成 |
|
|
|
synchronized ( this.tubeRackPutInWaitLock ) { |
|
|
|
try { |
|
|
|
this.tubeRackPutInWaitLock.wait(); |
|
|
@ -341,8 +385,15 @@ public class DigestionTaskThread extends Thread { |
|
|
|
|
|
|
|
// 等待取出试管架 |
|
|
|
private void waitForTubeRackTakeOut() { |
|
|
|
this.manager.sendMessageToTransBot("TubeRackTakeOut", Map.of("batchNo", this.taskModel.batchNo)); |
|
|
|
this.updateTaskStatus("TubeRackTakeOutWait", "等待取出试管架"); |
|
|
|
|
|
|
|
Map<String,Object> message = Map.of("batchNo", this.taskModel.batchNo, "taskId", this.taskModel.outTaskId); |
|
|
|
if ( "auto".equals(this.taskModel.mode) ) { |
|
|
|
this.manager.sendMessageToTransBot("TubeRackTakeOut", message); |
|
|
|
} else { |
|
|
|
UfMdbNotification.action("TubeRackTakeOut", message); |
|
|
|
} |
|
|
|
|
|
|
|
synchronized ( this.tubeRackTakeOutWaitLock ) { |
|
|
|
try { |
|
|
|
this.tubeRackTakeOutWaitLock.wait(); |
|
|
@ -356,6 +407,9 @@ public class DigestionTaskThread extends Thread { |
|
|
|
// 拍照检查试管 |
|
|
|
private void takeShotAndCheckErrorTubes() { |
|
|
|
this.updateTaskStatus("TubeCheck", "拍照检查试管,等待确认异常试管"); |
|
|
|
Map<String,Object> message = Map.of("batchNo", this.taskModel.batchNo, "taskId", this.taskModel.outTaskId); |
|
|
|
UfMdbNotification.action("TubeCheck", message); |
|
|
|
|
|
|
|
this.errorTubeIndexes.clear(); |
|
|
|
synchronized ( this.errorTubeIndexes ) { |
|
|
|
try { |
|
|
@ -370,6 +424,9 @@ public class DigestionTaskThread extends Thread { |
|
|
|
// 拍照检查试管 |
|
|
|
private void takeShotAndCheckFinishedTubes() { |
|
|
|
this.updateTaskStatus("ErrorTubeCheck", "拍照检查异常试管,等待确认完成试管"); |
|
|
|
Map<String,Object> message = Map.of("batchNo", this.taskModel.batchNo, "taskId", this.taskModel.outTaskId); |
|
|
|
UfMdbNotification.action("ErrorTubeCheck", message); |
|
|
|
|
|
|
|
this.finishedErrorTubeIndexes.clear(); |
|
|
|
synchronized ( this.finishedErrorTubeIndexes ) { |
|
|
|
try { |
|
|
|