|
|
@ -6,9 +6,9 @@ import com.iflytop.digester.underframework.dao.model.UfMdbNotification; |
|
|
|
import com.iflytop.digester.underframework.dao.record.UfActiveRecord; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
public class DigestionTaskThread extends Thread { |
|
|
|
// 任务完成回调 |
|
|
|
public interface FinishCallback { |
|
|
@ -37,6 +37,10 @@ public class DigestionTaskThread extends Thread { |
|
|
|
private FinishCallback finishCallback; |
|
|
|
// 消解任务管理器 |
|
|
|
private DigestionTaskTheadManager manager; |
|
|
|
// 预检查是否完成 |
|
|
|
private Boolean isPrecheckFinished; |
|
|
|
// 预检查锁 |
|
|
|
private final Object precheckLock = new Object(); |
|
|
|
|
|
|
|
// 消解任务 |
|
|
|
public DigestionTaskThread(MdbDigestionTask taskModel) { |
|
|
@ -101,13 +105,7 @@ public class DigestionTaskThread extends Thread { |
|
|
|
this.executeRound(round); |
|
|
|
} |
|
|
|
// 执行最后一轮 |
|
|
|
this.executeRound(lastRound); |
|
|
|
// 检查试管 |
|
|
|
this.tubeCheck(); |
|
|
|
// 启动异常处理线程 |
|
|
|
this.startErrorProcessThread(); |
|
|
|
// 消解结束 |
|
|
|
this.finish(); |
|
|
|
this.executeLastRound(lastRound); |
|
|
|
|
|
|
|
this.errorProcessThread.join(); |
|
|
|
this.updateTaskStatus("Finish", "消解任务结束"); |
|
|
@ -138,26 +136,8 @@ public class DigestionTaskThread extends Thread { |
|
|
|
device.door.close(); |
|
|
|
} |
|
|
|
|
|
|
|
// 消解结束 |
|
|
|
private void finish() { |
|
|
|
var device = Device.getInstance(); |
|
|
|
|
|
|
|
// 余温加热 |
|
|
|
this.heatingSlot.heating(100, 10); |
|
|
|
// 移动到加液盘 |
|
|
|
device.transferArm.moveTubeRackToLiquidPlate(this.heatingSlot.index); |
|
|
|
// 打开门 |
|
|
|
device.door.open(); |
|
|
|
// 等待取出 |
|
|
|
this.waitForTubeRackTakeOut(); |
|
|
|
// 关闭门 |
|
|
|
device.door.close(); |
|
|
|
// 释放加热位 |
|
|
|
this.heatingSlot.setTubeRackNo(null); |
|
|
|
} |
|
|
|
|
|
|
|
// 检查试管 |
|
|
|
private void tubeCheck() throws InterruptedException { |
|
|
|
private void tubeCheckAndMove() throws InterruptedException { |
|
|
|
var device = Device.getInstance(); |
|
|
|
// 移动到加液盘 |
|
|
|
device.transferArm.moveTubeRackToLiquidPlate(this.heatingSlot.index); |
|
|
@ -230,6 +210,77 @@ public class DigestionTaskThread extends Thread { |
|
|
|
device.transferArm.moveTubeRackToLiquidPlate(this.heatingSlot.index); |
|
|
|
} |
|
|
|
|
|
|
|
// 执行消解最后一轮配置 |
|
|
|
private void executeLastRound( MdbDigestionSolution.DigestionSolutionRound digestionRound ) throws InterruptedException { |
|
|
|
this.isPrecheckFinished = false; |
|
|
|
var device = Device.getInstance(); |
|
|
|
|
|
|
|
// 预检查定时, 在结束前10分钟执行 |
|
|
|
Integer totalDurationCount = 0; |
|
|
|
for ( var heating : digestionRound.heatings ) { |
|
|
|
totalDurationCount += heating.duration; |
|
|
|
} |
|
|
|
long preCheckDuration = totalDurationCount - 10; |
|
|
|
if ( 0 >= preCheckDuration ) { |
|
|
|
preCheckDuration = 0; |
|
|
|
} |
|
|
|
var preCheckTimerTask = new TimerTask() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
try { |
|
|
|
// 检查试管 |
|
|
|
DigestionTaskThread.this.tubeCheckAndMove(); |
|
|
|
// 启动异常处理线程 |
|
|
|
DigestionTaskThread.this.startErrorProcessThread(); |
|
|
|
// 预检查完成 |
|
|
|
DigestionTaskThread.this.isPrecheckFinished = true; |
|
|
|
synchronized ( DigestionTaskThread.this.precheckLock ) { |
|
|
|
DigestionTaskThread.this.precheckLock.notifyAll(); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
var preCheckTimer = new Timer(); |
|
|
|
preCheckTimer.schedule(preCheckTimerTask, preCheckDuration * 60 * 1000); |
|
|
|
|
|
|
|
// 加热 |
|
|
|
for ( var heating : digestionRound.heatings ) { |
|
|
|
this.updateTaskStatus("heating", String.format("加热 %d℃ %d分钟", heating.temperature, heating.duration)); |
|
|
|
this.heatingSlot.heating(heating.temperature, heating.duration); |
|
|
|
} |
|
|
|
|
|
|
|
// 等待预检查完成 |
|
|
|
if ( !this.isPrecheckFinished ) { |
|
|
|
this.updateTaskStatus("PreCheckWait", "等待预检完成"); |
|
|
|
synchronized ( this.precheckLock ) { |
|
|
|
try { |
|
|
|
this.precheckLock.wait(); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 加水定容 |
|
|
|
if ( 0 < digestionRound.waterVolume ) { |
|
|
|
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); |
|
|
|
} |
|
|
|
|
|
|
|
// 执行消解异常处理配置 |
|
|
|
private void executeErrorRound( MdbDigestionSolution.DigestionSolutionErrorRound errorRound ) throws InterruptedException { |
|
|
|
var device = Device.getInstance(); |
|
|
|