|
@ -3,48 +3,50 @@ import com.my.graphiteDigesterBg.MyDevice; |
|
|
import com.my.graphiteDigesterBg.diframe.DiTaskBase; |
|
|
import com.my.graphiteDigesterBg.diframe.DiTaskBase; |
|
|
import com.my.graphiteDigesterBg.diframe.Task; |
|
|
import com.my.graphiteDigesterBg.diframe.Task; |
|
|
import com.my.graphiteDigesterBg.diframe.actuator.DiActMotor; |
|
|
import com.my.graphiteDigesterBg.diframe.actuator.DiActMotor; |
|
|
|
|
|
import com.my.graphiteDigesterBg.diframe.model.DiMdbNotification; |
|
|
import com.my.graphiteDigesterBg.model.MdbOperationLog; |
|
|
import com.my.graphiteDigesterBg.model.MdbOperationLog; |
|
|
import com.my.graphiteDigesterBg.move.MoveMoveTubeRackFromHeatPlateToLiquidPlate; |
|
|
import com.my.graphiteDigesterBg.move.MoveMoveTubeRackFromHeatPlateToLiquidPlate; |
|
|
|
|
|
import com.my.graphiteDigesterBg.resource.ResHeatingTubeRackSlot; |
|
|
import com.my.graphiteDigesterBg.resource.ResHeatingTubeRackSlotManager; |
|
|
import com.my.graphiteDigesterBg.resource.ResHeatingTubeRackSlotManager; |
|
|
@Task(name="SampleTakeOut") |
|
|
@Task(name="SampleTakeOut") |
|
|
public class TaskSampleTakeOut extends DiTaskBase { |
|
|
public class TaskSampleTakeOut extends DiTaskBase { |
|
|
// slot index |
|
|
// slot index |
|
|
public Integer slotIndex; |
|
|
public Integer slotIndex; |
|
|
// done lock |
|
|
|
|
|
private final Object confirmLock = new Object(); |
|
|
|
|
|
|
|
|
// slot |
|
|
|
|
|
private ResHeatingTubeRackSlot slot; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
protected void execute() { |
|
|
|
|
|
this.setStatus(TaskStatus.RUNNING); |
|
|
|
|
|
MdbOperationLog.log(this.getUser(), "试管架%d : 取出样本", this.slotIndex); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void prepare() { |
|
|
var slotMan = this.getResourceManager(ResHeatingTubeRackSlotManager.class); |
|
|
var slotMan = this.getResourceManager(ResHeatingTubeRackSlotManager.class); |
|
|
var slot = slotMan.getSlotByIndex(this.slotIndex); |
|
|
|
|
|
|
|
|
|
|
|
if ( !slot.getIsLocked() ) { |
|
|
|
|
|
|
|
|
this.slot = slotMan.getSlotByIndex(this.slotIndex); |
|
|
|
|
|
if ( !this.slot.getIsLocked() ) { |
|
|
throw new RuntimeException("试管架位为空,无法取出样本"); |
|
|
throw new RuntimeException("试管架位为空,无法取出样本"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if ( slot.isHeating ) { |
|
|
|
|
|
|
|
|
if ( this.slot.isHeating ) { |
|
|
throw new RuntimeException("试管架正在加热中,无法取出样本"); |
|
|
throw new RuntimeException("试管架正在加热中,无法取出样本"); |
|
|
} |
|
|
} |
|
|
|
|
|
MdbOperationLog.log(this.getUser(), "试管架%d : 取出样本", this.slotIndex); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if ( slot.rackPosition.equals("LiquidPlate") ) { |
|
|
|
|
|
throw new RuntimeException("试管架未复位到加热盘,无法取出样本"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected void execute() { |
|
|
|
|
|
this.setStatus(TaskStatus.RUNNING); |
|
|
|
|
|
|
|
|
// 从加热盘移动到液体盘 |
|
|
|
|
|
var moveTubeRackFromHeatPlateToLiquidPlate = new MoveMoveTubeRackFromHeatPlateToLiquidPlate(); |
|
|
|
|
|
moveTubeRackFromHeatPlateToLiquidPlate.slotIndex = this.slotIndex; |
|
|
|
|
|
moveTubeRackFromHeatPlateToLiquidPlate.setDevice(this.getDevice()); |
|
|
|
|
|
moveTubeRackFromHeatPlateToLiquidPlate.run(); |
|
|
|
|
|
|
|
|
if ( this.slot.rackPosition.equals(ResHeatingTubeRackSlot.LOCATION_HEAT_PLATE) ) { |
|
|
|
|
|
// 从加热盘移动到液体盘 |
|
|
|
|
|
var moveTubeRackFromHeatPlateToLiquidPlate = new MoveMoveTubeRackFromHeatPlateToLiquidPlate(); |
|
|
|
|
|
moveTubeRackFromHeatPlateToLiquidPlate.slotIndex = this.slotIndex; |
|
|
|
|
|
moveTubeRackFromHeatPlateToLiquidPlate.setDevice(this.getDevice()); |
|
|
|
|
|
moveTubeRackFromHeatPlateToLiquidPlate.run(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 打开设备门 |
|
|
// 打开设备门 |
|
|
DiActMotor doorMotor = this.getActuator(MyDevice.ACT_DOOR_MOTOR, DiActMotor.class); |
|
|
DiActMotor doorMotor = this.getActuator(MyDevice.ACT_DOOR_MOTOR, DiActMotor.class); |
|
|
doorMotor.reset(); |
|
|
doorMotor.reset(); |
|
|
|
|
|
|
|
|
// 等待用户取出确认 |
|
|
// 等待用户取出确认 |
|
|
this.waitForUserTakeOutConfirm(); |
|
|
|
|
|
|
|
|
DiMdbNotification.taskAction(this, "TaskSampleTakeOutTubeRack"); |
|
|
|
|
|
this.waitAction("TaskSampleTakeOutTubeRack"); |
|
|
|
|
|
|
|
|
// 关闭设备门 |
|
|
// 关闭设备门 |
|
|
doorMotor.moveToIO(1, 1); |
|
|
doorMotor.moveToIO(1, 1); |
|
@ -53,23 +55,9 @@ public class TaskSampleTakeOut extends DiTaskBase { |
|
|
this.setStatus(TaskStatus.FINISHED); |
|
|
this.setStatus(TaskStatus.FINISHED); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// wait for user action |
|
|
|
|
|
private void waitForUserTakeOutConfirm() { |
|
|
|
|
|
this.setRuntimeStatus("WAIT_FOR_TAKING_CONFIRM"); |
|
|
|
|
|
synchronized (this.confirmLock) { |
|
|
|
|
|
try { |
|
|
|
|
|
this.confirmLock.wait(); |
|
|
|
|
|
} catch (InterruptedException e) { |
|
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
this.clearRuntimeStatus(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// tube rack take out confirm |
|
|
// tube rack take out confirm |
|
|
public void done() { |
|
|
|
|
|
synchronized (this.confirmLock) { |
|
|
|
|
|
this.confirmLock.notifyAll(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public void actionDone() { |
|
|
|
|
|
var action = this.getAction("TaskSampleTakeOutTubeRack"); |
|
|
|
|
|
action.finish(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |