1 from Plugins.Plugin import PluginDescriptor
3 from Screens.Screen import Screen
4 from Screens.ServiceScan import ServiceScan
5 from Screens.MessageBox import MessageBox
6 from Screens.DefaultWizard import DefaultWizard
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
16 from Tools.HardwareInfo import HardwareInfo
17 from Tools.Directories import resolveFilename, SCOPE_DEFAULTPARTITIONMOUNTDIR, SCOPE_DEFAULTDIR, SCOPE_DEFAULTPARTITION
19 from enigma import eTimer, eDVBFrontendParametersSatellite, eComponentScan, eDVBSatelliteEquipmentControl, eDVBFrontendParametersTerrestrial, eDVBFrontendParametersCable, eConsoleAppContainer, eDVBResourceManager
21 class Blindscan(ConfigListScreen, Screen):
23 <screen name="Blindscan" position="center,center" size="560,290" title="Blindscan">
24 <ePixmap pixmap="Vu_HD/buttons/red.png" position="5,0" size="140,40" alphatest="on" />
25 <ePixmap pixmap="Vu_HD/buttons/green.png" position="145,0" size="140,40" alphatest="on" />
26 <ePixmap pixmap="Vu_HD/buttons/button_off.png" position="285,0" size="140,40" alphatest="on" />
27 <ePixmap pixmap="Vu_HD/buttons/blue.png" position="425,0" size="140,40" alphatest="on" />
28 <widget source="key_red" render="Label" position="20,0" zPosition="1" size="115,30" font="Regular;20" halign="center" valign="center" transparent="1" />
29 <widget source="key_green" render="Label" position="160,0" zPosition="1" size="115,30" font="Regular;20" halign="center" valign="center" transparent="1" />
30 <widget source="key_blue" render="Label" position="440,0" zPosition="1" size="115,30" font="Regular;20" halign="center" valign="center" transparent="1" />
31 <widget name="config" position="5,50" size="550,200" scrollbarMode="showOnDemand" />
32 <widget name="introduction" position="0,265" size="560,20" font="Regular;20" halign="center" />
35 def __init__(self, session):
36 Screen.__init__(self, session)
38 self.current_play_service = self.session.nav.getCurrentlyPlayingServiceReference()
42 for slot in nimmanager.nim_slots:
43 if slot.isCompatible("DVB-S"):
44 self.satList.append(nimmanager.getSatListForNim(slot.slot))
52 ConfigListScreen.__init__(self, self.list)
53 if self.scan_nims.value != None and self.scan_nims.value != "" :
54 self["actions"] = ActionMap(["OkCancelActions", "ShortcutActions", "WizardActions", "ColorActions", "SetupActions", ],
56 "red": self.keyCancel,
60 "cancel": self.keyCancel,
62 self["key_red"] = StaticText(_("Exit"))
63 self["key_green"] = StaticText("Start")
64 self["key_blue"] = StaticText("Scan All")
65 self["introduction"] = Label(_("Press Green/OK to start the scan"))
68 self["actions"] = ActionMap(["OkCancelActions", "ShortcutActions", "WizardActions", "ColorActions", "SetupActions", ],
70 "red": self.keyCancel,
71 "green": self.keyNone,
74 "cancel": self.keyCancel,
76 self["key_red"] = StaticText(_("Exit"))
77 self["key_green"] = StaticText(" ")
78 self["key_blue"] = StaticText(" ")
79 self["introduction"] = Label(_("Please setup your tuner configuration."))
83 def callbackNone(self, *retval):
86 def openFrontend(self):
87 res_mgr = eDVBResourceManager.getInstance()
89 self.raw_channel = res_mgr.allocateRawChannel(self.feid)
91 self.frontend = self.raw_channel.getFrontend()
95 print "getFrontend failed"
97 print "getRawChannel failed"
99 print "getResourceManager instance failed"
102 def createConfig(self):
107 "system": eDVBFrontendParametersSatellite.System_DVB_S,
109 "inversion": eDVBFrontendParametersSatellite.Inversion_Unknown,
111 "polarization": eDVBFrontendParametersSatellite.Polarisation_Horizontal,
112 "fec": eDVBFrontendParametersSatellite.FEC_Auto,
113 "fec_s2": eDVBFrontendParametersSatellite.FEC_9_10,
114 "modulation": eDVBFrontendParametersSatellite.Modulation_QPSK
117 self.service = self.session.nav.getCurrentService()
118 if self.service is not None:
119 self.feinfo = self.service.frontendInfo()
120 frontendData = self.feinfo and self.feinfo.getAll(True)
121 if frontendData is not None:
122 ttype = frontendData.get("tuner_type", "UNKNOWN")
124 defaultSat["system"] = frontendData.get("system", eDVBFrontendParametersSatellite.System_DVB_S)
125 defaultSat["frequency"] = frontendData.get("frequency", 0) / 1000
126 defaultSat["inversion"] = frontendData.get("inversion", eDVBFrontendParametersSatellite.Inversion_Unknown)
127 defaultSat["symbolrate"] = frontendData.get("symbol_rate", 0) / 1000
128 defaultSat["polarization"] = frontendData.get("polarization", eDVBFrontendParametersSatellite.Polarisation_Horizontal)
129 if defaultSat["system"] == eDVBFrontendParametersSatellite.System_DVB_S2:
130 defaultSat["fec_s2"] = frontendData.get("fec_inner", eDVBFrontendParametersSatellite.FEC_Auto)
131 defaultSat["rolloff"] = frontendData.get("rolloff", eDVBFrontendParametersSatellite.RollOff_alpha_0_35)
132 defaultSat["pilot"] = frontendData.get("pilot", eDVBFrontendParametersSatellite.Pilot_Unknown)
134 defaultSat["fec"] = frontendData.get("fec_inner", eDVBFrontendParametersSatellite.FEC_Auto)
135 defaultSat["modulation"] = frontendData.get("modulation", eDVBFrontendParametersSatellite.Modulation_QPSK)
136 defaultSat["orbpos"] = frontendData.get("orbital_position", 0)
141 self.scan_sat = ConfigSubsection()
142 self.scan_networkScan = ConfigYesNo(default = False)
145 self.blindscan_hi = ConfigSelection(default = "hi_low", choices = [("low", _("low")), ("high", _("high")), ("hi_low", _("hi_low"))])
147 #ConfigYesNo(default = True)
148 self.blindscan_start_frequency = ConfigInteger(default = 950*1000000)
149 self.blindscan_stop_frequency = ConfigInteger(default = 2150*1000000)
150 self.blindscan_start_symbol = ConfigInteger(default = 2*1000000)
151 self.blindscan_stop_symbol = ConfigInteger(default = 45*1000000)
153 # collect all nims which are *not* set to "nothing"
155 for n in nimmanager.nim_slots:
156 if n.config_mode == "nothing":
158 if n.config_mode == "advanced" and len(nimmanager.getSatListForNim(n.slot)) < 1:
160 if n.config_mode in ("loopthrough", "satposdepends"):
161 root_id = nimmanager.sec.getRoot(n.slot_id, int(n.config.connectedTo.value))
162 if n.type == nimmanager.nim_slots[root_id].type: # check if connected from a DVB-S to DVB-S2 Nim or vice versa
164 nim_list.append((str(n.slot), n.friendly_full_description))
166 self.scan_nims = ConfigSelection(choices = nim_list)
169 self.scan_sat.frequency = ConfigInteger(default = defaultSat["frequency"], limits = (1, 99999))
170 #self.scan_sat.polarization = ConfigSelection(default = defaultSat["polarization"], choices = [
171 self.scan_sat.polarization = ConfigSelection(default = eDVBFrontendParametersSatellite.Polarisation_CircularRight + 1, choices = [
172 (eDVBFrontendParametersSatellite.Polarisation_CircularRight + 1, _("horizontal_vertical")),
173 (eDVBFrontendParametersSatellite.Polarisation_Horizontal, _("horizontal")),
174 (eDVBFrontendParametersSatellite.Polarisation_Vertical, _("vertical")),
175 (eDVBFrontendParametersSatellite.Polarisation_CircularLeft, _("circular left")),
176 (eDVBFrontendParametersSatellite.Polarisation_CircularRight, _("circular right"))])
177 self.scan_scansat = {}
178 for sat in nimmanager.satList:
179 self.scan_scansat[sat[0]] = ConfigYesNo(default = False)
181 self.scan_satselection = []
182 for slot in nimmanager.nim_slots:
183 if slot.isCompatible("DVB-S"):
184 self.scan_satselection.append(getConfigSatlist(defaultSat["orbpos"], self.satList[slot.slot]))
187 def createSetup(self):
189 self.multiscanlist = []
190 index_to_scan = int(self.scan_nims.value)
191 print "ID: ", index_to_scan
193 self.tunerEntry = getConfigListEntry(_("Tuner"), self.scan_nims)
194 self.list.append(self.tunerEntry)
196 if self.scan_nims == [ ]:
199 self.systemEntry = None
200 self.modulationEntry = None
201 nim = nimmanager.nim_slots[index_to_scan]
203 self.scan_networkScan.value = False
204 if nim.isCompatible("DVB-S") :
205 self.list.append(getConfigListEntry(_('Satellite'), self.scan_satselection[index_to_scan]))
206 self.list.append(getConfigListEntry(_('Scan start frequency'), self.blindscan_start_frequency))
207 self.list.append(getConfigListEntry(_('Scan stop frequency'), self.blindscan_stop_frequency))
208 self.list.append(getConfigListEntry(_("Polarity"), self.scan_sat.polarization))
209 self.list.append(getConfigListEntry(_("Scan band"), self.blindscan_hi))
210 self.list.append(getConfigListEntry(_('Scan start symbolrate'), self.blindscan_start_symbol))
211 self.list.append(getConfigListEntry(_('Scan stop symbolrate'), self.blindscan_stop_symbol))
212 self["config"].list = self.list
213 self["config"].l.setList(self.list)
216 cur = self["config"].getCurrent()
218 if cur == self.tunerEntry or \
219 cur == self.systemEntry or \
220 (self.modulationEntry and self.systemEntry[1].value == eDVBFrontendParametersSatellite.System_DVB_S2 and cur == self.modulationEntry):
223 def checkSettings(self):
224 if self.blindscan_start_frequency.value < 950*1000000 or self.blindscan_start_frequency.value > 2150*1000000 :
225 self.session.open(MessageBox, _("Please check again.\nStart frequency must be between 950 and 2150."), MessageBox.TYPE_ERROR)
227 if self.blindscan_stop_frequency.value < 950*1000000 or self.blindscan_stop_frequency.value > 2150*1000000 :
228 self.session.open(MessageBox, _("Please check again.\nStop frequency must be between 950 and 2150."), MessageBox.TYPE_ERROR)
230 if self.blindscan_start_frequency.value > self.blindscan_stop_frequency.value :
231 self.session.open(MessageBox, _("Please check again.\nFrequency : start value is larger than stop value."), MessageBox.TYPE_ERROR)
233 if self.blindscan_start_symbol.value < 2*1000000 or self.blindscan_start_symbol.value > 45*1000000 :
234 self.session.open(MessageBox, _("Please check again.\nStart symbolrate must be between 2MHz and 45MHz."), MessageBox.TYPE_ERROR)
236 if self.blindscan_stop_symbol.value < 2*1000000 or self.blindscan_stop_symbol.value > 45*1000000 :
237 self.session.open(MessageBox, _("Please check again.\nStop symbolrate must be between 2MHz and 45MHz."), MessageBox.TYPE_ERROR)
239 if self.blindscan_start_symbol.value > self.blindscan_stop_symbol.value :
240 self.session.open(MessageBox, _("Please check again.\nSymbolrate : start value is larger than stop value."), MessageBox.TYPE_ERROR)
245 ConfigListScreen.keyLeft(self)
249 ConfigListScreen.keyRight(self)
253 self.session.nav.playService(self.current_play_service)
254 for x in self["config"].list:
259 if self.checkSettings() == False:
263 eDVBFrontendParametersSatellite.Polarisation_Horizontal : "horizontal",
264 eDVBFrontendParametersSatellite.Polarisation_Vertical : "vertical",
265 eDVBFrontendParametersSatellite.Polarisation_CircularLeft : "circular left",
266 eDVBFrontendParametersSatellite.Polarisation_CircularRight : "circular right",
267 eDVBFrontendParametersSatellite.Polarisation_CircularRight + 1 : "horizontal_vertical"
273 tmp_list=[self.satList[0][self.scan_satselection[0].index]]
275 if self.blindscan_hi.value == "hi_low" :
276 tmp_band=["low","high"]
278 tmp_band=[self.blindscan_hi.value]
280 if self.scan_sat.polarization.value == eDVBFrontendParametersSatellite.Polarisation_CircularRight + 1 :
281 tmp_pol=["horizontal","vertical"]
283 tmp_pol=[tab_pol[self.scan_sat.polarization.value]]
285 self.doRun(tmp_list, tmp_pol, tmp_band)
288 if self.checkSettings() == False:
293 tmp_band=["low","high"]
294 tmp_pol=["horizontal","vertical"]
295 for slot in nimmanager.nim_slots:
296 if slot.isCompatible("DVB-S"):
297 for s in self.satList[slot.slot]:
300 self.doRun(tmp_list, tmp_pol, tmp_band)
302 def doRun(self, tmp_list, tmp_pol, tmp_band):
308 self.total_list.append([x,y,z])
309 print "add scan item : ", x, ", ", y, ", ", z
311 self.max_count = len(self.total_list)
312 self.is_runable = True
313 self.running_count = 0
314 self.clockTimer = eTimer()
315 self.clockTimer.callback.append(self.doClock)
316 self.clockTimer.start(1000)
321 if self.running_count >= self.max_count:
322 self.clockTimer.stop()
324 self.clockTimer = None
327 orb = self.total_list[self.running_count][0]
328 pol = self.total_list[self.running_count][1]
329 band = self.total_list[self.running_count][2]
330 self.running_count = self.running_count + 1
331 print "running status-[%d] : [%d][%s][%s]" %(self.running_count, orb[0], pol, band)
332 if self.running_count == self.max_count:
334 self.prepareScanData(orb, pol, band, is_scan)
336 def prepareScanData(self, orb, pol, band, is_scan):
337 self.is_runable = False
338 self.orb_position = orb[0]
339 self.feid = int(self.scan_nims.value)
340 tab_hilow = {"high" : 1, "low" : 0}
342 "horizontal" : eDVBFrontendParametersSatellite.Polarisation_Horizontal,
343 "vertical" : eDVBFrontendParametersSatellite.Polarisation_Vertical,
344 "circular left" : eDVBFrontendParametersSatellite.Polarisation_CircularLeft,
345 "circular right" : eDVBFrontendParametersSatellite.Polarisation_CircularRight
348 returnvalue = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
350 if not self.openFrontend():
351 self.oldref = self.session.nav.getCurrentlyPlayingServiceReference()
352 self.session.nav.stopService()
353 if not self.openFrontend():
354 if self.session.pipshown:
355 self.session.pipshown = False
357 if not self.openFrontend():
359 self.tuner = Tuner(self.frontend)
362 self.scan_sat.frequency.value = 12515
364 self.scan_sat.frequency.value = 11015
365 returnvalue = (self.scan_sat.frequency.value,
371 eDVBFrontendParametersSatellite.System_DVB_S,
375 self.tuner.tune(returnvalue)
377 cmd = "vuplus_blindscan %d %d %d %d %d %d %d" % (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)
378 print "prepared command : [%s]" % (cmd)
379 self.blindscan_container = eConsoleAppContainer()
380 self.blindscan_container.appClosed.append(self.blindscanContainerClose)
381 self.blindscan_container.dataAvail.append(self.blindscanContainerAvail)
382 self.blindscan_container.execute(cmd)
384 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)
386 self.blindscan_session = self.session.openWithCallback(self.blindscanSessionClose, MessageBox, _(tmpstr), MessageBox.TYPE_INFO)
388 self.blindscan_session = self.session.openWithCallback(self.blindscanSessionNone, MessageBox, _(tmpstr), MessageBox.TYPE_INFO)
390 def blindscanContainerClose(self, retval):
391 lines = self.full_data.split('\n')
394 print "cnt :", len(data), ", data :", data
397 parm = eDVBFrontendParametersSatellite()
398 sys = { "DVB-S" : eDVBFrontendParametersSatellite.System_DVB_S,
399 "DVB-S2" : eDVBFrontendParametersSatellite.System_DVB_S2}
400 qam = { "QPSK" : parm.Modulation_QPSK,
401 "8PSK" : parm.Modulation_8PSK}
402 inv = { "INVERSION_OFF" : parm.Inversion_Off,
403 "INVERSION_ON" : parm.Inversion_On,
404 "INVERSION_AUTO" : parm.Inversion_Unknown}
405 fec = { "FEC_AUTO" : parm.FEC_Auto,
406 "FEC_1_2" : parm.FEC_1_2,
407 "FEC_2_3" : parm.FEC_2_3,
408 "FEC_3_4" : parm.FEC_3_4,
409 "FEC_5_6": parm.FEC_5_6,
410 "FEC_7_8" : parm.FEC_7_8,
411 "FEC_8_9" : parm.FEC_8_9,
412 "FEC_3_5" : parm.FEC_3_5,
413 "FEC_9_10" : parm.FEC_9_10,
414 "FEC_NONE" : parm.FEC_None}
415 roll ={ "ROLLOFF_20" : parm.RollOff_alpha_0_20,
416 "ROLLOFF_25" : parm.RollOff_alpha_0_25,
417 "ROLLOFF_35" : parm.RollOff_alpha_0_35}
418 pilot={ "PILOT_ON" : parm.Pilot_On,
419 "PILOT_OFF" : parm.Pilot_Off}
420 pol = { "HORIZONTAL" : parm.Polarisation_Horizontal,
421 "VERTICAL" : parm.Polarisation_Vertical}
422 parm.orbital_position = self.orb_position
423 parm.polarisation = pol[data[1]]
424 parm.frequency = int(data[2])
425 parm.symbol_rate = int(data[3])
426 parm.system = sys[data[4]]
427 parm.inversion = inv[data[5]]
428 parm.pilot = pilot[data[6]]
429 parm.fec = fec[data[7]]
430 parm.modulation = qam[data[8]]
431 parm.rolloff = roll[data[9]]
432 self.tmp_tplist.append(parm)
433 self.blindscan_session.close(True)
435 def blindscanContainerAvail(self, str):
436 self.full_data = self.full_data + str
438 def blindscanSessionNone(self, *val):
440 self.blindscan_container.sendCtrlC()
441 self.blindscan_container = None
450 self.running_count = self.max_count
452 self.is_runable = True
454 def blindscanSessionClose(self, *val):
455 self.blindscanSessionNone(val[0])
457 if self.tmp_tplist != None and self.tmp_tplist != []:
458 for p in self.tmp_tplist:
459 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)
461 self.startScan(self.tmp_tplist, self.feid)
463 msg = "No found transponders!!\nPlease check the satellite connection, or scan other search condition."
465 msg = "Blindscan was canceled by the user."
466 self.session.openWithCallback(self.callbackNone, MessageBox, _(msg), MessageBox.TYPE_INFO, timeout=10)
469 def startScan(self, tlist, feid, networkid = 0):
470 self.scan_session = None
471 self.session.open(ServiceScan, [{"transponders": tlist, "feid": feid, "flags": 0, "networkid": networkid}])
473 def main(session, **kwargs):
474 session.open(Blindscan)
476 def Plugins(**kwargs):
477 return PluginDescriptor(name=_("Blindscan"), description="scan type(DVB-S)", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main)