def make_panel(wid, offset, bw, filtertype, transition, sql, afc):
    """ Create new xlater in model """
    model.append(None)
    model[-1] = [
        int(wid),
        libutil.safe_cast(offset, int, 0), filtertype,
        libutil.safe_cast(transition, int, 0),
        libutil.safe_cast(bw, int, 0), afc, sql,
        libutil.safe_cast(frequency + offset, int, 0)
    ]
Example #2
0
def make_panel(wid, offset, bw, filtertype, transition, sql, afc):
    """ Create new xlater in model """
    model.append(None)
    model[-1] = [
        int(wid),
        libutil.safe_cast(offset, int, 0),
        filtertype,
        libutil.safe_cast(transition, int, 0),
        libutil.safe_cast(bw, int, 0),
        afc,
        sql,
        libutil.safe_cast(frequency + offset, int, 0),
    ]
Example #3
0
  def set_frequency(self, f):
    hdr = struct.pack(proto.ENDIAN+"i", proto.RETUNE)

    msg = c2s.CLI_RETUNE()
    msg.freq = libutil.safe_cast(f, int)

    self.q_msg(hdr + msg.SerializeToString())
Example #4
0
    def set_frequency(self, f):
        hdr = struct.pack(proto.ENDIAN + "i", proto.RETUNE)

        msg = c2s.CLI_RETUNE()
        msg.freq = libutil.safe_cast(f, int)

        self.q_msg(hdr + msg.SerializeToString())
Example #5
0
def on_sql_change(widget, event):
    """ Handle edit in the SQL textbox """
    global conf

    if not is_enter(event):
        return False

    conf.sqldelta = libutil.safe_cast(tb_sql.get_text(), float, conf.sqldelta)
    tb_sql.set_text(str(conf.sqldelta))
Example #6
0
def on_sql_change(widget, event):
  """ Handle edit in the SQL textbox """
  global conf

  if not is_enter(event):
    return False

  conf.sqldelta = libutil.safe_cast(tb_sql.get_text(), float, conf.sqldelta)
  tb_sql.set_text(str(conf.sqldelta))
Example #7
0
 def croncmp(self, i, frag):
   """ Compare cron field (e.g. "*", "15" or "*/5"), return True on positive match.
   i - number to compare with
   frag - the cron field
   """
   if frag == "*":
     return True
   if frag[:2] == "*/":
     num = safe_cast(frag[2:], int, None)
     if not num or num == 0:
       self.l.l("Invalid modulo number %s"%frag[2:], "CRIT")
       return False
     if i % num == 0:
       return True
   raw = safe_cast(frag, int, None)
   if raw is not None:
     if raw == i:
       return True
   return False
Example #8
0
def on_ppm_change(widget, event):
    """ Handle edit in the PPM textbox """
    global ppm

    if not is_enter(event):
        return False

    ppm = libutil.safe_cast(tb_ppm.get_text(), int, ppm)
    tb_ppm.set_text(str(ppm))

    cl.set_ppm(ppm)
Example #9
0
def on_ppm_change(widget, event):
  """ Handle edit in the PPM textbox """
  global ppm

  if not is_enter(event):
    return False

  ppm = libutil.safe_cast(tb_ppm.get_text(), int, ppm)
  tb_ppm.set_text(str(ppm))

  cl.set_ppm(ppm)
Example #10
0
def on_freq_change(widget, event):
    """ Handle edit in the Frequency textbox """
    global frequency

    if not is_enter(event):
        return False

    newf = libutil.safe_cast(libutil.engnum(tb_freq.get_text()), int)
    if newf:
        cl.set_frequency(newf)
        frequency = newf
    return True
Example #11
0
def on_freq_change(widget, event):
  """ Handle edit in the Frequency textbox """
  global frequency

  if not is_enter(event):
    return False

  newf = libutil.safe_cast(libutil.engnum(tb_freq.get_text()), int)
  if newf:
    cl.set_frequency(newf)
    frequency = newf
  return True
Example #12
0
def on_gain_change(widget, event):
    """  Handle edit in the Gain textbox """
    if not is_enter(event):
        return False

    # if tb_gain.get_text() in ["a", "A", "auto"]:
    #  cl.set_gain(1, [0])
    # else:
    pieces = tb_gain.get_text().split(",")
    l = []
    for p in pieces:
        l.append(libutil.safe_cast(p, int, 0))
    cl.set_gain(l)
Example #13
0
def on_gain_change(widget, event):
  """  Handle edit in the Gain textbox """
  if not is_enter(event):
    return False

  #if tb_gain.get_text() in ["a", "A", "auto"]:
  #  cl.set_gain(1, [0])
  #else:
  pieces = tb_gain.get_text().split(",")
  l = []
  for p in pieces:
    l.append(libutil.safe_cast(p, int, 0))
  cl.set_gain(l)
Example #14
0
def xlater_edit(cell, row, new_value, field):
    """ Row in listview changed """
    cl.acquire_xlaters()
    newcast = libutil.safe_cast(libutil.engnum(new_value), type(model[row][field]))

    if not newcast:
        showerror("Value was not understood")
        return

    # handle frequency/offset consistency
    if field == 7:
        model[row][1] = newcast - frequency
    elif field == 1:
        model[row][7] = frequency + newcast

    model[row][field] = newcast
    commit_xlater(row)
    cl.release_xlaters()
Example #15
0
def xlater_edit(cell, row, new_value, field):
  """ Row in listview changed """
  cl.acquire_xlaters()
  newcast = libutil.safe_cast(libutil.engnum(new_value), type(model[row][field]))

  if not newcast:
    showerror("Value was not understood")
    return

  # handle frequency/offset consistency
  if field == 7:
    model[row][1] = newcast - frequency
  elif field == 1:
    model[row][7] = frequency + newcast

  model[row][field] = newcast
  commit_xlater(row)
  cl.release_xlaters()
Example #16
0
def float2color(f):
  """
  Get color index from power readings
  """
  idx = conf.spectrumscale*(f + conf.spectrumoffset)
  return max(0, min(libutil.safe_cast(idx, int, 0), len(colormap)-1))
Example #17
0
def float2color(f):
    """
  Get color index from power readings
  """
    idx = conf.spectrumscale * (f + conf.spectrumoffset)
    return max(0, min(libutil.safe_cast(idx, int, 0), len(colormap) - 1))