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 Screens.MessageBox import MessageBox
12 from enigma import eTimer, eDVBFrontendParametersSatellite, eComponentScan, \
13 eDVBSatelliteEquipmentControl, eDVBFrontendParametersTerrestrial, \
14 eDVBFrontendParametersCable, eConsoleAppContainer, eDVBResourceManager
16 def buildTerTransponder(frequency,
17 inversion=2, bandwidth = 3, fechigh = 6, feclow = 6,
18 modulation = 2, transmission = 2, guard = 4,
20 # print "freq", frequency, "inv", inversion, "bw", bandwidth, "fech", fechigh, "fecl", feclow, "mod", modulation, "tm", transmission, "guard", guard, "hierarchy", hierarchy
21 parm = eDVBFrontendParametersTerrestrial()
22 parm.frequency = frequency
23 parm.inversion = inversion
24 parm.bandwidth = bandwidth
25 parm.code_rate_HP = fechigh
26 parm.code_rate_LP = feclow
27 parm.modulation = modulation
28 parm.transmission_mode = transmission
29 parm.guard_interval = guard
30 parm.hierarchy = hierarchy
33 def getInitialTransponderList(tlist, pos):
34 list = nimmanager.getTransponders(pos)
37 parm = eDVBFrontendParametersSatellite()
39 parm.symbol_rate = x[2]
40 parm.polarisation = x[3]
43 parm.orbital_position = pos
45 parm.modulation = x[6]
50 def getInitialCableTransponderList(tlist, nim):
51 list = nimmanager.getTranspondersCable(nim)
54 parm = eDVBFrontendParametersCable()
56 parm.symbol_rate = x[2]
57 parm.modulation = x[3]
59 parm.inversion = parm.Inversion_Unknown
60 #print "frequency:", x[1]
61 #print "symbol_rate:", x[2]
62 #print "modulation:", x[3]
63 #print "fec_inner:", x[4]
64 #print "inversion:", 2
67 def getInitialTerrestrialTransponderList(tlist, region):
68 list = nimmanager.getTranspondersTerrestrial(region)
70 #self.transponders[self.parsedTer].append((2,freq,bw,const,crh,crl,guard,transm,hierarchy,inv))
72 #def buildTerTransponder(frequency, inversion = 2, bandwidth = 3, fechigh = 6, feclow = 6,
73 #modulation = 2, transmission = 2, guard = 4, hierarchy = 4):
76 if x[0] == 2: #TERRESTRIAL
77 parm = buildTerTransponder(x[1], x[9], x[2], x[4], x[5], x[3], x[7], x[6], x[8])
81 "DVBC_BAND_EU_VHF_I" : 1 << 0,
82 "DVBC_BAND_EU_MID" : 1 << 1,
83 "DVBC_BAND_EU_VHF_III" : 1 << 2,
84 "DVBC_BAND_EU_SUPER" : 1 << 3,
85 "DVBC_BAND_EU_HYPER" : 1 << 4,
86 "DVBC_BAND_EU_UHF_IV" : 1 << 5,
87 "DVBC_BAND_EU_UHF_V" : 1 << 6,
88 "DVBC_BAND_US_LO" : 1 << 7,
89 "DVBC_BAND_US_MID" : 1 << 8,
90 "DVBC_BAND_US_HI" : 1 << 9,
91 "DVBC_BAND_US_SUPER" : 1 << 10,
92 "DVBC_BAND_US_HYPER" : 1 << 11,
95 class CableTransponderSearchSupport:
96 # def setCableTransponderSearchResult(self, tlist):
99 # def cableTransponderSearchFinished(self):
102 def tryGetRawFrontend(self, feid):
103 res_mgr = eDVBResourceManager.getInstance()
105 raw_channel = res_mgr.allocateRawChannel(self.feid)
107 frontend = raw_channel.getFrontend()
114 def cableTransponderSearchSessionClosed(self, *val):
115 print "cableTransponderSearchSessionClosed, val", val
116 self.cable_search_container.appClosed.remove(self.cableTransponderSearchClosed)
117 self.cable_search_container.dataAvail.remove(self.getCableTransponderData)
118 self.cable_search_container = None
119 self.cable_search_session = None
120 if val and len(val) and val[0]:
121 self.setCableTransponderSearchResult(self.__tlist)
123 self.cableTransponderSearchFinished()
125 def cableTransponderSearchClosed(self, retval):
126 print "cableTransponderSearch finished", retval
127 self.cable_search_session.close(True)
129 def getCableTransponderData(self, str):
134 parm = eDVBFrontendParametersCable()
135 qam = { "QAM16" : parm.Modulation_QAM16,
136 "QAM32" : parm.Modulation_QAM32,
137 "QAM64" : parm.Modulation_QAM64,
138 "QAM128" : parm.Modulation_QAM128,
139 "QAM256" : parm.Modulation_QAM256 }
140 inv = { "INVERSION_OFF" : parm.Inversion_Off,
141 "INVERSION_ON" : parm.Inversion_On,
142 "INVERSION_AUTO" : parm.Inversion_Unknown }
143 fec = { "FEC_AUTO" : parm.FEC_Auto,
144 "FEC_1_2" : parm.FEC_1_2,
145 "FEC_2_3" : parm.FEC_2_3,
146 "FEC_3_4" : parm.FEC_3_4,
147 "FEC_5_6": parm.FEC_5_6,
148 "FEC_7_8" : parm.FEC_7_8,
149 "FEC_8_9" : parm.FEC_8_9,
150 "FEC_NONE" : parm.FEC_None }
151 parm.frequency = int(data[1])
152 parm.symbol_rate = int(data[2])
153 parm.fec_inner = fec[data[3]]
154 parm.modulation = qam[data[4]]
155 parm.inversion = inv[data[5]]
156 self.__tlist.append(parm)
157 tmpstr = _("Try to find used Transponders in cable network.. please wait...")
162 self.cable_search_session["text"].setText(tmpstr)
164 def startCableTransponderSearch(self, nim_idx):
165 if not self.tryGetRawFrontend(nim_idx):
166 self.session.nav.stopService()
167 if not self.tryGetRawFrontend(nim_idx):
168 if self.session.pipshown: # try to disable pip
169 self.session.pipshown = False
171 if not self.tryGetRawFrontend(nim_idx):
172 self.cableTransponderSearchFinished()
175 self.cable_search_container = eConsoleAppContainer()
176 self.cable_search_container.appClosed.append(self.cableTransponderSearchClosed)
177 self.cable_search_container.dataAvail.append(self.getCableTransponderData)
178 cableConfig = config.Nims[nim_idx].cable
179 cmd = "tda1002x --init --scan --verbose --wakeup --inv 2 --bus "
180 #FIXMEEEEEE hardcoded i2c devices for dm7025 and dm8000
185 cmd += "2" # first nim socket on DM8000 use /dev/i2c/2
187 cmd += "4" # second nim socket on DM8000 use /dev/i2c/4
188 if cableConfig.scan_type.value == "bands":
189 cmd += " --scan-bands "
191 if cableConfig.scan_band_EU_VHF_I.value:
192 bands |= cable_bands["DVBC_BAND_EU_VHF_I"]
193 if cableConfig.scan_band_EU_MID.value:
194 bands |= cable_bands["DVBC_BAND_EU_MID"]
195 if cableConfig.scan_band_EU_VHF_III.value:
196 bands |= cable_bands["DVBC_BAND_EU_VHF_III"]
197 if cableConfig.scan_band_EU_UHF_IV.value:
198 bands |= cable_bands["DVBC_BAND_EU_UHF_IV"]
199 if cableConfig.scan_band_EU_UHF_V.value:
200 bands |= cable_bands["DVBC_BAND_EU_UHF_V"]
201 if cableConfig.scan_band_EU_SUPER.value:
202 bands |= cable_bands["DVBC_BAND_EU_SUPER"]
203 if cableConfig.scan_band_EU_HYPER.value:
204 bands |= cable_bands["DVBC_BAND_EU_HYPER"]
205 if cableConfig.scan_band_US_LOW.value:
206 bands |= cable_bands["DVBC_BAND_US_LO"]
207 if cableConfig.scan_band_US_MID.value:
208 bands |= cable_bands["DVBC_BAND_US_MID"]
209 if cableConfig.scan_band_US_HIGH.value:
210 bands |= cable_bands["DVBC_BAND_US_HI"]
211 if cableConfig.scan_band_US_SUPER.value:
212 bands |= cable_bands["DVBC_BAND_US_SUPER"]
213 if cableConfig.scan_band_US_HYPER.value:
214 bands |= cable_bands["DVBC_BAND_US_HYPER"]
217 cmd += " --scan-stepsize "
218 cmd += str(cableConfig.scan_frequency_steps.value)
219 if cableConfig.scan_mod_qam16.value:
221 if cableConfig.scan_mod_qam32.value:
223 if cableConfig.scan_mod_qam64.value:
225 if cableConfig.scan_mod_qam128.value:
227 if cableConfig.scan_mod_qam256.value:
229 if cableConfig.scan_sr_6900.value:
230 cmd += " --sr 6900000"
231 if cableConfig.scan_sr_6875.value:
232 cmd += " --sr 6875000"
233 if cableConfig.scan_sr_ext1.value > 450:
235 cmd += str(cableConfig.scan_sr_ext1.value)
237 if cableConfig.scan_sr_ext2.value > 450:
239 cmd += str(cableConfig.scan_sr_ext2.value)
241 print "TDA1002x CMD is", cmd
243 self.cable_search_container.execute(cmd)
244 tmpstr = _("Try to find used transponders in cable network.. please wait...")
246 self.cable_search_session = self.session.openWithCallback(self.cableTransponderSearchSessionClosed, MessageBox, tmpstr, MessageBox.TYPE_INFO)
248 class DefaultSatLists(DefaultWizard):
249 def __init__(self, session, silent = True, showSteps = False):
250 self.xmlfile = "defaultsatlists.xml"
251 DefaultWizard.__init__(self, session, silent, showSteps, neededTag = "services")
252 print "configuredSats:", nimmanager.getConfiguredSats()
254 def setDirectory(self):
256 self.directory.append(resolveFilename(SCOPE_DEFAULTDIR))
258 os.system("mount %s %s" % (resolveFilename(SCOPE_DEFAULTPARTITION), resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR)))
259 self.directory.append(resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR))
261 def statusCallback(self, status, progress):
262 print "statusCallback:", status, progress
263 from Components.DreamInfoHandler import DreamInfoHandler
264 if status == DreamInfoHandler.STATUS_DONE:
265 self["text"].setText(_("The installation of the default services lists is finished.") + "\n\n" + _("Please press OK to continue."))
267 self.disableKeys = False
269 class ScanSetup(ConfigListScreen, Screen, CableTransponderSearchSupport):
270 def __init__(self, session):
271 Screen.__init__(self, session)
273 self.finished_cb = None
275 self.service = session.nav.getCurrentService()
278 if self.service is not None:
279 self.feinfo = self.service.frontendInfo()
280 frontendData = self.feinfo and self.feinfo.getAll(True)
282 self.createConfig(frontendData)
287 self["actions"] = NumberActionMap(["SetupActions"],
290 "cancel": self.keyCancel,
293 self.statusTimer = eTimer()
294 self.statusTimer.callback.append(self.updateStatus)
295 #self.statusTimer.start(5000, True)
298 ConfigListScreen.__init__(self, self.list)
299 if not self.scan_nims.value == "":
301 self["introduction"] = Label(_("Press OK to start the scan"))
303 self["introduction"] = Label(_("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."))
305 def runAsync(self, finished_cb):
306 self.finished_cb = finished_cb
309 def updateSatList(self):
311 for slot in nimmanager.nim_slots:
312 if slot.isCompatible("DVB-S"):
313 self.satList.append(nimmanager.getSatListForNim(slot.slot))
315 self.satList.append(None)
317 def createSetup(self):
319 self.multiscanlist = []
320 index_to_scan = int(self.scan_nims.value)
321 print "ID: ", index_to_scan
323 self.tunerEntry = getConfigListEntry(_("Tuner"), self.scan_nims)
324 self.list.append(self.tunerEntry)
326 if self.scan_nims == [ ]:
329 self.typeOfScanEntry = None
330 self.systemEntry = None
331 self.modulationEntry = None
332 nim = nimmanager.nim_slots[index_to_scan]
333 if nim.isCompatible("DVB-S"):
334 self.typeOfScanEntry = getConfigListEntry(_("Type of scan"), self.scan_type)
335 self.list.append(self.typeOfScanEntry)
336 elif nim.isCompatible("DVB-C"):
337 self.typeOfScanEntry = getConfigListEntry(_("Type of scan"), self.scan_typecable)
338 self.list.append(self.typeOfScanEntry)
339 elif nim.isCompatible("DVB-T"):
340 self.typeOfScanEntry = getConfigListEntry(_("Type of scan"), self.scan_typeterrestrial)
341 self.list.append(self.typeOfScanEntry)
343 self.scan_networkScan.value = False
344 if nim.isCompatible("DVB-S"):
345 if self.scan_type.value == "single_transponder":
347 if nim.isCompatible("DVB-S2"):
348 self.systemEntry = getConfigListEntry(_('System'), self.scan_sat.system)
349 self.list.append(self.systemEntry)
351 # downgrade to dvb-s, in case a -s2 config was active
352 self.scan_sat.system.value = eDVBFrontendParametersSatellite.System_DVB_S
353 self.list.append(getConfigListEntry(_('Satellite'), self.scan_satselection[index_to_scan]))
354 self.list.append(getConfigListEntry(_('Frequency'), self.scan_sat.frequency))
355 self.list.append(getConfigListEntry(_('Inversion'), self.scan_sat.inversion))
356 self.list.append(getConfigListEntry(_('Symbol Rate'), self.scan_sat.symbolrate))
357 self.list.append(getConfigListEntry(_("Polarity"), self.scan_sat.polarization))
358 if self.scan_sat.system.value == eDVBFrontendParametersSatellite.System_DVB_S:
359 self.list.append(getConfigListEntry(_("FEC"), self.scan_sat.fec))
360 elif self.scan_sat.system.value == eDVBFrontendParametersSatellite.System_DVB_S2:
361 self.list.append(getConfigListEntry(_("FEC"), self.scan_sat.fec_s2))
362 self.modulationEntry = getConfigListEntry(_('Modulation'), self.scan_sat.modulation)
363 self.list.append(self.modulationEntry)
364 self.list.append(getConfigListEntry(_('Rolloff'), self.scan_sat.rolloff))
365 self.list.append(getConfigListEntry(_('Pilot'), self.scan_sat.pilot))
366 elif self.scan_type.value == "single_satellite":
368 print self.scan_satselection[index_to_scan]
369 self.list.append(getConfigListEntry(_("Satellite"), self.scan_satselection[index_to_scan]))
370 self.scan_networkScan.value = True
371 elif self.scan_type.value.find("multisat") != -1:
373 SatList = nimmanager.getSatListForNim(index_to_scan)
375 if self.Satexists(tlist, x[0]) == 0:
377 sat = ConfigEnableDisable(default = self.scan_type.value.find("_yes") != -1 and True or False)
378 configEntry = getConfigListEntry(nimmanager.getSatDescription(x[0]), sat)
379 self.list.append(configEntry)
380 self.multiscanlist.append((x[0], sat))
381 self.scan_networkScan.value = True
382 elif nim.isCompatible("DVB-C"):
383 if self.scan_typecable.value == "single_transponder":
384 self.list.append(getConfigListEntry(_("Frequency"), self.scan_cab.frequency))
385 self.list.append(getConfigListEntry(_("Inversion"), self.scan_cab.inversion))
386 self.list.append(getConfigListEntry(_("Symbol Rate"), self.scan_cab.symbolrate))
387 self.list.append(getConfigListEntry(_("Modulation"), self.scan_cab.modulation))
388 self.list.append(getConfigListEntry(_("FEC"), self.scan_cab.fec))
389 elif nim.isCompatible("DVB-T"):
390 if self.scan_typeterrestrial.value == "single_transponder":
391 self.list.append(getConfigListEntry(_("Frequency"), self.scan_ter.frequency))
392 self.list.append(getConfigListEntry(_("Inversion"), self.scan_ter.inversion))
393 self.list.append(getConfigListEntry(_("Bandwidth"), self.scan_ter.bandwidth))
394 self.list.append(getConfigListEntry(_("Code rate high"), self.scan_ter.fechigh))
395 self.list.append(getConfigListEntry(_("Code rate low"), self.scan_ter.feclow))
396 self.list.append(getConfigListEntry(_("Modulation"), self.scan_ter.modulation))
397 self.list.append(getConfigListEntry(_("Transmission mode"), self.scan_ter.transmission))
398 self.list.append(getConfigListEntry(_("Guard interval mode"), self.scan_ter.guard))
399 self.list.append(getConfigListEntry(_("Hierarchy mode"), self.scan_ter.hierarchy))
400 self.list.append(getConfigListEntry(_("Network scan"), self.scan_networkScan))
401 self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
402 self.list.append(getConfigListEntry(_("Only Free scan"), self.scan_onlyfree))
403 self["config"].list = self.list
404 self["config"].l.setList(self.list)
406 def Satexists(self, tlist, pos):
413 cur = self["config"].getCurrent()
415 if cur == self.typeOfScanEntry or \
416 cur == self.tunerEntry or \
417 cur == self.systemEntry or \
418 (self.modulationEntry and self.systemEntry[1].value == eDVBFrontendParametersSatellite.System_DVB_S2 and cur == self.modulationEntry):
421 def createConfig(self, frontendData):
422 #("Type", frontendData["system"], TYPE_TEXT),
423 #("Modulation", frontendData["modulation"], TYPE_TEXT),
424 #("Orbital position", frontendData["orbital_position"], TYPE_VALUE_DEC),
425 #("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
426 #("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC),
427 #("Polarization", frontendData["polarization"], TYPE_TEXT),
428 #("Inversion", frontendData["inversion"], TYPE_TEXT),
429 #("FEC inner", frontendData["fec_inner"], TYPE_TEXT),
431 #elif frontendData["tuner_type"] == "DVB-C":
432 #return ( ("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
433 #("Type", frontendData["tuner_type"], TYPE_TEXT),
434 #("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
435 #("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC),
436 #("Modulation", frontendData["modulation"], TYPE_TEXT),
437 #("Inversion", frontendData["inversion"], TYPE_TEXT),
438 # ("FEC inner", frontendData["fec_inner"], TYPE_TEXT),
440 #elif frontendData["tuner_type"] == "DVB-T":
441 #return ( ("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
442 #("Type", frontendData["tuner_type"], TYPE_TEXT),
443 #("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
444 #("Inversion", frontendData["inversion"], TYPE_TEXT),
445 #("Bandwidth", frontendData["bandwidth"], TYPE_VALUE_DEC),
446 #("CodeRateLP", frontendData["code_rate_lp"], TYPE_TEXT),
447 #("CodeRateHP", frontendData["code_rate_hp"], TYPE_TEXT),
448 #("Constellation", frontendData["constellation"], TYPE_TEXT),
449 #("Transmission Mode", frontendData["transmission_mode"], TYPE_TEXT),
450 #("Guard Interval", frontendData["guard_interval"], TYPE_TEXT),
451 #("Hierarchy Inform.", frontendData["hierarchy_information"], TYPE_TEXT),
454 "system": eDVBFrontendParametersSatellite.System_DVB_S,
456 "inversion": eDVBFrontendParametersSatellite.Inversion_Unknown,
458 "polarization": eDVBFrontendParametersSatellite.Polarisation_Horizontal,
459 "fec": eDVBFrontendParametersSatellite.FEC_Auto,
460 "fec_s2": eDVBFrontendParametersSatellite.FEC_9_10,
461 "modulation": eDVBFrontendParametersSatellite.Modulation_QPSK }
464 "inversion": eDVBFrontendParametersCable.Inversion_Unknown,
465 "modulation": eDVBFrontendParametersCable.Modulation_QAM64,
466 "fec": eDVBFrontendParametersCable.FEC_Auto,
469 "frequency" : 466000,
470 "inversion" : eDVBFrontendParametersTerrestrial.Inversion_Unknown,
471 "bandwidth" : eDVBFrontendParametersTerrestrial.Bandwidth_7MHz,
472 "fechigh" : eDVBFrontendParametersTerrestrial.FEC_Auto,
473 "feclow" : eDVBFrontendParametersTerrestrial.FEC_Auto,
474 "modulation" : eDVBFrontendParametersTerrestrial.Modulation_Auto,
475 "transmission_mode" : eDVBFrontendParametersTerrestrial.TransmissionMode_Auto,
476 "guard_interval" : eDVBFrontendParametersTerrestrial.GuardInterval_Auto,
477 "hierarchy": eDVBFrontendParametersTerrestrial.Hierarchy_Auto }
479 if frontendData is not None:
480 ttype = frontendData.get("tuner_type", "UNKNOWN")
482 defaultSat["system"] = frontendData.get("system", eDVBFrontendParametersSatellite.System_DVB_S)
483 defaultSat["frequency"] = frontendData.get("frequency", 0) / 1000
484 defaultSat["inversion"] = frontendData.get("inversion", eDVBFrontendParametersSatellite.Inversion_Unknown)
485 defaultSat["symbolrate"] = frontendData.get("symbol_rate", 0) / 1000
486 defaultSat["polarization"] = frontendData.get("polarization", eDVBFrontendParametersSatellite.Polarisation_Horizontal)
487 if defaultSat["system"] == eDVBFrontendParametersSatellite.System_DVB_S2:
488 defaultSat["fec_s2"] = frontendData.get("fec_inner", eDVBFrontendParametersSatellite.FEC_Auto)
489 defaultSat["rolloff"] = frontendData.get("rolloff", eDVBFrontendParametersSatellite.RollOff_alpha_0_35)
490 defaultSat["pilot"] = frontendData.get("pilot", eDVBFrontendParametersSatellite.Pilot_Unknown)
492 defaultSat["fec"] = frontendData.get("fec_inner", eDVBFrontendParametersSatellite.FEC_Auto)
493 defaultSat["modulation"] = frontendData.get("modulation", eDVBFrontendParametersSatellite.Modulation_QPSK)
494 defaultSat["orbpos"] = frontendData.get("orbital_position", 0)
495 elif ttype == "DVB-C":
496 defaultCab["frequency"] = frontendData.get("frequency", 0) / 1000
497 defaultCab["symbolrate"] = frontendData.get("symbol_rate", 0) / 1000
498 defaultCab["inversion"] = frontendData.get("inversion", eDVBFrontendParametersCable.Inversion_Unknown)
499 defaultCab["fec"] = frontendData.get("fec_inner", eDVBFrontendParametersCable.FEC_Auto)
500 defaultCab["modulation"] = frontendData.get("modulation", eDVBFrontendParametersCable.Modulation_QAM16)
501 elif ttype == "DVB-T":
502 defaultTer["frequency"] = frontendData.get("frequency", 0)
503 defaultTer["inversion"] = frontendData.get("inversion", eDVBFrontendParametersTerrestrial.Inversion_Unknown)
504 defaultTer["bandwidth"] = frontendData.get("bandwidth", eDVBFrontendParametersTerrestrial.Bandwidth_7MHz)
505 defaultTer["fechigh"] = frontendData.get("code_rate_hp", eDVBFrontendParametersTerrestrial.FEC_Auto)
506 defaultTer["feclow"] = frontendData.get("code_rate_lp", eDVBFrontendParametersTerrestrial.FEC_Auto)
507 defaultTer["modulation"] = frontendData.get("constellation", eDVBFrontendParametersTerrestrial.Modulation_Auto)
508 defaultTer["transmission_mode"] = frontendData.get("transmission_mode", eDVBFrontendParametersTerrestrial.TransmissionMode_Auto)
509 defaultTer["guard_interval"] = frontendData.get("guard_interval", eDVBFrontendParametersTerrestrial.GuardInterval_Auto)
510 defaultTer["hierarchy"] = frontendData.get("hierarchy_information", eDVBFrontendParametersTerrestrial.Hierarchy_Auto)
512 self.scan_sat = ConfigSubsection()
513 self.scan_cab = ConfigSubsection()
514 self.scan_ter = ConfigSubsection()
516 self.scan_type = ConfigSelection(default = "single_transponder", choices = [("single_transponder", _("Single transponder")), ("single_satellite", _("Single satellite")), ("multisat", _("Multisat")), ("multisat_yes", _("Multisat"))])
517 self.scan_typecable = ConfigSelection(default = "single_transponder", choices = [("single_transponder", _("Single transponder")), ("complete", _("Complete"))])
518 self.scan_typeterrestrial = ConfigSelection(default = "single_transponder", choices = [("single_transponder", _("Single transponder")), ("complete", _("Complete"))])
519 self.scan_clearallservices = ConfigSelection(default = "no", choices = [("no", _("no")), ("yes", _("yes")), ("yes_hold_feeds", _("yes (keep feeds)"))])
520 self.scan_onlyfree = ConfigYesNo(default = False)
521 self.scan_networkScan = ConfigYesNo(default = False)
524 # collect all nims which are *not* set to "nothing"
525 for n in nimmanager.nim_slots:
526 if n.config_mode == "nothing":
528 if n.config_mode == "advanced" and len(nimmanager.getSatListForNim(n.slot)) < 1:
530 if n.config_mode in ("loopthrough", "satposdepends"):
531 root_id = nimmanager.sec.getRoot(n.slot_id, int(n.config.connectedTo.value))
532 if n.type == nimmanager.nim_slots[root_id].type: # check if connected from a DVB-S to DVB-S2 Nim or vice versa
534 nim_list.append((str(n.slot), n.friendly_full_description))
536 self.scan_nims = ConfigSelection(choices = nim_list)
539 self.scan_snr = ConfigSlider()
540 self.scan_snr.enabled = False
541 self.scan_agc = ConfigSlider()
542 self.scan_agc.enabled = False
543 self.scan_ber = ConfigSlider()
544 self.scan_ber.enabled = False
547 self.scan_sat.system = ConfigSelection(default = defaultSat["system"], choices = [
548 (eDVBFrontendParametersSatellite.System_DVB_S, _("DVB-S")),
549 (eDVBFrontendParametersSatellite.System_DVB_S2, _("DVB-S2"))])
550 self.scan_sat.frequency = ConfigInteger(default = defaultSat["frequency"], limits = (1, 99999))
551 self.scan_sat.inversion = ConfigSelection(default = defaultSat["inversion"], choices = [
552 (eDVBFrontendParametersSatellite.Inversion_Off, _("off")),
553 (eDVBFrontendParametersSatellite.Inversion_On, _("on")),
554 (eDVBFrontendParametersSatellite.Inversion_Unknown, _("Auto"))])
555 self.scan_sat.symbolrate = ConfigInteger(default = defaultSat["symbolrate"], limits = (1, 99999))
556 self.scan_sat.polarization = ConfigSelection(default = defaultSat["polarization"], choices = [
557 (eDVBFrontendParametersSatellite.Polarisation_Horizontal, _("horizontal")),
558 (eDVBFrontendParametersSatellite.Polarisation_Vertical, _("vertical")),
559 (eDVBFrontendParametersSatellite.Polarisation_CircularLeft, _("circular left")),
560 (eDVBFrontendParametersSatellite.Polarisation_CircularRight, _("circular right"))])
561 self.scan_sat.fec = ConfigSelection(default = defaultSat["fec"], choices = [
562 (eDVBFrontendParametersSatellite.FEC_Auto, _("Auto")),
563 (eDVBFrontendParametersSatellite.FEC_1_2, "1/2"),
564 (eDVBFrontendParametersSatellite.FEC_2_3, "2/3"),
565 (eDVBFrontendParametersSatellite.FEC_3_4, "3/4"),
566 (eDVBFrontendParametersSatellite.FEC_5_6, "5/6"),
567 (eDVBFrontendParametersSatellite.FEC_7_8, "7/8"),
568 (eDVBFrontendParametersSatellite.FEC_None, _("None"))])
569 self.scan_sat.fec_s2 = ConfigSelection(default = defaultSat["fec_s2"], choices = [
570 (eDVBFrontendParametersSatellite.FEC_1_2, "1/2"),
571 (eDVBFrontendParametersSatellite.FEC_2_3, "2/3"),
572 (eDVBFrontendParametersSatellite.FEC_3_4, "3/4"),
573 (eDVBFrontendParametersSatellite.FEC_3_5, "3/5"),
574 (eDVBFrontendParametersSatellite.FEC_4_5, "4/5"),
575 (eDVBFrontendParametersSatellite.FEC_5_6, "5/6"),
576 (eDVBFrontendParametersSatellite.FEC_7_8, "7/8"),
577 (eDVBFrontendParametersSatellite.FEC_8_9, "8/9"),
578 (eDVBFrontendParametersSatellite.FEC_9_10, "9/10")])
579 self.scan_sat.modulation = ConfigSelection(default = defaultSat["modulation"], choices = [
580 (eDVBFrontendParametersSatellite.Modulation_QPSK, "QPSK"),
581 (eDVBFrontendParametersSatellite.Modulation_8PSK, "8PSK")])
582 self.scan_sat.rolloff = ConfigSelection(default = defaultSat.get("rolloff", eDVBFrontendParametersSatellite.RollOff_alpha_0_35), choices = [
583 (eDVBFrontendParametersSatellite.RollOff_alpha_0_35, "0.35"),
584 (eDVBFrontendParametersSatellite.RollOff_alpha_0_25, "0.25"),
585 (eDVBFrontendParametersSatellite.RollOff_alpha_0_20, "0.20")])
586 self.scan_sat.pilot = ConfigSelection(default = defaultSat.get("pilot", eDVBFrontendParametersSatellite.Pilot_Unknown), choices = [
587 (eDVBFrontendParametersSatellite.Pilot_Off, _("off")),
588 (eDVBFrontendParametersSatellite.Pilot_On, _("on")),
589 (eDVBFrontendParametersSatellite.Pilot_Unknown, _("Auto"))])
592 self.scan_cab.frequency = ConfigInteger(default = defaultCab["frequency"], limits = (50, 999))
593 self.scan_cab.inversion = ConfigSelection(default = defaultCab["inversion"], choices = [
594 (eDVBFrontendParametersCable.Inversion_Off, _("off")),
595 (eDVBFrontendParametersCable.Inversion_On, _("on")),
596 (eDVBFrontendParametersCable.Inversion_Unknown, _("Auto"))])
597 self.scan_cab.modulation = ConfigSelection(default = defaultCab["modulation"], choices = [
598 (eDVBFrontendParametersCable.Modulation_QAM16, "16-QAM"),
599 (eDVBFrontendParametersCable.Modulation_QAM32, "32-QAM"),
600 (eDVBFrontendParametersCable.Modulation_QAM64, "64-QAM"),
601 (eDVBFrontendParametersCable.Modulation_QAM128, "128-QAM"),
602 (eDVBFrontendParametersCable.Modulation_QAM256, "256-QAM")])
603 self.scan_cab.fec = ConfigSelection(default = defaultCab["fec"], choices = [
604 (eDVBFrontendParametersCable.FEC_Auto, _("Auto")),
605 (eDVBFrontendParametersCable.FEC_1_2, "1/2"),
606 (eDVBFrontendParametersCable.FEC_2_3, "2/3"),
607 (eDVBFrontendParametersCable.FEC_3_4, "3/4"),
608 (eDVBFrontendParametersCable.FEC_5_6, "5/6"),
609 (eDVBFrontendParametersCable.FEC_7_8, "7/8"),
610 (eDVBFrontendParametersCable.FEC_8_9, "8/9"),
611 (eDVBFrontendParametersCable.FEC_None, _("None"))])
612 self.scan_cab.symbolrate = ConfigInteger(default = defaultCab["symbolrate"], limits = (1, 99999))
615 self.scan_ter.frequency = ConfigInteger(default = 466000, limits = (50000, 999000))
616 self.scan_ter.inversion = ConfigSelection(default = defaultTer["inversion"], choices = [
617 (eDVBFrontendParametersTerrestrial.Inversion_Off, _("off")),
618 (eDVBFrontendParametersTerrestrial.Inversion_On, _("on")),
619 (eDVBFrontendParametersTerrestrial.Inversion_Unknown, _("Auto"))])
620 # WORKAROUND: we can't use BW-auto
621 self.scan_ter.bandwidth = ConfigSelection(default = defaultTer["bandwidth"], choices = [
622 (eDVBFrontendParametersTerrestrial.Bandwidth_8MHz, "8MHz"),
623 (eDVBFrontendParametersTerrestrial.Bandwidth_7MHz, "7MHz"),
624 (eDVBFrontendParametersTerrestrial.Bandwidth_6MHz, "6MHz")])
625 #, (eDVBFrontendParametersTerrestrial.Bandwidth_Auto, _("Auto"))))
626 self.scan_ter.fechigh = ConfigSelection(default = defaultTer["fechigh"], choices = [
627 (eDVBFrontendParametersTerrestrial.FEC_1_2, "1/2"),
628 (eDVBFrontendParametersTerrestrial.FEC_2_3, "2/3"),
629 (eDVBFrontendParametersTerrestrial.FEC_3_4, "3/4"),
630 (eDVBFrontendParametersTerrestrial.FEC_5_6, "5/6"),
631 (eDVBFrontendParametersTerrestrial.FEC_7_8, "7/8"),
632 (eDVBFrontendParametersTerrestrial.FEC_Auto, _("Auto"))])
633 self.scan_ter.feclow = ConfigSelection(default = defaultTer["feclow"], choices = [
634 (eDVBFrontendParametersTerrestrial.FEC_1_2, "1/2"),
635 (eDVBFrontendParametersTerrestrial.FEC_2_3, "2/3"),
636 (eDVBFrontendParametersTerrestrial.FEC_3_4, "3/4"),
637 (eDVBFrontendParametersTerrestrial.FEC_5_6, "5/6"),
638 (eDVBFrontendParametersTerrestrial.FEC_7_8, "7/8"),
639 (eDVBFrontendParametersTerrestrial.FEC_Auto, _("Auto"))])
640 self.scan_ter.modulation = ConfigSelection(default = defaultTer["modulation"], choices = [
641 (eDVBFrontendParametersTerrestrial.Modulation_QPSK, "QPSK"),
642 (eDVBFrontendParametersTerrestrial.Modulation_QAM16, "QAM16"),
643 (eDVBFrontendParametersTerrestrial.Modulation_QAM64, "QAM64"),
644 (eDVBFrontendParametersTerrestrial.Modulation_Auto, _("Auto"))])
645 self.scan_ter.transmission = ConfigSelection(default = defaultTer["transmission_mode"], choices = [
646 (eDVBFrontendParametersTerrestrial.TransmissionMode_2k, "2K"),
647 (eDVBFrontendParametersTerrestrial.TransmissionMode_8k, "8K"),
648 (eDVBFrontendParametersTerrestrial.TransmissionMode_Auto, _("Auto"))])
649 self.scan_ter.guard = ConfigSelection(default = defaultTer["guard_interval"], choices = [
650 (eDVBFrontendParametersTerrestrial.GuardInterval_1_32, "1/32"),
651 (eDVBFrontendParametersTerrestrial.GuardInterval_1_16, "1/16"),
652 (eDVBFrontendParametersTerrestrial.GuardInterval_1_8, "1/8"),
653 (eDVBFrontendParametersTerrestrial.GuardInterval_1_4, "1/4"),
654 (eDVBFrontendParametersTerrestrial.GuardInterval_Auto, _("Auto"))])
655 self.scan_ter.hierarchy = ConfigSelection(default = defaultTer["hierarchy"], choices = [
656 (eDVBFrontendParametersTerrestrial.Hierarchy_None, _("None")),
657 (eDVBFrontendParametersTerrestrial.Hierarchy_1, "1"),
658 (eDVBFrontendParametersTerrestrial.Hierarchy_2, "2"),
659 (eDVBFrontendParametersTerrestrial.Hierarchy_4, "4"),
660 (eDVBFrontendParametersTerrestrial.Hierarchy_Auto, _("Auto"))])
662 self.scan_scansat = {}
663 for sat in nimmanager.satList:
665 self.scan_scansat[sat[0]] = ConfigYesNo(default = False)
667 self.scan_satselection = []
668 for slot in nimmanager.nim_slots:
669 if slot.isCompatible("DVB-S"):
670 self.scan_satselection.append(getConfigSatlist(defaultSat["orbpos"], self.satList[slot.slot]))
672 self.scan_satselection.append(None)
677 ConfigListScreen.keyLeft(self)
681 ConfigListScreen.keyRight(self)
684 def updateStatus(self):
687 def addSatTransponder(self, tlist, frequency, symbol_rate, polarisation, fec, inversion, orbital_position, system, modulation, rolloff, pilot):
688 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)
689 print "orbpos: " + str(orbital_position)
690 parm = eDVBFrontendParametersSatellite()
691 parm.modulation = modulation
693 parm.frequency = frequency * 1000
694 parm.symbol_rate = symbol_rate * 1000
695 parm.polarisation = polarisation
697 parm.inversion = inversion
698 parm.orbital_position = orbital_position
699 parm.rolloff = rolloff
703 def addCabTransponder(self, tlist, frequency, symbol_rate, modulation, fec, inversion):
704 print "Add Cab: frequ: " + str(frequency) + " symbol: " + str(symbol_rate) + " pol: " + str(modulation) + " fec: " + str(fec) + " inversion: " + str(inversion)
705 parm = eDVBFrontendParametersCable()
706 parm.frequency = frequency * 1000
707 parm.symbol_rate = symbol_rate * 1000
708 parm.modulation = modulation
710 parm.inversion = inversion
713 def addTerTransponder(self, tlist, *args, **kwargs):
714 tlist.append(buildTerTransponder(*args, **kwargs))
717 if self.scan_nims.value == "":
723 index_to_scan = int(self.scan_nims.value)
725 if self.scan_nims == [ ]:
726 self.session.open(MessageBox, _("No tuner is enabled!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
729 nim = nimmanager.nim_slots[index_to_scan]
730 print "nim", nim.slot
731 if nim.isCompatible("DVB-S"):
732 print "is compatible with DVB-S"
733 if self.scan_type.value == "single_transponder":
734 # these lists are generated for each tuner, so this has work.
735 assert len(self.satList) > index_to_scan
736 assert len(self.scan_satselection) > index_to_scan
738 nimsats = self.satList[index_to_scan]
739 selsatidx = self.scan_satselection[index_to_scan].index
741 # however, the satList itself could be empty. in that case, "index" is 0 (for "None").
743 orbpos = nimsats[selsatidx][0]
744 if self.scan_sat.system.value == eDVBFrontendParametersSatellite.System_DVB_S:
745 fec = self.scan_sat.fec.value
747 fec = self.scan_sat.fec_s2.value
748 print "add sat transponder"
749 self.addSatTransponder(tlist, self.scan_sat.frequency.value,
750 self.scan_sat.symbolrate.value,
751 self.scan_sat.polarization.value,
753 self.scan_sat.inversion.value,
755 self.scan_sat.system.value,
756 self.scan_sat.modulation.value,
757 self.scan_sat.rolloff.value,
758 self.scan_sat.pilot.value)
760 elif self.scan_type.value == "single_satellite":
761 sat = self.satList[index_to_scan][self.scan_satselection[index_to_scan].index]
762 getInitialTransponderList(tlist, sat[0])
763 elif self.scan_type.value.find("multisat") != -1:
764 SatList = nimmanager.getSatListForNim(index_to_scan)
765 for x in self.multiscanlist:
767 print " " + str(x[0])
768 getInitialTransponderList(tlist, x[0])
770 elif nim.isCompatible("DVB-C"):
771 if self.scan_typecable.value == "single_transponder":
772 self.addCabTransponder(tlist, self.scan_cab.frequency.value,
773 self.scan_cab.symbolrate.value,
774 self.scan_cab.modulation.value,
775 self.scan_cab.fec.value,
776 self.scan_cab.inversion.value)
778 elif self.scan_typecable.value == "complete":
779 if config.Nims[index_to_scan].cable.scan_type.value == "provider":
780 getInitialCableTransponderList(tlist, index_to_scan)
784 elif nim.isCompatible("DVB-T"):
785 if self.scan_typeterrestrial.value == "single_transponder":
786 self.addTerTransponder(tlist,
787 self.scan_ter.frequency.value * 1000,
788 inversion = self.scan_ter.inversion.value,
789 bandwidth = self.scan_ter.bandwidth.value,
790 fechigh = self.scan_ter.fechigh.value,
791 feclow = self.scan_ter.feclow.value,
792 modulation = self.scan_ter.modulation.value,
793 transmission = self.scan_ter.transmission.value,
794 guard = self.scan_ter.guard.value,
795 hierarchy = self.scan_ter.hierarchy.value)
797 elif self.scan_typeterrestrial.value == "complete":
798 getInitialTerrestrialTransponderList(tlist, nimmanager.getTerrestrialDescription(index_to_scan))
800 flags = self.scan_networkScan.value and eComponentScan.scanNetworkSearch or 0
802 tmp = self.scan_clearallservices.value
804 flags |= eComponentScan.scanRemoveServices
805 elif tmp == "yes_hold_feeds":
806 flags |= eComponentScan.scanRemoveServices
807 flags |= eComponentScan.scanDontRemoveFeeds
809 if tmp != "no" and not removeAll:
810 flags |= eComponentScan.scanDontRemoveUnscanned
812 if self.scan_onlyfree.value:
813 flags |= eComponentScan.scanOnlyFree
815 for x in self["config"].list:
819 self.startScan(tlist, flags, index_to_scan)
822 self.feid = index_to_scan
824 self.startCableTransponderSearch(self.feid)
826 def setCableTransponderSearchResult(self, tlist):
829 def cableTransponderSearchFinished(self):
830 self.startScan(self.tlist, self.flags, self.feid)
832 def startScan(self, tlist, flags, feid):
834 # flags |= eComponentScan.scanSearchBAT
836 self.session.openWithCallback(self.finished_cb, ServiceScan, [{"transponders": tlist, "feid": feid, "flags": flags}])
838 self.session.open(ServiceScan, [{"transponders": tlist, "feid": feid, "flags": flags}])
841 self.session.openWithCallback(self.finished_cb, MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
843 self.session.open(MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
846 for x in self["config"].list:
850 class ScanSimple(ConfigListScreen, Screen, CableTransponderSearchSupport):
851 def getNetworksForNim(self, nim):
852 if nim.isCompatible("DVB-S"):
853 networks = nimmanager.getSatListForNim(nim.slot)
855 networks = [ nim.type ] # "DVB-C" or "DVB-T". TODO: seperate networks for different C/T tuners, if we want to support that.
857 # empty tuners provide no networks.
861 def __init__(self, session):
862 Screen.__init__(self, session)
864 self["actions"] = ActionMap(["SetupActions"],
867 "cancel": self.keyCancel,
875 self.finished_cb = None
877 for nim in nimmanager.nim_slots:
878 # collect networks provided by this tuner
881 networks = self.getNetworksForNim(nim)
883 print "nim %d provides" % nim.slot, networks
884 print "known:", known_networks
886 # we only need to scan on the first tuner which provides a network.
887 # this gives the first tuner for each network priority for scanning.
889 if x not in known_networks:
891 print x, "not in ", known_networks
892 known_networks.append(x)
894 # don't offer to scan nims if nothing is connected
895 if not nimmanager.somethingConnected(nim.slot):
899 nims_to_scan.append(nim)
901 # we save the config elements to use them on keyGo
902 self.nim_enable = [ ]
904 if len(nims_to_scan):
905 self.scan_clearallservices = ConfigSelection(default = "yes", choices = [("no", _("no")), ("yes", _("yes")), ("yes_hold_feeds", _("yes (keep feeds)"))])
906 self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
908 for nim in nims_to_scan:
909 nimconfig = ConfigYesNo(default = True)
910 nimconfig.nim_index = nim.slot
911 self.nim_enable.append(nimconfig)
912 self.list.append(getConfigListEntry(_("Scan ") + nim.slot_name + " (" + nim.friendly_type + ")", nimconfig))
914 ConfigListScreen.__init__(self, self.list)
915 self["header"] = Label(_("Automatic Scan"))
916 self["footer"] = Label(_("Press OK to scan"))
918 def runAsync(self, finished_cb):
919 self.finished_cb = finished_cb
924 self.known_networks = set()
926 self.buildTransponderList()
928 def buildTransponderList(self): # this method is called multiple times because of asynchronous stuff
930 SEARCH_CABLE_TRANSPONDERS = 1
933 n = self.nim_iter < len(self.nim_enable) and self.nim_enable[self.nim_iter] or None
936 if n.value: # check if nim is enabled
938 nim = nimmanager.nim_slots[n.nim_index]
939 networks = set(self.getNetworksForNim(nim))
941 # don't scan anything twice
942 networks.discard(self.known_networks)
945 if nim.isCompatible("DVB-S"):
946 # get initial transponders for each satellite to be scanned
948 getInitialTransponderList(tlist, sat[0])
949 elif nim.isCompatible("DVB-C"):
950 if config.Nims[nim.slot].cable.scan_type.value == "provider":
951 getInitialCableTransponderList(tlist, nim.slot)
953 action = SEARCH_CABLE_TRANSPONDERS
954 elif nim.isCompatible("DVB-T"):
955 getInitialTerrestrialTransponderList(tlist, nimmanager.getTerrestrialDescription(nim.slot))
959 flags |= eComponentScan.scanNetworkSearch #FIXMEEE.. use flags from cables / satellites / terrestrial.xml
960 tmp = self.scan_clearallservices.value
962 flags |= eComponentScan.scanRemoveServices
963 elif tmp == "yes_hold_feeds":
964 flags |= eComponentScan.scanRemoveServices
965 flags |= eComponentScan.scanDontRemoveFeeds
967 if action == APPEND_NOW:
968 self.scanList.append({"transponders": tlist, "feid": nim.slot, "flags": flags})
969 elif action == SEARCH_CABLE_TRANSPONDERS:
972 self.startCableTransponderSearch(nim.slot)
977 self.buildTransponderList() # recursive call of this function !!!
979 # when we are here, then the recursion is finished and all enabled nims are checked
980 # so we now start the real transponder scan
981 self.startScan(self.scanList)
983 def startScan(self, scanList):
986 self.session.openWithCallback(self.finished_cb, ServiceScan, scanList = scanList)
988 self.session.open(ServiceScan, scanList = scanList)
991 self.session.openWithCallback(self.finished_cb, MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
993 self.session.open(MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
995 def setCableTransponderSearchResult(self, tlist):
996 self.scanList.append({"transponders": tlist, "feid": self.feid, "flags": self.flags})
998 def cableTransponderSearchFinished(self):
999 self.buildTransponderList()
1001 def keyCancel(self):
1004 def Satexists(self, tlist, pos):