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):
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 self.list.append(getConfigListEntry(nimmanager.getSatDescription(x[1]), sat))
108 # for sat in nimmanager.satList:
109 # self.list.append(getConfigListEntry(sat[0], config.scan.scansat[sat[1]]))
112 if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-C"]):
113 if (config.scan.typecable.value == 0): # single transponder
114 self.list.append(getConfigListEntry(_("Frequency"), config.scan.cab.frequency))
115 self.list.append(getConfigListEntry(_("Inversion"), config.scan.cab.inversion))
116 self.list.append(getConfigListEntry(_("Symbol Rate"), config.scan.cab.symbolrate))
117 self.list.append(getConfigListEntry(_("Modulation"), config.scan.cab.modulation))
118 self.list.append(getConfigListEntry(_("FEC"), config.scan.cab.fec))
119 if (config.scan.typecable.value == 1): # complete
122 if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-T"]):
123 if (config.scan.typeterrestrial.value == 0): # single transponder
124 self.list.append(getConfigListEntry(_("Frequency"), config.scan.ter.frequency))
125 self.list.append(getConfigListEntry(_("Inversion"), config.scan.ter.inversion))
126 self.list.append(getConfigListEntry(_("Bandwidth"), config.scan.ter.bandwidth))
127 self.list.append(getConfigListEntry(_("Code rate high"), config.scan.ter.fechigh))
128 self.list.append(getConfigListEntry(_("Code rate low"), config.scan.ter.feclow))
129 self.list.append(getConfigListEntry(_("Modulation"), config.scan.ter.modulation))
130 self.list.append(getConfigListEntry(_("Transmission mode"), config.scan.ter.transmission))
131 self.list.append(getConfigListEntry(_("Guard interval mode"), config.scan.ter.guard))
132 self.list.append(getConfigListEntry(_("Hierarchy mode"), config.scan.ter.hierarchy))
133 if (config.scan.typeterrestrial.value == 1): # complete
136 self["config"].list = self.list
137 self["config"].l.setList(self.list)
139 def Satexists(self, tlist, pos):
146 print self["config"].getCurrent()
147 if self["config"].getCurrent()[0] == _("Type of scan"):
149 if self["config"].getCurrent()[0] == _("Tuner"):
152 def createConfig(self):
153 config.scan = ConfigSubsection()
154 config.scan.sat = ConfigSubsection()
155 config.scan.cab = ConfigSubsection()
156 config.scan.ter = ConfigSubsection()
158 config.scan.type = configElement_nonSave("config.scan.type", configSelection, 0, ("Single transponder", "Single satellite", "Multisat"))
159 config.scan.typecable = configElement_nonSave("config.scan.typecable", configSelection, 0, ("Single transponder", "Complete"))
160 config.scan.typeterrestrial = configElement_nonSave("config.scan.typeterrestrial", configSelection, 0, ("Single transponder", "Complete"))
163 for nim in nimmanager.nimList():
164 nimList.append(nim[0])
165 #nimList.append("all")
166 config.scan.nims = configElement_nonSave("config.scan.nims", configSelection, 0, nimList)
169 config.scan.sat.frequency = configElement_nonSave("config.scan.sat.frequency", configSequence, [11836], configsequencearg.get("INTEGER", (10000, 14000)))
170 config.scan.sat.inversion = configElement_nonSave("config.scan.sat.inversion", configSelection, 2, (_("off"), _("on"), _("Auto")))
171 config.scan.sat.symbolrate = configElement_nonSave("config.scan.sat.symbolrate", configSequence, [27500], configsequencearg.get("INTEGER", (1, 99999)))
172 config.scan.sat.polarization = configElement_nonSave("config.scan.sat.polarization", configSelection, 0, (_("horizontal"), _("vertical"), _("circular left"), _("circular right")))
173 config.scan.sat.fec = configElement_nonSave("config.scan.sat.fec", configSelection, 7, (_("Auto"), "1/2", "2/3", "3/4", "5/6", "7/8", _("None")))
176 config.scan.cab.frequency = configElement_nonSave("config.scan.cab.frequency", configSequence, [466], configsequencearg.get("INTEGER", (50, 9999)))
177 config.scan.cab.inversion = configElement_nonSave("config.scan.cab.inversion", configSelection, 2, (_("off"), _("on"), _("Auto")))
178 config.scan.cab.modulation = configElement_nonSave("config.scan.cab.modulation", configSelection, 2, ("16-QAM", "32-QAM", "64-QAM", "128-QAM", "256-QAM", _("Auto")))
179 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")))
180 config.scan.cab.symbolrate = configElement_nonSave("config.scan.cab.symbolrate", configSequence, [6900], configsequencearg.get("INTEGER", (1, 9999)))
183 config.scan.ter.frequency = configElement_nonSave("config.scan.ter.frequency", configSequence, [466], configsequencearg.get("INTEGER", (10000, 14000)))
184 config.scan.ter.inversion = configElement_nonSave("config.scan.ter.inversion", configSelection, 2, (_("off"), _("on"), _("Auto")))
185 config.scan.ter.bandwidth = configElement_nonSave("config.scan.ter.bandwidth", configSelection, 3, ("8MHz", "7MHz", "6MHz", _("Auto")))
186 config.scan.ter.fechigh = configElement_nonSave("config.scan.ter.fechigh", configSelection, 6, (_("None"), "1/2", "2/3", "3/4", "5/6", "7/8", _("Auto")))
187 config.scan.ter.feclow = configElement_nonSave("config.scan.ter.feclow", configSelection, 6, (_("None"), "1/2", "2/3", "3/4", "5/6", "7/8", _("Auto")))
188 config.scan.ter.modulation = configElement_nonSave("config.scan.ter.modulation", configSelection, 2, ("QPSK", "QAM16", _("Auto")))
189 config.scan.ter.transmission = configElement_nonSave("config.scan.ter.transmission", configSelection, 2, ("2K", "8K", _("Auto")))
190 config.scan.ter.guard = configElement_nonSave("config.scan.ter.guard", configSelection, 4, ("1/32", "1/16", "1/8", "1/4", _("Auto")))
191 config.scan.ter.hierarchy = configElement_nonSave("config.scan.ter.hierarchy", configSelection, 4, (_("None"), "1", "2", "4", _("Auto")))
193 config.scan.scansat = {}
194 for sat in nimmanager.satList:
196 config.scan.scansat[sat[1]] = configElement_nonSave("config.scan.scansat[" + str(sat[1]) + "]", configSelection, 0, (_("yes"), _("no")))
198 config.scan.satselection = []
200 for slot in nimmanager.nimslots:
201 if (nimmanager.getNimType(slot.slotid) == nimmanager.nimType["DVB-S"]):
202 print str(slot.slotid) + " : " + str(self.satList)
203 config.scan.satselection.append(configElement_nonSave("config.scan.satselection[" + str(slot.slotid) + "]", configSatlist, 0, self.satList[slot.slotid]))
205 config.scan.satselection.append(None)
207 self["config"].handleKey(config.key["prevElement"])
211 self["config"].handleKey(config.key["nextElement"])
214 def keyNumberGlobal(self, number):
215 print "You pressed number " + str(number)
216 if (self["config"].getCurrent()[1].parent.enabled == True):
217 self["config"].handleKey(config.key[str(number)])
219 def addSatTransponder(self, tlist, frequency, symbol_rate, polarisation, fec, inversion, orbital_position):
220 print "Add Sat: frequ: " + str(frequency) + " symbol: " + str(symbol_rate) + " pol: " + str(polarisation) + " fec: " + str(fec) + " inversion: " + str(inversion)
221 print "orbpos: " + str(orbital_position)
222 parm = eDVBFrontendParametersSatellite()
223 parm.frequency = frequency * 1000
224 parm.symbol_rate = symbol_rate * 1000
225 parm.polarisation = polarisation # eDVBFrontendParametersSatellite.Polarisation.Verti
226 parm.fec = fec # eDVBFrontendParametersSatellite.FEC.f3_4;
228 parm.inversion = inversion #eDVBFrontendParametersSatellite.Inversion.Off;
229 #parm.inversion = 2 #AUTO
230 parm.orbital_position = int(orbital_position)
233 # FIXME use correct parameters
234 def addCabTransponder(self, tlist, frequency, symbol_rate, modulation, fec, inversion):
235 print "Add Sat: frequ: " + str(frequency) + " symbol: " + str(symbol_rate) + " pol: " + str(modulation) + " fec: " + str(fec) + " inversion: " + str(inversion)
236 parm = eDVBFrontendParametersCable()
237 parm.frequency = frequency * 1000
238 parm.symbol_rate = symbol_rate * 1000
239 parm.modulation = modulation # eDVBFrontendParametersSatellite.Polarisation.Verti
240 parm.fec = fec # eDVBFrontendParametersSatellite.FEC.f3_4;
242 parm.inversion = inversion #eDVBFrontendParametersSatellite.Inversion.Off;
243 #parm.inversion = 2 #AUTO
246 # FIXME use correct parameters
247 def addTerTransponder(self, tlist, frequency, symbol_rate, polarisation, fec, inversion, orbital_position):
248 print "Add Sat: frequ: " + str(frequency) + " symbol: " + str(symbol_rate) + " pol: " + str(polarisation) + " fec: " + str(fec) + " inversion: " + str(inversion)
249 print "orbpos: " + str(orbital_position)
250 parm = eDVBFrontendParametersTerrestrial()
251 parm.frequency = frequency * 1000
252 parm.symbol_rate = symbol_rate * 1000
253 parm.polarisation = polarisation # eDVBFrontendParametersSatellite.Polarisation.Verti
254 parm.fec = fec # eDVBFrontendParametersSatellite.FEC.f3_4;
256 parm.inversion = inversion #eDVBFrontendParametersSatellite.Inversion.Off;
257 #parm.inversion = 2 #AUTO
258 parm.orbital_position = int(orbital_position)
264 if (config.scan.type.value == 0): # single transponder scan
265 if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-S"]):
266 self.addSatTransponder(tlist, config.scan.sat.frequency.value[0],
267 config.scan.sat.symbolrate.value[0],
268 config.scan.sat.polarization.value,
269 config.scan.sat.fec.value,
270 config.scan.sat.inversion.value,
271 self.satList[config.scan.nims.value][config.scan.satselection[config.scan.nims.value].value][1])
272 if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-C"]):
273 self.addCabTransponder(tlist, config.scan.cab.frequency.value[0],
274 config.scan.cab.symbolrate.value[0],
275 config.scan.cab.modulation.value,
276 config.scan.cab.fec.value,
277 config.scan.cab.inversion.value)
278 if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-T"]):
279 self.addTerTransponder(tlist, config.scan.sat.frequency.value[0],
280 config.scan.sat.symbolrate.value[0],
281 config.scan.sat.polarization.value,
282 config.scan.sat.fec.value,
283 config.scan.sat.inversion.value,
284 self.satList[config.scan.nims.value][config.scan.satselection[config.scan.nims.value].value][1])
286 if (config.scan.type.value == 1): # single sat scan
287 getInitialTransponderList(tlist, int(self.satList[config.scan.nims.value][config.scan.satselection[config.scan.nims.value].value][1]))
288 flags |= eComponentScan.scanNetworkSearch
290 if (config.scan.type.value == 2): # multi sat scan
291 SatList = nimmanager.getSatListForNim(config.scan.nims.value)
294 if x[1].parent.value == 0:
295 print " " + str(x[1].parent.configPath)
296 getInitialTransponderList(tlist, x[1].parent.configPath)
297 flags |= eComponentScan.scanNetworkSearch
299 for x in self["config"].list:
302 feid = config.scan.nims.value
303 # flags |= eComponentScan.scanSearchBAT
304 self.session.openWithCallback(self.doNothing, ServiceScan, tlist, feid, flags)
311 for x in self["config"].list:
315 class ScanSimple(Screen):
318 print "start scan for sats:"
321 if x[1].parent.value == 0:
322 print " " + str(x[1].parent.configPath)
323 getInitialTransponderList(tlist, x[1].parent.configPath)
326 self.session.openWithCallback(self.doNothing, ServiceScan, tlist, feid, eComponentScan.scanNetworkSearch)
330 print "start scan for sats:"
333 if x[1].parent.value == 0:
334 print " " + str(x[1].parent.configPath)
335 getInitialTransponderList(tlist, x[1].parent.configPath)
338 self.session.openWithCallback(self.doNothing, ServiceScan, tlist, feid, eComponentScan.scanNetworkSearch)
347 self["config"].handleKey(config.key["prevElement"])
350 self["config"].handleKey(config.key["nextElement"])
352 def Satexists(self, tlist, pos):
358 def __init__(self, session):
359 Screen.__init__(self, session)
361 self["actions"] = ActionMap(["SetupActions"],
364 "cancel": self.keyCancel,
365 "left": self.keyLeft,
366 "right": self.keyRight,
372 SatList = nimmanager.getConfiguredSats()
375 if self.Satexists(tlist, x) == 0:
377 sat = configElement_nonSave(x, configSelection, 0, (_("Enable"), _("Disable")))
378 self.list.append(getConfigListEntry(nimmanager.getSatDescription(x), sat))
380 self["config"] = ConfigList(self.list)
381 self["header"] = Label(_("Automatic Scan"))
382 self["footer"] = Label(_("Press OK to scan"))