Пример #1
0
	def createConfig(self, foo):
		self.tuning_type = ConfigSelection(default = "predefined_transponder", choices = [("single_transponder", _("User defined transponder")), ("predefined_transponder", _("Predefined transponder"))])
		self.orbital_position = 192
		if self.frontendData and self.frontendData.has_key('orbital_position'):
			self.orbital_position = self.frontendData['orbital_position']
		ScanSetup.createConfig(self, self.frontendData)

		for x in (self.scan_sat.frequency,
			self.scan_sat.inversion, self.scan_sat.symbolrate,
			self.scan_sat.polarization, self.scan_sat.fec, self.scan_sat.pilot,
			self.scan_sat.fec_s2, self.scan_sat.fec, self.scan_sat.modulation,
			self.scan_sat.rolloff, self.scan_sat.system,
			self.scan_ter.channel, self.scan_ter.frequency, self.scan_ter.inversion,
			self.scan_ter.bandwidth, self.scan_ter.fechigh, self.scan_ter.feclow,
			self.scan_ter.modulation, self.scan_ter.transmission,
			self.scan_ter.guard, self.scan_ter.hierarchy, self.scan_ter.plp_id,
			self.scan_cab.frequency, self.scan_cab.inversion, self.scan_cab.symbolrate,
			self.scan_cab.modulation, self.scan_cab.fec):
			x.addNotifier(self.retune, initial_call = False)

		satfinder_nim_list = []
		for n in nimmanager.nim_slots:
			if not (n.isCompatible("DVB-S") or n.isCompatible("DVB-T") or n.isCompatible("DVB-C")):
				continue
			if n.config_mode  in ("loopthrough", "satposdepends", "nothing"):
				continue
			if n.isCompatible("DVB-S") and len(nimmanager.getSatListForNim(n.slot)) < 1:
				continue
			if n.isCompatible("DVB-S") and n.isFBCTuner() and not n.isFBCRoot():
				continue
			satfinder_nim_list.append((str(n.slot), n.friendly_full_description))
		self.satfinder_scan_nims = ConfigSelection(choices = satfinder_nim_list)
		if self.frontendData is not None and len(satfinder_nim_list) > 0: # open the plugin with the currently active NIM as default
			active_nim = self.frontendData.get("tuner_number", int(satfinder_nim_list[0][0]))
			if not nimmanager.nim_slots[active_nim].isFBCLink():
				self.satfinder_scan_nims.setValue(str(active_nim))

		self.feid = int(self.satfinder_scan_nims.value)

		self.satList = []
		self.scan_satselection = []
		for slot in nimmanager.nim_slots:
			if slot.isCompatible("DVB-S"):
				self.satList.append(nimmanager.getSatListForNim(slot.slot))
				self.scan_satselection.append(getConfigSatlist(self.orbital_position, self.satList[slot.slot]))
			else:
				self.satList.append(None)

		if self.frontendData:
			ttype = self.frontendData.get("tuner_type", "UNKNOWN")
			if ttype == "DVB-S" and self.predefinedTranspondersList(self.getSelectedSatIndex(self.feid)) is None and len(nimmanager.getTransponders(self.getSelectedSatIndex(self.feid))) > 0:
				self.tuning_type.value = "single_transponder"
			elif ttype == "DVB-T" and self.predefinedTerrTranspondersList() is None and len(nimmanager.getTranspondersTerrestrial(nimmanager.getTerrestrialDescription(self.feid))) > 0:
				self.tuning_type.value = "single_transponder"
			elif ttype == "DVB-C" and self.predefinedCabTranspondersList() is None and len(nimmanager.getTranspondersCable(self.feid)) > 0:
				self.tuning_type.value = "single_transponder"
Пример #2
0
def getInitialCableTransponderList(tlist, nim):
	list = nimmanager.getTranspondersCable(nim)
	for x in list:
		if x[0] == 1: #CABLE
			parm = eDVBFrontendParametersCable()
			parm.frequency = x[1]
			parm.symbol_rate = x[2]
			parm.modulation = x[3]
			parm.fec_inner = x[4]
			parm.inversion = x[5]
			parm.system = x[6]
			tlist.append(parm)
Пример #3
0
def getInitialCableTransponderList(tlist, nim):
	list = nimmanager.getTranspondersCable(nim)
	for x in list:
		if x[0] == 1: #CABLE
			parm = eDVBFrontendParametersCable()
			parm.frequency = x[1]
			parm.symbol_rate = x[2]
			parm.modulation = x[3]
			parm.fec_inner = x[4]
			parm.inversion = parm.Inversion_Unknown
			#print "frequency:", x[1]
			#print "symbol_rate:", x[2]
			#print "modulation:", x[3]
			#print "fec_inner:", x[4]
			#print "inversion:", 2
			tlist.append(parm)
Пример #4
0
	def retuneCab(self):
		if self.initcomplete:
			if self.tuning_type.value == "single_transponder":
				transponder = (
					self.scan_cab.frequency.value*1000,
					self.scan_cab.symbolrate.value*1000,
					self.scan_cab.modulation.value,
					self.scan_cab.fec.value,
					self.scan_cab.inversion.value
				)
				self.tuner.tuneCab(transponder)
				self.transponder = transponder
			elif self.tuning_type.value == "predefined_transponder":
				tps = nimmanager.getTranspondersCable(int(self.satfinder_scan_nims.value))
				if len(tps) > self.CableTransponders.index :
					tp = tps[self.CableTransponders.index]
					# tp = 0 transponder type, 1 freq, 2 sym, 3 mod, 4 fec, 5 inv, 6 sys
					transponder = (tp[1], tp[2], tp[3], tp[4], tp[5])
					self.tuner.tuneCab(transponder)
					self.transponder = transponder
