示例#1
0
  private static void setConstantsFromConfig(String[] args) throws IOException {

    try {
      config = new Config(new File("sos.config"));
      CommandLineOptions.processArgs(args, config);
      // if(config.getIntValue("sos.password")==SOSConstant.PASSWORD)
      if (!SOSConstant.IS_CHALLENGE_RUNNING)
        SOSConstant.IS_CHALLENGE_RUNNING = config.getBooleanValue("sos.IS_CHALLENGE_RUNNING", true);
      if (!SOSConstant.NO_ANY_LOG)
        SOSConstant.NO_ANY_LOG = config.getBooleanValue("sos.NO_ANY_LOG", true);
    } catch (ConfigException e1) {
      sosLogger.error(e1.getMessage());
    }
  }
  @Override
  public void connect(ComponentLauncher launcher, Config config, AbstractLoader loader) {
    int count = config.getIntValue(ConfigKey.KEY_AMBULANCE_TEAM_COUNT, 0);
    int connected = 0;

    if (count == 0) {
      return;
    }

    /*
    String classStr = config.getValue(ConfigKey.KEY_AMBULANCE_TEAM_NAME);
    if (classStr == null)
    {
    	System.out.println("[ERROR] Cannot Load AmbulanceTeam Tactics !!");
    	return;
    }
    System.out.println("[START] Connect AmbulanceTeam (teamName:" + classStr + ")");
    System.out.println("[INFO ] Load AmbulanceTeam (teamName:" + classStr + ")");
    */

    try {
      if (loader.getTacticsAmbulance() == null) {
        System.out.println("[ERROR ] Cannot Load AmbulanceTeam Tactics !!");
        return;
      }
      for (int i = 0; i != count; ++i) {
        TacticsAmbulance tacticsAmbulance = loader.getTacticsAmbulance();
        boolean isPrecompute = config.getBooleanValue(ConfigKey.KEY_PRECOMPUTE, false);
        launcher.connect(new PlatoonAmbulance(tacticsAmbulance, isPrecompute));
        // System.out.println(name);
        connected++;
      }
    } catch (ComponentConnectionException | InterruptedException | ConnectionException e) {
      // e.printStackTrace();
      System.out.println("[ERROR ] Cannot Load AmbulanceTeam Tactics !!");
    }
    System.out.println("[FINISH] Connect AmbulanceTeam (success:" + connected + ")");
  }