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 = ("DVB-T %s %d %s") %( { tp.Modulation_QPSK : "QPSK",
84 tp.Modulation_QAM16 : "QAM16", tp.Modulation_QAM64 : "QAM64",
85 tp.Modulation_Auto : "AUTO" }.get(tp.modulation, tp.Modulation_Auto),
87 { tp.Bandwidth_8MHz : "Bw 8MHz", tp.Bandwidth_7MHz : "Bw 7MHz", tp.Bandwidth_6MHz : "Bw 6MHz",
88 tp.Bandwidth_Auto : "Bw Auto" }.get(tp.bandwidth, tp.Bandwidth_Auto))
90 print "unknown transponder type in scanStatusChanged"
91 self.network.setText(network)
92 self.transponder.setText(tp_text)
94 if self.state == self.Done:
95 if self.scan.getNumServices() == 0:
96 self.text.setText(_("scan done!") + ' ' + _("%d services found!") % 0 )
98 self.text.setText(_("scan done!") + ' ' + _("%d services found!") % (self.foundServices + self.scan.getNumServices()))
100 if self.state == self.Error:
101 self.text.setText(_("ERROR - failed to scan (%s)!") % (self.Errors[self.errorcode]) )
103 if self.state == self.Done or self.state == self.Error:
104 if self.run != len(self.scanList) - 1:
105 self.foundServices += self.scan.getNumServices()
110 def __init__(self, progressbar, text, servicelist, passNumber, scanList, network, transponder, frontendInfo, lcd_summary):
111 self.foundServices = 0
112 self.progressbar = progressbar
114 self.servicelist = servicelist
115 self.passNumber = passNumber
116 self.scanList = scanList
117 self.frontendInfo = frontendInfo
118 self.transponder = transponder
119 self.network = network
121 self.lcd_summary = lcd_summary
124 self.scan = eComponentScan()
125 self.frontendInfo.frontend_source = lambda : self.scan.getFrontend()
126 self.feid = self.scanList[self.run]["feid"]
127 self.flags = self.scanList[self.run]["flags"]
128 self.state = self.Idle
129 self.scanStatusChanged()
131 for x in self.scanList[self.run]["transponders"]:
132 self.scan.addInitial(x)
134 def updatePass(self):
135 size = len(self.scanList)
137 self.passNumber.setText(_("pass") + " " + str(self.run + 1) + "/" + str(size) + " (" + _("Tuner") + " " + str(self.scanList[self.run]["feid"]) + ")")
142 self.scan.statusChanged.get().append(self.scanStatusChanged)
143 self.scan.newService.get().append(self.newService)
144 self.servicelist.clear()
145 self.state = self.Running
146 err = self.scan.start(self.feid, self.flags)
147 self.frontendInfo.updateFrontendData()
149 self.state = self.Error
151 self.scanStatusChanged()
154 self.scan.statusChanged.get().remove(self.scanStatusChanged)
155 self.scan.newService.get().remove(self.newService)
156 if not self.isDone():
157 print "*** warning *** scan was not finished!"
162 return self.state == self.Done or self.state == self.Error
164 def newService(self):
165 newServiceName = self.scan.getLastServiceName()
166 self.servicelist.addItem(newServiceName)
167 self.lcd_summary.updateService(self.scan.getLastServiceName())