1 from Source import Source
2 from enigma import eTimer
4 class FrontendStatus(Source):
5 def __init__(self, service_source = None, frontend_source = None, update_interval = 1000):
7 self.update_interval = update_interval
8 self.service_source = service_source
9 self.frontend_source = frontend_source
11 self.poll_timer = eTimer()
12 self.poll_timer.callback.append(self.updateFrontendStatus)
13 self.poll_timer.start(update_interval, True)
16 self.snr = self.agc = self.ber = self.lock = self.snr_db = None
18 def updateFrontendStatus(self):
19 status = self.getFrontendStatus()
23 self.snr = status.get("tuner_signal_quality")
24 self.snr_db = status.get("tuner_signal_quality_db")
25 self.agc = status.get("tuner_signal_power")
26 self.ber = status.get("tuner_bit_error_rate")
27 self.lock = status.get("tuner_locked")
28 self.changed((self.CHANGED_ALL, ))
29 self.poll_timer.start(self.update_interval, True)
31 def getFrontendStatus(self):
32 if self.frontend_source:
33 frontend = self.frontend_source()
36 frontend.getFrontendStatus(dict)
38 elif self.service_source:
39 service = self.service_source()
40 feinfo = service and service.frontendInfo()
41 return feinfo and feinfo.getFrontendStatus()
45 def doSuspend(self, suspended):
47 self.poll_timer.stop()
49 self.updateFrontendStatus()
52 self.poll_timer.callback.remove(self.updateFrontendStatus)