1 from Components.Converter.Converter import Converter
2 from Components.Element import cached
4 class FrontendInfo(Converter, object):
13 def __init__(self, type):
14 Converter.__init__(self, type)
20 self.type = self.SNRdB
23 elif type == "NUMBER":
24 self.type = self.SLOT_NUMBER
26 self.type = self.TUNER_TYPE
32 assert self.type not in (self.LOCK, self.SLOT_NUMBER), "the text output of FrontendInfo cannot be used for lock info"
34 if self.type == self.BER: # as count
35 count = self.source.ber
40 elif self.type == self.AGC:
41 percent = self.source.agc
42 elif self.type == self.SNR:
43 percent = self.source.snr
44 elif self.type == self.SNRdB:
45 if self.source.snr_db is not None:
46 return "%3.02f dB" % (self.source.snr_db / 100.0)
47 elif self.source.snr is not None: #fallback to normal SNR...
48 percent = self.source.snr
49 elif self.type == self.TUNER_TYPE:
50 return self.source.frontend_type and self.frontend_type or "Unknown"
53 return "%d %%" % (percent * 100 / 65536)
57 assert self.type in (self.LOCK, self.BER), "the boolean output of FrontendInfo can only be used for lock or BER info"
58 if self.type == self.LOCK:
59 lock = self.source.lock
69 text = property(getText)
71 boolean = property(getBool)
75 assert self.type != self.LOCK, "the value/range output of FrontendInfo can not be used for lock info"
76 if self.type == self.AGC:
77 return self.source.agc or 0
78 elif self.type == self.SNR:
79 return self.source.snr or 0
80 elif self.type == self.BER:
81 if self.BER < self.range:
85 elif self.type == self.TUNER_TYPE:
86 type = self.source.frontend_type
94 elif self.type == self.SLOT_NUMBER:
95 num = self.source.slot_number
96 return num is None and -1 or num
99 value = property(getValue)