Class FWSimConsole

java.lang.Object
net.simplace.sim.FWSimConsole

public class FWSimConsole extends Object
Command line interface of SIMPLACE. The first argument is the command, the following arguments are options of the form -name=value (see echoUsage()):
  • run: runs a solution with an optional project
  • check: like run with check level ONLY
  • postprocess: prepares the session and runs only its post-processing
  • migrate: migrates solution and project files (or the whole work directory) with FWSimMigrator
  • rest: starts the REST wrapper server (net.simplace.sim.wrapper.rest)
  • web: starts the web client, a browser page to run solutions and look at their outputs (net.simplace.sim.wrapper.web; option config: properties file with the login)
  • split: splits a project data file into chunks and writes a batch script for a cluster queue
Except for rest and web, the JVM is terminated with System.exit(int) at the end.
Author:
Andreas Enders
  • Constructor Details

    • FWSimConsole

      public FWSimConsole()
  • Method Details

    • main

      public static void main(String[] aArgumentsArray)
      Entry point: prints the usage for no arguments, help or ?, otherwise executes the command.
      Parameters:
      aArgumentsArray - command followed by the options
    • readOptions

      protected HashMap<String,String> readOptions(String[] aArgumentsArray)
      Parses the options (all arguments after the command). Each option has the form -name=value; a short name (one letter, fd, fp) is expanded (see replaceShortForm(String)), -v:name=value becomes variable:name. Quotes enclosing the whole value are removed (see removeEnclosingQuotes(String)). Arguments not starting with -, without = or with an unknown short name are skipped with a warning.
      Parameters:
      aArgumentsArray - all command line arguments, including the command at index 0
      Returns:
      the options by name
    • removeEnclosingQuotes

      public static String removeEnclosingQuotes(String aValue)
      Removes quotes that enclose the whole value of an option ("value" or 'value'), e.g. if a calling script passes them literally. Quotes inside the value are kept, so JSON like [{"DOY":1,"yield":500.0}] stays intact. Before (#610) the text between the first and the last double quote was taken, which destroyed every JSON value with double quotes.
      Parameters:
      aValue - the value of the option
      Returns:
      the value without enclosing quotes, trimmed
    • parseSlotCount

      public static int parseSlotCount(String aValue)
      Parses the value of the option slotcount: the number of simulations of a project that run in parallel (default: number of processors minus one, at least 2, see FWSimEngine.getSlotCount()). Before this option the console could not set it: the parameter slotcount is only read on the GUI path (FWSimEngine.call(int, String, HashMap, APPLICATION_MODE)), and -v:slotcount only creates a simulation variable.
      Parameters:
      aValue - value of the option
      Returns:
      the slot count (at least 1)
      Throws:
      IllegalArgumentException - if the value is not an integer of at least 1
    • performMainActions

      protected void performMainActions(String aCommand, HashMap<String,String> aOptions)
      Executes a command with its options, see the class description. For run, check and postprocess:
      • slotcount sets the number of simulations of a project that run in parallel (also for rest and web)
      • the directories are set from target (predefined settings for CLUSTER, BONNACLUSTER, MODULES, RUN) and then from workdir, projectsdir, datadir, outputdir
      • solution and project are searched as given, relative to the work directory, and on the class path
      • options variable:name override solution variables
      • with pack and lines the output directory is packed into an archive (.zip, .tar or .tar.gz) and deleted afterwards
      Parameters:
      aCommand - the command
      aOptions - the options, see readOptions(String[])
    • echoUsage

      protected void echoUsage()
      Prints the usage of all commands and options to System.out.