X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/67b53c1cb06988394c35a6e965c99b72b67fe1be..0e314839b15e3090ee5b39fcc307dc31745a9831:/lib/python/Components/NimManager.py diff --git a/lib/python/Components/NimManager.py b/lib/python/Components/NimManager.py index 22c99520..471f65b9 100644 --- a/lib/python/Components/NimManager.py +++ b/lib/python/Components/NimManager.py @@ -1,14 +1,13 @@ -from config import config, ConfigSubsection, ConfigSelection, ConfigFloat, ConfigSatlist, ConfigYesNo, ConfigInteger, ConfigSubList, ConfigNothing, ConfigSubDict, ConfigOnOff, ConfigDateTime +from config import config, ConfigSubsection, ConfigSelection, ConfigFloat, \ + ConfigSatlist, ConfigYesNo, ConfigInteger, ConfigSubList, ConfigNothing, \ + ConfigSubDict, ConfigOnOff, ConfigDateTime from enigma import eDVBSatelliteEquipmentControl as secClass, \ eDVBSatelliteLNBParameters as lnbParam, \ eDVBSatelliteDiseqcParameters as diseqcParam, \ eDVBSatelliteSwitchParameters as switchParam, \ eDVBSatelliteRotorParameters as rotorParam, \ - eDVBResourceManager - -from xml.sax import make_parser -from xml.sax.handler import ContentHandler + eDVBResourceManager, eDVBDB from time import localtime, mktime from datetime import datetime @@ -29,7 +28,7 @@ def tryOpen(filename): return procFile class SecConfigure: - def addLNBSimple(self, sec, slotid, diseqcmode, toneburstmode = diseqcParam.NO, diseqcpos = diseqcParam.SENDNO, orbpos = 0, longitude = 0, latitude = 0, loDirection = 0, laDirection = 0, turningSpeed = rotorParam.FAST): + def addLNBSimple(self, sec, slotid, diseqcmode, toneburstmode = diseqcParam.NO, diseqcpos = diseqcParam.SENDNO, orbpos = 0, longitude = 0, latitude = 0, loDirection = 0, laDirection = 0, turningSpeed = rotorParam.FAST, useInputPower=True, inputPowerDelta=50): #simple defaults sec.addLNB() tunermask = 1 << slotid @@ -65,8 +64,8 @@ class SecConfigure: sec.setLaDirection(laDirection) sec.setLongitude(longitude) sec.setLoDirection(loDirection) - sec.setUseInputpower(True) - sec.setInputpowerDelta(50) + sec.setUseInputpower(useInputPower) + sec.setInputpowerDelta(inputPowerDelta) sec.setRotorTurningSpeed(turningSpeed) for x in self.NimManager.satList: @@ -104,6 +103,11 @@ class SecConfigure: used_nim_slots = [ ] + for slot in nim_slots: + if slot.type is not None: + used_nim_slots.append((slot.slot, slot.description, slot.config.configMode.value != "nothing" and True or False)) + eDVBResourceManager.getInstance().setFrontendSlotInformations(used_nim_slots) + for slot in nim_slots: x = slot.slot nim = slot.config @@ -119,11 +123,6 @@ class SecConfigure: self.setSatposDepends(sec, x, int(nim.satposDependsTo.value)) self.satposdepends[int(nim.satposDependsTo.value)]=x - if slot.type is not None: - used_nim_slots.append((slot.slot, slot.description, nim.configMode.value != "nothing" and True or False)) - - eDVBResourceManager.getInstance().setFrontendSlotInformations(used_nim_slots) - for slot in nim_slots: x = slot.slot nim = slot.config @@ -159,20 +158,28 @@ class SecConfigure: loValue = rotorParam.EAST else: loValue = rotorParam.WEST - turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW } - if turn_speed_dict.has_key(nim.turningSpeed.value): - turning_speed = turn_speed_dict[nim.turningSpeed.value] - else: - beg_time = localtime(nim.fastTurningBegin.value) - end_time = localtime(nim.fastTurningEnd.value) - turning_speed = ((beg_time.tm_hour+1) * 60 + beg_time.tm_min + 1) << 16 - turning_speed |= (end_time.tm_hour+1) * 60 + end_time.tm_min + 1 + inputPowerDelta=50 + useInputPower=False + turning_speed=0 + if nim.powerMeasurement.value: + useInputPower=True + inputPowerDelta=nim.powerThreshold.value + turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW } + if turn_speed_dict.has_key(nim.turningSpeed.value): + turning_speed = turn_speed_dict[nim.turningSpeed.value] + else: + beg_time = localtime(nim.fastTurningBegin.value) + end_time = localtime(nim.fastTurningEnd.value) + turning_speed = ((beg_time.tm_hour+1) * 60 + beg_time.tm_min + 1) << 16 + turning_speed |= (end_time.tm_hour+1) * 60 + end_time.tm_min + 1 self.addLNBSimple(sec, slotid = x, diseqcmode = 3, longitude = nim.longitude.float, loDirection = loValue, latitude = nim.latitude.float, laDirection = laValue, - turningSpeed = turning_speed) + turningSpeed = turning_speed, + useInputPower = useInputPower, + inputPowerDelta = inputPowerDelta) elif nim.configMode.value == "advanced": #advanced config self.updateAdvanced(sec, x) print "sec config completed" @@ -403,100 +410,6 @@ class NIM(object): empty = property(lambda self: self.type is None) class NimManager: - class parseSats(ContentHandler): - def __init__(self, satList, satellites, transponders): - self.isPointsElement, self.isReboundsElement = 0, 0 - self.satList = satList - self.satellites = satellites - self.transponders = transponders - - def startElement(self, name, attrs): - if (name == "sat"): - #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',"")) - tpos = int(attrs.get('position',"")) - if tpos < 0: - tpos = 3600 + tpos - tname = attrs.get('name',"").encode("UTF-8") - self.satellites[tpos] = tname - self.satList.append( (tpos, tname) ) - self.parsedSat = int(tpos) - elif (name == "transponder"): - modulation = int(attrs.get('modulation',"1")) # QPSK default - system = int(attrs.get('system',"0")) # DVB-S default - freq = int(attrs.get('frequency',"")) - sr = int(attrs.get('symbol_rate',"")) - pol = int(attrs.get('polarization',"")) - fec = int(attrs.get('fec_inner',"0")) # AUTO default - if self.parsedSat in self.transponders: - pass - else: - self.transponders[self.parsedSat] = [ ] - - self.transponders[self.parsedSat].append((0, freq, sr, pol, fec, system, modulation)) - - class parseCables(ContentHandler): - def __init__(self, cablesList, transponders): - self.isPointsElement, self.isReboundsElement = 0, 0 - self.cablesList = cablesList - for x in self.cablesList: - self.cablesList.remove(x) - self.transponders = transponders - - def startElement(self, name, attrs): - if (name == "cable"): - #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',"")) - tname = attrs.get('name',"").encode("UTF-8") - tflags = int(attrs.get('flags',"0")) - self.cablesList.append((tname, tflags)) - self.parsedCab = tname - elif (name == "transponder"): - freq = int(attrs.get('frequency',"")) - while freq > 999999: - freq /= 10 - sr = int(attrs.get('symbol_rate',"0")) - mod = int(attrs.get('modulation',"3")) # QAM64 default - fec = int(attrs.get('fec_inner',"0")) # AUTO default - if self.parsedCab in self.transponders: - pass - else: - self.transponders[self.parsedCab] = [ ] - self.transponders[self.parsedCab].append((1, freq, sr, mod, fec)) - - class parseTerrestrials(ContentHandler): - def __init__(self, terrestrialsList, transponders): - self.isPointsElement, self.isReboundsElement = 0, 0 - self.terrestrialsList = terrestrialsList - self.transponders = transponders - - def startElement(self, name, attrs): - if (name == "terrestrial"): - #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',"")) - tname = attrs.get('name',"").encode("UTF-8") - tflags = attrs.get('flags',"") - self.terrestrialsList.append((tname, tflags)) - self.parsedTer = str(tname) - elif (name == "transponder"): - # TODO finish this! - freq = int(attrs.get('centre_frequency',"")) - bw = int(attrs.get('bandwidth',"3")) # AUTO - const = int(attrs.get('constellation',"1")) # AUTO - crh = int(attrs.get('code_rate_hp',"5")) # AUTO - if crh > 5: # our terrestrial.xml is buggy... 6 for AUTO - crh = 5 - crl = int(attrs.get('code_rate_lp',"5")) # AUTO - if crl > 5: # our terrestrial.xml is buggy... 6 for AUTO - crl = 5 - guard = int(attrs.get('guard_interval',"4")) # AUTO - transm = int(attrs.get('transmission_mode',"2")) # AUTO - hierarchy = int(attrs.get('hierarchy_information',"4")) # AUTO - inv = int(attrs.get('inversion',"2")) # AUTO - if self.parsedTer in self.transponders: - pass - else: - self.transponders[self.parsedTer] = [ ] - - self.transponders[self.parsedTer].append((2, freq, bw, const, crh, crl, guard, transm, hierarchy, inv)) - def getTransponders(self, pos): if self.transponders.has_key(pos): return self.transponders[pos] @@ -530,33 +443,32 @@ class NimManager: def getSatDescription(self, pos): return self.satellites[pos] - def readSatsfromFile(self): + def readTransponders(self): # read initial networks from file. we only read files which we are interested in, # which means only these where a compatible tuner exists. self.satellites = { } self.transponders = { } self.transponderscable = { } - self.transpondersterrestrial = { } - - parser = make_parser() - + self.transpondersterrestrial = { } + db = eDVBDB.getInstance() if self.hasNimType("DVB-S"): print "Reading satellites.xml" - satHandler = self.parseSats(self.satList, self.satellites, self.transponders) - parser.setContentHandler(satHandler) - parser.parse('/etc/tuxbox/satellites.xml') + db.readSatellites(self.satList, self.satellites, self.transponders) +# print "SATLIST", self.satList +# print "SATS", self.satellites +# print "TRANSPONDERS", self.transponders if self.hasNimType("DVB-C"): print "Reading cables.xml" - cabHandler = self.parseCables(self.cablesList, self.transponderscable) - parser.setContentHandler(cabHandler) - parser.parse('/etc/tuxbox/cables.xml') + db.readCables(self.cablesList, self.transponderscable) +# print "CABLIST", self.cablesList +# print "TRANSPONDERS", self.transponders if self.hasNimType("DVB-T"): print "Reading terrestrial.xml" - terHandler = self.parseTerrestrials(self.terrestrialsList, self.transpondersterrestrial) - parser.setContentHandler(terHandler) - parser.parse('/etc/tuxbox/terrestrial.xml') + db.readTerrestrials(self.terrestrialsList, self.transpondersterrestrial) +# print "TERLIST", self.terrestrialsList +# print "TRANSPONDERS", self.transpondersterrestrial def enumerateNIMs(self): # enum available NIMs. This is currently very dreambox-centric and uses the /proc/bus/nim_sockets interface. @@ -578,6 +490,9 @@ class NimManager: # # Type will be either "DVB-S", "DVB-S2", "DVB-T", "DVB-C" or None. + # nim_slots is an array which has exactly one entry for each slot, even for empty ones. + self.nim_slots = [ ] + nimfile = tryOpen("/proc/bus/nim_sockets") if nimfile is None: @@ -602,9 +517,6 @@ class NimManager: entries[current_slot]["name"] = _("N/A") nimfile.close() - # nim_slots is an array which has exactly one entry for each slot, even for empty ones. - self.nim_slots = [ ] - for id, entry in entries.items(): if not (entry.has_key("name") and entry.has_key("type")): entry["name"] = _("N/A") @@ -630,8 +542,7 @@ class NimManager: self.cablesList = [] self.terrestrialsList = [] self.enumerateNIMs() - self.readSatsfromFile() - + self.readTransponders() InitNimManager(self) #init config stuff # get a list with the friendly full description @@ -834,6 +745,8 @@ def InitNimManager(nimmgr): nim.longitudeOrientation = ConfigSelection(choices={"east": _("East"), "west": _("West")}, default = "east") nim.latitude = ConfigFloat(default=[50,767], limits=[(0,359),(0,999)]) nim.latitudeOrientation = ConfigSelection(choices={"north": _("North"), "south": _("South")}, default="north") + nim.powerMeasurement = ConfigYesNo(default=True) + nim.powerThreshold = ConfigInteger(default=50, limits=(0, 100)) nim.turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch")) ], default = "fast") btime = datetime(1970, 1, 1, 7, 0); nim.fastTurningBegin = ConfigDateTime(default = mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 900) @@ -930,8 +843,8 @@ def InitNimManager(nimmgr): possible_scan_types = [("bands", _("Frequency bands")), ("steps", _("Frequency steps"))] if n: possible_scan_types.append(("provider", _("Provider"))) + nim.cable.scan_provider = ConfigSelection(default = "0", choices = list) nim.cable.scan_type = ConfigSelection(default = "bands", choices = possible_scan_types) - nim.cable.scan_provider = ConfigSelection(default = "0", choices = list) nim.cable.scan_band_EU_VHF_I = ConfigYesNo(default = True) nim.cable.scan_band_EU_MID = ConfigYesNo(default = True) nim.cable.scan_band_EU_VHF_III = ConfigYesNo(default = True)