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