예제 #1
0
  protected static JSAP getOptions() throws JSAPException {
    JSAP jsap = new JSAP();

    FlaggedOption inetAddress =
        new FlaggedOption(CMD_INET_ADDRESS)
            .setStringParser(new InetAddressStringParser())
            .setDefault("255.255.255.255")
            .setRequired(false)
            .setShortFlag('i')
            .setLongFlag("inet-address");

    inetAddress.setHelp(Messages.CMD_MESSAGES.getString("cmdline.description.inet-address"));
    jsap.registerParameter(inetAddress);

    FlaggedOption port =
        new FlaggedOption(CMD_PORT)
            .setStringParser(new IntegerStringParser())
            .setDefault("9")
            .setRequired(false)
            .setShortFlag('p')
            .setLongFlag("port");

    port.setHelp(Messages.CMD_MESSAGES.getString("cmdline.description.port"));
    jsap.registerParameter(port);

    FlaggedOption config =
        new FlaggedOption(CMD_CONFIG_FILE)
            .setStringParser(new StringStringParser())
            .setRequired(false)
            .setDefault(getConfigFilePath())
            .setShortFlag('c')
            .setLongFlag("config");

    config.setHelp(Messages.CMD_MESSAGES.getString("cmdline.description.config"));
    jsap.registerParameter(config);

    Switch version = new Switch(CMD_VERSION).setShortFlag('v').setLongFlag("version");

    version.setHelp(Messages.CMD_MESSAGES.getString("cmdline.description.version"));
    jsap.registerParameter(version);

    Switch help = new Switch(CMD_HELP).setShortFlag('h').setLongFlag("help");

    help.setHelp(Messages.CMD_MESSAGES.getString("cmdline.description.help"));
    jsap.registerParameter(help);

    Switch debug = new Switch(CMD_DEBUG).setShortFlag('d').setLongFlag("debug");

    debug.setHelp(Messages.CMD_MESSAGES.getString("cmdline.description.debug"));
    jsap.registerParameter(debug);

    UnflaggedOption addresses =
        new UnflaggedOption(CMD_ADDRESSES).setRequired(false).setGreedy(true);

    addresses.setHelp(Messages.CMD_MESSAGES.getString("cmdline.description.addresses"));
    jsap.registerParameter(addresses);

    return jsap;
  }
  protected static Options parseArguments(String[] args) throws JSAPException, IOException {
    JSAP jsap = new JSAP();

    FlaggedOption rosNameSpace =
        new FlaggedOption("namespace")
            .setLongFlag("namespace")
            .setShortFlag(JSAP.NO_SHORTFLAG)
            .setRequired(false)
            .setStringParser(JSAP.STRING_PARSER);
    rosNameSpace.setDefault(DEFAULT_PREFIX);

    FlaggedOption tfPrefix =
        new FlaggedOption("tfPrefix")
            .setLongFlag("tfPrefix")
            .setShortFlag(JSAP.NO_SHORTFLAG)
            .setRequired(false)
            .setStringParser(JSAP.STRING_PARSER);
    tfPrefix.setDefault(DEFAULT_TF_PREFIX);

    FlaggedOption model =
        new FlaggedOption("robotModel")
            .setLongFlag("model")
            .setShortFlag('m')
            .setRequired(false)
            .setStringParser(JSAP.STRING_PARSER);
    model.setDefault(DEFAULT_STRING);

    FlaggedOption location =
        new FlaggedOption("startingLocation")
            .setLongFlag("location")
            .setShortFlag('s')
            .setRequired(false)
            .setStringParser(JSAP.STRING_PARSER);
    location.setDefault(DEFAULT_STRING);

    Switch visualizeSCSSwitch =
        new Switch("disable-visualize").setShortFlag('d').setLongFlag("disable-visualize");
    visualizeSCSSwitch.setHelp("Disable rendering/visualization of Simulation Construction Set");

    Switch requestAutomaticDiagnostic =
        new Switch("requestAutomaticDiagnostic")
            .setLongFlag("requestAutomaticDiagnostic")
            .setShortFlag(JSAP.NO_SHORTFLAG);
    requestAutomaticDiagnostic.setHelp("enable automatic diagnostic routine");

    jsap.registerParameter(model);
    jsap.registerParameter(location);
    jsap.registerParameter(rosNameSpace);
    jsap.registerParameter(tfPrefix);
    jsap.registerParameter(requestAutomaticDiagnostic);
    jsap.registerParameter(visualizeSCSSwitch);
    JSAPResult config = jsap.parse(args);

    Options options = new Options();
    options.robotModel = config.getString(model.getID());
    options.disableViz = config.getBoolean(visualizeSCSSwitch.getID());
    options.startingLocation = config.getString(location.getID());
    options.tfPrefix = config.getString(tfPrefix.getID());
    options.nameSpace = config.getString(rosNameSpace.getID());
    options.runAutomaticDiagnosticRoutine = config.getBoolean(requestAutomaticDiagnostic.getID());
    return options;
  }
