1 from GUIComponent import GUIComponent
3 from enigma import eLabel, eSlider, iFrontendStatusInformation
7 class TunerInfo(GUIComponent):
21 def __init__(self, type, servicefkt = None, frontendfkt = None):
22 GUIComponent.__init__(self)
27 self.servicefkt = servicefkt
28 self.frontendfkt = frontendfkt
32 def setText(self, text):
35 self.instance.setText(self.message)
37 def setValue(self, value):
40 self.instance.setValue(self.value)
46 return (long)(log(val)/log(2))
50 if self.type == self.SNR_PERCENTAGE or self.type == self.SNR_BAR:
51 value = self.getValue(self.SNR) * 100 / 65536
52 elif self.type == self.AGC_PERCENTAGE or self.type == self.AGC_BAR:
53 value = self.getValue(self.AGC) * 100 / 65536
54 elif self.type == self.BER_VALUE or self.type == self.BER_BAR:
55 value = self.getValue(self.BER)
56 elif self.type == self.LOCK_STATE:
57 value = self.getValue(self.LOCK)
59 if self.type == self.SNR_PERCENTAGE or self.type == self.AGC_PERCENTAGE:
60 self.setText("%d%%" % (value))
61 elif self.type == self.BER_VALUE:
62 self.setText("%d" % (value))
63 elif self.type == self.SNR_BAR or self.type == self.AGC_BAR:
65 elif self.type == self.BER_BAR:
66 self.setValue(self.calc(value))
67 elif self.type == self.LOCK_STATE:
69 self.setText(_("locked"))
71 self.setText(_("not locked"))
73 def getValue(self, what):
74 if self.servicefkt is not None:
75 service = self.servicefkt()
76 if service is not None:
77 feinfo = service.frontendStatusInfo()
78 if feinfo is not None:
80 return feinfo.getFrontendInfo(iFrontendStatusInformation.signalPower)
81 elif what == self.AGC:
82 return feinfo.getFrontendInfo(iFrontendStatusInformation.signalQuality)
83 elif what == self.BER:
84 return feinfo.getFrontendInfo(iFrontendStatusInformation.bitErrorRate)
85 elif what == self.LOCK:
86 return feinfo.getFrontendInfo(iFrontendStatusInformation.LockState)
87 elif self.frontendfkt is not None:
88 frontend = self.frontendfkt()
90 return frontend.readFrontendData(iFrontendStatusInformation.signalPower)
91 elif what == self.AGC:
92 return frontend.readFrontendData(iFrontendStatusInformation.signalQuality)
93 elif what == self.BER:
94 return frontend.readFrontendData(iFrontendStatusInformation.bitErrorRate)
95 elif what == self.LOCK:
96 return frontend.readFrontendData(iFrontendStatusInformation.LockState)
100 def createWidget(self, parent):
101 if self.SNR_PERCENTAGE <= self.type <= self.BER_VALUE or self.type == self.LOCK_STATE:
102 return eLabel(parent)
103 elif self.SNR_BAR <= self.type <= self.BER_BAR:
104 self.g = eSlider(parent)
105 self.g.setRange(0, 100)
108 def postWidgetCreate(self, instance):
109 if self.message is not None:
110 instance.setText(self.message)
111 elif self.value is not None:
112 instance.setValue(self.value)