/** * Performs the current task in the queue and checks to see if the task is complete. If the task * is complete, this removes the task from the queue and performs any necessary clean-up. */ public void DoCurrentTask() { try { // If we have something to do, try to get it done if (currentTask != null) { currentTask.PerformTaskActions(); // Check to see if the current task is complete if (currentTask.IsComplete()) { // Perform any cleanup actions associated with the task with // which we're finished currentTask.CleanUpTask(); // If we have another task to do, make it the current task, // otherwise we make the current task null if (taskQueue.Size() > 0) { currentTask = taskQueue.Pop(); } else { currentTask = null; } } } else if (taskQueue.Size() > 0) { currentTask = taskQueue.Pop(); } } catch (Exception ex) { currentTask = null; System.err.println(ex.toString()); } }
/** * Returns the current task's state. * * @return State of the current task */ public String GetCurrentTaskState() { if (currentTask == null) { return " "; } return currentTask.GetStateName(); }
/** * Polls the current task to see if it is OK to respond to operator inputs. * * @return True if it is OK to respond to operator inputs, false otherwise */ public boolean OkToDrive() { if (currentTask == null) { return true; } return currentTask.OkToDrive(); }
/** Removes all tasks from the queue, performing clean-up actions as necessary. */ public void ClearAllTasks() { TaskBase popedTask; while (taskQueue.Size() > 0) { // Remove the task from the queue and perform necessary clean-up // actions try { popedTask = taskQueue.Pop(); popedTask.CleanUpTask(); } catch (Exception ex) { System.err.println(ex.toString()); } } // In addition to clearing the queue, set the current task to null currentTask = null; }
/** * Returns the name of the current task, if one exists. * * @return Name of the current task */ public String GetCurrentTaskName() { if (currentTask == null) { // Names should be 21 characters long return "None "; } return currentTask.GetName(); }
public void debugInfo(StringBuilder builder) { super.debugInfo(builder); builder.append(", matcher=").append(_matcher); }
/** * 运行等待队列中的任务 * * @param netWorkResultTask */ public void performerStandTask(TaskBase netWorkResultTask) { taskRuningList.add(netWorkResultTask); taskStandByList.remove(netWorkResultTask); netWorkResultTask.start(); }
/** * 执行任务 * * @param task 需要执行的任务 */ public void performerTask(TaskBase task) { taskRuningList.add(task); task.start(); }