Ejemplo n.º 1
0
  public String getWaveServerMenuItem(final int p, final double embargo, final double span) {
    if (!winston.checkConnect()) {
      return null;
    }

    try {
      String result = null;
      winston.useRootDatabase();
      final ResultSet rs =
          winston.getStatement().executeQuery("SELECT code FROM channels WHERE sid=" + p);
      if (rs.next()) {
        final String code = rs.getString(1);
        final double[] ts = data.getTimeSpan(code);

        /*
         * if (embargo != 0)
         * {
         * double now = CurrentTime.nowJ2K();
         * double emnow = now - embargo;
         * maxt = Math.min(emnow, maxt);
         * }
         * if (span != 0)
         * mint = Math.max(mint, maxt - span);
         */
        final StringTokenizer st = new StringTokenizer(code, "$");
        final String sta = st.nextToken();
        final String ch = st.nextToken();
        final String nw = st.nextToken();

        result =
            " "
                + p
                + " "
                + sta
                + " "
                + ch
                + " "
                + nw
                + " "
                + decimalFormat.format(Ew.fromEpoch(J2kSec.asEpoch(ts[0])))
                + " "
                + decimalFormat.format(Ew.fromEpoch(J2kSec.asEpoch(ts[1])))
                + " s4 ";
      }
      rs.close();
      return result;
    } catch (final Exception e) {
      LOGGER.error("Could not get wave server menu item. ({})", e.getLocalizedMessage());
    }
    return null;
  }
Ejemplo n.º 2
0
  public List<String> getWaveServerMenu(
      final boolean scnl, final double embargo, final double span, final double maxDays) {
    if (!winston.checkConnect()) {
      return null;
    }

    final List<Channel> sts = channels.getChannels();
    if (sts == null) {
      return null;
    }

    final List<String> list = new ArrayList<String>(sts.size());
    for (final Channel st : sts) {
      final String[] ss = st.getCode().split("\\$");
      final double[] ts = {st.getMinTime(), st.getMaxTime()};

      if (maxDays > 0) {
        ts[0] = Math.max(ts[0], J2kSec.now() - (maxDays * ONE_DAY));
      }

      if (ts != null && ts[0] < ts[1]) {

        if (!scnl && ss.length == 3) {
          list.add(
              " "
                  + st.getSID()
                  + " "
                  + ss[0]
                  + " "
                  + ss[1]
                  + " "
                  + ss[2]
                  + " "
                  + decimalFormat.format(Ew.fromEpoch(J2kSec.asEpoch(ts[0])))
                  + " "
                  + decimalFormat.format(Ew.fromEpoch(J2kSec.asEpoch(ts[1])))
                  + " s4 ");
        } else if (scnl) {
          final String loc = (ss.length == 4 ? ss[3] : "--");
          final String line =
              " "
                  + st.getSID()
                  + " "
                  + ss[0]
                  + " "
                  + ss[1]
                  + " "
                  + ss[2]
                  + " "
                  + loc
                  + " "
                  + decimalFormat.format(Ew.fromEpoch(J2kSec.asEpoch(ts[0])))
                  + " "
                  + decimalFormat.format(Ew.fromEpoch(J2kSec.asEpoch(ts[1])))
                  + " s4 ";
          list.add(line);
        }
      }
    }
    return list;
  }