Пример #5
0
	def retuneCab(self, configElement):
		if not nimmanager.nim_slots[int(self.satfinder_scan_nims.value)].isCompatible("DVB-C"):
			return
		if self.initcomplete:
			if self.tuning_type.value == "manual_transponder":
				transponder = (
					self.scan_cab.frequency.value*1000,
					self.scan_cab.symbolrate.value*1000,
					self.scan_cab.modulation.value,
					self.scan_cab.fec.value,
					self.scan_cab.inversion.value
				)
				if self.initcomplete:
					self.tuner.tuneCab(transponder)
				self.transponder = transponder
			elif self.tuning_type.value == "predefined_transponder":
				tps = nimmanager.getTranspondersCable(int(self.satfinder_scan_nims.value))
				if len(tps) and len(tps) > self.CableTransponders.index :
					tp = tps[self.CableTransponders.index]
					# tp = 0 transponder type, 1 freq, 2 sym, 3 mod, 4 fec, 5 inv, 6 sys
					transponder = (tp[1], tp[2], tp[3], tp[4], tp[5])
					if self.initcomplete:
						self.tuner.tuneCab(transponder)
					self.transponder = transponder
Пример #6
0
	def createSetup(self):
		self.list = []
		self.satfinderTunerEntry = getConfigListEntry(_("Tuner"), self.satfinder_scan_nims)
		self.list.append(self.satfinderTunerEntry)
		if nimmanager.nim_slots[int(self.satfinder_scan_nims.value)].isCompatible("DVB-S"):
			self.tuning_sat = self.scan_satselection[self.getSelectedSatIndex(self.feid)]
			self.satEntry = getConfigListEntry(_('Satellite'), self.tuning_sat)
			self.list.append(self.satEntry)
			self.typeOfTuningEntry = getConfigListEntry(_('Tune'), self.tuning_type)
			if len(nimmanager.getTransponders(int(self.tuning_sat.value))) < 1: # Only offer 'predefined transponder' if some transponders exist
				self.tuning_type.value = "single_transponder"
			else:
				self.list.append(self.typeOfTuningEntry)

			nim = nimmanager.nim_slots[self.feid]

			if self.tuning_type.value == "single_transponder":
				if nim.isCompatible("DVB-S2"):
					self.systemEntry = getConfigListEntry(_('System'), self.scan_sat.system)
					self.list.append(self.systemEntry)
				else:
					# downgrade to dvb-s, in case a -s2 config was active
					self.scan_sat.system.value = eDVBFrontendParametersSatellite.System_DVB_S
				self.list.append(getConfigListEntry(_('Frequency'), self.scan_sat.frequency))
				self.list.append(getConfigListEntry(_('Polarization'), self.scan_sat.polarization))
				self.list.append(getConfigListEntry(_('Symbol rate'), self.scan_sat.symbolrate))
				self.list.append(getConfigListEntry(_('Inversion'), self.scan_sat.inversion))
				if self.scan_sat.system.value == eDVBFrontendParametersSatellite.System_DVB_S:
					self.list.append(getConfigListEntry(_("FEC"), self.scan_sat.fec))
				elif self.scan_sat.system.value == eDVBFrontendParametersSatellite.System_DVB_S2:
					self.list.append(getConfigListEntry(_("FEC"), self.scan_sat.fec_s2))
					self.modulationEntry = getConfigListEntry(_('Modulation'), self.scan_sat.modulation)
					self.list.append(self.modulationEntry)
					self.list.append(getConfigListEntry(_('Roll-off'), self.scan_sat.rolloff))
					self.list.append(getConfigListEntry(_('Pilot'), self.scan_sat.pilot))
					self.list.append(getConfigListEntry(_('Input Stream ID'), self.scan_sat.is_id))
					self.list.append(getConfigListEntry(_("PLS Mode"), self.scan_sat.pls_mode))
					self.list.append(getConfigListEntry(_('PLS Code'), self.scan_sat.pls_code))
			elif self.tuning_type.value == "predefined_transponder":
				self.updatePreDefTransponders()
				self.list.append(getConfigListEntry(_("Transponder"), self.preDefTransponders))
		elif nimmanager.nim_slots[int(self.satfinder_scan_nims.value)].isCompatible("DVB-C"):
			self.typeOfTuningEntry = getConfigListEntry(_('Tune'), self.tuning_type)
			if config.Nims[self.feid].cable.scan_type.value != "provider" or len(nimmanager.getTranspondersCable(int(self.satfinder_scan_nims.value))) < 1: # only show 'predefined transponder' if in provider mode and transponders exist
				self.tuning_type.value = "single_transponder"
			else:
				self.list.append(self.typeOfTuningEntry)
			if self.tuning_type.value == "single_transponder":
				self.list.append(getConfigListEntry(_("Frequency"), self.scan_cab.frequency))
				self.list.append(getConfigListEntry(_("Inversion"), self.scan_cab.inversion))
				self.list.append(getConfigListEntry(_("Symbol rate"), self.scan_cab.symbolrate))
				self.list.append(getConfigListEntry(_("Modulation"), self.scan_cab.modulation))
				self.list.append(getConfigListEntry(_("FEC"), self.scan_cab.fec))
			elif self.tuning_type.value == "predefined_transponder":
				self.scan_nims.value = self.satfinder_scan_nims.value
				self.predefinedCabTranspondersList()
				self.list.append(getConfigListEntry(_('Transponder'), self.CableTransponders))
		elif nimmanager.nim_slots[int(self.satfinder_scan_nims.value)].isCompatible("DVB-T"):
			self.typeOfTuningEntry = getConfigListEntry(_('Tune'), self.tuning_type)
			region = nimmanager.getTerrestrialDescription(int(self.satfinder_scan_nims.value))
			if len(nimmanager.getTranspondersTerrestrial(region)) < 1: # Only offer 'predefined transponder' if some transponders exist
				self.tuning_type.value = "single_transponder"
			else:
				self.list.append(self.typeOfTuningEntry)
			if self.tuning_type.value == "single_transponder":
				if nimmanager.nim_slots[int(self.satfinder_scan_nims.value)].isCompatible("DVB-T2"):
					self.systemEntryTerr = getConfigListEntry(_('System'), self.scan_ter.system)
					self.list.append(self.systemEntryTerr)
				else:
					self.scan_ter.system.value = eDVBFrontendParametersTerrestrial.System_DVB_T
				self.typeOfInputEntry = getConfigListEntry(_("Use frequency or channel"), self.scan_input_as)
				if self.ter_channel_input:
					self.list.append(self.typeOfInputEntry)
				else:
					self.scan_input_as.value = self.scan_input_as.choices[0]
				if self.ter_channel_input and self.scan_input_as.value == "channel":
					channel = getChannelNumber(self.scan_ter.frequency.value*1000, self.ter_tnumber)
					if channel:
						self.scan_ter.channel.value = int(channel.replace("+","").replace("-",""))
					self.list.append(getConfigListEntry(_("Channel"), self.scan_ter.channel))
				else:
					prev_val = self.scan_ter.frequency.value
					self.scan_ter.frequency.value = channel2frequency(self.scan_ter.channel.value, self.ter_tnumber)/1000
					if self.scan_ter.frequency.value == 474000:
						self.scan_ter.frequency.value = prev_val
					self.list.append(getConfigListEntry(_("Frequency"), self.scan_ter.frequency))
				self.list.append(getConfigListEntry(_("Inversion"), self.scan_ter.inversion))
				self.list.append(getConfigListEntry(_("Bandwidth"), self.scan_ter.bandwidth))
				self.list.append(getConfigListEntry(_("Code rate HP"), self.scan_ter.fechigh))
				self.list.append(getConfigListEntry(_("Code rate LP"), self.scan_ter.feclow))
				self.list.append(getConfigListEntry(_("Modulation"), self.scan_ter.modulation))
				self.list.append(getConfigListEntry(_("Transmission mode"), self.scan_ter.transmission))
				self.list.append(getConfigListEntry(_("Guard interval"), self.scan_ter.guard))
				self.list.append(getConfigListEntry(_("Hierarchy info"), self.scan_ter.hierarchy))
				if self.scan_ter.system.value == eDVBFrontendParametersTerrestrial.System_DVB_T2:
					self.list.append(getConfigListEntry(_('PLP ID'), self.scan_ter.plp_id))
			elif self.tuning_type.value == "predefined_transponder":
				self.scan_nims.value = self.satfinder_scan_nims.value
				self.predefinedTerrTranspondersList()
				self.list.append(getConfigListEntry(_('Transponder'), self.TerrestrialTransponders))
		self.retune(None)
		self["config"].list = self.list
		self["config"].l.setList(self.list)
