X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/dabf2f38d7b132883c7b67524432e9b0de3c9412..54c379e068e843d388e8088fb2d48a1ca40409a1:/lib/python/Components/NimManager.py diff --git a/lib/python/Components/NimManager.py b/lib/python/Components/NimManager.py index 09928d07..f6362545 100644 --- a/lib/python/Components/NimManager.py +++ b/lib/python/Components/NimManager.py @@ -18,6 +18,13 @@ from Tools import XMLTools from xml.sax import make_parser from xml.sax.handler import ContentHandler +def tryOpen(filename): + try: + procFile = open(filename) + except IOError: + return "" + return procFile + class SecConfigure: def addLNBSimple(self, slotid, orbpos, toneburstmode, diseqcmode, diseqcpos): #simple defaults @@ -92,10 +99,11 @@ class nimSlot: class NimManager: class parseSats(ContentHandler): - def __init__(self, satList, satellites): + 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"): @@ -104,6 +112,21 @@ class NimManager: tname = attrs.get('name',"") self.satellites[tpos] = tname self.satList.append( (tname, tpos) ) + self.parsedSat = int(tpos) + elif (name == "transponder"): + freq = int(attrs.get('frequency',"")) + sr = int(attrs.get('symbol_rate',"")) + pol = int(attrs.get('polarization',"")) + fec = int(attrs.get('fec_inner',"")) + if self.parsedSat in self.transponders: + pass + else: + self.transponders[self.parsedSat] = [ ] + + self.transponders[self.parsedSat].append((0, freq, sr, pol, fec)) + + def getTransponders(self, pos): + return self.transponders[pos] def getConfiguredSats(self): return self.sec.getSatList() @@ -113,19 +136,46 @@ class NimManager: def readSatsfromFile(self): self.satellites = { } + self.transponders = { } print "Reading satellites.xml" parser = make_parser() - satHandler = self.parseSats(self.satList, self.satellites) + satHandler = self.parseSats(self.satList, self.satellites, self.transponders) parser.setContentHandler(satHandler) parser.parse('/etc/tuxbox/satellites.xml') def getNimType(self, slotID): #FIXME get it from /proc - if slotID == 0: - return self.nimType["DVB-S"] - else: - return self.nimType["empty/unknown"] + nimfile = tryOpen("/proc/bus/nim_sockets") + + if nimfile == "": + # FIXME: remove this in the final version + # check if we have a device for 7020 comp?atibility reasons + try: + open("/dev/dvb/card0/frontend" + str(slotID)) + return self.nimType["DVB-S"] + except IOError: + return self.nimType["empty/unknown"] + + + while 1: + line = nimfile.readline() + if line == "": + break + if line.startswith("NIM Socket"): + parts = line.strip().split(" ") + id = int(parts[2][:1]) + if id == slotID: + line = nimfile.readline() + if line == "": + break + if line.startswith(" Type:"): + nimfile.close() + return self.nimType["DVB-S"] + else: + break + nimfile.close() + return self.nimType["empty/unknown"] def getNimName(self, slotID): #FIXME get it from /proc @@ -147,7 +197,7 @@ class NimManager: self.satList = [ ] self.readSatsfromFile() - + self.nimCount = self.getNimSocketCount() self.nimslots = [ ] @@ -174,17 +224,19 @@ class NimManager: return list def getSatListForNim(self, slotid): - #print "slotid:", slotid list = [] - #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value] - #print "diseqcA:", config.Nims[slotid].diseqcA.value - if (config.Nims[slotid].diseqcMode.value <= 3): - list.append(self.satList[config.Nims[slotid].diseqcA.value]) - if (0 < config.Nims[slotid].diseqcMode.value <= 3): - list.append(self.satList[config.Nims[slotid].diseqcB.value]) - if (config.Nims[slotid].diseqcMode.value == 3): - list.append(self.satList[config.Nims[slotid].diseqcC.value]) - list.append(self.satList[config.Nims[slotid].diseqcD.value]) + if (self.getNimType(slotid) != self.nimType["empty/unknown"]): + #print "slotid:", slotid + + #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value] + #print "diseqcA:", config.Nims[slotid].diseqcA.value + if (config.Nims[slotid].diseqcMode.value <= 3): + list.append(self.satList[config.Nims[slotid].diseqcA.value]) + if (0 < config.Nims[slotid].diseqcMode.value <= 3): + list.append(self.satList[config.Nims[slotid].diseqcB.value]) + if (config.Nims[slotid].diseqcMode.value == 3): + list.append(self.satList[config.Nims[slotid].diseqcC.value]) + list.append(self.satList[config.Nims[slotid].diseqcD.value]) return list #callbacks for c++ config @@ -195,9 +247,10 @@ class NimManager: #print "nimDiseqcModeChanged set to " + str(mode) pass def nimPortAChanged(self, slotid, val): - #print "nimDiseqcA set to " + str(val) + #print "nimDiseqcA set to " + str(slotid) + " val:" + str(val) pass def nimPortBChanged(self, slotid, val): + #print "nimDiseqcA set to " + str(slotid) + " val:" + str(val) #print "nimDiseqcB set to " + str(val) pass def nimPortCChanged(self, slotid, val): @@ -209,8 +262,10 @@ class NimManager: def InitNimManager(nimmgr): - config.Nims = [ConfigSubsection()] * nimmgr.nimCount - + config.Nims = [] + for x in range(nimmgr.nimCount): + config.Nims.append(ConfigSubsection()) + def nimConfigModeChanged(slotid, configElement): nimmgr.nimConfigModeChanged(slotid, configElement.value) def nimDiseqcModeChanged(slotid, configElement): @@ -243,13 +298,13 @@ def InitNimManager(nimmgr): #perhaps the instance of the slot is more useful? nim.configMode.addNotifier(boundFunction(nimConfigModeChanged,x)) nim.diseqcMode.addNotifier(boundFunction(nimDiseqcModeChanged,x)) - nim.diseqcA.addNotifier(boundFunction(nimPortAChanged,x)) + nim.diseqcA.addNotifier(boundFunction(nimPortAChanged,int(x))) nim.diseqcB.addNotifier(boundFunction(nimPortBChanged,x)) nim.diseqcC.addNotifier(boundFunction(nimPortCChanged,x)) nim.diseqcD.addNotifier(boundFunction(nimPortDChanged,x)) else: print "pls add support for this frontend type!" - + nimmgr.sec = SecConfigure(nimmgr) nimmanager = NimManager()