1 from config import config #global config instance
3 from config import configElement
4 from config import ConfigSubsection
5 from config import ConfigSlider
6 from config import configSelection
7 from config import configSatlist
10 from xml.dom import EMPTY_NAMESPACE
11 from skin import elementsWithTag
12 from Tools import XMLTools
15 def __init__(self, fnc, *args):
18 def __call__(self, *args):
19 self.fnc(*self.args + args)
22 def __init__(self, slotid, nimtype, name):
24 self.nimType = nimtype
28 def readSatsfromFile(self):
31 satdom = xml.dom.minidom.parse('/etc/tuxbox/satellites.xml')
34 for entries in elementsWithTag(satdom.childNodes, "satellites"):
35 for x in elementsWithTag(entries.childNodes, "sat"):
36 #print "found sat " + x.getAttribute('name') + " " + str(x.getAttribute('position'))
37 tpos = x.getAttribute('position')
38 tname = x.getAttribute('name')
40 self.satellites[tpos] = tname
41 self.satList.append( (tname, tpos) )
43 def getNimType(self, slotID):
44 #FIXME get it from /proc
46 return self.nimType["DVB-S"]
48 return self.nimType["empty/unknown"]
50 def getNimName(self, slotID):
51 #FIXME get it from /proc
54 def getNimSocketCount(self):
55 #FIXME get it from /proc
58 def getConfigPrefix(self, slotid):
59 return "config.Nim" + ("A","B","C","D")[slotid] + "."
63 self.nimType = { "empty/unknown": -1,
69 self.readSatsfromFile()
71 self.nimCount = self.getNimSocketCount()
75 while x < self.nimCount:
76 tType = self.getNimType(x)
77 tName = self.getNimName(x)
78 tNim = nimSlot(x, tType, tName)
79 self.nimslots.append(tNim)
82 InitNimManager(self) #init config stuff
86 for slot in self.nimslots:
87 nimText = "Socket " + ("A", "B", "C", "D")[slot.slotid] + ": "
88 if slot.nimType == -1:
89 nimText += "empty/unknown"
91 nimText += slot.name + " ("
92 nimText += ("DVB-S", "DVB-C", "DVB-T")[slot.nimType] + ")"
93 list.append((nimText, slot))
96 #callbacks for c++ config
97 def nimConfigModeChanged(self, slotid, mode):
98 print "nimConfigModeChanged set to " + str(mode)
99 def nimDiseqcModeChanged(self, slotid, mode):
100 print "nimDiseqcModeChanged set to " + str(mode)
101 def nimPortAChanged(self, slotid, val):
102 print "nimDiseqcA set to " + str(val)
103 def nimPortBChanged(self, slotid, val):
104 print "nimDiseqcB set to " + str(val)
105 def nimPortCChanged(self, slotid, val):
106 print "nimDiseqcC set to " + str(val)
107 def nimPortDChanged(self, slotid, val):
108 print "nimDiseqcD set to " + str(val)
111 def InitNimManager(nimmgr):
112 config.Nims = [ConfigSubsection()] * nimmgr.nimCount
114 def nimConfigModeChanged(slotid, configElement):
115 nimmgr.nimConfigModeChanged(slotid, configElement.value)
116 def nimDiseqcModeChanged(slotid, configElement):
117 nimmgr.nimDiseqcModeChanged(slotid, configElement.value)
119 def nimPortAChanged(slotid, configElement):
120 nimmgr.nimPortAChanged(slotid, configElement.vals[configElement.value][1])
121 def nimPortBChanged(slotid, configElement):
122 nimmgr.nimPortBChanged(slotid, configElement.vals[configElement.value][1])
123 def nimPortCChanged(slotid, configElement):
124 nimmgr.nimPortCChanged(slotid, configElement.vals[configElement.value][1])
125 def nimPortDChanged(slotid, configElement):
126 nimmgr.nimPortDChanged(slotid, configElement.vals[configElement.value][1])
128 for slot in nimmgr.nimslots:
130 cname = nimmgr.getConfigPrefix(x)
132 if slot.nimType == nimmgr.nimType["DVB-S"]:
133 config.Nims[x].configMode = configElement(cname + "configMode",configSelection, 0, ("Simple", "Advanced"));
134 config.Nims[x].diseqcMode = configElement(cname + "diseqcMode",configSelection, 2, ("Single", "Toneburst A/B", "DiSEqC A/B", "DiSEqC A/B/C/D"));
135 config.Nims[x].diseqcA = configElement(cname + "diseqcA",configSatlist, 192, nimmgr.satList);
136 config.Nims[x].diseqcB = configElement(cname + "diseqcB",configSatlist, 130, nimmgr.satList);
137 config.Nims[x].diseqcC = configElement(cname + "diseqcC",configSatlist, 0, nimmgr.satList);
138 config.Nims[x].diseqcD = configElement(cname + "diseqcD",configSatlist, 0, nimmgr.satList);
140 #perhaps the instance of the slot is more useful?
141 config.Nims[x].configMode.addNotifier(boundFunction(nimConfigModeChanged,x))
142 config.Nims[x].diseqcMode.addNotifier(boundFunction(nimDiseqcModeChanged,x))
143 config.Nims[x].diseqcA.addNotifier(boundFunction(nimPortAChanged,x))
144 config.Nims[x].diseqcB.addNotifier(boundFunction(nimPortBChanged,x))
145 config.Nims[x].diseqcC.addNotifier(boundFunction(nimPortCChanged,x))
146 config.Nims[x].diseqcD.addNotifier(boundFunction(nimPortDChanged,x))
148 print "pls add support for this frontend type!"
150 nimmanager = NimManager()