コード例 #1
0
 private void printInputParameters(
     final PrintWriter w, BulkParameterFactory f, ExperimentRunSettings s, boolean allParams) {
   w.println("<form action=\"#\">");
   w.println("<h2>Input parameters</h2>");
   w.println("<table>");
   for (final ParameterType t : ParameterType.values()) {
     if (!allParams && t.getDescription().isEmpty()) {
       continue;
     }
     w.println("<tr><td style=\"vertical-align:top;text-align:right\">");
     w.println(t.toString());
     w.println("</td><td style=\"vertical-align:top\">");
     w.println(this.getInputFor(t, f));
     w.println("</td><td style=\"vertical-align:top\">");
     w.println(t.getDescription());
     w.println("</td></tr>");
   }
   w.println("</table>");
   w.println("<h2>Experiment settings</h2>");
   w.println("<table>");
   for (final ExperimentRunParameters t : ExperimentRunParameters.values()) {
     w.println("<tr><td style=\"vertical-align:top;text-align:right\">");
     w.println(t.toString());
     w.println("</td><td style=\"vertical-align:top\">");
     w.println(this.getInputFor(t, s));
     w.println("</td><td style=\"vertical-align:top\">");
     w.println(t.getDescription());
     w.println("</td></tr>");
   }
   w.println("</table>");
   w.println("<button type=\"submit\">Start simulation</button>");
   w.println("</form>");
 }
コード例 #2
0
 private Properties settingsToProperties(ExperimentRunSettings s) {
   final Properties ret = new Properties();
   for (final ExperimentRunParameters type : ExperimentRunParameters.values()) {
     ret.setProperty(type.name(), Double.toString(s.get(type)));
   }
   return ret;
 }
コード例 #3
0
 private ExperimentRunSettings getExperimentSettings(PrintWriter w, HttpServletRequest request) {
   ExperimentRunSettings s = ExperimentRunSettings.defaultSettings();
   for (final ExperimentRunParameters t : ExperimentRunParameters.values()) {
     final String param = request.getParameter(t.name());
     if (param != null && !param.isEmpty()) {
       try {
         s = s.copyWithChangedParam(t, Double.parseDouble(param));
       } catch (final RuntimeException e) {
         this.printParseError(w, t.toString(), e);
       }
     }
   }
   return s;
 }
コード例 #4
0
 private String getInputFor(ExperimentRunParameters t, ExperimentRunSettings s) {
   return "<input name=\""
       + t.name()
       + "\" value=\""
       + s.get(t)
       + "\" type=\"number\" step=\"any\" />";
 }
コード例 #5
0
  private ExperimentRunSettings loadSettings(int requestId) throws IOException {
    final File requestDir = this.getRequestDir(requestId);
    final File paramsFile = new File(requestDir, SETTINGS_PROPERTIES);
    try (FileInputStream in = new FileInputStream(paramsFile)) {
      final Properties properties = new Properties();
      properties.load(in);

      ExperimentRunSettings ret = ExperimentRunSettings.defaultSettings();
      for (final String name : properties.stringPropertyNames()) {
        final ExperimentRunParameters type = ExperimentRunParameters.valueOf(name);
        ret = ret.copyWithChangedParam(type, Double.parseDouble(properties.getProperty(name)));
      }
      return ret;
    }
  }