1 from enigma import eDVBResourceManager,\
2 eDVBFrontendParametersSatellite, eDVBFrontendParameters
4 from Screens.Screen import Screen
5 from Screens.ScanSetup import ScanSetup
6 from Screens.MessageBox import MessageBox
7 from Plugins.Plugin import PluginDescriptor
9 from Components.Label import Label
10 from Components.Sources.FrontendStatus import FrontendStatus
11 from Components.ActionMap import ActionMap
12 from Components.NimManager import nimmanager, getConfigSatlist
13 from Components.MenuList import MenuList
14 from Components.config import ConfigSelection, getConfigListEntry
15 from Components.TuneTest import Tuner
17 class Satfinder(ScanSetup):
18 def openFrontend(self):
19 res_mgr = eDVBResourceManager.getInstance()
21 self.raw_channel = res_mgr.allocateRawChannel(self.feid)
23 self.frontend = self.raw_channel.getFrontend()
27 print "getFrontend failed"
29 print "getRawChannel failed"
31 print "getResourceManager instance failed"
34 def __init__(self, session, feid):
35 self.initcomplete = False
39 if not self.openFrontend():
40 self.oldref = session.nav.getCurrentlyPlayingServiceReference()
41 session.nav.stopService() # try to disable foreground service
42 if not self.openFrontend():
43 if session.pipshown: # try to disable pip
44 session.pipshown = False
46 if not self.openFrontend():
47 self.frontend = None # in normal case this should not happen
49 ScanSetup.__init__(self, session)
50 self.tuner = Tuner(self.frontend)
51 self["introduction"].setText("")
52 self["Frontend"] = FrontendStatus(frontend_source = lambda : self.frontend, update_interval = 100)
53 self.initcomplete = True
54 self.onClose.append(self.__onClose)
57 self.session.nav.playService(self.oldref)
59 def createSetup(self):
60 self.typeOfTuningEntry = None
65 self.typeOfTuningEntry = getConfigListEntry(_('Tune'), self.tuning_type)
66 self.list.append(self.typeOfTuningEntry)
67 self.satEntry = getConfigListEntry(_('Satellite'), self.tuning_sat)
68 self.list.append(self.satEntry)
70 nim = nimmanager.nim_slots[self.feid]
72 self.systemEntry = None
73 if self.tuning_type.value == "manual_transponder":
74 if nim.isCompatible("DVB-S2"):
75 self.systemEntry = getConfigListEntry(_('System'), self.scan_sat.system)
76 self.list.append(self.systemEntry)
78 # downgrade to dvb-s, in case a -s2 config was active
79 self.scan_sat.system.value = eDVBFrontendParametersSatellite.System_DVB_S
80 self.list.append(getConfigListEntry(_('Frequency'), self.scan_sat.frequency))
81 self.list.append(getConfigListEntry(_('Inversion'), self.scan_sat.inversion))
82 self.list.append(getConfigListEntry(_('Symbol Rate'), self.scan_sat.symbolrate))
83 self.list.append(getConfigListEntry(_("Polarity"), self.scan_sat.polarization))
84 if self.scan_sat.system.value == eDVBFrontendParametersSatellite.System_DVB_S:
85 self.list.append(getConfigListEntry(_("FEC"), self.scan_sat.fec))
86 elif self.scan_sat.system.value == eDVBFrontendParametersSatellite.System_DVB_S2:
87 self.list.append(getConfigListEntry(_("FEC"), self.scan_sat.fec_s2))
88 self.modulationEntry = getConfigListEntry(_('Modulation'), self.scan_sat.modulation)
89 self.list.append(self.modulationEntry)
90 self.list.append(getConfigListEntry(_('Rolloff'), self.scan_sat.rolloff))
91 self.list.append(getConfigListEntry(_('Pilot'), self.scan_sat.pilot))
92 elif self.tuning_transponder and self.tuning_type.value == "predefined_transponder":
93 self.list.append(getConfigListEntry(_("Transponder"), self.tuning_transponder))
94 self["config"].list = self.list
95 self["config"].l.setList(self.list)
98 cur = self["config"].getCurrent()
99 if cur in (self.typeOfTuningEntry, self.systemEntry):
101 elif cur == self.satEntry:
105 def sat_changed(self, config_element):
107 self.retune(config_element)
109 def retune(self, configElement):
110 returnvalue = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
111 satpos = int(self.tuning_sat.value)
112 if self.tuning_type.value == "manual_transponder":
113 if self.scan_sat.system.value == eDVBFrontendParametersSatellite.System_DVB_S2:
114 fec = self.scan_sat.fec_s2.value
116 fec = self.scan_sat.fec.value
118 self.scan_sat.frequency.value,
119 self.scan_sat.symbolrate.value,
120 self.scan_sat.polarization.value,
122 self.scan_sat.inversion.value,
124 self.scan_sat.system.value,
125 self.scan_sat.modulation.value,
126 self.scan_sat.rolloff.value,
127 self.scan_sat.pilot.value)
128 self.tune(returnvalue)
129 elif self.tuning_type.value == "predefined_transponder":
130 tps = nimmanager.getTransponders(satpos)
132 if l > self.tuning_transponder.index:
133 transponder = tps[self.tuning_transponder.index]
134 returnvalue = (transponder[1] / 1000, transponder[2] / 1000,
135 transponder[3], transponder[4], 2, satpos, transponder[5], transponder[6], transponder[8], transponder[9])
136 self.tune(returnvalue)
138 def createConfig(self, foo):
139 self.tuning_transponder = None
140 self.tuning_type = ConfigSelection(choices = [("manual_transponder", _("Manual transponder")), ("predefined_transponder", _("Predefined transponder"))])
141 self.tuning_sat = getConfigSatlist(192, nimmanager.getSatListForNim(self.feid))
142 ScanSetup.createConfig(self, None)
146 for x in (self.tuning_type, self.tuning_sat, self.scan_sat.frequency,
147 self.scan_sat.inversion, self.scan_sat.symbolrate,
148 self.scan_sat.polarization, self.scan_sat.fec, self.scan_sat.pilot,
149 self.scan_sat.fec_s2, self.scan_sat.fec, self.scan_sat.modulation,
150 self.scan_sat.rolloff, self.scan_sat.system):
151 x.addNotifier(self.retune, initial_call = False)
153 def updateSats(self):
154 orb_pos = self.tuning_sat.orbital_position
155 if orb_pos is not None:
156 transponderlist = nimmanager.getTransponders(orb_pos)
160 for x in transponderlist:
195 e = str(x[1]) + "," + str(x[2]) + "," + pol + "," + fec
198 list.append((str(index), e))
200 self.tuning_transponder = ConfigSelection(choices = list, default = default)
201 self.tuning_transponder.addNotifier(self.retune, initial_call = False)
204 self.retune(self.tuning_type)
206 def restartPrevService(self, yesno):
217 self.session.openWithCallback(self.restartPrevService, MessageBox, _("Zap back to service before satfinder?"), MessageBox.TYPE_YESNO)
219 self.restartPrevService(False)
221 def tune(self, transponder):
222 if self.initcomplete:
223 if transponder is not None:
224 self.tuner.tune(transponder)
226 class SatNimSelection(Screen):
228 <screen position="140,165" size="400,130" title="select Slot">
229 <widget name="nimlist" position="20,10" size="360,100" />
232 def __init__(self, session):
233 Screen.__init__(self, session)
235 nimlist = nimmanager.getNimListOfType("DVB-S")
238 nimMenuList.append((nimmanager.nim_slots[x].friendly_full_description, x))
240 self["nimlist"] = MenuList(nimMenuList)
242 self["actions"] = ActionMap(["OkCancelActions"],
244 "ok": self.okbuttonClick ,
248 def okbuttonClick(self):
249 selection = self["nimlist"].getCurrent()[1]
250 self.session.open(Satfinder, selection)
252 def SatfinderMain(session, **kwargs):
253 nims = nimmanager.getNimListOfType("DVB-S")
257 if not nimmanager.getNimConfig(x).configMode.value in ("loopthrough", "satposdepends", "nothing"):
260 if len(nimList) == 0:
261 session.open(MessageBox, _("No satellite frontend found!!"), MessageBox.TYPE_ERROR)
263 if session.nav.RecordTimer.isRecording():
264 session.open(MessageBox, _("A recording is currently running. Please stop the recording before trying to start the satfinder."), MessageBox.TYPE_ERROR)
266 if len(nimList) == 1:
267 session.open(Satfinder, nimList[0])
269 session.open(SatNimSelection)
271 def SatfinderStart(menuid, **kwargs):
273 return [(_("Satfinder"), SatfinderMain, "satfinder", None)]
277 def Plugins(**kwargs):
278 if (nimmanager.hasNimType("DVB-S")):
279 return PluginDescriptor(name=_("Satfinder"), description="Helps setting up your dish", where = PluginDescriptor.WHERE_MENU, fnc=SatfinderStart)