1 from Screen import Screen
2 from Screens.DefaultWizard import DefaultWizard
3 from ServiceScan import ServiceScan
4 from Components.config import config, ConfigSubsection, ConfigSelection, \
5 ConfigYesNo, ConfigInteger, getConfigListEntry, ConfigSlider, ConfigEnableDisable
6 from Components.ActionMap import NumberActionMap, ActionMap
7 from Components.ConfigList import ConfigListScreen
8 from Components.NimManager import nimmanager, getConfigSatlist
9 from Components.Label import Label
10 from Tools.Directories import resolveFilename, SCOPE_DEFAULTPARTITIONMOUNTDIR, SCOPE_DEFAULTDIR, SCOPE_DEFAULTPARTITION
11 from Tools.HardwareInfo import HardwareInfo
12 from Screens.MessageBox import MessageBox
13 from enigma import eTimer, eDVBFrontendParametersSatellite, eComponentScan, \
14 eDVBSatelliteEquipmentControl, eDVBFrontendParametersTerrestrial, \
15 eDVBFrontendParametersCable, eConsoleAppContainer, eDVBResourceManager
17 def buildTerTransponder(frequency,
18 inversion=2, bandwidth = 3, fechigh = 6, feclow = 6,
19 modulation = 2, transmission = 2, guard = 4,
21 # print "freq", frequency, "inv", inversion, "bw", bandwidth, "fech", fechigh, "fecl", feclow, "mod", modulation, "tm", transmission, "guard", guard, "hierarchy", hierarchy
22 parm = eDVBFrontendParametersTerrestrial()
23 parm.frequency = frequency
24 parm.inversion = inversion
25 parm.bandwidth = bandwidth
26 parm.code_rate_HP = fechigh
27 parm.code_rate_LP = feclow
28 parm.modulation = modulation
29 parm.transmission_mode = transmission
30 parm.guard_interval = guard
31 parm.hierarchy = hierarchy
34 def getInitialTransponderList(tlist, pos):
35 list = nimmanager.getTransponders(pos)
38 parm = eDVBFrontendParametersSatellite()
40 parm.symbol_rate = x[2]
41 parm.polarisation = x[3]
44 parm.orbital_position = pos
46 parm.modulation = x[6]
51 def getInitialCableTransponderList(tlist, nim):
52 list = nimmanager.getTranspondersCable(nim)
55 parm = eDVBFrontendParametersCable()
57 parm.symbol_rate = x[2]
58 parm.modulation = x[3]
60 parm.inversion = parm.Inversion_Unknown
61 #print "frequency:", x[1]
62 #print "symbol_rate:", x[2]
63 #print "modulation:", x[3]
64 #print "fec_inner:", x[4]
65 #print "inversion:", 2
68 def getInitialTerrestrialTransponderList(tlist, region):
69 list = nimmanager.getTranspondersTerrestrial(region)
71 #self.transponders[self.parsedTer].append((2,freq,bw,const,crh,crl,guard,transm,hierarchy,inv))
73 #def buildTerTransponder(frequency, inversion = 2, bandwidth = 3, fechigh = 6, feclow = 6,
74 #modulation = 2, transmission = 2, guard = 4, hierarchy = 4):
77 if x[0] == 2: #TERRESTRIAL
78 parm = buildTerTransponder(x[1], x[9], x[2], x[4], x[5], x[3], x[7], x[6], x[8])
82 "DVBC_BAND_EU_VHF_I" : 1 << 0,
83 "DVBC_BAND_EU_MID" : 1 << 1,
84 "DVBC_BAND_EU_VHF_III" : 1 << 2,
85 "DVBC_BAND_EU_SUPER" : 1 << 3,
86 "DVBC_BAND_EU_HYPER" : 1 << 4,
87 "DVBC_BAND_EU_UHF_IV" : 1 << 5,
88 "DVBC_BAND_EU_UHF_V" : 1 << 6,
89 "DVBC_BAND_US_LO" : 1 << 7,
90 "DVBC_BAND_US_MID" : 1 << 8,
91 "DVBC_BAND_US_HI" : 1 << 9,
92 "DVBC_BAND_US_SUPER" : 1 << 10,
93 "DVBC_BAND_US_HYPER" : 1 << 11,
96 class CableTransponderSearchSupport:
97 # def setCableTransponderSearchResult(self, tlist):
100 # def cableTransponderSearchFinished(self):
103 def tryGetRawFrontend(self, feid):
104 res_mgr = eDVBResourceManager.getInstance()
106 raw_channel = res_mgr.allocateRawChannel(self.feid)
108 frontend = raw_channel.getFrontend()
110 frontend.closeFrontend() # immediate close...
116 def cableTransponderSearchSessionClosed(self, *val):
117 print "cableTransponderSearchSessionClosed, val", val
118 self.cable_search_container.appClosed.remove(self.cableTransponderSearchClosed)
119 self.cable_search_container.dataAvail.remove(self.getCableTransponderData)
122 self.setCableTransponderSearchResult(self.__tlist)
124 self.cable_search_container.sendCtrlC()
125 self.setCableTransponderSearchResult(None)
126 self.cable_search_container = None
127 self.cable_search_session = None
129 self.cableTransponderSearchFinished()
131 def cableTransponderSearchClosed(self, retval):
132 print "cableTransponderSearch finished", retval
133 self.cable_search_session.close(True)
135 def getCableTransponderData(self, str):
140 parm = eDVBFrontendParametersCable()
141 qam = { "QAM16" : parm.Modulation_QAM16,
142 "QAM32" : parm.Modulation_QAM32,
143 "QAM64" : parm.Modulation_QAM64,
144 "QAM128" : parm.Modulation_QAM128,
145 "QAM256" : parm.Modulation_QAM256 }
146 inv = { "INVERSION_OFF" : parm.Inversion_Off,
147 "INVERSION_ON" : parm.Inversion_On,
148 "INVERSION_AUTO" : parm.Inversion_Unknown }
149 fec = { "FEC_AUTO" : parm.FEC_Auto,
150 "FEC_1_2" : parm.FEC_1_2,
151 "FEC_2_3" : parm.FEC_2_3,
152 "FEC_3_4" : parm.FEC_3_4,
153 "FEC_5_6": parm.FEC_5_6,
154 "FEC_7_8" : parm.FEC_7_8,
155 "FEC_8_9" : parm.FEC_8_9,
156 "FEC_NONE" : parm.FEC_None }
157 parm.frequency = int(data[1])
158 parm.symbol_rate = int(data[2])
159 parm.fec_inner = fec[data[3]]
160 parm.modulation = qam[data[4]]
161 parm.inversion = inv[data[5]]
162 self.__tlist.append(parm)
163 tmpstr = _("Try to find used Transponders in cable network.. please wait...")
168 self.cable_search_session["text"].setText(tmpstr)
170 def startCableTransponderSearch(self, nim_idx):
171 if not self.tryGetRawFrontend(nim_idx):
172 self.session.nav.stopService()
173 if not self.tryGetRawFrontend(nim_idx):
174 if self.session.pipshown: # try to disable pip
175 self.session.pipshown = False
177 if not self.tryGetRawFrontend(nim_idx):
178 self.cableTransponderSearchFinished()
181 self.cable_search_container = eConsoleAppContainer()
182 self.cable_search_container.appClosed.append(self.cableTransponderSearchClosed)
183 self.cable_search_container.dataAvail.append(self.getCableTransponderData)
184 cableConfig = config.Nims[nim_idx].cable
185 tunername = nimmanager.getNimName(nim_idx)
186 bus = nimmanager.getI2CDevice(nim_idx)
188 print "ERROR: could not get I2C device for nim", nim_idx, "for cable transponder search"
191 if tunername == "CXD1981":
192 cmd = "cxd1978 --init --scan --verbose --wakeup --inv 2 --bus %d" % bus
194 cmd = "tda1002x --init --scan --verbose --wakeup --inv 2 --bus %d" % bus
196 if cableConfig.scan_type.value == "bands":
197 cmd += " --scan-bands "
199 if cableConfig.scan_band_EU_VHF_I.value:
200 bands |= cable_bands["DVBC_BAND_EU_VHF_I"]
201 if cableConfig.scan_band_EU_MID.value:
202 bands |= cable_bands["DVBC_BAND_EU_MID"]
203 if cableConfig.scan_band_EU_VHF_III.value:
204 bands |= cable_bands["DVBC_BAND_EU_VHF_III"]
205 if cableConfig.scan_band_EU_UHF_IV.value:
206 bands |= cable_bands["DVBC_BAND_EU_UHF_IV"]
207 if cableConfig.scan_band_EU_UHF_V.value:
208 bands |= cable_bands["DVBC_BAND_EU_UHF_V"]
209 if cableConfig.scan_band_EU_SUPER.value:
210 bands |= cable_bands["DVBC_BAND_EU_SUPER"]
211 if cableConfig.scan_band_EU_HYPER.value:
212 bands |= cable_bands["DVBC_BAND_EU_HYPER"]
213 if cableConfig.scan_band_US_LOW.value:
214 bands |= cable_bands["DVBC_BAND_US_LO"]
215 if cableConfig.scan_band_US_MID.value:
216 bands |= cable_bands["DVBC_BAND_US_MID"]
217 if cableConfig.scan_band_US_HIGH.value:
218 bands |= cable_bands["DVBC_BAND_US_HI"]
219 if cableConfig.scan_band_US_SUPER.value:
220 bands |= cable_bands["DVBC_BAND_US_SUPER"]
221 if cableConfig.scan_band_US_HYPER.value:
222 bands |= cable_bands["DVBC_BAND_US_HYPER"]
225 cmd += " --scan-stepsize "
226 cmd += str(cableConfig.scan_frequency_steps.value)
227 if cableConfig.scan_mod_qam16.value:
229 if cableConfig.scan_mod_qam32.value:
231 if cableConfig.scan_mod_qam64.value:
233 if cableConfig.scan_mod_qam128.value:
235 if cableConfig.scan_mod_qam256.value:
237 if cableConfig.scan_sr_6900.value:
238 cmd += " --sr 6900000"
239 if cableConfig.scan_sr_6875.value:
240 cmd += " --sr 6875000"
241 if cableConfig.scan_sr_ext1.value > 450:
243 cmd += str(cableConfig.scan_sr_ext1.value)
245 if cableConfig.scan_sr_ext2.value > 450:
247 cmd += str(cableConfig.scan_sr_ext2.value)
249 print "TDA1002x CMD is", cmd
251 self.cable_search_container.execute(cmd)
252 tmpstr = _("Try to find used transponders in cable network.. please wait...")
254 self.cable_search_session = self.session.openWithCallback(self.cableTransponderSearchSessionClosed, MessageBox, tmpstr, MessageBox.TYPE_INFO)
256 class DefaultSatLists(DefaultWizard):
257 def __init__(self, session, silent = True, showSteps = False):
258 self.xmlfile = "defaultsatlists.xml"
259 DefaultWizard.__init__(self, session, silent, showSteps, neededTag = "services")
260 print "configuredSats:", nimmanager.getConfiguredSats()
262 def setDirectory(self):
264 self.directory.append(resolveFilename(SCOPE_DEFAULTDIR))
266 os.system("mount %s %s" % (resolveFilename(SCOPE_DEFAULTPARTITION), resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR)))
267 self.directory.append(resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR))
269 def statusCallback(self, status, progress):
270 print "statusCallback:", status, progress
271 from Components.DreamInfoHandler import DreamInfoHandler
272 if status == DreamInfoHandler.STATUS_DONE:
273 self["text"].setText(_("The installation of the default services lists is finished.") + "\n\n" + _("Please press OK to continue."))
275 self.disableKeys = False
277 class ScanSetup(ConfigListScreen, Screen, CableTransponderSearchSupport):
278 def __init__(self, session):
279 Screen.__init__(self, session)
281 self.finished_cb = None
283 self.service = session.nav.getCurrentService()
286 if self.service is not None:
287 self.feinfo = self.service.frontendInfo()
288 frontendData = self.feinfo and self.feinfo.getAll(True)
290 self.createConfig(frontendData)
295 self["actions"] = NumberActionMap(["SetupActions"],
298 "cancel": self.keyCancel,
301 self.statusTimer = eTimer()
302 self.statusTimer.callback.append(self.updateStatus)
303 #self.statusTimer.start(5000, True)
306 ConfigListScreen.__init__(self, self.list)
307 if not self.scan_nims.value == "":
309 self["introduction"] = Label(_("Press OK to start the scan"))
311 self["introduction"] = Label(_("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."))
313 def runAsync(self, finished_cb):
314 self.finished_cb = finished_cb
317 def updateSatList(self):
319 for slot in nimmanager.nim_slots:
320 if slot.isCompatible("DVB-S"):
321 self.satList.append(nimmanager.getSatListForNim(slot.slot))
323 self.satList.append(None)
325 def createSetup(self):
327 self.multiscanlist = []
328 index_to_scan = int(self.scan_nims.value)
329 print "ID: ", index_to_scan
331 self.tunerEntry = getConfigListEntry(_("Tuner"), self.scan_nims)
332 self.list.append(self.tunerEntry)
334 if self.scan_nims == [ ]:
337 self.typeOfScanEntry = None
338 self.systemEntry = None
339 self.modulationEntry = None
340 nim = nimmanager.nim_slots[index_to_scan]
341 if nim.isCompatible("DVB-S"):
342 self.typeOfScanEntry = getConfigListEntry(_("Type of scan"), self.scan_type)
343 self.list.append(self.typeOfScanEntry)
344 elif nim.isCompatible("DVB-C"):
345 self.typeOfScanEntry = getConfigListEntry(_("Type of scan"), self.scan_typecable)
346 self.list.append(self.typeOfScanEntry)
347 elif nim.isCompatible("DVB-T"):
348 self.typeOfScanEntry = getConfigListEntry(_("Type of scan"), self.scan_typeterrestrial)
349 self.list.append(self.typeOfScanEntry)
351 self.scan_networkScan.value = False
352 if nim.isCompatible("DVB-S"):
353 if self.scan_type.value == "single_transponder":
355 if nim.isCompatible("DVB-S2"):
356 self.systemEntry = getConfigListEntry(_('System'), self.scan_sat.system)
357 self.list.append(self.systemEntry)
359 # downgrade to dvb-s, in case a -s2 config was active
360 self.scan_sat.system.value = eDVBFrontendParametersSatellite.System_DVB_S
361 self.list.append(getConfigListEntry(_('Satellite'), self.scan_satselection[index_to_scan]))
362 self.list.append(getConfigListEntry(_('Frequency'), self.scan_sat.frequency))
363 self.list.append(getConfigListEntry(_('Inversion'), self.scan_sat.inversion))
364 self.list.append(getConfigListEntry(_('Symbol Rate'), self.scan_sat.symbolrate))
365 self.list.append(getConfigListEntry(_("Polarity"), self.scan_sat.polarization))
366 if self.scan_sat.system.value == eDVBFrontendParametersSatellite.System_DVB_S:
367 self.list.append(getConfigListEntry(_("FEC"), self.scan_sat.fec))
368 elif self.scan_sat.system.value == eDVBFrontendParametersSatellite.System_DVB_S2:
369 self.list.append(getConfigListEntry(_("FEC"), self.scan_sat.fec_s2))
370 self.modulationEntry = getConfigListEntry(_('Modulation'), self.scan_sat.modulation)
371 self.list.append(self.modulationEntry)
372 self.list.append(getConfigListEntry(_('Rolloff'), self.scan_sat.rolloff))
373 self.list.append(getConfigListEntry(_('Pilot'), self.scan_sat.pilot))
374 elif self.scan_type.value == "single_satellite":
376 print self.scan_satselection[index_to_scan]
377 self.list.append(getConfigListEntry(_("Satellite"), self.scan_satselection[index_to_scan]))
378 self.scan_networkScan.value = True
379 elif self.scan_type.value.find("multisat") != -1:
381 SatList = nimmanager.getSatListForNim(index_to_scan)
383 if self.Satexists(tlist, x[0]) == 0:
385 sat = ConfigEnableDisable(default = self.scan_type.value.find("_yes") != -1 and True or False)
386 configEntry = getConfigListEntry(nimmanager.getSatDescription(x[0]), sat)
387 self.list.append(configEntry)
388 self.multiscanlist.append((x[0], sat))
389 self.scan_networkScan.value = True
390 elif nim.isCompatible("DVB-C"):
391 if self.scan_typecable.value == "single_transponder":
392 self.list.append(getConfigListEntry(_("Frequency"), self.scan_cab.frequency))
393 self.list.append(getConfigListEntry(_("Inversion"), self.scan_cab.inversion))
394 self.list.append(getConfigListEntry(_("Symbol Rate"), self.scan_cab.symbolrate))
395 self.list.append(getConfigListEntry(_("Modulation"), self.scan_cab.modulation))
396 self.list.append(getConfigListEntry(_("FEC"), self.scan_cab.fec))
397 elif nim.isCompatible("DVB-T"):
398 if self.scan_typeterrestrial.value == "single_transponder":
399 self.list.append(getConfigListEntry(_("Frequency"), self.scan_ter.frequency))
400 self.list.append(getConfigListEntry(_("Inversion"), self.scan_ter.inversion))
401 self.list.append(getConfigListEntry(_("Bandwidth"), self.scan_ter.bandwidth))
402 self.list.append(getConfigListEntry(_("Code rate high"), self.scan_ter.fechigh))
403 self.list.append(getConfigListEntry(_("Code rate low"), self.scan_ter.feclow))
404 self.list.append(getConfigListEntry(_("Modulation"), self.scan_ter.modulation))
405 self.list.append(getConfigListEntry(_("Transmission mode"), self.scan_ter.transmission))
406 self.list.append(getConfigListEntry(_("Guard interval mode"), self.scan_ter.guard))
407 self.list.append(getConfigListEntry(_("Hierarchy mode"), self.scan_ter.hierarchy))
408 self.list.append(getConfigListEntry(_("Network scan"), self.scan_networkScan))
409 self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
410 self.list.append(getConfigListEntry(_("Only Free scan"), self.scan_onlyfree))
411 self["config"].list = self.list
412 self["config"].l.setList(self.list)
414 def Satexists(self, tlist, pos):
421 cur = self["config"].getCurrent()
423 if cur == self.typeOfScanEntry or \
424 cur == self.tunerEntry or \
425 cur == self.systemEntry or \
426 (self.modulationEntry and self.systemEntry[1].value == eDVBFrontendParametersSatellite.System_DVB_S2 and cur == self.modulationEntry):
429 def createConfig(self, frontendData):
430 #("Type", frontendData["system"], TYPE_TEXT),
431 #("Modulation", frontendData["modulation"], TYPE_TEXT),
432 #("Orbital position", frontendData["orbital_position"], TYPE_VALUE_DEC),
433 #("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
434 #("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC),
435 #("Polarization", frontendData["polarization"], TYPE_TEXT),
436 #("Inversion", frontendData["inversion"], TYPE_TEXT),
437 #("FEC inner", frontendData["fec_inner"], TYPE_TEXT),
439 #elif frontendData["tuner_type"] == "DVB-C":
440 #return ( ("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
441 #("Type", frontendData["tuner_type"], TYPE_TEXT),
442 #("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
443 #("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC),
444 #("Modulation", frontendData["modulation"], TYPE_TEXT),
445 #("Inversion", frontendData["inversion"], TYPE_TEXT),
446 # ("FEC inner", frontendData["fec_inner"], TYPE_TEXT),
448 #elif frontendData["tuner_type"] == "DVB-T":
449 #return ( ("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
450 #("Type", frontendData["tuner_type"], TYPE_TEXT),
451 #("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
452 #("Inversion", frontendData["inversion"], TYPE_TEXT),
453 #("Bandwidth", frontendData["bandwidth"], TYPE_VALUE_DEC),
454 #("CodeRateLP", frontendData["code_rate_lp"], TYPE_TEXT),
455 #("CodeRateHP", frontendData["code_rate_hp"], TYPE_TEXT),
456 #("Constellation", frontendData["constellation"], TYPE_TEXT),
457 #("Transmission Mode", frontendData["transmission_mode"], TYPE_TEXT),
458 #("Guard Interval", frontendData["guard_interval"], TYPE_TEXT),
459 #("Hierarchy Inform.", frontendData["hierarchy_information"], TYPE_TEXT),
462 "system": eDVBFrontendParametersSatellite.System_DVB_S,
464 "inversion": eDVBFrontendParametersSatellite.Inversion_Unknown,
466 "polarization": eDVBFrontendParametersSatellite.Polarisation_Horizontal,
467 "fec": eDVBFrontendParametersSatellite.FEC_Auto,
468 "fec_s2": eDVBFrontendParametersSatellite.FEC_9_10,
469 "modulation": eDVBFrontendParametersSatellite.Modulation_QPSK }
472 "inversion": eDVBFrontendParametersCable.Inversion_Unknown,
473 "modulation": eDVBFrontendParametersCable.Modulation_QAM64,
474 "fec": eDVBFrontendParametersCable.FEC_Auto,
477 "frequency" : 466000,
478 "inversion" : eDVBFrontendParametersTerrestrial.Inversion_Unknown,
479 "bandwidth" : eDVBFrontendParametersTerrestrial.Bandwidth_7MHz,
480 "fechigh" : eDVBFrontendParametersTerrestrial.FEC_Auto,
481 "feclow" : eDVBFrontendParametersTerrestrial.FEC_Auto,
482 "modulation" : eDVBFrontendParametersTerrestrial.Modulation_Auto,
483 "transmission_mode" : eDVBFrontendParametersTerrestrial.TransmissionMode_Auto,
484 "guard_interval" : eDVBFrontendParametersTerrestrial.GuardInterval_Auto,
485 "hierarchy": eDVBFrontendParametersTerrestrial.Hierarchy_Auto }
487 if frontendData is not None:
488 ttype = frontendData.get("tuner_type", "UNKNOWN")
490 defaultSat["system"] = frontendData.get("system", eDVBFrontendParametersSatellite.System_DVB_S)
491 defaultSat["frequency"] = frontendData.get("frequency", 0) / 1000
492 defaultSat["inversion"] = frontendData.get("inversion", eDVBFrontendParametersSatellite.Inversion_Unknown)
493 defaultSat["symbolrate"] = frontendData.get("symbol_rate", 0) / 1000
494 defaultSat["polarization"] = frontendData.get("polarization", eDVBFrontendParametersSatellite.Polarisation_Horizontal)
495 if defaultSat["system"] == eDVBFrontendParametersSatellite.System_DVB_S2:
496 defaultSat["fec_s2"] = frontendData.get("fec_inner", eDVBFrontendParametersSatellite.FEC_Auto)
497 defaultSat["rolloff"] = frontendData.get("rolloff", eDVBFrontendParametersSatellite.RollOff_alpha_0_35)
498 defaultSat["pilot"] = frontendData.get("pilot", eDVBFrontendParametersSatellite.Pilot_Unknown)
500 defaultSat["fec"] = frontendData.get("fec_inner", eDVBFrontendParametersSatellite.FEC_Auto)
501 defaultSat["modulation"] = frontendData.get("modulation", eDVBFrontendParametersSatellite.Modulation_QPSK)
502 defaultSat["orbpos"] = frontendData.get("orbital_position", 0)
503 elif ttype == "DVB-C":
504 defaultCab["frequency"] = frontendData.get("frequency", 0) / 1000
505 defaultCab["symbolrate"] = frontendData.get("symbol_rate", 0) / 1000
506 defaultCab["inversion"] = frontendData.get("inversion", eDVBFrontendParametersCable.Inversion_Unknown)
507 defaultCab["fec"] = frontendData.get("fec_inner", eDVBFrontendParametersCable.FEC_Auto)
508 defaultCab["modulation"] = frontendData.get("modulation", eDVBFrontendParametersCable.Modulation_QAM16)
509 elif ttype == "DVB-T":
510 defaultTer["frequency"] = frontendData.get("frequency", 0)
511 defaultTer["inversion"] = frontendData.get("inversion", eDVBFrontendParametersTerrestrial.Inversion_Unknown)
512 defaultTer["bandwidth"] = frontendData.get("bandwidth", eDVBFrontendParametersTerrestrial.Bandwidth_7MHz)
513 defaultTer["fechigh"] = frontendData.get("code_rate_hp", eDVBFrontendParametersTerrestrial.FEC_Auto)
514 defaultTer["feclow"] = frontendData.get("code_rate_lp", eDVBFrontendParametersTerrestrial.FEC_Auto)
515 defaultTer["modulation"] = frontendData.get("constellation", eDVBFrontendParametersTerrestrial.Modulation_Auto)
516 defaultTer["transmission_mode"] = frontendData.get("transmission_mode", eDVBFrontendParametersTerrestrial.TransmissionMode_Auto)
517 defaultTer["guard_interval"] = frontendData.get("guard_interval", eDVBFrontendParametersTerrestrial.GuardInterval_Auto)
518 defaultTer["hierarchy"] = frontendData.get("hierarchy_information", eDVBFrontendParametersTerrestrial.Hierarchy_Auto)
520 self.scan_sat = ConfigSubsection()
521 self.scan_cab = ConfigSubsection()
522 self.scan_ter = ConfigSubsection()
524 self.scan_type = ConfigSelection(default = "single_transponder", choices = [("single_transponder", _("Single transponder")), ("single_satellite", _("Single satellite")), ("multisat", _("Multisat")), ("multisat_yes", _("Multisat"))])
525 self.scan_typecable = ConfigSelection(default = "single_transponder", choices = [("single_transponder", _("Single transponder")), ("complete", _("Complete"))])
526 self.scan_typeterrestrial = ConfigSelection(default = "single_transponder", choices = [("single_transponder", _("Single transponder")), ("complete", _("Complete"))])
527 self.scan_clearallservices = ConfigSelection(default = "no", choices = [("no", _("no")), ("yes", _("yes")), ("yes_hold_feeds", _("yes (keep feeds)"))])
528 self.scan_onlyfree = ConfigYesNo(default = False)
529 self.scan_networkScan = ConfigYesNo(default = False)
532 # collect all nims which are *not* set to "nothing"
533 for n in nimmanager.nim_slots:
534 if n.config_mode == "nothing":
536 if n.config_mode == "advanced" and len(nimmanager.getSatListForNim(n.slot)) < 1:
538 if n.config_mode in ("loopthrough", "satposdepends"):
539 root_id = nimmanager.sec.getRoot(n.slot_id, int(n.config.connectedTo.value))
540 if n.type == nimmanager.nim_slots[root_id].type: # check if connected from a DVB-S to DVB-S2 Nim or vice versa
542 nim_list.append((str(n.slot), n.friendly_full_description))
544 self.scan_nims = ConfigSelection(choices = nim_list)
547 self.scan_snr = ConfigSlider()
548 self.scan_snr.enabled = False
549 self.scan_agc = ConfigSlider()
550 self.scan_agc.enabled = False
551 self.scan_ber = ConfigSlider()
552 self.scan_ber.enabled = False
555 self.scan_sat.system = ConfigSelection(default = defaultSat["system"], choices = [
556 (eDVBFrontendParametersSatellite.System_DVB_S, _("DVB-S")),
557 (eDVBFrontendParametersSatellite.System_DVB_S2, _("DVB-S2"))])
558 self.scan_sat.frequency = ConfigInteger(default = defaultSat["frequency"], limits = (1, 99999))
559 self.scan_sat.inversion = ConfigSelection(default = defaultSat["inversion"], choices = [
560 (eDVBFrontendParametersSatellite.Inversion_Off, _("off")),
561 (eDVBFrontendParametersSatellite.Inversion_On, _("on")),
562 (eDVBFrontendParametersSatellite.Inversion_Unknown, _("Auto"))])
563 self.scan_sat.symbolrate = ConfigInteger(default = defaultSat["symbolrate"], limits = (1, 99999))
564 self.scan_sat.polarization = ConfigSelection(default = defaultSat["polarization"], choices = [
565 (eDVBFrontendParametersSatellite.Polarisation_Horizontal, _("horizontal")),
566 (eDVBFrontendParametersSatellite.Polarisation_Vertical, _("vertical")),
567 (eDVBFrontendParametersSatellite.Polarisation_CircularLeft, _("circular left")),
568 (eDVBFrontendParametersSatellite.Polarisation_CircularRight, _("circular right"))])
569 self.scan_sat.fec = ConfigSelection(default = defaultSat["fec"], choices = [
570 (eDVBFrontendParametersSatellite.FEC_Auto, _("Auto")),
571 (eDVBFrontendParametersSatellite.FEC_1_2, "1/2"),
572 (eDVBFrontendParametersSatellite.FEC_2_3, "2/3"),
573 (eDVBFrontendParametersSatellite.FEC_3_4, "3/4"),
574 (eDVBFrontendParametersSatellite.FEC_5_6, "5/6"),
575 (eDVBFrontendParametersSatellite.FEC_7_8, "7/8"),
576 (eDVBFrontendParametersSatellite.FEC_None, _("None"))])
577 self.scan_sat.fec_s2 = ConfigSelection(default = defaultSat["fec_s2"], choices = [
578 (eDVBFrontendParametersSatellite.FEC_1_2, "1/2"),
579 (eDVBFrontendParametersSatellite.FEC_2_3, "2/3"),
580 (eDVBFrontendParametersSatellite.FEC_3_4, "3/4"),
581 (eDVBFrontendParametersSatellite.FEC_3_5, "3/5"),
582 (eDVBFrontendParametersSatellite.FEC_4_5, "4/5"),
583 (eDVBFrontendParametersSatellite.FEC_5_6, "5/6"),
584 (eDVBFrontendParametersSatellite.FEC_7_8, "7/8"),
585 (eDVBFrontendParametersSatellite.FEC_8_9, "8/9"),
586 (eDVBFrontendParametersSatellite.FEC_9_10, "9/10")])
587 self.scan_sat.modulation = ConfigSelection(default = defaultSat["modulation"], choices = [
588 (eDVBFrontendParametersSatellite.Modulation_QPSK, "QPSK"),
589 (eDVBFrontendParametersSatellite.Modulation_8PSK, "8PSK")])
590 self.scan_sat.rolloff = ConfigSelection(default = defaultSat.get("rolloff", eDVBFrontendParametersSatellite.RollOff_alpha_0_35), choices = [
591 (eDVBFrontendParametersSatellite.RollOff_alpha_0_35, "0.35"),
592 (eDVBFrontendParametersSatellite.RollOff_alpha_0_25, "0.25"),
593 (eDVBFrontendParametersSatellite.RollOff_alpha_0_20, "0.20")])
594 self.scan_sat.pilot = ConfigSelection(default = defaultSat.get("pilot", eDVBFrontendParametersSatellite.Pilot_Unknown), choices = [
595 (eDVBFrontendParametersSatellite.Pilot_Off, _("off")),
596 (eDVBFrontendParametersSatellite.Pilot_On, _("on")),
597 (eDVBFrontendParametersSatellite.Pilot_Unknown, _("Auto"))])
600 self.scan_cab.frequency = ConfigInteger(default = defaultCab["frequency"], limits = (50, 999))
601 self.scan_cab.inversion = ConfigSelection(default = defaultCab["inversion"], choices = [
602 (eDVBFrontendParametersCable.Inversion_Off, _("off")),
603 (eDVBFrontendParametersCable.Inversion_On, _("on")),
604 (eDVBFrontendParametersCable.Inversion_Unknown, _("Auto"))])
605 self.scan_cab.modulation = ConfigSelection(default = defaultCab["modulation"], choices = [
606 (eDVBFrontendParametersCable.Modulation_QAM16, "16-QAM"),
607 (eDVBFrontendParametersCable.Modulation_QAM32, "32-QAM"),
608 (eDVBFrontendParametersCable.Modulation_QAM64, "64-QAM"),
609 (eDVBFrontendParametersCable.Modulation_QAM128, "128-QAM"),
610 (eDVBFrontendParametersCable.Modulation_QAM256, "256-QAM")])
611 self.scan_cab.fec = ConfigSelection(default = defaultCab["fec"], choices = [
612 (eDVBFrontendParametersCable.FEC_Auto, _("Auto")),
613 (eDVBFrontendParametersCable.FEC_1_2, "1/2"),
614 (eDVBFrontendParametersCable.FEC_2_3, "2/3"),
615 (eDVBFrontendParametersCable.FEC_3_4, "3/4"),
616 (eDVBFrontendParametersCable.FEC_5_6, "5/6"),
617 (eDVBFrontendParametersCable.FEC_7_8, "7/8"),
618 (eDVBFrontendParametersCable.FEC_8_9, "8/9"),
619 (eDVBFrontendParametersCable.FEC_None, _("None"))])
620 self.scan_cab.symbolrate = ConfigInteger(default = defaultCab["symbolrate"], limits = (1, 99999))
623 self.scan_ter.frequency = ConfigInteger(default = 466000, limits = (50000, 999000))
624 self.scan_ter.inversion = ConfigSelection(default = defaultTer["inversion"], choices = [
625 (eDVBFrontendParametersTerrestrial.Inversion_Off, _("off")),
626 (eDVBFrontendParametersTerrestrial.Inversion_On, _("on")),
627 (eDVBFrontendParametersTerrestrial.Inversion_Unknown, _("Auto"))])
628 # WORKAROUND: we can't use BW-auto
629 self.scan_ter.bandwidth = ConfigSelection(default = defaultTer["bandwidth"], choices = [
630 (eDVBFrontendParametersTerrestrial.Bandwidth_8MHz, "8MHz"),
631 (eDVBFrontendParametersTerrestrial.Bandwidth_7MHz, "7MHz"),
632 (eDVBFrontendParametersTerrestrial.Bandwidth_6MHz, "6MHz")])
633 #, (eDVBFrontendParametersTerrestrial.Bandwidth_Auto, _("Auto"))))
634 self.scan_ter.fechigh = ConfigSelection(default = defaultTer["fechigh"], choices = [
635 (eDVBFrontendParametersTerrestrial.FEC_1_2, "1/2"),
636 (eDVBFrontendParametersTerrestrial.FEC_2_3, "2/3"),
637 (eDVBFrontendParametersTerrestrial.FEC_3_4, "3/4"),
638 (eDVBFrontendParametersTerrestrial.FEC_5_6, "5/6"),
639 (eDVBFrontendParametersTerrestrial.FEC_7_8, "7/8"),
640 (eDVBFrontendParametersTerrestrial.FEC_Auto, _("Auto"))])
641 self.scan_ter.feclow = ConfigSelection(default = defaultTer["feclow"], choices = [
642 (eDVBFrontendParametersTerrestrial.FEC_1_2, "1/2"),
643 (eDVBFrontendParametersTerrestrial.FEC_2_3, "2/3"),
644 (eDVBFrontendParametersTerrestrial.FEC_3_4, "3/4"),
645 (eDVBFrontendParametersTerrestrial.FEC_5_6, "5/6"),
646 (eDVBFrontendParametersTerrestrial.FEC_7_8, "7/8"),
647 (eDVBFrontendParametersTerrestrial.FEC_Auto, _("Auto"))])
648 self.scan_ter.modulation = ConfigSelection(default = defaultTer["modulation"], choices = [
649 (eDVBFrontendParametersTerrestrial.Modulation_QPSK, "QPSK"),
650 (eDVBFrontendParametersTerrestrial.Modulation_QAM16, "QAM16"),
651 (eDVBFrontendParametersTerrestrial.Modulation_QAM64, "QAM64"),
652 (eDVBFrontendParametersTerrestrial.Modulation_Auto, _("Auto"))])
653 self.scan_ter.transmission = ConfigSelection(default = defaultTer["transmission_mode"], choices = [
654 (eDVBFrontendParametersTerrestrial.TransmissionMode_2k, "2K"),
655 (eDVBFrontendParametersTerrestrial.TransmissionMode_8k, "8K"),
656 (eDVBFrontendParametersTerrestrial.TransmissionMode_Auto, _("Auto"))])
657 self.scan_ter.guard = ConfigSelection(default = defaultTer["guard_interval"], choices = [
658 (eDVBFrontendParametersTerrestrial.GuardInterval_1_32, "1/32"),
659 (eDVBFrontendParametersTerrestrial.GuardInterval_1_16, "1/16"),
660 (eDVBFrontendParametersTerrestrial.GuardInterval_1_8, "1/8"),
661 (eDVBFrontendParametersTerrestrial.GuardInterval_1_4, "1/4"),
662 (eDVBFrontendParametersTerrestrial.GuardInterval_Auto, _("Auto"))])
663 self.scan_ter.hierarchy = ConfigSelection(default = defaultTer["hierarchy"], choices = [
664 (eDVBFrontendParametersTerrestrial.Hierarchy_None, _("None")),
665 (eDVBFrontendParametersTerrestrial.Hierarchy_1, "1"),
666 (eDVBFrontendParametersTerrestrial.Hierarchy_2, "2"),
667 (eDVBFrontendParametersTerrestrial.Hierarchy_4, "4"),
668 (eDVBFrontendParametersTerrestrial.Hierarchy_Auto, _("Auto"))])
670 self.scan_scansat = {}
671 for sat in nimmanager.satList:
673 self.scan_scansat[sat[0]] = ConfigYesNo(default = False)
675 self.scan_satselection = []
676 for slot in nimmanager.nim_slots:
677 if slot.isCompatible("DVB-S"):
678 self.scan_satselection.append(getConfigSatlist(defaultSat["orbpos"], self.satList[slot.slot]))
680 self.scan_satselection.append(None)
685 ConfigListScreen.keyLeft(self)
689 ConfigListScreen.keyRight(self)
692 def updateStatus(self):
695 def addSatTransponder(self, tlist, frequency, symbol_rate, polarisation, fec, inversion, orbital_position, system, modulation, rolloff, pilot):
696 print "Add Sat: frequ: " + str(frequency) + " symbol: " + str(symbol_rate) + " pol: " + str(polarisation) + " fec: " + str(fec) + " inversion: " + str(inversion) + " modulation: " + str(modulation) + " system: " + str(system) + " rolloff" + str(rolloff) + " pilot" + str(pilot)
697 print "orbpos: " + str(orbital_position)
698 parm = eDVBFrontendParametersSatellite()
699 parm.modulation = modulation
701 parm.frequency = frequency * 1000
702 parm.symbol_rate = symbol_rate * 1000
703 parm.polarisation = polarisation
705 parm.inversion = inversion
706 parm.orbital_position = orbital_position
707 parm.rolloff = rolloff
711 def addCabTransponder(self, tlist, frequency, symbol_rate, modulation, fec, inversion):
712 print "Add Cab: frequ: " + str(frequency) + " symbol: " + str(symbol_rate) + " pol: " + str(modulation) + " fec: " + str(fec) + " inversion: " + str(inversion)
713 parm = eDVBFrontendParametersCable()
714 parm.frequency = frequency * 1000
715 parm.symbol_rate = symbol_rate * 1000
716 parm.modulation = modulation
718 parm.inversion = inversion
721 def addTerTransponder(self, tlist, *args, **kwargs):
722 tlist.append(buildTerTransponder(*args, **kwargs))
725 if self.scan_nims.value == "":
731 index_to_scan = int(self.scan_nims.value)
733 if self.scan_nims == [ ]:
734 self.session.open(MessageBox, _("No tuner is enabled!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
737 nim = nimmanager.nim_slots[index_to_scan]
738 print "nim", nim.slot
739 if nim.isCompatible("DVB-S"):
740 print "is compatible with DVB-S"
741 if self.scan_type.value == "single_transponder":
742 # these lists are generated for each tuner, so this has work.
743 assert len(self.satList) > index_to_scan
744 assert len(self.scan_satselection) > index_to_scan
746 nimsats = self.satList[index_to_scan]
747 selsatidx = self.scan_satselection[index_to_scan].index
749 # however, the satList itself could be empty. in that case, "index" is 0 (for "None").
751 orbpos = nimsats[selsatidx][0]
752 if self.scan_sat.system.value == eDVBFrontendParametersSatellite.System_DVB_S:
753 fec = self.scan_sat.fec.value
755 fec = self.scan_sat.fec_s2.value
756 print "add sat transponder"
757 self.addSatTransponder(tlist, self.scan_sat.frequency.value,
758 self.scan_sat.symbolrate.value,
759 self.scan_sat.polarization.value,
761 self.scan_sat.inversion.value,
763 self.scan_sat.system.value,
764 self.scan_sat.modulation.value,
765 self.scan_sat.rolloff.value,
766 self.scan_sat.pilot.value)
768 elif self.scan_type.value == "single_satellite":
769 sat = self.satList[index_to_scan][self.scan_satselection[index_to_scan].index]
770 getInitialTransponderList(tlist, sat[0])
771 elif self.scan_type.value.find("multisat") != -1:
772 SatList = nimmanager.getSatListForNim(index_to_scan)
773 for x in self.multiscanlist:
775 print " " + str(x[0])
776 getInitialTransponderList(tlist, x[0])
778 elif nim.isCompatible("DVB-C"):
779 if self.scan_typecable.value == "single_transponder":
780 self.addCabTransponder(tlist, self.scan_cab.frequency.value,
781 self.scan_cab.symbolrate.value,
782 self.scan_cab.modulation.value,
783 self.scan_cab.fec.value,
784 self.scan_cab.inversion.value)
786 elif self.scan_typecable.value == "complete":
787 if config.Nims[index_to_scan].cable.scan_type.value == "provider":
788 getInitialCableTransponderList(tlist, index_to_scan)
792 elif nim.isCompatible("DVB-T"):
793 if self.scan_typeterrestrial.value == "single_transponder":
794 self.addTerTransponder(tlist,
795 self.scan_ter.frequency.value * 1000,
796 inversion = self.scan_ter.inversion.value,
797 bandwidth = self.scan_ter.bandwidth.value,
798 fechigh = self.scan_ter.fechigh.value,
799 feclow = self.scan_ter.feclow.value,
800 modulation = self.scan_ter.modulation.value,
801 transmission = self.scan_ter.transmission.value,
802 guard = self.scan_ter.guard.value,
803 hierarchy = self.scan_ter.hierarchy.value)
805 elif self.scan_typeterrestrial.value == "complete":
806 getInitialTerrestrialTransponderList(tlist, nimmanager.getTerrestrialDescription(index_to_scan))
808 flags = self.scan_networkScan.value and eComponentScan.scanNetworkSearch or 0
810 tmp = self.scan_clearallservices.value
812 flags |= eComponentScan.scanRemoveServices
813 elif tmp == "yes_hold_feeds":
814 flags |= eComponentScan.scanRemoveServices
815 flags |= eComponentScan.scanDontRemoveFeeds
817 if tmp != "no" and not removeAll:
818 flags |= eComponentScan.scanDontRemoveUnscanned
820 if self.scan_onlyfree.value:
821 flags |= eComponentScan.scanOnlyFree
823 for x in self["config"].list:
827 self.startScan(tlist, flags, index_to_scan)
830 self.feid = index_to_scan
832 self.startCableTransponderSearch(self.feid)
834 def setCableTransponderSearchResult(self, tlist):
837 def cableTransponderSearchFinished(self):
838 if self.tlist is None:
841 self.startScan(self.tlist, self.flags, self.feid)
843 def startScan(self, tlist, flags, feid):
845 # flags |= eComponentScan.scanSearchBAT
847 self.session.openWithCallback(self.finished_cb, ServiceScan, [{"transponders": tlist, "feid": feid, "flags": flags}])
849 self.session.open(ServiceScan, [{"transponders": tlist, "feid": feid, "flags": flags}])
852 self.session.openWithCallback(self.finished_cb, MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
854 self.session.open(MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
857 for x in self["config"].list:
861 class ScanSimple(ConfigListScreen, Screen, CableTransponderSearchSupport):
862 def getNetworksForNim(self, nim):
863 if nim.isCompatible("DVB-S"):
864 networks = nimmanager.getSatListForNim(nim.slot)
866 networks = [ nim.type ] # "DVB-C" or "DVB-T". TODO: seperate networks for different C/T tuners, if we want to support that.
868 # empty tuners provide no networks.
872 def __init__(self, session):
873 Screen.__init__(self, session)
875 self["actions"] = ActionMap(["SetupActions"],
878 "cancel": self.keyCancel,
886 self.finished_cb = None
888 for nim in nimmanager.nim_slots:
889 # collect networks provided by this tuner
892 networks = self.getNetworksForNim(nim)
894 print "nim %d provides" % nim.slot, networks
895 print "known:", known_networks
897 # we only need to scan on the first tuner which provides a network.
898 # this gives the first tuner for each network priority for scanning.
900 if x not in known_networks:
902 print x, "not in ", known_networks
903 known_networks.append(x)
905 # don't offer to scan nims if nothing is connected
906 if not nimmanager.somethingConnected(nim.slot):
910 nims_to_scan.append(nim)
912 # we save the config elements to use them on keyGo
913 self.nim_enable = [ ]
915 if len(nims_to_scan):
916 self.scan_clearallservices = ConfigSelection(default = "yes", choices = [("no", _("no")), ("yes", _("yes")), ("yes_hold_feeds", _("yes (keep feeds)"))])
917 self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
919 for nim in nims_to_scan:
920 nimconfig = ConfigYesNo(default = True)
921 nimconfig.nim_index = nim.slot
922 self.nim_enable.append(nimconfig)
923 self.list.append(getConfigListEntry(_("Scan ") + nim.slot_name + " (" + nim.friendly_type + ")", nimconfig))
925 ConfigListScreen.__init__(self, self.list)
926 self["header"] = Label(_("Automatic Scan"))
927 self["footer"] = Label(_("Press OK to scan"))
929 def runAsync(self, finished_cb):
930 self.finished_cb = finished_cb
935 self.known_networks = set()
937 self.buildTransponderList()
939 def buildTransponderList(self): # this method is called multiple times because of asynchronous stuff
941 SEARCH_CABLE_TRANSPONDERS = 1
944 n = self.nim_iter < len(self.nim_enable) and self.nim_enable[self.nim_iter] or None
947 if n.value: # check if nim is enabled
949 nim = nimmanager.nim_slots[n.nim_index]
950 networks = set(self.getNetworksForNim(nim))
952 # don't scan anything twice
953 networks.discard(self.known_networks)
956 if nim.isCompatible("DVB-S"):
957 # get initial transponders for each satellite to be scanned
959 getInitialTransponderList(tlist, sat[0])
960 elif nim.isCompatible("DVB-C"):
961 if config.Nims[nim.slot].cable.scan_type.value == "provider":
962 getInitialCableTransponderList(tlist, nim.slot)
964 action = SEARCH_CABLE_TRANSPONDERS
965 elif nim.isCompatible("DVB-T"):
966 getInitialTerrestrialTransponderList(tlist, nimmanager.getTerrestrialDescription(nim.slot))
970 flags |= eComponentScan.scanNetworkSearch #FIXMEEE.. use flags from cables / satellites / terrestrial.xml
971 tmp = self.scan_clearallservices.value
973 flags |= eComponentScan.scanRemoveServices
974 elif tmp == "yes_hold_feeds":
975 flags |= eComponentScan.scanRemoveServices
976 flags |= eComponentScan.scanDontRemoveFeeds
978 if action == APPEND_NOW:
979 self.scanList.append({"transponders": tlist, "feid": nim.slot, "flags": flags})
980 elif action == SEARCH_CABLE_TRANSPONDERS:
983 self.startCableTransponderSearch(nim.slot)
988 self.buildTransponderList() # recursive call of this function !!!
990 # when we are here, then the recursion is finished and all enabled nims are checked
991 # so we now start the real transponder scan
992 self.startScan(self.scanList)
994 def startScan(self, scanList):
997 self.session.openWithCallback(self.finished_cb, ServiceScan, scanList = scanList)
999 self.session.open(ServiceScan, scanList = scanList)
1001 if self.finished_cb:
1002 self.session.openWithCallback(self.finished_cb, MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
1004 self.session.open(MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
1006 def setCableTransponderSearchResult(self, tlist):
1007 if tlist is not None:
1008 self.scanList.append({"transponders": tlist, "feid": self.feid, "flags": self.flags})
1010 def cableTransponderSearchFinished(self):
1011 self.buildTransponderList()
1013 def keyCancel(self):
1016 def Satexists(self, tlist, pos):