1 changed files with 49 additions and 2 deletions
@ -1,28 +1,75 @@ |
|||||
package com.my.graphiteDigesterBg.task; |
package com.my.graphiteDigesterBg.task; |
||||
|
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.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.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(); |
||||
|
|
||||
@Override |
@Override |
||||
public void run() { |
|
||||
|
protected void execute() { |
||||
|
this.setStatus(TaskStatus.RUNNING); |
||||
MdbOperationLog.log(this.getUser(), "试管架%d : 取出样本", this.slotIndex); |
MdbOperationLog.log(this.getUser(), "试管架%d : 取出样本", this.slotIndex); |
||||
|
|
||||
var slotMan = this.getResourceManager(ResHeatingTubeRackSlotManager.class); |
var slotMan = this.getResourceManager(ResHeatingTubeRackSlotManager.class); |
||||
var slot = slotMan.getSlotByIndex(this.slotIndex); |
var slot = slotMan.getSlotByIndex(this.slotIndex); |
||||
|
|
||||
|
if ( !slot.getIsLocked() ) { |
||||
|
throw new RuntimeException("试管架位为空,无法取出样本"); |
||||
|
} |
||||
|
|
||||
|
if ( slot.isHeating ) { |
||||
|
throw new RuntimeException("试管架正在加热中,无法取出样本"); |
||||
|
} |
||||
|
|
||||
|
if ( slot.rackPosition.equals("LiquidPlate") ) { |
||||
|
throw new RuntimeException("试管架未复位到加热盘,无法取出样本"); |
||||
|
} |
||||
|
|
||||
|
// 从加热盘移动到液体盘 |
||||
var moveTubeRackFromHeatPlateToLiquidPlate = new MoveMoveTubeRackFromHeatPlateToLiquidPlate(); |
var moveTubeRackFromHeatPlateToLiquidPlate = new MoveMoveTubeRackFromHeatPlateToLiquidPlate(); |
||||
moveTubeRackFromHeatPlateToLiquidPlate.slotIndex = this.slotIndex; |
moveTubeRackFromHeatPlateToLiquidPlate.slotIndex = this.slotIndex; |
||||
moveTubeRackFromHeatPlateToLiquidPlate.setDevice(this.getDevice()); |
moveTubeRackFromHeatPlateToLiquidPlate.setDevice(this.getDevice()); |
||||
moveTubeRackFromHeatPlateToLiquidPlate.run(); |
moveTubeRackFromHeatPlateToLiquidPlate.run(); |
||||
|
|
||||
|
// 打开设备门 |
||||
|
DiActMotor doorMotor = this.getActuator(MyDevice.ACT_DOOR_MOTOR, DiActMotor.class); |
||||
|
doorMotor.reset(); |
||||
|
|
||||
|
// 等待用户取出确认 |
||||
|
this.waitForUserTakeOutConfirm(); |
||||
|
|
||||
|
// 关闭设备门 |
||||
|
doorMotor.moveToIO(1, 1); |
||||
|
|
||||
slot.unlock(); |
slot.unlock(); |
||||
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 |
||||
|
public void done() { |
||||
|
synchronized (this.confirmLock) { |
||||
|
this.confirmLock.notifyAll(); |
||||
|
} |
||||
|
} |
||||
} |
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue