X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/68311d2054d10b9b1c043e4e615147728c5e6aa0..3599539f102d1c20c9c967249a06bbfcf6e7db2d:/lib/python/Plugins/SystemPlugins/Satfinder/plugin.py diff --git a/lib/python/Plugins/SystemPlugins/Satfinder/plugin.py b/lib/python/Plugins/SystemPlugins/Satfinder/plugin.py index 8cc93f69..3cf48fb8 100644 --- a/lib/python/Plugins/SystemPlugins/Satfinder/plugin.py +++ b/lib/python/Plugins/SystemPlugins/Satfinder/plugin.py @@ -1,16 +1,17 @@ -from enigma import eTimer, eDVBSatelliteEquipmentControl, eDVBResourceManager, eDVBDiseqcCommand, eDVBResourceManagerPtr, iDVBChannelPtr, iDVBFrontendPtr, iDVBFrontend, eDVBFrontendParametersSatellite, eDVBFrontendParameters +from enigma import eTimer, eDVBResourceManager,\ + eDVBFrontendParametersSatellite, eDVBFrontendParameters + from Screens.Screen import Screen from Screens.ScanSetup import ScanSetup from Screens.MessageBox import MessageBox from Plugins.Plugin import PluginDescriptor from Components.Label import Label -from Components.ConfigList import ConfigList from Components.TunerInfo import TunerInfo from Components.ActionMap import ActionMap -from Components.NimManager import nimmanager +from Components.NimManager import nimmanager, getConfigSatlist from Components.MenuList import MenuList -from Components.config import config, ConfigSubsection, configElement_nonSave, configNothing, getConfigListEntry, configSelection, currentConfigSelectionElement, configSatlist +from Components.config import ConfigSelection, getConfigListEntry class Tuner: def __init__(self, frontend): @@ -56,12 +57,12 @@ class Satfinder(ScanSetup): """ def openFrontend(self): - res_mgr = eDVBResourceManagerPtr() - if eDVBResourceManager.getInstance(res_mgr) == 0: - self.raw_channel = iDVBChannelPtr() - if res_mgr.allocateRawChannel(self.raw_channel, self.feid) == 0: - self.frontend = iDVBFrontendPtr() - if self.raw_channel.getFrontend(self.frontend) == 0: + res_mgr = eDVBResourceManager.getInstance() + if res_mgr: + self.raw_channel = res_mgr.allocateRawChannel(self.feid) + if self.raw_channel: + self.frontend = self.raw_channel.getFrontend() + if self.frontend: return True else: print "getFrontend failed" @@ -71,41 +72,49 @@ class Satfinder(ScanSetup): print "getResourceManager instance failed" return False - def getFrontend(self): - return self.frontend - def __init__(self, session, feid): self.initcomplete = False self.feid = feid - + self.oldref = None + self.frontendStatus = { } + if not self.openFrontend(): - self.frontend = None + self.oldref = session.nav.getCurrentlyPlayingServiceReference() + session.nav.stopService() # try to disable foreground service + if not self.openFrontend(): + if session.pipshown: # try to disable pip + session.pipshown = False + del session.pip + if not self.openFrontend(): + self.frontend = None # in normal case this should not happen ScanSetup.__init__(self, session) - self.session.nav.stopService() self.tuner = Tuner(self.frontend) self["snr"] = Label() self["agc"] = Label() self["ber"] = Label() self["lock"] = Label() - self["snr_percentage"] = TunerInfo(TunerInfo.SNR_PERCENTAGE, frontendfkt = self.getFrontend) - self["agc_percentage"] = TunerInfo(TunerInfo.AGC_PERCENTAGE, frontendfkt = self.getFrontend) - self["ber_value"] = TunerInfo(TunerInfo.BER_VALUE, frontendfkt = self.getFrontend) - self["snr_bar"] = TunerInfo(TunerInfo.SNR_BAR, frontendfkt = self.getFrontend) - self["agc_bar"] = TunerInfo(TunerInfo.AGC_BAR, frontendfkt = self.getFrontend) - self["ber_bar"] = TunerInfo(TunerInfo.BER_BAR, frontendfkt = self.getFrontend) - self["lock_state"] = TunerInfo(TunerInfo.LOCK_STATE, frontendfkt = self.getFrontend) - - self["introduction"].setText("") + self["snr_percentage"] = TunerInfo(TunerInfo.SNR_PERCENTAGE, statusDict = self.frontendStatus) + self["agc_percentage"] = TunerInfo(TunerInfo.AGC_PERCENTAGE, statusDict = self.frontendStatus) + self["ber_value"] = TunerInfo(TunerInfo.BER_VALUE, statusDict = self.frontendStatus) + self["snr_bar"] = TunerInfo(TunerInfo.SNR_BAR, statusDict = self.frontendStatus) + self["agc_bar"] = TunerInfo(TunerInfo.AGC_BAR, statusDict = self.frontendStatus) + self["ber_bar"] = TunerInfo(TunerInfo.BER_BAR, statusDict = self.frontendStatus) + self["lock_state"] = TunerInfo(TunerInfo.LOCK_STATE, statusDict = self.frontendStatus) + self["introduction"].setText("") + self.statusTimer = eTimer() self.statusTimer.timeout.get().append(self.updateStatus) self.statusTimer.start(50, False) - self.initcomplete = True - + def updateStatus(self): + if self.frontend: + self.frontend.getFrontendStatus(self.frontendStatus) + else: + self.frontendStatus.clear() self["snr_percentage"].update() self["agc_percentage"].update() self["ber_value"].update() @@ -117,20 +126,20 @@ class Satfinder(ScanSetup): def createSetup(self): self.typeOfTuningEntry = None self.satEntry = None - + self.list = [] - self.typeOfTuningEntry = getConfigListEntry(_('Tune'), config.tuning.type) + self.typeOfTuningEntry = getConfigListEntry(_('Tune'), self.tuning_type) self.list.append(self.typeOfTuningEntry) - self.satEntry = getConfigListEntry(_('Satellite'), config.tuning.sat) + self.satEntry = getConfigListEntry(_('Satellite'), self.tuning_sat) self.list.append(self.satEntry) - if currentConfigSelectionElement(config.tuning.type) == "manual_transponder": - self.list.append(getConfigListEntry(_('Frequency'), config.scan.sat.frequency)) - self.list.append(getConfigListEntry(_('Inversion'), config.scan.sat.inversion)) - self.list.append(getConfigListEntry(_('Symbol Rate'), config.scan.sat.symbolrate)) - self.list.append(getConfigListEntry(_("Polarity"), config.scan.sat.polarization)) - self.list.append(getConfigListEntry(_("FEC"), config.scan.sat.fec)) - elif currentConfigSelectionElement(config.tuning.type) == "predefined_transponder": - self.list.append(getConfigListEntry(_("Transponder"), config.tuning.transponder)) + if self.tuning_type.value == "manual_transponder": + self.list.append(getConfigListEntry(_('Frequency'), self.scan_sat.frequency)) + self.list.append(getConfigListEntry(_('Inversion'), self.scan_sat.inversion)) + self.list.append(getConfigListEntry(_('Symbol Rate'), self.scan_sat.symbolrate)) + self.list.append(getConfigListEntry(_("Polarity"), self.scan_sat.polarization)) + self.list.append(getConfigListEntry(_("FEC"), self.scan_sat.fec)) + elif self.tuning_transponder and self.tuning_type.value == "predefined_transponder": + self.list.append(getConfigListEntry(_("Transponder"), self.tuning_transponder)) self["config"].list = self.list self["config"].l.setList(self.list) @@ -141,38 +150,42 @@ class Satfinder(ScanSetup): self.updateSats() self.createSetup() + def sat_changed(self, config_element): + self.newConfig() + self.retune(config_element) + def retune(self, configElement): returnvalue = (0, 0, 0, 0, 0, 0, 0) - satpos = config.tuning.sat.vals[config.tuning.sat.value][1] - if currentConfigSelectionElement(config.tuning.type) == "manual_transponder": - returnvalue = (config.scan.sat.frequency.value[0], config.scan.sat.symbolrate.value[0], config.scan.sat.polarization.value, config.scan.sat.fec.value, config.scan.sat.inversion.value, satpos) - elif currentConfigSelectionElement(config.tuning.type) == "predefined_transponder": - transponder = nimmanager.getTransponders(config.tuning.sat.vals[config.tuning.sat.value][1])[config.tuning.transponder.value] - returnvalue = (int(transponder[1] / 1000), int(transponder[2] / 1000), transponder[3], transponder[4], 2, config.tuning.sat.vals[config.tuning.sat.value][1], satpos) - self.tune(returnvalue) + satpos = self.tuning_sat.orbital_position + + if satpos is not None: + if self.tuning_type.value == "manual_transponder": + returnvalue = (self.scan_sat.frequency.value, self.scan_sat.symbolrate.value, self.scan_sat.polarization.index, self.scan_sat.fec.index, self.scan_sat.inversion.index, satpos) + elif self.tuning_type.value == "predefined_transponder": + transponder = nimmanager.getTransponders(satpos)[self.tuning_transponder.index] + returnvalue = (int(transponder[1] / 1000), int(transponder[2] / 1000), transponder[3], transponder[4], 2, satpos) + self.tune(returnvalue) def createConfig(self, foo): - config.tuning = ConfigSubsection() - - config.tuning.type = configElement_nonSave("config.tuning.type", configSelection, 0, (("manual_transponder", _("Manual transponder")), ("predefined_transponder", _("Predefined satellite")))) - config.tuning.sat = configElement_nonSave("config.tuning.sat", configSatlist, 192, nimmanager.getSatListForNim(self.feid)) + self.tuning_transponder = None + self.tuning_type = ConfigSelection(choices = [("manual_transponder", _("Manual transponder")), ("predefined_transponder", _("Predefined transponder"))]) + self.tuning_sat = getConfigSatlist(192, nimmanager.getSatListForNim(self.feid)) ScanSetup.createConfig(self, None) self.updateSats() - - config.tuning.type.addNotifier(self.retune) - config.tuning.sat.addNotifier(self.retune) - config.scan.sat.frequency.addNotifier(self.retune) - config.scan.sat.inversion.addNotifier(self.retune) - config.scan.sat.symbolrate.addNotifier(self.retune) - config.scan.sat.polarization.addNotifier(self.retune) - config.scan.sat.fec.addNotifier(self.retune) + + self.tuning_type.addNotifier(self.retune, initial_call = False) + self.tuning_sat.addNotifier(self.sat_changed, initial_call = False) + self.scan_sat.frequency.addNotifier(self.retune, initial_call = False) + self.scan_sat.inversion.addNotifier(self.retune, initial_call = False) + self.scan_sat.symbolrate.addNotifier(self.retune, initial_call = False) + self.scan_sat.polarization.addNotifier(self.retune, initial_call = False) + self.scan_sat.fec.addNotifier(self.retune, initial_call = False) def updateSats(self): - satnum = config.tuning.sat.value - satlist = config.tuning.sat.vals - if len(satlist): - transponderlist = nimmanager.getTransponders(satlist[satnum][1]) + orb_pos = self.tuning_sat.orbital_position + if orb_pos is not None: + transponderlist = nimmanager.getTransponders(orb_pos) list = [] for x in transponderlist: if x[3] == 0: @@ -200,22 +213,26 @@ class Satfinder(ScanSetup): elif x[4] == 6: fec = "FEC_None" list.append(str(x[1]) + "," + str(x[2]) + "," + pol + "," + fec) - config.tuning.transponder = configElement_nonSave("config.tuning.transponder", configSelection, 0, list) - config.tuning.transponder.addNotifier(self.retune) - + self.tuning_transponder = ConfigSelection(choices = list) + self.tuning_transponder.addNotifier(self.retune, initial_call = False) + def keyGo(self): - returnvalue = (0, 0, 0, 0, 0, 0, 0) - satpos = config.tuning.sat.vals[config.tuning.sat.value][1] - if currentConfigSelectionElement(config.tuning.type) == "manual_transponder": - returnvalue = (config.scan.sat.frequency.value[0], config.scan.sat.symbolrate.value[0], config.scan.sat.polarization.value, config.scan.sat.fec.value, config.scan.sat.inversion.value, satpos) - elif currentConfigSelectionElement(config.tuning.type) == "predefined_transponder": - transponder = nimmanager.getTransponders(config.tuning.sat.vals[config.tuning.sat.value][1])[config.tuning.transponder.value] - returnvalue = (int(transponder[1] / 1000), int(transponder[2] / 1000), transponder[3], transponder[4], 2, config.tuning.sat.vals[config.tuning.sat.value][1], satpos) - self.close(returnvalue) + self.retune(self.tuning_type) - def keyCancel(self): + def restartPrevService(self, yesno): + if yesno: + if self.frontend: + self.frontend = None + del self.raw_channel + self.session.nav.playService(self.oldref) self.close(None) - + + def keyCancel(self): + if self.oldref: + self.session.openWithCallback(self.restartPrevService, MessageBox, _("Zap back to service before satfinder?"), MessageBox.TYPE_YESNO) + else: + self.restartPrevService(False) + def tune(self, transponder): if self.initcomplete: if transponder is not None: @@ -230,11 +247,11 @@ class NimSelection(Screen): def __init__(self, session): Screen.__init__(self, session) - nimlist = nimmanager.getNimListOfType(nimmanager.nimType["DVB-S"]) + nimlist = nimmanager.getNimListOfType("DVB-S") nimMenuList = [] for x in nimlist: - nimMenuList.append((_("NIM ") + (["A", "B", "C", "D"][x]) + ": " + nimmanager.getNimName(x) + " (" + nimmanager.getNimTypeName(x) + ")", x)) - + nimMenuList.append((nimmanager.nim_slots[x].friendly_full_description, x)) + self["nimlist"] = MenuList(nimMenuList) self["actions"] = ActionMap(["OkCancelActions"], @@ -244,23 +261,30 @@ class NimSelection(Screen): }, -1) def okbuttonClick(self): - selection = self["nimlist"].getCurrent() - self.session.open(Satfinder, selection[1]) + selection = self["nimlist"].getCurrent()[1] + self.session.open(Satfinder, selection) def SatfinderMain(session, **kwargs): - nimList = nimmanager.getNimListOfType(nimmanager.nimType["DVB-S"]) + nimList = nimmanager.getNimListOfType("DVB-S") if len(nimList) == 0: - session.open(MessageBox, _("No positioner capable frontend found."), MessageBox.TYPE_ERROR) + session.open(MessageBox, _("No satellite frontend found!!"), MessageBox.TYPE_ERROR) else: if session.nav.RecordTimer.isRecording(): - session.open(MessageBox, _("A recording is currently running. Please stop the recording before trying to configure the positioner."), MessageBox.TYPE_ERROR) + session.open(MessageBox, _("A recording is currently running. Please stop the recording before trying to start the satfinder."), MessageBox.TYPE_ERROR) else: if len(nimList) == 1: session.open(Satfinder, nimList[0]) - elif len(nimList) > 1: - session.open(NimSelection) else: - session.open(MessageBox, _("No tuner is configured for use with a diseqc positioner!"), MessageBox.TYPE_ERROR) + session.open(NimSelection) + +def SatfinderStart(menuid): + if menuid == "scan": + return [(_("Satfinder"), SatfinderMain)] + else: + return [] def Plugins(**kwargs): - return PluginDescriptor(name="Satfinder", description="Helps setting up your dish", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=SatfinderMain) + if (nimmanager.hasNimType("DVB-T")): + return PluginDescriptor(name=_("Satfinder"), description="Helps setting up your dish", where = PluginDescriptor.WHERE_SETUP, fnc=SatfinderStart) + else: + return []