예제 #3
0
  public static void execCommandArgs(String[] args) {
    JSAP jsap = new JSAP();
    final String update = "up";
    final String help = "help";
    final String prozess = "tex";
    final String outout = "out";
    final String src = "src";

    try {

      Switch swHelp = new Switch(help);
      swHelp.setShortFlag('h');
      swHelp.setLongFlag("help");
      swHelp.setHelp("Show this.");

      jsap.registerParameter(swHelp);

      Switch swUpdate = new Switch(update);
      swUpdate.setShortFlag('u');
      swUpdate.setLongFlag("update");
      swUpdate.setHelp("Updates from Remote");

      jsap.registerParameter(swUpdate);

      Switch swTex = new Switch(prozess);
      swTex.setShortFlag('t');
      swTex.setLongFlag("transform");
      swTex.setHelp("starts transform to tex");

      jsap.registerParameter(swTex);

      FlaggedOption optOut = new FlaggedOption(outout);
      optOut.setStringParser(JSAP.STRING_PARSER);
      optOut.setDefault(DEFAULT_OUTPUT_FOLDER + "/Songbook.tex");
      optOut.setRequired(false);
      optOut.setShortFlag('o');
      optOut.setLongFlag("output");
      optOut.setHelp("Filename for output");

      jsap.registerParameter(optOut);

      FlaggedOption optSrc = new FlaggedOption(src);
      optSrc.setStringParser(JSAP.STRING_PARSER);
      optSrc.setDefault(DEFAULT_DATA_FOLDER);
      optSrc.setRequired(false);
      optSrc.setShortFlag('s');
      optSrc.setLongFlag("src");
      optSrc.setHelp("input folder");

      jsap.registerParameter(optSrc);

      if (false) {
        final String style = "style";
        FlaggedOption optStyle = new FlaggedOption(style);
        optStyle.setStringParser(JSAP.STRING_PARSER);
        optStyle.setDefault(getDefault());
        optStyle.setRequired(false);
        optStyle.setShortFlag('y');
        optStyle.setLongFlag("style");

        jsap.registerParameter(optStyle);
      }

    } catch (JSAPException e) {
      throw new IllegalStateException(e);
    }
    JSAPResult config = jsap.parse(args);
    if (config.getBoolean("help") || !config.success() || !config.getBoolean(prozess)) {
      // TODO jar name/ package
      System.out.println("Usage: java -jar " + "??????.jar " + jsap.getUsage());

      System.out.println();
      System.out.println(jsap.getHelp());
      System.out.println();
    }

    if (config.getBoolean(update)) {
      updater.update();
    }
    if (config.getBoolean(prozess)) {
      File sourceDir = new File(config.getString(src));
      if (!sourceDir.isDirectory()) {
        System.out.println("No songs. Please update; " + sourceDir.getAbsolutePath());
      } else {
        processSongs(config.getString(src), config.getString(outout));
      }
    }
  }
