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 configSequence
8 from config import configsequencearg
9 from config import configSatlist
13 import xml.dom.minidom
14 from xml.dom import EMPTY_NAMESPACE
15 from skin import elementsWithTag
16 from Tools import XMLTools
18 from xml.sax import make_parser
19 from xml.sax.handler import ContentHandler
22 def addLNBSimple(self, slotid, orbpos, toneburstmode, diseqcmode, diseqcpos):
24 sec = eDVBSatelliteEquipmentControl.getInstance()
26 sec.setLNBTunerMask(1 << slotid)
27 sec.setLNBLOFL(9750000)
28 sec.setLNBLOFH(10600000)
29 sec.setLNBThreshold(11750000)
33 sec.setVoltageMode(0) #HV
34 sec.setToneMode(0) #HILO
35 sec.setCommandOrder(0)
37 sec.setDiSEqCMode(diseqcmode)
38 sec.setToneburst(toneburstmode)
39 sec.setCommittedCommand(diseqcpos)
40 #print "set orbpos to:" + str(orbpos)
41 sec.addSatellite(orbpos)
42 self.satList.append(orbpos)
48 eDVBSatelliteEquipmentControl.getInstance().clear()
51 for slot in self.NimManager.nimslots:
54 if slot.nimType == self.NimManager.nimType["DVB-S"]:
55 print "slot: " + str(x) + " configmode: " + str(nim.configMode.value)
56 if nim.configMode.value == 0: #simple config
57 if nim.diseqcMode.value == 0: #single
58 self.addLNBSimple(x, int(nim.diseqcA.vals[nim.diseqcA.value][1]), 0, 0, 4)
59 elif nim.diseqcMode.value == 1: #Toneburst A/B
60 self.addLNBSimple(x, int(nim.diseqcA.vals[nim.diseqcA.value][1]), 1, 0, 4)
61 self.addLNBSimple(x, int(nim.diseqcB.vals[nim.diseqcB.value][1]), 1, 0, 4)
62 elif nim.diseqcMode.value == 2: #DiSEqC A/B
63 self.addLNBSimple(x, int(nim.diseqcA.vals[nim.diseqcA.value][1]), 0, 1, 0)
64 self.addLNBSimple(x, int(nim.diseqcB.vals[nim.diseqcB.value][1]), 0, 1, 1)
65 elif nim.diseqcMode.value == 3: #DiSEqC A/B/C/D
66 self.addLNBSimple(x, int(nim.diseqcA.vals[nim.diseqcA.value][1]), 0, 1, 0)
67 self.addLNBSimple(x, int(nim.diseqcB.vals[nim.diseqcB.value][1]), 0, 1, 1)
68 self.addLNBSimple(x, int(nim.diseqcC.vals[nim.diseqcC.value][1]), 0, 1, 2)
69 self.addLNBSimple(x, int(nim.diseqcD.vals[nim.diseqcD.value][1]), 0, 1, 3)
70 elif nim.diseqcMode.value == 4: #Positioner
71 print "FIXME: positioner suppport"
73 else: #advanced config
74 print "FIXME add support for advanced config"
76 def __init__(self, nimmgr):
77 self.NimManager = nimmgr
81 def __init__(self, fnc, *args):
84 def __call__(self, *args):
85 self.fnc(*self.args + args)
88 def __init__(self, slotid, nimtype, name):
90 self.nimType = nimtype
94 class parseSats(ContentHandler):
95 def __init__(self, satList, satellites):
96 self.isPointsElement, self.isReboundsElement = 0, 0
97 self.satList = satList
98 self.satellites = satellites
100 def startElement(self, name, attrs):
102 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
103 tpos = attrs.get('position',"")
104 tname = attrs.get('name',"")
105 self.satellites[tpos] = tname
106 self.satList.append( (tname, tpos) )
108 def getConfiguredSats(self):
109 return self.sec.getSatList()
111 def getSatDescription(self, pos):
112 return self.satellites[str(pos)]
114 def readSatsfromFile(self):
115 self.satellites = { }
117 print "Reading satellites.xml"
118 parser = make_parser()
119 satHandler = self.parseSats(self.satList, self.satellites)
120 parser.setContentHandler(satHandler)
121 parser.parse('/etc/tuxbox/satellites.xml')
123 def getNimType(self, slotID):
124 #FIXME get it from /proc
126 return self.nimType["DVB-S"]
128 return self.nimType["empty/unknown"]
130 def getNimName(self, slotID):
131 #FIXME get it from /proc
134 def getNimSocketCount(self):
135 #FIXME get it from /proc
138 def getConfigPrefix(self, slotid):
139 return "config.Nim" + ("A","B","C","D")[slotid] + "."
143 self.nimType = { "empty/unknown": -1,
149 self.readSatsfromFile()
151 self.nimCount = self.getNimSocketCount()
155 while x < self.nimCount:
156 tType = self.getNimType(x)
157 tName = self.getNimName(x)
158 tNim = nimSlot(x, tType, tName)
159 self.nimslots.append(tNim)
162 InitNimManager(self) #init config stuff
166 for slot in self.nimslots:
167 nimText = "Socket " + ("A", "B", "C", "D")[slot.slotid] + ": "
168 if slot.nimType == -1:
169 nimText += "empty/unknown"
171 nimText += slot.name + " ("
172 nimText += ("DVB-S", "DVB-C", "DVB-T")[slot.nimType] + ")"
173 list.append((nimText, slot))
176 def getSatListForNim(self, slotid):
177 #print "slotid:", slotid
179 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
180 #print "diseqcA:", config.Nims[slotid].diseqcA.value
181 if (config.Nims[slotid].diseqcMode.value <= 3):
182 list.append(self.satList[config.Nims[slotid].diseqcA.value])
183 if (0 < config.Nims[slotid].diseqcMode.value <= 3):
184 list.append(self.satList[config.Nims[slotid].diseqcB.value])
185 if (config.Nims[slotid].diseqcMode.value == 3):
186 list.append(self.satList[config.Nims[slotid].diseqcC.value])
187 list.append(self.satList[config.Nims[slotid].diseqcD.value])
190 #callbacks for c++ config
191 def nimConfigModeChanged(self, slotid, mode):
192 #print "nimConfigModeChanged set to " + str(mode)
194 def nimDiseqcModeChanged(self, slotid, mode):
195 #print "nimDiseqcModeChanged set to " + str(mode)
197 def nimPortAChanged(self, slotid, val):
198 #print "nimDiseqcA set to " + str(val)
200 def nimPortBChanged(self, slotid, val):
201 #print "nimDiseqcB set to " + str(val)
203 def nimPortCChanged(self, slotid, val):
204 #print "nimDiseqcC set to " + str(val)
206 def nimPortDChanged(self, slotid, val):
207 #print "nimDiseqcD set to " + str(val)
211 def InitNimManager(nimmgr):
212 config.Nims = [ConfigSubsection()] * nimmgr.nimCount
214 def nimConfigModeChanged(slotid, configElement):
215 nimmgr.nimConfigModeChanged(slotid, configElement.value)
216 def nimDiseqcModeChanged(slotid, configElement):
217 nimmgr.nimDiseqcModeChanged(slotid, configElement.value)
219 def nimPortAChanged(slotid, configElement):
220 nimmgr.nimPortAChanged(slotid, configElement.vals[configElement.value][1])
221 def nimPortBChanged(slotid, configElement):
222 nimmgr.nimPortBChanged(slotid, configElement.vals[configElement.value][1])
223 def nimPortCChanged(slotid, configElement):
224 nimmgr.nimPortCChanged(slotid, configElement.vals[configElement.value][1])
225 def nimPortDChanged(slotid, configElement):
226 nimmgr.nimPortDChanged(slotid, configElement.vals[configElement.value][1])
228 for slot in nimmgr.nimslots:
230 cname = nimmgr.getConfigPrefix(x)
233 if slot.nimType == nimmgr.nimType["DVB-S"]:
234 nim.configMode = configElement(cname + "configMode",configSelection, 0, ("Simple", "Advanced"));
235 nim.diseqcMode = configElement(cname + "diseqcMode",configSelection, 2, ("Single", "Toneburst A/B", "DiSEqC A/B", "DiSEqC A/B/C/D", "Positioner"));
236 nim.diseqcA = configElement(cname + "diseqcA",configSatlist, 192, nimmgr.satList);
237 nim.diseqcB = configElement(cname + "diseqcB",configSatlist, 130, nimmgr.satList);
238 nim.diseqcC = configElement(cname + "diseqcC",configSatlist, 0, nimmgr.satList);
239 nim.diseqcD = configElement(cname + "diseqcD",configSatlist, 0, nimmgr.satList);
240 nim.longitude = configElement(cname + "longitude",configSequence, [0,0], configsequencearg.get("FLOAT", [(0,90),(0,999)]));
241 nim.latitude = configElement(cname + "latitude",configSequence, [0,0], configsequencearg.get("FLOAT", [(0,90),(0,999)]));
243 #perhaps the instance of the slot is more useful?
244 nim.configMode.addNotifier(boundFunction(nimConfigModeChanged,x))
245 nim.diseqcMode.addNotifier(boundFunction(nimDiseqcModeChanged,x))
246 nim.diseqcA.addNotifier(boundFunction(nimPortAChanged,x))
247 nim.diseqcB.addNotifier(boundFunction(nimPortBChanged,x))
248 nim.diseqcC.addNotifier(boundFunction(nimPortCChanged,x))
249 nim.diseqcD.addNotifier(boundFunction(nimPortDChanged,x))
251 print "pls add support for this frontend type!"
253 nimmgr.sec = SecConfigure(nimmgr)
255 nimmanager = NimManager()