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.config import config
7 from Components.config import getConfigListEntry
8 from Components.NimManager import nimmanager
9 from Components.Label import Label
10 from enigma import eDVBFrontendParametersSatellite, eComponentScan
12 def getInitialTransponderList(tlist, pos):
14 list = nimmanager.getTransponders(pos)
18 parm = eDVBFrontendParametersSatellite()
20 parm.symbol_rate = x[2]
21 parm.polarisation = x[3] # eDVBFrontendParametersSatellite.Polarisation.Vertical
22 parm.fec = x[4] # eDVBFrontendParametersSatellite.FEC.f3_4;
24 #parm.inversion = 1 #eDVBFrontendParametersSatellite.Inversion.Off;
25 parm.inversion = 2 #AUTO
26 parm.orbital_position = pos
29 class ScanSetup(Screen):
30 def __init__(self, session):
31 Screen.__init__(self, session)
37 self["actions"] = NumberActionMap(["SetupActions"],
40 "cancel": self.keyCancel,
42 "right": self.keyRight,
43 "1": self.keyNumberGlobal,
44 "2": self.keyNumberGlobal,
45 "3": self.keyNumberGlobal,
46 "4": self.keyNumberGlobal,
47 "5": self.keyNumberGlobal,
48 "6": self.keyNumberGlobal,
49 "7": self.keyNumberGlobal,
50 "8": self.keyNumberGlobal,
51 "9": self.keyNumberGlobal,
52 "0": self.keyNumberGlobal
56 self["config"] = ConfigList(self.list)
59 self["introduction"] = Label(_("Press OK to start the scan"))
61 def updateSatList(self):
63 for slot in nimmanager.nimslots:
64 if (nimmanager.getNimType(slot.slotid) == nimmanager.nimType["DVB-S"]):
65 self.satList.append(nimmanager.getSatListForNim(slot.slotid))
67 self.satList.append(None)
69 def createSetup(self):
71 self.multiscanlist = []
72 print "ID: " + str(config.scan.nims.value)
74 self.list.append(getConfigListEntry(_("Tuner"), config.scan.nims))
76 if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-S"]):
77 self.list.append(getConfigListEntry(_("Type of scan"), config.scan.type))
78 elif (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-C"]):
79 self.list.append(getConfigListEntry(_("Type of scan"), config.scan.typecable))
80 elif (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-T"]):
81 self.list.append(getConfigListEntry(_("Type of scan"), config.scan.typeterrestrial))
84 if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-S"]):
85 if (config.scan.type.value == 0): # single transponder scan
86 self.list.append(getConfigListEntry(_('Satellite'), config.scan.satselection[config.scan.nims.value]))
87 self.list.append(getConfigListEntry(_('Frequency'), config.scan.sat.frequency))
88 self.list.append(getConfigListEntry(_('Inversion'), config.scan.sat.inversion))
89 self.list.append(getConfigListEntry(_('Symbol Rate'), config.scan.sat.symbolrate))
90 self.list.append(getConfigListEntry(_("Polarity"), config.scan.sat.polarization))
91 self.list.append(getConfigListEntry(_("FEC"), config.scan.sat.fec))
92 if (config.scan.type.value == 1): # single satellite scan
94 print config.scan.satselection[config.scan.nims.value]
95 self.list.append(getConfigListEntry(_("Satellite"), config.scan.satselection[config.scan.nims.value]))
96 if (config.scan.type.value == 2): # multi sat scan
99 SatList = nimmanager.getSatListForNim(config.scan.nims.value)
102 if self.Satexists(tlist, x[1]) == 0:
104 sat = configElement_nonSave(x[1], configSelection, 0, (_("Enable"), _("Disable")))
105 configEntry = getConfigListEntry(nimmanager.getSatDescription(x[1]), sat)
106 self.list.append(configEntry)
107 self.multiscanlist.append(configEntry)
109 # for sat in nimmanager.satList:
110 # self.list.append(getConfigListEntry(sat[0], config.scan.scansat[sat[1]]))
113 if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-C"]):
114 if (config.scan.typecable.value == 0): # single transponder
115 self.list.append(getConfigListEntry(_("Frequency"), config.scan.cab.frequency))
116 self.list.append(getConfigListEntry(_("Inversion"), config.scan.cab.inversion))
117 self.list.append(getConfigListEntry(_("Symbol Rate"), config.scan.cab.symbolrate))
118 self.list.append(getConfigListEntry(_("Modulation"), config.scan.cab.modulation))
119 self.list.append(getConfigListEntry(_("FEC"), config.scan.cab.fec))
120 if (config.scan.typecable.value == 1): # complete
123 if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-T"]):
124 if (config.scan.typeterrestrial.value == 0): # single transponder
125 self.list.append(getConfigListEntry(_("Frequency"), config.scan.ter.frequency))
126 self.list.append(getConfigListEntry(_("Inversion"), config.scan.ter.inversion))
127 self.list.append(getConfigListEntry(_("Bandwidth"), config.scan.ter.bandwidth))
128 self.list.append(getConfigListEntry(_("Code rate high"), config.scan.ter.fechigh))
129 self.list.append(getConfigListEntry(_("Code rate low"), config.scan.ter.feclow))
130 self.list.append(getConfigListEntry(_("Modulation"), config.scan.ter.modulation))
131 self.list.append(getConfigListEntry(_("Transmission mode"), config.scan.ter.transmission))
132 self.list.append(getConfigListEntry(_("Guard interval mode"), config.scan.ter.guard))
133 self.list.append(getConfigListEntry(_("Hierarchy mode"), config.scan.ter.hierarchy))
134 if (config.scan.typeterrestrial.value == 1): # complete
137 self["config"].list = self.list
138 self["config"].l.setList(self.list)
140 def Satexists(self, tlist, pos):
147 print self["config"].getCurrent()
148 if self["config"].getCurrent()[0] == _("Type of scan"):
150 if self["config"].getCurrent()[0] == _("Tuner"):
153 def createConfig(self):
154 config.scan = ConfigSubsection()
155 config.scan.sat = ConfigSubsection()
156 config.scan.cab = ConfigSubsection()
157 config.scan.ter = ConfigSubsection()
159 config.scan.type = configElement_nonSave("config.scan.type", configSelection, 0, ("Single transponder", "Single satellite", "Multisat"))
160 config.scan.typecable = configElement_nonSave("config.scan.typecable", configSelection, 0, ("Single transponder", "Complete"))
161 config.scan.typeterrestrial = configElement_nonSave("config.scan.typeterrestrial", configSelection, 0, ("Single transponder", "Complete"))
164 for nim in nimmanager.nimList():
165 nimList.append(nim[0])
166 #nimList.append("all")
167 config.scan.nims = configElement_nonSave("config.scan.nims", configSelection, 0, nimList)
170 config.scan.sat.frequency = configElement_nonSave("config.scan.sat.frequency", configSequence, [11836], configsequencearg.get("INTEGER", (10000, 14000)))
171 config.scan.sat.inversion = configElement_nonSave("config.scan.sat.inversion", configSelection, 2, (_("off"), _("on"), _("Auto")))
172 config.scan.sat.symbolrate = configElement_nonSave("config.scan.sat.symbolrate", configSequence, [27500], configsequencearg.get("INTEGER", (1, 99999)))
173 config.scan.sat.polarization = configElement_nonSave("config.scan.sat.polarization", configSelection, 0, (_("horizontal"), _("vertical"), _("circular left"), _("circular right")))
174 config.scan.sat.fec = configElement_nonSave("config.scan.sat.fec", configSelection, 7, (_("Auto"), "1/2", "2/3", "3/4", "5/6", "7/8", _("None")))
177 config.scan.cab.frequency = configElement_nonSave("config.scan.cab.frequency", configSequence, [466], configsequencearg.get("INTEGER", (50, 9999)))
178 config.scan.cab.inversion = configElement_nonSave("config.scan.cab.inversion", configSelection, 2, (_("off"), _("on"), _("Auto")))
179 config.scan.cab.modulation = configElement_nonSave("config.scan.cab.modulation", configSelection, 2, ("16-QAM", "32-QAM", "64-QAM", "128-QAM", "256-QAM", _("Auto")))
180 config.scan.cab.fec = configElement_nonSave("config.scan.cab.fec", configSelection, 9, (_("None"), "1/2", "2/3", "3/4", "4/5", "5/6", "6/7", "7/8", "8/9", _("Auto")))
181 config.scan.cab.symbolrate = configElement_nonSave("config.scan.cab.symbolrate", configSequence, [6900], configsequencearg.get("INTEGER", (1, 9999)))
184 config.scan.ter.frequency = configElement_nonSave("config.scan.ter.frequency", configSequence, [466], configsequencearg.get("INTEGER", (10000, 14000)))
185 config.scan.ter.inversion = configElement_nonSave("config.scan.ter.inversion", configSelection, 2, (_("off"), _("on"), _("Auto")))
186 config.scan.ter.bandwidth = configElement_nonSave("config.scan.ter.bandwidth", configSelection, 3, ("8MHz", "7MHz", "6MHz", _("Auto")))
187 config.scan.ter.fechigh = configElement_nonSave("config.scan.ter.fechigh", configSelection, 6, (_("None"), "1/2", "2/3", "3/4", "5/6", "7/8", _("Auto")))
188 config.scan.ter.feclow = configElement_nonSave("config.scan.ter.feclow", configSelection, 6, (_("None"), "1/2", "2/3", "3/4", "5/6", "7/8", _("Auto")))
189 config.scan.ter.modulation = configElement_nonSave("config.scan.ter.modulation", configSelection, 2, ("QPSK", "QAM16", _("Auto")))
190 config.scan.ter.transmission = configElement_nonSave("config.scan.ter.transmission", configSelection, 2, ("2K", "8K", _("Auto")))
191 config.scan.ter.guard = configElement_nonSave("config.scan.ter.guard", configSelection, 4, ("1/32", "1/16", "1/8", "1/4", _("Auto")))
192 config.scan.ter.hierarchy = configElement_nonSave("config.scan.ter.hierarchy", configSelection, 4, (_("None"), "1", "2", "4", _("Auto")))
194 config.scan.scansat = {}
195 for sat in nimmanager.satList:
197 config.scan.scansat[sat[1]] = configElement_nonSave("config.scan.scansat[" + str(sat[1]) + "]", configSelection, 0, (_("yes"), _("no")))
199 config.scan.satselection = []
201 for slot in nimmanager.nimslots:
202 if (nimmanager.getNimType(slot.slotid) == nimmanager.nimType["DVB-S"]):
203 print str(slot.slotid) + " : " + str(self.satList)
204 config.scan.satselection.append(configElement_nonSave("config.scan.satselection[" + str(slot.slotid) + "]", configSatlist, 0, self.satList[slot.slotid]))
206 config.scan.satselection.append(None)
208 self["config"].handleKey(config.key["prevElement"])
212 self["config"].handleKey(config.key["nextElement"])
215 def keyNumberGlobal(self, number):
216 print "You pressed number " + str(number)
217 if (self["config"].getCurrent()[1].parent.enabled == True):
218 self["config"].handleKey(config.key[str(number)])
220 def addSatTransponder(self, tlist, frequency, symbol_rate, polarisation, fec, inversion, orbital_position):
221 print "Add Sat: frequ: " + str(frequency) + " symbol: " + str(symbol_rate) + " pol: " + str(polarisation) + " fec: " + str(fec) + " inversion: " + str(inversion)
222 print "orbpos: " + str(orbital_position)
223 parm = eDVBFrontendParametersSatellite()
224 parm.frequency = frequency * 1000
225 parm.symbol_rate = symbol_rate * 1000
226 parm.polarisation = polarisation # eDVBFrontendParametersSatellite.Polarisation.Verti
227 parm.fec = fec # eDVBFrontendParametersSatellite.FEC.f3_4;
229 parm.inversion = inversion #eDVBFrontendParametersSatellite.Inversion.Off;
230 #parm.inversion = 2 #AUTO
231 parm.orbital_position = int(orbital_position)
234 # FIXME use correct parameters
235 def addCabTransponder(self, tlist, frequency, symbol_rate, modulation, fec, inversion):
236 print "Add Sat: frequ: " + str(frequency) + " symbol: " + str(symbol_rate) + " pol: " + str(modulation) + " fec: " + str(fec) + " inversion: " + str(inversion)
237 parm = eDVBFrontendParametersCable()
238 parm.frequency = frequency * 1000
239 parm.symbol_rate = symbol_rate * 1000
240 parm.modulation = modulation # eDVBFrontendParametersSatellite.Polarisation.Verti
241 parm.fec = fec # eDVBFrontendParametersSatellite.FEC.f3_4;
243 parm.inversion = inversion #eDVBFrontendParametersSatellite.Inversion.Off;
244 #parm.inversion = 2 #AUTO
247 # FIXME use correct parameters
248 def addTerTransponder(self, tlist, frequency, symbol_rate, polarisation, fec, inversion, orbital_position):
249 print "Add Sat: frequ: " + str(frequency) + " symbol: " + str(symbol_rate) + " pol: " + str(polarisation) + " fec: " + str(fec) + " inversion: " + str(inversion)
250 print "orbpos: " + str(orbital_position)
251 parm = eDVBFrontendParametersTerrestrial()
252 parm.frequency = frequency * 1000
253 parm.symbol_rate = symbol_rate * 1000
254 parm.polarisation = polarisation # eDVBFrontendParametersSatellite.Polarisation.Verti
255 parm.fec = fec # eDVBFrontendParametersSatellite.FEC.f3_4;
257 parm.inversion = inversion #eDVBFrontendParametersSatellite.Inversion.Off;
258 #parm.inversion = 2 #AUTO
259 parm.orbital_position = int(orbital_position)
265 if (config.scan.type.value == 0): # single transponder scan
266 if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-S"]):
267 self.addSatTransponder(tlist, config.scan.sat.frequency.value[0],
268 config.scan.sat.symbolrate.value[0],
269 config.scan.sat.polarization.value,
270 config.scan.sat.fec.value,
271 config.scan.sat.inversion.value,
272 self.satList[config.scan.nims.value][config.scan.satselection[config.scan.nims.value].value][1])
273 if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-C"]):
274 self.addCabTransponder(tlist, config.scan.cab.frequency.value[0],
275 config.scan.cab.symbolrate.value[0],
276 config.scan.cab.modulation.value,
277 config.scan.cab.fec.value,
278 config.scan.cab.inversion.value)
279 if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-T"]):
280 self.addTerTransponder(tlist, config.scan.sat.frequency.value[0],
281 config.scan.sat.symbolrate.value[0],
282 config.scan.sat.polarization.value,
283 config.scan.sat.fec.value,
284 config.scan.sat.inversion.value,
285 self.satList[config.scan.nims.value][config.scan.satselection[config.scan.nims.value].value][1])
287 if (config.scan.type.value == 1): # single sat scan
288 getInitialTransponderList(tlist, int(self.satList[config.scan.nims.value][config.scan.satselection[config.scan.nims.value].value][1]))
289 flags |= eComponentScan.scanNetworkSearch
291 if (config.scan.type.value == 2): # multi sat scan
292 SatList = nimmanager.getSatListForNim(config.scan.nims.value)
294 for x in self.multiscanlist:
295 if x[1].parent.value == 0:
296 print " " + str(x[1].parent.configPath)
297 getInitialTransponderList(tlist, x[1].parent.configPath)
298 flags |= eComponentScan.scanNetworkSearch
300 for x in self["config"].list:
303 feid = config.scan.nims.value
304 # flags |= eComponentScan.scanSearchBAT
305 self.session.openWithCallback(self.doNothing, ServiceScan, tlist, feid, flags)
312 for x in self["config"].list:
316 class ScanSimple(Screen):
319 print "start scan for sats:"
322 if x[1].parent.value == 0:
323 print " " + str(x[1].parent.configPath)
324 getInitialTransponderList(tlist, x[1].parent.configPath)
327 self.session.openWithCallback(self.doNothing, ServiceScan, tlist, feid, eComponentScan.scanNetworkSearch)
331 print "start scan for sats:"
334 if x[1].parent.value == 0:
335 print " " + str(x[1].parent.configPath)
336 getInitialTransponderList(tlist, x[1].parent.configPath)
339 self.session.openWithCallback(self.doNothing, ServiceScan, tlist, feid, eComponentScan.scanNetworkSearch)
348 self["config"].handleKey(config.key["prevElement"])
351 self["config"].handleKey(config.key["nextElement"])
353 def Satexists(self, tlist, pos):
359 def __init__(self, session):
360 Screen.__init__(self, session)
362 self["actions"] = ActionMap(["SetupActions"],
365 "cancel": self.keyCancel,
366 "left": self.keyLeft,
367 "right": self.keyRight,
374 for slotid in nimmanager.getNimListOfType(nimmanager.nimType["DVB-S"]):
375 SatList = nimmanager.getSatListForNim(slotid)
378 if self.Satexists(tlist, x[1]) == 0:
380 sat = configElement_nonSave(x[1], configSelection, 0, (_("Enable"), _("Disable")))
381 self.list.append(getConfigListEntry(nimmanager.getSatDescription(x[1]), sat))
383 self["config"] = ConfigList(self.list)
384 self["header"] = Label(_("Automatic Scan"))
385 self["footer"] = Label(_("Press OK to scan"))