|
|
@ -31,6 +31,8 @@ public class Executor implements Runnable { |
|
|
|
public String workingStatus = "WAIT_FOR_TUBE_RACK"; |
|
|
|
// incubator wait task |
|
|
|
private Task incubatorWaitTask = null; |
|
|
|
// resource wait task |
|
|
|
private Task resourceWaitTask = null; |
|
|
|
|
|
|
|
/** |
|
|
|
* execute single task on device |
|
|
@ -55,6 +57,8 @@ public class Executor implements Runnable { |
|
|
|
public void run() { |
|
|
|
LOG.info("task executor start"); |
|
|
|
this.status = Executor.STATUS_RUNNING; |
|
|
|
this.workingStatus = "EXECUTING"; |
|
|
|
this.device.websocketServerService.log("Task Executor Started"); |
|
|
|
|
|
|
|
while (!Objects.equals(this.status, Executor.STATUS_STOP_REQUEST)) { |
|
|
|
Task task = this.findExecutableTask(); |
|
|
@ -86,6 +90,7 @@ public class Executor implements Runnable { |
|
|
|
this.status = Executor.STATUS_STOPPED; |
|
|
|
this.workingStatus = "STOPPED"; |
|
|
|
LOG.info("task executor stop"); |
|
|
|
this.device.websocketServerService.log("Task Executor Stopped"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -166,6 +171,8 @@ public class Executor implements Runnable { |
|
|
|
// stop executor |
|
|
|
public void stop() { |
|
|
|
LOG.info("task executor stop : start"); |
|
|
|
this.device.websocketServerService.log("Task Executor Stopping"); |
|
|
|
|
|
|
|
for ( Task task : this.tasks ) { |
|
|
|
task.stop(); |
|
|
|
} |
|
|
@ -181,6 +188,8 @@ public class Executor implements Runnable { |
|
|
|
*/ |
|
|
|
public void pause() { |
|
|
|
LOG.info("task executor pause : start"); |
|
|
|
this.device.websocketServerService.log("Task Executor Pausing"); |
|
|
|
|
|
|
|
this.status = Executor.STATUS_PAUSE_REQUEST; |
|
|
|
synchronized (this.tasks) { |
|
|
|
this.tasks.notifyAll(); |
|
|
@ -192,17 +201,28 @@ public class Executor implements Runnable { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this.workingStatus = "PAUSED"; |
|
|
|
LOG.info("task executor pause : end"); |
|
|
|
this.device.websocketServerService.log("Task Executor Paused"); |
|
|
|
} |
|
|
|
|
|
|
|
// resume executor |
|
|
|
public void resume() { |
|
|
|
LOG.info("task executor resume : start"); |
|
|
|
this.device.websocketServerService.log("Task Executor Resuming"); |
|
|
|
|
|
|
|
if ( null != this.resourceWaitTask ) { |
|
|
|
this.resourceWaitTask.setStatus(Task.STATUS_READY); |
|
|
|
this.resourceWaitTask = null; |
|
|
|
} |
|
|
|
|
|
|
|
this.status = Executor.STATUS_RUNNING; |
|
|
|
synchronized (this.tasks) { |
|
|
|
this.tasks.notifyAll(); |
|
|
|
} |
|
|
|
LOG.info("task executor resume : end"); |
|
|
|
this.device.websocketServerService.log("Task Executor Resumed"); |
|
|
|
} |
|
|
|
|
|
|
|
// append task |
|
|
@ -231,6 +251,7 @@ public class Executor implements Runnable { |
|
|
|
// wait for incubator slot |
|
|
|
public void waitForIncubatorSlot( Task task ) { |
|
|
|
LOG.info("task executor wait for incubator slot"); |
|
|
|
this.device.websocketServerService.log("Task Executor Waiting For Incubator Slot"); |
|
|
|
this.status = Executor.STATUS_PAUSED; |
|
|
|
this.incubatorWaitTask = task; |
|
|
|
} |
|
|
@ -241,10 +262,19 @@ public class Executor implements Runnable { |
|
|
|
return ; |
|
|
|
} |
|
|
|
LOG.info("task executor incubator slot available"); |
|
|
|
this.device.websocketServerService.log("Task Executor Incubator Slot Available"); |
|
|
|
this.status = Executor.STATUS_RUNNING; |
|
|
|
this.incubatorWaitTask.setStatus(Task.STATUS_READY); |
|
|
|
this.incubatorWaitTask = null; |
|
|
|
} |
|
|
|
|
|
|
|
// public void waitForConsumable( Task task ); |
|
|
|
// wait for consumable resource |
|
|
|
public void waitForConsumableResource( Task task, Exception e ) { |
|
|
|
LOG.info("task executor wait for consumable resource"); |
|
|
|
this.device.websocketServerService.log("Task Executor Waiting For Consumable Resource"); |
|
|
|
this.workingStatus = "WAIT_FOR_CONSUMABLE_RESOURCE"; |
|
|
|
this.status = Executor.STATUS_PAUSED; |
|
|
|
this.resourceWaitTask = task; |
|
|
|
this.device.websocketServerService.emit("deviceWaitForConsumableResource", e); |
|
|
|
} |
|
|
|
} |