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.get().remove(self.cableTransponderSearchClosed)
164 self.cable_search_container.dataAvail.get().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.get().append(self.cableTransponderSearchClosed)
211 self.cable_search_container.dataAvail.get().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 DefaultWizard.__init__(self, session, silent, showSteps, neededTag = "services")
285 print "configuredSats:", nimmanager.getConfiguredSats()
287 def setDirectory(self):
289 self.directory.append(resolveFilename(SCOPE_DEFAULTDIR))
291 os.system("mount %s %s" % (resolveFilename(SCOPE_DEFAULTPARTITION), resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR)))
292 self.directory.append(resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR))
293 self.xmlfile = "defaultsatlists.xml"
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."))
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 if nim.isCompatible("DVB-S"):
376 if self.scan_type.value == "single_transponder":
378 if nim.isCompatible("DVB-S2"):
379 self.systemEntry = getConfigListEntry(_('System'), self.scan_sat.system)
380 self.list.append(self.systemEntry)
382 # downgrade to dvb-s, in case a -s2 config was active
383 self.scan_sat.system.value = "dvb-s"
384 self.list.append(getConfigListEntry(_('Satellite'), self.scan_satselection[index_to_scan]))
385 self.list.append(getConfigListEntry(_('Frequency'), self.scan_sat.frequency))
386 self.list.append(getConfigListEntry(_('Inversion'), self.scan_sat.inversion))
387 self.list.append(getConfigListEntry(_('Symbol Rate'), self.scan_sat.symbolrate))
388 self.list.append(getConfigListEntry(_("Polarity"), self.scan_sat.polarization))
389 if self.scan_sat.system.value == "dvb-s":
390 self.list.append(getConfigListEntry(_("FEC"), self.scan_sat.fec))
391 elif self.scan_sat.system.value == "dvb-s2":
392 self.list.append(getConfigListEntry(_("FEC"), self.scan_sat.fec_s2))
393 self.modulationEntry = getConfigListEntry(_('Modulation'), self.scan_sat.modulation)
394 self.list.append(self.modulationEntry)
395 self.list.append(getConfigListEntry(_('Rolloff'), self.scan_sat.rolloff))
396 if self.scan_sat.modulation.value == "8psk":
397 self.list.append(getConfigListEntry(_('Pilot'), self.scan_sat.pilot))
398 self.list.append(getConfigListEntry(_("Network scan"), self.scan_networkScan))
399 elif self.scan_type.value == "single_satellite":
401 print self.scan_satselection[index_to_scan]
402 self.list.append(getConfigListEntry(_("Satellite"), self.scan_satselection[index_to_scan]))
403 self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
404 elif self.scan_type.value == "multisat":
407 SatList = nimmanager.getSatListForNim(index_to_scan)
408 self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
410 if self.Satexists(tlist, x[0]) == 0:
412 sat = ConfigEnableDisable(default = True)
413 configEntry = getConfigListEntry(nimmanager.getSatDescription(x[0]), sat)
414 self.list.append(configEntry)
415 self.multiscanlist.append((x[0], sat))
417 # for sat in nimmanager.satList:
418 # self.list.append(getConfigListEntry(sat[1], self.scan_scansat[sat[0]]))
419 elif nim.isCompatible("DVB-C"):
420 if self.scan_typecable.value == "single_transponder":
421 self.list.append(getConfigListEntry(_("Frequency"), self.scan_cab.frequency))
422 self.list.append(getConfigListEntry(_("Inversion"), self.scan_cab.inversion))
423 self.list.append(getConfigListEntry(_("Symbol Rate"), self.scan_cab.symbolrate))
424 self.list.append(getConfigListEntry(_("Modulation"), self.scan_cab.modulation))
425 self.list.append(getConfigListEntry(_("FEC"), self.scan_cab.fec))
426 self.list.append(getConfigListEntry(_("Network scan"), self.scan_networkScan))
427 elif self.scan_typecable.value == "complete":
428 self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
429 elif nim.isCompatible("DVB-T"):
430 if self.scan_typeterrestrial.value == "single_transponder":
431 self.list.append(getConfigListEntry(_("Frequency"), self.scan_ter.frequency))
432 self.list.append(getConfigListEntry(_("Inversion"), self.scan_ter.inversion))
433 self.list.append(getConfigListEntry(_("Bandwidth"), self.scan_ter.bandwidth))
434 self.list.append(getConfigListEntry(_("Code rate high"), self.scan_ter.fechigh))
435 self.list.append(getConfigListEntry(_("Code rate low"), self.scan_ter.feclow))
436 self.list.append(getConfigListEntry(_("Modulation"), self.scan_ter.modulation))
437 self.list.append(getConfigListEntry(_("Transmission mode"), self.scan_ter.transmission))
438 self.list.append(getConfigListEntry(_("Guard interval mode"), self.scan_ter.guard))
439 self.list.append(getConfigListEntry(_("Hierarchy mode"), self.scan_ter.hierarchy))
440 self.list.append(getConfigListEntry(_("Network scan"), self.scan_networkScan))
441 elif self.scan_typeterrestrial.value == "complete":
442 self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
444 # if (nim.isCompatible("DVB-S") and self.scan_type.type == "single_transponder") or \
445 # (nim.isCompatbile("DVB-C") and self.scan_typecable.type == "single_transponder") or \
446 # (nim.isCompatible("DVB-T") and self.scan_typeterrestrial.type == "single_transponder"):
447 # self.configElementSNR = getConfigListEntry(_("SNR"), self.scan_snr)
448 # self.list.append(self.configElementSNR)
449 # self.configElementACG = getConfigListEntry(_("AGC"), self.scan_agc)
450 # self.list.append(self.configElementACG)
451 # self.configElementBER = getConfigListEntry(_("BER"), self.scan_ber)
452 # self.list.append(self.configElementBER)
453 # self.statusTimer.start(500, False)
455 # self.statusTimer.stop()
457 self["config"].list = self.list
458 self["config"].l.setList(self.list)
460 def Satexists(self, tlist, pos):
467 cur = self["config"].getCurrent()
469 if cur == self.typeOfScanEntry or \
470 cur == self.tunerEntry or \
471 cur == self.systemEntry or \
472 (self.modulationEntry and self.systemEntry[1].value == "dvb-s2" and cur == self.modulationEntry):
475 def createConfig(self, frontendData):
476 #("Type", frontendData["system"], TYPE_TEXT),
477 #("Modulation", frontendData["modulation"], TYPE_TEXT),
478 #("Orbital position", frontendData["orbital_position"], TYPE_VALUE_DEC),
479 #("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
480 #("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC),
481 #("Polarization", frontendData["polarization"], TYPE_TEXT),
482 #("Inversion", frontendData["inversion"], TYPE_TEXT),
483 #("FEC inner", frontendData["fec_inner"], TYPE_TEXT),
485 #elif frontendData["tuner_type"] == "DVB-C":
486 #return ( ("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
487 #("Type", frontendData["tuner_type"], TYPE_TEXT),
488 #("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
489 #("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC),
490 #("Modulation", frontendData["modulation"], TYPE_TEXT),
491 #("Inversion", frontendData["inversion"], TYPE_TEXT),
492 # ("FEC inner", frontendData["fec_inner"], TYPE_TEXT),
494 #elif frontendData["tuner_type"] == "DVB-T":
495 #return ( ("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
496 #("Type", frontendData["tuner_type"], TYPE_TEXT),
497 #("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
498 #("Inversion", frontendData["inversion"], TYPE_TEXT),
499 #("Bandwidth", frontendData["bandwidth"], TYPE_VALUE_DEC),
500 #("CodeRateLP", frontendData["code_rate_lp"], TYPE_TEXT),
501 #("CodeRateHP", frontendData["code_rate_hp"], TYPE_TEXT),
502 #("Constellation", frontendData["constellation"], TYPE_TEXT),
503 #("Transmission Mode", frontendData["transmission_mode"], TYPE_TEXT),
504 #("Guard Interval", frontendData["guard_interval"], TYPE_TEXT),
505 #("Hierarchy Inform.", frontendData["hierarchy_information"], TYPE_TEXT),
506 defaultSat = { "orbpos": 192, "system": "dvb-s", "frequency": 11836, "inversion": "auto", "symbolrate": 27500, "polarization": "horizontal", "fec": "auto", "fec_s2": "9_10", "modulation": "qpsk" }
507 defaultCab = {"frequency": 466, "inversion": "auto", "modulation": "64qam", "fec": "auto", "symbolrate": 6900}
508 if frontendData is not None:
509 ttype = frontendData.get("tuner_type", "UNKNOWN")
511 defaultSat["system"] = {"DVB-S": "dvb-s", "DVB-S2": "dvb-s2"}[frontendData.get("system", "DVB-S")]
512 defaultSat["frequency"] = int(frontendData.get("frequency", 0) / 1000)
513 defaultSat["inversion"] = {"INVERSION_OFF": "off", "INVERSION_ON": "on", "INVERSION_AUTO": "auto"}[frontendData.get("inversion", "INVERSION_AUTO")]
514 defaultSat["symbolrate"] = int(frontendData.get("symbol_rate", 0) / 1000)
515 defaultSat["polarization"] = {"HORIZONTAL": "horizontal", "VERTICAL": "vertical", "CIRCULAR_LEFT": "circular_left", "CIRCULAR_RIGHT": "circular_right", "UNKNOWN": None}[frontendData.get("polarization", "HORIZONTAL")]
517 if frontendData.get("system", "DVB-S") == "DVB-S2":
518 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"} \
519 [frontendData.get("fec_inner", "FEC_AUTO")]
520 defaultSat["rolloff"] = {"ROLLOFF_0_35" : "0_35", "ROLLOFF_0_25" : "0_25", "ROLLOFF_0_20" : "0_20"}[frontendData.get("rolloff", "ROLLOFF_0_35")]
521 defaultSat["pilot"] = {"PILOT_ON" : "on", "PILOT_OFF" : "off", "PILOT_AUTO" : "auto"}[frontendData.get("pilot", "PILOT_AUTO")]
523 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"} \
524 [frontendData.get("fec_inner", "FEC_AUTO")]
526 defaultSat["modulation"] = {"QPSK": "qpsk", "8PSK": "8psk"}[frontendData.get("modulation", "QPSK")]
527 defaultSat["orbpos"] = frontendData.get("orbital_position", 0)
528 elif ttype == "DVB-C":
529 defaultCab["frequency"] = int(frontendData.get("frequency", 0) / 1000)
530 defaultCab["symbolrate"] = int(frontendData.get("symbol_rate", 0) / 1000)
531 defaultCab["inversion"] = {"INVERSION_OFF": "off", "INVERSION_ON": "on", "INVERSION_AUTO": "auto"}[frontendData.get("inversion", "INVERSION_AUTO")]
532 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")]
533 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")]
535 self.scan_sat = ConfigSubsection()
536 self.scan_cab = ConfigSubsection()
537 self.scan_ter = ConfigSubsection()
539 self.scan_type = ConfigSelection(default = "single_transponder", choices = [("single_transponder", _("Single transponder")), ("single_satellite", _("Single satellite")), ("multisat", _("Multisat"))])
540 self.scan_typecable = ConfigSelection(default = "single_transponder", choices = [("single_transponder", _("Single transponder")), ("complete", _("Complete"))])
541 self.scan_typeterrestrial = ConfigSelection(default = "single_transponder", choices = [("single_transponder", _("Single transponder")), ("complete", _("Complete"))])
542 self.scan_clearallservices = ConfigSelection(default = "no", choices = [("no", _("no")), ("yes", _("yes")), ("yes_hold_feeds", _("yes (keep feeds)"))])
543 self.scan_networkScan = ConfigYesNo(default = False)
546 # collect all nims which are *not* set to "nothing"
547 for n in nimmanager.nim_slots:
548 if n.config_mode != "nothing":
549 nim_list.append((str(n.slot), n.friendly_full_description))
551 self.scan_nims = ConfigSelection(choices = nim_list)
554 self.scan_snr = ConfigSlider()
555 self.scan_snr.enabled = False
556 self.scan_agc = ConfigSlider()
557 self.scan_agc.enabled = False
558 self.scan_ber = ConfigSlider()
559 self.scan_ber.enabled = False
562 self.scan_sat.system = ConfigSelection(default = defaultSat["system"], choices = [("dvb-s", _("DVB-S")), ("dvb-s2", _("DVB-S2"))])
563 self.scan_sat.frequency = ConfigInteger(default = defaultSat["frequency"], limits = (1, 99999))
564 self.scan_sat.inversion = ConfigSelection(default = defaultSat["inversion"], choices = [("off", _("off")), ("on", _("on")), ("auto", _("Auto"))])
565 self.scan_sat.symbolrate = ConfigInteger(default = defaultSat["symbolrate"], limits = (1, 99999))
566 self.scan_sat.polarization = ConfigSelection(default = defaultSat["polarization"], choices = [("horizontal", _("horizontal")), ("vertical", _("vertical")), ("circular_left", _("circular left")), ("circular_right", _("circular right"))])
567 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"))])
568 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")])
569 self.scan_sat.modulation = ConfigSelection(default = defaultSat["modulation"], choices = [("qpsk", "QPSK"), ("8psk", "8PSK")])
570 self.scan_sat.rolloff = ConfigSelection(default = defaultSat.get("rolloff", "0_35"), choices = [("0_35", "0.35"), ("0_25", "0.25"), ("0_20", "0.20")])
571 self.scan_sat.pilot = ConfigSelection(default = defaultSat.get("pilot", "auto"), choices = [("off", _("off")), ("on", _("on")), ("auto", _("Auto"))])
574 self.scan_cab.frequency = ConfigInteger(default = defaultCab["frequency"], limits = (50, 999))
575 self.scan_cab.inversion = ConfigSelection(default = defaultCab["inversion"], choices = [("off", _("off")), ("on", _("on")), ("auto", _("Auto"))])
576 self.scan_cab.modulation = ConfigSelection(default = defaultCab["modulation"], choices = [("16qam", "16-QAM"), ("32qam", "32-QAM"), ("64qam", "64-QAM"), ("128qam", "128-QAM"), ("256qam", "256-QAM")])
577 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"))])
578 self.scan_cab.symbolrate = ConfigInteger(default = defaultCab["symbolrate"], limits = (1, 99999))
581 self.scan_ter.frequency = ConfigInteger(default = 466000, limits = (50000, 999000))
582 self.scan_ter.inversion = ConfigSelection(default = "auto", choices = [("off", _("off")), ("on", _("on")), ("auto", _("Auto"))])
583 # WORKAROUND: we can't use BW-auto
584 self.scan_ter.bandwidth = ConfigSelection(default = "8MHz", choices = [("8MHz", "8MHz"), ("7MHz", "7MHz"), ("6MHz", "6MHz")])
585 #, ("auto", _("Auto"))))
586 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"))])
587 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"))])
588 self.scan_ter.modulation = ConfigSelection(default = "auto", choices = [("qpsk", "QPSK"), ("qam16", "QAM16"), ("qam64", "QAM64"), ("auto", _("Auto"))])
589 self.scan_ter.transmission = ConfigSelection(default = "auto", choices = [("2k", "2K"), ("8k", "8K"), ("auto", _("Auto"))])
590 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"))])
591 self.scan_ter.hierarchy = ConfigSelection(default = "auto", choices = [("none", _("None")), ("1", "1"), ("2", "2"), ("4", "4"), ("auto", _("Auto"))])
593 self.scan_scansat = {}
594 for sat in nimmanager.satList:
596 self.scan_scansat[sat[0]] = ConfigYesNo(default = False)
598 self.scan_satselection = []
599 for slot in nimmanager.nim_slots:
600 if slot.isCompatible("DVB-S"):
601 self.scan_satselection.append(getConfigSatlist(int(defaultSat["orbpos"]), self.satList[slot.slot]))
603 self.scan_satselection.append(None)
608 ConfigListScreen.keyLeft(self)
612 ConfigListScreen.keyRight(self)
615 def updateStatus(self):
618 fecmap = { "auto": 0,
631 def addSatTransponder(self, tlist, frequency, symbol_rate, polarisation, fec, inversion, orbital_position, system, modulation, rolloff, pilot):
632 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)
633 print "orbpos: " + str(orbital_position)
634 parm = eDVBFrontendParametersSatellite()
636 parm.modulation = 2 # eDVBFrontendParametersSatellite.Modulation.8PSK
638 parm.modulation = 1 # eDVBFrontendParametersSatellite.Modulation.QPSK
640 parm.frequency = frequency * 1000
641 parm.symbol_rate = symbol_rate * 1000
642 parm.polarisation = polarisation
643 parm.fec = self.fecmap[fec]
644 parm.inversion = inversion
645 parm.orbital_position = int(orbital_position)
646 parm.rolloff = int(rolloff)
647 parm.pilot = int(pilot)
650 def addCabTransponder(self, tlist, frequency, symbol_rate, modulation, fec, inversion):
651 print "Add Cab: frequ: " + str(frequency) + " symbol: " + str(symbol_rate) + " pol: " + str(modulation) + " fec: " + str(fec) + " inversion: " + str(inversion)
652 parm = eDVBFrontendParametersCable()
653 parm.frequency = frequency * 1000
654 parm.symbol_rate = symbol_rate * 1000
655 parm.modulation = modulation
656 parm.fec = self.fecmap[fec]
657 parm.inversion = inversion
660 def addTerTransponder(self, tlist, *args, **kwargs):
661 tlist.append(buildTerTransponder(*args, **kwargs))
669 index_to_scan = int(self.scan_nims.value)
671 if self.scan_nims == [ ]:
672 self.session.open(MessageBox, _("No tuner is enabled!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
675 nim = nimmanager.nim_slots[index_to_scan]
676 print "nim", nim.slot
677 if nim.isCompatible("DVB-S"):
678 print "is compatible with DVB-S"
679 if self.scan_type.value == "single_transponder":
680 # these lists are generated for each tuner, so this has work.
681 assert len(self.satList) > index_to_scan
682 assert len(self.scan_satselection) > index_to_scan
684 nimsats = self.satList[index_to_scan]
685 selsatidx = self.scan_satselection[index_to_scan].index
687 # however, the satList itself could be empty. in that case, "index" is 0 (for "None").
689 orbpos = nimsats[selsatidx][0]
690 if self.scan_sat.system.value == "dvb-s":
691 fec = self.scan_sat.fec.value
693 fec = self.scan_sat.fec_s2.value
694 print "add sat transponder"
695 self.addSatTransponder(tlist, self.scan_sat.frequency.value,
696 self.scan_sat.symbolrate.value,
697 self.scan_sat.polarization.index,
699 self.scan_sat.inversion.index,
701 self.scan_sat.system.index,
702 self.scan_sat.modulation.index,
703 self.scan_sat.rolloff.index,
704 self.scan_sat.pilot.index)
705 flags = self.scan_networkScan.value and eComponentScan.scanNetworkSearch or 0
707 elif self.scan_type.value == "single_satellite":
708 sat = self.satList[index_to_scan][self.scan_satselection[index_to_scan].index]
709 getInitialTransponderList(tlist, sat[0])
710 elif self.scan_type.value == "multisat":
711 SatList = nimmanager.getSatListForNim(index_to_scan)
712 for x in self.multiscanlist:
714 print " " + str(x[0])
715 getInitialTransponderList(tlist, x[0])
717 elif nim.isCompatible("DVB-C"):
718 if self.scan_typecable.value == "single_transponder":
719 fec = self.scan_cab.fec.value
720 self.addCabTransponder(tlist, self.scan_cab.frequency.value,
721 self.scan_cab.symbolrate.value,
722 self.scan_cab.modulation.index + 1,
724 self.scan_cab.inversion.index)
725 flags = self.scan_networkScan.value and eComponentScan.scanNetworkSearch or 0
727 elif self.scan_typecable.value == "complete":
728 if config.Nims[index_to_scan].cable.scan_type.value == "provider":
729 getInitialCableTransponderList(tlist, index_to_scan)
733 elif nim.isCompatible("DVB-T"):
734 if self.scan_typeterrestrial.value == "single_transponder":
735 self.addTerTransponder(tlist,
736 self.scan_ter.frequency.value * 1000,
737 inversion = self.scan_ter.inversion.index,
738 bandwidth = self.scan_ter.bandwidth.index,
739 fechigh = self.scan_ter.fechigh.index,
740 feclow = self.scan_ter.feclow.index,
741 modulation = self.scan_ter.modulation.index,
742 transmission = self.scan_ter.transmission.index,
743 guard = self.scan_ter.guard.index,
744 hierarchy = self.scan_ter.hierarchy.index)
745 flags = self.scan_networkScan.value and eComponentScan.scanNetworkSearch or 0
747 elif self.scan_typeterrestrial.value == "complete":
748 getInitialTerrestrialTransponderList(tlist, nimmanager.getTerrestrialDescription(index_to_scan))
751 flags = eComponentScan.scanNetworkSearch
754 tmp = self.scan_clearallservices.value
756 flags |= eComponentScan.scanRemoveServices
757 elif tmp == "yes_hold_feeds":
758 flags |= eComponentScan.scanRemoveServices
759 flags |= eComponentScan.scanDontRemoveFeeds
761 for x in self["config"].list:
765 self.startScan(tlist, flags, index_to_scan)
768 self.feid = index_to_scan
770 self.startCableTransponderSearch(self.feid)
772 def setCableTransponderSearchResult(self, tlist):
775 def cableTransponderSearchFinished(self):
776 self.startScan(self.tlist, self.flags, self.feid)
778 def startScan(self, tlist, flags, feid):
780 # flags |= eComponentScan.scanSearchBAT
782 self.session.openWithCallback(self.finished_cb, ServiceScan, [{"transponders": tlist, "feid": feid, "flags": flags}])
784 self.session.open(ServiceScan, [{"transponders": tlist, "feid": feid, "flags": flags}])
787 self.session.openWithCallback(self.finished_cb, MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
789 self.session.open(MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
792 for x in self["config"].list:
796 class ScanSimple(ConfigListScreen, Screen, CableTransponderSearchSupport):
797 def getNetworksForNim(self, nim):
798 if nim.isCompatible("DVB-S"):
799 networks = nimmanager.getSatListForNim(nim.slot)
800 # the original code took "loopthrough" etc. into account. Do we need this?
801 # if nimmanager.getNimConfigMode(1) in ["loopthrough", "satposdepends", "equal", "nothing"]:
803 # sec = eDVBSatelliteEquipmentControl.getInstance()
804 # if sec is not None:
805 # exclusive_satellites = sec.get_exclusive_satellites(0,1)
806 # if len(exclusive_satellites) == 2:
808 # idx = exclusive_satellites[0]+1
809 # exclusive_nim_sats = exclusive_satellites[idx+1:idx+1+exclusive_satellites[idx]]
810 # if len(exclusive_nim_sats):
813 networks = [ nim.type ] # "DVB-C" or "DVB-T". TODO: seperate networks for different C/T tuners, if we want to support that.
815 # empty tuners provide no networks.
819 def __init__(self, session):
820 Screen.__init__(self, session)
822 self["actions"] = ActionMap(["SetupActions"],
825 "cancel": self.keyCancel,
833 self.finished_cb = None
835 for nim in nimmanager.nim_slots:
836 # collect networks provided by this tuner
839 networks = self.getNetworksForNim(nim)
841 print "nim %d provides" % nim.slot, networks
842 print "known:", known_networks
844 # we only need to scan on the first tuner which provides a network.
845 # this gives the first tuner for each network priority for scanning.
847 if x not in known_networks:
849 print x, "not in ", known_networks
850 known_networks.append(x)
853 nims_to_scan.append(nim)
855 # we save the config elements to use them on keyGo
856 self.nim_enable = [ ]
858 if len(nims_to_scan):
859 self.scan_clearallservices = ConfigSelection(default = "yes", choices = [("no", _("no")), ("yes", _("yes")), ("yes_hold_feeds", _("yes (keep feeds)"))])
860 self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
862 for nim in nims_to_scan:
863 nimconfig = ConfigYesNo(default = True)
864 nimconfig.nim_index = nim.slot
865 self.nim_enable.append(nimconfig)
866 self.list.append(getConfigListEntry(_("Scan ") + nim.slot_name + " (" + nim.friendly_type + ")", nimconfig))
868 ConfigListScreen.__init__(self, self.list)
869 self["header"] = Label(_("Automatic Scan"))
870 self["footer"] = Label(_("Press OK to scan"))
872 def runAsync(self, finished_cb):
873 self.finished_cb = finished_cb
878 self.known_networks = set()
880 self.buildTransponderList()
882 def buildTransponderList(self): # this method is called multiple times because of asynchronous stuff
884 SEARCH_CABLE_TRANSPONDERS = 1
887 n = self.nim_iter < len(self.nim_enable) and self.nim_enable[self.nim_iter] or None
890 if n.value: # check if nim is enabled
892 nim = nimmanager.nim_slots[n.nim_index]
893 networks = set(self.getNetworksForNim(nim))
895 # don't scan anything twice
896 networks.discard(self.known_networks)
899 if nim.isCompatible("DVB-S"):
900 # get initial transponders for each satellite to be scanned
902 getInitialTransponderList(tlist, sat[0])
903 elif nim.isCompatible("DVB-C"):
904 if config.Nims[nim.slot].cable.scan_type.value == "provider":
905 getInitialCableTransponderList(tlist, nim.slot)
907 action = SEARCH_CABLE_TRANSPONDERS
908 elif nim.isCompatible("DVB-T"):
909 getInitialTerrestrialTransponderList(tlist, nimmanager.getTerrestrialDescription(nim.slot))
913 flags |= eComponentScan.scanNetworkSearch #FIXMEEE.. use flags from cables / satellites / terrestrial.xml
914 tmp = self.scan_clearallservices.value
916 flags |= eComponentScan.scanRemoveServices
917 elif tmp == "yes_hold_feeds":
918 flags |= eComponentScan.scanRemoveServices
919 flags |= eComponentScan.scanDontRemoveFeeds
921 if action == APPEND_NOW:
922 self.scanList.append({"transponders": tlist, "feid": nim.slot, "flags": flags})
923 elif action == SEARCH_CABLE_TRANSPONDERS:
926 self.startCableTransponderSearch(nim.slot)
931 self.buildTransponderList() # recursive call of this function !!!
933 # when we are here, then the recursion is finished and all enabled nims are checked
934 # so we now start the real transponder scan
935 self.startScan(self.scanList)
937 def startScan(self, scanList):
940 self.session.openWithCallback(self.finished_cb, ServiceScan, scanList = scanList)
942 self.session.open(ServiceScan, scanList = scanList)
945 self.session.openWithCallback(self.finished_cb, MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
947 self.session.open(MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
949 def setCableTransponderSearchResult(self, tlist):
950 self.scanList.append({"transponders": tlist, "feid": self.feid, "flags": self.flags})
952 def cableTransponderSearchFinished(self):
953 self.buildTransponderList()
958 def Satexists(self, tlist, pos):