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 = None
160 self.cable_search_session = None
161 if val and len(val) and val[0]:
162 self.setCableTransponderSearchResult(self.__tlist)
164 self.cableTransponderSearchFinished()
166 def cableTransponderSearchClosed(self, retval):
167 print "cableTransponderSearch finished", retval
168 self.cable_search_session.close(True)
170 def getCableTransponderData(self, str):
175 qam = { "QAM16" : 1, "QAM32" : 2, "QAM64" : 3, "QAM128" : 4, "QAM256" : 5 }
176 inv = { "INVERSION_OFF" : 0, "INVERSION_ON" : 1 }
177 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 }
178 parm = eDVBFrontendParametersCable()
179 parm.frequency = int(data[1])
180 parm.symbol_rate = int(data[2])
181 parm.fec_inner = fec[data[3]]
182 parm.modulation = qam[data[4]]
183 parm.inversion = inv[data[5]]
184 self.__tlist.append(parm)
185 tmpstr = _("Try to find used Transponders in cable network.. please wait...")
190 self.cable_search_session["text"].setText(tmpstr)
192 def startCableTransponderSearch(self, nim_idx):
193 if not self.tryGetRawFrontend(nim_idx):
194 self.session.nav.stopService()
195 if not self.tryGetRawFrontend(nim_idx):
196 if self.session.pipshown: # try to disable pip
197 self.session.pipshown = False
199 if not self.tryGetRawFrontend(nim_idx):
200 self.cableTransponderSearchFinished()
203 self.cable_search_container = eConsoleAppContainer()
204 self.cable_search_container.appClosed.get().append(self.cableTransponderSearchClosed)
205 self.cable_search_container.dataAvail.get().append(self.getCableTransponderData)
206 cableConfig = config.Nims[nim_idx].cable
207 cmd = "tda1002x --init --scan --verbose --wakeup --inv 2 --bus "
208 #FIXMEEEEEE hardcoded i2c devices for dm7025 and dm8000
213 cmd += "2" # first nim socket on DM8000 use /dev/i2c/2
215 cmd += "4" # second nim socket on DM8000 use /dev/i2c/4
216 if cableConfig.scan_type.value == "bands":
217 cmd += " --scan-bands "
219 if cableConfig.scan_band_EU_VHF_I.value:
220 bands |= cable_bands["DVBC_BAND_EU_VHF_I"]
221 if cableConfig.scan_band_EU_MID.value:
222 bands |= cable_bands["DVBC_BAND_EU_MID"]
223 if cableConfig.scan_band_EU_VHF_III.value:
224 bands |= cable_bands["DVBC_BAND_EU_VHF_III"]
225 if cableConfig.scan_band_EU_UHF_IV.value:
226 bands |= cable_bands["DVBC_BAND_EU_UHF_IV"]
227 if cableConfig.scan_band_EU_UHF_V.value:
228 bands |= cable_bands["DVBC_BAND_EU_UHF_V"]
229 if cableConfig.scan_band_EU_SUPER.value:
230 bands |= cable_bands["DVBC_BAND_EU_SUPER"]
231 if cableConfig.scan_band_EU_HYPER.value:
232 bands |= cable_bands["DVBC_BAND_EU_HYPER"]
233 if cableConfig.scan_band_US_LOW.value:
234 bands |= cable_bands["DVBC_BAND_US_LO"]
235 if cableConfig.scan_band_US_MID.value:
236 bands |= cable_bands["DVBC_BAND_US_MID"]
237 if cableConfig.scan_band_US_HIGH.value:
238 bands |= cable_bands["DVBC_BAND_US_HI"]
239 if cableConfig.scan_band_US_SUPER.value:
240 bands |= cable_bands["DVBC_BAND_US_SUPER"]
241 if cableConfig.scan_band_US_HYPER.value:
242 bands |= cable_bands["DVBC_BAND_US_HYPER"]
245 cmd += " --scan-stepsize "
246 cmd += str(cableConfig.scan_frequency_steps.value)
247 if cableConfig.scan_mod_qam16.value:
249 if cableConfig.scan_mod_qam32.value:
251 if cableConfig.scan_mod_qam64.value:
253 if cableConfig.scan_mod_qam128.value:
255 if cableConfig.scan_mod_qam256.value:
257 if cableConfig.scan_sr_6900.value:
258 cmd += " --sr 6900000"
259 if cableConfig.scan_sr_6875.value:
260 cmd += " --sr 6875000"
261 if cableConfig.scan_sr_ext1.value > 450:
263 cmd += str(cableConfig.scan_sr_ext1.value)
265 if cableConfig.scan_sr_ext2.value > 450:
267 cmd += str(cableConfig.scan_sr_ext2.value)
269 print "TDA1002x CMD is", cmd
271 self.cable_search_container.execute(cmd)
272 tmpstr = _("Try to find used transponders in cable network.. please wait...")
274 self.cable_search_session = self.session.openWithCallback(self.cableTransponderSearchSessionClosed, MessageBox, tmpstr, MessageBox.TYPE_INFO)
276 class ScanSetup(ConfigListScreen, Screen, CableTransponderSearchSupport):
277 def __init__(self, session):
278 Screen.__init__(self, session)
280 self.finished_cb = None
282 self.service = session.nav.getCurrentService()
285 if self.service is not None:
286 self.feinfo = self.service.frontendInfo()
287 frontendData = self.feinfo and self.feinfo.getAll(True)
289 self.createConfig(frontendData)
294 self["actions"] = NumberActionMap(["SetupActions"],
297 "cancel": self.keyCancel,
300 self.statusTimer = eTimer()
301 self.statusTimer.timeout.get().append(self.updateStatus)
302 #self.statusTimer.start(5000, True)
305 ConfigListScreen.__init__(self, self.list)
308 self["introduction"] = Label(_("Press OK to start the scan"))
310 def runAsync(self, finished_cb):
311 self.finished_cb = finished_cb
314 def updateSatList(self):
316 for slot in nimmanager.nim_slots:
317 if slot.isCompatible("DVB-S"):
318 self.satList.append(nimmanager.getSatListForNim(slot.slot))
320 self.satList.append(None)
322 def createSetup(self):
324 self.multiscanlist = []
325 index_to_scan = int(self.scan_nims.value)
326 print "ID: ", index_to_scan
328 self.tunerEntry = getConfigListEntry(_("Tuner"), self.scan_nims)
329 self.list.append(self.tunerEntry)
331 if self.scan_nims == [ ]:
334 self.typeOfScanEntry = None
335 self.systemEntry = None
336 nim = nimmanager.nim_slots[index_to_scan]
337 if nim.isCompatible("DVB-S"):
338 self.typeOfScanEntry = getConfigListEntry(_("Type of scan"), self.scan_type)
339 self.list.append(self.typeOfScanEntry)
340 elif nim.isCompatible("DVB-C"):
341 self.typeOfScanEntry = getConfigListEntry(_("Type of scan"), self.scan_typecable)
342 self.list.append(self.typeOfScanEntry)
343 elif nim.isCompatible("DVB-T"):
344 self.typeOfScanEntry = getConfigListEntry(_("Type of scan"), self.scan_typeterrestrial)
345 self.list.append(self.typeOfScanEntry)
347 if nim.isCompatible("DVB-S"):
348 if self.scan_type.value == "single_transponder":
350 if nim.isCompatible("DVB-S2"):
351 self.systemEntry = getConfigListEntry(_('System'), self.scan_sat.system)
352 self.list.append(self.systemEntry)
354 # downgrade to dvb-s, in case a -s2 config was active
355 self.scan_sat.system.value = "dvb-s"
356 self.list.append(getConfigListEntry(_('Satellite'), self.scan_satselection[index_to_scan]))
357 self.list.append(getConfigListEntry(_('Frequency'), self.scan_sat.frequency))
358 self.list.append(getConfigListEntry(_('Inversion'), self.scan_sat.inversion))
359 self.list.append(getConfigListEntry(_('Symbol Rate'), self.scan_sat.symbolrate))
360 self.list.append(getConfigListEntry(_("Polarity"), self.scan_sat.polarization))
361 if self.scan_sat.system.value == "dvb-s":
362 self.list.append(getConfigListEntry(_("FEC"), self.scan_sat.fec))
363 elif self.scan_sat.system.value == "dvb-s2":
364 self.list.append(getConfigListEntry(_("FEC"), self.scan_sat.fec_s2))
365 self.list.append(getConfigListEntry(_('Modulation'), self.scan_sat.modulation))
366 self.list.append(getConfigListEntry(_("Network scan"), self.scan_networkScan))
367 elif self.scan_type.value == "single_satellite":
369 print self.scan_satselection[index_to_scan]
370 self.list.append(getConfigListEntry(_("Satellite"), self.scan_satselection[index_to_scan]))
371 self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
372 elif self.scan_type.value == "multisat":
375 SatList = nimmanager.getSatListForNim(index_to_scan)
376 self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
378 if self.Satexists(tlist, x[0]) == 0:
380 sat = ConfigEnableDisable(default = True)
381 configEntry = getConfigListEntry(nimmanager.getSatDescription(x[0]), sat)
382 self.list.append(configEntry)
383 self.multiscanlist.append((x[0], sat))
385 # for sat in nimmanager.satList:
386 # self.list.append(getConfigListEntry(sat[1], self.scan_scansat[sat[0]]))
387 elif nim.isCompatible("DVB-C"):
388 if self.scan_typecable.value == "single_transponder":
389 self.list.append(getConfigListEntry(_("Frequency"), self.scan_cab.frequency))
390 self.list.append(getConfigListEntry(_("Inversion"), self.scan_cab.inversion))
391 self.list.append(getConfigListEntry(_("Symbol Rate"), self.scan_cab.symbolrate))
392 self.list.append(getConfigListEntry(_("Modulation"), self.scan_cab.modulation))
393 self.list.append(getConfigListEntry(_("FEC"), self.scan_cab.fec))
394 self.list.append(getConfigListEntry(_("Network scan"), self.scan_networkScan))
395 elif self.scan_typecable.value == "complete":
396 self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
397 elif nim.isCompatible("DVB-T"):
398 if self.scan_typeterrestrial.value == "single_transponder":
399 self.list.append(getConfigListEntry(_("Frequency"), self.scan_ter.frequency))
400 self.list.append(getConfigListEntry(_("Inversion"), self.scan_ter.inversion))
401 self.list.append(getConfigListEntry(_("Bandwidth"), self.scan_ter.bandwidth))
402 self.list.append(getConfigListEntry(_("Code rate high"), self.scan_ter.fechigh))
403 self.list.append(getConfigListEntry(_("Code rate low"), self.scan_ter.feclow))
404 self.list.append(getConfigListEntry(_("Modulation"), self.scan_ter.modulation))
405 self.list.append(getConfigListEntry(_("Transmission mode"), self.scan_ter.transmission))
406 self.list.append(getConfigListEntry(_("Guard interval mode"), self.scan_ter.guard))
407 self.list.append(getConfigListEntry(_("Hierarchy mode"), self.scan_ter.hierarchy))
408 self.list.append(getConfigListEntry(_("Network scan"), self.scan_networkScan))
409 elif self.scan_typeterrestrial.value == "complete":
410 self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
412 # if (nim.isCompatible("DVB-S") and self.scan_type.type == "single_transponder") or \
413 # (nim.isCompatbile("DVB-C") and self.scan_typecable.type == "single_transponder") or \
414 # (nim.isCompatible("DVB-T") and self.scan_typeterrestrial.type == "single_transponder"):
415 # self.configElementSNR = getConfigListEntry(_("SNR"), self.scan_snr)
416 # self.list.append(self.configElementSNR)
417 # self.configElementACG = getConfigListEntry(_("AGC"), self.scan_agc)
418 # self.list.append(self.configElementACG)
419 # self.configElementBER = getConfigListEntry(_("BER"), self.scan_ber)
420 # self.list.append(self.configElementBER)
421 # self.statusTimer.start(500, False)
423 # self.statusTimer.stop()
425 self["config"].list = self.list
426 self["config"].l.setList(self.list)
428 def Satexists(self, tlist, pos):
435 cur = self["config"].getCurrent()
437 if cur == self.typeOfScanEntry or \
438 cur == self.tunerEntry or \
439 cur == self.systemEntry:
442 def createConfig(self, frontendData):
443 #("Type", frontendData["system"], TYPE_TEXT),
444 #("Modulation", frontendData["modulation"], TYPE_TEXT),
445 #("Orbital position", frontendData["orbital_position"], TYPE_VALUE_DEC),
446 #("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
447 #("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC),
448 #("Polarization", frontendData["polarization"], TYPE_TEXT),
449 #("Inversion", frontendData["inversion"], TYPE_TEXT),
450 #("FEC inner", frontendData["fec_inner"], TYPE_TEXT),
452 #elif frontendData["tuner_type"] == "DVB-C":
453 #return ( ("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
454 #("Type", frontendData["tuner_type"], TYPE_TEXT),
455 #("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
456 #("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC),
457 #("Modulation", frontendData["modulation"], TYPE_TEXT),
458 #("Inversion", frontendData["inversion"], TYPE_TEXT),
459 # ("FEC inner", frontendData["fec_inner"], TYPE_TEXT),
461 #elif frontendData["tuner_type"] == "DVB-T":
462 #return ( ("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
463 #("Type", frontendData["tuner_type"], TYPE_TEXT),
464 #("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
465 #("Inversion", frontendData["inversion"], TYPE_TEXT),
466 #("Bandwidth", frontendData["bandwidth"], TYPE_VALUE_DEC),
467 #("CodeRateLP", frontendData["code_rate_lp"], TYPE_TEXT),
468 #("CodeRateHP", frontendData["code_rate_hp"], TYPE_TEXT),
469 #("Constellation", frontendData["constellation"], TYPE_TEXT),
470 #("Transmission Mode", frontendData["transmission_mode"], TYPE_TEXT),
471 #("Guard Interval", frontendData["guard_interval"], TYPE_TEXT),
472 #("Hierarchy Inform.", frontendData["hierarchy_information"], TYPE_TEXT),
473 defaultSat = { "orbpos": 192, "system": "dvb-s", "frequency": 11836, "inversion": "auto", "symbolrate": 27500, "polarization": "horizontal", "fec": "auto", "fec_s2": "9_10", "modulation": "qpsk" }
474 defaultCab = {"frequency": 466, "inversion": "auto", "modulation": "64qam", "fec": "auto", "symbolrate": 6900}
475 if frontendData is not None:
476 ttype = frontendData.get("tuner_type", "UNKNOWN")
478 defaultSat["system"] = {"DVB-S": "dvb-s", "DVB-S2": "dvb-s2"}[frontendData.get("system", "DVB-S")]
479 defaultSat["frequency"] = int(frontendData.get("frequency", 0) / 1000)
480 defaultSat["inversion"] = {"INVERSION_OFF": "off", "INVERSION_ON": "on", "INVERSION_AUTO": "auto"}[frontendData.get("inversion", "INVERSION_AUTO")]
481 defaultSat["symbolrate"] = int(frontendData.get("symbol_rate", 0) / 1000)
482 defaultSat["polarization"] = {"HORIZONTAL": "horizontal", "VERTICAL": "vertical", "CIRCULAR_LEFT": "circular_left", "CIRCULAR_RIGHT": "circular_right", "UNKNOWN": None}[frontendData.get("polarization", "HORIZONTAL")]
484 if frontendData.get("system", "DVB-S") == "DVB-S2":
485 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"} \
486 [frontendData.get("fec_inner", "FEC_AUTO")]
488 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"} \
489 [frontendData.get("fec_inner", "FEC_AUTO")]
491 defaultSat["modulation"] = {"QPSK": "qpsk", "8PSK": "8psk"}[frontendData.get("modulation", "QPSK")]
492 defaultSat["orbpos"] = frontendData.get("orbital_position", 0)
493 elif ttype == "DVB-C":
494 defaultCab["frequency"] = int(frontendData.get("frequency", 0) / 1000)
495 defaultCab["symbolrate"] = int(frontendData.get("symbol_rate", 0) / 1000)
496 defaultCab["inversion"] = {"INVERSION_OFF": "off", "INVERSION_ON": "on", "INVERSION_AUTO": "auto"}[frontendData.get("inversion", "INVERSION_AUTO")]
497 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")]
498 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")]
500 self.scan_sat = ConfigSubsection()
501 self.scan_cab = ConfigSubsection()
502 self.scan_ter = ConfigSubsection()
504 self.scan_type = ConfigSelection(default = "single_transponder", choices = [("single_transponder", _("Single transponder")), ("single_satellite", _("Single satellite")), ("multisat", _("Multisat"))])
505 self.scan_typecable = ConfigSelection(default = "single_transponder", choices = [("single_transponder", _("Single transponder")), ("complete", _("Complete"))])
506 self.scan_typeterrestrial = ConfigSelection(default = "single_transponder", choices = [("single_transponder", _("Single transponder")), ("complete", _("Complete"))])
507 self.scan_clearallservices = ConfigSelection(default = "no", choices = [("no", _("no")), ("yes", _("yes")), ("yes_hold_feeds", _("yes (keep feeds)"))])
508 self.scan_networkScan = ConfigYesNo(default = False)
511 # collect all nims which are *not* set to "nothing"
512 for n in nimmanager.nim_slots:
513 if n.config_mode != "nothing":
514 nim_list.append((str(n.slot), n.friendly_full_description))
516 self.scan_nims = ConfigSelection(choices = nim_list)
519 self.scan_snr = ConfigSlider()
520 self.scan_snr.enabled = False
521 self.scan_agc = ConfigSlider()
522 self.scan_agc.enabled = False
523 self.scan_ber = ConfigSlider()
524 self.scan_ber.enabled = False
527 self.scan_sat.system = ConfigSelection(default = defaultSat["system"], choices = [("dvb-s", _("DVB-S")), ("dvb-s2", _("DVB-S2"))])
528 self.scan_sat.frequency = ConfigInteger(default = defaultSat["frequency"], limits = (1, 99999))
529 self.scan_sat.inversion = ConfigSelection(default = defaultSat["inversion"], choices = [("off", _("off")), ("on", _("on")), ("auto", _("Auto"))])
530 self.scan_sat.symbolrate = ConfigInteger(default = defaultSat["symbolrate"], limits = (1, 99999))
531 self.scan_sat.polarization = ConfigSelection(default = defaultSat["polarization"], choices = [("horizontal", _("horizontal")), ("vertical", _("vertical")), ("circular_left", _("circular left")), ("circular_right", _("circular right"))])
532 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"))])
533 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")])
534 self.scan_sat.modulation = ConfigSelection(default = defaultSat["modulation"], choices = [("qpsk", "QPSK"), ("8psk", "8PSK")])
537 self.scan_cab.frequency = ConfigInteger(default = defaultCab["frequency"], limits = (50, 999))
538 self.scan_cab.inversion = ConfigSelection(default = defaultCab["inversion"], choices = [("off", _("off")), ("on", _("on")), ("auto", _("Auto"))])
539 self.scan_cab.modulation = ConfigSelection(default = defaultCab["modulation"], choices = [("16qam", "16-QAM"), ("32qam", "32-QAM"), ("64qam", "64-QAM"), ("128qam", "128-QAM"), ("256qam", "256-QAM")])
540 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"))])
541 self.scan_cab.symbolrate = ConfigInteger(default = defaultCab["symbolrate"], limits = (1, 99999))
544 self.scan_ter.frequency = ConfigInteger(default = 466000, limits = (50000, 999000))
545 self.scan_ter.inversion = ConfigSelection(default = "auto", choices = [("off", _("off")), ("on", _("on")), ("auto", _("Auto"))])
546 # WORKAROUND: we can't use BW-auto
547 self.scan_ter.bandwidth = ConfigSelection(default = "8MHz", choices = [("8MHz", "8MHz"), ("7MHz", "7MHz"), ("6MHz", "6MHz")])
548 #, ("auto", _("Auto"))))
549 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"))])
550 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"))])
551 self.scan_ter.modulation = ConfigSelection(default = "auto", choices = [("qpsk", "QPSK"), ("qam16", "QAM16"), ("qam64", "QAM64"), ("auto", _("Auto"))])
552 self.scan_ter.transmission = ConfigSelection(default = "auto", choices = [("2k", "2K"), ("8k", "8K"), ("auto", _("Auto"))])
553 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"))])
554 self.scan_ter.hierarchy = ConfigSelection(default = "auto", choices = [("none", _("None")), ("1", "1"), ("2", "2"), ("4", "4"), ("auto", _("Auto"))])
556 self.scan_scansat = {}
557 for sat in nimmanager.satList:
559 self.scan_scansat[sat[0]] = ConfigYesNo(default = False)
561 self.scan_satselection = []
562 for slot in nimmanager.nim_slots:
563 if slot.isCompatible("DVB-S"):
564 self.scan_satselection.append(getConfigSatlist(int(defaultSat["orbpos"]), self.satList[slot.slot]))
566 self.scan_satselection.append(None)
571 ConfigListScreen.keyLeft(self)
575 ConfigListScreen.keyRight(self)
578 def updateStatus(self):
581 fecmap = { "auto": 0,
594 def addSatTransponder(self, tlist, frequency, symbol_rate, polarisation, fec, inversion, orbital_position, system, modulation):
595 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)
596 print "orbpos: " + str(orbital_position)
597 parm = eDVBFrontendParametersSatellite()
599 parm.modulation = 2 # eDVBFrontendParametersSatellite.Modulation.8PSK
601 parm.modulation = 1 # eDVBFrontendParametersSatellite.Modulation.QPSK
603 parm.frequency = frequency * 1000
604 parm.symbol_rate = symbol_rate * 1000
605 parm.polarisation = polarisation
606 parm.fec = self.fecmap[fec]
607 parm.inversion = inversion
608 parm.orbital_position = int(orbital_position)
611 def addCabTransponder(self, tlist, frequency, symbol_rate, modulation, fec, inversion):
612 print "Add Cab: frequ: " + str(frequency) + " symbol: " + str(symbol_rate) + " pol: " + str(modulation) + " fec: " + str(fec) + " inversion: " + str(inversion)
613 parm = eDVBFrontendParametersCable()
614 parm.frequency = frequency * 1000
615 parm.symbol_rate = symbol_rate * 1000
616 parm.modulation = modulation
617 parm.fec = self.fecmap[fec]
618 parm.inversion = inversion
621 def addTerTransponder(self, tlist, *args, **kwargs):
622 tlist.append(buildTerTransponder(*args, **kwargs))
630 index_to_scan = int(self.scan_nims.value)
632 if self.scan_nims == [ ]:
633 self.session.open(MessageBox, _("No tuner is enabled!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
636 nim = nimmanager.nim_slots[index_to_scan]
637 print "nim", nim.slot
638 if nim.isCompatible("DVB-S"):
639 print "is compatible with DVB-S"
640 if self.scan_type.value == "single_transponder":
641 # these lists are generated for each tuner, so this has work.
642 assert len(self.satList) > index_to_scan
643 assert len(self.scan_satselection) > index_to_scan
645 nimsats = self.satList[index_to_scan]
646 selsatidx = self.scan_satselection[index_to_scan].index
648 # however, the satList itself could be empty. in that case, "index" is 0 (for "None").
650 orbpos = nimsats[selsatidx][0]
651 if self.scan_sat.system.value == "dvb-s":
652 fec = self.scan_sat.fec.value
654 fec = self.scan_sat.fec_s2.value
655 print "add sat transponder"
656 self.addSatTransponder(tlist, self.scan_sat.frequency.value,
657 self.scan_sat.symbolrate.value,
658 self.scan_sat.polarization.index,
660 self.scan_sat.inversion.index,
662 self.scan_sat.system.index,
663 self.scan_sat.modulation.index)
664 flags = self.scan_networkScan.value and eComponentScan.scanNetworkSearch or 0
666 elif self.scan_type.value == "single_satellite":
667 sat = self.satList[index_to_scan][self.scan_satselection[index_to_scan].index]
668 getInitialTransponderList(tlist, sat[0])
669 elif self.scan_type.value == "multisat":
670 SatList = nimmanager.getSatListForNim(index_to_scan)
671 for x in self.multiscanlist:
673 print " " + str(x[0])
674 getInitialTransponderList(tlist, x[0])
676 elif nim.isCompatible("DVB-C"):
677 if self.scan_typecable.value == "single_transponder":
678 fec = self.scan_cab.fec.value
679 self.addCabTransponder(tlist, self.scan_cab.frequency.value,
680 self.scan_cab.symbolrate.value,
681 self.scan_cab.modulation.index + 1,
683 self.scan_cab.inversion.index)
684 flags = self.scan_networkScan.value and eComponentScan.scanNetworkSearch or 0
686 elif self.scan_typecable.value == "complete":
687 if config.Nims[index_to_scan].cable.scan_type.value == "provider":
688 getInitialCableTransponderList(tlist, index_to_scan)
692 elif nim.isCompatible("DVB-T"):
693 if self.scan_typeterrestrial.value == "single_transponder":
694 self.addTerTransponder(tlist,
695 self.scan_ter.frequency.value * 1000,
696 inversion = self.scan_ter.inversion.index,
697 bandwidth = self.scan_ter.bandwidth.index,
698 fechigh = self.scan_ter.fechigh.index,
699 feclow = self.scan_ter.feclow.index,
700 modulation = self.scan_ter.modulation.index,
701 transmission = self.scan_ter.transmission.index,
702 guard = self.scan_ter.guard.index,
703 hierarchy = self.scan_ter.hierarchy.index)
704 flags = self.scan_networkScan.value and eComponentScan.scanNetworkSearch or 0
706 elif self.scan_typeterrestrial.value == "complete":
707 getInitialTerrestrialTransponderList(tlist, nimmanager.getTerrestrialDescription(index_to_scan))
710 flags = eComponentScan.scanNetworkSearch
713 tmp = self.scan_clearallservices.value
715 flags |= eComponentScan.scanRemoveServices
716 elif tmp == "yes_hold_feeds":
717 flags |= eComponentScan.scanRemoveServices
718 flags |= eComponentScan.scanDontRemoveFeeds
720 for x in self["config"].list:
724 self.startScan(tlist, flags, index_to_scan)
727 self.feid = index_to_scan
729 self.startCableTransponderSearch(self.feid)
731 def setCableTransponderSearchResult(self, tlist):
734 def cableTransponderSearchFinished(self):
735 self.startScan(self.tlist, self.flags, self.feid)
737 def startScan(self, tlist, flags, feid):
739 # flags |= eComponentScan.scanSearchBAT
741 self.session.openWithCallback(self.finished_cb, ServiceScan, [{"transponders": tlist, "feid": feid, "flags": flags}])
743 self.session.open(ServiceScan, [{"transponders": tlist, "feid": feid, "flags": flags}])
746 self.session.openWithCallback(self.finished_cb, MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
748 self.session.open(MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
751 for x in self["config"].list:
755 class ScanSimple(ConfigListScreen, Screen, CableTransponderSearchSupport):
756 def getNetworksForNim(self, nim):
757 if nim.isCompatible("DVB-S"):
758 networks = nimmanager.getSatListForNim(nim.slot)
759 # the original code took "loopthrough" etc. into account. Do we need this?
760 # if nimmanager.getNimConfigMode(1) in ["loopthrough", "satposdepends", "equal", "nothing"]:
762 # sec = eDVBSatelliteEquipmentControl.getInstance()
763 # if sec is not None:
764 # exclusive_satellites = sec.get_exclusive_satellites(0,1)
765 # if len(exclusive_satellites) == 2:
767 # idx = exclusive_satellites[0]+1
768 # exclusive_nim_sats = exclusive_satellites[idx+1:idx+1+exclusive_satellites[idx]]
769 # if len(exclusive_nim_sats):
772 networks = [ nim.type ] # "DVB-C" or "DVB-T". TODO: seperate networks for different C/T tuners, if we want to support that.
774 # empty tuners provide no networks.
778 def __init__(self, session):
779 Screen.__init__(self, session)
781 self["actions"] = ActionMap(["SetupActions"],
784 "cancel": self.keyCancel,
792 self.finished_cb = None
794 for nim in nimmanager.nim_slots:
795 # collect networks provided by this tuner
798 networks = self.getNetworksForNim(nim)
800 print "nim %d provides" % nim.slot, networks
801 print "known:", known_networks
803 # we only need to scan on the first tuner which provides a network.
804 # this gives the first tuner for each network priority for scanning.
806 if x not in known_networks:
808 print x, "not in ", known_networks
809 known_networks.append(x)
812 nims_to_scan.append(nim)
814 # we save the config elements to use them on keyGo
815 self.nim_enable = [ ]
817 if len(nims_to_scan):
818 self.scan_clearallservices = ConfigSelection(default = "yes", choices = [("no", _("no")), ("yes", _("yes")), ("yes_hold_feeds", _("yes (keep feeds)"))])
819 self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
821 for nim in nims_to_scan:
822 nimconfig = ConfigYesNo(default = True)
823 nimconfig.nim_index = nim.slot
824 self.nim_enable.append(nimconfig)
825 self.list.append(getConfigListEntry(_("Scan ") + nim.slot_name + " (" + nim.friendly_type + ")", nimconfig))
827 ConfigListScreen.__init__(self, self.list)
828 self["header"] = Label(_("Automatic Scan"))
829 self["footer"] = Label(_("Press OK to scan"))
831 def runAsync(self, finished_cb):
832 self.finished_cb = finished_cb
837 self.known_networks = set()
839 self.buildTransponderList()
841 def buildTransponderList(self): # this method is called multiple times because of asynchronous stuff
843 SEARCH_CABLE_TRANSPONDERS = 1
846 n = self.nim_iter < len(self.nim_enable) and self.nim_enable[self.nim_iter] or None
849 if n.value: # check if nim is enabled
851 nim = nimmanager.nim_slots[n.nim_index]
852 networks = set(self.getNetworksForNim(nim))
854 # don't scan anything twice
855 networks.discard(self.known_networks)
858 if nim.isCompatible("DVB-S"):
859 # get initial transponders for each satellite to be scanned
861 getInitialTransponderList(tlist, sat[0])
862 elif nim.isCompatible("DVB-C"):
863 if config.Nims[nim.slot].cable.scan_type.value == "provider":
864 getInitialCableTransponderList(tlist, nim.slot)
866 action = SEARCH_CABLE_TRANSPONDERS
867 elif nim.isCompatible("DVB-T"):
868 getInitialTerrestrialTransponderList(tlist, nimmanager.getTerrestrialDescription(nim.slot))
872 flags |= eComponentScan.scanNetworkSearch #FIXMEEE.. use flags from cables / satellites / terrestrial.xml
873 tmp = self.scan_clearallservices.value
875 flags |= eComponentScan.scanRemoveServices
876 elif tmp == "yes_hold_feeds":
877 flags |= eComponentScan.scanRemoveServices
878 flags |= eComponentScan.scanDontRemoveFeeds
880 if action == APPEND_NOW:
881 self.scanList.append({"transponders": tlist, "feid": nim.slot, "flags": flags})
882 elif action == SEARCH_CABLE_TRANSPONDERS:
885 self.startCableTransponderSearch(nim.slot)
890 self.buildTransponderList() # recursive call of this function !!!
892 # when we are here, then the recursion is finished and all enabled nims are checked
893 # so we now start the real transponder scan
894 self.startScan(self.scanList)
896 def startScan(self, scanList):
899 self.session.openWithCallback(self.finished_cb, ServiceScan, scanList = scanList)
901 self.session.open(ServiceScan, scanList = scanList)
904 self.session.openWithCallback(self.finished_cb, MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
906 self.session.open(MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
908 def setCableTransponderSearchResult(self, tlist):
909 self.scanList.append({"transponders": tlist, "feid": self.feid, "flags": self.flags})
911 def cableTransponderSearchFinished(self):
912 self.buildTransponderList()
917 def Satexists(self, tlist, pos):