8f02ab3a87faec7d18b50cb7055217c537c6bf42
[enigma2.git] / lib / python / Screens / ScanSetup.py
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
9
10 def getInitialTransponderList(tlist, pos):
11         list = nimmanager.getTransponders(pos)
12
13         for x in list:
14                 if x[0] == 0:           #SAT
15                         parm = eDVBFrontendParametersSatellite()
16                         parm.frequency = x[1]
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;
20                         #parm.fec = 6                                   # AUTO
21                         #parm.inversion = 1     #eDVBFrontendParametersSatellite.Inversion.Off;
22                         parm.inversion = 2              #AUTO
23                         parm.orbital_position = pos
24                         tlist.append(parm)
25
26 def getInitialCableTransponderList(tlist, cable):
27         list = nimmanager.getTranspondersCable(cable)
28
29         for x in list:
30                 if x[0] == 1:           #CABLE
31                         parm = eDVBFrontendParametersCable()
32                         parm.frequency = x[1]
33                         parm.symbol_rate = x[2]
34                         parm.modulation = x[3] # AUTO
35                         parm.fec_inner = x[4] # AUTO
36                         parm.inversion = 2 # AUTO
37                         tlist.append(parm)
38
39 class ScanSetup(Screen):
40         def __init__(self, session):
41                 Screen.__init__(self, session)
42
43                 self.updateSatList()
44                 self.createConfig()
45
46
47                 self["actions"] = NumberActionMap(["SetupActions"],
48                 {
49                         "ok": self.keyGo,
50                         "cancel": self.keyCancel,
51                         "left": self.keyLeft,
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
63                 }, -1)
64                 
65                 self.statusTimer = eTimer()
66                 self.statusTimer.timeout.get().append(self.updateStatus)
67                 #self.statusTimer.start(5000, True)
68
69                 self.list = []
70                 self["config"] = ConfigList(self.list)
71                 self.createSetup()
72
73                 self["introduction"] = Label(_("Press OK to start the scan"))
74
75         def run(self):
76                 self.keyGo()
77
78         def updateSatList(self):
79                 self.satList = []
80                 for slot in nimmanager.nimslots:
81                         if (nimmanager.getNimType(slot.slotid) == nimmanager.nimType["DVB-S"]):
82                                 self.satList.append(nimmanager.getSatListForNim(slot.slotid))
83                         else:
84                                 self.satList.append(None)
85                                 
86         def createSetup(self):
87                 self.list = []
88                 self.multiscanlist = []
89                 print "ID: " + str(config.scan.nims.value)
90
91                 self.tunerEntry = getConfigListEntry(_("Tuner"), config.scan.nims)
92                 self.list.append(self.tunerEntry)
93                 
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)
104
105
106                 if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-S"]):
107
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":
116                                 self.updateSatList()
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":
120                                 # if (norotor)
121                                 tlist = []
122                                 SatList = nimmanager.getSatListForNim(config.scan.nims.value)
123         
124                                 for x in SatList:
125                                         if self.Satexists(tlist, x[1]) == 0:
126                                                 tlist.append(x[1])
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)
131                                 # if (rotor):
132                            # for sat in nimmanager.satList:
133                                 #       self.list.append(getConfigListEntry(sat[0], config.scan.scansat[sat[1]]))
134
135
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":
145                                 pass
146                                 
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":
159                                 pass
160
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)
171                 else:
172                         self.statusTimer.stop()
173
174                 self["config"].list = self.list
175                 self["config"].l.setList(self.list)
176
177         def Satexists(self, tlist, pos):
178                 for x in tlist:
179                         if x == pos:
180                                 return 1
181                 return 0
182
183         def newConfig(self):
184                 print self["config"].getCurrent()
185                 if self["config"].getCurrent() == self.typeOfScanEntry:
186                         self.createSetup()
187                 if self["config"].getCurrent() == self.tunerEntry:
188                         self.createSetup()
189
190         def createConfig(self):
191                         config.scan = ConfigSubsection()
192                         config.scan.sat = ConfigSubsection()
193                         config.scan.cab = ConfigSubsection()
194                         config.scan.ter = ConfigSubsection()
195
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"))))
199
200                         nimList = [ ]
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)
205                         
206                         # status
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
213
214                         # sat
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"))))
220
221                         # cable
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"))))
228
229                         # terrestial
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"))))
239
240                         config.scan.scansat = {}
241                         for sat in nimmanager.satList:
242                                 #print sat[1]
243                                 config.scan.scansat[sat[1]] = configElement_nonSave("config.scan.scansat[" + str(sat[1]) + "]", configSelection, 0, (("yes", _("yes")), ("no", _("no"))))
244
245                         config.scan.satselection = []
246                         slotid = 0
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]))
251                                 else:
252                                         config.scan.satselection.append(None)
253         def keyLeft(self):
254                 self["config"].handleKey(config.key["prevElement"])
255                 self.newConfig()
256
257         def keyRight(self):
258                 self["config"].handleKey(config.key["nextElement"])
259                 self.newConfig()
260
261         def updateStatus(self):
262                 print "updatestatus"
263
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)])
268
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;
277                 #parm.fec = 6                                   # AUTO
278                 parm.inversion = inversion      #eDVBFrontendParametersSatellite.Inversion.Off;
279                 #parm.inversion = 2             #AUTO
280                 parm.orbital_position = int(orbital_position)
281                 tlist.append(parm)
282
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;
291                 #parm.fec = 6                                   # AUTO
292                 parm.inversion = inversion      #eDVBFrontendParametersSatellite.Inversion.Off;
293                 #parm.inversion = 2             #AUTO
294                 tlist.append(parm)
295
296         # FIXME use correct parameters
297         def addTerTransponder(self, tlist, frequency):
298                 parm = eDVBFrontendParametersTerrestrial()
299                 
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;
308                 tlist.append(parm)
309
310         def keyGo(self):
311                 tlist = []
312                 flags = 0
313                 if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-S"]):
314                         if currentConfigSelectionElement(config.scan.type) == "single_transponder":
315
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
325         
326                         elif currentConfigSelectionElement(config.scan.type) == "multisat":
327                                 SatList = nimmanager.getSatListForNim(config.scan.nims.value)
328         
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
334
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
347
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":
353                                 pass
354
355
356
357                 for x in self["config"].list:
358                         x[1].save()
359
360                 feid = config.scan.nims.value
361                 # flags |= eComponentScan.scanSearchBAT
362                 self.session.openWithCallback(self.doNothing, ServiceScan, [{"transponders": tlist, "feid": feid, "flags": flags}])
363
364                 #self.close()
365         def doNothing(self):
366                 pass
367
368         def keyCancel(self):
369                 for x in self["config"].list:
370                         x[1].cancel()
371                 self.close()
372
373 class ScanSimple(Screen):
374         def run(self):
375                 self.keyGo()
376
377         def keyGo(self):
378                 scanList = []
379                 if nimmanager.getNimType(0) == nimmanager.nimType["DVB-S"] and nimmanager.getNimType(0) == nimmanager.getNimType(1):
380                         sec = eDVBSatelliteEquipmentControl.getInstance()
381                         if sec is not None:
382                                 exclusive_satellites = sec.get_exclusive_satellites(0,1)
383                         else:
384                                 exclusive_satellites = [0,0]
385                 else:
386                         exclusive_satellites = [0,0]
387                 print "exclusive satellites", exclusive_satellites
388                 for x in self.list:
389                         slotid = x[1].parent.configPath
390                         print "Scan Tuner", slotid, "-", currentConfigSelectionElement(x[1].parent)
391                         if currentConfigSelectionElement(x[1].parent) == "yes":
392                                 tlist = [ ]
393                                 if nimmanager.getNimType(x[1].parent.configPath) == nimmanager.nimType["DVB-S"]:
394                                         if slotid > 0:
395                                                 idx = exclusive_satellites[0]+1
396                                         else:
397                                                 idx = 0
398                                         exclusive_nim_sats = exclusive_satellites[idx+1:idx+1+exclusive_satellites[idx]]
399                                         print "exclusive_nim_sats", exclusive_nim_sats
400                                         SatList = nimmanager.getSatListForNim(slotid)
401                                         for sat in SatList:
402                                                 if sat[1] in exclusive_nim_sats or slotid == 0:
403                                                         print sat
404                                                         getInitialTransponderList(tlist, sat[1])
405                                 elif nimmanager.getNimType(x[1].parent.configPath) == nimmanager.nimType["DVB-C"]:
406                                         getInitialCableTransponderList(tlist, nimmanager.getCableDescription(slotid))
407                                 scanList.append({"transponders": tlist, "feid": slotid, "flags": eComponentScan.scanNetworkSearch})
408                 self.session.openWithCallback(self.doNothing, ServiceScan, scanList = scanList)
409
410         def doNothing(self):
411                 pass
412         
413         def keyCancel(self):
414                 self.close()
415
416         def keyLeft(self):
417                 self["config"].handleKey(config.key["prevElement"])
418
419         def keyRight(self):
420                 self["config"].handleKey(config.key["nextElement"])
421
422         def Satexists(self, tlist, pos):
423                 for x in tlist:
424                         if x == pos:
425                                 return 1
426                 return 0
427
428         def ScanNimTwoNeeded(self):
429                 if nimmanager.getNimType(0) != nimmanager.getNimType(1):
430                         return True
431                 if nimmanager.getNimType(0) == nimmanager.nimType["DVB-S"]: #two dvb-s nims
432                         if nimmanager.getNimConfigMode(1) in ["loopthrough", "satposdepends", "equal", "nothing"]:
433                                 return False
434                         sec = eDVBSatelliteEquipmentControl.getInstance()
435                         if sec is not None:
436                                 exclusive_satellites = sec.get_exclusive_satellites(0,1)
437                                 if len(exclusive_satellites) == 0:
438                                         return False
439                         return True
440
441         def __init__(self, session):
442                 Screen.__init__(self, session)
443
444                 self["actions"] = ActionMap(["SetupActions"],
445                 {
446                         "ok": self.keyGo,
447                         "cancel": self.keyCancel,
448                         "left": self.keyLeft,
449                         "right": self.keyRight,
450                 }, -1)
451
452                 self.list = []
453                 tlist = []
454
455                 nimcount = nimmanager.getNimSocketCount()
456                 if nimcount > 0:
457                         nim = configElement_nonSave(0, configSelection, 0,(("yes", _("yes")),("no", _("no"))))
458                         self.list.append(getConfigListEntry(_("Scan NIM") + " 0 (" + nimmanager.getNimTypeName(0) + ")", nim))
459                 if nimcount > 1 and self.ScanNimTwoNeeded():
460                         nim = configElement_nonSave(1, configSelection, 0, (("yes", _("yes")), ("no", _("no"))))
461                         self.list.append(getConfigListEntry(_("Scan NIM") + " 1 (" + nimmanager.getNimTypeName(1) + ")", nim))
462
463                 self["config"] = ConfigList(self.list)
464                 self["header"] = Label(_("Automatic Scan"))
465                 self["footer"] = Label(_("Press OK to scan"))