コード例 #1
0
ファイル: HistogramViewer.java プロジェクト: Gumtree/gumtree
  /* (non-Javadoc)
   * @see au.gov.ansto.bragg.quokka.dra.core.ConcreteProcessor#process()
   */
  public Boolean process() throws Exception {
    // TODO Auto-generated method stub
    //		if (histogramViewer_interval.doubleValue() != interval.doubleValue()){
    //			System.out.println("oldValue=" + interval + " newValue=" + histogramViewer_interval);
    //			setInterval(histogramViewer_interval);
    //			System.out.println("set the interval to " + interval);
    //			return true;
    //		}
    retriever = new LiveDataRetriever();
    retriever.setUser("Gumtree");
    retriever.setPassword("Gumtree");

    //		histogramViewer_host = "localhost";
    if (histogramViewer_host.equals("default")) {
      ICommandLineOptions options = ServiceUtils.getService(ICommandLineOptions.class);
      if (options.hasOptionValue(OPTION_SICS_INSTRUMENT)) {
        String instrumentName = options.getOptionValue(OPTION_SICS_INSTRUMENT);
        instrumentName = instrumentName.substring(instrumentName.lastIndexOf(".") + 1);
        histogramViewer_host = "das1-" + instrumentName + ".nbi.ansto.gov.au";
      }
    }
    //		histogramViewer_host = "localhost";
    //
    URI fileHandle = null;
    try {
      //			fileHandle = retriever.getHDFFileHandle("localhost", 8081, HistogramType.TOTAL_HISTO_XY);
      fileHandle =
          retriever.getHDFFileHandle(
              histogramViewer_host, histogramViewer_port, HistogramType.TOTAL_HISTO_XY);
    } catch (Exception e) {
      // TODO Auto-generated catch block
      try {
        fileHandle = retriever.getHDFFileHandle("localhost", 8080, HistogramType.TOTAL_HISTO_XY);
      } catch (Exception e1) {
        // TODO: handle exception
        throw e1;
      }
      //			e.printStackTrace();
      //			return "can not make the connection";
    }
    // Test if file is physically available
    System.out.println("wait for " + histogramViewer_interval + "sec");
    try {
      Thread.sleep((long) (histogramViewer_interval * 1000));
    } catch (Exception e) {
      // TODO: handle exception
      throw e;
    }
    System.out.println(fileHandle);
    histogramViewer_data =
        ((NcGroup)
                DataManagerFactory.getDataManager(
                        ConverterLib.getDictionaryPath(Activator.PLUGIN_ID))
                    .getGroup(fileHandle))
            .getFirstEntryAccess();
    histogramViewer_loopOut = !histogramViewer_stop;
    return histogramViewer_stop;
  }
コード例 #2
0
ファイル: HistogramViewer.java プロジェクト: Gumtree/gumtree
 private String findPluginID() {
   String pluginId = DEFAULT_DRA_PLUGIN;
   ICommandLineOptions options = ServiceUtils.getService(ICommandLineOptions.class);
   if (null != options) {
     if (options.hasOptionValue(OPTION_ALGO_SET)) {
       pluginId = options.getOptionValue(OPTION_ALGO_SET);
     }
   }
   return pluginId;
 }
コード例 #3
0
ファイル: HistogramViewer.java プロジェクト: Gumtree/gumtree
  public Boolean process() throws Exception {

    retriever = new LiveDataRetriever();
    retriever.setUser("Gumtree");
    retriever.setPassword("Gumtree");

    /* 'serverName' is one of the option strings, usually predefined by the algorithm,
     * and including the "default" option.
     * 'server' is the string for the actual server host name
     */
    String server = serverName;
    if (serverName.equals("default")) {
      ICommandLineOptions options = ServiceUtils.getService(ICommandLineOptions.class);
      if (options.hasOptionValue(OPTION_SICS_INSTRUMENT)) {
        String instrumentName = options.getOptionValue(OPTION_SICS_INSTRUMENT);
        server = instrumentName.substring(instrumentName.lastIndexOf(".") + 1);
        server = "das1-" + server + ".nbi.ansto.gov.au";
      }
    }

    URI fileHandle = null;
    try {
      fileHandle = retriever.getHDFFileHandle(server, serverPort, HistogramType.TOTAL_HISTO_XY);
    } catch (Exception e) {
      try {
        fileHandle =
            retriever.getHDFFileHandle("localhost", serverPort, HistogramType.TOTAL_HISTO_XY);
      } catch (Exception e1) {
        throw e1;
      }
      debugging("Cannot establish server connection");
    }

    // Test if file is physically available
    long sleepTime;
    if (isFirst) {
      sleepTime = 2000;
      isFirst = false;
    } else {
      sleepTime = (long) (pollInterval * 1000);
    }
    try {
      debugging("> wait for " + sleepTime + " milliseconds");
      Thread.sleep(sleepTime);
    } catch (Exception e) {
      throw e;
    }

    doStop = doStop || (null == fileHandle);

    if (doStop) {
      debugging("> Manual Stop or filehandle not available");
    } else {
      debugging("> filehandle: " + fileHandle);
      histogram = fetchHistogram(fileHandle);
    }
    if (null == histogram) {
      debugging("> histogram: null");
      doStop = true;
      histogram = Factory.createGroup("empty");
    }
    outLoop = !doStop;
    return doStop;
  }