1 from config import config #global config instance
3 from config import configElement
4 from config import ConfigSubsection
5 from config import configSelection
6 from config import currentConfigSelectionElement
7 from config import getConfigSelectionElement
8 from config import configSequence
9 from config import configsequencearg
10 from config import configSatlist
12 from enigma import eDVBSatelliteEquipmentControl, \
13 eDVBSatelliteLNBParameters as lnbParam, \
14 eDVBSatelliteDiseqcParameters as diseqcParam, \
15 eDVBSatelliteSwitchParameters as switchParam, \
16 eDVBSatelliteRotorParameters as rotorParam
18 import xml.dom.minidom
19 from xml.dom import EMPTY_NAMESPACE
20 from skin import elementsWithTag
21 from Tools import XMLTools
23 from xml.sax import make_parser
24 from xml.sax.handler import ContentHandler
26 from Tools.BoundFunction import boundFunction
28 def tryOpen(filename):
30 procFile = open(filename)
36 def addLNBSimple(self, sec, slotid, diseqcmode, toneburstmode = 0, diseqcpos = 0, orbpos = 0, longitude = 0, latitude = 0, loDirection = 0, laDirection = 0):
39 tunermask = 1 << slotid
40 if self.equal.has_key(slotid):
41 tunermask |= (1 << self.equal[slotid])
42 elif self.linked.has_key(slotid):
43 tunermask |= (1 << self.linked[slotid])
44 sec.setLNBTunerMask(tunermask)
45 sec.setLNBLOFL(9750000)
46 sec.setLNBLOFH(10600000)
47 sec.setLNBThreshold(11750000)
48 sec.setLNBIncreasedVoltage(lnbParam.OFF)
52 sec.setVoltageMode(switchParam.HV)
53 sec.setToneMode(switchParam.HILO)
54 sec.setCommandOrder(0)
57 sec.setDiSEqCMode(diseqcmode)
58 sec.setToneburst(toneburstmode)
59 sec.setCommittedCommand(diseqcpos)
60 #print "set orbpos to:" + str(orbpos)
62 if (0 <= diseqcmode < 3):
63 sec.addSatellite(orbpos)
64 self.satList.append(orbpos)
65 elif (diseqcmode == 3): # diseqc 1.2
66 if self.satposdepends.has_key(slotid):
67 tunermask |= (1 << self.satposdepends[slotid])
68 sec.setLNBTunerMask(tunermask)
69 sec.setLatitude(latitude)
70 sec.setLaDirection(laDirection)
71 sec.setLongitude(longitude)
72 sec.setLoDirection(loDirection)
73 sec.setUseInputpower(True)
74 sec.setInputpowerDelta(50)
76 for x in self.NimManager.satList:
77 print "Add sat " + str(x[1])
78 sec.addSatellite(int(x[1]))
81 sec.setRotorPosNum(0) # USALS
82 self.satList.append(int(x[1]))
84 def setSatposDepends(self, sec, nim1, nim2):
85 print "tuner", nim1, "depends on satpos of", nim2
86 sec.setTunerDepends(nim1, nim2)
88 def linkNIMs(self, sec, nim1, nim2):
89 print "link tuner", nim1, "to tuner", nim2
90 sec.setTunerLinked(nim1, nim2)
96 sec = eDVBSatelliteEquipmentControl.getInstance()
97 sec.clear() ## this do unlinking NIMs too !!
98 print "sec config cleared"
102 self.satposdepends = { }
104 for slot in self.NimManager.nimslots:
107 if slot.nimType == self.NimManager.nimType["DVB-S"]:
108 if currentConfigSelectionElement(nim.configMode) == "equal":
109 self.equal[nim.equalTo.value]=x
110 if currentConfigSelectionElement(nim.configMode) == "loopthrough":
111 self.linkNIMs(sec, x, nim.linkedTo.value)
112 self.linked[nim.linkedTo.value]=x
113 elif currentConfigSelectionElement(nim.configMode) == "satposdepends":
114 self.setSatposDepends(sec, x, nim.satposDependsTo.value)
115 self.satposdepends[nim.satposDependsTo.value]=x
117 for slot in self.NimManager.nimslots:
120 if slot.nimType == self.NimManager.nimType["DVB-S"]:
121 print "slot: " + str(x) + " configmode: " + str(nim.configMode.value)
122 if currentConfigSelectionElement(nim.configMode) in [ "loopthrough", "satposdepends", "equal", "nothing" ]:
124 elif currentConfigSelectionElement(nim.configMode) == "simple": #simple config
125 if currentConfigSelectionElement(nim.diseqcMode) == "single": #single
126 self.addLNBSimple(sec, slotid = x, orbpos = int(nim.diseqcA.vals[nim.diseqcA.value][1]), toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.NONE, diseqcpos = diseqcParam.SENDNO)
127 elif currentConfigSelectionElement(nim.diseqcMode) == "toneburst_a_b": #Toneburst A/B
128 self.addLNBSimple(sec, slotid = x, orbpos = int(nim.diseqcA.vals[nim.diseqcA.value][1]), toneburstmode = diseqcParam.A, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO)
129 self.addLNBSimple(sec, slotid = x, orbpos = int(nim.diseqcB.vals[nim.diseqcB.value][1]), toneburstmode = diseqcParam.B, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO)
130 elif currentConfigSelectionElement(nim.diseqcMode) == "diseqc_a_b": #DiSEqC A/B
131 self.addLNBSimple(sec, slotid = x, orbpos = int(nim.diseqcA.vals[nim.diseqcA.value][1]), toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA)
132 self.addLNBSimple(sec, slotid = x, orbpos = int(nim.diseqcB.vals[nim.diseqcB.value][1]), toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB)
133 elif currentConfigSelectionElement(nim.diseqcMode) == "diseqc_a_b_c_d": #DiSEqC A/B/C/D
134 self.addLNBSimple(sec, slotid = x, orbpos = int(nim.diseqcA.vals[nim.diseqcA.value][1]), toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA)
135 self.addLNBSimple(sec, slotid = x, orbpos = int(nim.diseqcB.vals[nim.diseqcB.value][1]), toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB)
136 self.addLNBSimple(sec, slotid = x, orbpos = int(nim.diseqcC.vals[nim.diseqcC.value][1]), toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BA)
137 self.addLNBSimple(sec, slotid = x, orbpos = int(nim.diseqcD.vals[nim.diseqcD.value][1]), toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BB)
138 elif currentConfigSelectionElement(nim.diseqcMode) == "positioner": #Positioner
139 if currentConfigSelectionElement(nim.latitudeOrientation) == "north":
140 laValue = rotorParam.NORTH
142 laValue = rotorParam.SOUTH
143 if currentConfigSelectionElement(nim.longitudeOrientation) == "east":
144 loValue = rotorParam.EAST
146 loValue = rotorParam.WEST
147 self.addLNBSimple(sec, slotid = x, diseqcmode = 3,
148 longitude = configsequencearg.getFloat(nim.longitude),
149 loDirection = loValue,
150 latitude = configsequencearg.getFloat(nim.latitude),
151 laDirection = laValue)
152 elif currentConfigSelectionElement(nim.configMode) == "advanced": #advanced config
153 self.updateAdvanced(sec, x)
154 print "sec config completed"
156 def updateAdvanced(self, sec, slotid):
158 for x in range(1,33):
160 for x in self.NimManager.satList:
161 lnb = config.Nims[slotid].advanced.sat[x[1]].lnb.value
163 print "add", x[1], "to", lnb
164 lnbSat[lnb].append(x[1])
165 for x in range(1,33):
166 if len(lnbSat[x]) > 0:
167 currLnb = config.Nims[slotid].advanced.lnb[x]
170 tunermask = 1 << slotid
171 if self.equal.has_key(slotid):
172 tunermask |= (1 << self.equal[slotid])
173 elif self.linked.has_key(slotid):
174 tunermask |= (1 << self.linked[slotid])
176 if currentConfigSelectionElement(currLnb.lof) == "universal_lnb":
177 sec.setLNBLOFL(9750000)
178 sec.setLNBLOFH(10600000)
179 sec.setLNBThreshold(11750000)
180 elif currentConfigSelectionElement(currLnb.lof) == "c_band":
181 sec.setLNBLOFL(5150000)
182 sec.setLNBLOFH(5150000)
183 sec.setLNBThreshold(5150000)
184 elif currentConfigSelectionElement(currLnb.lof) == "user_defined":
185 sec.setLNBLOFL(currLnb.lofl.value[0] * 1000)
186 sec.setLNBLOFH(currLnb.lofh.value[0] * 1000)
187 sec.setLNBThreshold(currLnb.threshold.value[0] * 1000)
189 if currentConfigSelectionElement(currLnb.output_12v) == "0V":
190 pass # nyi in drivers
191 elif currentConfigSelectionElement(currLnb.output_12v) == "12V":
192 pass # nyi in drivers
194 if currentConfigSelectionElement(currLnb.increased_voltage) == "yes":
195 sec.setLNBIncreasedVoltage(lnbParam.ON)
197 sec.setLNBIncreasedVoltage(lnbParam.OFF)
199 if currentConfigSelectionElement(currLnb.diseqcMode) == "none":
200 sec.setDiSEqCMode(diseqcParam.NONE)
201 elif currentConfigSelectionElement(currLnb.diseqcMode) == "1_0":
202 sec.setDiSEqCMode(diseqcParam.V1_0)
203 elif currentConfigSelectionElement(currLnb.diseqcMode) == "1_1":
204 sec.setDiSEqCMode(diseqcParam.V1_1)
205 elif currentConfigSelectionElement(currLnb.diseqcMode) == "1_2":
206 sec.setDiSEqCMode(diseqcParam.V1_2)
208 if self.satposdepends.has_key(slotid): # only useable with rotors
209 tunermask |= (1 << self.satposdepends[slotid])
211 if currentConfigSelectionElement(currLnb.diseqcMode) != "none":
212 if currentConfigSelectionElement(currLnb.toneburst) == "none":
213 sec.setToneburst(diseqcParam.NO)
214 elif currentConfigSelectionElement(currLnb.toneburst) == "A":
215 sec.setToneburst(diseqcParam.A)
216 elif currentConfigSelectionElement(currLnb.toneburst) == "B":
217 sec.setToneburst(diseqcParam.B)
219 if currentConfigSelectionElement(currLnb.commitedDiseqcCommand) == "none":
220 sec.setCommittedCommand(diseqcParam.SENDNO)
221 elif currentConfigSelectionElement(currLnb.commitedDiseqcCommand) == "AA":
222 sec.setCommittedCommand(diseqcParam.AA)
223 elif currentConfigSelectionElement(currLnb.commitedDiseqcCommand) == "AB":
224 sec.setCommittedCommand(diseqcParam.AB)
225 elif currentConfigSelectionElement(currLnb.commitedDiseqcCommand) == "BA":
226 sec.setCommittedCommand(diseqcParam.BA)
227 elif currentConfigSelectionElement(currLnb.commitedDiseqcCommand) == "BB":
228 sec.setCommittedCommand(diseqcParam.BB)
230 sec.setCommittedCommand(long(currentConfigSelectionElement(currLnb.commitedDiseqcCommand)))
232 if currentConfigSelectionElement(currLnb.fastDiseqc) == "yes":
233 sec.setFastDiSEqC(True)
235 sec.setFastDiSEqC(False)
237 if currentConfigSelectionElement(currLnb.sequenceRepeat) == "yes":
238 sec.setSeqRepeat(True)
240 sec.setSeqRepeat(False)
242 if currentConfigSelectionElement(currLnb.diseqcMode) == "1_0":
243 currCO = currLnb.commandOrder1_0.value
245 currCO = currLnb.commandOrder.value
247 if currLnb.uncommittedDiseqcCommand.value > 0:
248 sec.setUncommittedCommand(0xF0|(currLnb.uncommittedDiseqcCommand.value-1))
250 sec.setUncommittedCommand(0) # SENDNO
252 if currentConfigSelectionElement(currLnb.diseqcRepeats) == "none":
254 elif currentConfigSelectionElement(currLnb.diseqcRepeats) == "One":
256 elif currentConfigSelectionElement(currLnb.diseqcRepeats) == "Two":
258 elif currentConfigSelectionElement(currLnb.diseqcRepeats) == "Three":
261 setCommandOrder=False
262 if currCO == 0: # committed, toneburst
264 elif currCO == 1: # toneburst, committed
266 elif currCO == 2: # committed, uncommitted, toneburst
268 elif currCO == 3: # toneburst, committed, uncommitted
270 elif currCO == 4: # uncommitted, committed, toneburst
272 elif currCO == 5: # toneburst, uncommitted, commmitted
275 sec.setCommandOrder(currCO)
277 if currentConfigSelectionElement(currLnb.diseqcMode) == "1_2":
278 latitude = configsequencearg.getFloat(currLnb.latitude)
279 sec.setLatitude(latitude)
280 longitude = configsequencearg.getFloat(currLnb.longitude)
281 sec.setLongitude(longitude)
282 if currentConfigSelectionElement(currLnb.latitudeOrientation) == "north":
283 sec.setLaDirection(rotorParam.NORTH)
285 sec.setLaDirection(rotorParam.SOUTH)
286 if currentConfigSelectionElement(currLnb.longitudeOrientation) == "east":
287 sec.setLoDirection(rotorParam.EAST)
289 sec.setLoDirection(rotorParam.WEST)
291 if currentConfigSelectionElement(currLnb.powerMeasurement) == "yes":
292 sec.setUseInputpower(True)
293 sec.setInputpowerDelta(currLnb.powerThreshold.value[0])
295 sec.setUseInputpower(False)
297 sec.setLNBTunerMask(tunermask)
299 # finally add the orbital positions
302 currSat = config.Nims[slotid].advanced.sat[y]
303 if currentConfigSelectionElement(currSat.voltage) == "polarization":
304 sec.setVoltageMode(switchParam.HV)
305 elif currentConfigSelectionElement(currSat.voltage) == "13V":
306 sec.setVoltageMode(switchParam._14V)
307 elif currentConfigSelectionElement(currSat.voltage) == "18V":
308 sec.setVoltageMode(switchParam._18V)
310 if currentConfigSelectionElement(currSat.tonemode) == "band":
311 sec.setToneMode(switchParam.HILO)
312 elif currentConfigSelectionElement(currSat.tonemode) == "on":
313 sec.setToneMode(switchParam.ON)
314 elif currentConfigSelectionElement(currSat.tonemode) == "off":
315 sec.setToneMode(switchParam.OFF)
317 if currentConfigSelectionElement(currSat.usals) == "no":
318 sec.setRotorPosNum(currSat.rotorposition.value[0])
320 sec.setRotorPosNum(0) #USALS
322 def __init__(self, nimmgr):
323 self.NimManager = nimmgr
327 def __init__(self, slotid, nimtype, name):
329 self.nimType = nimtype
333 class parseSats(ContentHandler):
334 def __init__(self, satList, satellites, transponders):
335 self.isPointsElement, self.isReboundsElement = 0, 0
336 self.satList = satList
337 self.satellites = satellites
338 self.transponders = transponders
340 def startElement(self, name, attrs):
342 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
343 tpos = int(attrs.get('position',""))
346 tname = attrs.get('name',"")
347 self.satellites[tpos] = tname
348 self.satList.append( (tname, tpos) )
349 self.parsedSat = int(tpos)
350 elif (name == "transponder"):
351 freq = int(attrs.get('frequency',""))
352 sr = int(attrs.get('symbol_rate',""))
353 pol = int(attrs.get('polarization',""))
354 fec = int(attrs.get('fec_inner',""))
355 if self.parsedSat in self.transponders:
358 self.transponders[self.parsedSat] = [ ]
360 self.transponders[self.parsedSat].append((0, freq, sr, pol, fec))
362 class parseCables(ContentHandler):
363 def __init__(self, cablesList, transponders):
364 self.isPointsElement, self.isReboundsElement = 0, 0
365 self.cablesList = cablesList
366 self.transponders = transponders
368 def startElement(self, name, attrs):
369 if (name == "cable"):
370 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
371 tname = attrs.get('name',"")
372 self.cablesList.append(str(tname))
373 self.parsedCab = str(tname)
374 elif (name == "transponder"):
375 freq = int(attrs.get('frequency',""))
376 sr = int(attrs.get('symbol_rate',""))
377 mod = int(attrs.get('modulation',""))
378 fec = int(attrs.get('fec_inner',""))
379 if self.parsedCab in self.transponders:
382 self.transponders[self.parsedCab] = [ ]
383 self.transponders[self.parsedCab].append((1, freq, sr, mod, fec))
385 class parseTerrestrials(ContentHandler):
386 def __init__(self, terrestrialsList, transponders):
387 self.isPointsElement, self.isReboundsElement = 0, 0
388 self.terrestrialsList = terrestrialsList
389 self.transponders = transponders
391 def startElement(self, name, attrs):
392 if (name == "terrestrial"):
393 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
394 tname = attrs.get('name',"").encode("UTF-8")
395 tflags = attrs.get('flags',"")
396 self.terrestrialsList.append((tname, tflags))
397 self.parsedTer = str(tname)
398 elif (name == "transponder"):
400 freq = int(attrs.get('centre_frequency',""))
401 bw = int(attrs.get('bandwidth',""))
402 const = int(attrs.get('constellation',""))
403 crh = int(attrs.get('code_rate_hp',""))
404 crl = int(attrs.get('code_rate_lp',""))
405 guard = int(attrs.get('guard_interval',""))
406 transm = int(attrs.get('transmission_mode',""))
407 hierarchy = int(attrs.get('hierarchy_information',""))
408 inv = int(attrs.get('inversion',""))
409 if self.parsedTer in self.transponders:
412 self.transponders[self.parsedTer] = [ ]
414 self.transponders[self.parsedTer].append((2, freq, bw, const, crh, crl, guard, transm, hierarchy, inv))
416 def getTransponders(self, pos):
417 if self.transponders.has_key(pos):
418 return self.transponders[pos]
422 def getTranspondersCable(self, cable):
423 return self.transponderscable[cable]
425 def getCableDescription(self, nim):
426 return self.cablesList[config.Nims[nim].cable.value]
428 def getConfiguredSats(self):
429 return self.sec.getSatList()
431 def getSatDescription(self, pos):
432 return self.satellites[pos]
434 def readSatsfromFile(self):
435 self.satellites = { }
436 self.transponders = { }
437 self.transponderscable = { }
438 self.transpondersterrestrial = { }
440 parser = make_parser()
441 if (self.hasNimType(self.nimType["DVB-S"])):
442 print "Reading satellites.xml"
443 satHandler = self.parseSats(self.satList, self.satellites, self.transponders)
444 parser.setContentHandler(satHandler)
445 parser.parse('/etc/tuxbox/satellites.xml')
446 if (self.hasNimType(self.nimType["DVB-C"])):
447 print "Reading cables.xml"
448 cabHandler = self.parseCables(self.cablesList, self.transponderscable)
449 parser.setContentHandler(cabHandler)
450 parser.parse('/etc/tuxbox/cables.xml')
452 if (self.hasNimType(self.nimType["DVB-T"])):
453 print "Reading terrestrial.xml"
454 terHandler = self.parseTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
455 parser.setContentHandler(terHandler)
456 parser.parse('/etc/tuxbox/terrestrial.xml')
461 self.nimSocketCount = 0
462 nimfile = tryOpen("/proc/bus/nim_sockets")
465 return self.nimType["empty/unknown"]
470 line = nimfile.readline()
473 if line.strip().startswith("NIM Socket"):
474 parts = line.strip().split(" ")
475 id = int(parts[2][:1])
477 self.nimSocketCount += 1
478 elif line.strip().startswith("Type:"):
479 self.nimTypes[lastsocket] = str(line.strip()[6:])
480 self.nimTypes[lastsocket] = str("DVB-T")
481 elif line.strip().startswith("Name:"):
482 self.nimNames[lastsocket] = str(line.strip()[6:])
483 elif line.strip().startswith("empty"):
484 self.nimNames[lastsocket] = _("N/A")
485 self.nimTypes[lastsocket] = "empty/unknown"
489 def getNimType(self, slotID):
490 if slotID >= self.nimCount:
491 return self.nimType["empty/unknown"]
493 return self.nimType[self.nimTypes[slotID]]
495 def getNimTypeName(self, slotID):
496 if slotID >= self.nimCount:
497 return "empty/unknown"
499 return self.nimTypes[slotID]
501 def getNimName(self, slotID):
502 return self.nimNames[slotID]
504 def getNimSocketCount(self):
505 return self.nimSocketCount
507 def hasNimType(self, chktype):
508 for id, type in self.nimTypes.items():
509 if (chktype == self.nimType[str(type)]):
513 def getNimListOfType(self, type, exception = -1):
515 for x in self.nimslots:
516 if ((x.nimType == type) and (x.slotid != exception)):
517 list.append(x.slotid)
520 def getConfigPrefix(self, slotid):
521 return "config.Nim" + ("A","B","C","D")[slotid] + "."
525 self.nimType = { "empty/unknown": -1,
531 self.terrestrialsList = []
535 self.readSatsfromFile()
537 self.nimCount = self.getNimSocketCount()
541 while x < self.nimCount:
542 tType = self.getNimType(x)
543 tName = self.getNimName(x)
544 tNim = nimSlot(x, tType, tName)
545 self.nimslots.append(tNim)
548 InitNimManager(self) #init config stuff
552 for slot in self.nimslots:
553 nimText = _("Socket ") + ("A", "B", "C", "D")[slot.slotid] + ": "
554 if slot.nimType == -1:
555 nimText += _("empty/unknown")
557 nimText += slot.name + " ("
558 nimText += ("DVB-S", "DVB-C", "DVB-T")[slot.nimType] + ")"
559 list.append((nimText, slot))
562 def getNimConfigMode(self, slotid):
563 return currentConfigSelectionElement(config.Nims[slotid].configMode)
565 def getSatListForNim(self, slotid):
567 if (self.getNimType(slotid) == self.nimType["DVB-S"]):
568 #print "slotid:", slotid
570 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
571 #print "diseqcA:", config.Nims[slotid].diseqcA.value
572 configMode = currentConfigSelectionElement(config.Nims[slotid].configMode)
573 if configMode == "simple":
574 if (config.Nims[slotid].diseqcMode.value <= 3):
575 list.append(self.satList[config.Nims[slotid].diseqcA.value])
576 if (0 < config.Nims[slotid].diseqcMode.value <= 3):
577 list.append(self.satList[config.Nims[slotid].diseqcB.value])
578 if (config.Nims[slotid].diseqcMode.value == 3):
579 list.append(self.satList[config.Nims[slotid].diseqcC.value])
580 list.append(self.satList[config.Nims[slotid].diseqcD.value])
581 if (config.Nims[slotid].diseqcMode.value == 4):
582 for x in self.satList:
584 elif configMode == "advanced":
585 for x in self.satList:
586 if config.Nims[slotid].advanced.sat[x[1]].lnb.value != 0:
590 def nimDiseqcModeChanged(self, slotid, mode):
591 #print "nimDiseqcModeChanged set to " + str(mode)
593 def nimPortAChanged(self, slotid, val):
594 #print "nimDiseqcA set to " + str(slotid) + " val:" + str(val)
596 def nimPortBChanged(self, slotid, val):
597 #print "nimDiseqcA set to " + str(slotid) + " val:" + str(val)
598 #print "nimDiseqcB set to " + str(val)
600 def nimPortCChanged(self, slotid, val):
601 #print "nimDiseqcC set to " + str(val)
603 def nimPortDChanged(self, slotid, val):
604 #print "nimDiseqcD set to " + str(val)
607 def InitNimManager(nimmgr):
609 for x in range(nimmgr.nimCount):
610 config.Nims.append(ConfigSubsection())
612 # def nimConfigModeChanged(slotid, configElement):
613 # nimmgr.nimConfigModeChanged(slotid, configElement.value)
614 def nimDiseqcModeChanged(slotid, configElement):
615 nimmgr.nimDiseqcModeChanged(slotid, configElement.value)
617 def nimPortAChanged(slotid, configElement):
618 nimmgr.nimPortAChanged(slotid, configElement.vals[configElement.value][1])
619 def nimPortBChanged(slotid, configElement):
620 nimmgr.nimPortBChanged(slotid, configElement.vals[configElement.value][1])
621 def nimPortCChanged(slotid, configElement):
622 nimmgr.nimPortCChanged(slotid, configElement.vals[configElement.value][1])
623 def nimPortDChanged(slotid, configElement):
624 nimmgr.nimPortDChanged(slotid, configElement.vals[configElement.value][1])
626 for slot in nimmgr.nimslots:
628 cname = nimmgr.getConfigPrefix(x)
631 if slot.nimType == nimmgr.nimType["DVB-S"]:
633 nim.configMode = configElement(cname + "configMode", configSelection, 0, (
634 ("simple", _("Simple")), ("advanced", _("Advanced"))), False)
636 nim.configMode = configElement(cname + "configMode", configSelection, 0, (
637 ("equal", _("Equal to Socket A")),
638 ("loopthrough", _("Loopthrough to Socket A")),
639 ("nothing", _("Nothing connected")),
640 ("satposdepends", _("Secondary cable from motorized LNB")),
641 ("simple", _("Simple")),
642 ("advanced", _("Advanced"))), False)
643 #important - check if just the 2nd one is LT only and the first one is DVB-S
644 if currentConfigSelectionElement(nim.configMode) in ["loopthrough", "satposdepends", "equal"]:
645 if x == 0: #first one can never be linked to anything
646 nim.configMode.value = getConfigSelectionElement(nim.configMode, "simple") #reset to simple
647 nim.configMode.save()
649 #FIXME: make it better
650 for y in nimmgr.nimslots:
652 if y.nimType != nimmgr.nimType["DVB-S"]:
653 nim.configMode.value = getConfigSelectionElement(nim.configMode, "simple") #reset to simple
654 nim.configMode.save()
656 nim.diseqcMode = configElement(cname + "diseqcMode", configSelection, 2, (("single", _("Single")), ("toneburst_a_b", _("Toneburst A/B")), ("diseqc_a_b", _("DiSEqC A/B")), ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")), ("positioner", _("Positioner"))), False);
657 nim.diseqcA = configElement(cname + "diseqcA", configSatlist, 192, nimmgr.satList, False);
658 nim.diseqcB = configElement(cname + "diseqcB", configSatlist, 130, nimmgr.satList, False);
659 nim.diseqcC = configElement(cname + "diseqcC", configSatlist, 0, nimmgr.satList, False);
660 nim.diseqcD = configElement(cname + "diseqcD", configSatlist, 0, nimmgr.satList, False);
661 nim.positionerMode = configElement(cname + "positionerMode", configSelection, 0, (("usals", _("USALS")), ("manual", _("manual"))), False);
662 nim.longitude = configElement(cname + "longitude", configSequence, [5,100], configsequencearg.get("FLOAT", [(0,90),(0,999)]), False);
663 nim.longitudeOrientation = configElement(cname + "longitudeOrientation", configSelection, 0, (("east", _("East")), ("west", _("West"))), False)
664 nim.latitude = configElement(cname + "latitude", configSequence, [50,767], configsequencearg.get("FLOAT", [(0,90),(0,999)]), False);
665 nim.latitudeOrientation = configElement(cname + "latitudeOrientation", configSelection, 0, (("north", _("North")), ("south", _("South"))), False)
666 satNimList = nimmgr.getNimListOfType(nimmgr.nimType["DVB-S"], slot.slotid)
669 satNimListNames.append((("Slot_" + ("A", "B", "C", "D")[x] + "_" + nimmgr.getNimName(x)), _("Slot ") + ("A", "B", "C", "D")[x] + ": " + nimmgr.getNimName(x)))
670 nim.equalTo = configElement(cname + "equalTo", configSelection, 0, satNimListNames, False);
671 nim.linkedTo = configElement(cname + "linkedTo", configSelection, 0, satNimListNames, False);
672 nim.satposDependsTo = configElement(cname + "satposDependsTo", configSelection, 0, satNimListNames, False);
674 #perhaps the instance of the slot is more useful?
675 # nim.configMode.addNotifier(boundFunction(nimConfigModeChanged,x))
676 nim.diseqcMode.addNotifier(boundFunction(nimDiseqcModeChanged,x))
677 nim.diseqcA.addNotifier(boundFunction(nimPortAChanged,int(x)))
678 nim.diseqcB.addNotifier(boundFunction(nimPortBChanged,x))
679 nim.diseqcC.addNotifier(boundFunction(nimPortCChanged,x))
680 nim.diseqcD.addNotifier(boundFunction(nimPortDChanged,x))
683 nim.advanced = ConfigSubsection()
684 nim.advanced.sats = configElement(cname + "advanced.sats", configSatlist, 192, nimmgr.satList, False);
685 nim.advanced.sat = {}
686 lnbs = ["not available"]
687 for y in range(1, 33):
688 lnbs.append("LNB " + str(y))
689 for x in nimmgr.satList:
690 nim.advanced.sat[x[1]] = ConfigSubsection()
691 nim.advanced.sat[x[1]].voltage = configElement(cname + "advanced.sat" + str(x[1]) + ".voltage", configSelection, 0, (("polarization", _("Polarization")), ("13V", _("13 V")), ("18V", _("18 V"))), False)
692 nim.advanced.sat[x[1]].tonemode = configElement(cname + "advanced.sat" + str(x[1]) + ".tonemode", configSelection, 0, (("band", _("Band")), ("on", _("On")), ("off", _("Off"))), False)
693 nim.advanced.sat[x[1]].usals = configElement(cname + "advanced.sat" + str(x[1]) + ".usals", configSelection, 0, (("yes", _("Yes")), ("no", _("No"))), False)
694 nim.advanced.sat[x[1]].rotorposition = configElement(cname + "advanced.sat" + str(x[1]) + ".rotorposition", configSequence, [1], configsequencearg.get("INTEGER", (1, 255)), False)
695 nim.advanced.sat[x[1]].lnb = configElement(cname + "advanced.sat" + str(x[1]) + ".lnb", configSelection, 0, lnbs, False)
697 csw = [("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))]
698 for y in range(0, 16):
699 csw.append((str(0xF0|y), "Input " + str(y+1)))
701 ucsw = [("none", _("None"))]
702 for y in range(1, 17):
703 ucsw.append("Input " + str(y))
705 nim.advanced.lnb = [0]
706 for x in range(1, 33):
707 nim.advanced.lnb.append(ConfigSubsection())
708 nim.advanced.lnb[x].lof = configElement(cname + "advanced.lnb" + str(x) + ".lof", configSelection, 0, (("universal_lnb", _("Universal LNB")), ("c_band", _("C-Band")), ("user_defined", _("User defined"))), False)
709 nim.advanced.lnb[x].lofl = configElement(cname + "advanced.lnb" + str(x) + ".lofl", configSequence, [9750], configsequencearg.get("INTEGER", (0, 99999)), False)
710 nim.advanced.lnb[x].lofh = configElement(cname + "advanced.lnb" + str(x) + ".lofh", configSequence, [10600], configsequencearg.get("INTEGER", (0, 99999)), False)
711 nim.advanced.lnb[x].threshold = configElement(cname + "advanced.lnb" + str(x) + ".threshold", configSequence, [11750], configsequencearg.get("INTEGER", (0, 99999)), False)
712 nim.advanced.lnb[x].output_12v = configElement(cname + "advanced.lnb" + str(x) + ".output_12v", configSelection, 0, (("0V", _("0 V")), ("12V", _("12 V"))), False)
713 nim.advanced.lnb[x].increased_voltage = configElement(cname + "advanced.lnb" + str(x) + ".increased_voltage", configSelection, 0, (("no", _("No")), ("yes", _("Yes"))), False)
714 nim.advanced.lnb[x].toneburst = configElement(cname + "advanced.lnb" + str(x) + ".toneburst", configSelection, 0, (("none", _("None")), ("A", _("A")), ("B", _("B"))), False)
715 nim.advanced.lnb[x].diseqcMode = configElement(cname + "advanced.lnb" + str(x) + ".diseqcMode", configSelection, 0, (("none", _("None")), ("1_0", _("1.0")), ("1_1", _("1.1")), ("1_2", _("1.2"))), False)
716 nim.advanced.lnb[x].commitedDiseqcCommand = configElement(cname + "advanced.lnb" + str(x) + ".commitedDiseqcCommand", configSelection, 0, csw, False)
717 nim.advanced.lnb[x].fastDiseqc = configElement(cname + "advanced.lnb" + str(x) + ".fastDiseqc", configSelection, 0, (("no", _("No")), ("yes", _("Yes"))), False)
718 nim.advanced.lnb[x].sequenceRepeat = configElement(cname + "advanced.lnb" + str(x) + ".sequenceRepeat", configSelection, 0, (("no", _("No")), ("yes", _("Yes"))), False)
719 nim.advanced.lnb[x].commandOrder1_0 = configElement(cname + "advanced.lnb" + str(x) + ".commandOrder1_0", configSelection, 0, ("committed, toneburst", "toneburst, committed"), False)
720 nim.advanced.lnb[x].commandOrder = configElement(cname + "advanced.lnb" + str(x) + ".commandOrder", configSelection, 0, ("committed, toneburst", "toneburst, committed", "committed, uncommitted, toneburst", "toneburst, committed, uncommitted", "uncommitted, committed, toneburst", "toneburst, uncommitted, commmitted"), False)
721 nim.advanced.lnb[x].uncommittedDiseqcCommand = configElement(cname + "advanced.lnb" + str(x) + ".uncommittedDiseqcCommand", configSelection, 0, ucsw, False)
722 nim.advanced.lnb[x].diseqcRepeats = configElement(cname + "advanced.lnb" + str(x) + ".diseqcRepeats", configSelection, 0, (("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))), False)
723 nim.advanced.lnb[x].longitude = configElement(cname + "advanced.lnb" + str(x) + ".longitude", configSequence, [5,100], configsequencearg.get("FLOAT", [(0,90),(0,999)]), False)
724 nim.advanced.lnb[x].longitudeOrientation = configElement(cname + "advanced.lnb" + str(x) + ".longitudeOrientation", configSelection, 0, (("east", _("East")), ("west", _("West"))), False)
725 nim.advanced.lnb[x].latitude = configElement(cname + "advanced.lnb" + str(x) + ".latitude", configSequence, [50,767], configsequencearg.get("FLOAT", [(0,90),(0,999)]), False)
726 nim.advanced.lnb[x].latitudeOrientation = configElement(cname + "advanced.lnb" + str(x) + ".latitudeOrientation", configSelection, 0, (("north", _("North")), ("south", _("South"))), False)
727 nim.advanced.lnb[x].powerMeasurement = configElement(cname + "advanced.lnb" + str(x) + ".powerMeasurement", configSelection, 0, (("yes", _("Yes")), ("no", _("No"))), False)
728 nim.advanced.lnb[x].powerThreshold = configElement(cname + "advanced.lnb" + str(x) + ".powerThreshold", configSequence, [50], configsequencearg.get("INTEGER", (0, 100)), False)
729 elif slot.nimType == nimmgr.nimType["DVB-C"]:
730 nim.cable = configElement(cname + "cable", configSelection, 0, nimmgr.cablesList, False);
731 elif slot.nimType == nimmgr.nimType["DVB-T"]:
733 for x in nimmgr.terrestrialsList:
735 nim.terrestrial = configElement(cname + "terrestrial", configSelection, 0, list, False);
737 print "pls add support for this frontend type!"
739 nimmgr.sec = SecConfigure(nimmgr)
741 nimmanager = NimManager()