|
|
@ -3,21 +3,27 @@ import com.my.graphiteDigesterBg.MyDevice; |
|
|
|
import com.my.graphiteDigesterBg.diframe.DiTaskBase; |
|
|
|
import com.my.graphiteDigesterBg.diframe.Task; |
|
|
|
import com.my.graphiteDigesterBg.diframe.actuator.DiActMotor; |
|
|
|
import com.my.graphiteDigesterBg.diframe.model.DiMdbNotification; |
|
|
|
import com.my.graphiteDigesterBg.model.MdbDigestion; |
|
|
|
import com.my.graphiteDigesterBg.model.MdbOperationLog; |
|
|
|
import com.my.graphiteDigesterBg.move.MoveMoveTubeRackFromLiquidPlateToHeatPlate; |
|
|
|
import com.my.graphiteDigesterBg.resource.ResHeatingTubeRackSlot; |
|
|
|
import com.my.graphiteDigesterBg.resource.ResHeatingTubeRackSlotManager; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
@Task(name="SampleAdd") |
|
|
|
public class TaskSampleAdd extends DiTaskBase { |
|
|
|
// done lock |
|
|
|
private final Object doneLock = new Object(); |
|
|
|
// add status |
|
|
|
private String addStatus = "waiting"; |
|
|
|
// param : eid |
|
|
|
public String eid; |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void execute() { |
|
|
|
this.setStatus(TaskStatus.RUNNING); |
|
|
|
|
|
|
|
var digestion = new MdbDigestion(); |
|
|
|
digestion.eid = this.eid; |
|
|
|
digestion.save(); |
|
|
|
|
|
|
|
ResHeatingTubeRackSlotManager slotMan = this.getResourceManager(ResHeatingTubeRackSlotManager.class); |
|
|
|
ResHeatingTubeRackSlot slot = slotMan.allocFreeSlot(); |
|
|
|
MdbOperationLog.log(this.getUser(), "试管架%d : 放入样本", slot.index); |
|
|
@ -35,50 +41,48 @@ public class TaskSampleAdd extends DiTaskBase { |
|
|
|
transLrMotor.moveTo("TransLrMotorStandby"); |
|
|
|
// 加液转盘移动到就添加位置 |
|
|
|
liquidPlateMotor.moveTo("LiquidPlatePlaceTubeRack"); |
|
|
|
// 等待用户添加完成 |
|
|
|
this.waitForUserAction(); |
|
|
|
|
|
|
|
// 等待用户放置样本 |
|
|
|
DiMdbNotification.taskAction(this, "TaskSampleAddTubeRackPutIn"); |
|
|
|
var putinAction = this.waitAction("TaskSampleAddTubeRackPutIn"); |
|
|
|
var putinActionResult = putinAction.getResult(String.class); |
|
|
|
// 关闭设备门 |
|
|
|
doorMotor.moveToIO(1, 1); |
|
|
|
if ( "canceled".equals(this.addStatus) ) { |
|
|
|
if ( "canceled".equals(putinActionResult) ) { |
|
|
|
slot.unlock(); |
|
|
|
this.setStatus(TaskStatus.FINISHED); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
var moveMoveTubeRackFromLiquidPlateToHeatPlate = new MoveMoveTubeRackFromLiquidPlateToHeatPlate(); |
|
|
|
moveMoveTubeRackFromLiquidPlateToHeatPlate.slotIndex = slot.index; |
|
|
|
moveMoveTubeRackFromLiquidPlateToHeatPlate.setDevice(this.getDevice()); |
|
|
|
moveMoveTubeRackFromLiquidPlateToHeatPlate.run(); |
|
|
|
// 初始化试管架状态 |
|
|
|
for ( int i=0; i<16; i++ ) { |
|
|
|
slot.setTubeStatus(i, ResHeatingTubeRackSlot.TUBE_STATUS_USED); |
|
|
|
} |
|
|
|
// 移动加液盘到观察视角 |
|
|
|
liquidPlateMotor.moveTo("LiquidPlateCameraShot"); |
|
|
|
// 等待试管状态确认 |
|
|
|
DiMdbNotification.taskAction(this, "TaskSampleAddTubeRackStatusConfirm"); |
|
|
|
var statusConfirmAction = this.waitAction("TaskSampleAddTubeRackStatusConfirm"); |
|
|
|
var tubeRackEmptyList = statusConfirmAction.getResult(List.class); |
|
|
|
for ( var item : tubeRackEmptyList ) { |
|
|
|
Integer index = (Integer)item; |
|
|
|
slot.setTubeStatus(index, ResHeatingTubeRackSlot.TUBE_STATUS_EMPTY); |
|
|
|
} |
|
|
|
|
|
|
|
slot.rackPosition = ResHeatingTubeRackSlot.LOCATION_LIQUID_PLATE; |
|
|
|
this.setStatus(TaskStatus.FINISHED); |
|
|
|
} |
|
|
|
|
|
|
|
// wait for user action |
|
|
|
private void waitForUserAction() { |
|
|
|
this.setRuntimeStatus("WAIT_FOR_PUTTING_CONFIRM"); |
|
|
|
synchronized (this.doneLock) { |
|
|
|
try { |
|
|
|
this.doneLock.wait(); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
this.clearRuntimeStatus(); |
|
|
|
// 放置试管架确认 |
|
|
|
public void actionPutInConfirm( Map<String, Object> params ) { |
|
|
|
String result = (String)params.get("result"); |
|
|
|
var action = this.getAction("TaskSampleAddTubeRackPutIn"); |
|
|
|
action.finish(result); |
|
|
|
} |
|
|
|
|
|
|
|
// close cover |
|
|
|
public void done() { |
|
|
|
this.addStatus = "done"; |
|
|
|
synchronized (this.doneLock) { |
|
|
|
this.doneLock.notifyAll(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// cancel |
|
|
|
public void cancel() { |
|
|
|
this.addStatus = "canceled"; |
|
|
|
synchronized (this.doneLock) { |
|
|
|
this.doneLock.notifyAll(); |
|
|
|
} |
|
|
|
// 试管架空位确认 |
|
|
|
public void actionTubeStatusConfirm( Map<String, Object> params ) { |
|
|
|
var action = this.getAction("TaskSampleAddTubeRackStatusConfirm"); |
|
|
|
action.finish(params.get("emptyList")); |
|
|
|
} |
|
|
|
} |