[blindscan] fixed a bug that failed to scan on the uno and ultimo.
[vuplus_dvbapp] / lib / python / Plugins / SystemPlugins / Blindscan / plugin.py
1 from Plugins.Plugin import PluginDescriptor
2
3 from Screens.Screen import Screen
4 from Screens.ServiceScan import ServiceScan
5 from Screens.MessageBox import MessageBox
6 from Screens.DefaultWizard import DefaultWizard
7
8 from Components.Label import Label
9 from Components.TuneTest import Tuner
10 from Components.ConfigList import ConfigListScreen
11 from Components.Sources.StaticText import StaticText
12 from Components.ActionMap import NumberActionMap, ActionMap
13 from Components.NimManager import nimmanager, getConfigSatlist
14 from Components.config import config, ConfigSubsection, ConfigSelection, ConfigYesNo, ConfigInteger, getConfigListEntry, ConfigSlider, ConfigEnableDisable
15
16 from Tools.HardwareInfo import HardwareInfo
17 from Tools.Directories import resolveFilename, SCOPE_DEFAULTPARTITIONMOUNTDIR, SCOPE_DEFAULTDIR, SCOPE_DEFAULTPARTITION
18
19 from enigma import eTimer, eDVBFrontendParametersSatellite, eComponentScan, eDVBSatelliteEquipmentControl, eDVBFrontendParametersTerrestrial, eDVBFrontendParametersCable, eConsoleAppContainer, eDVBResourceManager, getDesktop
20
21 _supportNimType   = { 'AVL1208':'', 'AVL6222':'6222_', 'AVL6211':'6211_'}
22
23 class Blindscan(ConfigListScreen, Screen):
24         skin =  """
25                 <screen position="center,center" size="560,390" title="Blindscan">
26                         <ePixmap pixmap="skin_default/buttons/red.png" position="40,10" size="140,40" alphatest="on" />
27                         <ePixmap pixmap="skin_default/buttons/green.png" position="210,10" size="140,40" alphatest="on" />
28                         <ePixmap pixmap="skin_default/buttons/blue.png" position="380,10" size="140,40" alphatest="on" />
29
30                         <widget source="key_red" render="Label" position="40,10" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" foregroundColor="#ffffff" transparent="1"/>
31                         <widget source="key_green" render="Label" position="210,10" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" foregroundColor="#ffffff" transparent="1"/>
32                         <widget source="key_blue" render="Label" position="380,10" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" foregroundColor="#ffffff" transparent="1"/>
33
34                         <widget name="config" position="5,70" size="550,280" scrollbarMode="showOnDemand" />
35                         <widget name="introduction" position="0,365" size="560,20" font="Regular;20" halign="center" />
36                 </screen>
37                 """
38
39         def __init__(self, session): 
40                 Screen.__init__(self, session)
41
42                 self.current_play_service = self.session.nav.getCurrentlyPlayingServiceReference()
43
44                 # update sat list
45                 self.satList = []
46                 for slot in nimmanager.nim_slots:
47                         if slot.isCompatible("DVB-S"):
48                                 self.satList.append(nimmanager.getSatListForNim(slot.slot))
49                         else:
50                                 self.satList.append(None)
51
52                 # make config
53                 self.createConfig()
54
55                 self.list = []
56                 self.status = ""
57
58                 ConfigListScreen.__init__(self, self.list)
59                 if self.scan_nims.value != None and self.scan_nims.value != "" :
60                         self["actions"] = ActionMap(["OkCancelActions", "ShortcutActions", "WizardActions", "ColorActions", "SetupActions", ],
61                         {
62                                 "red": self.keyCancel,
63                                 "green": self.keyGo,
64                                 "blue":self.keyGoAll,
65                                 "ok": self.keyGo,
66                                 "cancel": self.keyCancel,
67                         }, -2)
68                         self["key_red"] = StaticText(_("Exit"))
69                         self["key_green"] = StaticText("Scan")
70                         self["key_blue"] = StaticText("Scan All")
71                         self["introduction"] = Label(_("Press Green/OK to start the scan"))
72                         self.createSetup()
73                 else :
74                         self["actions"] = ActionMap(["OkCancelActions", "ShortcutActions", "WizardActions", "ColorActions", "SetupActions", ],
75                         {
76                                 "red": self.keyCancel,
77                                 "green": self.keyNone,
78                                 "blue":self.keyNone,
79                                 "ok": self.keyNone,
80                                 "cancel": self.keyCancel,
81                         }, -2)
82                         self["key_red"] = StaticText(_("Exit"))
83                         self["key_green"] = StaticText(" ")
84                         self["key_blue"] = StaticText(" ")
85                         self["introduction"] = Label(_("Please setup your tuner configuration."))
86
87                 self.i2c_mapping_table = None
88                 self.makeNimSocket()
89                 self.nimSockets = self.ScanNimsocket()
90
91         def ScanNimsocket(self):
92                 _nimSocket = {}
93                 fp = file('/proc/bus/nim_sockets')
94
95                 sNo, sName = -1, ""
96                 for line in fp:
97                         line = line.strip()
98                         if line.startswith('NIM Socket'):
99                                 sNo = line.split()[2][:-1]
100                         elif line.startswith('Name:'):
101                                 sName = line.split()[3][4:-1]
102                         if sNo >= 0 and sName != "":
103                                 _nimSocket[sNo] = sName
104                                 sNo   = -1
105                                 sName = ''
106                 fp.close()
107                 return _nimSocket
108
109         def makeNimSocket(self, nimname=""):
110                 self.i2c_mapping_table = {}
111
112                 if nimname == "AVL6222":
113                         model = file('/proc/stb/info/vumodel').read().strip()
114                         if model == "uno":
115                                 self.i2c_mapping_table = {0:3, 1:3, 2:1, 3:0}
116                         elif model == "duo2":
117                                 if self.nimSockets['0'] == "AVL6222":
118                                         self.i2c_mapping_table = {0:2, 1:2, 2:4, 3:4}
119                                 else:   self.i2c_mapping_table = {0:2, 1:4, 2:4, 3:0}
120                         else:   self.i2c_mapping_table = {0:2, 1:4, 2:0, 3:0}
121                 else:   self.i2c_mapping_table = {0:2, 1:3, 2:1, 3:0}
122
123         def getNimSocket(self, slot_number):
124                 if slot_number < 0 or slot_number > 3:
125                         return -1
126                 return self.i2c_mapping_table[slot_number]
127
128         def keyNone(self):
129                 None
130         def callbackNone(self, *retval):
131                 None
132
133         def openFrontend(self):
134                 res_mgr = eDVBResourceManager.getInstance()
135                 if res_mgr:
136                         self.raw_channel = res_mgr.allocateRawChannel(self.feid)
137                         if self.raw_channel:
138                                 self.frontend = self.raw_channel.getFrontend()
139                                 if self.frontend:
140                                         return True
141                                 else:
142                                         print "getFrontend failed"
143                         else:
144                                 print "getRawChannel failed"
145                 else:
146                         print "getResourceManager instance failed"
147                 return False
148
149         def createConfig(self):
150                 self.feinfo = None
151                 frontendData = None
152                 defaultSat = {
153                         "orbpos": 192,
154                         "system": eDVBFrontendParametersSatellite.System_DVB_S,
155                         "frequency": 11836,
156                         "inversion": eDVBFrontendParametersSatellite.Inversion_Unknown,
157                         "symbolrate": 27500,
158                         "polarization": eDVBFrontendParametersSatellite.Polarisation_Horizontal,
159                         "fec": eDVBFrontendParametersSatellite.FEC_Auto,
160                         "fec_s2": eDVBFrontendParametersSatellite.FEC_9_10,
161                         "modulation": eDVBFrontendParametersSatellite.Modulation_QPSK 
162                 }
163
164                 self.service = self.session.nav.getCurrentService()
165                 if self.service is not None:
166                         self.feinfo = self.service.frontendInfo()
167                         frontendData = self.feinfo and self.feinfo.getAll(True)
168                 if frontendData is not None:
169                         ttype = frontendData.get("tuner_type", "UNKNOWN")
170                         if ttype == "DVB-S":
171                                 defaultSat["system"] = frontendData.get("system", eDVBFrontendParametersSatellite.System_DVB_S)
172                                 defaultSat["frequency"] = frontendData.get("frequency", 0) / 1000
173                                 defaultSat["inversion"] = frontendData.get("inversion", eDVBFrontendParametersSatellite.Inversion_Unknown)
174                                 defaultSat["symbolrate"] = frontendData.get("symbol_rate", 0) / 1000
175                                 defaultSat["polarization"] = frontendData.get("polarization", eDVBFrontendParametersSatellite.Polarisation_Horizontal)
176                                 if defaultSat["system"] == eDVBFrontendParametersSatellite.System_DVB_S2:
177                                         defaultSat["fec_s2"] = frontendData.get("fec_inner", eDVBFrontendParametersSatellite.FEC_Auto)
178                                         defaultSat["rolloff"] = frontendData.get("rolloff", eDVBFrontendParametersSatellite.RollOff_alpha_0_35)
179                                         defaultSat["pilot"] = frontendData.get("pilot", eDVBFrontendParametersSatellite.Pilot_Unknown)
180                                 else:
181                                         defaultSat["fec"] = frontendData.get("fec_inner", eDVBFrontendParametersSatellite.FEC_Auto)
182                                 defaultSat["modulation"] = frontendData.get("modulation", eDVBFrontendParametersSatellite.Modulation_QPSK)
183                                 defaultSat["orbpos"] = frontendData.get("orbital_position", 0)
184                 del self.feinfo
185                 del self.service
186                 del frontendData
187                 
188                 self.scan_sat = ConfigSubsection()
189                 self.scan_networkScan = ConfigYesNo(default = False)
190                 
191                 # blindscan add
192                 self.blindscan_hi = ConfigSelection(default = "hi_low", choices = [("low", _("low")), ("high", _("high")), ("hi_low", _("hi_low"))])
193
194                 #ConfigYesNo(default = True)
195                 self.blindscan_start_frequency = ConfigInteger(default = 950*1000000)
196                 self.blindscan_stop_frequency = ConfigInteger(default = 2150*1000000)
197                 self.blindscan_start_symbol = ConfigInteger(default = 2*1000000)
198                 self.blindscan_stop_symbol = ConfigInteger(default = 45*1000000)
199                 self.scan_clearallservices = ConfigYesNo(default = False)
200                 self.scan_onlyfree = ConfigYesNo(default = False)
201
202                 # collect all nims which are *not* set to "nothing"
203                 nim_list = []
204                 for n in nimmanager.nim_slots:
205                         if n.config_mode == "nothing":
206                                 continue
207                         if n.config_mode == "advanced" and len(nimmanager.getSatListForNim(n.slot)) < 1:
208                                 continue
209                         if n.config_mode in ("loopthrough", "satposdepends"):
210                                 root_id = nimmanager.sec.getRoot(n.slot_id, int(n.config.connectedTo.value))
211                                 if n.type == nimmanager.nim_slots[root_id].type: # check if connected from a DVB-S to DVB-S2 Nim or vice versa
212                                         continue
213                         if n.isCompatible("DVB-S"):
214                                 nim_list.append((str(n.slot), n.friendly_full_description))
215                 self.scan_nims = ConfigSelection(choices = nim_list)
216
217                 # sat
218                 self.scan_sat.frequency = ConfigInteger(default = defaultSat["frequency"], limits = (1, 99999))
219                 #self.scan_sat.polarization = ConfigSelection(default = defaultSat["polarization"], choices = [
220                 self.scan_sat.polarization = ConfigSelection(default = eDVBFrontendParametersSatellite.Polarisation_CircularRight + 1, choices = [
221                         (eDVBFrontendParametersSatellite.Polarisation_CircularRight + 1, _("horizontal_vertical")),
222                         (eDVBFrontendParametersSatellite.Polarisation_Horizontal, _("horizontal")),
223                         (eDVBFrontendParametersSatellite.Polarisation_Vertical, _("vertical")),
224                         (eDVBFrontendParametersSatellite.Polarisation_CircularLeft, _("circular left")),
225                         (eDVBFrontendParametersSatellite.Polarisation_CircularRight, _("circular right"))])
226                 self.scan_scansat = {}
227                 for sat in nimmanager.satList:
228                         self.scan_scansat[sat[0]] = ConfigYesNo(default = False)
229                 
230                 self.scan_satselection = []
231                 for slot in nimmanager.nim_slots:
232                         if slot.isCompatible("DVB-S"):
233                                 self.scan_satselection.append(getConfigSatlist(defaultSat["orbpos"], self.satList[slot.slot]))
234                 return True
235
236         def getSelectedSatIndex(self, v):
237                 index    = 0
238                 none_cnt = 0
239                 for n in self.satList:
240                         if self.satList[index] == None:
241                                 none_cnt = none_cnt + 1
242                         if index == int(v):
243                                 return (index-none_cnt)
244                         index = index + 1
245                 return -1
246
247         def createSetup(self):
248                 self.list = []
249                 self.multiscanlist = []
250                 index_to_scan = int(self.scan_nims.value)
251                 print "ID: ", index_to_scan
252
253                 self.tunerEntry = getConfigListEntry(_("Tuner"), self.scan_nims)
254                 self.list.append(self.tunerEntry)
255                 
256                 if self.scan_nims == [ ]:
257                         return
258                 
259                 self.systemEntry = None
260                 self.modulationEntry = None
261                 nim = nimmanager.nim_slots[index_to_scan]
262
263                 self.scan_networkScan.value = False
264                 if nim.isCompatible("DVB-S") :
265                         self.list.append(getConfigListEntry(_('Satellite'), self.scan_satselection[self.getSelectedSatIndex(index_to_scan)]))
266                         self.list.append(getConfigListEntry(_('Scan start frequency'), self.blindscan_start_frequency))
267                         self.list.append(getConfigListEntry(_('Scan stop frequency'), self.blindscan_stop_frequency))
268                         self.list.append(getConfigListEntry(_("Polarity"), self.scan_sat.polarization))
269                         self.list.append(getConfigListEntry(_("Scan band"), self.blindscan_hi))
270                         self.list.append(getConfigListEntry(_('Scan start symbolrate'), self.blindscan_start_symbol))
271                         self.list.append(getConfigListEntry(_('Scan stop symbolrate'), self.blindscan_stop_symbol))
272                         self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
273                         self.list.append(getConfigListEntry(_("Only Free scan"), self.scan_onlyfree))
274                         self["config"].list = self.list
275                         self["config"].l.setList(self.list)
276                         
277         def newConfig(self):
278                 cur = self["config"].getCurrent()
279                 print "cur is", cur
280                 if cur == self.tunerEntry or \
281                         cur == self.systemEntry or \
282                         (self.modulationEntry and self.systemEntry[1].value == eDVBFrontendParametersSatellite.System_DVB_S2 and cur == self.modulationEntry):
283                         self.createSetup()
284
285         def checkSettings(self):
286                 if self.blindscan_start_frequency.value < 950*1000000 or self.blindscan_start_frequency.value > 2150*1000000 :
287                         self.session.open(MessageBox, _("Please check again.\nStart frequency must be between 950 and 2150."), MessageBox.TYPE_ERROR)
288                         return False
289                 if self.blindscan_stop_frequency.value < 950*1000000 or self.blindscan_stop_frequency.value > 2150*1000000 :
290                         self.session.open(MessageBox, _("Please check again.\nStop frequency must be between 950 and 2150."), MessageBox.TYPE_ERROR)
291                         return False
292                 if self.blindscan_start_frequency.value > self.blindscan_stop_frequency.value :
293                         self.session.open(MessageBox, _("Please check again.\nFrequency : start value is larger than stop value."), MessageBox.TYPE_ERROR)
294                         return False
295                 if self.blindscan_start_symbol.value < 2*1000000 or self.blindscan_start_symbol.value > 45*1000000 :
296                         self.session.open(MessageBox, _("Please check again.\nStart symbolrate must be between 2MHz and 45MHz."), MessageBox.TYPE_ERROR)
297                         return False
298                 if self.blindscan_stop_symbol.value < 2*1000000 or self.blindscan_stop_symbol.value > 45*1000000 :
299                         self.session.open(MessageBox, _("Please check again.\nStop symbolrate must be between 2MHz and 45MHz."), MessageBox.TYPE_ERROR)
300                         return False
301                 if self.blindscan_start_symbol.value > self.blindscan_stop_symbol.value :
302                         self.session.open(MessageBox, _("Please check again.\nSymbolrate : start value is larger than stop value."), MessageBox.TYPE_ERROR)
303                         return False
304                 return True
305
306         def keyLeft(self):
307                 ConfigListScreen.keyLeft(self)
308                 self.newConfig()
309
310         def keyRight(self):
311                 ConfigListScreen.keyRight(self)
312                 self.newConfig()
313                         
314         def keyCancel(self):
315                 self.session.nav.playService(self.current_play_service)
316                 for x in self["config"].list:
317                         x[1].cancel()
318                 self.close()
319
320         def keyGo(self):
321                 if self.checkSettings() == False:
322                         return
323
324                 tab_pol = {
325                         eDVBFrontendParametersSatellite.Polarisation_Horizontal : "horizontal", 
326                         eDVBFrontendParametersSatellite.Polarisation_Vertical : "vertical",
327                         eDVBFrontendParametersSatellite.Polarisation_CircularLeft : "circular left",
328                         eDVBFrontendParametersSatellite.Polarisation_CircularRight : "circular right",
329                         eDVBFrontendParametersSatellite.Polarisation_CircularRight + 1 : "horizontal_vertical"
330                 }
331
332                 self.tmp_tplist=[]
333                 tmp_pol = []
334                 tmp_band = []
335                 idx_selected_sat = int(self.getSelectedSatIndex(self.scan_nims.value))
336                 tmp_list=[self.satList[int(self.scan_nims.value)][self.scan_satselection[idx_selected_sat].index]]
337
338                 if self.blindscan_hi.value == "hi_low" :
339                         tmp_band=["low","high"]
340                 else:
341                         tmp_band=[self.blindscan_hi.value]
342                         
343                 if self.scan_sat.polarization.value ==  eDVBFrontendParametersSatellite.Polarisation_CircularRight + 1 : 
344                         tmp_pol=["horizontal","vertical"]
345                 else:
346                         tmp_pol=[tab_pol[self.scan_sat.polarization.value]]
347
348                 self.doRun(tmp_list, tmp_pol, tmp_band)
349                 
350         def keyGoAll(self):
351                 if self.checkSettings() == False:
352                         return
353                 self.tmp_tplist=[]
354                 tmp_list=[]
355                 tmp_band=["low","high"]
356                 tmp_pol=["horizontal","vertical"]
357                 
358                 for slot in nimmanager.nim_slots:
359                         device_name = "/dev/dvb/adapter0/frontend%d" % (slot.slot)
360                         if slot.isCompatible("DVB-S") and int(self.scan_nims.value) == slot.slot:
361                                 for s in self.satList[slot.slot]:
362                                         tmp_list.append(s)
363                 self.doRun(tmp_list, tmp_pol, tmp_band)
364                 
365         def doRun(self, tmp_list, tmp_pol, tmp_band):
366                 def GetCommand(nimIdx):
367                         _nimSocket = self.nimSockets
368                         try:
369                                 sName = _nimSocket[str(nimIdx)]
370                                 sType = _supportNimType[sName]
371                                 return "vuplus_%(TYPE)sblindscan"%{'TYPE':sType}, sName
372                         except: pass
373                         return "vuplus_blindscan", ""
374                 self.binName,nimName =  GetCommand(self.scan_nims.value)
375                 
376                 self.makeNimSocket(nimName)
377                 if self.binName is None:
378                         self.session.open(MessageBox, "Blindscan is not supported in " + nimName + " tuner.", MessageBox.TYPE_ERROR)
379                         print nimName + " is not support blindscan."
380                         return
381
382                 self.full_data = ""
383                 self.total_list=[]
384                 for x in tmp_list:
385                         for y in tmp_pol:
386                                 for z in tmp_band:
387                                         self.total_list.append([x,y,z])
388                                         print "add scan item : ", x, ", ", y, ", ", z
389
390                 self.max_count = len(self.total_list)
391                 self.is_runable = True
392                 self.running_count = 0
393                 self.clockTimer = eTimer()
394                 self.clockTimer.callback.append(self.doClock)
395                 self.clockTimer.start(1000)
396
397         def doClock(self):
398                 is_scan = False
399                 if self.is_runable :
400                         if self.running_count >= self.max_count:
401                                 self.clockTimer.stop()
402                                 del self.clockTimer
403                                 self.clockTimer = None
404                                 print "Done"
405                                 return
406                         orb = self.total_list[self.running_count][0]
407                         pol = self.total_list[self.running_count][1]
408                         band = self.total_list[self.running_count][2]
409                         self.running_count = self.running_count + 1
410                         print "running status-[%d] : [%d][%s][%s]" %(self.running_count, orb[0], pol, band)
411                         if self.running_count == self.max_count:
412                                 is_scan = True
413                         self.prepareScanData(orb, pol, band, is_scan)
414
415         def prepareScanData(self, orb, pol, band, is_scan):
416                 self.is_runable = False
417                 self.orb_position = orb[0]
418                 self.feid = int(self.scan_nims.value)
419                 tab_hilow = {"high" : 1, "low" : 0}
420                 tab_pol = {
421                         "horizontal" : eDVBFrontendParametersSatellite.Polarisation_Horizontal, 
422                         "vertical" : eDVBFrontendParametersSatellite.Polarisation_Vertical,
423                         "circular left" : eDVBFrontendParametersSatellite.Polarisation_CircularLeft,
424                         "circular right" : eDVBFrontendParametersSatellite.Polarisation_CircularRight
425                 }
426
427                 returnvalue = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
428
429                 if not self.openFrontend():
430                         self.oldref = self.session.nav.getCurrentlyPlayingServiceReference()
431                         self.session.nav.stopService()
432                         if not self.openFrontend():
433                                 if self.session.pipshown:
434                                         self.session.pipshown = False
435                                         del self.session.pip
436                                         if not self.openFrontend():
437                                                 self.frontend = None
438                 self.tuner = Tuner(self.frontend)
439
440                 if tab_hilow[band]:
441                         self.scan_sat.frequency.value = 12515
442                 else:
443                         self.scan_sat.frequency.value = 11015
444                 returnvalue = (self.scan_sat.frequency.value,
445                                          0,
446                                          tab_pol[pol],
447                                          0,
448                                          0,
449                                          orb[0],
450                                          eDVBFrontendParametersSatellite.System_DVB_S,
451                                          0,
452                                          0,
453                                          0)
454                 self.tuner.tune(returnvalue)
455
456                 if self.getNimSocket(self.feid) < 0:
457                         print "can't find i2c number!!"
458                         return
459                 try:
460                         cmd = "%s %d %d %d %d %d %d %d %d" % (self.binName, self.blindscan_start_frequency.value/1000000, self.blindscan_stop_frequency.value/1000000, self.blindscan_start_symbol.value/1000000, self.blindscan_stop_symbol.value/1000000, tab_pol[pol], tab_hilow[band], self.feid, self.getNimSocket(self.feid))
461                 except: return
462                 print "prepared command : [%s]" % (cmd)
463                 self.blindscan_container = eConsoleAppContainer()
464                 self.blindscan_container.appClosed.append(self.blindscanContainerClose)
465                 self.blindscan_container.dataAvail.append(self.blindscanContainerAvail)
466                 self.blindscan_container.execute(cmd)
467
468                 tmpstr = "Look for available transponders.\nThis works will take several minutes.\n\n   - Current Status : %d/%d\n   - Orbital Positions : %s\n   - Polarization : %s\n   - Bandwidth : %s" %(self.running_count, self.max_count, orb[1], pol, band)
469                 if is_scan :
470                         self.blindscan_session = self.session.openWithCallback(self.blindscanSessionClose, MessageBox, _(tmpstr), MessageBox.TYPE_INFO)
471                 else:
472                         self.blindscan_session = self.session.openWithCallback(self.blindscanSessionNone, MessageBox, _(tmpstr), MessageBox.TYPE_INFO)
473
474         def blindscanContainerClose(self, retval):
475                 lines = self.full_data.split('\n')
476                 for line in lines:
477                         data = line.split()
478                         print "cnt :", len(data), ", data :", data
479                         if len(data) >= 10:
480                                 if data[0] == 'OK':
481                                         parm = eDVBFrontendParametersSatellite()
482                                         sys = { "DVB-S" : eDVBFrontendParametersSatellite.System_DVB_S,
483                                                 "DVB-S2" : eDVBFrontendParametersSatellite.System_DVB_S2}
484                                         qam = { "QPSK" : parm.Modulation_QPSK,
485                                                 "8PSK" : parm.Modulation_8PSK}
486                                         inv = { "INVERSION_OFF" : parm.Inversion_Off,
487                                                 "INVERSION_ON" : parm.Inversion_On,
488                                                 "INVERSION_AUTO" : parm.Inversion_Unknown}
489                                         fec = { "FEC_AUTO" : parm.FEC_Auto,
490                                                 "FEC_1_2" : parm.FEC_1_2,
491                                                 "FEC_2_3" : parm.FEC_2_3,
492                                                 "FEC_3_4" : parm.FEC_3_4,
493                                                 "FEC_5_6": parm.FEC_5_6,
494                                                 "FEC_7_8" : parm.FEC_7_8,
495                                                 "FEC_8_9" : parm.FEC_8_9,
496                                                 "FEC_3_5" : parm.FEC_3_5,
497                                                 "FEC_9_10" : parm.FEC_9_10,
498                                                 "FEC_NONE" : parm.FEC_None}
499                                         roll ={ "ROLLOFF_20" : parm.RollOff_alpha_0_20,
500                                                 "ROLLOFF_25" : parm.RollOff_alpha_0_25,
501                                                 "ROLLOFF_35" : parm.RollOff_alpha_0_35}
502                                         pilot={ "PILOT_ON" : parm.Pilot_On,
503                                                 "PILOT_OFF" : parm.Pilot_Off}
504                                         pol = { "HORIZONTAL" : parm.Polarisation_Horizontal,
505                                                 "VERTICAL" : parm.Polarisation_Vertical}
506                                         try :
507                                                 parm.orbital_position = self.orb_position
508                                                 parm.polarisation = pol[data[1]]
509                                                 parm.frequency = int(data[2])
510                                                 parm.symbol_rate = int(data[3])
511                                                 parm.system = sys[data[4]]
512                                                 parm.inversion = inv[data[5]]
513                                                 parm.pilot = pilot[data[6]]
514                                                 parm.fec = fec[data[7]]
515                                                 parm.modulation = qam[data[8]]
516                                                 parm.rolloff = roll[data[9]]
517                                                 self.tmp_tplist.append(parm)
518                                         except:
519                                                 pass
520                 self.blindscan_session.close(True)
521
522         def blindscanContainerAvail(self, str):
523                 print str
524                 #if str.startswith("OK"):
525                 self.full_data = self.full_data + str
526
527         def blindscanSessionNone(self, *val):
528                 import time
529                 self.blindscan_container.sendCtrlC()
530                 self.blindscan_container = None
531                 time.sleep(2)
532
533                 if self.frontend:
534                         self.frontend = None
535                         del self.raw_channel
536
537                 if val[0] == False:
538                         self.tmp_tplist = []
539                         self.running_count = self.max_count
540
541                 self.is_runable = True
542
543         def blindscanSessionClose(self, *val):
544                 self.blindscanSessionNone(val[0])
545
546                 if self.tmp_tplist != None and self.tmp_tplist != []:
547                         for p in self.tmp_tplist:
548                                 print "data : [%d][%d][%d][%d][%d][%d][%d][%d][%d][%d]" % (p.orbital_position, p.polarisation, p.frequency, p.symbol_rate, p.system, p.inversion, p.pilot, p.fec, p.modulation, p.modulation)
549
550                         self.startScan(self.tmp_tplist, self.feid)
551                 else:
552                         msg = "No found transponders!!\nPlease check the satellite connection, or scan other search condition." 
553                         if val[0] == False:
554                                 msg = "Blindscan was canceled by the user."
555                         self.session.openWithCallback(self.callbackNone, MessageBox, _(msg), MessageBox.TYPE_INFO, timeout=10)
556                         self.tmp_tplist = []
557
558         def startScan(self, tlist, feid, networkid = 0):
559                 self.scan_session = None
560
561                 flags = 0
562                 if self.scan_clearallservices.value:
563                         flags |= eComponentScan.scanRemoveServices
564                 else:
565                         flags |= eComponentScan.scanDontRemoveUnscanned
566                 if self.scan_onlyfree.value:
567                         flags |= eComponentScan.scanOnlyFree
568                 self.session.open(ServiceScan, [{"transponders": tlist, "feid": feid, "flags": flags, "networkid": networkid}])
569
570 def main(session, **kwargs):
571         session.open(Blindscan)
572                                                            
573 def Plugins(**kwargs):            
574         return PluginDescriptor(name=_("Blindscan"), description="scan type(DVB-S)", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main)
575