From 216dbbfd18a36835b8a48d2f2e1e1ce2c65c8f14 Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Mon, 24 Nov 2008 22:42:42 +0100 Subject: catch up DiseqcTest development --- .../Plugins/SystemPlugins/DiseqcTester/Makefile.am | 5 + .../Plugins/SystemPlugins/DiseqcTester/__init__.py | 0 .../Plugins/SystemPlugins/DiseqcTester/plugin.py | 239 +++++++++++++++++++++ 3 files changed, 244 insertions(+) create mode 100644 lib/python/Plugins/SystemPlugins/DiseqcTester/Makefile.am create mode 100644 lib/python/Plugins/SystemPlugins/DiseqcTester/__init__.py create mode 100644 lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py (limited to 'lib/python/Plugins/SystemPlugins/DiseqcTester') diff --git a/lib/python/Plugins/SystemPlugins/DiseqcTester/Makefile.am b/lib/python/Plugins/SystemPlugins/DiseqcTester/Makefile.am new file mode 100644 index 00000000..cd72696a --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/DiseqcTester/Makefile.am @@ -0,0 +1,5 @@ +installdir = $(LIBDIR)/enigma2/python/Plugins/SystemPlugins/DiseqcTester + +install_PYTHON = \ + __init__.py \ + plugin.py \ No newline at end of file diff --git a/lib/python/Plugins/SystemPlugins/DiseqcTester/__init__.py b/lib/python/Plugins/SystemPlugins/DiseqcTester/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py b/lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py new file mode 100644 index 00000000..57340368 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py @@ -0,0 +1,239 @@ +from Screens.Satconfig import NimSelection +from Screens.Screen import Screen + +from Plugins.Plugin import PluginDescriptor + +from Components.ActionMap import NumberActionMap +from Components.NimManager import nimmanager +from Components.ResourceManager import resourcemanager +from Components.Sources.FrontendStatus import FrontendStatus +from Components.TuneTest import TuneTest +from Components.Sources.Progress import Progress +from Components.Sources.StaticText import StaticText + +class DiseqcTester(Screen, TuneTest): + skin = """ + + + + SNRdB + + + + SNR + + + SNR + + + + AGC + + + AGC + + + + BER + + + BER + + + + LOCK + + + + LOCK + Invert + + + + + + + + + + + + """ + + TEST_TYPE_QUICK = 0 + TEST_TYPE_RANDOM = 1 + TEST_TYPE_COMPLETE = 2 + def __init__(self, session, feid, test_type = TEST_TYPE_QUICK): + Screen.__init__(self, session) + self.feid = feid + self.test_type = test_type + + self["actions"] = NumberActionMap(["SetupActions"], + { + "ok": self.keyGo, + "cancel": self.keyCancel, + }, -2) + + TuneTest.__init__(self, feid, stopOnSuccess = True) + self["Frontend"] = FrontendStatus(frontend_source = lambda : self.frontend, update_interval = 100) + self["overall_progress"] = Progress() + self["sub_progress"] = Progress() + self["failed_counter"] = StaticText("10") + self["succeeded_counter"] = StaticText("10") + + self.indexlist = {} + self.readTransponderList() + + def readTransponderList(self): + for sat in nimmanager.getSatListForNim(self.feid): + for transponder in nimmanager.getTransponders(sat[0]): + #print transponder + mytransponder = (transponder[1] / 1000, transponder[2] / 1000, transponder[3], transponder[4], transponder[5], sat[0], None, None, transponder[10], transponder[11]) + self.analyseTransponder(mytransponder) + + def getIndexForTransponder(self, transponder): + if transponder[0] < 11700: + band = 1 # low + else: + band = 0 # high + + polarisation = transponder[2] + + sat = transponder[5] + + index = (band, polarisation, sat) + return index + + # sort the transponder into self.transponderlist + def analyseTransponder(self, transponder): + index = self.getIndexForTransponder(transponder) + if index not in self.indexlist: + self.indexlist[index] = [] + self.indexlist[index].append(transponder) + #print "self.indexlist:", self.indexlist + + # returns a string for the user representing a human readable output for index + def getTextualIndexRepresentation(self, index): + print "getTextualIndexRepresentation:", index + text = "" + + # TODO better sat representation + text += "%s, " % index[2] + + if index[0] == 1: + text += "Low Band, " + else: + text += "High Band, " + + if index[1] == 0: + text += "H" + else: + text += "V" + return text + + def fillTransponderList(self): + self.clearTransponder() + print "----------- fillTransponderList" + print "index:", self.currentlyTestedIndex + keys = self.indexlist.keys() + if self.getContinueScanning(): + print "index:", self.getTextualIndexRepresentation(self.currentlyTestedIndex) + for transponder in self.indexlist[self.currentlyTestedIndex]: + self.addTransponder(transponder) + print "transponderList:", self.transponderlist + return True + else: + return False + + def progressCallback(self, progress): + if progress[0] != self["sub_progress"].getRange(): + self["sub_progress"].setRange(progress[0]) + self["sub_progress"].setValue(progress[1]) + + # logic for scanning order of transponders + # on go getFirstIndex is called + def getFirstIndex(self): + # TODO use other function to scan more randomly + if self.test_type == self.TEST_TYPE_QUICK: + self.myindex = 0 + keys = self.indexlist.keys() + self["overall_progress"].setRange(len(keys)) + self["overall_progress"].setValue(self.myindex) + return keys[0] + + # after each index is finished, getNextIndex is called to get the next index to scan + def getNextIndex(self): + # TODO use other function to scan more randomly + if self.test_type == self.TEST_TYPE_QUICK: + self.myindex += 1 + keys = self.indexlist.keys() + + self["overall_progress"].setValue(self.myindex) + if self.myindex < len(keys): + return keys[self.myindex] + else: + return None + + # after each index is finished and the next index is returned by getNextIndex + # the algorithm checks, if we should continue scanning + def getContinueScanning(self): + if self.test_type == self.TEST_TYPE_QUICK: + return (self.myindex < len(self.indexlist.keys())) + + def finishedChecking(self): + print "finishedChecking" + TuneTest.finishedChecking(self) + self.currentlyTestedIndex = self.getNextIndex() + if self.fillTransponderList(): + self.run(checkPIDs = True) + + def keyGo(self): + self.currentlyTestedIndex = self.getFirstIndex() + if self.fillTransponderList(): + self.run(True) + + def keyCancel(self): + self.close() + +class DiseqcTesterNimSelection(NimSelection): + skin = """ + + + + {"template": [ + MultiContentEntryText(pos = (10, 5), size = (360, 30), flags = RT_HALIGN_LEFT, text = 1), # index 1 is the nim name, + MultiContentEntryText(pos = (50, 30), size = (320, 30), font = 1, flags = RT_HALIGN_LEFT, text = 2), # index 2 is a description of the nim settings, + ], + "fonts": [gFont("Regular", 20), gFont("Regular", 15)], + "itemHeight": 70 + } + + + """ + + def __init__(self, session, args = None): + NimSelection.__init__(self, session) + + def setResultClass(self): + self.resultclass = DiseqcTester + + def showNim(self, nim): + nimConfig = nimmanager.getNimConfig(nim.slot) + if nim.isCompatible("DVB-S"): + if nimConfig.configMode.value in ["loopthrough", "equal", "satposdepends", "nothing"]: + return False + if nimConfig.configMode.value == "simple": + if nimConfig.diseqcMode.value == "positioner": + return False + return True + return False + +def DiseqcTesterMain(session, **kwargs): + session.open(DiseqcTesterNimSelection) + +def autostart(reason, **kwargs): + resourcemanager.addResource("DiseqcTester", DiseqcTesterMain) + +def Plugins(**kwargs): + return [ PluginDescriptor(name="DiSEqC Tester", description=_("Test DiSEqC settings"), where = PluginDescriptor.WHERE_PLUGINMENU, fnc=DiseqcTesterMain), + PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart)] \ No newline at end of file -- cgit v1.2.3