コード例 #1
0
 @Override
 public String getStatus() {
   try {
     setStatus();
     return status.name();
   } catch (TaskAbortException ex) {
     return "Error finding Status";
   }
 }
コード例 #2
0
ファイル: SimpleSearchManager.java プロジェクト: jpollo/rcrss
  @Override
  public void execute() throws CommandException {
    if (world.getTime() == lastExecuteTime) {
      thisCycleExecute++;
    } else {
      lastExecuteTime = world.getTime();
      thisCycleExecute = 0;
    }

    if (thisCycleExecute > 10) {
      if (MRLConstants.DEBUG_SEARCH) {
        world.printData("This cycle had too much execute... search failed!");
      }
      shouldChangePath = true;
      return;
    }
    logger.debug("Execute.");

    if (isNeedToEvaluateTarget()) {
      if (isNeedUpdateDecisionMaker()) {
        lastUpdateTime = world.getTime();
        decisionMaker.update();
      }
      targetPath = decisionMaker.getNextPath();
      shouldChangePath = false;
      logger.debug("targetPath was null and now is set to: " + targetPath);
    }
    searchStrategy.setSearchingPath(targetPath, true);
    SearchStatus status = searchStrategy.searchPath();

    if (status.equals(CANCELED)) {
      shouldChangePath = true;
      targetPath = null;
      execute();
    }
    if (status == FINISHED) {
      targetPath = null;
      shouldChangePath = true;
      execute();
    } else if (status == SEARCHING) {
      // Do Nothing
    }
  }