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()
39 if tp_type == iDVBFrontend.feSatellite:
40 network = _("Satellite")
41 tp = transponder.getDVBS()
42 orb_pos = tp.orbital_position
44 sat_name = str(nimmgr.getSatDescription(orb_pos))
47 if orb_pos > 1800: # west
48 orb_pos = 3600 - orb_pos
52 if sat_name.find("%d.%d" % (orb_pos/10, orb_pos%10)) != -1:
55 network = ("%s %d.%d %s") % (sat_name, orb_pos / 10, orb_pos % 10, h)
56 tp_text = ("%s %s %d%c / %d / %s") %( { tp.System_DVB_S : "DVB-S",
57 tp.System_DVB_S2 : "DVB-S2" }.get(tp.system, tp.System_DVB_S),
58 { tp.Modulation_Auto : "Auto", tp.Modulation_QPSK : "QPSK",
59 tp.Modulation_8PSK : "8PSK", tp.Modulation_QAM16 : "QAM16" }.get(tp.modulation, tp.Modulation_QPSK),
61 { tp.Polarisation_Horizontal : 'H', tp.Polarisation_Vertical : 'V', tp.Polarisation_CircularLeft : 'L',
62 tp.Polarisation_CircularRight : 'R' }.get(tp.polarisation, tp.Polarisation_Horizontal),
64 { tp.FEC_Auto : "AUTO", tp.FEC_1_2 : "1/2", tp.FEC_2_3 : "2/3",
65 tp.FEC_3_4 : "3/4", tp.FEC_5_6 : "5/6", tp.FEC_7_8 : "7/8",
66 tp.FEC_8_9 : "8/9", tp.FEC_3_5 : "3/5", tp.FEC_4_5 : "4/5",
67 tp.FEC_9_10 : "9/10", tp.FEC_None : "NONE" }.get(tp.fec, tp.FEC_Auto))
68 elif tp_type == iDVBFrontend.feCable:
70 tp = transponder.getDVBC()
71 tp_text = ("DVB-C %s %d / %d / %s") %( { tp.Modulation_Auto : "AUTO",
72 tp.Modulation_QAM16 : "QAM16", tp.Modulation_QAM32 : "QAM32",
73 tp.Modulation_QAM64 : "QAM64", tp.Modulation_QAM128 : "QAM128",
74 tp.Modulation_QAM256 : "QAM256" }.get(tp.modulation, tp.Modulation_Auto),
77 { tp.FEC_Auto : "AUTO", tp.FEC_1_2 : "1/2", tp.FEC_2_3 : "2/3",
78 tp.FEC_3_4 : "3/4", tp.FEC_5_6 : "5/6", tp.FEC_7_8 : "7/8",
79 tp.FEC_8_9 : "8/9", tp.FEC_None : "NONE" }.get(tp.fec_inner, tp.FEC_Auto))
80 elif tp_type == iDVBFrontend.feTerrestrial:
81 network = _("Terrestrial")
82 tp = transponder.getDVBT()
83 tp_text = ("%s %s %d %s") %(
85 tp.System_DVB_T : "DVB-T",
86 tp.System_DVB_T2 : "DVB-T2"
89 tp.Modulation_QPSK : "QPSK",
90 tp.Modulation_QAM16 : "QAM16",
91 tp.Modulation_QAM64 : "QAM64",
92 tp.Modulation_QAM256 : "QAM256",
93 tp.Modulation_Auto : "AUTO"
94 }.get(tp.modulation, tp.Modulation_Auto),
97 tp.Bandwidth_8MHz : "Bw 8MHz",
98 tp.Bandwidth_7MHz : "Bw 7MHz",
99 tp.Bandwidth_6MHz : "Bw 6MHz",
100 tp.Bandwidth_Auto : "Bw Auto",
101 tp.Bandwidth_5MHz : "Bw 5MHz",
102 tp.Bandwidth_10MHz : "Bw 10MHz",
103 tp.Bandwidth_1_712MHz : "Bw 1.712MHz"
104 }.get(tp.bandwidth, tp.Bandwidth_Auto))
106 print "unknown transponder type in scanStatusChanged"
107 self.network.setText(network)
108 self.transponder.setText(tp_text)
110 if self.state == self.Done:
111 if self.scan.getNumServices() == 0:
112 self.text.setText(_("scan done!") + ' ' + _("%d services found!") % 0 )
114 self.text.setText(_("scan done!") + ' ' + _("%d services found!") % (self.foundServices + self.scan.getNumServices()))
116 if self.state == self.Error:
117 self.text.setText(_("ERROR - failed to scan (%s)!") % (self.Errors[self.errorcode]) )
119 if self.state == self.Done or self.state == self.Error:
120 if self.run != len(self.scanList) - 1:
121 self.foundServices += self.scan.getNumServices()
122 self.execEnd(False) # reset eComponentScan
126 def __init__(self, progressbar, text, servicelist, passNumber, scanList, network, transponder, frontendInfo, lcd_summary):
127 self.foundServices = 0
128 self.progressbar = progressbar
130 self.servicelist = servicelist
131 self.passNumber = passNumber
132 self.scanList = scanList
133 self.frontendInfo = frontendInfo
134 self.transponder = transponder
135 self.network = network
137 self.lcd_summary = lcd_summary
141 if self.scan is None:
142 self.scan = eComponentScan()
143 self.frontendInfo.frontend_source = lambda : self.scan.getFrontend()
144 self.feid = self.scanList[self.run]["feid"]
145 self.flags = self.scanList[self.run]["flags"]
146 self.state = self.Idle
147 self.scanStatusChanged()
149 for x in self.scanList[self.run]["transponders"]:
150 self.scan.addInitial(x)
152 def updatePass(self):
153 size = len(self.scanList)
155 self.passNumber.setText(_("pass") + " " + str(self.run + 1) + "/" + str(size) + " (" + _("Tuner") + " " + str(self.scanList[self.run]["feid"]) + ")")
160 self.scan.statusChanged.get().append(self.scanStatusChanged)
161 self.scan.newService.get().append(self.newService)
162 self.servicelist.clear()
163 self.state = self.Running
164 err = self.scan.start(self.feid, self.flags)
165 self.frontendInfo.updateFrontendData()
167 self.state = self.Error
169 self.scanStatusChanged()
171 def execEnd(self, onClose = True):
172 # when closing screen, destroy eComponentScan. otherwise reset.
173 self.scan.statusChanged.get().remove(self.scanStatusChanged)
174 self.scan.newService.get().remove(self.newService)
175 if not self.isDone():
176 print "*** warning *** scan was not finished!"
184 return self.state == self.Done or self.state == self.Error
186 def newService(self):
187 newServiceName = self.scan.getLastServiceName()
188 self.servicelist.addItem(newServiceName)
189 self.lcd_summary.updateService(self.scan.getLastServiceName())