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
17 def __init__(self, frontend):
18 self.frontend = frontend
20 def tune(self, transponder):
22 print "tuning to transponder with data", transponder
23 parm = eDVBFrontendParametersSatellite()
24 parm.frequency = transponder[0] * 1000
25 parm.symbol_rate = transponder[1] * 1000
26 parm.polarisation = transponder[2]
27 parm.fec = transponder[3]
28 parm.inversion = transponder[4]
29 parm.orbital_position = transponder[5]
30 parm.system = 0 # FIXMEE !! HARDCODED DVB-S (add support for DVB-S2)
31 parm.modulation = 1 # FIXMEE !! HARDCODED QPSK
32 feparm = eDVBFrontendParameters()
34 self.lastparm = feparm
35 self.frontend.tune(feparm)
39 self.frontend.tune(self.lastparm)
41 class Satfinder(ScanSetup):
42 def openFrontend(self):
43 res_mgr = eDVBResourceManager.getInstance()
45 self.raw_channel = res_mgr.allocateRawChannel(self.feid)
47 self.frontend = self.raw_channel.getFrontend()
51 print "getFrontend failed"
53 print "getRawChannel failed"
55 print "getResourceManager instance failed"
58 def __init__(self, session, feid):
59 self.initcomplete = False
63 if not self.openFrontend():
64 self.oldref = session.nav.getCurrentlyPlayingServiceReference()
65 session.nav.stopService() # try to disable foreground service
66 if not self.openFrontend():
67 if session.pipshown: # try to disable pip
68 session.pipshown = False
70 if not self.openFrontend():
71 self.frontend = None # in normal case this should not happen
73 ScanSetup.__init__(self, session)
74 self.tuner = Tuner(self.frontend)
75 self["introduction"].setText("")
76 self["Frontend"] = FrontendStatus(frontend_source = lambda : self.frontend, update_interval = 100)
77 self.initcomplete = True
78 self.onClose.append(self.__onClose)
81 self.session.nav.playService(self.oldref)
83 def createSetup(self):
84 self.typeOfTuningEntry = None
88 self.typeOfTuningEntry = getConfigListEntry(_('Tune'), self.tuning_type)
89 self.list.append(self.typeOfTuningEntry)
90 self.satEntry = getConfigListEntry(_('Satellite'), self.tuning_sat)
91 self.list.append(self.satEntry)
92 if self.tuning_type.value == "manual_transponder":
93 self.list.append(getConfigListEntry(_('Frequency'), self.scan_sat.frequency))
94 self.list.append(getConfigListEntry(_('Inversion'), self.scan_sat.inversion))
95 self.list.append(getConfigListEntry(_('Symbol Rate'), self.scan_sat.symbolrate))
96 self.list.append(getConfigListEntry(_("Polarity"), self.scan_sat.polarization))
97 self.list.append(getConfigListEntry(_("FEC"), self.scan_sat.fec))
98 elif self.tuning_transponder and self.tuning_type.value == "predefined_transponder":
99 self.list.append(getConfigListEntry(_("Transponder"), self.tuning_transponder))
100 self["config"].list = self.list
101 self["config"].l.setList(self.list)
104 if self["config"].getCurrent() == self.typeOfTuningEntry:
106 elif self["config"].getCurrent() == self.satEntry:
110 def sat_changed(self, config_element):
112 self.retune(config_element)
114 def retune(self, configElement):
115 returnvalue = (0, 0, 0, 0, 0, 0, 0)
116 satpos = self.tuning_sat.orbital_position
118 if satpos is not None:
119 if self.tuning_type.value == "manual_transponder":
120 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)
121 self.tune(returnvalue)
122 elif self.tuning_type.value == "predefined_transponder":
123 tps = nimmanager.getTransponders(satpos)
125 if l > self.tuning_transponder.index:
126 transponder = nimmanager.getTransponders(satpos)[self.tuning_transponder.index]
127 returnvalue = (int(transponder[1] / 1000), int(transponder[2] / 1000), transponder[3], transponder[4], 2, satpos)
128 self.tune(returnvalue)
130 def createConfig(self, foo):
131 self.tuning_transponder = None
132 self.tuning_type = ConfigSelection(choices = [("manual_transponder", _("Manual transponder")), ("predefined_transponder", _("Predefined transponder"))])
133 self.tuning_sat = getConfigSatlist(192, nimmanager.getSatListForNim(self.feid))
134 ScanSetup.createConfig(self, None)
138 self.tuning_type.addNotifier(self.retune, initial_call = False)
139 self.tuning_sat.addNotifier(self.sat_changed, initial_call = False)
140 self.scan_sat.frequency.addNotifier(self.retune, initial_call = False)
141 self.scan_sat.inversion.addNotifier(self.retune, initial_call = False)
142 self.scan_sat.symbolrate.addNotifier(self.retune, initial_call = False)
143 self.scan_sat.polarization.addNotifier(self.retune, initial_call = False)
144 self.scan_sat.fec.addNotifier(self.retune, initial_call = False)
146 def updateSats(self):
147 orb_pos = self.tuning_sat.orbital_position
148 if orb_pos is not None:
149 transponderlist = nimmanager.getTransponders(orb_pos)
152 for x in transponderlist:
187 e = str(x[1]) + "," + str(x[2]) + "," + pol + "," + fec
191 self.tuning_transponder = ConfigSelection(choices = list, default = default)
192 self.tuning_transponder.addNotifier(self.retune, initial_call = False)
195 self.retune(self.tuning_type)
197 def restartPrevService(self, yesno):
208 self.session.openWithCallback(self.restartPrevService, MessageBox, _("Zap back to service before satfinder?"), MessageBox.TYPE_YESNO)
210 self.restartPrevService(False)
212 def tune(self, transponder):
213 if self.initcomplete:
214 if transponder is not None:
215 self.tuner.tune(transponder)
217 class SatNimSelection(Screen):
219 <screen position="140,165" size="400,100" title="select Slot">
220 <widget name="nimlist" position="20,10" size="360,75" />
223 def __init__(self, session):
224 Screen.__init__(self, session)
226 nimlist = nimmanager.getNimListOfType("DVB-S")
229 nimMenuList.append((nimmanager.nim_slots[x].friendly_full_description, x))
231 self["nimlist"] = MenuList(nimMenuList)
233 self["actions"] = ActionMap(["OkCancelActions"],
235 "ok": self.okbuttonClick ,
239 def okbuttonClick(self):
240 selection = self["nimlist"].getCurrent()[1]
241 self.session.open(Satfinder, selection)
243 def SatfinderMain(session, **kwargs):
244 nimList = nimmanager.getNimListOfType("DVB-S")
245 if len(nimList) == 0:
246 session.open(MessageBox, _("No satellite frontend found!!"), MessageBox.TYPE_ERROR)
248 if session.nav.RecordTimer.isRecording():
249 session.open(MessageBox, _("A recording is currently running. Please stop the recording before trying to start the satfinder."), MessageBox.TYPE_ERROR)
251 if len(nimList) == 1:
252 session.open(Satfinder, nimList[0])
254 session.open(SatNimSelection)
256 def SatfinderStart(menuid, **kwargs):
258 return [(_("Satfinder"), SatfinderMain, "satfinder", None)]
262 def Plugins(**kwargs):
263 if (nimmanager.hasNimType("DVB-S")):
264 return PluginDescriptor(name=_("Satfinder"), description="Helps setting up your dish", where = PluginDescriptor.WHERE_MENU, fnc=SatfinderStart)