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,
21 # print "freq", frequency, "inv", inversion, "bw", bandwidth, "fech", fechigh, "fecl", feclow, "mod", modulation, "tm", transmission, "guard", guard, "hierarchy", hierarchy
23 # WARNING: normally, enums are working directly.
24 # Don't copy this (very bad)!! Instead either fix swig (good) or
25 # move this into a central place.
29 #Bw5MHz = 3 #not implemented for e1 compatibilty
41 #TM4k = 2 #not implemented for e1 compatibilty
65 parm = eDVBFrontendParametersTerrestrial()
67 parm.frequency = frequency
69 parm.inversion = [Off, On, Unknown][inversion]
70 parm.bandwidth = [Bw8MHz, Bw7MHz, Bw6MHz, BwAuto][bandwidth] # Bw5MHz unsupported
71 parm.code_rate_HP = [f1_2, f2_3, f3_4, f5_6, f7_8, fAuto][fechigh]
72 parm.code_rate_LP = [f1_2, f2_3, f3_4, f5_6, f7_8, fAuto][feclow]
73 parm.modulation = [QPSK, QAM16, QAM64, Auto][modulation]
74 parm.transmission_mode = [TM2k, TM8k, TMAuto][transmission] # TM4k unsupported
75 parm.guard_interval = [GI_1_32, GI_1_16, GI_1_8, GI_1_4, GI_Auto][guard]
76 parm.hierarchy = [HNone, H1, H2, H4, HAuto][hierarchy]
80 def getInitialTransponderList(tlist, pos):
81 list = nimmanager.getTransponders(pos)
84 parm = eDVBFrontendParametersSatellite()
86 parm.symbol_rate = x[2]
87 parm.polarisation = x[3]
90 parm.orbital_position = pos
92 parm.modulation = x[6]
97 def getInitialCableTransponderList(tlist, nim):
98 list = nimmanager.getTranspondersCable(nim)
101 parm = eDVBFrontendParametersCable()
102 parm.frequency = x[1]
103 parm.symbol_rate = x[2]
104 parm.modulation = x[3]
105 parm.fec_inner = x[4]
106 parm.inversion = 2 # AUTO
107 #print "frequency:", x[1]
108 #print "symbol_rate:", x[2]
109 #print "modulation:", x[3]
110 #print "fec_inner:", x[4]
111 #print "inversion:", 2
114 def getInitialTerrestrialTransponderList(tlist, region):
115 list = nimmanager.getTranspondersTerrestrial(region)
117 #self.transponders[self.parsedTer].append((2,freq,bw,const,crh,crl,guard,transm,hierarchy,inv))
119 #def buildTerTransponder(frequency, inversion = 2, bandwidth = 3, fechigh = 6, feclow = 6,
120 #modulation = 2, transmission = 2, guard = 4, hierarchy = 4):
123 if x[0] == 2: #TERRESTRIAL
124 parm = buildTerTransponder(x[1], x[9], x[2], x[4], x[5], x[3], x[7], x[6], x[8])
128 "DVBC_BAND_EU_VHF_I" : 1 << 0,
129 "DVBC_BAND_EU_MID" : 1 << 1,
130 "DVBC_BAND_EU_VHF_III" : 1 << 2,
131 "DVBC_BAND_EU_SUPER" : 1 << 3,
132 "DVBC_BAND_EU_HYPER" : 1 << 4,
133 "DVBC_BAND_EU_UHF_IV" : 1 << 5,
134 "DVBC_BAND_EU_UHF_V" : 1 << 6,
135 "DVBC_BAND_US_LO" : 1 << 7,
136 "DVBC_BAND_US_MID" : 1 << 8,
137 "DVBC_BAND_US_HI" : 1 << 9,
138 "DVBC_BAND_US_SUPER" : 1 << 10,
139 "DVBC_BAND_US_HYPER" : 1 << 11,
142 class CableTransponderSearchSupport:
143 # def setCableTransponderSearchResult(self, tlist):
146 # def cableTransponderSearchFinished(self):
149 def tryGetRawFrontend(self, feid):
150 res_mgr = eDVBResourceManager.getInstance()
152 raw_channel = res_mgr.allocateRawChannel(self.feid)
154 frontend = raw_channel.getFrontend()
161 def cableTransponderSearchSessionClosed(self, *val):
162 print "cableTransponderSearchSessionClosed, val", val
163 self.cable_search_container.appClosed.remove(self.cableTransponderSearchClosed)
164 self.cable_search_container.dataAvail.remove(self.getCableTransponderData)
165 self.cable_search_container = None
166 self.cable_search_session = None
167 if val and len(val) and val[0]:
168 self.setCableTransponderSearchResult(self.__tlist)
170 self.cableTransponderSearchFinished()
172 def cableTransponderSearchClosed(self, retval):
173 print "cableTransponderSearch finished", retval
174 self.cable_search_session.close(True)
176 def getCableTransponderData(self, str):
181 qam = { "QAM16" : 1, "QAM32" : 2, "QAM64" : 3, "QAM128" : 4, "QAM256" : 5 }
182 inv = { "INVERSION_OFF" : 0, "INVERSION_ON" : 1 }
183 fec = { "FEC_AUTO" : 0, "FEC_1_2" : 1, "FEC_2_3" : 2, "FEC_3_4" : 3, "FEC_5_6": 4, "FEC_7_8" : 5, "FEC_8_9" : 6, "FEC_NONE" : 15 }
184 parm = eDVBFrontendParametersCable()
185 parm.frequency = int(data[1])
186 parm.symbol_rate = int(data[2])
187 parm.fec_inner = fec[data[3]]
188 parm.modulation = qam[data[4]]
189 parm.inversion = inv[data[5]]
190 self.__tlist.append(parm)
191 tmpstr = _("Try to find used Transponders in cable network.. please wait...")
196 self.cable_search_session["text"].setText(tmpstr)
198 def startCableTransponderSearch(self, nim_idx):
199 if not self.tryGetRawFrontend(nim_idx):
200 self.session.nav.stopService()
201 if not self.tryGetRawFrontend(nim_idx):
202 if self.session.pipshown: # try to disable pip
203 self.session.pipshown = False
205 if not self.tryGetRawFrontend(nim_idx):
206 self.cableTransponderSearchFinished()
209 self.cable_search_container = eConsoleAppContainer()
210 self.cable_search_container.appClosed.append(self.cableTransponderSearchClosed)
211 self.cable_search_container.dataAvail.append(self.getCableTransponderData)
212 cableConfig = config.Nims[nim_idx].cable
213 cmd = "tda1002x --init --scan --verbose --wakeup --inv 2 --bus "
214 #FIXMEEEEEE hardcoded i2c devices for dm7025 and dm8000
219 cmd += "2" # first nim socket on DM8000 use /dev/i2c/2
221 cmd += "4" # second nim socket on DM8000 use /dev/i2c/4
222 if cableConfig.scan_type.value == "bands":
223 cmd += " --scan-bands "
225 if cableConfig.scan_band_EU_VHF_I.value:
226 bands |= cable_bands["DVBC_BAND_EU_VHF_I"]
227 if cableConfig.scan_band_EU_MID.value:
228 bands |= cable_bands["DVBC_BAND_EU_MID"]
229 if cableConfig.scan_band_EU_VHF_III.value:
230 bands |= cable_bands["DVBC_BAND_EU_VHF_III"]
231 if cableConfig.scan_band_EU_UHF_IV.value:
232 bands |= cable_bands["DVBC_BAND_EU_UHF_IV"]
233 if cableConfig.scan_band_EU_UHF_V.value:
234 bands |= cable_bands["DVBC_BAND_EU_UHF_V"]
235 if cableConfig.scan_band_EU_SUPER.value:
236 bands |= cable_bands["DVBC_BAND_EU_SUPER"]
237 if cableConfig.scan_band_EU_HYPER.value:
238 bands |= cable_bands["DVBC_BAND_EU_HYPER"]
239 if cableConfig.scan_band_US_LOW.value:
240 bands |= cable_bands["DVBC_BAND_US_LO"]
241 if cableConfig.scan_band_US_MID.value:
242 bands |= cable_bands["DVBC_BAND_US_MID"]
243 if cableConfig.scan_band_US_HIGH.value:
244 bands |= cable_bands["DVBC_BAND_US_HI"]
245 if cableConfig.scan_band_US_SUPER.value:
246 bands |= cable_bands["DVBC_BAND_US_SUPER"]
247 if cableConfig.scan_band_US_HYPER.value:
248 bands |= cable_bands["DVBC_BAND_US_HYPER"]
251 cmd += " --scan-stepsize "
252 cmd += str(cableConfig.scan_frequency_steps.value)
253 if cableConfig.scan_mod_qam16.value:
255 if cableConfig.scan_mod_qam32.value:
257 if cableConfig.scan_mod_qam64.value:
259 if cableConfig.scan_mod_qam128.value:
261 if cableConfig.scan_mod_qam256.value:
263 if cableConfig.scan_sr_6900.value:
264 cmd += " --sr 6900000"
265 if cableConfig.scan_sr_6875.value:
266 cmd += " --sr 6875000"
267 if cableConfig.scan_sr_ext1.value > 450:
269 cmd += str(cableConfig.scan_sr_ext1.value)
271 if cableConfig.scan_sr_ext2.value > 450:
273 cmd += str(cableConfig.scan_sr_ext2.value)
275 print "TDA1002x CMD is", cmd
277 self.cable_search_container.execute(cmd)
278 tmpstr = _("Try to find used transponders in cable network.. please wait...")
280 self.cable_search_session = self.session.openWithCallback(self.cableTransponderSearchSessionClosed, MessageBox, tmpstr, MessageBox.TYPE_INFO)
282 class DefaultSatLists(DefaultWizard):
283 def __init__(self, session, silent = True, showSteps = False):
284 self.xmlfile = "defaultsatlists.xml"
285 DefaultWizard.__init__(self, session, silent, showSteps, neededTag = "services")
286 print "configuredSats:", nimmanager.getConfiguredSats()
288 def setDirectory(self):
290 self.directory.append(resolveFilename(SCOPE_DEFAULTDIR))
292 os.system("mount %s %s" % (resolveFilename(SCOPE_DEFAULTPARTITION), resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR)))
293 self.directory.append(resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR))
295 def statusCallback(self, status, progress):
296 print "statusCallback:", status, progress
297 from Components.DreamInfoHandler import DreamInfoHandler
298 if status == DreamInfoHandler.STATUS_DONE:
299 self["text"].setText(_("The installation of the default services lists is finished.") + "\n\n" + _("Please press OK to continue."))
301 self.disableKeys = False
303 class ScanSetup(ConfigListScreen, Screen, CableTransponderSearchSupport):
304 def __init__(self, session):
305 Screen.__init__(self, session)
307 self.finished_cb = None
309 self.service = session.nav.getCurrentService()
312 if self.service is not None:
313 self.feinfo = self.service.frontendInfo()
314 frontendData = self.feinfo and self.feinfo.getAll(True)
316 self.createConfig(frontendData)
321 self["actions"] = NumberActionMap(["SetupActions"],
324 "cancel": self.keyCancel,
327 self.statusTimer = eTimer()
328 self.statusTimer.callback.append(self.updateStatus)
329 #self.statusTimer.start(5000, True)
332 ConfigListScreen.__init__(self, self.list)
335 self["introduction"] = Label(_("Press OK to start the scan"))
337 def runAsync(self, finished_cb):
338 self.finished_cb = finished_cb
341 def updateSatList(self):
343 for slot in nimmanager.nim_slots:
344 if slot.isCompatible("DVB-S"):
345 self.satList.append(nimmanager.getSatListForNim(slot.slot))
347 self.satList.append(None)
349 def createSetup(self):
351 self.multiscanlist = []
352 index_to_scan = int(self.scan_nims.value)
353 print "ID: ", index_to_scan
355 self.tunerEntry = getConfigListEntry(_("Tuner"), self.scan_nims)
356 self.list.append(self.tunerEntry)
358 if self.scan_nims == [ ]:
361 self.typeOfScanEntry = None
362 self.systemEntry = None
363 self.modulationEntry = None
364 nim = nimmanager.nim_slots[index_to_scan]
365 if nim.isCompatible("DVB-S"):
366 self.typeOfScanEntry = getConfigListEntry(_("Type of scan"), self.scan_type)
367 self.list.append(self.typeOfScanEntry)
368 elif nim.isCompatible("DVB-C"):
369 self.typeOfScanEntry = getConfigListEntry(_("Type of scan"), self.scan_typecable)
370 self.list.append(self.typeOfScanEntry)
371 elif nim.isCompatible("DVB-T"):
372 self.typeOfScanEntry = getConfigListEntry(_("Type of scan"), self.scan_typeterrestrial)
373 self.list.append(self.typeOfScanEntry)
375 self.scan_networkScan.value = False
376 if nim.isCompatible("DVB-S"):
377 if self.scan_type.value == "single_transponder":
379 if nim.isCompatible("DVB-S2"):
380 self.systemEntry = getConfigListEntry(_('System'), self.scan_sat.system)
381 self.list.append(self.systemEntry)
383 # downgrade to dvb-s, in case a -s2 config was active
384 self.scan_sat.system.value = "dvb-s"
385 self.list.append(getConfigListEntry(_('Satellite'), self.scan_satselection[index_to_scan]))
386 self.list.append(getConfigListEntry(_('Frequency'), self.scan_sat.frequency))
387 self.list.append(getConfigListEntry(_('Inversion'), self.scan_sat.inversion))
388 self.list.append(getConfigListEntry(_('Symbol Rate'), self.scan_sat.symbolrate))
389 self.list.append(getConfigListEntry(_("Polarity"), self.scan_sat.polarization))
390 if self.scan_sat.system.value == "dvb-s":
391 self.list.append(getConfigListEntry(_("FEC"), self.scan_sat.fec))
392 elif self.scan_sat.system.value == "dvb-s2":
393 self.list.append(getConfigListEntry(_("FEC"), self.scan_sat.fec_s2))
394 self.modulationEntry = getConfigListEntry(_('Modulation'), self.scan_sat.modulation)
395 self.list.append(self.modulationEntry)
396 self.list.append(getConfigListEntry(_('Rolloff'), self.scan_sat.rolloff))
397 self.list.append(getConfigListEntry(_('Pilot'), self.scan_sat.pilot))
398 elif self.scan_type.value == "single_satellite":
400 print self.scan_satselection[index_to_scan]
401 self.list.append(getConfigListEntry(_("Satellite"), self.scan_satselection[index_to_scan]))
402 self.scan_networkScan.value = True
403 elif self.scan_type.value.find("multisat") != -1:
405 SatList = nimmanager.getSatListForNim(index_to_scan)
407 if self.Satexists(tlist, x[0]) == 0:
409 sat = ConfigEnableDisable(default = self.scan_type.value.find("_yes") != -1 and True or False)
410 configEntry = getConfigListEntry(nimmanager.getSatDescription(x[0]), sat)
411 self.list.append(configEntry)
412 self.multiscanlist.append((x[0], sat))
413 self.scan_networkScan.value = True
414 elif nim.isCompatible("DVB-C"):
415 if self.scan_typecable.value == "single_transponder":
416 self.list.append(getConfigListEntry(_("Frequency"), self.scan_cab.frequency))
417 self.list.append(getConfigListEntry(_("Inversion"), self.scan_cab.inversion))
418 self.list.append(getConfigListEntry(_("Symbol Rate"), self.scan_cab.symbolrate))
419 self.list.append(getConfigListEntry(_("Modulation"), self.scan_cab.modulation))
420 self.list.append(getConfigListEntry(_("FEC"), self.scan_cab.fec))
421 elif nim.isCompatible("DVB-T"):
422 if self.scan_typeterrestrial.value == "single_transponder":
423 self.list.append(getConfigListEntry(_("Frequency"), self.scan_ter.frequency))
424 self.list.append(getConfigListEntry(_("Inversion"), self.scan_ter.inversion))
425 self.list.append(getConfigListEntry(_("Bandwidth"), self.scan_ter.bandwidth))
426 self.list.append(getConfigListEntry(_("Code rate high"), self.scan_ter.fechigh))
427 self.list.append(getConfigListEntry(_("Code rate low"), self.scan_ter.feclow))
428 self.list.append(getConfigListEntry(_("Modulation"), self.scan_ter.modulation))
429 self.list.append(getConfigListEntry(_("Transmission mode"), self.scan_ter.transmission))
430 self.list.append(getConfigListEntry(_("Guard interval mode"), self.scan_ter.guard))
431 self.list.append(getConfigListEntry(_("Hierarchy mode"), self.scan_ter.hierarchy))
432 self.list.append(getConfigListEntry(_("Network scan"), self.scan_networkScan))
433 self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
434 self.list.append(getConfigListEntry(_("Only Free scan"), self.scan_onlyfree))
435 self["config"].list = self.list
436 self["config"].l.setList(self.list)
438 def Satexists(self, tlist, pos):
445 cur = self["config"].getCurrent()
447 if cur == self.typeOfScanEntry or \
448 cur == self.tunerEntry or \
449 cur == self.systemEntry or \
450 (self.modulationEntry and self.systemEntry[1].value == "dvb-s2" and cur == self.modulationEntry):
453 def createConfig(self, frontendData):
454 #("Type", frontendData["system"], TYPE_TEXT),
455 #("Modulation", frontendData["modulation"], TYPE_TEXT),
456 #("Orbital position", frontendData["orbital_position"], TYPE_VALUE_DEC),
457 #("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
458 #("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC),
459 #("Polarization", frontendData["polarization"], TYPE_TEXT),
460 #("Inversion", frontendData["inversion"], TYPE_TEXT),
461 #("FEC inner", frontendData["fec_inner"], TYPE_TEXT),
463 #elif frontendData["tuner_type"] == "DVB-C":
464 #return ( ("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
465 #("Type", frontendData["tuner_type"], TYPE_TEXT),
466 #("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
467 #("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC),
468 #("Modulation", frontendData["modulation"], TYPE_TEXT),
469 #("Inversion", frontendData["inversion"], TYPE_TEXT),
470 # ("FEC inner", frontendData["fec_inner"], TYPE_TEXT),
472 #elif frontendData["tuner_type"] == "DVB-T":
473 #return ( ("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
474 #("Type", frontendData["tuner_type"], TYPE_TEXT),
475 #("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
476 #("Inversion", frontendData["inversion"], TYPE_TEXT),
477 #("Bandwidth", frontendData["bandwidth"], TYPE_VALUE_DEC),
478 #("CodeRateLP", frontendData["code_rate_lp"], TYPE_TEXT),
479 #("CodeRateHP", frontendData["code_rate_hp"], TYPE_TEXT),
480 #("Constellation", frontendData["constellation"], TYPE_TEXT),
481 #("Transmission Mode", frontendData["transmission_mode"], TYPE_TEXT),
482 #("Guard Interval", frontendData["guard_interval"], TYPE_TEXT),
483 #("Hierarchy Inform.", frontendData["hierarchy_information"], TYPE_TEXT),
484 defaultSat = { "orbpos": 192, "system": "dvb-s", "frequency": 11836, "inversion": "auto", "symbolrate": 27500, "polarization": "horizontal", "fec": "auto", "fec_s2": "9_10", "modulation": "qpsk" }
485 defaultCab = {"frequency": 466, "inversion": "auto", "modulation": "64qam", "fec": "auto", "symbolrate": 6900}
486 if frontendData is not None:
487 ttype = frontendData.get("tuner_type", "UNKNOWN")
489 defaultSat["system"] = {"DVB-S": "dvb-s", "DVB-S2": "dvb-s2"}[frontendData.get("system", "DVB-S")]
490 defaultSat["frequency"] = frontendData.get("frequency", 0) / 1000
491 defaultSat["inversion"] = {"INVERSION_OFF": "off", "INVERSION_ON": "on", "INVERSION_AUTO": "auto"}[frontendData.get("inversion", "INVERSION_AUTO")]
492 defaultSat["symbolrate"] = frontendData.get("symbol_rate", 0) / 1000
493 defaultSat["polarization"] = {"HORIZONTAL": "horizontal", "VERTICAL": "vertical", "CIRCULAR_LEFT": "circular_left", "CIRCULAR_RIGHT": "circular_right", "UNKNOWN": None}[frontendData.get("polarization", "HORIZONTAL")]
495 if frontendData.get("system", "DVB-S") == "DVB-S2":
496 defaultSat["fec_s2"] = {"FEC_1_2": "1_2", "FEC_2_3": "2_3", "FEC_3_4": "3_4", "FEC_4_5": "4_5", "FEC_5_6": "5_6", "FEC_7_8": "7_8", "FEC_8_9": "8_9", "FEC_9_10": "9_10"} \
497 [frontendData.get("fec_inner", "FEC_AUTO")]
498 defaultSat["rolloff"] = {"ROLLOFF_0_35" : "0_35", "ROLLOFF_0_25" : "0_25", "ROLLOFF_0_20" : "0_20"}[frontendData.get("rolloff", "ROLLOFF_0_35")]
499 defaultSat["pilot"] = {"PILOT_ON" : "on", "PILOT_OFF" : "off", "PILOT_AUTO" : "auto"}[frontendData.get("pilot", "PILOT_AUTO")]
501 defaultSat["fec"] = {"FEC_AUTO": "auto", "FEC_1_2": "1_2", "FEC_2_3": "2_3", "FEC_3_4": "3_4", "FEC_5_6": "5_6", "FEC_7_8": "7_8", "FEC_NONE": "none"} \
502 [frontendData.get("fec_inner", "FEC_AUTO")]
504 defaultSat["modulation"] = {"QPSK": "qpsk", "8PSK": "8psk"}[frontendData.get("modulation", "QPSK")]
505 defaultSat["orbpos"] = frontendData.get("orbital_position", 0)
506 elif ttype == "DVB-C":
507 defaultCab["frequency"] = frontendData.get("frequency", 0) / 1000
508 defaultCab["symbolrate"] = frontendData.get("symbol_rate", 0) / 1000
509 defaultCab["inversion"] = {"INVERSION_OFF": "off", "INVERSION_ON": "on", "INVERSION_AUTO": "auto"}[frontendData.get("inversion", "INVERSION_AUTO")]
510 defaultCab["fec"] = {"FEC_AUTO": "auto", "FEC_1_2": "1_2", "FEC_2_3": "2_3", "FEC_3_4": "3_4", "FEC_5_6": "5_6", "FEC_7_8": "7_8", "FEC_8_9": "8_9", "FEC_NONE": "none"}[frontendData.get("fec_inner", "FEC_AUTO")]
511 defaultCab["modulation"] = {"QAM_AUTO": "auto", "QAM_16": "16qam", "QAM_32": "32qam", "QAM_64": "64qam", "QAM_128": "128qam", "QAM_256": "256qam"}[frontendData.get("modulation", "QAM_16")]
513 self.scan_sat = ConfigSubsection()
514 self.scan_cab = ConfigSubsection()
515 self.scan_ter = ConfigSubsection()
517 self.scan_type = ConfigSelection(default = "single_transponder", choices = [("single_transponder", _("Single transponder")), ("single_satellite", _("Single satellite")), ("multisat", _("Multisat")), ("multisat_yes", _("Multisat"))])
518 self.scan_typecable = ConfigSelection(default = "single_transponder", choices = [("single_transponder", _("Single transponder")), ("complete", _("Complete"))])
519 self.scan_typeterrestrial = ConfigSelection(default = "single_transponder", choices = [("single_transponder", _("Single transponder")), ("complete", _("Complete"))])
520 self.scan_clearallservices = ConfigSelection(default = "no", choices = [("no", _("no")), ("yes", _("yes")), ("yes_hold_feeds", _("yes (keep feeds)"))])
521 self.scan_onlyfree = ConfigYesNo(default = False)
522 self.scan_networkScan = ConfigYesNo(default = False)
525 # collect all nims which are *not* set to "nothing"
526 for n in nimmanager.nim_slots:
527 if not n.config_mode in ("loopthrough", "satposdepends", "nothing"):
528 nim_list.append((str(n.slot), n.friendly_full_description))
530 self.scan_nims = ConfigSelection(choices = nim_list)
533 self.scan_snr = ConfigSlider()
534 self.scan_snr.enabled = False
535 self.scan_agc = ConfigSlider()
536 self.scan_agc.enabled = False
537 self.scan_ber = ConfigSlider()
538 self.scan_ber.enabled = False
541 self.scan_sat.system = ConfigSelection(default = defaultSat["system"], choices = [("dvb-s", _("DVB-S")), ("dvb-s2", _("DVB-S2"))])
542 self.scan_sat.frequency = ConfigInteger(default = defaultSat["frequency"], limits = (1, 99999))
543 self.scan_sat.inversion = ConfigSelection(default = defaultSat["inversion"], choices = [("off", _("off")), ("on", _("on")), ("auto", _("Auto"))])
544 self.scan_sat.symbolrate = ConfigInteger(default = defaultSat["symbolrate"], limits = (1, 99999))
545 self.scan_sat.polarization = ConfigSelection(default = defaultSat["polarization"], choices = [("horizontal", _("horizontal")), ("vertical", _("vertical")), ("circular_left", _("circular left")), ("circular_right", _("circular right"))])
546 self.scan_sat.fec = ConfigSelection(default = defaultSat["fec"], choices = [("auto", _("Auto")), ("1_2", "1/2"), ("2_3", "2/3"), ("3_4", "3/4"), ("5_6", "5/6"), ("7_8", "7/8"), ("none", _("None"))])
547 self.scan_sat.fec_s2 = ConfigSelection(default = defaultSat["fec_s2"], choices = [("1_2", "1/2"), ("2_3", "2/3"), ("3_4", "3/4"), ("3_5", "3/5"), ("4_5", "4/5"), ("5_6", "5/6"), ("7_8", "7/8"), ("8_9", "8/9"), ("9_10", "9/10")])
548 self.scan_sat.modulation = ConfigSelection(default = defaultSat["modulation"], choices = [("qpsk", "QPSK"), ("8psk", "8PSK")])
549 self.scan_sat.rolloff = ConfigSelection(default = defaultSat.get("rolloff", "0_35"), choices = [("0_35", "0.35"), ("0_25", "0.25"), ("0_20", "0.20")])
550 self.scan_sat.pilot = ConfigSelection(default = defaultSat.get("pilot", "auto"), choices = [("off", _("off")), ("on", _("on")), ("auto", _("Auto"))])
553 self.scan_cab.frequency = ConfigInteger(default = defaultCab["frequency"], limits = (50, 999))
554 self.scan_cab.inversion = ConfigSelection(default = defaultCab["inversion"], choices = [("off", _("off")), ("on", _("on")), ("auto", _("Auto"))])
555 self.scan_cab.modulation = ConfigSelection(default = defaultCab["modulation"], choices = [("16qam", "16-QAM"), ("32qam", "32-QAM"), ("64qam", "64-QAM"), ("128qam", "128-QAM"), ("256qam", "256-QAM")])
556 self.scan_cab.fec = ConfigSelection(default = defaultCab["fec"], choices = [("auto", _("Auto")), ("1_2", "1/2"), ("2_3", "2/3"), ("3_4", "3/4"), ("5_6", "5/6"), ("7_8", "7/8"), ("8_9", "8/9"), ("none", _("None"))])
557 self.scan_cab.symbolrate = ConfigInteger(default = defaultCab["symbolrate"], limits = (1, 99999))
560 self.scan_ter.frequency = ConfigInteger(default = 466000, limits = (50000, 999000))
561 self.scan_ter.inversion = ConfigSelection(default = "auto", choices = [("off", _("off")), ("on", _("on")), ("auto", _("Auto"))])
562 # WORKAROUND: we can't use BW-auto
563 self.scan_ter.bandwidth = ConfigSelection(default = "8MHz", choices = [("8MHz", "8MHz"), ("7MHz", "7MHz"), ("6MHz", "6MHz")])
564 #, ("auto", _("Auto"))))
565 self.scan_ter.fechigh = ConfigSelection(default = "auto", choices = [("1_2", "1/2"), ("2_3", "2/3"), ("3_4", "3/4"), ("5_6", "5/6"), ("7_8", "7/8"), ("auto", _("Auto"))])
566 self.scan_ter.feclow = ConfigSelection(default = "auto", choices = [("1_2", "1/2"), ("2_3", "2/3"), ("3_4", "3/4"), ("5_6", "5/6"), ("7_8", "7/8"), ("auto", _("Auto"))])
567 self.scan_ter.modulation = ConfigSelection(default = "auto", choices = [("qpsk", "QPSK"), ("qam16", "QAM16"), ("qam64", "QAM64"), ("auto", _("Auto"))])
568 self.scan_ter.transmission = ConfigSelection(default = "auto", choices = [("2k", "2K"), ("8k", "8K"), ("auto", _("Auto"))])
569 self.scan_ter.guard = ConfigSelection(default = "auto", choices = [("1_32", "1/32"), ("1_16", "1/16"), ("1_8", "1/8"), ("1_4", "1/4"), ("auto", _("Auto"))])
570 self.scan_ter.hierarchy = ConfigSelection(default = "auto", choices = [("none", _("None")), ("1", "1"), ("2", "2"), ("4", "4"), ("auto", _("Auto"))])
572 self.scan_scansat = {}
573 for sat in nimmanager.satList:
575 self.scan_scansat[sat[0]] = ConfigYesNo(default = False)
577 self.scan_satselection = []
578 for slot in nimmanager.nim_slots:
579 if slot.isCompatible("DVB-S"):
580 self.scan_satselection.append(getConfigSatlist(defaultSat["orbpos"], self.satList[slot.slot]))
582 self.scan_satselection.append(None)
587 ConfigListScreen.keyLeft(self)
591 ConfigListScreen.keyRight(self)
594 def updateStatus(self):
597 fecmap = { "auto": 0,
610 def addSatTransponder(self, tlist, frequency, symbol_rate, polarisation, fec, inversion, orbital_position, system, modulation, rolloff, pilot):
611 print "Add Sat: frequ: " + str(frequency) + " symbol: " + str(symbol_rate) + " pol: " + str(polarisation) + " fec: " + str(self.fecmap[fec]) + " inversion: " + str(inversion) + " modulation: " + str(modulation) + " system: " + str(system) + " rolloff" + str(rolloff) + " pilot" + str(pilot)
612 print "orbpos: " + str(orbital_position)
613 parm = eDVBFrontendParametersSatellite()
615 parm.modulation = 2 # eDVBFrontendParametersSatellite.Modulation.8PSK
617 parm.modulation = 1 # eDVBFrontendParametersSatellite.Modulation.QPSK
619 parm.frequency = frequency * 1000
620 parm.symbol_rate = symbol_rate * 1000
621 parm.polarisation = polarisation
622 parm.fec = self.fecmap[fec]
623 parm.inversion = inversion
624 parm.orbital_position = orbital_position
625 parm.rolloff = rolloff
629 def addCabTransponder(self, tlist, frequency, symbol_rate, modulation, fec, inversion):
630 print "Add Cab: frequ: " + str(frequency) + " symbol: " + str(symbol_rate) + " pol: " + str(modulation) + " fec: " + str(fec) + " inversion: " + str(inversion)
631 parm = eDVBFrontendParametersCable()
632 parm.frequency = frequency * 1000
633 parm.symbol_rate = symbol_rate * 1000
634 parm.modulation = modulation
635 parm.fec = self.fecmap[fec]
636 parm.inversion = inversion
639 def addTerTransponder(self, tlist, *args, **kwargs):
640 tlist.append(buildTerTransponder(*args, **kwargs))
647 index_to_scan = int(self.scan_nims.value)
649 if self.scan_nims == [ ]:
650 self.session.open(MessageBox, _("No tuner is enabled!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
653 nim = nimmanager.nim_slots[index_to_scan]
654 print "nim", nim.slot
655 if nim.isCompatible("DVB-S"):
656 print "is compatible with DVB-S"
657 if self.scan_type.value == "single_transponder":
658 # these lists are generated for each tuner, so this has work.
659 assert len(self.satList) > index_to_scan
660 assert len(self.scan_satselection) > index_to_scan
662 nimsats = self.satList[index_to_scan]
663 selsatidx = self.scan_satselection[index_to_scan].index
665 # however, the satList itself could be empty. in that case, "index" is 0 (for "None").
667 orbpos = nimsats[selsatidx][0]
668 if self.scan_sat.system.value == "dvb-s":
669 fec = self.scan_sat.fec.value
671 fec = self.scan_sat.fec_s2.value
672 print "add sat transponder"
673 self.addSatTransponder(tlist, self.scan_sat.frequency.value,
674 self.scan_sat.symbolrate.value,
675 self.scan_sat.polarization.index,
677 self.scan_sat.inversion.index,
679 self.scan_sat.system.index,
680 self.scan_sat.modulation.index,
681 self.scan_sat.rolloff.index,
682 self.scan_sat.pilot.index)
684 elif self.scan_type.value == "single_satellite":
685 sat = self.satList[index_to_scan][self.scan_satselection[index_to_scan].index]
686 getInitialTransponderList(tlist, sat[0])
687 elif self.scan_type.value.find("multisat") != -1:
688 SatList = nimmanager.getSatListForNim(index_to_scan)
689 for x in self.multiscanlist:
691 print " " + str(x[0])
692 getInitialTransponderList(tlist, x[0])
694 elif nim.isCompatible("DVB-C"):
695 if self.scan_typecable.value == "single_transponder":
696 fec = self.scan_cab.fec.value
697 self.addCabTransponder(tlist, self.scan_cab.frequency.value,
698 self.scan_cab.symbolrate.value,
699 self.scan_cab.modulation.index + 1,
701 self.scan_cab.inversion.index)
703 elif self.scan_typecable.value == "complete":
704 if config.Nims[index_to_scan].cable.scan_type.value == "provider":
705 getInitialCableTransponderList(tlist, index_to_scan)
709 elif nim.isCompatible("DVB-T"):
710 if self.scan_typeterrestrial.value == "single_transponder":
711 self.addTerTransponder(tlist,
712 self.scan_ter.frequency.value * 1000,
713 inversion = self.scan_ter.inversion.index,
714 bandwidth = self.scan_ter.bandwidth.index,
715 fechigh = self.scan_ter.fechigh.index,
716 feclow = self.scan_ter.feclow.index,
717 modulation = self.scan_ter.modulation.index,
718 transmission = self.scan_ter.transmission.index,
719 guard = self.scan_ter.guard.index,
720 hierarchy = self.scan_ter.hierarchy.index)
722 elif self.scan_typeterrestrial.value == "complete":
723 getInitialTerrestrialTransponderList(tlist, nimmanager.getTerrestrialDescription(index_to_scan))
725 flags = self.scan_networkScan.value and eComponentScan.scanNetworkSearch or 0
727 tmp = self.scan_clearallservices.value
729 flags |= eComponentScan.scanRemoveServices
730 elif tmp == "yes_hold_feeds":
731 flags |= eComponentScan.scanRemoveServices
732 flags |= eComponentScan.scanDontRemoveFeeds
734 if tmp != "no" and not removeAll:
735 flags |= eComponentScan.scanDontRemoveUnscanned
737 if self.scan_onlyfree.value:
738 flags |= eComponentScan.scanOnlyFree
740 for x in self["config"].list:
744 self.startScan(tlist, flags, index_to_scan)
747 self.feid = index_to_scan
749 self.startCableTransponderSearch(self.feid)
751 def setCableTransponderSearchResult(self, tlist):
754 def cableTransponderSearchFinished(self):
755 self.startScan(self.tlist, self.flags, self.feid)
757 def startScan(self, tlist, flags, feid):
759 # flags |= eComponentScan.scanSearchBAT
761 self.session.openWithCallback(self.finished_cb, ServiceScan, [{"transponders": tlist, "feid": feid, "flags": flags}])
763 self.session.open(ServiceScan, [{"transponders": tlist, "feid": feid, "flags": flags}])
766 self.session.openWithCallback(self.finished_cb, MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
768 self.session.open(MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
771 for x in self["config"].list:
775 class ScanSimple(ConfigListScreen, Screen, CableTransponderSearchSupport):
776 def getNetworksForNim(self, nim):
777 if nim.isCompatible("DVB-S"):
778 networks = nimmanager.getSatListForNim(nim.slot)
780 networks = [ nim.type ] # "DVB-C" or "DVB-T". TODO: seperate networks for different C/T tuners, if we want to support that.
782 # empty tuners provide no networks.
786 def __init__(self, session):
787 Screen.__init__(self, session)
789 self["actions"] = ActionMap(["SetupActions"],
792 "cancel": self.keyCancel,
800 self.finished_cb = None
802 for nim in nimmanager.nim_slots:
803 # collect networks provided by this tuner
806 networks = self.getNetworksForNim(nim)
808 print "nim %d provides" % nim.slot, networks
809 print "known:", known_networks
811 # we only need to scan on the first tuner which provides a network.
812 # this gives the first tuner for each network priority for scanning.
814 if x not in known_networks:
816 print x, "not in ", known_networks
817 known_networks.append(x)
820 nims_to_scan.append(nim)
822 # we save the config elements to use them on keyGo
823 self.nim_enable = [ ]
825 if len(nims_to_scan):
826 self.scan_clearallservices = ConfigSelection(default = "yes", choices = [("no", _("no")), ("yes", _("yes")), ("yes_hold_feeds", _("yes (keep feeds)"))])
827 self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
829 for nim in nims_to_scan:
830 nimconfig = ConfigYesNo(default = True)
831 nimconfig.nim_index = nim.slot
832 self.nim_enable.append(nimconfig)
833 self.list.append(getConfigListEntry(_("Scan ") + nim.slot_name + " (" + nim.friendly_type + ")", nimconfig))
835 ConfigListScreen.__init__(self, self.list)
836 self["header"] = Label(_("Automatic Scan"))
837 self["footer"] = Label(_("Press OK to scan"))
839 def runAsync(self, finished_cb):
840 self.finished_cb = finished_cb
845 self.known_networks = set()
847 self.buildTransponderList()
849 def buildTransponderList(self): # this method is called multiple times because of asynchronous stuff
851 SEARCH_CABLE_TRANSPONDERS = 1
854 n = self.nim_iter < len(self.nim_enable) and self.nim_enable[self.nim_iter] or None
857 if n.value: # check if nim is enabled
859 nim = nimmanager.nim_slots[n.nim_index]
860 networks = set(self.getNetworksForNim(nim))
862 # don't scan anything twice
863 networks.discard(self.known_networks)
866 if nim.isCompatible("DVB-S"):
867 # get initial transponders for each satellite to be scanned
869 getInitialTransponderList(tlist, sat[0])
870 elif nim.isCompatible("DVB-C"):
871 if config.Nims[nim.slot].cable.scan_type.value == "provider":
872 getInitialCableTransponderList(tlist, nim.slot)
874 action = SEARCH_CABLE_TRANSPONDERS
875 elif nim.isCompatible("DVB-T"):
876 getInitialTerrestrialTransponderList(tlist, nimmanager.getTerrestrialDescription(nim.slot))
880 flags |= eComponentScan.scanNetworkSearch #FIXMEEE.. use flags from cables / satellites / terrestrial.xml
881 tmp = self.scan_clearallservices.value
883 flags |= eComponentScan.scanRemoveServices
884 elif tmp == "yes_hold_feeds":
885 flags |= eComponentScan.scanRemoveServices
886 flags |= eComponentScan.scanDontRemoveFeeds
888 if action == APPEND_NOW:
889 self.scanList.append({"transponders": tlist, "feid": nim.slot, "flags": flags})
890 elif action == SEARCH_CABLE_TRANSPONDERS:
893 self.startCableTransponderSearch(nim.slot)
898 self.buildTransponderList() # recursive call of this function !!!
900 # when we are here, then the recursion is finished and all enabled nims are checked
901 # so we now start the real transponder scan
902 self.startScan(self.scanList)
904 def startScan(self, scanList):
907 self.session.openWithCallback(self.finished_cb, ServiceScan, scanList = scanList)
909 self.session.open(ServiceScan, scanList = scanList)
912 self.session.openWithCallback(self.finished_cb, MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
914 self.session.open(MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
916 def setCableTransponderSearchResult(self, tlist):
917 self.scanList.append({"transponders": tlist, "feid": self.feid, "flags": self.flags})
919 def cableTransponderSearchFinished(self):
920 self.buildTransponderList()
925 def Satexists(self, tlist, pos):