Ejemplo n.º 1
0
  private static OrderedMap<Long, Double[]> _MergeDataSets(boolean F, TemperatureSet TSList[]) {

    /* merge temperature data sets */
    OrderedMap<Long, Double[]> rowMap = new OrderedMap<Long, Double[]>();
    if (!ListTools.isEmpty(TSList)) {
      for (int d = 0; d < TSList.length; d++) {
        TemperatureSet TS = TSList[d];
        if (TS != null) {
          Collection<Temperature> TList = TS.getTemperatures();
          for (Temperature T : TList) {
            Long ts = new Long(T.getTimestamp());
            Double tmp = new Double(T.getTemperature(F));
            Double row[] = rowMap.get(ts);
            if (row == null) {
              row = new Double[TSList.length];
              rowMap.put(ts, row);
            }
            row[d] = tmp;
          }
        }
      }
    }

    /* sort by timestamp */
    rowMap.sortKeys(new ListTools.NumberComparator<Long>());

    /* return */
    return rowMap;
  }
Ejemplo n.º 2
0
  public static void main(String argv[]) {
    RTConfig.setCommandLineArgs(argv);
    long ts = DateTime.getCurrentTimeSec();
    double C = -5.6;

    TemperatureSet TSList[] = new TemperatureSet[3];
    for (int s = 0; s < TSList.length; s++) {
      TemperatureSet TS = new TemperatureSet();
      for (int i = 0; i < 10; i++) {
        long tempTS = ts + (12345L * (i + 1) * (s + 1));
        double tempC = C + (2.3 * i) + (1.1 * s);
        Print.logInfo(s + ":" + i + "] Adding " + tempTS + ", " + tempC);
        TS.addTemperature(tempTS, tempC);
      }
      TSList[s] = TS;
    }

    String t = TemperatureSet.CreateGoogleDataTableJavaScript(false, TSList);
    Print.sysPrintln(t);
  }