예제 #4
0
  static {
    probeNameOptionF =
        new FlaggedOption(PROBENAME)
            .setStringParser(JSAP.STRING_PARSER)
            .setRequired(true)
            .setShortFlag('x')
            .setLongFlag(JSAP.NO_LONGFLAG)
            .setUsageName(PROBENAME);
    probeNameOptionF.setHelp("the name of the probe in the x-axis (required)");

    probeNameOptionUF =
        new UnflaggedOption(PROBENAME)
            .setStringParser(JSAP.STRING_PARSER)
            .setRequired(true)
            .setUsageName(PROBENAME);
    probeNameOptionUF.setHelp("the name of the probe (required)");

    valueOptionUF =
        new UnflaggedOption(VALUE)
            .setStringParser(JSAP.STRING_PARSER)
            .setRequired(false)
            .setUsageName(VALUE);

    optionsOptionF =
        new FlaggedOption(OPTIONS)
            .setStringParser(JSAP.STRING_PARSER)
            .setRequired(false)
            .setLongFlag(OPTIONS)
            .setUsageName(OPTIONS);

    currentTypeOptionF =
        new FlaggedOption(PROBE_TYPE)
            .setStringParser(
                EnumeratedStringParser.getParser(
                    StringUtilities.join(
                        ";",
                        new String[] {
                          VIRTPORT_TYPE.CURRENT_DYN.getTclOption(),
                          VIRTPORT_TYPE.CURRENT_LEAK.getTclOption(),
                          VIRTPORT_TYPE.CURRENT_TOT.getTclOption(),
                          VIRTPORT_TYPE.CURRENT_DYN_ALL.getTclOption(),
                          VIRTPORT_TYPE.CURRENT_LEAK_ALL.getTclOption(),
                          VIRTPORT_TYPE.CURRENT_TOT_ALL.getTclOption(),
                          VIRTPORT_TYPE.POWER_DYN.getTclOption(),
                          VIRTPORT_TYPE.POWER_LEAK.getTclOption(),
                          VIRTPORT_TYPE.POWER_TOT.getTclOption(),
                          VIRTPORT_TYPE.POWER_DYN_ALL.getTclOption(),
                          VIRTPORT_TYPE.POWER_LEAK_ALL.getTclOption(),
                          VIRTPORT_TYPE.POWER_TOT_ALL.getTclOption()
                        })))
            .setRequired(false)
            .setShortFlag('t')
            .setLongFlag(PROBE_TYPE)
            .setUsageName(PROBE_TYPE);

    orderOptionF =
        new FlaggedOption(ORDER_OPTION)
            .setStringParser(
                EnumeratedStringParser.getParser(
                    SLICE_ORDER.PARALLEL.getText() + ";" + SLICE_ORDER.SERIAL.getText()))
            .setRequired(false)
            .setShortFlag('o')
            .setLongFlag(ORDER_OPTION)
            .setUsageName(SLICE_ORDER.PARALLEL.getText() + "|" + SLICE_ORDER.SERIAL.getText());

    activityOptionF =
        new FlaggedOption(ACTIVTY)
            .setStringParser(JSAP.FLOAT_PARSER)
            .setRequired(false)
            .setShortFlag('a')
            .setLongFlag(ACTIVTY)
            .setUsageName("% of activity of the scenario");

    configOption_S = new Switch(CONFIG_OPTION).setLongFlag(CONFIG_OPTION);

    configOption_S.setHelp("specify a config state");

    defaultOption_S = new Switch(DEFAULT_OPTION).setLongFlag(DEFAULT_OPTION);

    defaultOption_S.setHelp("specify a default content");

    tilltime_F =
        new FlaggedOption(TILLTIME_OPTION)
            .setStringParser(JSAP.FLOAT_PARSER)
            .setRequired(false)
            .setLongFlag(TILLTIME_OPTION)
            .setUsageName(TILLTIME_OPTION);

    setOnlyS = new Switch(SETONLY_OPTION).setLongFlag(SETONLY_OPTION);
    setOnlyS.setHelp("force only the signal, and do to recompute the state of");

    bundleS = new Switch(BUNDLE_OPTION).setLongFlag(BUNDLE_OPTION);
    bundleS.setHelp("create a bundle");

    removeS = new Switch(REMOVE_OPTION).setLongFlag(REMOVE_OPTION);
    removeS.setHelp("remove the force command");

    addS = new Switch(ADD_OPTION).setLongFlag(ADD_OPTION).setShortFlag('a');
    addS.setHelp("add the probe to the table");

    datapoints_S = new Switch(DATAPOINTS_OPTION).setLongFlag(DATAPOINTS_OPTION).setShortFlag('d');
    datapoints_S.setHelp("return all data points");

    pathOptionF =
        new FlaggedOption(PATH_OPTION)
            .setStringParser(JSAP.STRING_PARSER)
            .setRequired(true)
            .setShortFlag('p')
            .setLongFlag(PATH_OPTION)
            .setUsageName("scenario|slice|activity path");
  }