1 from enigma import eComponentScan, iDVBFrontend
2 from Components.NimManager import nimmanager as nimmgr
12 0: "error starting scanning",
13 1: "error while scanning",
14 2: "no resource manager",
18 def scanStatusChanged(self):
19 if self.state == self.Running:
20 self.progressbar.setValue(self.scan.getProgress())
21 self.lcd_summary.updateProgress(self.scan.getProgress())
22 if self.scan.isDone():
23 errcode = self.scan.getError()
26 self.state = self.Done
28 self.state = self.Error
29 self.errorcode = errcode
30 self.network.setText("")
31 self.transponder.setText("")
33 self.text.setText(_("scan in progress - %d%% done!") % self.scan.getProgress() + ' ' + _("%d services found!") % (self.foundServices + self.scan.getNumServices()))
34 transponder = self.scan.getCurrentTransponder()
38 tp_type = transponder.getSystem()
41 if tp_type == iDVBFrontend.feSatellite:
42 network = _("Satellite")
43 tp = transponder.getDVBS()
46 orb_pos = tp.orbital_position
48 sat_name = str(nimmgr.getSatDescription(orb_pos))
51 if orb_pos > 1800: # west
52 orb_pos = 3600 - orb_pos
56 if sat_name.find("%d.%d" % (orb_pos/10, orb_pos%10)) != -1:
59 network = ("%s %d.%d %s") % (sat_name, orb_pos / 10, orb_pos % 10, h)
60 tp_text = ("%s %s %d%c / %d / %s") %( { 0 : "DVB-S", 1 : "DVB-S2" }[tp.system],
61 { 0 : "Auto", 1 : "QPSK", 2 : "M8PSK", 3 : "QAM16" }[tp.modulation],
63 { 0 : 'H', 1 : 'V', 2 : 'L', 3 : 'R' }[tp.polarisation],
65 { 0 : "AUTO", 1 : "1/2", 2 : "2/3", 3 : "3/4", 4 : "5/6",
66 5 : "7/8", 6 : "8/9", 7 : "3/5", 8 : "4/5", 9 : "9/10",
67 15 : "NONE" }[tp.fec] )
68 elif tp_type == iDVBFrontend.feCable:
70 tp = transponder.getDVBC()
73 tp_text = ("DVB-C %s %d / %d / %s") %( { 0 : "AUTO", 1 : "QAM16", 2 : "QAM32", 3 : "QAM64", 4 : "QAM128", 5 : "QAM256" }[tp.modulation],
76 { 0 : "AUTO", 1 : "1/2", 2 : "2/3", 3 : "3/4", 4 : "5/6", 5 : "7/8", 6 : "8/9", 15 : "NONE" }[tp.fec_inner] )
77 elif tp_type == iDVBFrontend.feTerrestrial:
78 network = _("Terrestrial")
79 tp = transponder.getDVBT()
82 tp_text = ("DVB-T %s %d %s") %( { 0 : "QPSK", 1 : "QAM16", 2 : "QAM64", 3 : "AUTO"}[tp.modulation],
84 { 0 : "Bw 8MHz", 1 : "Bw 7MHz", 2 : "Bw 6MHz", 3 : "Bw Auto" }[tp.bandwidth])
86 print "unknown transponder type in scanStatusChanged"
87 self.network.setText(network)
88 self.transponder.setText(tp_text)
90 if self.state == self.Done:
91 if self.scan.getNumServices() == 0:
92 self.text.setText(_("scan done!") + ' ' + _("%d services found!") % 0 )
94 self.text.setText(_("scan done!") + ' ' + _("%d services found!") % (self.foundServices + self.scan.getNumServices()))
96 if self.state == self.Error:
97 self.text.setText(_("ERROR - failed to scan (%s)!") % (self.Errors[self.errorcode]) )
99 if self.state == self.Done or self.state == self.Error:
100 if self.run != len(self.scanList) - 1:
101 self.foundServices += self.scan.getNumServices()
106 def __init__(self, progressbar, text, servicelist, passNumber, scanList, network, transponder, frontendInfo, lcd_summary):
107 self.foundServices = 0
108 self.progressbar = progressbar
110 self.servicelist = servicelist
111 self.passNumber = passNumber
112 self.scanList = scanList
113 self.frontendInfo = frontendInfo
114 self.transponder = transponder
115 self.network = network
117 self.lcd_summary = lcd_summary
120 self.scan = eComponentScan()
121 self.frontendInfo.frontend_source = lambda : self.scan.getFrontend()
122 self.feid = self.scanList[self.run]["feid"]
123 self.flags = self.scanList[self.run]["flags"]
124 self.state = self.Idle
125 self.scanStatusChanged()
127 for x in self.scanList[self.run]["transponders"]:
128 self.scan.addInitial(x)
130 def updatePass(self):
131 size = len(self.scanList)
133 self.passNumber.setText(_("pass") + " " + str(self.run + 1) + "/" + str(size) + " (" + _("Tuner") + " " + str(self.scanList[self.run]["feid"]) + ")")
138 self.scan.statusChanged.get().append(self.scanStatusChanged)
139 self.scan.newService.get().append(self.newService)
140 self.servicelist.clear()
141 self.state = self.Running
142 err = self.scan.start(self.feid, self.flags)
143 self.frontendInfo.updateFrontendData()
145 self.state = self.Error
147 self.scanStatusChanged()
150 self.scan.statusChanged.get().remove(self.scanStatusChanged)
151 self.scan.newService.get().remove(self.newService)
152 if not self.isDone():
153 print "*** warning *** scan was not finished!"
158 return self.state == self.Done or self.state == self.Error
160 def newService(self):
161 newServiceName = self.scan.getLastServiceName()
162 self.servicelist.addItem(newServiceName)
163 self.lcd_summary.updateService(self.scan.getLastServiceName())