|
|
@ -8,17 +8,88 @@ import com.my.graphiteDigesterBg.resource.ResHeatingTubeRackSlot; |
|
|
|
import com.my.graphiteDigesterBg.resource.ResHeatingTubeRackSlotManager; |
|
|
|
@Task(name="SampleAdd") |
|
|
|
public class TaskSampleAdd extends DiTaskBase { |
|
|
|
// done lock |
|
|
|
private final Object doneLock = new Object(); |
|
|
|
// add status |
|
|
|
private String addStatus = "waiting"; |
|
|
|
|
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
DiActMotor transLrMotor = this.getActuator(MyDevice.ACT_TRANSFER_LR_MOTOR, DiActMotor.class); |
|
|
|
DiActMotor transUdMotor = this.getActuator(MyDevice.ACT_TRANSFER_UD_MOTOR, DiActMotor.class); |
|
|
|
DiActServo transferClipServo = (DiActServo)this.getActuator(MyDevice.ACT_TRANSFER_CLIP_SERVO); |
|
|
|
DiActMotor liquidPlateMotor = this.getActuator(MyDevice.ACT_LIQUID_PLATE_MOTOR, DiActMotor.class); |
|
|
|
DiActMotor heatPlateMotor = (DiActMotor)this.getActuator(MyDevice.ACT_HEAT_PLATE_MOTOR); |
|
|
|
|
|
|
|
ResHeatingTubeRackSlotManager slotMan = this.getResourceManager(ResHeatingTubeRackSlotManager.class); |
|
|
|
ResHeatingTubeRackSlot slot = slotMan.allocFreeSlot(); |
|
|
|
|
|
|
|
DiActMotor heatPlateMotor = (DiActMotor)this.getActuator(MyDevice.ACT_HEAT_PLATE_MOTOR); |
|
|
|
heatPlateMotor.moveTo(slot.getOperationWindowLocation()); |
|
|
|
|
|
|
|
DiActServo coverServo = (DiActServo)this.getActuator(MyDevice.ACT_HEAT_SLOT_01_COVER_SERVO); |
|
|
|
coverServo.moveTo(1000); |
|
|
|
// 搬运上升到顶部 |
|
|
|
transUdMotor.moveTo(1300); |
|
|
|
// 搬运机械臂移动到就绪位置 |
|
|
|
transLrMotor.moveTo(1000); |
|
|
|
// 加液转盘移动到就添加位置 |
|
|
|
liquidPlateMotor.moveTo(200); |
|
|
|
// 等待用户添加完成 |
|
|
|
this.waitForUserAction(); |
|
|
|
if ( "canceled".equals(this.addStatus) ) { |
|
|
|
slot.unlock(); |
|
|
|
this.setStatus(TaskStatus.FINISHED); |
|
|
|
} |
|
|
|
// 加液转盘移动到取架位置 |
|
|
|
liquidPlateMotor.moveTo(642); |
|
|
|
// 搬运移动到加液取放架位置 |
|
|
|
transLrMotor.moveTo(365); |
|
|
|
// 搬运下降到取架位置 |
|
|
|
transUdMotor.moveTo(540); |
|
|
|
// 张开试管架夹爪 |
|
|
|
transferClipServo.moveTo(2670); |
|
|
|
// 搬运上升到顶部 |
|
|
|
transUdMotor.moveTo(1300); |
|
|
|
// 加热转盘移动到取放架位置 |
|
|
|
heatPlateMotor.moveTo(8580); |
|
|
|
// 打开试管架盖 |
|
|
|
slot.coverOpen(); |
|
|
|
// 搬运移动到加热盘取放位置 |
|
|
|
transLrMotor.moveTo(1650); |
|
|
|
// 搬运下降到放架位置 |
|
|
|
transUdMotor.moveTo(150); |
|
|
|
// 关闭试管架夹爪 |
|
|
|
transferClipServo.moveTo(2073); |
|
|
|
// 搬运上升到顶部 |
|
|
|
transUdMotor.moveTo(1300); |
|
|
|
// 搬运移动到绪位置 |
|
|
|
transLrMotor.moveTo(1000); |
|
|
|
// 试管架盖关闭 |
|
|
|
slot.coverClose(); |
|
|
|
|
|
|
|
this.setStatus(TaskStatus.FINISHED); |
|
|
|
} |
|
|
|
|
|
|
|
// wait for user action |
|
|
|
private void waitForUserAction() { |
|
|
|
synchronized (this.doneLock) { |
|
|
|
try { |
|
|
|
this.doneLock.wait(); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 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(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |