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