1 from Screen import Screen
2 from ServiceScan import *
3 from Components.config import *
4 from Components.ActionMap import NumberActionMap
5 from Components.ConfigList import ConfigList
6 from Components.NimManager import nimmanager
7 from Components.Label import Label
8 from enigma import eDVBFrontendParametersSatellite, eComponentScan, eDVBSatelliteEquipmentControl
10 def getInitialTransponderList(tlist, pos):
11 list = nimmanager.getTransponders(pos)
15 parm = eDVBFrontendParametersSatellite()
17 parm.symbol_rate = x[2]
18 parm.polarisation = x[3]#lookup_sat_polarisation[x[3]] # eDVBFrontendParametersSatellite.Polarisation.Vertical
19 parm.fec = x[4] # eDVBFrontendParametersSatellite.FEC.f3_4;
21 #parm.inversion = 1 #eDVBFrontendParametersSatellite.Inversion.Off;
22 parm.inversion = 2 #AUTO
23 parm.orbital_position = pos
26 def getInitialCableTransponderList(tlist, cable):
27 list = nimmanager.getTranspondersCable(cable)
31 parm = eDVBFrontendParametersCable()
33 parm.symbol_rate = x[2]
34 parm.modulation = x[3] # AUTO
35 parm.fec_inner = x[4] # AUTO
36 parm.inversion = 2 # AUTO
39 class ScanSetup(Screen):
40 def __init__(self, session):
41 Screen.__init__(self, session)
47 self["actions"] = NumberActionMap(["SetupActions"],
50 "cancel": self.keyCancel,
52 "right": self.keyRight,
53 "1": self.keyNumberGlobal,
54 "2": self.keyNumberGlobal,
55 "3": self.keyNumberGlobal,
56 "4": self.keyNumberGlobal,
57 "5": self.keyNumberGlobal,
58 "6": self.keyNumberGlobal,
59 "7": self.keyNumberGlobal,
60 "8": self.keyNumberGlobal,
61 "9": self.keyNumberGlobal,
62 "0": self.keyNumberGlobal
65 self.statusTimer = eTimer()
66 self.statusTimer.timeout.get().append(self.updateStatus)
67 #self.statusTimer.start(5000, True)
70 self["config"] = ConfigList(self.list)
73 self["introduction"] = Label(_("Press OK to start the scan"))
78 def updateSatList(self):
80 for slot in nimmanager.nimslots:
81 if (nimmanager.getNimType(slot.slotid) == nimmanager.nimType["DVB-S"]):
82 self.satList.append(nimmanager.getSatListForNim(slot.slotid))
84 self.satList.append(None)
86 def createSetup(self):
88 self.multiscanlist = []
89 print "ID: " + str(config.scan.nims.value)
91 self.tunerEntry = getConfigListEntry(_("Tuner"), config.scan.nims)
92 self.list.append(self.tunerEntry)
94 self.typeOfScanEntry = None
95 if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-S"]):
96 self.typeOfScanEntry = getConfigListEntry(_("Type of scan"), config.scan.type)
97 self.list.append(self.typeOfScanEntry)
98 elif (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-C"]):
99 self.typeOfScanEntry = getConfigListEntry(_("Type of scan"), config.scan.typecable)
100 self.list.append(self.typeOfScanEntry)
101 elif (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-T"]):
102 self.typeOfScanEntry = getConfigListEntry(_("Type of scan"), config.scan.typeterrestrial)
103 self.list.append(self.typeOfScanEntry)
106 if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-S"]):
108 if currentConfigSelectionElement(config.scan.type) == "single_transponder":
109 self.list.append(getConfigListEntry(_('Satellite'), config.scan.satselection[config.scan.nims.value]))
110 self.list.append(getConfigListEntry(_('Frequency'), config.scan.sat.frequency))
111 self.list.append(getConfigListEntry(_('Inversion'), config.scan.sat.inversion))
112 self.list.append(getConfigListEntry(_('Symbol Rate'), config.scan.sat.symbolrate))
113 self.list.append(getConfigListEntry(_("Polarity"), config.scan.sat.polarization))
114 self.list.append(getConfigListEntry(_("FEC"), config.scan.sat.fec))
115 elif currentConfigSelectionElement(config.scan.type) == "single_satellite":
117 print config.scan.satselection[config.scan.nims.value]
118 self.list.append(getConfigListEntry(_("Satellite"), config.scan.satselection[config.scan.nims.value]))
119 elif currentConfigSelectionElement(config.scan.type) == "multisat":
122 SatList = nimmanager.getSatListForNim(config.scan.nims.value)
125 if self.Satexists(tlist, x[1]) == 0:
127 sat = configElement_nonSave(x[1], configSelection, 0, (("enable", _("Enable")), ("disable", _("Disable"))))
128 configEntry = getConfigListEntry(nimmanager.getSatDescription(x[1]), sat)
129 self.list.append(configEntry)
130 self.multiscanlist.append(configEntry)
132 # for sat in nimmanager.satList:
133 # self.list.append(getConfigListEntry(sat[0], config.scan.scansat[sat[1]]))
136 if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-C"]):
137 if currentConfigSelectionElement(config.scan.typecable) == "single_transponder":
138 self.list.append(getConfigListEntry(_("Frequency"), config.scan.cab.frequency))
139 self.list.append(getConfigListEntry(_("Inversion"), config.scan.cab.inversion))
140 self.list.append(getConfigListEntry(_("Symbol Rate"), config.scan.cab.symbolrate))
141 self.list.append(getConfigListEntry(_("Modulation"), config.scan.cab.modulation))
142 self.list.append(getConfigListEntry(_("FEC"), config.scan.cab.fec))
143 self.list.append(getConfigListEntry(_("Network scan"), config.scan.cab.networkScan))
144 elif currentConfigSelectionElement(config.scan.typecable) == "complete":
147 if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-T"]):
148 if currentConfigSelectionElement(config.scan.typeterrestrial) == "single_transponder":
149 self.list.append(getConfigListEntry(_("Frequency"), config.scan.ter.frequency))
150 self.list.append(getConfigListEntry(_("Inversion"), config.scan.ter.inversion))
151 self.list.append(getConfigListEntry(_("Bandwidth"), config.scan.ter.bandwidth))
152 self.list.append(getConfigListEntry(_("Code rate high"), config.scan.ter.fechigh))
153 self.list.append(getConfigListEntry(_("Code rate low"), config.scan.ter.feclow))
154 self.list.append(getConfigListEntry(_("Modulation"), config.scan.ter.modulation))
155 self.list.append(getConfigListEntry(_("Transmission mode"), config.scan.ter.transmission))
156 self.list.append(getConfigListEntry(_("Guard interval mode"), config.scan.ter.guard))
157 self.list.append(getConfigListEntry(_("Hierarchy mode"), config.scan.ter.hierarchy))
158 elif currentConfigSelectionElement(config.scan.typeterrestrial) == "complete":
161 if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-S"] and currentConfigSelectionElement(config.scan.type) == "single_transponder") or \
162 (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-C"] and currentConfigSelectionElement(config.scan.typecable) == "single_transponder") or \
163 (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-T"] and currentConfigSelectionElement(config.scan.typeterrestrial) == "single_transponder"):
164 self.configElementSNR = getConfigListEntry(_("SNR"), config.scan.snr)
165 self.list.append(self.configElementSNR)
166 self.configElementACG = getConfigListEntry(_("AGC"), config.scan.agc)
167 self.list.append(self.configElementACG)
168 self.configElementBER = getConfigListEntry(_("BER"), config.scan.ber)
169 self.list.append(self.configElementBER)
170 self.statusTimer.start(500, False)
172 self.statusTimer.stop()
174 self["config"].list = self.list
175 self["config"].l.setList(self.list)
177 def Satexists(self, tlist, pos):
184 print self["config"].getCurrent()
185 if self["config"].getCurrent() == self.typeOfScanEntry:
187 if self["config"].getCurrent() == self.tunerEntry:
190 def createConfig(self):
191 config.scan = ConfigSubsection()
192 config.scan.sat = ConfigSubsection()
193 config.scan.cab = ConfigSubsection()
194 config.scan.ter = ConfigSubsection()
196 config.scan.type = configElement_nonSave("config.scan.type", configSelection, 0, (("single_transponder", _("Single transponder")), ("single_satellite", _("Single satellite")), ("multisat", _("Multisat"))))
197 config.scan.typecable = configElement_nonSave("config.scan.typecable", configSelection, 0, (("single_transponder", _("Single transponder")), ("complete", _("Complete"))))
198 config.scan.typeterrestrial = configElement_nonSave("config.scan.typeterrestrial", configSelection, 0, (("single_transponder", _("Single transponder")), ("complete", _("Complete"))))
201 for nim in nimmanager.nimList():
202 nimList.append(nim[0])
203 #nimList.append("all")
204 config.scan.nims = configElement_nonSave("config.scan.nims", configSelection, 0, nimList)
207 config.scan.snr = configElement_nonSave("config.scan.snr", configSlider, 0, (1, 100))
208 config.scan.snr.enabled = False
209 config.scan.agc = configElement_nonSave("config.scan.agc", configSlider, 0, (1, 100))
210 config.scan.agc.enabled = False
211 config.scan.ber = configElement_nonSave("config.scan.ber", configSlider, 0, (1, 100))
212 config.scan.ber.enabled = False
215 config.scan.sat.frequency = configElement_nonSave("config.scan.sat.frequency", configSequence, [11836], configsequencearg.get("INTEGER", (1, 99999)))
216 config.scan.sat.inversion = configElement_nonSave("config.scan.sat.inversion", configSelection, 2, (("off", _("off")), ("on", _("on")), _("Auto")))
217 config.scan.sat.symbolrate = configElement_nonSave("config.scan.sat.symbolrate", configSequence, [27500], configsequencearg.get("INTEGER", (1, 99999)))
218 config.scan.sat.polarization = configElement_nonSave("config.scan.sat.polarization", configSelection, 0, (("horizontal", _("horizontal")), ("vertical", _("vertical")), ("circular_left", _("circular left")), ("circular_right", _("circular right"))))
219 config.scan.sat.fec = configElement_nonSave("config.scan.sat.fec", configSelection, 7, (("auto", _("Auto")), ("1_2", "1/2"), ("2_3", "2/3"), ("3_4", "3/4"), ("5_6", "5/6"), ("7_8", "7/8"), ("none", _("None"))))
222 config.scan.cab.frequency = configElement_nonSave("config.scan.cab.frequency", configSequence, [466], configsequencearg.get("INTEGER", (50, 999)))
223 config.scan.cab.inversion = configElement_nonSave("config.scan.cab.inversion", configSelection, 2, (("off", _("off")), ("on", _("on")), ("auto", _("Auto"))))
224 config.scan.cab.modulation = configElement_nonSave("config.scan.cab.modulation", configSelection, 0, (("auto", _("Auto")), ("16qam", "16-QAM"), ("32qam", "32-QAM"), ("64qam", "64-QAM"), ("128qam", "128-QAM"), ("256qam", "256-QAM")))
225 config.scan.cab.fec = configElement_nonSave("config.scan.cab.fec", configSelection, 0, (("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"))))
226 config.scan.cab.symbolrate = configElement_nonSave("config.scan.cab.symbolrate", configSequence, [6900], configsequencearg.get("INTEGER", (1, 9999)))
227 config.scan.cab.networkScan = configElement_nonSave("config.scan.cab.networkScan", configSelection, 0, (("no", _("no")), ("yes", _("yes"))))
230 config.scan.ter.frequency = configElement_nonSave("config.scan.ter.frequency", configSequence, [466], configsequencearg.get("INTEGER", (100, 900)))
231 config.scan.ter.inversion = configElement_nonSave("config.scan.ter.inversion", configSelection, 2, (("off", _("off")), ("on", _("on")), ("auto", _("Auto"))))
232 config.scan.ter.bandwidth = configElement_nonSave("config.scan.ter.bandwidth", configSelection, 3, (("8MHz", "8MHz"), ("7MHz", "7MHz"), ("6MHz", "6MHz"), ("auto", _("Auto"))))
233 config.scan.ter.fechigh = configElement_nonSave("config.scan.ter.fechigh", configSelection, 6, (("none", _("None")), "1/2", "2/3", "3/4", "5/6", "7/8", _("Auto")))
234 config.scan.ter.feclow = configElement_nonSave("config.scan.ter.feclow", configSelection, 6, (_("None"), ("1_2", "1/2"), ("2_3", "2/3"), ("3_4", "3/4"), ("5_6", "5/6"), ("7_8", "7/8"), ("auto", _("Auto"))))
235 config.scan.ter.modulation = configElement_nonSave("config.scan.ter.modulation", configSelection, 2, (("qpsk", "QPSK"), ("qam16", "QAM16"), ("auto", _("Auto"))))
236 config.scan.ter.transmission = configElement_nonSave("config.scan.ter.transmission", configSelection, 2, (("2k", "2K"), ("8k", "8K"), ("auto", _("Auto"))))
237 config.scan.ter.guard = configElement_nonSave("config.scan.ter.guard", configSelection, 4, (("1_32", "1/32"), ("1_16", "1/16"), ("1_8", "1/8"), ("1_4", "1/4"), ("auto", _("Auto"))))
238 config.scan.ter.hierarchy = configElement_nonSave("config.scan.ter.hierarchy", configSelection, 4, (("none", _("None")), ("1", "1"), ("2", "2"), ("4", "4"), ("auto", _("Auto"))))
240 config.scan.scansat = {}
241 for sat in nimmanager.satList:
243 config.scan.scansat[sat[1]] = configElement_nonSave("config.scan.scansat[" + str(sat[1]) + "]", configSelection, 0, (("yes", _("yes")), ("no", _("no"))))
245 config.scan.satselection = []
247 for slot in nimmanager.nimslots:
248 if (nimmanager.getNimType(slot.slotid) == nimmanager.nimType["DVB-S"]):
249 print str(slot.slotid) + " : " + str(self.satList)
250 config.scan.satselection.append(configElement_nonSave("config.scan.satselection[" + str(slot.slotid) + "]", configSatlist, 0, self.satList[slot.slotid]))
252 config.scan.satselection.append(None)
254 self["config"].handleKey(config.key["prevElement"])
258 self["config"].handleKey(config.key["nextElement"])
261 def updateStatus(self):
264 def keyNumberGlobal(self, number):
265 print "You pressed number " + str(number)
266 if (self["config"].getCurrent()[1].parent.enabled == True):
267 self["config"].handleKey(config.key[str(number)])
269 def addSatTransponder(self, tlist, frequency, symbol_rate, polarisation, fec, inversion, orbital_position):
270 print "Add Sat: frequ: " + str(frequency) + " symbol: " + str(symbol_rate) + " pol: " + str(polarisation) + " fec: " + str(fec) + " inversion: " + str(inversion)
271 print "orbpos: " + str(orbital_position)
272 parm = eDVBFrontendParametersSatellite()
273 parm.frequency = frequency * 1000
274 parm.symbol_rate = symbol_rate * 1000
275 parm.polarisation = polarisation # eDVBFrontendParametersSatellite.Polarisation.Verti
276 parm.fec = fec # eDVBFrontendParametersSatellite.FEC.f3_4;
278 parm.inversion = inversion #eDVBFrontendParametersSatellite.Inversion.Off;
279 #parm.inversion = 2 #AUTO
280 parm.orbital_position = int(orbital_position)
283 # FIXME use correct parameters
284 def addCabTransponder(self, tlist, frequency, symbol_rate, modulation, fec, inversion):
285 print "Add Cab: frequ: " + str(frequency) + " symbol: " + str(symbol_rate) + " pol: " + str(modulation) + " fec: " + str(fec) + " inversion: " + str(inversion)
286 parm = eDVBFrontendParametersCable()
287 parm.frequency = frequency * 1000
288 parm.symbol_rate = symbol_rate * 1000
289 parm.modulation = modulation # modulation # eDVBFrontendParametersSatellite.Polarisation.Verti
290 parm.fec = fec # eDVBFrontendParametersSatellite.FEC.f3_4;
292 parm.inversion = inversion #eDVBFrontendParametersSatellite.Inversion.Off;
293 #parm.inversion = 2 #AUTO
296 # FIXME use correct parameters
297 def addTerTransponder(self, tlist, frequency):
298 parm = eDVBFrontendParametersTerrestrial()
300 parm.frequency = frequency * 1000000
301 parm.inversion = 2 # eDVBFrontendParametersTerrestrial.Inversion.Unknown;
302 parm.bandwidth = 0 #eDVBFrontendParametersTerrestrial.Bandwidth.Bw8MHz;
303 parm.code_rate_HP = parm.code_rate_LP = 6 #eDVBFrontendParametersTerrestrial.FEC.fAuto;
304 parm.modulation = 1 #eDVBFrontendParametersTerrestrial.Modulation.QAM16;
305 parm.transmission_mode = 1 # eDVBFrontendParametersTerrestrial.TransmissionMode.TM8k;
306 parm.guard_interval = 0 # eDVBFrontendParametersTerrestrial.GuardInterval.GI_1_32;
307 parm.hierarchy = 0 #eDVBFrontendParametersTerrestrial.Hierarchy.HNone;
313 if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-S"]):
314 if currentConfigSelectionElement(config.scan.type) == "single_transponder":
316 self.addSatTransponder(tlist, config.scan.sat.frequency.value[0],
317 config.scan.sat.symbolrate.value[0],
318 config.scan.sat.polarization.value,
319 config.scan.sat.fec.value,
320 config.scan.sat.inversion.value,
321 self.satList[config.scan.nims.value][config.scan.satselection[config.scan.nims.value].value][1])
322 elif currentConfigSelectionElement(config.scan.type) == "single_satellite":
323 getInitialTransponderList(tlist, int(self.satList[config.scan.nims.value][config.scan.satselection[config.scan.nims.value].value][1]))
324 flags |= eComponentScan.scanNetworkSearch
326 elif currentConfigSelectionElement(config.scan.type) == "multisat":
327 SatList = nimmanager.getSatListForNim(config.scan.nims.value)
329 for x in self.multiscanlist:
330 if x[1].parent.value == 0:
331 print " " + str(x[1].parent.configPath)
332 getInitialTransponderList(tlist, x[1].parent.configPath)
333 flags |= eComponentScan.scanNetworkSearch
335 elif (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-C"]):
336 if currentConfigSelectionElement(config.scan.typecable) == "single_transponder":
337 self.addCabTransponder(tlist, config.scan.cab.frequency.value[0],
338 config.scan.cab.symbolrate.value[0],
339 config.scan.cab.modulation.value,
340 config.scan.cab.fec.value,
341 config.scan.cab.inversion.value)
342 if currentConfigSelectionElement(config.scan.cab.networkScan) == "yes":
343 flags |= eComponentScan.scanNetworkSearch
344 elif currentConfigSelectionElement(config.scan.typecable) == "complete":
345 getInitialCableTransponderList(tlist, nimmanager.getCableDescription(config.scan.nims.value))
346 flags |= eComponentScan.scanNetworkSearch
348 elif (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-T"]):
349 if currentConfigSelectionElement(config.scan.typeterrestrial) == "single_transponder":
350 self.addTerTransponder(tlist,
351 config.scan.ter.frequency.value[0])
352 if currentConfigSelectionElement(config.scan.typeterrestrial) == "complete":
357 for x in self["config"].list:
360 feid = config.scan.nims.value
361 # flags |= eComponentScan.scanSearchBAT
362 self.session.openWithCallback(self.doNothing, ServiceScan, [{"transponders": tlist, "feid": feid, "flags": flags}])
369 for x in self["config"].list:
373 class ScanSimple(Screen):
380 slotid = x[1].parent.configPath
381 print "configpath:", x[1].parent.configPath, "-", currentConfigSelectionElement(x[1].parent)
382 if currentConfigSelectionElement(x[1].parent) == "yes":
384 if nimmanager.getNimType(x[1].parent.configPath) == nimmanager.nimType["DVB-S"]:
385 SatList = nimmanager.getSatListForNim(slotid)
387 getInitialTransponderList(tlist, sat[1])
388 elif nimmanager.getNimType(x[1].parent.configPath) == nimmanager.nimType["DVB-C"]:
389 getInitialCableTransponderList(tlist, nimmanager.getCableDescription(slotid))
390 scanList.append({"transponders": tlist, "feid": slotid, "flags": eComponentScan.scanNetworkSearch})
391 self.session.openWithCallback(self.doNothing, ServiceScan, scanList = scanList)
400 self["config"].handleKey(config.key["prevElement"])
403 self["config"].handleKey(config.key["nextElement"])
405 def Satexists(self, tlist, pos):
411 def ScanNimTwoNeeded(self):
412 if nimmanager.getNimType(0) != nimmanager.getNimType(1):
414 if nimmanager.getNimType(0) == nimmanager.nimType["DVB-S"]: #two dvb-s nims
415 if nimmanager.getNimConfigMode(1) in ["loopthrough", "satposdepends", "equal", "nothing"]:
417 sec = eDVBSatelliteEquipmentControl.getInstance()
419 different_satellites = sec.get_different_satellites(0,1)
420 if different_satellites is None:# or not len(different_satellites):
424 def __init__(self, session):
425 Screen.__init__(self, session)
427 self["actions"] = ActionMap(["SetupActions"],
430 "cancel": self.keyCancel,
431 "left": self.keyLeft,
432 "right": self.keyRight,
438 nimcount = nimmanager.getNimSocketCount()
440 nim = configElement_nonSave(0, configSelection, 0,(("yes", _("yes")),("no", _("no"))))
441 self.list.append(getConfigListEntry(_("Scan NIM") + " 0 (" + nimmanager.getNimTypeName(0) + ")", nim))
442 if nimcount > 1 and self.ScanNimTwoNeeded():
443 nim = configElement_nonSave(1, configSelection, 0, (("yes", _("yes")), ("no", _("no"))))
444 self.list.append(getConfigListEntry(_("Scan NIM") + " 1 (" + nimmanager.getNimTypeName(1) + ")", nim))
446 self["config"] = ConfigList(self.list)
447 self["header"] = Label(_("Automatic Scan"))
448 self["footer"] = Label(_("Press OK to scan"))