Ejemplo n.º 1
0
  /**
   * 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());
    }
  }
Ejemplo n.º 2
0
  /**
   * Returns the current task's state.
   *
   * @return State of the current task
   */
  public String GetCurrentTaskState() {
    if (currentTask == null) {
      return "                     ";
    }

    return currentTask.GetStateName();
  }
Ejemplo n.º 3
0
  /**
   * 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();
  }
Ejemplo n.º 4
0
  /** 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;
  }
Ejemplo n.º 5
0
  /**
   * 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();
  }
Ejemplo n.º 6
0
 public void debugInfo(StringBuilder builder) {
   super.debugInfo(builder);
   builder.append(", matcher=").append(_matcher);
 }
Ejemplo n.º 7
0
 /**
  * 运行等待队列中的任务
  *
  * @param netWorkResultTask
  */
 public void performerStandTask(TaskBase netWorkResultTask) {
   taskRuningList.add(netWorkResultTask);
   taskStandByList.remove(netWorkResultTask);
   netWorkResultTask.start();
 }
Ejemplo n.º 8
0
 /**
  * 执行任务
  *
  * @param task 需要执行的任务
  */
 public void performerTask(TaskBase task) {
   taskRuningList.add(task);
   task.start();
 }