Ejemplo n.º 1
0
  private ArrayStructureAdde readData(String selectClause, CancelTask cancel) {
    try {
      String urlString =
          (selectClause == null)
              ? addeURL + "&num=all"
              : addeURL + "&num=all&select='" + selectClause + "'";
      AddePointDataReader reader = callAdde(urlString);

      int[][] stationObsData = reader.getData();
      int nparams = stationObsData.length;
      int nobs = stationObsData[0].length;
      if (debugAddeCall) {
        System.out.println("CALL ADDE= " + urlString);
        System.out.println(" nparams= " + nparams + " nobs=" + nobs);
        System.out.println(" size= " + (nparams * nobs * 4) + " bytes");
      }

      return new ArrayStructureAdde(members, new int[] {nobs}, stationObsData, scaleFactor);

    } catch (AddeException e) {
      e.printStackTrace();
      throw new RuntimeException(e.getMessage());

    } catch (IOException e) {
      e.printStackTrace();
      throw new RuntimeException(e.getMessage()); // LOOK BAD
    }
  }
Ejemplo n.º 2
0
  static void test(String urlString) {
    try {
      long start = System.currentTimeMillis();
      System.out.println(" get " + urlString);

      AddePointDataReader reader = new AddePointDataReader(urlString);

      System.out.println(" took= " + (System.currentTimeMillis() - start) + " msec");
      System.out.println(reader.toString());

      System.out.println(" Param  Unit Scale");

      String[] params = reader.getParams();
      String[] units = reader.getUnits();
      int[] scales = reader.getScales();
      for (int i = 0; i < params.length; i++) {
        System.out.println(" " + params[i] + " " + units[i] + " " + scales[i]);
      }

      int[][] data = reader.getData();
      System.out.println(" nparams= " + params.length);
      System.out.println(" n= " + data.length);
      System.out.println(" m= " + data[0].length);

    } catch (AddeException e) {
      e.printStackTrace(); // To change body of catch statement use File | Settings | File
      // Templates.
    }
  }
Ejemplo n.º 3
0
  private void init() throws IOException {
    members = new StructureMembers("stationObs");

    // used to convert from adde format
    calendar = new GregorianCalendar();
    calendar.setTimeZone(TimeZone.getTimeZone("GMT"));

    // time unit
    timeUnit = DateUnit.getUnixDateUnit();

    try {
      AddePointDataReader reader = callAdde(addeURL);

      String[] params = reader.getParams();
      String[] units = reader.getUnits();
      int[] scales = reader.getScales();
      scaleFactor = new double[params.length];

      if (debugHead) System.out.println(" Param  Unit Scale");
      for (int paramNo = 0; paramNo < params.length; paramNo++) {
        // memberNames.add( params[i]);

        if (debugHead)
          System.out.println(" " + params[paramNo] + " " + units[paramNo] + " " + scales[paramNo]);
        if (scales[paramNo] != 0)
          scaleFactor[paramNo] = 1.0 / Math.pow(10.0, (double) scales[paramNo]);

        DataType dt = null;
        if ("CHAR".equals(units[paramNo])) dt = DataType.STRING;
        else if (scaleFactor[paramNo] == 0) dt = DataType.INT;
        else dt = DataType.DOUBLE;

        String unitString = null;
        if ((units[paramNo] != null) && (units[paramNo].length() > 0))
          unitString = visad.jmet.MetUnits.makeSymbol(units[paramNo]);

        AddeTypedDataVariable tdv = new AddeTypedDataVariable(params[paramNo], unitString, dt);
        dataVariables.add(tdv);
        StructureMembers.Member m =
            members.addMember(
                tdv.getShortName(),
                tdv.getDescription(),
                tdv.getUnitsString(),
                tdv.getDataType(),
                tdv.getShape());
        m.setDataParam(paramNo);
        members.addMember(m);
      }

    } catch (AddeException e) {
      e.printStackTrace();
      throw new IOException(e.getMessage());
    }
  }
Ejemplo n.º 4
0
  static AddePointDataReader callAdde(String request) throws IOException {
    try {
      System.out.println("Call ADDE request= " + request);
      long start = System.currentTimeMillis();
      AddePointDataReader reader = new AddePointDataReader(request);
      System.out.println(" took= " + (System.currentTimeMillis() - start) + " msec");

      return reader;

    } catch (AddeException e) {
      e.printStackTrace();
      throw new IOException(e.getMessage());
    }
  }