1 from Screen import Screen
2 from ServiceScan import ServiceScan
3 from Components.config import config, ConfigSubsection, ConfigSelection, \
4 ConfigYesNo, ConfigInteger, getConfigListEntry, ConfigSlider, ConfigEnableDisable
5 from Components.ActionMap import NumberActionMap, ActionMap
6 from Components.ConfigList import ConfigListScreen
7 from Components.NimManager import nimmanager, getConfigSatlist
8 from Components.Label import Label
9 from Screens.MessageBox import MessageBox
10 from enigma import eTimer, eDVBFrontendParametersSatellite, eComponentScan, \
11 eDVBSatelliteEquipmentControl, eDVBFrontendParametersTerrestrial, \
12 eDVBFrontendParametersCable, eConsoleAppContainer, eDVBResourceManager
14 def buildTerTransponder(frequency,
15 inversion=2, bandwidth = 3, fechigh = 6, feclow = 6,
16 modulation = 2, transmission = 2, guard = 4,
19 # print "freq", frequency, "inv", inversion, "bw", bandwidth, "fech", fechigh, "fecl", feclow, "mod", modulation, "tm", transmission, "guard", guard, "hierarchy", hierarchy
21 # WARNING: normally, enums are working directly.
22 # Don't copy this (very bad)!! Instead either fix swig (good) or
23 # move this into a central place.
27 #Bw5MHz = 3 #not implemented for e1 compatibilty
39 #TM4k = 2 #not implemented for e1 compatibilty
63 parm = eDVBFrontendParametersTerrestrial()
65 parm.frequency = frequency
67 parm.inversion = [Off, On, Unknown][inversion]
68 parm.bandwidth = [Bw8MHz, Bw7MHz, Bw6MHz, BwAuto][bandwidth] # Bw5MHz unsupported
69 parm.code_rate_HP = [f1_2, f2_3, f3_4, f5_6, f7_8, fAuto][fechigh]
70 parm.code_rate_LP = [f1_2, f2_3, f3_4, f5_6, f7_8, fAuto][feclow]
71 parm.modulation = [QPSK, QAM16, QAM64, Auto][modulation]
72 parm.transmission_mode = [TM2k, TM8k, TMAuto][transmission] # TM4k unsupported
73 parm.guard_interval = [GI_1_32, GI_1_16, GI_1_8, GI_1_4, GI_Auto][guard]
74 parm.hierarchy = [HNone, H1, H2, H4, HAuto][hierarchy]
78 def getInitialTransponderList(tlist, pos):
79 list = nimmanager.getTransponders(pos)
82 parm = eDVBFrontendParametersSatellite()
84 parm.symbol_rate = x[2]
85 parm.polarisation = x[3]
87 parm.inversion = 2 # AUTO
88 parm.orbital_position = pos
90 parm.modulation = x[6]
93 def getInitialCableTransponderList(tlist, nim):
94 list = nimmanager.getTranspondersCable(nim)
97 parm = eDVBFrontendParametersCable()
99 parm.symbol_rate = x[2]
100 parm.modulation = x[3]
101 parm.fec_inner = x[4]
102 parm.inversion = 2 # AUTO
103 #print "frequency:", x[1]
104 #print "symbol_rate:", x[2]
105 #print "modulation:", x[3]
106 #print "fec_inner:", x[4]
107 #print "inversion:", 2
110 def getInitialTerrestrialTransponderList(tlist, region):
111 list = nimmanager.getTranspondersTerrestrial(region)
113 #self.transponders[self.parsedTer].append((2,freq,bw,const,crh,crl,guard,transm,hierarchy,inv))
115 #def buildTerTransponder(frequency, inversion = 2, bandwidth = 3, fechigh = 6, feclow = 6,
116 #modulation = 2, transmission = 2, guard = 4, hierarchy = 4):
119 if x[0] == 2: #TERRESTRIAL
120 parm = buildTerTransponder(x[1], x[9], x[2], x[4], x[5], x[3], x[7], x[6], x[8])
124 "DVBC_BAND_EU_VHF_I" : 1 << 0,
125 "DVBC_BAND_EU_MID" : 1 << 1,
126 "DVBC_BAND_EU_VHF_III" : 1 << 2,
127 "DVBC_BAND_EU_SUPER" : 1 << 3,
128 "DVBC_BAND_EU_HYPER" : 1 << 4,
129 "DVBC_BAND_EU_UHF_IV" : 1 << 5,
130 "DVBC_BAND_EU_UHF_V" : 1 << 6,
131 "DVBC_BAND_US_LO" : 1 << 7,
132 "DVBC_BAND_US_MID" : 1 << 8,
133 "DVBC_BAND_US_HI" : 1 << 9,
134 "DVBC_BAND_US_SUPER" : 1 << 10,
135 "DVBC_BAND_US_HYPER" : 1 << 11,
138 class CableTransponderSearchSupport:
139 # def setCableTransponderSearchResult(self, tlist):
142 # def cableTransponderSearchFinished(self):
145 def tryGetRawFrontend(self, feid):
146 res_mgr = eDVBResourceManager.getInstance()
148 raw_channel = res_mgr.allocateRawChannel(self.feid)
150 frontend = raw_channel.getFrontend()
157 def cableTransponderSearchSessionClosed(self, *val):
158 print "cableTransponderSearchSessionClosed, val", val
159 self.cable_search_container.appClosed.get().remove(self.cableTransponderSearchClosed)
160 self.cable_search_container.dataAvail.get().remove(self.getCableTransponderData)
161 self.cable_search_container = None
162 self.cable_search_session = None
163 if val and len(val) and val[0]:
164 self.setCableTransponderSearchResult(self.__tlist)
166 self.cableTransponderSearchFinished()
168 def cableTransponderSearchClosed(self, retval):
169 print "cableTransponderSearch finished", retval
170 self.cable_search_session.close(True)
172 def getCableTransponderData(self, str):
177 qam = { "QAM16" : 1, "QAM32" : 2, "QAM64" : 3, "QAM128" : 4, "QAM256" : 5 }
178 inv = { "INVERSION_OFF" : 0, "INVERSION_ON" : 1 }
179 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 }
180 parm = eDVBFrontendParametersCable()
181 parm.frequency = int(data[1])
182 parm.symbol_rate = int(data[2])
183 parm.fec_inner = fec[data[3]]
184 parm.modulation = qam[data[4]]
185 parm.inversion = inv[data[5]]
186 self.__tlist.append(parm)
187 tmpstr = _("Try to find used Transponders in cable network.. please wait...")
192 self.cable_search_session["text"].setText(tmpstr)
194 def startCableTransponderSearch(self, nim_idx):
195 if not self.tryGetRawFrontend(nim_idx):
196 self.session.nav.stopService()
197 if not self.tryGetRawFrontend(nim_idx):
198 if self.session.pipshown: # try to disable pip
199 self.session.pipshown = False
201 if not self.tryGetRawFrontend(nim_idx):
202 self.cableTransponderSearchFinished()
205 self.cable_search_container = eConsoleAppContainer()
206 self.cable_search_container.appClosed.get().append(self.cableTransponderSearchClosed)
207 self.cable_search_container.dataAvail.get().append(self.getCableTransponderData)
208 cableConfig = config.Nims[nim_idx].cable
209 cmd = "tda1002x --init --scan --verbose --wakeup --inv 2 --bus "
210 #FIXMEEEEEE hardcoded i2c devices for dm7025 and dm8000
215 cmd += "2" # first nim socket on DM8000 use /dev/i2c/2
217 cmd += "4" # second nim socket on DM8000 use /dev/i2c/4
218 if cableConfig.scan_type.value == "bands":
219 cmd += " --scan-bands "
221 if cableConfig.scan_band_EU_VHF_I.value:
222 bands |= cable_bands["DVBC_BAND_EU_VHF_I"]
223 if cableConfig.scan_band_EU_MID.value:
224 bands |= cable_bands["DVBC_BAND_EU_MID"]
225 if cableConfig.scan_band_EU_VHF_III.value:
226 bands |= cable_bands["DVBC_BAND_EU_VHF_III"]
227 if cableConfig.scan_band_EU_UHF_IV.value:
228 bands |= cable_bands["DVBC_BAND_EU_UHF_IV"]
229 if cableConfig.scan_band_EU_UHF_V.value:
230 bands |= cable_bands["DVBC_BAND_EU_UHF_V"]
231 if cableConfig.scan_band_EU_SUPER.value:
232 bands |= cable_bands["DVBC_BAND_EU_SUPER"]
233 if cableConfig.scan_band_EU_HYPER.value:
234 bands |= cable_bands["DVBC_BAND_EU_HYPER"]
235 if cableConfig.scan_band_US_LOW.value:
236 bands |= cable_bands["DVBC_BAND_US_LO"]
237 if cableConfig.scan_band_US_MID.value:
238 bands |= cable_bands["DVBC_BAND_US_MID"]
239 if cableConfig.scan_band_US_HIGH.value:
240 bands |= cable_bands["DVBC_BAND_US_HI"]
241 if cableConfig.scan_band_US_SUPER.value:
242 bands |= cable_bands["DVBC_BAND_US_SUPER"]
243 if cableConfig.scan_band_US_HYPER.value:
244 bands |= cable_bands["DVBC_BAND_US_HYPER"]
247 cmd += " --scan-stepsize "
248 cmd += str(cableConfig.scan_frequency_steps.value)
249 if cableConfig.scan_mod_qam16.value:
251 if cableConfig.scan_mod_qam32.value:
253 if cableConfig.scan_mod_qam64.value:
255 if cableConfig.scan_mod_qam128.value:
257 if cableConfig.scan_mod_qam256.value:
259 if cableConfig.scan_sr_6900.value:
260 cmd += " --sr 6900000"
261 if cableConfig.scan_sr_6875.value:
262 cmd += " --sr 6875000"
263 if cableConfig.scan_sr_ext1.value > 450:
265 cmd += str(cableConfig.scan_sr_ext1.value)
267 if cableConfig.scan_sr_ext2.value > 450:
269 cmd += str(cableConfig.scan_sr_ext2.value)
271 print "TDA1002x CMD is", cmd
273 self.cable_search_container.execute(cmd)
274 tmpstr = _("Try to find used transponders in cable network.. please wait...")
276 self.cable_search_session = self.session.openWithCallback(self.cableTransponderSearchSessionClosed, MessageBox, tmpstr, MessageBox.TYPE_INFO)
278 class ScanSetup(ConfigListScreen, Screen, CableTransponderSearchSupport):
279 def __init__(self, session):
280 Screen.__init__(self, session)
282 self.finished_cb = None
284 self.service = session.nav.getCurrentService()
287 if self.service is not None:
288 self.feinfo = self.service.frontendInfo()
289 frontendData = self.feinfo and self.feinfo.getAll(True)
291 self.createConfig(frontendData)
296 self["actions"] = NumberActionMap(["SetupActions"],
299 "cancel": self.keyCancel,
302 self.statusTimer = eTimer()
303 self.statusTimer.callback.append(self.updateStatus)
304 #self.statusTimer.start(5000, True)
307 ConfigListScreen.__init__(self, self.list)
310 self["introduction"] = Label(_("Press OK to start the scan"))
312 def runAsync(self, finished_cb):
313 self.finished_cb = finished_cb
316 def updateSatList(self):
318 for slot in nimmanager.nim_slots:
319 if slot.isCompatible("DVB-S"):
320 self.satList.append(nimmanager.getSatListForNim(slot.slot))
322 self.satList.append(None)
324 def createSetup(self):
326 self.multiscanlist = []
327 index_to_scan = int(self.scan_nims.value)
328 print "ID: ", index_to_scan
330 self.tunerEntry = getConfigListEntry(_("Tuner"), self.scan_nims)
331 self.list.append(self.tunerEntry)
333 if self.scan_nims == [ ]:
336 self.typeOfScanEntry = None
337 self.systemEntry = None
338 nim = nimmanager.nim_slots[index_to_scan]
339 if nim.isCompatible("DVB-S"):
340 self.typeOfScanEntry = getConfigListEntry(_("Type of scan"), self.scan_type)
341 self.list.append(self.typeOfScanEntry)
342 elif nim.isCompatible("DVB-C"):
343 self.typeOfScanEntry = getConfigListEntry(_("Type of scan"), self.scan_typecable)
344 self.list.append(self.typeOfScanEntry)
345 elif nim.isCompatible("DVB-T"):
346 self.typeOfScanEntry = getConfigListEntry(_("Type of scan"), self.scan_typeterrestrial)
347 self.list.append(self.typeOfScanEntry)
349 if nim.isCompatible("DVB-S"):
350 if self.scan_type.value == "single_transponder":
352 if nim.isCompatible("DVB-S2"):
353 self.systemEntry = getConfigListEntry(_('System'), self.scan_sat.system)
354 self.list.append(self.systemEntry)
356 # downgrade to dvb-s, in case a -s2 config was active
357 self.scan_sat.system.value = "dvb-s"
358 self.list.append(getConfigListEntry(_('Satellite'), self.scan_satselection[index_to_scan]))
359 self.list.append(getConfigListEntry(_('Frequency'), self.scan_sat.frequency))
360 self.list.append(getConfigListEntry(_('Inversion'), self.scan_sat.inversion))
361 self.list.append(getConfigListEntry(_('Symbol Rate'), self.scan_sat.symbolrate))
362 self.list.append(getConfigListEntry(_("Polarity"), self.scan_sat.polarization))
363 if self.scan_sat.system.value == "dvb-s":
364 self.list.append(getConfigListEntry(_("FEC"), self.scan_sat.fec))
365 elif self.scan_sat.system.value == "dvb-s2":
366 self.list.append(getConfigListEntry(_("FEC"), self.scan_sat.fec_s2))
367 self.list.append(getConfigListEntry(_('Modulation'), self.scan_sat.modulation))
368 self.list.append(getConfigListEntry(_("Network scan"), self.scan_networkScan))
369 elif self.scan_type.value == "single_satellite":
371 print self.scan_satselection[index_to_scan]
372 self.list.append(getConfigListEntry(_("Satellite"), self.scan_satselection[index_to_scan]))
373 self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
374 elif self.scan_type.value == "multisat":
377 SatList = nimmanager.getSatListForNim(index_to_scan)
378 self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
380 if self.Satexists(tlist, x[0]) == 0:
382 sat = ConfigEnableDisable(default = True)
383 configEntry = getConfigListEntry(nimmanager.getSatDescription(x[0]), sat)
384 self.list.append(configEntry)
385 self.multiscanlist.append((x[0], sat))
387 # for sat in nimmanager.satList:
388 # self.list.append(getConfigListEntry(sat[1], self.scan_scansat[sat[0]]))
389 elif nim.isCompatible("DVB-C"):
390 if self.scan_typecable.value == "single_transponder":
391 self.list.append(getConfigListEntry(_("Frequency"), self.scan_cab.frequency))
392 self.list.append(getConfigListEntry(_("Inversion"), self.scan_cab.inversion))
393 self.list.append(getConfigListEntry(_("Symbol Rate"), self.scan_cab.symbolrate))
394 self.list.append(getConfigListEntry(_("Modulation"), self.scan_cab.modulation))
395 self.list.append(getConfigListEntry(_("FEC"), self.scan_cab.fec))
396 self.list.append(getConfigListEntry(_("Network scan"), self.scan_networkScan))
397 elif self.scan_typecable.value == "complete":
398 self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
399 elif nim.isCompatible("DVB-T"):
400 if self.scan_typeterrestrial.value == "single_transponder":
401 self.list.append(getConfigListEntry(_("Frequency"), self.scan_ter.frequency))
402 self.list.append(getConfigListEntry(_("Inversion"), self.scan_ter.inversion))
403 self.list.append(getConfigListEntry(_("Bandwidth"), self.scan_ter.bandwidth))
404 self.list.append(getConfigListEntry(_("Code rate high"), self.scan_ter.fechigh))
405 self.list.append(getConfigListEntry(_("Code rate low"), self.scan_ter.feclow))
406 self.list.append(getConfigListEntry(_("Modulation"), self.scan_ter.modulation))
407 self.list.append(getConfigListEntry(_("Transmission mode"), self.scan_ter.transmission))
408 self.list.append(getConfigListEntry(_("Guard interval mode"), self.scan_ter.guard))
409 self.list.append(getConfigListEntry(_("Hierarchy mode"), self.scan_ter.hierarchy))
410 self.list.append(getConfigListEntry(_("Network scan"), self.scan_networkScan))
411 elif self.scan_typeterrestrial.value == "complete":
412 self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
414 # if (nim.isCompatible("DVB-S") and self.scan_type.type == "single_transponder") or \
415 # (nim.isCompatbile("DVB-C") and self.scan_typecable.type == "single_transponder") or \
416 # (nim.isCompatible("DVB-T") and self.scan_typeterrestrial.type == "single_transponder"):
417 # self.configElementSNR = getConfigListEntry(_("SNR"), self.scan_snr)
418 # self.list.append(self.configElementSNR)
419 # self.configElementACG = getConfigListEntry(_("AGC"), self.scan_agc)
420 # self.list.append(self.configElementACG)
421 # self.configElementBER = getConfigListEntry(_("BER"), self.scan_ber)
422 # self.list.append(self.configElementBER)
423 # self.statusTimer.start(500, False)
425 # self.statusTimer.stop()
427 self["config"].list = self.list
428 self["config"].l.setList(self.list)
430 def Satexists(self, tlist, pos):
437 cur = self["config"].getCurrent()
439 if cur == self.typeOfScanEntry or \
440 cur == self.tunerEntry or \
441 cur == self.systemEntry:
444 def createConfig(self, frontendData):
445 #("Type", frontendData["system"], TYPE_TEXT),
446 #("Modulation", frontendData["modulation"], TYPE_TEXT),
447 #("Orbital position", frontendData["orbital_position"], TYPE_VALUE_DEC),
448 #("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
449 #("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC),
450 #("Polarization", frontendData["polarization"], TYPE_TEXT),
451 #("Inversion", frontendData["inversion"], TYPE_TEXT),
452 #("FEC inner", frontendData["fec_inner"], TYPE_TEXT),
454 #elif frontendData["tuner_type"] == "DVB-C":
455 #return ( ("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
456 #("Type", frontendData["tuner_type"], TYPE_TEXT),
457 #("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
458 #("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC),
459 #("Modulation", frontendData["modulation"], TYPE_TEXT),
460 #("Inversion", frontendData["inversion"], TYPE_TEXT),
461 # ("FEC inner", frontendData["fec_inner"], TYPE_TEXT),
463 #elif frontendData["tuner_type"] == "DVB-T":
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 #("Inversion", frontendData["inversion"], TYPE_TEXT),
468 #("Bandwidth", frontendData["bandwidth"], TYPE_VALUE_DEC),
469 #("CodeRateLP", frontendData["code_rate_lp"], TYPE_TEXT),
470 #("CodeRateHP", frontendData["code_rate_hp"], TYPE_TEXT),
471 #("Constellation", frontendData["constellation"], TYPE_TEXT),
472 #("Transmission Mode", frontendData["transmission_mode"], TYPE_TEXT),
473 #("Guard Interval", frontendData["guard_interval"], TYPE_TEXT),
474 #("Hierarchy Inform.", frontendData["hierarchy_information"], TYPE_TEXT),
475 defaultSat = { "orbpos": 192, "system": "dvb-s", "frequency": 11836, "inversion": "auto", "symbolrate": 27500, "polarization": "horizontal", "fec": "auto", "fec_s2": "9_10", "modulation": "qpsk" }
476 defaultCab = {"frequency": 466, "inversion": "auto", "modulation": "64qam", "fec": "auto", "symbolrate": 6900}
477 if frontendData is not None:
478 ttype = frontendData.get("tuner_type", "UNKNOWN")
480 defaultSat["system"] = {"DVB-S": "dvb-s", "DVB-S2": "dvb-s2"}[frontendData.get("system", "DVB-S")]
481 defaultSat["frequency"] = int(frontendData.get("frequency", 0) / 1000)
482 defaultSat["inversion"] = {"INVERSION_OFF": "off", "INVERSION_ON": "on", "INVERSION_AUTO": "auto"}[frontendData.get("inversion", "INVERSION_AUTO")]
483 defaultSat["symbolrate"] = int(frontendData.get("symbol_rate", 0) / 1000)
484 defaultSat["polarization"] = {"HORIZONTAL": "horizontal", "VERTICAL": "vertical", "CIRCULAR_LEFT": "circular_left", "CIRCULAR_RIGHT": "circular_right", "UNKNOWN": None}[frontendData.get("polarization", "HORIZONTAL")]
486 if frontendData.get("system", "DVB-S") == "DVB-S2":
487 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"} \
488 [frontendData.get("fec_inner", "FEC_AUTO")]
490 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"} \
491 [frontendData.get("fec_inner", "FEC_AUTO")]
493 defaultSat["modulation"] = {"QPSK": "qpsk", "8PSK": "8psk"}[frontendData.get("modulation", "QPSK")]
494 defaultSat["orbpos"] = frontendData.get("orbital_position", 0)
495 elif ttype == "DVB-C":
496 defaultCab["frequency"] = int(frontendData.get("frequency", 0) / 1000)
497 defaultCab["symbolrate"] = int(frontendData.get("symbol_rate", 0) / 1000)
498 defaultCab["inversion"] = {"INVERSION_OFF": "off", "INVERSION_ON": "on", "INVERSION_AUTO": "auto"}[frontendData.get("inversion", "INVERSION_AUTO")]
499 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")]
500 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")]
502 self.scan_sat = ConfigSubsection()
503 self.scan_cab = ConfigSubsection()
504 self.scan_ter = ConfigSubsection()
506 self.scan_type = ConfigSelection(default = "single_transponder", choices = [("single_transponder", _("Single transponder")), ("single_satellite", _("Single satellite")), ("multisat", _("Multisat"))])
507 self.scan_typecable = ConfigSelection(default = "single_transponder", choices = [("single_transponder", _("Single transponder")), ("complete", _("Complete"))])
508 self.scan_typeterrestrial = ConfigSelection(default = "single_transponder", choices = [("single_transponder", _("Single transponder")), ("complete", _("Complete"))])
509 self.scan_clearallservices = ConfigSelection(default = "no", choices = [("no", _("no")), ("yes", _("yes")), ("yes_hold_feeds", _("yes (keep feeds)"))])
510 self.scan_networkScan = ConfigYesNo(default = False)
513 # collect all nims which are *not* set to "nothing"
514 for n in nimmanager.nim_slots:
515 if n.config_mode != "nothing":
516 nim_list.append((str(n.slot), n.friendly_full_description))
518 self.scan_nims = ConfigSelection(choices = nim_list)
521 self.scan_snr = ConfigSlider()
522 self.scan_snr.enabled = False
523 self.scan_agc = ConfigSlider()
524 self.scan_agc.enabled = False
525 self.scan_ber = ConfigSlider()
526 self.scan_ber.enabled = False
529 self.scan_sat.system = ConfigSelection(default = defaultSat["system"], choices = [("dvb-s", _("DVB-S")), ("dvb-s2", _("DVB-S2"))])
530 self.scan_sat.frequency = ConfigInteger(default = defaultSat["frequency"], limits = (1, 99999))
531 self.scan_sat.inversion = ConfigSelection(default = defaultSat["inversion"], choices = [("off", _("off")), ("on", _("on")), ("auto", _("Auto"))])
532 self.scan_sat.symbolrate = ConfigInteger(default = defaultSat["symbolrate"], limits = (1, 99999))
533 self.scan_sat.polarization = ConfigSelection(default = defaultSat["polarization"], choices = [("horizontal", _("horizontal")), ("vertical", _("vertical")), ("circular_left", _("circular left")), ("circular_right", _("circular right"))])
534 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"))])
535 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")])
536 self.scan_sat.modulation = ConfigSelection(default = defaultSat["modulation"], choices = [("qpsk", "QPSK"), ("8psk", "8PSK")])
539 self.scan_cab.frequency = ConfigInteger(default = defaultCab["frequency"], limits = (50, 999))
540 self.scan_cab.inversion = ConfigSelection(default = defaultCab["inversion"], choices = [("off", _("off")), ("on", _("on")), ("auto", _("Auto"))])
541 self.scan_cab.modulation = ConfigSelection(default = defaultCab["modulation"], choices = [("16qam", "16-QAM"), ("32qam", "32-QAM"), ("64qam", "64-QAM"), ("128qam", "128-QAM"), ("256qam", "256-QAM")])
542 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"))])
543 self.scan_cab.symbolrate = ConfigInteger(default = defaultCab["symbolrate"], limits = (1, 99999))
546 self.scan_ter.frequency = ConfigInteger(default = 466000, limits = (50000, 999000))
547 self.scan_ter.inversion = ConfigSelection(default = "auto", choices = [("off", _("off")), ("on", _("on")), ("auto", _("Auto"))])
548 # WORKAROUND: we can't use BW-auto
549 self.scan_ter.bandwidth = ConfigSelection(default = "8MHz", choices = [("8MHz", "8MHz"), ("7MHz", "7MHz"), ("6MHz", "6MHz")])
550 #, ("auto", _("Auto"))))
551 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"))])
552 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"))])
553 self.scan_ter.modulation = ConfigSelection(default = "auto", choices = [("qpsk", "QPSK"), ("qam16", "QAM16"), ("qam64", "QAM64"), ("auto", _("Auto"))])
554 self.scan_ter.transmission = ConfigSelection(default = "auto", choices = [("2k", "2K"), ("8k", "8K"), ("auto", _("Auto"))])
555 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"))])
556 self.scan_ter.hierarchy = ConfigSelection(default = "auto", choices = [("none", _("None")), ("1", "1"), ("2", "2"), ("4", "4"), ("auto", _("Auto"))])
558 self.scan_scansat = {}
559 for sat in nimmanager.satList:
561 self.scan_scansat[sat[0]] = ConfigYesNo(default = False)
563 self.scan_satselection = []
564 for slot in nimmanager.nim_slots:
565 if slot.isCompatible("DVB-S"):
566 self.scan_satselection.append(getConfigSatlist(int(defaultSat["orbpos"]), self.satList[slot.slot]))
568 self.scan_satselection.append(None)
573 ConfigListScreen.keyLeft(self)
577 ConfigListScreen.keyRight(self)
580 def updateStatus(self):
583 fecmap = { "auto": 0,
596 def addSatTransponder(self, tlist, frequency, symbol_rate, polarisation, fec, inversion, orbital_position, system, modulation):
597 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)
598 print "orbpos: " + str(orbital_position)
599 parm = eDVBFrontendParametersSatellite()
601 parm.modulation = 2 # eDVBFrontendParametersSatellite.Modulation.8PSK
603 parm.modulation = 1 # eDVBFrontendParametersSatellite.Modulation.QPSK
605 parm.frequency = frequency * 1000
606 parm.symbol_rate = symbol_rate * 1000
607 parm.polarisation = polarisation
608 parm.fec = self.fecmap[fec]
609 parm.inversion = inversion
610 parm.orbital_position = int(orbital_position)
613 def addCabTransponder(self, tlist, frequency, symbol_rate, modulation, fec, inversion):
614 print "Add Cab: frequ: " + str(frequency) + " symbol: " + str(symbol_rate) + " pol: " + str(modulation) + " fec: " + str(fec) + " inversion: " + str(inversion)
615 parm = eDVBFrontendParametersCable()
616 parm.frequency = frequency * 1000
617 parm.symbol_rate = symbol_rate * 1000
618 parm.modulation = modulation
619 parm.fec = self.fecmap[fec]
620 parm.inversion = inversion
623 def addTerTransponder(self, tlist, *args, **kwargs):
624 tlist.append(buildTerTransponder(*args, **kwargs))
632 index_to_scan = int(self.scan_nims.value)
634 if self.scan_nims == [ ]:
635 self.session.open(MessageBox, _("No tuner is enabled!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
638 nim = nimmanager.nim_slots[index_to_scan]
639 print "nim", nim.slot
640 if nim.isCompatible("DVB-S"):
641 print "is compatible with DVB-S"
642 if self.scan_type.value == "single_transponder":
643 # these lists are generated for each tuner, so this has work.
644 assert len(self.satList) > index_to_scan
645 assert len(self.scan_satselection) > index_to_scan
647 nimsats = self.satList[index_to_scan]
648 selsatidx = self.scan_satselection[index_to_scan].index
650 # however, the satList itself could be empty. in that case, "index" is 0 (for "None").
652 orbpos = nimsats[selsatidx][0]
653 if self.scan_sat.system.value == "dvb-s":
654 fec = self.scan_sat.fec.value
656 fec = self.scan_sat.fec_s2.value
657 print "add sat transponder"
658 self.addSatTransponder(tlist, self.scan_sat.frequency.value,
659 self.scan_sat.symbolrate.value,
660 self.scan_sat.polarization.index,
662 self.scan_sat.inversion.index,
664 self.scan_sat.system.index,
665 self.scan_sat.modulation.index)
666 flags = self.scan_networkScan.value and eComponentScan.scanNetworkSearch or 0
668 elif self.scan_type.value == "single_satellite":
669 sat = self.satList[index_to_scan][self.scan_satselection[index_to_scan].index]
670 getInitialTransponderList(tlist, sat[0])
671 elif self.scan_type.value == "multisat":
672 SatList = nimmanager.getSatListForNim(index_to_scan)
673 for x in self.multiscanlist:
675 print " " + str(x[0])
676 getInitialTransponderList(tlist, x[0])
678 elif nim.isCompatible("DVB-C"):
679 if self.scan_typecable.value == "single_transponder":
680 fec = self.scan_cab.fec.value
681 self.addCabTransponder(tlist, self.scan_cab.frequency.value,
682 self.scan_cab.symbolrate.value,
683 self.scan_cab.modulation.index + 1,
685 self.scan_cab.inversion.index)
686 flags = self.scan_networkScan.value and eComponentScan.scanNetworkSearch or 0
688 elif self.scan_typecable.value == "complete":
689 if config.Nims[index_to_scan].cable.scan_type.value == "provider":
690 getInitialCableTransponderList(tlist, index_to_scan)
694 elif nim.isCompatible("DVB-T"):
695 if self.scan_typeterrestrial.value == "single_transponder":
696 self.addTerTransponder(tlist,
697 self.scan_ter.frequency.value * 1000,
698 inversion = self.scan_ter.inversion.index,
699 bandwidth = self.scan_ter.bandwidth.index,
700 fechigh = self.scan_ter.fechigh.index,
701 feclow = self.scan_ter.feclow.index,
702 modulation = self.scan_ter.modulation.index,
703 transmission = self.scan_ter.transmission.index,
704 guard = self.scan_ter.guard.index,
705 hierarchy = self.scan_ter.hierarchy.index)
706 flags = self.scan_networkScan.value and eComponentScan.scanNetworkSearch or 0
708 elif self.scan_typeterrestrial.value == "complete":
709 getInitialTerrestrialTransponderList(tlist, nimmanager.getTerrestrialDescription(index_to_scan))
712 flags = eComponentScan.scanNetworkSearch
715 tmp = self.scan_clearallservices.value
717 flags |= eComponentScan.scanRemoveServices
718 elif tmp == "yes_hold_feeds":
719 flags |= eComponentScan.scanRemoveServices
720 flags |= eComponentScan.scanDontRemoveFeeds
722 for x in self["config"].list:
726 self.startScan(tlist, flags, index_to_scan)
729 self.feid = index_to_scan
731 self.startCableTransponderSearch(self.feid)
733 def setCableTransponderSearchResult(self, tlist):
736 def cableTransponderSearchFinished(self):
737 self.startScan(self.tlist, self.flags, self.feid)
739 def startScan(self, tlist, flags, feid):
741 # flags |= eComponentScan.scanSearchBAT
743 self.session.openWithCallback(self.finished_cb, ServiceScan, [{"transponders": tlist, "feid": feid, "flags": flags}])
745 self.session.open(ServiceScan, [{"transponders": tlist, "feid": feid, "flags": flags}])
748 self.session.openWithCallback(self.finished_cb, MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
750 self.session.open(MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
753 for x in self["config"].list:
757 class ScanSimple(ConfigListScreen, Screen, CableTransponderSearchSupport):
758 def getNetworksForNim(self, nim):
759 if nim.isCompatible("DVB-S"):
760 networks = nimmanager.getSatListForNim(nim.slot)
761 # the original code took "loopthrough" etc. into account. Do we need this?
762 # if nimmanager.getNimConfigMode(1) in ["loopthrough", "satposdepends", "equal", "nothing"]:
764 # sec = eDVBSatelliteEquipmentControl.getInstance()
765 # if sec is not None:
766 # exclusive_satellites = sec.get_exclusive_satellites(0,1)
767 # if len(exclusive_satellites) == 2:
769 # idx = exclusive_satellites[0]+1
770 # exclusive_nim_sats = exclusive_satellites[idx+1:idx+1+exclusive_satellites[idx]]
771 # if len(exclusive_nim_sats):
774 networks = [ nim.type ] # "DVB-C" or "DVB-T". TODO: seperate networks for different C/T tuners, if we want to support that.
776 # empty tuners provide no networks.
780 def __init__(self, session):
781 Screen.__init__(self, session)
783 self["actions"] = ActionMap(["SetupActions"],
786 "cancel": self.keyCancel,
794 self.finished_cb = None
796 for nim in nimmanager.nim_slots:
797 # collect networks provided by this tuner
800 networks = self.getNetworksForNim(nim)
802 print "nim %d provides" % nim.slot, networks
803 print "known:", known_networks
805 # we only need to scan on the first tuner which provides a network.
806 # this gives the first tuner for each network priority for scanning.
808 if x not in known_networks:
810 print x, "not in ", known_networks
811 known_networks.append(x)
814 nims_to_scan.append(nim)
816 # we save the config elements to use them on keyGo
817 self.nim_enable = [ ]
819 if len(nims_to_scan):
820 self.scan_clearallservices = ConfigSelection(default = "yes", choices = [("no", _("no")), ("yes", _("yes")), ("yes_hold_feeds", _("yes (keep feeds)"))])
821 self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
823 for nim in nims_to_scan:
824 nimconfig = ConfigYesNo(default = True)
825 nimconfig.nim_index = nim.slot
826 self.nim_enable.append(nimconfig)
827 self.list.append(getConfigListEntry(_("Scan ") + nim.slot_name + " (" + nim.friendly_type + ")", nimconfig))
829 ConfigListScreen.__init__(self, self.list)
830 self["header"] = Label(_("Automatic Scan"))
831 self["footer"] = Label(_("Press OK to scan"))
833 def runAsync(self, finished_cb):
834 self.finished_cb = finished_cb
839 self.known_networks = set()
841 self.buildTransponderList()
843 def buildTransponderList(self): # this method is called multiple times because of asynchronous stuff
845 SEARCH_CABLE_TRANSPONDERS = 1
848 n = self.nim_iter < len(self.nim_enable) and self.nim_enable[self.nim_iter] or None
851 if n.value: # check if nim is enabled
853 nim = nimmanager.nim_slots[n.nim_index]
854 networks = set(self.getNetworksForNim(nim))
856 # don't scan anything twice
857 networks.discard(self.known_networks)
860 if nim.isCompatible("DVB-S"):
861 # get initial transponders for each satellite to be scanned
863 getInitialTransponderList(tlist, sat[0])
864 elif nim.isCompatible("DVB-C"):
865 if config.Nims[nim.slot].cable.scan_type.value == "provider":
866 getInitialCableTransponderList(tlist, nim.slot)
868 action = SEARCH_CABLE_TRANSPONDERS
869 elif nim.isCompatible("DVB-T"):
870 getInitialTerrestrialTransponderList(tlist, nimmanager.getTerrestrialDescription(nim.slot))
874 flags |= eComponentScan.scanNetworkSearch #FIXMEEE.. use flags from cables / satellites / terrestrial.xml
875 tmp = self.scan_clearallservices.value
877 flags |= eComponentScan.scanRemoveServices
878 elif tmp == "yes_hold_feeds":
879 flags |= eComponentScan.scanRemoveServices
880 flags |= eComponentScan.scanDontRemoveFeeds
882 if action == APPEND_NOW:
883 self.scanList.append({"transponders": tlist, "feid": nim.slot, "flags": flags})
884 elif action == SEARCH_CABLE_TRANSPONDERS:
887 self.startCableTransponderSearch(nim.slot)
892 self.buildTransponderList() # recursive call of this function !!!
894 # when we are here, then the recursion is finished and all enabled nims are checked
895 # so we now start the real transponder scan
896 self.startScan(self.scanList)
898 def startScan(self, scanList):
901 self.session.openWithCallback(self.finished_cb, ServiceScan, scanList = scanList)
903 self.session.open(ServiceScan, scanList = scanList)
906 self.session.openWithCallback(self.finished_cb, MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
908 self.session.open(MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
910 def setCableTransponderSearchResult(self, tlist):
911 self.scanList.append({"transponders": tlist, "feid": self.feid, "flags": self.flags})
913 def cableTransponderSearchFinished(self):
914 self.buildTransponderList()
919 def Satexists(self, tlist, pos):