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