Пример #7
0
    def createSetup(self):
        self.list = []
        self.satfinderTunerEntry = getConfigListEntry(_("Tuner"),
                                                      self.satfinder_scan_nims)
        self.list.append(self.satfinderTunerEntry)
        if nimmanager.nim_slots[int(
                self.satfinder_scan_nims.value)].isCompatible("DVB-S"):
            self.tuning_sat = self.scan_satselection[self.getSelectedSatIndex(
                self.feid)]
            if self.tuning_sat.value:
                self.satEntry = getConfigListEntry(_('Satellite'),
                                                   self.tuning_sat)
                self.list.append(self.satEntry)
                self.typeOfTuningEntry = getConfigListEntry(
                    _('Tune'), self.tuning_type)
                if len(
                        nimmanager.getTransponders(int(self.tuning_sat.value))
                ) < 1:  # Only offer 'predefined transponder' if some transponders exist
                    self.tuning_type.value = "single_transponder"
                else:
                    self.list.append(self.typeOfTuningEntry)

                nim = nimmanager.nim_slots[self.feid]

                if self.tuning_type.value == "single_transponder":
                    if nim.isCompatible("DVB-S2"):
                        self.systemEntry = getConfigListEntry(
                            _('System'), self.scan_sat.system)
                        self.list.append(self.systemEntry)
                    else:
                        # downgrade to dvb-s, in case a -s2 config was active
                        self.scan_sat.system.value = eDVBFrontendParametersSatellite.System_DVB_S
                    self.frequencyEntry = getConfigListEntry(
                        _('Frequency'), self.scan_sat.frequency)
                    self.list.append(self.frequencyEntry)
                    self.polarizationEntry = getConfigListEntry(
                        _('Polarization'), self.scan_sat.polarization)
                    self.list.append(self.polarizationEntry)
                    self.symbolrateEntry = (getConfigListEntry(
                        _('Symbol rate'), self.scan_sat.symbolrate))
                    self.list.append(self.symbolrateEntry)
                    self.inversionEntry = getConfigListEntry(
                        _('Inversion'), self.scan_sat.inversion)
                    self.list.append(self.inversionEntry)

                    if self.scan_sat.system.value == eDVBFrontendParametersSatellite.System_DVB_S:
                        self.fecEntry = getConfigListEntry(
                            _("FEC"), self.scan_sat.fec)
                        self.list.append(self.fecEntry)
                    elif self.scan_sat.system.value == eDVBFrontendParametersSatellite.System_DVB_S2:
                        self.fecEntry = getConfigListEntry(
                            _("FEC"), self.scan_sat.fec_s2)
                        self.list.append(self.fecEntry)
                        self.modulationEntry = getConfigListEntry(
                            _('Modulation'), self.scan_sat.modulation)
                        self.list.append(self.modulationEntry)
                        self.rolloffEntry = getConfigListEntry(
                            _('Roll-off'), self.scan_sat.rolloff)
                        self.list.append(self.rolloffEntry)
                        self.pilotEntry = getConfigListEntry(
                            _('Pilot'), self.scan_sat.pilot)
                        self.list.append(self.pilotEntry)
                        if nim.isMultistream():
                            self.list.append(
                                getConfigListEntry(_('Input Stream ID'),
                                                   self.scan_sat.is_id))
                            self.list.append(
                                getConfigListEntry(_('PLS Mode'),
                                                   self.scan_sat.pls_mode))
                            self.list.append(
                                getConfigListEntry(_('PLS Code'),
                                                   self.scan_sat.pls_code))
                elif self.tuning_type.value == "predefined_transponder":
                    if self.preDefTransponders is None:
                        self.updatePreDefTransponders()
                    self.list.append(
                        getConfigListEntry(_("Transponder"),
                                           self.preDefTransponders))
        elif nimmanager.nim_slots[int(
                self.satfinder_scan_nims.value)].isCompatible("DVB-C"):
            self.typeOfTuningEntry = getConfigListEntry(
                _('Tune'), self.tuning_type)
            if config.Nims[self.feid].cable.scan_type.value != "provider" or len(
                    nimmanager.getTranspondersCable(
                        int(self.satfinder_scan_nims.value))
            ) < 1:  # only show 'predefined transponder' if in provider mode and transponders exist
                self.tuning_type.value = "single_transponder"
            else:
                self.list.append(self.typeOfTuningEntry)
            if self.tuning_type.value == "single_transponder":
                self.list.append(
                    getConfigListEntry(_("Frequency"),
                                       self.scan_cab.frequency))
                self.list.append(
                    getConfigListEntry(_("Inversion"),
                                       self.scan_cab.inversion))
                self.list.append(
                    getConfigListEntry(_("Symbol rate"),
                                       self.scan_cab.symbolrate))
                self.list.append(
                    getConfigListEntry(_("Modulation"),
                                       self.scan_cab.modulation))
                self.list.append(
                    getConfigListEntry(_("FEC"), self.scan_cab.fec))
            elif self.tuning_type.value == "predefined_transponder":
                self.scan_nims.value = self.satfinder_scan_nims.value
                if self.CableTransponders is None:
                    self.predefinedCabTranspondersList()
                self.list.append(
                    getConfigListEntry(_('Transponder'),
                                       self.CableTransponders))
        elif nimmanager.nim_slots[int(
                self.satfinder_scan_nims.value)].isCompatible("DVB-T"):
            self.typeOfTuningEntry = getConfigListEntry(
                _('Tune'), self.tuning_type)
            region = nimmanager.getTerrestrialDescription(
                int(self.satfinder_scan_nims.value))
            if len(
                    nimmanager.getTranspondersTerrestrial(region)
            ) < 1:  # Only offer 'predefined transponder' if some transponders exist
                self.tuning_type.value = "single_transponder"
            else:
                self.list.append(self.typeOfTuningEntry)
            if self.tuning_type.value == "single_transponder":
                if nimmanager.nim_slots[int(
                        self.satfinder_scan_nims.value)].isCompatible(
                            "DVB-T2"):
                    self.systemEntryTerr = getConfigListEntry(
                        _('System'), self.scan_ter.system)
                    self.list.append(self.systemEntryTerr)
                else:
                    self.scan_ter.system.value = eDVBFrontendParametersTerrestrial.System_DVB_T
                self.typeOfInputEntry = getConfigListEntry(
                    _("Use frequency or channel"), self.scan_input_as)
                if self.ter_channel_input:
                    self.list.append(self.typeOfInputEntry)
                else:
                    self.scan_input_as.value = self.scan_input_as.choices[0]
                if self.ter_channel_input and self.scan_input_as.value == "channel":
                    channel = getChannelNumber(
                        self.scan_ter.frequency.floatint * 1000,
                        self.ter_tnumber)
                    if channel:
                        self.scan_ter.channel.value = int(
                            channel.replace("+", "").replace("-", ""))
                    self.list.append(
                        getConfigListEntry(_("Channel"),
                                           self.scan_ter.channel))
                else:
                    prev_val = self.scan_ter.frequency.floatint
                    self.scan_ter.frequency.floatint = channel2frequency(
                        self.scan_ter.channel.value, self.ter_tnumber) / 1000
                    if self.scan_ter.frequency.floatint == 474000:
                        self.scan_ter.frequency.floatint = prev_val
                    self.list.append(
                        getConfigListEntry(_("Frequency"),
                                           self.scan_ter.frequency))
                self.list.append(
                    getConfigListEntry(_("Inversion"),
                                       self.scan_ter.inversion))
                self.list.append(
                    getConfigListEntry(_("Bandwidth"),
                                       self.scan_ter.bandwidth))
                self.list.append(
                    getConfigListEntry(_("Code rate HP"),
                                       self.scan_ter.fechigh))
                self.list.append(
                    getConfigListEntry(_("Code rate LP"),
                                       self.scan_ter.feclow))
                self.list.append(
                    getConfigListEntry(_("Modulation"),
                                       self.scan_ter.modulation))
                self.list.append(
                    getConfigListEntry(_("Transmission mode"),
                                       self.scan_ter.transmission))
                self.list.append(
                    getConfigListEntry(_("Guard interval"),
                                       self.scan_ter.guard))
                self.list.append(
                    getConfigListEntry(_("Hierarchy info"),
                                       self.scan_ter.hierarchy))
                if self.scan_ter.system.value == eDVBFrontendParametersTerrestrial.System_DVB_T2:
                    self.list.append(
                        getConfigListEntry(_('PLP ID'), self.scan_ter.plp_id))
            elif self.tuning_type.value == "predefined_transponder":
                self.scan_nims.value = self.satfinder_scan_nims.value
                if self.TerrestrialTransponders is None:
                    self.predefinedTerrTranspondersList()
                self.list.append(
                    getConfigListEntry(_('Transponder'),
                                       self.TerrestrialTransponders))
        elif nimmanager.nim_slots[int(
                self.satfinder_scan_nims.value)].isCompatible("ATSC"):
            self.typeOfTuningEntry = getConfigListEntry(
                _('Tune'), self.tuning_type)
            if len(
                    nimmanager.getTranspondersATSC(
                        int(self.satfinder_scan_nims.value))
            ) < 1:  # only show 'predefined transponder' if transponders exist
                self.tuning_type.value = "single_transponder"
            else:
                self.list.append(self.typeOfTuningEntry)
            if self.tuning_type.value == "single_transponder":
                self.systemEntryATSC = getConfigListEntry(
                    _("System"), self.scan_ats.system)
                self.list.append(self.systemEntryATSC)
                self.list.append(
                    getConfigListEntry(_("Frequency"),
                                       self.scan_ats.frequency))
                self.list.append(
                    getConfigListEntry(_("Inversion"),
                                       self.scan_ats.inversion))
                self.list.append(
                    getConfigListEntry(_("Modulation"),
                                       self.scan_ats.modulation))
            elif self.tuning_type.value == "predefined_transponder":
                #FIXME add region
                self.scan_nims.value = self.satfinder_scan_nims.value
                self.predefinedATSCTranspondersList()
                self.list.append(
                    getConfigListEntry(_('Transponder'),
                                       self.ATSCTransponders))
        self["config"].list = self.list
        self["config"].l.setList(self.list)
