Browse Source

孵育盘卡位资源等待

master
sige 2 years ago
parent
commit
b190130b59
  1. 24
      src/main/java/com/dreamworks/boditech/driver/actuator/ActIncubator.java
  2. 22
      src/main/java/com/dreamworks/boditech/driver/task/Executor.java
  3. 2
      src/main/java/com/dreamworks/boditech/driver/task/TaskStartReset.java
  4. 27
      src/main/java/com/dreamworks/boditech/driver/task/TaskTestBase.java
  5. 1
      src/main/java/com/dreamworks/boditech/driver/task/step/StepAnalysis.java
  6. 4
      src/main/java/com/dreamworks/boditech/utils/AppExceptionHandler.java

24
src/main/java/com/dreamworks/boditech/driver/actuator/ActIncubator.java

@ -5,6 +5,10 @@ import com.dreamworks.boditech.utils.AppError;
import com.dreamworks.boditech.utils.AppRuntimeException;
import com.dreamworks.boditech.utils.MyCommon;
public class ActIncubator extends ActMotor {
// init exit slot index
public static final Integer INIT_EXIT_SLOT_INDEX = 10;
// incubator slot count
public static final Integer SLOT_COUNT = 20;
// slots
private final IncubatorSlot[] slots;
// alloc index
@ -15,8 +19,8 @@ public class ActIncubator extends ActMotor {
super(mid, device);
this.allocStartIndex = 0;
this.slots = new IncubatorSlot[20];
for ( int i = 0; i < 20; i++ ) {
this.slots = new IncubatorSlot[ActIncubator.SLOT_COUNT];
for ( int i = 0; i < ActIncubator.SLOT_COUNT; i++ ) {
IncubatorSlot slot = new IncubatorSlot(this);
slot.index = i;
slot.isFree = true;
@ -36,9 +40,9 @@ public class ActIncubator extends ActMotor {
// get free slot
public IncubatorSlot allocSlot() {
for ( int i = this.allocStartIndex; i < 20; i++ ) {
for ( int i = this.allocStartIndex; i < ActIncubator.SLOT_COUNT; i++ ) {
if ( this.slots[i].isFree ) {
this.allocStartIndex = (i + 1) % 20;
this.allocStartIndex = (i + 1) % ActIncubator.SLOT_COUNT;
return this.slots[i];
}
}
@ -59,7 +63,7 @@ public class ActIncubator extends ActMotor {
// has locked slot
public Boolean hasLockedSlot() {
for ( int i = 0; i < 20; i++ ) {
for ( int i = 0; i < ActIncubator.SLOT_COUNT; i++ ) {
if ( !this.slots[i].isFree ) {
return true;
}
@ -67,6 +71,16 @@ public class ActIncubator extends ActMotor {
return false;
}
// has free slot
public Boolean hasFreeSlot() {
for ( int i = 0; i < ActIncubator.SLOT_COUNT; i++ ) {
if ( this.slots[i].isFree ) {
return true;
}
}
return false;
}
// update runtime slot status
private void updateRuntimeSlotStatus() {
this.getDevice().runtimeVariableService.setString(

22
src/main/java/com/dreamworks/boditech/driver/task/Executor.java

@ -29,6 +29,8 @@ public class Executor implements Runnable {
private final Object statusLock = new Object();
// working status
public String workingStatus = "WAIT_FOR_TUBE_RACK";
// incubator wait task
private Task incubatorWaitTask = null;
/**
* execute single task on device
@ -225,4 +227,24 @@ public class Executor implements Runnable {
public Device getDevice() {
return this.device;
}
// wait for incubator slot
public void waitForIncubatorSlot( Task task ) {
LOG.info("task executor wait for incubator slot");
this.status = Executor.STATUS_PAUSED;
this.incubatorWaitTask = task;
}
// incubator slot available
public void incubatorSlotAvailable() {
if ( null == this.incubatorWaitTask ) {
return ;
}
LOG.info("task executor incubator slot available");
this.status = Executor.STATUS_RUNNING;
this.incubatorWaitTask.setStatus(Task.STATUS_READY);
this.incubatorWaitTask = null;
}
// public void waitForConsumable( Task task );
}

2
src/main/java/com/dreamworks/boditech/driver/task/TaskStartReset.java

@ -107,7 +107,7 @@ public class TaskStartReset extends TaskBase {
// 11. 光学推杆电机复位
LOG.info("[reset] analysis push motor");
IncubatorSlot incubatorSlot = incubatorMotor.getSlotByIndex(10);
IncubatorSlot incubatorSlot = incubatorMotor.getSlotByIndex(ActIncubator.INIT_EXIT_SLOT_INDEX);
incubatorMotor.moveTo(incubatorSlot.getExitLocation());
this.analysisPushMotor.reset();
this.analysisPushMotor.moveTo("analysisPushMotorStandby");

27
src/main/java/com/dreamworks/boditech/driver/task/TaskTestBase.java

@ -1,5 +1,7 @@
package com.dreamworks.boditech.driver.task;
import com.dreamworks.boditech.driver.Device;
import com.dreamworks.boditech.driver.actuator.ActIncubator;
import com.dreamworks.boditech.driver.actuator.ActuatorModule;
import com.dreamworks.boditech.driver.consumable.CsmBufferTube;
import com.dreamworks.boditech.driver.consumable.CsmSampleTube;
import com.dreamworks.boditech.driver.entity.IncubatorSlot;
@ -67,7 +69,9 @@ abstract public class TaskTestBase extends TaskBase implements TaskTest {
public void execute(Executor executor) {
this.device = executor.getDevice();
this.taskExecutor = executor;
this.setupTask();
if ( !this.setupTask() ) {
return ;
}
// execute steps
while ( this.stepIndex < this.steps.size() ) {
@ -104,10 +108,14 @@ abstract public class TaskTestBase extends TaskBase implements TaskTest {
}
// setup task if needed
private void setupTask() {
private Boolean setupTask() {
this.setStatus(Task.STATUS_EXECUTING);
if ( null != this.steps ) {
return ;
return true;
}
if ( !this.waitForResource() ) {
return false;
}
Device device = this.taskExecutor.getDevice();
@ -123,6 +131,19 @@ abstract public class TaskTestBase extends TaskBase implements TaskTest {
this.test = new MdbTest();
this.beforeTaskExecute(this.test);
device.testService.insert(this.test);
return true;
}
// wait for resource
private Boolean waitForResource() {
ActIncubator incubator = (ActIncubator) this.device.getActuator(ActuatorModule.INCUBATOR_MOTOR);
if ( !incubator.hasFreeSlot() ) {
this.taskExecutor.waitForIncubatorSlot(this);
this.setStatus(Task.STATUS_WAITING);
return false;
}
return true;
}
// execute step

1
src/main/java/com/dreamworks/boditech/driver/task/step/StepAnalysis.java

@ -55,6 +55,7 @@ public class StepAnalysis extends StepBase {
// unlock incubator slot
incubator.unlockSlot(incubatorSlot.getIndex());
executor.incubatorSlotAvailable();
}
// calculate result

4
src/main/java/com/dreamworks/boditech/utils/AppExceptionHandler.java

@ -8,6 +8,8 @@ public class AppExceptionHandler {
@ExceptionHandler(value = AppRuntimeException.class)
@ResponseBody
public ApiResponse handleAppRuntimeException(AppRuntimeException e) {
e.printStackTrace();
ApiResponse response = new ApiResponse();
response.success = false;
response.message = e.getMessage();
@ -19,6 +21,8 @@ public class AppExceptionHandler {
@ExceptionHandler(value = RuntimeException.class)
@ResponseBody
public ApiResponse handleRuntimeException(RuntimeException e ) {
e.printStackTrace();
ApiResponse response = new ApiResponse();
response.success = false;
response.message = e.getMessage();

Loading…
Cancel
Save