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="80,40" alphatest="on" />
25 <ePixmap pixmap="Vu_HD/buttons/green.png" position="186,0" size="80,40" alphatest="on" />
26 <ePixmap pixmap="Vu_HD/buttons/blue.png" position="372,0" size="80,40" alphatest="on" />
28 <widget source="key_red" render="Label" position="28,0" zPosition="1" size="160,30" font="Regular;20" halign="center" valign="center" transparent="1"/>
29 <widget source="key_green" render="Label" position="213,0" zPosition="1" size="160,30" font="Regular;20" halign="center" valign="center" transparent="1"/>
30 <widget source="key_blue" render="Label" position="400,0" zPosition="1" size="160,30" font="Regular;20" halign="center" valign="center" transparent="1"/>
32 <widget name="config" position="5,50" size="550,200" scrollbarMode="showOnDemand" />
33 <widget name="introduction" position="0,265" size="560,20" font="Regular;20" halign="center" />
36 def __init__(self, session):
37 Screen.__init__(self, session)
39 self.current_play_service = self.session.nav.getCurrentlyPlayingServiceReference()
43 for slot in nimmanager.nim_slots:
44 if slot.isCompatible("DVB-S"):
45 self.satList.append(nimmanager.getSatListForNim(slot.slot))
53 ConfigListScreen.__init__(self, self.list)
54 if self.scan_nims.value != None and self.scan_nims.value != "" :
55 self["actions"] = ActionMap(["OkCancelActions", "ShortcutActions", "WizardActions", "ColorActions", "SetupActions", ],
57 "red": self.keyCancel,
61 "cancel": self.keyCancel,
63 self["key_red"] = StaticText(_("Exit"))
64 self["key_green"] = StaticText("Start")
65 self["key_blue"] = StaticText("Scan All")
66 self["introduction"] = Label(_("Press Green/OK to start the scan"))
69 self["actions"] = ActionMap(["OkCancelActions", "ShortcutActions", "WizardActions", "ColorActions", "SetupActions", ],
71 "red": self.keyCancel,
72 "green": self.keyNone,
75 "cancel": self.keyCancel,
77 self["key_red"] = StaticText(_("Exit"))
78 self["key_green"] = StaticText(" ")
79 self["key_blue"] = StaticText(" ")
80 self["introduction"] = Label(_("Please setup your tuner configuration."))
84 def callbackNone(self, *retval):
87 def openFrontend(self):
88 res_mgr = eDVBResourceManager.getInstance()
90 self.raw_channel = res_mgr.allocateRawChannel(self.feid)
92 self.frontend = self.raw_channel.getFrontend()
96 print "getFrontend failed"
98 print "getRawChannel failed"
100 print "getResourceManager instance failed"
103 def createConfig(self):
108 "system": eDVBFrontendParametersSatellite.System_DVB_S,
110 "inversion": eDVBFrontendParametersSatellite.Inversion_Unknown,
112 "polarization": eDVBFrontendParametersSatellite.Polarisation_Horizontal,
113 "fec": eDVBFrontendParametersSatellite.FEC_Auto,
114 "fec_s2": eDVBFrontendParametersSatellite.FEC_9_10,
115 "modulation": eDVBFrontendParametersSatellite.Modulation_QPSK
118 self.service = self.session.nav.getCurrentService()
119 if self.service is not None:
120 self.feinfo = self.service.frontendInfo()
121 frontendData = self.feinfo and self.feinfo.getAll(True)
122 if frontendData is not None:
123 ttype = frontendData.get("tuner_type", "UNKNOWN")
125 defaultSat["system"] = frontendData.get("system", eDVBFrontendParametersSatellite.System_DVB_S)
126 defaultSat["frequency"] = frontendData.get("frequency", 0) / 1000
127 defaultSat["inversion"] = frontendData.get("inversion", eDVBFrontendParametersSatellite.Inversion_Unknown)
128 defaultSat["symbolrate"] = frontendData.get("symbol_rate", 0) / 1000
129 defaultSat["polarization"] = frontendData.get("polarization", eDVBFrontendParametersSatellite.Polarisation_Horizontal)
130 if defaultSat["system"] == eDVBFrontendParametersSatellite.System_DVB_S2:
131 defaultSat["fec_s2"] = frontendData.get("fec_inner", eDVBFrontendParametersSatellite.FEC_Auto)
132 defaultSat["rolloff"] = frontendData.get("rolloff", eDVBFrontendParametersSatellite.RollOff_alpha_0_35)
133 defaultSat["pilot"] = frontendData.get("pilot", eDVBFrontendParametersSatellite.Pilot_Unknown)
135 defaultSat["fec"] = frontendData.get("fec_inner", eDVBFrontendParametersSatellite.FEC_Auto)
136 defaultSat["modulation"] = frontendData.get("modulation", eDVBFrontendParametersSatellite.Modulation_QPSK)
137 defaultSat["orbpos"] = frontendData.get("orbital_position", 0)
142 self.scan_sat = ConfigSubsection()
143 self.scan_networkScan = ConfigYesNo(default = False)
146 self.blindscan_hi = ConfigSelection(default = "hi_low", choices = [("low", _("low")), ("high", _("high")), ("hi_low", _("hi_low"))])
148 #ConfigYesNo(default = True)
149 self.blindscan_start_frequency = ConfigInteger(default = 950*1000000)
150 self.blindscan_stop_frequency = ConfigInteger(default = 2150*1000000)
151 self.blindscan_start_symbol = ConfigInteger(default = 2*1000000)
152 self.blindscan_stop_symbol = ConfigInteger(default = 45*1000000)
154 # collect all nims which are *not* set to "nothing"
156 for n in nimmanager.nim_slots:
157 if n.config_mode == "nothing":
159 if n.config_mode == "advanced" and len(nimmanager.getSatListForNim(n.slot)) < 1:
161 if n.config_mode in ("loopthrough", "satposdepends"):
162 root_id = nimmanager.sec.getRoot(n.slot_id, int(n.config.connectedTo.value))
163 if n.type == nimmanager.nim_slots[root_id].type: # check if connected from a DVB-S to DVB-S2 Nim or vice versa
165 nim_list.append((str(n.slot), n.friendly_full_description))
167 self.scan_nims = ConfigSelection(choices = nim_list)
170 self.scan_sat.frequency = ConfigInteger(default = defaultSat["frequency"], limits = (1, 99999))
171 #self.scan_sat.polarization = ConfigSelection(default = defaultSat["polarization"], choices = [
172 self.scan_sat.polarization = ConfigSelection(default = eDVBFrontendParametersSatellite.Polarisation_CircularRight + 1, choices = [
173 (eDVBFrontendParametersSatellite.Polarisation_CircularRight + 1, _("horizontal_vertical")),
174 (eDVBFrontendParametersSatellite.Polarisation_Horizontal, _("horizontal")),
175 (eDVBFrontendParametersSatellite.Polarisation_Vertical, _("vertical")),
176 (eDVBFrontendParametersSatellite.Polarisation_CircularLeft, _("circular left")),
177 (eDVBFrontendParametersSatellite.Polarisation_CircularRight, _("circular right"))])
178 self.scan_scansat = {}
179 for sat in nimmanager.satList:
180 self.scan_scansat[sat[0]] = ConfigYesNo(default = False)
182 self.scan_satselection = []
183 for slot in nimmanager.nim_slots:
184 if slot.isCompatible("DVB-S"):
185 self.scan_satselection.append(getConfigSatlist(defaultSat["orbpos"], self.satList[slot.slot]))
188 def createSetup(self):
190 self.multiscanlist = []
191 index_to_scan = int(self.scan_nims.value)
192 print "ID: ", index_to_scan
194 self.tunerEntry = getConfigListEntry(_("Tuner"), self.scan_nims)
195 self.list.append(self.tunerEntry)
197 if self.scan_nims == [ ]:
200 self.systemEntry = None
201 self.modulationEntry = None
202 nim = nimmanager.nim_slots[index_to_scan]
204 self.scan_networkScan.value = False
205 if nim.isCompatible("DVB-S") :
206 self.list.append(getConfigListEntry(_('Satellite'), self.scan_satselection[index_to_scan]))
207 self.list.append(getConfigListEntry(_('Scan start frequency'), self.blindscan_start_frequency))
208 self.list.append(getConfigListEntry(_('Scan stop frequency'), self.blindscan_stop_frequency))
209 self.list.append(getConfigListEntry(_("Polarity"), self.scan_sat.polarization))
210 self.list.append(getConfigListEntry(_("Scan band"), self.blindscan_hi))
211 self.list.append(getConfigListEntry(_('Scan start symbolrate'), self.blindscan_start_symbol))
212 self.list.append(getConfigListEntry(_('Scan stop symbolrate'), self.blindscan_stop_symbol))
213 self["config"].list = self.list
214 self["config"].l.setList(self.list)
217 cur = self["config"].getCurrent()
219 if cur == self.tunerEntry or \
220 cur == self.systemEntry or \
221 (self.modulationEntry and self.systemEntry[1].value == eDVBFrontendParametersSatellite.System_DVB_S2 and cur == self.modulationEntry):
224 def checkSettings(self):
225 if self.blindscan_start_frequency.value < 950*1000000 or self.blindscan_start_frequency.value > 2150*1000000 :
226 self.session.open(MessageBox, _("Please check again.\nStart frequency must be between 950 and 2150."), MessageBox.TYPE_ERROR)
228 if self.blindscan_stop_frequency.value < 950*1000000 or self.blindscan_stop_frequency.value > 2150*1000000 :
229 self.session.open(MessageBox, _("Please check again.\nStop frequency must be between 950 and 2150."), MessageBox.TYPE_ERROR)
231 if self.blindscan_start_frequency.value > self.blindscan_stop_frequency.value :
232 self.session.open(MessageBox, _("Please check again.\nFrequency : start value is larger than stop value."), MessageBox.TYPE_ERROR)
234 if self.blindscan_start_symbol.value < 2*1000000 or self.blindscan_start_symbol.value > 45*1000000 :
235 self.session.open(MessageBox, _("Please check again.\nStart symbolrate must be between 2MHz and 45MHz."), MessageBox.TYPE_ERROR)
237 if self.blindscan_stop_symbol.value < 2*1000000 or self.blindscan_stop_symbol.value > 45*1000000 :
238 self.session.open(MessageBox, _("Please check again.\nStop symbolrate must be between 2MHz and 45MHz."), MessageBox.TYPE_ERROR)
240 if self.blindscan_start_symbol.value > self.blindscan_stop_symbol.value :
241 self.session.open(MessageBox, _("Please check again.\nSymbolrate : start value is larger than stop value."), MessageBox.TYPE_ERROR)
246 ConfigListScreen.keyLeft(self)
250 ConfigListScreen.keyRight(self)
254 self.session.nav.playService(self.current_play_service)
255 for x in self["config"].list:
260 if self.checkSettings() == False:
264 eDVBFrontendParametersSatellite.Polarisation_Horizontal : "horizontal",
265 eDVBFrontendParametersSatellite.Polarisation_Vertical : "vertical",
266 eDVBFrontendParametersSatellite.Polarisation_CircularLeft : "circular left",
267 eDVBFrontendParametersSatellite.Polarisation_CircularRight : "circular right",
268 eDVBFrontendParametersSatellite.Polarisation_CircularRight + 1 : "horizontal_vertical"
274 tmp_list=[self.satList[0][self.scan_satselection[0].index]]
276 if self.blindscan_hi.value == "hi_low" :
277 tmp_band=["low","high"]
279 tmp_band=[self.blindscan_hi.value]
281 if self.scan_sat.polarization.value == eDVBFrontendParametersSatellite.Polarisation_CircularRight + 1 :
282 tmp_pol=["horizontal","vertical"]
284 tmp_pol=[tab_pol[self.scan_sat.polarization.value]]
286 self.doRun(tmp_list, tmp_pol, tmp_band)
289 if self.checkSettings() == False:
294 tmp_band=["low","high"]
295 tmp_pol=["horizontal","vertical"]
296 for slot in nimmanager.nim_slots:
297 if slot.isCompatible("DVB-S"):
298 for s in self.satList[slot.slot]:
301 self.doRun(tmp_list, tmp_pol, tmp_band)
303 def doRun(self, tmp_list, tmp_pol, tmp_band):
309 self.total_list.append([x,y,z])
310 print "add scan item : ", x, ", ", y, ", ", z
312 self.max_count = len(self.total_list)
313 self.is_runable = True
314 self.running_count = 0
315 self.clockTimer = eTimer()
316 self.clockTimer.callback.append(self.doClock)
317 self.clockTimer.start(1000)
322 if self.running_count >= self.max_count:
323 self.clockTimer.stop()
325 self.clockTimer = None
328 orb = self.total_list[self.running_count][0]
329 pol = self.total_list[self.running_count][1]
330 band = self.total_list[self.running_count][2]
331 self.running_count = self.running_count + 1
332 print "running status-[%d] : [%d][%s][%s]" %(self.running_count, orb[0], pol, band)
333 if self.running_count == self.max_count:
335 self.prepareScanData(orb, pol, band, is_scan)
337 def prepareScanData(self, orb, pol, band, is_scan):
338 self.is_runable = False
339 self.orb_position = orb[0]
340 self.feid = int(self.scan_nims.value)
341 tab_hilow = {"high" : 1, "low" : 0}
343 "horizontal" : eDVBFrontendParametersSatellite.Polarisation_Horizontal,
344 "vertical" : eDVBFrontendParametersSatellite.Polarisation_Vertical,
345 "circular left" : eDVBFrontendParametersSatellite.Polarisation_CircularLeft,
346 "circular right" : eDVBFrontendParametersSatellite.Polarisation_CircularRight
349 returnvalue = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
351 if not self.openFrontend():
352 self.oldref = self.session.nav.getCurrentlyPlayingServiceReference()
353 self.session.nav.stopService()
354 if not self.openFrontend():
355 if self.session.pipshown:
356 self.session.pipshown = False
358 if not self.openFrontend():
360 self.tuner = Tuner(self.frontend)
363 self.scan_sat.frequency.value = 12515
365 self.scan_sat.frequency.value = 11015
366 returnvalue = (self.scan_sat.frequency.value,
372 eDVBFrontendParametersSatellite.System_DVB_S,
376 self.tuner.tune(returnvalue)
378 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)
379 print "prepared command : [%s]" % (cmd)
380 self.blindscan_container = eConsoleAppContainer()
381 self.blindscan_container.appClosed.append(self.blindscanContainerClose)
382 self.blindscan_container.dataAvail.append(self.blindscanContainerAvail)
383 self.blindscan_container.execute(cmd)
385 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)
387 self.blindscan_session = self.session.openWithCallback(self.blindscanSessionClose, MessageBox, _(tmpstr), MessageBox.TYPE_INFO)
389 self.blindscan_session = self.session.openWithCallback(self.blindscanSessionNone, MessageBox, _(tmpstr), MessageBox.TYPE_INFO)
391 def blindscanContainerClose(self, retval):
392 lines = self.full_data.split('\n')
395 print "cnt :", len(data), ", data :", data
398 parm = eDVBFrontendParametersSatellite()
399 sys = { "DVB-S" : eDVBFrontendParametersSatellite.System_DVB_S,
400 "DVB-S2" : eDVBFrontendParametersSatellite.System_DVB_S2}
401 qam = { "QPSK" : parm.Modulation_QPSK,
402 "8PSK" : parm.Modulation_8PSK}
403 inv = { "INVERSION_OFF" : parm.Inversion_Off,
404 "INVERSION_ON" : parm.Inversion_On,
405 "INVERSION_AUTO" : parm.Inversion_Unknown}
406 fec = { "FEC_AUTO" : parm.FEC_Auto,
407 "FEC_1_2" : parm.FEC_1_2,
408 "FEC_2_3" : parm.FEC_2_3,
409 "FEC_3_4" : parm.FEC_3_4,
410 "FEC_5_6": parm.FEC_5_6,
411 "FEC_7_8" : parm.FEC_7_8,
412 "FEC_8_9" : parm.FEC_8_9,
413 "FEC_3_5" : parm.FEC_3_5,
414 "FEC_9_10" : parm.FEC_9_10,
415 "FEC_NONE" : parm.FEC_None}
416 roll ={ "ROLLOFF_20" : parm.RollOff_alpha_0_20,
417 "ROLLOFF_25" : parm.RollOff_alpha_0_25,
418 "ROLLOFF_35" : parm.RollOff_alpha_0_35}
419 pilot={ "PILOT_ON" : parm.Pilot_On,
420 "PILOT_OFF" : parm.Pilot_Off}
421 pol = { "HORIZONTAL" : parm.Polarisation_Horizontal,
422 "VERTICAL" : parm.Polarisation_Vertical}
423 parm.orbital_position = self.orb_position
424 parm.polarisation = pol[data[1]]
425 parm.frequency = int(data[2])
426 parm.symbol_rate = int(data[3])
427 parm.system = sys[data[4]]
428 parm.inversion = inv[data[5]]
429 parm.pilot = pilot[data[6]]
430 parm.fec = fec[data[7]]
431 parm.modulation = qam[data[8]]
432 parm.rolloff = roll[data[9]]
433 self.tmp_tplist.append(parm)
434 self.blindscan_session.close(True)
436 def blindscanContainerAvail(self, str):
437 self.full_data = self.full_data + str
439 def blindscanSessionNone(self, *val):
441 self.blindscan_container.sendCtrlC()
442 self.blindscan_container = None
451 self.running_count = self.max_count
453 self.is_runable = True
455 def blindscanSessionClose(self, *val):
456 self.blindscanSessionNone(val[0])
458 if self.tmp_tplist != None and self.tmp_tplist != []:
459 for p in self.tmp_tplist:
460 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)
462 self.startScan(self.tmp_tplist, self.feid)
464 msg = "No found transponders!!\nPlease check the satellite connection, or scan other search condition."
466 msg = "Blindscan was canceled by the user."
467 self.session.openWithCallback(self.callbackNone, MessageBox, _(msg), MessageBox.TYPE_INFO, timeout=10)
470 def startScan(self, tlist, feid, networkid = 0):
471 self.scan_session = None
472 self.session.open(ServiceScan, [{"transponders": tlist, "feid": feid, "flags": 0, "networkid": networkid}])
474 def main(session, **kwargs):
475 session.open(Blindscan)
477 def Plugins(**kwargs):
478 return PluginDescriptor(name=_("Blindscan"), description="scan type(DVB-S)", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main)