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 return self.source.lock
61 return self.source.ber > 0
63 text = property(getText)
65 boolean = property(getBool)
69 assert self.type != self.LOCK, "the value/range output of FrontendInfo can not be used for lock info"
70 if self.type == self.AGC:
71 return self.source.agc or 0
72 elif self.type == self.SNR:
73 return self.source.snr or 0
74 elif self.type == self.BER:
75 if self.BER < self.range:
79 elif self.type == self.TUNER_TYPE:
80 type = self.source.frontend_type
88 elif self.type == self.SLOT_NUMBER:
89 return self.source.slot_number or -1
92 value = property(getValue)