Пример #8
0
    def createConfig(self, foo):
        self.tuning_type = ConfigSelection(
            default="predefined_transponder",
            choices=[("single_transponder", _("User defined transponder")),
                     ("predefined_transponder", _("Predefined transponder"))])
        self.orbital_position = 192
        if self.frontendData and self.frontendData.has_key('orbital_position'):
            self.orbital_position = self.frontendData['orbital_position']
        ScanSetup.createConfig(self, self.frontendData)

        for x in (self.scan_sat.frequency, self.scan_sat.inversion,
                  self.scan_sat.symbolrate, self.scan_sat.polarization,
                  self.scan_sat.fec, self.scan_sat.pilot, self.scan_sat.fec_s2,
                  self.scan_sat.fec, self.scan_sat.modulation,
                  self.scan_sat.rolloff, self.scan_sat.system,
                  self.scan_ter.channel, self.scan_ter.frequency,
                  self.scan_ter.inversion, self.scan_ter.bandwidth,
                  self.scan_ter.fechigh, self.scan_ter.feclow,
                  self.scan_ter.modulation, self.scan_ter.transmission,
                  self.scan_ter.guard, self.scan_ter.hierarchy,
                  self.scan_ter.plp_id, self.scan_cab.frequency,
                  self.scan_cab.inversion, self.scan_cab.symbolrate,
                  self.scan_cab.modulation, self.scan_cab.fec):
            x.addNotifier(self.retune, initial_call=False)

        satfinder_nim_list = []
        for n in nimmanager.nim_slots:
            if not (n.isCompatible("DVB-S") or n.isCompatible("DVB-T")
                    or n.isCompatible("DVB-C")):
                continue
            if n.config_mode in ("loopthrough", "satposdepends", "nothing"):
                continue
            if n.isCompatible("DVB-S") and n.config_mode == "advanced" and len(
                    nimmanager.getSatListForNim(n.slot)) < 1:
                continue
            satfinder_nim_list.append(
                (str(n.slot), n.friendly_full_description))
        self.satfinder_scan_nims = ConfigSelection(choices=satfinder_nim_list)
        if self.frontendData is not None and len(
                satfinder_nim_list
        ) > 0:  # open the plugin with the currently active NIM as default
            self.satfinder_scan_nims.setValue(
                str(
                    self.frontendData.get("tuner_number",
                                          satfinder_nim_list[0][0])))

        self.feid = int(self.satfinder_scan_nims.value)

        self.satList = []
        self.scan_satselection = []
        for slot in nimmanager.nim_slots:
            if slot.isCompatible("DVB-S"):
                self.satList.append(nimmanager.getSatListForNim(slot.slot))
                self.scan_satselection.append(
                    getConfigSatlist(self.orbital_position,
                                     self.satList[slot.slot]))
            else:
                self.satList.append(None)

        if self.frontendData:
            ttype = self.frontendData.get("tuner_type", "UNKNOWN")
            if ttype == "DVB-S" and self.predefinedTranspondersList(
                    self.getSelectedSatIndex(self.feid)) is None and len(
                        nimmanager.getTransponders(
                            self.getSelectedSatIndex(self.feid))) > 0:
                self.tuning_type.value = "single_transponder"
            elif ttype == "DVB-T" and self.predefinedTerrTranspondersList(
            ) is None and len(
                    nimmanager.getTranspondersTerrestrial(
                        nimmanager.getTerrestrialDescription(self.feid))) > 0:
                self.tuning_type.value = "single_transponder"
            elif ttype == "DVB-C" and self.predefinedCabTranspondersList(
            ) is None and len(nimmanager.getTranspondersCable(self.feid)) > 0:
                self.tuning_type.value = "single_transponder"
