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 currentConfigSelectionElement
8 from config import getConfigSelectionElement
9 from config import configSequence
10 from config import configsequencearg
11 from config import configSatlist
13 from enigma import eDVBSatelliteEquipmentControl, \
14 eDVBSatelliteLNBParameters as lnbParam, \
15 eDVBSatelliteDiseqcParameters as diseqcParam, \
16 eDVBSatelliteSwitchParameters as switchParam, \
17 eDVBSatelliteRotorParameters as rotorParam
19 import xml.dom.minidom
20 from xml.dom import EMPTY_NAMESPACE
21 from skin import elementsWithTag
22 from Tools import XMLTools
24 from xml.sax import make_parser
25 from xml.sax.handler import ContentHandler
27 from Tools.BoundFunction import boundFunction
29 def tryOpen(filename):
31 procFile = open(filename)
37 def addLNBSimple(self, sec, slotid, diseqcmode, toneburstmode = 0, diseqcpos = 0, orbpos = 0, longitude = 0, latitude = 0, loDirection = 0, laDirection = 0):
40 tunermask = 1 << slotid
41 if self.linked.has_key(slotid):
42 tunermask |= (1 << self.linked[slotid])
43 sec.setLNBTunerMask(tunermask)
44 sec.setLNBLOFL(9750000)
45 sec.setLNBLOFH(10600000)
46 sec.setLNBThreshold(11750000)
50 sec.setVoltageMode(switchParam.HV)
51 sec.setToneMode(switchParam.HILO)
52 sec.setCommandOrder(0)
54 sec.setDiSEqCMode(diseqcmode)
55 sec.setToneburst(toneburstmode)
56 sec.setCommittedCommand(diseqcpos)
57 #print "set orbpos to:" + str(orbpos)
59 if (0 <= diseqcmode < 3):
60 sec.addSatellite(orbpos)
61 self.satList.append(orbpos)
62 elif (diseqcmode == 3): # diseqc 1.2
63 sec.setLatitude(latitude)
64 sec.setLaDirection(laDirection)
65 sec.setLongitude(longitude)
66 sec.setLoDirection(loDirection)
67 sec.setUseInputpower(True)
68 sec.setInputpowerDelta(50)
70 for x in self.NimManager.satList:
71 print "Add sat " + str(x[1])
72 sec.addSatellite(int(x[1]))
75 self.satList.append(int(x[1]))
77 def linkNIMs(self, sec, nim1, nim2):
78 print "link tuner", nim1, "to tuner", nim2
79 sec.setTunerLinked(nim1, nim2)
85 sec = eDVBSatelliteEquipmentControl.getInstance()
86 sec.clear() ## this do unlinking NIMs too !!
87 print "sec config cleared"
91 for slot in self.NimManager.nimslots:
94 if slot.nimType == self.NimManager.nimType["DVB-S"]:
95 if currentConfigSelectionElement(nim.configMode) == "loopthrough":
96 self.linkNIMs(sec, x, nim.linkedTo.value)
97 self.linked[nim.linkedTo.value]=x
99 for slot in self.NimManager.nimslots:
102 if slot.nimType == self.NimManager.nimType["DVB-S"]:
103 print "slot: " + str(x) + " configmode: " + str(nim.configMode.value)
104 if currentConfigSelectionElement(nim.configMode) == "loopthrough":
106 elif currentConfigSelectionElement(nim.configMode) == "simple": #simple config
107 if currentConfigSelectionElement(nim.diseqcMode) == "single": #single
108 self.addLNBSimple(sec, slotid = x, orbpos = int(nim.diseqcA.vals[nim.diseqcA.value][1]), toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.NONE, diseqcpos = diseqcParam.SENDNO)
109 elif currentConfigSelectionElement(nim.diseqcMode) == "toneburst_a_b": #Toneburst A/B
110 self.addLNBSimple(sec, slotid = x, orbpos = int(nim.diseqcA.vals[nim.diseqcA.value][1]), toneburstmode = diseqcParam.A, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO)
111 self.addLNBSimple(sec, slotid = x, orbpos = int(nim.diseqcB.vals[nim.diseqcB.value][1]), toneburstmode = diseqcParam.B, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO)
112 elif currentConfigSelectionElement(nim.diseqcMode) == "diseqc_a_b": #DiSEqC A/B
113 self.addLNBSimple(sec, slotid = x, orbpos = int(nim.diseqcA.vals[nim.diseqcA.value][1]), toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA)
114 self.addLNBSimple(sec, slotid = x, orbpos = int(nim.diseqcB.vals[nim.diseqcB.value][1]), toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB)
115 elif currentConfigSelectionElement(nim.diseqcMode) == "diseqc_a_b_c_d": #DiSEqC A/B/C/D
116 self.addLNBSimple(sec, slotid = x, orbpos = int(nim.diseqcA.vals[nim.diseqcA.value][1]), toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA)
117 self.addLNBSimple(sec, slotid = x, orbpos = int(nim.diseqcB.vals[nim.diseqcB.value][1]), toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB)
118 self.addLNBSimple(sec, slotid = x, orbpos = int(nim.diseqcC.vals[nim.diseqcC.value][1]), toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BA)
119 self.addLNBSimple(sec, slotid = x, orbpos = int(nim.diseqcD.vals[nim.diseqcD.value][1]), toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BB)
120 elif currentConfigSelectionElement(nim.diseqcMode) == "positioner": #Positioner
121 if currentConfigSelectionElement(nim.latitudeOrientation) == "north":
122 laValue = rotorParam.NORTH
124 laValue = rotorParam.SOUTH
125 if currentConfigSelectionElement(nim.longitudeOrientation) == "east":
126 loValue = rotorParam.EAST
128 loValue = rotorParam.WEST
129 self.addLNBSimple(sec, slotid = x, diseqcmode = 3,
130 longitude = configsequencearg.getFloat(nim.longitude),
131 loDirection = loValue,
132 latitude = configsequencearg.getFloat(nim.latitude),
133 laDirection = laValue)
135 elif currentConfigSelectionElement(nim.configMode) == "nothing":
137 elif currentConfigSelectionElement(nim.configMode) == "advanced": #advanced config
138 self.updateAdvanced(sec, x)
139 print "sec config completed"
141 def updateAdvanced(self, sec, slotid):
143 for x in range(1,33):
145 for x in self.NimManager.satList:
146 lnb = config.Nims[slotid].advanced.sat[x[1]].lnb.value
148 print "add", x[1], "to", lnb
149 lnbSat[lnb].append(x[1])
150 for x in range(1,33):
151 if len(lnbSat[x]) > 0:
152 currLnb = config.Nims[slotid].advanced.lnb[x]
155 tunermask = 1 << slotid
156 if self.linked.has_key(slotid):
157 tunermask |= (1 << self.linked[slotid])
158 sec.setLNBTunerMask(tunermask)
160 if currentConfigSelectionElement(currLnb.lof) == "universal_lnb":
161 sec.setLNBLOFL(9750000)
162 sec.setLNBLOFH(10600000)
163 sec.setLNBThreshold(11750000)
164 elif currentConfigSelectionElement(currLnb.lof) == "c_band":
165 sec.setLNBLOFL(5150000)
166 sec.setLNBLOFH(5150000)
167 sec.setLNBThreshold(5150000)
168 elif currentConfigSelectionElement(currLnb.lof) == "user_defined":
169 sec.setLNBLOFL(currLnb.lofl.value[0] * 1000)
170 sec.setLNBLOFH(currLnb.lofh.value[0] * 1000)
171 sec.setLNBThreshold(currLnb.threshold.value[0] * 1000)
173 if currentConfigSelectionElement(currLnb.output_12v) == "0V":
174 pass # nyi in drivers
175 elif currentConfigSelectionElement(currLnb.output_12v) == "12V":
176 pass # nyi in drivers
178 if currentConfigSelectionElement(currLnb.increased_voltage) == "yes":
179 sec.setLNBIncreasedVoltage(lnbParam.ON)
181 sec.setLNBIncreasedVoltage(lnbParam.OFF)
183 if currentConfigSelectionElement(currLnb.diseqcMode) == "none":
184 sec.setDiSEqCMode(diseqcParam.NONE)
185 elif currentConfigSelectionElement(currLnb.diseqcMode) == "1_0":
186 sec.setDiSEqCMode(diseqcParam.V1_0)
187 elif currentConfigSelectionElement(currLnb.diseqcMode) == "1_1":
188 sec.setDiSEqCMode(diseqcParam.V1_1)
189 elif currentConfigSelectionElement(currLnb.diseqcMode) == "1_2":
190 sec.setDiSEqCMode(diseqcParam.V1_2)
192 if currentConfigSelectionElement(currLnb.diseqcMode) != "none":
193 if currentConfigSelectionElement(currLnb.toneburst) == "none":
194 sec.setToneburst(diseqcParam.NO)
195 elif currentConfigSelectionElement(currLnb.toneburst) == "A":
196 sec.setToneburst(diseqcParam.A)
197 elif currentConfigSelectionElement(currLnb.toneburst) == "B":
198 sec.setToneburst(diseqcParam.B)
200 if currentConfigSelectionElement(currLnb.commitedDiseqcCommand) == "none":
201 sec.setCommittedCommand(diseqcParam.SENDNO)
202 elif currentConfigSelectionElement(currLnb.commitedDiseqcCommand) == "AA":
203 sec.setCommittedCommand(diseqcParam.AA)
204 elif currentConfigSelectionElement(currLnb.commitedDiseqcCommand) == "AB":
205 sec.setCommittedCommand(diseqcParam.AB)
206 elif currentConfigSelectionElement(currLnb.commitedDiseqcCommand) == "BA":
207 sec.setCommittedCommand(diseqcParam.BA)
208 elif currentConfigSelectionElement(currLnb.commitedDiseqcCommand) == "BB":
209 sec.setCommittedCommand(diseqcParam.BB)
211 if currentConfigSelectionElement(currLnb.fastDiseqc) == "yes":
212 sec.setFastDiSEqC(True)
214 sec.setFastDiSEqC(False)
216 if currentConfigSelectionElement(currLnb.sequenceRepeat) == "yes":
217 sec.setSeqRepeat(True)
219 sec.setSeqRepeat(False)
221 if currentConfigSelectionElement(currLnb.diseqcMode) == "1_0":
222 currCO = currLnb.commandOrder1_0.value
224 currCO = currLnb.commandOrder.value
226 if currLnb.uncommittedDiseqcCommand.value > 0:
227 sec.setUncommittedCommand(0xF0|(currLnb.uncommittedDiseqcCommand.value-1))
229 sec.setUncommittedCommand(0) # SENDNO
231 if currentConfigSelectionElement(currLnb.diseqcRepeats) == "none":
233 elif currentConfigSelectionElement(currLnb.diseqcRepeats) == "One":
235 elif currentConfigSelectionElement(currLnb.diseqcRepeats) == "Two":
237 elif currentConfigSelectionElement(currLnb.diseqcRepeats) == "Three":
240 setCommandOrder=False
241 if currCO == 0: # committed, toneburst
243 elif currCO == 1: # toneburst, committed
245 elif currCO == 2: # committed, uncommitted, toneburst
247 elif currCO == 3: # toneburst, committed, uncommitted
249 elif currCO == 4: # uncommitted, committed, toneburst
251 elif currCO == 5: # toneburst, uncommitted, commmitted
254 sec.setCommandOrder(currCO)
256 if currentConfigSelectionElement(currLnb.diseqcMode) == "1_2":
257 latitude = configsequencearg.getFloat(currLnb.latitude)
258 sec.setLatitude(latitude)
259 longitude = configsequencearg.getFloat(currLnb.longitude)
260 sec.setLongitude(longitude)
261 if currentConfigSelectionElement(currLnb.latitudeOrientation) == "north":
262 sec.setLaDirection(rotorParam.NORTH)
264 sec.setLaDirection(rotorParam.SOUTH)
265 if currentConfigSelectionElement(currLnb.longitudeOrientation) == "east":
266 sec.setLoDirection(rotorParam.EAST)
268 sec.setLoDirection(rotorParam.WEST)
270 if currentConfigSelectionElement(currLnb.powerMeasurement) == "yes":
271 sec.setUseInputpower(True)
272 sec.setInputpowerDelta(currLnb.powerThreshold.value[0])
274 sec.setUseInputpower(False)
276 # finally add the orbital positions
279 currSat = config.Nims[slotid].advanced.sat[y]
280 if currentConfigSelectionElement(currSat.voltage) == "polarization":
281 sec.setVoltageMode(switchParam.HV)
282 elif currentConfigSelectionElement(currSat.voltage) == "13V":
283 sec.setVoltageMode(switchParam._14V)
284 elif currentConfigSelectionElement(currSat.voltage) == "18V":
285 sec.setVoltageMode(switchParam._18V)
287 if currentConfigSelectionElement(currSat.tonemode) == "band":
288 sec.setToneMode(switchParam.HILO)
289 elif currentConfigSelectionElement(currSat.tonemode) == "on":
290 sec.setToneMode(switchParam.ON)
291 elif currentConfigSelectionElement(currSat.tonemode) == "off":
292 sec.setToneMode(switchParam.OFF)
294 if currentConfigSelectionElement(currSat.usals) == "no":
295 sec.setRotorPosNum(currSat.rotorposition.value[0])
297 sec.setRotorPosNum(0) #USALS
299 def __init__(self, nimmgr):
300 self.NimManager = nimmgr
304 def __init__(self, slotid, nimtype, name):
306 self.nimType = nimtype
310 class parseSats(ContentHandler):
311 def __init__(self, satList, satellites, transponders):
312 self.isPointsElement, self.isReboundsElement = 0, 0
313 self.satList = satList
314 self.satellites = satellites
315 self.transponders = transponders
317 def startElement(self, name, attrs):
319 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
320 tpos = int(attrs.get('position',""))
323 tname = attrs.get('name',"")
324 self.satellites[tpos] = tname
325 self.satList.append( (tname, tpos) )
326 self.parsedSat = int(tpos)
327 elif (name == "transponder"):
328 freq = int(attrs.get('frequency',""))
329 sr = int(attrs.get('symbol_rate',""))
330 pol = int(attrs.get('polarization',""))
331 fec = int(attrs.get('fec_inner',""))
332 if self.parsedSat in self.transponders:
335 self.transponders[self.parsedSat] = [ ]
337 self.transponders[self.parsedSat].append((0, freq, sr, pol, fec))
339 class parseCables(ContentHandler):
340 def __init__(self, cablesList, transponders):
341 self.isPointsElement, self.isReboundsElement = 0, 0
342 self.cablesList = cablesList
343 self.transponders = transponders
345 def startElement(self, name, attrs):
346 if (name == "cable"):
347 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
348 tname = attrs.get('name',"")
349 self.cablesList.append(str(tname))
350 self.parsedCab = str(tname)
351 elif (name == "transponder"):
352 freq = int(attrs.get('frequency',""))
353 sr = int(attrs.get('symbol_rate',""))
354 mod = int(attrs.get('modulation',""))
355 fec = int(attrs.get('fec_inner',""))
356 if self.parsedCab in self.transponders:
359 self.transponders[self.parsedCab] = [ ]
361 self.transponders[self.parsedCab].append((1, freq, sr, mod, fec))
363 class parseTerrestrials(ContentHandler):
364 def __init__(self, terrestrialsList, transponders):
365 self.isPointsElement, self.isReboundsElement = 0, 0
366 self.terrestrialsList = terrestrialsList
367 self.transponders = transponders
369 def startElement(self, name, attrs):
370 if (name == "terrestrial"):
371 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
372 tname = attrs.get('name',"")
373 tflags = attrs.get('flags',"")
374 self.terrestrialsList.append((tname, tflags))
375 self.parsedTer = str(tname)
376 elif (name == "transponder"):
378 freq = int(attrs.get('centre_frequency',""))
379 bw = int(attrs.get('bandwidth',""))
380 const = int(attrs.get('constellation',""))
381 crh = int(attrs.get('code_rate_hp',""))
382 crl = int(attrs.get('code_rate_lp',""))
383 guard = int(attrs.get('guard_interval',""))
384 transm = int(attrs.get('transmission_mode',""))
385 hierarchy = int(attrs.get('hierarchy_information',""))
386 inv = int(attrs.get('inversion',""))
387 if self.parsedTer in self.transponders:
390 self.transponders[self.parsedTer] = [ ]
392 self.transponders[self.parsedTer].append((2, freq, bw, const, crh, crl, guard, transm, hierarchy, inv))
394 def getTransponders(self, pos):
395 return self.transponders[pos]
397 def getConfiguredSats(self):
398 return self.sec.getSatList()
400 def getSatDescription(self, pos):
401 return self.satellites[pos]
403 def readSatsfromFile(self):
404 self.satellites = { }
405 self.transponders = { }
406 self.transponderscable = { }
407 self.transpondersterrestrial = { }
409 parser = make_parser()
410 if (self.hasNimType(self.nimType["DVB-S"])):
411 print "Reading satellites.xml"
412 satHandler = self.parseSats(self.satList, self.satellites, self.transponders)
413 parser.setContentHandler(satHandler)
414 parser.parse('/etc/tuxbox/satellites.xml')
415 if (self.hasNimType(self.nimType["DVB-C"])):
416 print "Reading cables.xml"
417 cabHandler = self.parseCables(self.cablesList, self.transponderscable)
418 parser.setContentHandler(cabHandler)
419 parser.parse('/etc/tuxbox/cables.xml')
421 if (self.hasNimType(self.nimType["DVB-T"])):
422 print "Reading terrestrial.xml"
423 terHandler = self.parseTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
424 parser.setContentHandler(terHandler)
425 parser.parse('/etc/tuxbox/terrestrial.xml')
430 self.nimSocketCount = 0
431 nimfile = tryOpen("/proc/bus/nim_sockets")
434 return self.nimType["empty/unknown"]
439 line = nimfile.readline()
442 if line.strip().startswith("NIM Socket"):
443 parts = line.strip().split(" ")
444 id = int(parts[2][:1])
446 self.nimSocketCount += 1
447 elif line.strip().startswith("Type:"):
448 self.nimTypes[lastsocket] = str(line.strip()[6:])
449 elif line.strip().startswith("Name:"):
450 self.nimNames[lastsocket] = str(line.strip()[6:])
451 elif line.strip().startswith("empty"):
452 self.nimNames[lastsocket] = _("N/A")
453 self.nimTypes[lastsocket] = "empty/unknown"
457 def getNimType(self, slotID):
458 if slotID >= self.nimCount:
459 return "empty/unknown"
461 return self.nimType[self.nimTypes[slotID]]
463 def getNimName(self, slotID):
464 return self.nimNames[slotID]
466 def getNimSocketCount(self):
467 return self.nimSocketCount
469 def hasNimType(self, chktype):
470 for id, type in self.nimTypes.items():
471 if (chktype == self.nimType[str(type)]):
475 def getNimListOfType(self, type, exception = -1):
477 for x in self.nimslots:
478 if ((x.nimType == type) and (x.slotid != exception)):
479 list.append(x.slotid)
482 def getConfigPrefix(self, slotid):
483 return "config.Nim" + ("A","B","C","D")[slotid] + "."
487 self.nimType = { "empty/unknown": -1,
493 self.terrestrialsList = []
497 self.readSatsfromFile()
499 self.nimCount = self.getNimSocketCount()
503 while x < self.nimCount:
504 tType = self.getNimType(x)
505 tName = self.getNimName(x)
506 tNim = nimSlot(x, tType, tName)
507 self.nimslots.append(tNim)
510 InitNimManager(self) #init config stuff
514 for slot in self.nimslots:
515 nimText = _("Socket ") + ("A", "B", "C", "D")[slot.slotid] + ": "
516 if slot.nimType == -1:
517 nimText += _("empty/unknown")
519 nimText += slot.name + " ("
520 nimText += ("DVB-S", "DVB-C", "DVB-T")[slot.nimType] + ")"
521 list.append((nimText, slot))
524 def getSatListForNim(self, slotid):
526 if (self.getNimType(slotid) == self.nimType["DVB-S"]):
527 #print "slotid:", slotid
529 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
530 #print "diseqcA:", config.Nims[slotid].diseqcA.value
531 configMode = currentConfigSelectionElement(config.Nims[slotid].configMode)
532 if configMode == "simple":
533 if (config.Nims[slotid].diseqcMode.value <= 3):
534 list.append(self.satList[config.Nims[slotid].diseqcA.value])
535 if (0 < config.Nims[slotid].diseqcMode.value <= 3):
536 list.append(self.satList[config.Nims[slotid].diseqcB.value])
537 if (config.Nims[slotid].diseqcMode.value == 3):
538 list.append(self.satList[config.Nims[slotid].diseqcC.value])
539 list.append(self.satList[config.Nims[slotid].diseqcD.value])
540 if (config.Nims[slotid].diseqcMode.value == 4):
541 for x in self.satList:
543 elif configMode == "advanced":
544 for x in self.satList:
545 if config.Nims[slotid].advanced.sat[x[1]].lnb.value != 0:
549 # #callbacks for c++ config
550 # def nimConfigModeChanged(self, slotid, mode):
551 # if (mode != 2): # not linked
552 # print "Unlinking slot " + str(slotid)
553 # # TODO call c++ to unlink nim in slot slotid
554 # if (mode == 2): # linked
557 # #if (len(self.getNimListOfType(self.nimType["DVB-S"], slotid)) > 0):
558 # # print "Linking slot " + str(slotid) + " to " + str(nimmgr.getConfigPrefix(slotid).value)
559 # # TODO call c++ to link nim in slot slotid with nim in slot nimmgr.getConfigPrefix(slotid).value
561 # def nimLinkedToChanged(self, slotid, val):
562 # print "Linking slot " + str(slotid) + " to " + str(val)
564 def nimDiseqcModeChanged(self, slotid, mode):
565 #print "nimDiseqcModeChanged set to " + str(mode)
567 def nimPortAChanged(self, slotid, val):
568 #print "nimDiseqcA set to " + str(slotid) + " val:" + str(val)
570 def nimPortBChanged(self, slotid, val):
571 #print "nimDiseqcA set to " + str(slotid) + " val:" + str(val)
572 #print "nimDiseqcB set to " + str(val)
574 def nimPortCChanged(self, slotid, val):
575 #print "nimDiseqcC set to " + str(val)
577 def nimPortDChanged(self, slotid, val):
578 #print "nimDiseqcD set to " + str(val)
581 def InitNimManager(nimmgr):
583 for x in range(nimmgr.nimCount):
584 config.Nims.append(ConfigSubsection())
586 # def nimConfigModeChanged(slotid, configElement):
587 # nimmgr.nimConfigModeChanged(slotid, configElement.value)
588 # def nimLinkedToChanged(slotid, configElement):
589 # nimmgr.nimLinkedToChanged(slotid, configElement.value)
590 def nimDiseqcModeChanged(slotid, configElement):
591 nimmgr.nimDiseqcModeChanged(slotid, configElement.value)
593 def nimPortAChanged(slotid, configElement):
594 nimmgr.nimPortAChanged(slotid, configElement.vals[configElement.value][1])
595 def nimPortBChanged(slotid, configElement):
596 nimmgr.nimPortBChanged(slotid, configElement.vals[configElement.value][1])
597 def nimPortCChanged(slotid, configElement):
598 nimmgr.nimPortCChanged(slotid, configElement.vals[configElement.value][1])
599 def nimPortDChanged(slotid, configElement):
600 nimmgr.nimPortDChanged(slotid, configElement.vals[configElement.value][1])
602 for slot in nimmgr.nimslots:
604 cname = nimmgr.getConfigPrefix(x)
607 if slot.nimType == nimmgr.nimType["DVB-S"]:
609 nim.configMode = configElement(cname + "configMode", configSelection, 0, (("simple", _("Simple")), ("advanced", _("Advanced"))))
611 nim.configMode = configElement(cname + "configMode", configSelection, 0, (("simple", _("Simple")), ("nothing", _("Nothing connected")), ("loopthrough", _("Loopthrough to Socket A")), ("advanced", _("Advanced"))))
613 #important - check if just the 2nd one is LT only and the first one is DVB-S
614 if currentConfigSelectionElement(nim.configMode) == "loopthrough": #linked
615 if x == 0: #first one can never be linked to anything
616 nim.configMode.value = getConfigSelectionElement(nim.configMode, "simple") #reset to simple
617 nim.configMode.save()
619 #FIXME: make it better
620 for y in nimmgr.nimslots:
622 if y.nimType != nimmgr.nimType["DVB-S"]:
623 nim.configMode.value = getConfigSelectionElement(nim.configMode, "simple") #reset to simple
624 nim.configMode.save()
626 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"))));
627 nim.diseqcA = configElement(cname + "diseqcA", configSatlist, 192, nimmgr.satList);
628 nim.diseqcB = configElement(cname + "diseqcB", configSatlist, 130, nimmgr.satList);
629 nim.diseqcC = configElement(cname + "diseqcC", configSatlist, 0, nimmgr.satList);
630 nim.diseqcD = configElement(cname + "diseqcD", configSatlist, 0, nimmgr.satList);
631 nim.positionerMode = configElement(cname + "positionerMode", configSelection, 0, (("usals", _("USALS")), ("manual", _("manual"))));
632 nim.longitude = configElement(cname + "longitude", configSequence, [5,100], configsequencearg.get("FLOAT", [(0,90),(0,999)]));
633 nim.longitudeOrientation = configElement(cname + "longitudeOrientation", configSelection, 0, (("east", _("East")), ("west", _("West"))))
634 nim.latitude = configElement(cname + "latitude", configSequence, [50,767], configsequencearg.get("FLOAT", [(0,90),(0,999)]));
635 nim.latitudeOrientation = configElement(cname + "latitudeOrientation", configSelection, 0, (("north", _("North")), ("south", _("South"))))
636 satNimList = nimmgr.getNimListOfType(nimmgr.nimType["DVB-S"], slot.slotid)
639 satNimListNames.append((("Slot_" + ("A", "B", "C", "D")[x] + "_" + nimmgr.getNimName(x)), _("Slot ") + ("A", "B", "C", "D")[x] + ": " + nimmgr.getNimName(x)))
640 nim.linkedTo = configElement(cname + "linkedTo", configSelection, 0, satNimListNames);
642 #perhaps the instance of the slot is more useful?
643 # nim.configMode.addNotifier(boundFunction(nimConfigModeChanged,x))
644 nim.diseqcMode.addNotifier(boundFunction(nimDiseqcModeChanged,x))
645 nim.diseqcA.addNotifier(boundFunction(nimPortAChanged,int(x)))
646 nim.diseqcB.addNotifier(boundFunction(nimPortBChanged,x))
647 nim.diseqcC.addNotifier(boundFunction(nimPortCChanged,x))
648 nim.diseqcD.addNotifier(boundFunction(nimPortDChanged,x))
649 # nim.linkedTo.addNotifier(boundFunction(nimLinkedToChanged,x))
652 nim.advanced = ConfigSubsection()
653 nim.advanced.sats = configElement(cname + "advanced.sats", configSatlist, 192, nimmgr.satList, False);
654 nim.advanced.sat = {}
655 lnbs = ["not available"]
656 for y in range(1, 33):
657 lnbs.append("LNB " + str(y))
658 for x in nimmgr.satList:
659 nim.advanced.sat[x[1]] = ConfigSubsection()
660 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)
661 nim.advanced.sat[x[1]].tonemode = configElement(cname + "advanced.sat" + str(x[1]) + ".tonemode", configSelection, 0, (("band", _("Band")), ("on", _("On")), ("off", _("Off"))), False)
662 nim.advanced.sat[x[1]].usals = configElement(cname + "advanced.sat" + str(x[1]) + ".usals", configSelection, 0, (("yes", _("Yes")), ("no", _("No"))), False)
663 nim.advanced.sat[x[1]].rotorposition = configElement(cname + "advanced.sat" + str(x[1]) + ".rotorposition", configSequence, [1], configsequencearg.get("INTEGER", (1, 255)), False)
664 nim.advanced.sat[x[1]].lnb = configElement(cname + "advanced.sat" + str(x[1]) + ".lnb", configSelection, 0, lnbs, False)
666 nim.advanced.lnb = [0]
667 for x in range(1, 33):
668 nim.advanced.lnb.append(ConfigSubsection())
669 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)
670 nim.advanced.lnb[x].lofl = configElement(cname + "advanced.lnb" + str(x) + ".lofl", configSequence, [9750], configsequencearg.get("INTEGER", (0, 99999)), False)
671 nim.advanced.lnb[x].lofh = configElement(cname + "advanced.lnb" + str(x) + ".lofh", configSequence, [10600], configsequencearg.get("INTEGER", (0, 99999)), False)
672 nim.advanced.lnb[x].threshold = configElement(cname + "advanced.lnb" + str(x) + ".threshold", configSequence, [11750], configsequencearg.get("INTEGER", (0, 99999)), False)
673 nim.advanced.lnb[x].output_12v = configElement(cname + "advanced.lnb" + str(x) + ".output_12v", configSelection, 0, (("0V", _("0 V")), ("12V", _("12 V"))), False)
674 nim.advanced.lnb[x].increased_voltage = configElement(cname + "advanced.lnb" + str(x) + ".increased_voltage", configSelection, 0, (("no", _("No")), ("yes", _("Yes"))), False)
675 nim.advanced.lnb[x].toneburst = configElement(cname + "advanced.lnb" + str(x) + ".toneburst", configSelection, 0, (("none", _("None")), ("A", _("A")), ("B", _("B"))), False)
676 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)
677 nim.advanced.lnb[x].commitedDiseqcCommand = configElement(cname + "advanced.lnb" + str(x) + ".commitedDiseqcCommand", configSelection, 0, (("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))), False)
678 nim.advanced.lnb[x].fastDiseqc = configElement(cname + "advanced.lnb" + str(x) + ".fastDiseqc", configSelection, 0, (("no", _("No")), ("yes", _("Yes"))), False)
679 nim.advanced.lnb[x].sequenceRepeat = configElement(cname + "advanced.lnb" + str(x) + ".sequenceRepeat", configSelection, 0, (("no", _("No")), ("yes", _("Yes"))), False)
680 nim.advanced.lnb[x].commandOrder1_0 = configElement(cname + "advanced.lnb" + str(x) + ".commandOrder1_0", configSelection, 0, ("committed, toneburst", "toneburst, committed"), False)
681 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)
683 for y in range(1, 17):
684 disCmd.append("Input " + str(y))
685 nim.advanced.lnb[x].uncommittedDiseqcCommand = configElement(cname + "advanced.lnb" + str(x) + ".uncommittedDiseqcCommand", configSelection, 0, disCmd, False)
686 nim.advanced.lnb[x].diseqcRepeats = configElement(cname + "advanced.lnb" + str(x) + ".diseqcRepeats", configSelection, 0, (("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))), False)
687 nim.advanced.lnb[x].longitude = configElement(cname + "advanced.lnb" + str(x) + ".longitude", configSequence, [5,100], configsequencearg.get("FLOAT", [(0,90),(0,999)]), False)
688 nim.advanced.lnb[x].longitudeOrientation = configElement(cname + "advanced.lnb" + str(x) + ".longitudeOrientation", configSelection, 0, (("east", _("East")), ("west", _("West"))), False)
689 nim.advanced.lnb[x].latitude = configElement(cname + "advanced.lnb" + str(x) + ".latitude", configSequence, [50,767], configsequencearg.get("FLOAT", [(0,90),(0,999)]), False)
690 nim.advanced.lnb[x].latitudeOrientation = configElement(cname + "advanced.lnb" + str(x) + ".latitudeOrientation", configSelection, 0, (("north", _("North")), ("south", _("South"))), False)
691 nim.advanced.lnb[x].powerMeasurement = configElement(cname + "advanced.lnb" + str(x) + ".powerMeasurement", configSelection, 0, (("yes", _("Yes")), ("no", _("No"))), False)
692 nim.advanced.lnb[x].powerThreshold = configElement(cname + "advanced.lnb" + str(x) + ".powerThreshold", configSequence, [50], configsequencearg.get("INTEGER", (0, 100)), False)
693 elif slot.nimType == nimmgr.nimType["DVB-C"]:
694 nim.cable = configElement(cname + "cable", configSelection, 0, nimmgr.cablesList);
695 elif slot.nimType == nimmgr.nimType["DVB-T"]:
696 nim.cable = configElement(cname + "terrestrial", configSelection, 0, nimmgr.terrestrialsList);
698 print "pls add support for this frontend type!"
700 nimmgr.sec = SecConfigure(nimmgr)
702 nimmanager = NimManager()