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 if self.scan.isDone():
22 errcode = self.scan.getError()
25 self.state = self.Done
27 self.state = self.Error
28 self.errorcode = errcode
29 self.network.setText("")
30 self.transponder.setText("")
32 self.text.setText(_("scan in progress - %d %% done! %d services found!") % (self.scan.getProgress(), self.foundServices + self.scan.getNumServices()))
33 transponder = self.scan.getCurrentTransponder()
37 tp_type = transponder.getSystem()
40 if tp_type == iDVBFrontend.feSatellite:
41 network = _("Satellite")
42 tp = transponder.getDVBS()
45 orb_pos = tp.orbital_position
47 sat_name = str(nimmgr.getSatDescription(orb_pos))
50 if orb_pos > 1800: # west
51 orb_pos = 3600 - orb_pos
55 if sat_name.find("%d.%d" % (orb_pos/10, orb_pos%10)) != -1:
58 network = ("%s %d.%d %s") % (sat_name, orb_pos / 10, orb_pos % 10, h)
59 tp_text = ("%s %s %d%c / %d / %s") %( { 0 : "DVB-S", 1 : "DVB-S2" }[tp.system],
60 { 0 : "Auto", 1 : "QPSK", 2 : "M8PSK", 3 : "QAM16" }[tp.modulation],
62 { 0 : 'H', 1 : 'V', 2 : 'L', 3 : 'R' }[tp.polarisation],
64 { 0 : "AUTO", 1 : "1/2", 2 : "2/3", 3 : "3/4", 4 : "5/6",
65 5 : "7/8", 6 : "8/9", 7 : "3/5", 8 : "4/5", 9 : "9/10",
66 15 : "NONE" }[tp.fec] )
67 elif tp_type == iDVBFrontend.feCable:
69 tp = transponder.getDVBC()
72 tp_text = ("DVB-C %s %d / %d / %s") %( { 0 : "AUTO", 1 : "QAM16", 2 : "QAM32", 3 : "QAM64", 4 : "QAM128", 5 : "QAM256" }[tp.modulation],
75 { 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] )
76 elif tp_type == iDVBFrontend.feTerrestrial:
77 network = _("Terrestrial")
78 tp = transponder.getDVBT()
81 tp_text = ("DVB-T %s %d %s") %( { 0 : "QPSK", 1 : "QAM16", 2 : "QAM64", 3 : "AUTO"}[tp.modulation],
83 { 0 : "Bw 8MHz", 1 : "Bw 7MHz", 2 : "Bw 6MHz", 3 : "Bw Auto" }[tp.bandwidth])
85 print "unknown transponder type in scanStatusChanged"
86 self.network.setText(network)
87 self.transponder.setText(tp_text)
89 if self.state == self.Done:
90 if self.scan.getNumServices() == 1:
91 self.text.setText(_("scan done! One service found!"))
92 elif self.scan.getNumServices() == 0:
93 self.text.setText(_("scan done! No service found!"))
95 self.text.setText(_("scan done! %d services found!") % (self.foundServices + self.scan.getNumServices()))
97 if self.state == self.Error:
98 self.text.setText(_("ERROR - failed to scan (%s)!") % (self.Errors[self.errorcode]) )
100 if self.state == self.Done or self.state == self.Error:
101 if self.run != len(self.scanList) - 1:
102 self.foundServices += self.scan.getNumServices()
107 def __init__(self, progressbar, text, servicelist, passNumber, scanList, network, transponder, frontendInfo):
108 self.foundServices = 0
109 self.progressbar = progressbar
111 self.servicelist = servicelist
112 self.passNumber = passNumber
113 self.scanList = scanList
114 self.frontendInfo = frontendInfo
115 self.transponder = transponder
116 self.network = network
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)