package org.bucksch.zeipis.recorder;
import org.bucksch.zeipis.all.*;
import java.sql.*;

public class DVBTTransponder extends DVBTransponder
{
  public DVBTTransponder() { super(); myDVBSubtype = "DVB-T"; }
  protected void readFromDatabaseResultSet(ResultSet rs)
    throws Misconfiguration, SQLException
  {
    super.readFromDatabaseResultSet(rs);
    bandwidth = rs.getString("bandwidth").toUpperCase().charAt(0);
    if (bandwidth != 'A' && bandwidth != '8' && bandwidth != '7' && bandwidth != '6')
      throw new Misconfiguration("Unknown bandwidth " + bandwidth);
    hp_code_rate = rs.getString("hp_code_rate").toUpperCase();
    lp_code_rate = rs.getString("lp_code_rate").toUpperCase();
    transmission_mode = rs.getString("transmission_mode").toUpperCase().charAt(0);
    if (transmission_mode != 'A' && transmission_mode != '2' && transmission_mode != '8')
      throw new Misconfiguration("Unknown transmission mode " + transmission_mode);
    guard_interval = rs.getString("guard_interval").toUpperCase();
    String hier = rs.getString("hierarchy").toUpperCase();
    if (hier == null || hier.length() == 0)
      throw new Misconfiguration("hierarchy is empty, should probably be 'auto'");
    hierarchy = hier.charAt(0);
    if (hierarchy != 'A' && hierarchy != 'N' && hierarchy != '1' && hierarchy != '2' && hierarchy != '4')
      throw new Misconfiguration("Unknown hierarchy " + hierarchy);
    inversion = rs.getString("inversion").toUpperCase().charAt(0);
    if (inversion != 'A' && inversion != '1' && inversion != '0')
      throw new Misconfiguration("Unknown inversion " + inversion);
  }
  
  // physical tuning
  public char inversion;
  public char bandwidth;
  public String hp_code_rate;
  public String lp_code_rate;
  public char transmission_mode;
  public String guard_interval;
  public char hierarchy;
}
