aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>2006-04-04 09:24:39 +0000
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>2006-04-04 09:24:39 +0000
commit200264273687a4c4bd97574ee7f725122548d019 (patch)
tree0568e6181ddd0ba4e8d34d3eea6065adebbfc11f /lib
parentdeddfcf89d1356ae1b3782f800ad6925caf92335 (diff)
downloadenigma2-200264273687a4c4bd97574ee7f725122548d019.tar.gz
enigma2-200264273687a4c4bd97574ee7f725122548d019.zip
avoid future redundant code by moving functionality for tuner status display to a seperate component (which is a BIT slower because infobar values are gathered twice)
Diffstat (limited to 'lib')
-rw-r--r--lib/python/Components/Makefile.am2
-rw-r--r--lib/python/Components/TunerInfo.py83
-rw-r--r--lib/python/Components/__init__.py2
-rw-r--r--lib/python/Screens/InfoBarGenerics.py44
4 files changed, 98 insertions, 33 deletions
diff --git a/lib/python/Components/Makefile.am b/lib/python/Components/Makefile.am
index 94a8c06c..8f43cae1 100644
--- a/lib/python/Components/Makefile.am
+++ b/lib/python/Components/Makefile.am
@@ -13,6 +13,6 @@ install_PYTHON = \
BlinkingPixmap.py Pixmap.py ConditionalWidget.py Slider.py LanguageList.py \
PluginList.py PluginComponent.py RecordingConfig.py About.py UsageConfig.py \
FIFOList.py ServiceEventTracker.py Input.py TimerSanityCheck.py FileList.py \
- MultiContent.py MediaPlayer.py
+ MultiContent.py MediaPlayer.py TunerInfo.py
diff --git a/lib/python/Components/TunerInfo.py b/lib/python/Components/TunerInfo.py
new file mode 100644
index 00000000..e22ce468
--- /dev/null
+++ b/lib/python/Components/TunerInfo.py
@@ -0,0 +1,83 @@
+from GUIComponent import GUIComponent
+
+from enigma import eLabel, eSlider, iFrontendStatusInformation
+
+from math import log
+
+class TunerInfo(GUIComponent):
+ SNR_PERCENTAGE = 0
+ AGC_PERCENTAGE = 1
+ BER_VALUE = 2
+ SNR_BAR = 3
+ AGC_BAR = 4
+ BER_BAR = 5
+ def __init__(self, type, servicefkt):
+ GUIComponent.__init__(self)
+ self.instance = None
+ self.message = None
+ self.value = None
+
+ self.servicefkt = servicefkt
+ self.type = type
+ self.update()
+
+ def setText(self, text):
+ self.message = text
+ if self.instance:
+ self.instance.setText(self.message)
+
+ def setValue(self, value):
+ self.value = value
+ if self.instance:
+ self.instance.setValue(self.value)
+
+ def calc(self,val):
+ if not val:
+ return 0
+ if val < 2500:
+ return (long)(log(val)/log(2))
+ return val*100/65535
+
+ def update(self):
+ service = self.servicefkt()
+ value = 0
+ if service is not None:
+ feinfo = service.frontendStatusInfo()
+ if feinfo is not None:
+ if self.type == self.SNR_PERCENTAGE or self.type == self.SNR_BAR:
+ value = feinfo.getFrontendInfo(iFrontendStatusInformation.signalPower) * 100 / 65536
+ elif self.type == self.AGC_PERCENTAGE or self.type == self.AGC_BAR:
+ value = feinfo.getFrontendInfo(iFrontendStatusInformation.signalQuality) * 100 / 65536
+ elif self.type == self.BER_VALUE or self.type == self.BER_BAR:
+ value = feinfo.getFrontendInfo(iFrontendStatusInformation.bitErrorRate)
+
+ if self.type == self.SNR_PERCENTAGE or self.type == self.AGC_PERCENTAGE:
+ self.setText("%d%%" % (value))
+ elif self.type == self.BER_VALUE:
+ self.setText("%d" % (value))
+ elif self.type == self.SNR_BAR or self.type == self.AGC_BAR:
+ self.setValue(value)
+ elif self.type == self.BER_BAR:
+ self.setValue(self.calc(value))
+
+ def createWidget(self, parent):
+ if self.SNR_PERCENTAGE <= self.type <= self.BER_VALUE:
+ return eLabel(parent)
+ elif self.SNR_BAR <= self.type <= self.BER_BAR:
+ self.g = eSlider(parent)
+ self.g.setRange(0, 100)
+ return self.g
+
+ def GUIcreate(self, parent):
+ self.instance = self.createWidget(parent)
+ if self.message is not None:
+ self.instance.setText(self.message)
+ elif self.value is not None:
+ self.instance.setValue(self.value)
+
+ def GUIdelete(self):
+ self.removeWidget(self.instance)
+ self.instance = None
+
+ def removeWidget(self, instance):
+ pass \ No newline at end of file
diff --git a/lib/python/Components/__init__.py b/lib/python/Components/__init__.py
index 1b148d79..b6ad939c 100644
--- a/lib/python/Components/__init__.py
+++ b/lib/python/Components/__init__.py
@@ -7,4 +7,4 @@ __all__ = ["ActionMap", "Button", "Clock", "ConfigList", "EventInfo",
"InputDevice", "ServicePosition", "IPAddress", "VariableIP", "IPGateway",
"IPNameserver", "Network", "RFmon", "DiskInfo", "NimManager", "TimerEntry",
"Lcd", "EpgList" "ScrollLabel", "Timezones", "HelpMenuList", "TimerSanityCheck",
- "FileList", "MultiContent" ]
+ "FileList", "MultiContent", "TunerInfo" ]
diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py
index f8b185f0..358ef44d 100644
--- a/lib/python/Screens/InfoBarGenerics.py
+++ b/lib/python/Screens/InfoBarGenerics.py
@@ -16,6 +16,7 @@ from Components.ServiceName import ServiceName
from Components.config import config, configElement, ConfigSubsection, configSequence, configElementBoolean
from Components.config import configfile, configsequencearg
from Components.TimerList import TimerEntryComponent
+from Components.TunerInfo import TunerInfo
from EpgSelection import EPGSelection
from Plugins.Plugin import PluginDescriptor
@@ -429,49 +430,30 @@ class InfoBarEPG:
self.epglist[1]=tmp
setEvent(self.epglist[0])
-from math import log
-
class InfoBarTuner:
"""provides a snr/agc/ber display"""
def __init__(self):
self["snr"] = Label()
self["agc"] = Label()
self["ber"] = Label()
- self["snr_percent"] = Label()
- self["agc_percent"] = Label()
- self["ber_count"] = Label()
- self["snr_progress"] = ProgressBar()
- self["agc_progress"] = ProgressBar()
- self["ber_progress"] = ProgressBar()
+ self["snr_percent"] = TunerInfo(TunerInfo.SNR_PERCENTAGE, self.session.nav.getCurrentService)
+ self["agc_percent"] = TunerInfo(TunerInfo.AGC_PERCENTAGE, self.session.nav.getCurrentService)
+ self["ber_count"] = TunerInfo(TunerInfo.BER_VALUE, self.session.nav.getCurrentService)
+ self["snr_progress"] = TunerInfo(TunerInfo.SNR_BAR, self.session.nav.getCurrentService)
+ self["agc_progress"] = TunerInfo(TunerInfo.AGC_BAR, self.session.nav.getCurrentService)
+ self["ber_progress"] = TunerInfo(TunerInfo.BER_BAR, self.session.nav.getCurrentService)
self.timer = eTimer()
self.timer.timeout.get().append(self.updateTunerInfo)
self.timer.start(1000)
- def calc(self,val):
- if not val:
- return 0
- if val < 2500:
- return (long)(log(val)/log(2))
- return val*100/65535
-
def updateTunerInfo(self):
if self.instance.isVisible():
- service = self.session.nav.getCurrentService()
- snr=0
- agc=0
- ber=0
- if service is not None:
- feinfo = service.frontendStatusInfo()
- if feinfo is not None:
- ber=feinfo.getFrontendInfo(iFrontendStatusInformation.bitErrorRate)
- snr=feinfo.getFrontendInfo(iFrontendStatusInformation.signalPower)*100/65536
- agc=feinfo.getFrontendInfo(iFrontendStatusInformation.signalQuality)*100/65536
- self["snr_percent"].setText("%d%%"%(snr))
- self["agc_percent"].setText("%d%%"%(agc))
- self["ber_count"].setText("%d"%(ber))
- self["snr_progress"].setValue(snr)
- self["agc_progress"].setValue(agc)
- self["ber_progress"].setValue(self.calc(ber))
+ self["snr_percent"].update()
+ self["agc_percent"].update()
+ self["ber_count"].update()
+ self["snr_progress"].update()
+ self["agc_progress"].update()
+ self["ber_progress"].update()
class InfoBarEvent:
"""provides a current/next event info display"""