Пример #9
0
class Satfinder(ScanSetup, ServiceScan):
	"""Inherits StaticText [key_red] and [key_green] properties from ScanSetup"""

	def __init__(self, session):
		self.initcomplete = False
		service = session and session.nav.getCurrentService()
		feinfo = service and service.frontendInfo()
		self.frontendData = feinfo and feinfo.getAll(True)
		del feinfo
		del service

		self.typeOfTuningEntry = None
		self.systemEntry = None
		self.systemEntryATSC = None
		self.satfinderTunerEntry = None
		self.satEntry = None
		self.typeOfInputEntry = None
		self.DVB_TypeEntry = None
		self.systemEntryTerr = None
		self.preDefTransponderEntry = None
		self.preDefTransponderCableEntry = None
		self.preDefTransponderTerrEntry = None
		self.preDefTransponderAtscEntry = None
		self.frontend = None
		self.is_id_boolEntry = None

		ScanSetup.__init__(self, session)
		self.setTitle(_("Signal finder"))
		self["Frontend"] = FrontendStatus(frontend_source = lambda : self.frontend, update_interval = 100)

		self["actions"] = ActionMap(["SetupActions", "ColorActions"],
		{
			"save": self.keyGoScan,
			"ok": self.keyGoScan,
			"cancel": self.keyCancel,
		}, -3)

		self.initcomplete = True
		self.session.postScanService = self.session.nav.getCurrentlyPlayingServiceOrGroup()
		self.onClose.append(self.__onClose)
		self.onShow.append(self.prepareFrontend)

	def openFrontend(self):
		res_mgr = eDVBResourceManager.getInstance()
		if res_mgr:
			self.raw_channel = res_mgr.allocateRawChannel(self.feid)
			if self.raw_channel:
				self.frontend = self.raw_channel.getFrontend()
				if self.frontend:
					return True
		return False

	def prepareFrontend(self):
		self.frontend = None
		if not self.openFrontend():
			self.session.nav.stopService()
			if not self.openFrontend():
				if self.session.pipshown:
					from Screens.InfoBar import InfoBar
					InfoBar.instance and hasattr(InfoBar.instance, "showPiP") and InfoBar.instance.showPiP()
					if not self.openFrontend():
						self.frontend = None # in normal case this should not happen
		self.tuner = Tuner(self.frontend)
		self.retune()

	def __onClose(self):
		self.session.nav.playService(self.session.postScanService)

	def newConfig(self):
		cur = self["config"].getCurrent()
		if cur in (
					self.typeOfTuningEntry, 
					self.systemEntry, 
					self.typeOfInputEntry, 
					self.systemEntryATSC, 
					self.DVB_TypeEntry, 
					self.systemEntryTerr, 
					self.satEntry
					):  # update screen and retune
			self.createSetup()
			self.retune()
		
		elif cur == self.satfinderTunerEntry: # switching tuners, update screen, get frontend, and retune (in prepareFrontend())
			self.feid = int(self.satfinder_scan_nims.value)
			self.createSetup()
			self.prepareFrontend()
			if self.frontend is None:
				msg = _("Tuner not available.")
				if self.session.nav.RecordTimer.isRecording():
					msg += _("\nRecording in progress.")
				self.session.open(MessageBox, msg, MessageBox.TYPE_ERROR)

		elif cur in (self.preDefTransponderEntry, self.preDefTransponderCableEntry, self.preDefTransponderTerrEntry, self.preDefTransponderAtscEntry): # retune only
			self.retune()
		elif cur == self.is_id_boolEntry:
			if self.is_id_boolEntry[1].value:
				self.scan_sat.is_id.value = 0 if self.is_id_memory < 0 else self.is_id_memory
				self.scan_sat.pls_mode.value = self.pls_mode_memory
				self.scan_sat.pls_code.value = self.pls_code_memory
			else:
				self.is_id_memory = self.scan_sat.is_id.value
				self.pls_mode_memory = self.scan_sat.pls_mode.value
				self.pls_code_memory = self.scan_sat.pls_code.value
				self.scan_sat.is_id.value = self.NO_STREAM_ID_FILTER
				self.scan_sat.pls_mode.value = eDVBFrontendParametersSatellite.PLS_Gold
				self.scan_sat.pls_code.value = 0
			self.createSetup()
			self.retune()


	def createSetup(self):
		self.list = []
		self.satfinderTunerEntry = getConfigListEntry(_("Tuner"), self.satfinder_scan_nims)
		self.list.append(self.satfinderTunerEntry)
		self.DVB_type = self.nim_type_dict[int(self.satfinder_scan_nims.value)]["selection"]
		self.DVB_TypeEntry = getConfigListEntry(_("DVB type"), self.DVB_type) # multitype?
		if len(self.nim_type_dict[int(self.satfinder_scan_nims.value)]["modes"]) > 1:
			 self.list.append(self.DVB_TypeEntry)
		if self.DVB_type.value == "DVB-S":
			self.tuning_sat = self.scan_satselection[self.getSelectedSatIndex(self.feid)]
			self.satEntry = getConfigListEntry(_('Satellite'), self.tuning_sat)
			self.list.append(self.satEntry)
			self.typeOfTuningEntry = getConfigListEntry(_('Tune'), self.tuning_type)
			if len(nimmanager.getTransponders(int(self.tuning_sat.value), self.feid)) < 1: # Only offer 'predefined transponder' if some transponders exist
				self.tuning_type.value = "single_transponder"
			else:
				self.list.append(self.typeOfTuningEntry)

			nim = nimmanager.nim_slots[self.feid]

			if self.tuning_type.value == "single_transponder":
				if nim.canBeCompatible("DVB-S2"):
					self.systemEntry = getConfigListEntry(_('System'), self.scan_sat.system)
					self.list.append(self.systemEntry)
				else:
					# downgrade to dvb-s, in case a -s2 config was active
					self.scan_sat.system.value = eDVBFrontendParametersSatellite.System_DVB_S
				self.list.append(getConfigListEntry(_('Frequency'), self.scan_sat.frequency))
				self.list.append(getConfigListEntry(_('Polarization'), self.scan_sat.polarization))
				self.list.append(getConfigListEntry(_('Symbol rate'), self.scan_sat.symbolrate))
				self.list.append(getConfigListEntry(_('Inversion'), self.scan_sat.inversion))
				if self.scan_sat.system.value == eDVBFrontendParametersSatellite.System_DVB_S:
					self.list.append(getConfigListEntry(_("FEC"), self.scan_sat.fec))
				elif self.scan_sat.system.value == eDVBFrontendParametersSatellite.System_DVB_S2:
					self.list.append(getConfigListEntry(_("FEC"), self.scan_sat.fec_s2))
					self.modulationEntry = getConfigListEntry(_('Modulation'), self.scan_sat.modulation)
					self.list.append(self.modulationEntry)
					self.list.append(getConfigListEntry(_('Roll-off'), self.scan_sat.rolloff))
					self.list.append(getConfigListEntry(_('Pilot'), self.scan_sat.pilot))
					if nim.isMultistream():
						self.is_id_boolEntry = getConfigListEntry(_('Transport Stream Type'), self.scan_sat.is_id_bool)
						self.list.append(self.is_id_boolEntry)
						if self.scan_sat.is_id_bool.value:
							self.list.append(getConfigListEntry(_('Input Stream ID'), self.scan_sat.is_id))
							self.list.append(getConfigListEntry(_('PLS Mode'), self.scan_sat.pls_mode))
							self.list.append(getConfigListEntry(_('PLS Code'), self.scan_sat.pls_code))
					else:
						self.scan_sat.is_id.value = self.NO_STREAM_ID_FILTER
						self.scan_sat.pls_mode.value = eDVBFrontendParametersSatellite.PLS_Gold
						self.scan_sat.pls_code.value = 0
			elif self.tuning_type.value == "predefined_transponder":
				self.updatePreDefTransponders()
				self.preDefTransponderEntry = getConfigListEntry(_("Transponder"), self.preDefTransponders)
				self.list.append(self.preDefTransponderEntry)
		elif self.DVB_type.value == "DVB-C":
			self.typeOfTuningEntry = getConfigListEntry(_('Tune'), self.tuning_type)
			if config.Nims[self.feid].cable.scan_type.value != "provider" or len(nimmanager.getTranspondersCable(int(self.satfinder_scan_nims.value))) < 1: # only show 'predefined transponder' if in provider mode and transponders exist
				self.tuning_type.value = "single_transponder"
			else:
				self.list.append(self.typeOfTuningEntry)
			if self.tuning_type.value == "single_transponder":
				self.list.append(getConfigListEntry(_("Frequency"), self.scan_cab.frequency))
				self.list.append(getConfigListEntry(_("Inversion"), self.scan_cab.inversion))
				self.list.append(getConfigListEntry(_("Symbol rate"), self.scan_cab.symbolrate))
				self.list.append(getConfigListEntry(_("Modulation"), self.scan_cab.modulation))
				self.list.append(getConfigListEntry(_("FEC"), self.scan_cab.fec))
			elif self.tuning_type.value == "predefined_transponder":
				self.scan_nims.value = self.satfinder_scan_nims.value
				self.predefinedCabTranspondersList()
				self.preDefTransponderCableEntry = getConfigListEntry(_("Transponder"), self.CableTransponders)
				self.list.append(self.preDefTransponderCableEntry)
		elif self.DVB_type.value == "DVB-T":
			self.typeOfTuningEntry = getConfigListEntry(_('Tune'), self.tuning_type)
			region = nimmanager.getTerrestrialDescription(int(self.satfinder_scan_nims.value))
			if len(nimmanager.getTranspondersTerrestrial(region)) < 1: # Only offer 'predefined transponder' if some transponders exist
				self.tuning_type.value = "single_transponder"
			else:
				self.list.append(self.typeOfTuningEntry)
			if self.tuning_type.value == "single_transponder":
				if nimmanager.nim_slots[int(self.satfinder_scan_nims.value)].canBeCompatible("DVB-T2"):
					self.systemEntryTerr = getConfigListEntry(_('System'), self.scan_ter.system)
					self.list.append(self.systemEntryTerr)
				else:
					self.scan_ter.system.value = eDVBFrontendParametersTerrestrial.System_DVB_T
				self.typeOfInputEntry = getConfigListEntry(_("Use frequency or channel"), self.scan_input_as)
				if self.ter_channel_input:
					self.list.append(self.typeOfInputEntry)
				else:
					self.scan_input_as.value = self.scan_input_as.choices[0]
				if self.ter_channel_input and self.scan_input_as.value == "channel":
					channel = getChannelNumber(self.scan_ter.frequency.floatint * 1000, self.ter_tnumber)
					if channel:
						self.scan_ter.channel.value = int(channel.replace("+","").replace("-",""))
					self.list.append(getConfigListEntry(_("Channel"), self.scan_ter.channel))
				else:
					prev_val = self.scan_ter.frequency.floatint
					self.scan_ter.frequency.floatint = channel2frequency(self.scan_ter.channel.value, self.ter_tnumber)/1000
					if self.scan_ter.frequency.floatint == 474000:
						self.scan_ter.frequency.floatint = prev_val
					self.list.append(getConfigListEntry(_("Frequency"), self.scan_ter.frequency))
				self.list.append(getConfigListEntry(_("Inversion"), self.scan_ter.inversion))
				self.list.append(getConfigListEntry(_("Bandwidth"), self.scan_ter.bandwidth))
				self.list.append(getConfigListEntry(_("Code rate HP"), self.scan_ter.fechigh))
				self.list.append(getConfigListEntry(_("Code rate LP"), self.scan_ter.feclow))
				self.list.append(getConfigListEntry(_("Modulation"), self.scan_ter.modulation))
				self.list.append(getConfigListEntry(_("Transmission mode"), self.scan_ter.transmission))
				self.list.append(getConfigListEntry(_("Guard interval"), self.scan_ter.guard))
				self.list.append(getConfigListEntry(_("Hierarchy info"), self.scan_ter.hierarchy))
				if self.scan_ter.system.value == eDVBFrontendParametersTerrestrial.System_DVB_T2:
					self.list.append(getConfigListEntry(_('PLP ID'), self.scan_ter.plp_id))
			elif self.tuning_type.value == "predefined_transponder":
				self.scan_nims.value = self.satfinder_scan_nims.value
				self.predefinedTerrTranspondersList()
				self.preDefTransponderTerrEntry = getConfigListEntry(_('Transponder'), self.TerrestrialTransponders)
				self.list.append(self.preDefTransponderTerrEntry)
		elif self.DVB_type.value == "ATSC":
			self.typeOfTuningEntry = getConfigListEntry(_('Tune'), self.tuning_type)
			if len(nimmanager.getTranspondersATSC(int(self.satfinder_scan_nims.value))) < 1: # only show 'predefined transponder' if transponders exist
				self.tuning_type.value = "single_transponder"
			else:
				self.list.append(self.typeOfTuningEntry)
			if self.tuning_type.value == "single_transponder":
				self.systemEntryATSC = getConfigListEntry(_("System"), self.scan_ats.system)
				self.list.append(self.systemEntryATSC)
				self.list.append(getConfigListEntry(_("Frequency"), self.scan_ats.frequency))
				self.list.append(getConfigListEntry(_("Inversion"), self.scan_ats.inversion))
				self.list.append(getConfigListEntry(_("Modulation"), self.scan_ats.modulation))
			elif self.tuning_type.value == "predefined_transponder":
				#FIXME add region
				self.scan_nims.value = self.satfinder_scan_nims.value
				self.predefinedATSCTranspondersList()
				self.preDefTransponderAtscEntry = getConfigListEntry(_('Transponder'), self.ATSCTransponders)
				self.list.append(self.preDefTransponderAtscEntry)
		self["config"].list = self.list
		self["config"].l.setList(self.list)

	def createConfig(self, foo):
		self.tuning_type = ConfigSelection(default = "predefined_transponder", choices = [("single_transponder", _("User defined transponder")), ("predefined_transponder", _("Predefined transponder"))])
		self.orbital_position = 192
		if self.frontendData and 'orbital_position' in self.frontendData:
			self.orbital_position = self.frontendData['orbital_position']
		ScanSetup.createConfig(self, self.frontendData)

		# The following are updated in self.newConfig(). Do not add here. 
		# self.scan_sat.system, self.tuning_type, self.scan_input_as, self.scan_ats.system, self.DVB_type, self.scan_ter.system, self.satfinder_scan_nims, self.tuning_sat
  		for x in (self.scan_sat.frequency,
			self.scan_sat.inversion, self.scan_sat.symbolrate,
			self.scan_sat.polarization, self.scan_sat.fec, self.scan_sat.pilot,
			self.scan_sat.fec_s2, self.scan_sat.fec, self.scan_sat.modulation,
			self.scan_sat.rolloff,
			self.scan_sat.is_id, self.scan_sat.pls_mode, self.scan_sat.pls_code,
			self.scan_ter.channel, self.scan_ter.frequency, self.scan_ter.inversion,
			self.scan_ter.bandwidth, self.scan_ter.fechigh, self.scan_ter.feclow,
			self.scan_ter.modulation, self.scan_ter.transmission,
			self.scan_ter.guard, self.scan_ter.hierarchy, self.scan_ter.plp_id,
			self.scan_cab.frequency, self.scan_cab.inversion, self.scan_cab.symbolrate,
			self.scan_cab.modulation, self.scan_cab.fec,
			self.scan_ats.frequency, self.scan_ats.modulation, self.scan_ats.inversion):
			x.addNotifier(self.retune, initial_call = False)

		satfinder_nim_list = []
		for n in nimmanager.nim_slots:
			if not any([n.isCompatible(x) for x in "DVB-S", "DVB-T", "DVB-C", "ATSC"]):
				continue
			if n.config_mode  in ("loopthrough", "satposdepends", "nothing"):
				continue
			if n.isCompatible("DVB-S") and n.config_mode == "advanced" and len(nimmanager.getSatListForNim(n.slot)) < 1:
				continue
			satfinder_nim_list.append((str(n.slot), n.friendly_full_description))
		self.satfinder_scan_nims = ConfigSelection(choices = satfinder_nim_list)
		if self.frontendData is not None and len(satfinder_nim_list) > 0: # open the plugin with the currently active NIM as default
			self.satfinder_scan_nims.setValue(str(self.frontendData.get("tuner_number", satfinder_nim_list[0][0])))

		self.feid = int(self.satfinder_scan_nims.value)

		self.satList = []
		self.scan_satselection = []
		for slot in nimmanager.nim_slots:
			if slot.isCompatible("DVB-S"):
				self.satList.append(nimmanager.getSatListForNim(slot.slot))
				self.scan_satselection.append(getConfigSatlist(self.orbital_position, self.satList[slot.slot]))
			else:
				self.satList.append(None)

		if self.frontendData:
			ttype = self.frontendData.get("tuner_type", "UNKNOWN")
			if ttype == "DVB-S" and self.predefinedTranspondersList(self.getSelectedSatIndex(self.feid)) is None and len(nimmanager.getTransponders(self.getSelectedSatIndex(self.feid), self.feid)) > 0:
				self.tuning_type.value = "single_transponder"
			elif ttype == "DVB-T" and self.predefinedTerrTranspondersList() is None and len(nimmanager.getTranspondersTerrestrial(nimmanager.getTerrestrialDescription(self.feid))) > 0:
				self.tuning_type.value = "single_transponder"
			elif ttype == "DVB-C" and self.predefinedCabTranspondersList() is None and len(nimmanager.getTranspondersCable(self.feid)) > 0:
				self.tuning_type.value = "single_transponder"
			elif ttype == "ATSC" and self.predefinedATSCTranspondersList() is None and len(nimmanager.getTranspondersATSC(self.feid)) > 0:
				self.tuning_type.value = "single_transponder"