add FrontendStatus source, add converter to SNR/AGC/BER bar and text
[enigma2.git] / lib / python / Components / Sources / FrontendStatus.py
1 from Source import Source
2 from enigma import eTimer, iFrontendInformation
3
4 class FrontendStatus(Source):
5         def __init__(self, service_source = None, frontend_source = None):
6                 Source.__init__(self)
7                 self.service_source = service_source
8                 self.frontend_source = frontend_source
9                 self.invalidate()
10                 
11                 self.poll_timer = eTimer()
12                 self.poll_timer.timeout.get().append(self.updateFrontendStatus)
13                 self.poll_timer.start(1000)
14
15         def invalidate(self):
16                 self.snr = self.agc = self.ber = self.lock = None
17
18         def updateFrontendStatus(self):
19                 print "update frontend status. %d downstream elements" % len(self.downstream_elements)
20                 feinfo = self.getFrontendInfo()
21                 if feinfo is None:
22                         self.invalidate()
23                 else:
24                         (self.snr, self.agc, self.ber, self.lock) = \
25                                 [feinfo.getFrontendInfo(x) \
26                                         for x in [iFrontendInformation.signalPower, 
27                                                 iFrontendInformation.signalQuality, 
28                                                 iFrontendInformation.bitErrorRate, 
29                                                 iFrontendInformation.lockState] ]
30
31                 self.changed()
32
33         def getFrontendInfo(self):
34                 if self.frontend_source:
35                         return self.frontend_source()
36                 elif self.service_source:
37                         service = self.service_source()
38                         return service and service.frontendInfo()
39                 else:
40                         return None