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(11700000)
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(11700000)
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',"").encode("UTF-8")
347 self.satellites[tpos] = tname
348 self.satList.append( (tname, tpos) )
349 self.parsedSat = int(tpos)
350 elif (name == "transponder"):
351 modulation = int(attrs.get('modulation',"1")) # QPSK default
352 system = int(attrs.get('system',"0")) # DVB-S default
353 freq = int(attrs.get('frequency',""))
354 sr = int(attrs.get('symbol_rate',""))
355 pol = int(attrs.get('polarization',""))
356 fec = int(attrs.get('fec_inner',"0")) # AUTO default
357 if self.parsedSat in self.transponders:
360 self.transponders[self.parsedSat] = [ ]
362 self.transponders[self.parsedSat].append((0, freq, sr, pol, fec, system, modulation))
364 class parseCables(ContentHandler):
365 def __init__(self, cablesList, transponders):
366 self.isPointsElement, self.isReboundsElement = 0, 0
367 self.cablesList = cablesList
368 self.transponders = transponders
370 def startElement(self, name, attrs):
371 if (name == "cable"):
372 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
373 tname = attrs.get('name',"").encode("UTF-8")
374 self.cablesList.append(str(tname))
375 self.parsedCab = str(tname)
376 elif (name == "transponder"):
377 freq = int(attrs.get('frequency',""))
378 sr = int(attrs.get('symbol_rate',""))
379 mod = int(attrs.get('modulation',"3")) # QAM64 default
380 fec = int(attrs.get('fec_inner',"0")) # AUTO default
381 if self.parsedCab in self.transponders:
384 self.transponders[self.parsedCab] = [ ]
385 self.transponders[self.parsedCab].append((1, freq, sr, mod, fec))
387 class parseTerrestrials(ContentHandler):
388 def __init__(self, terrestrialsList, transponders):
389 self.isPointsElement, self.isReboundsElement = 0, 0
390 self.terrestrialsList = terrestrialsList
391 self.transponders = transponders
393 def startElement(self, name, attrs):
394 if (name == "terrestrial"):
395 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
396 tname = attrs.get('name',"").encode("UTF-8")
397 tflags = attrs.get('flags',"")
398 self.terrestrialsList.append((tname, tflags))
399 self.parsedTer = str(tname)
400 elif (name == "transponder"):
402 freq = int(attrs.get('centre_frequency',""))
403 bw = int(attrs.get('bandwidth',"3")) # AUTO
404 const = int(attrs.get('constellation',"1")) # AUTO
405 crh = int(attrs.get('code_rate_hp',"5")) # AUTO
406 if crh > 5: # our terrestrial.xml is buggy... 6 for AUTO
408 crl = int(attrs.get('code_rate_lp',"5")) # AUTO
409 if crl > 5: # our terrestrial.xml is buggy... 6 for AUTO
411 guard = int(attrs.get('guard_interval',"4")) # AUTO
412 transm = int(attrs.get('transmission_mode',"2")) # AUTO
413 hierarchy = int(attrs.get('hierarchy_information',"4")) # AUTO
414 inv = int(attrs.get('inversion',"2")) # AUTO
415 if self.parsedTer in self.transponders:
418 self.transponders[self.parsedTer] = [ ]
420 self.transponders[self.parsedTer].append((2, freq, bw, const, crh, crl, guard, transm, hierarchy, inv))
422 def getTransponders(self, pos):
423 if self.transponders.has_key(pos):
424 return self.transponders[pos]
428 def getTranspondersCable(self, cable):
429 return self.transponderscable[cable]
431 def getTranspondersTerrestrial(self, region):
432 return self.transpondersterrestrial[region]
434 def getCableDescription(self, nim):
435 return self.cablesList[config.Nims[nim].cable.value]
437 def getTerrestrialDescription(self, nim):
438 return self.terrestrialsList[config.Nims[nim].terrestrial.value][0]
440 def getTerrestrialFlags(self, nim):
441 return self.terrestrialsList[config.Nims[nim].terrestrial.value][1]
443 def getConfiguredSats(self):
444 return self.sec.getSatList()
446 def getSatDescription(self, pos):
447 return self.satellites[pos]
449 def readSatsfromFile(self):
450 self.satellites = { }
451 self.transponders = { }
452 self.transponderscable = { }
453 self.transpondersterrestrial = { }
455 parser = make_parser()
456 if (self.hasNimType(self.nimType["DVB-S"])):
457 print "Reading satellites.xml"
458 satHandler = self.parseSats(self.satList, self.satellites, self.transponders)
459 parser.setContentHandler(satHandler)
460 parser.parse('/etc/tuxbox/satellites.xml')
461 if (self.hasNimType(self.nimType["DVB-C"])):
462 print "Reading cables.xml"
463 cabHandler = self.parseCables(self.cablesList, self.transponderscable)
464 parser.setContentHandler(cabHandler)
465 parser.parse('/etc/tuxbox/cables.xml')
467 if (self.hasNimType(self.nimType["DVB-T"])):
468 print "Reading terrestrial.xml"
469 terHandler = self.parseTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
470 parser.setContentHandler(terHandler)
471 parser.parse('/etc/tuxbox/terrestrial.xml')
476 self.nimSocketCount = 0
477 nimfile = tryOpen("/proc/bus/nim_sockets")
480 return self.nimType["empty/unknown"]
485 line = nimfile.readline()
488 if line.strip().startswith("NIM Socket"):
489 parts = line.strip().split(" ")
490 id = int(parts[2][:1])
492 self.nimSocketCount += 1
493 elif line.strip().startswith("Type:"):
494 self.nimTypes[lastsocket] = str(line.strip()[6:])
495 #self.nimTypes[lastsocket] = str("DVB-T")
496 elif line.strip().startswith("Name:"):
497 self.nimNames[lastsocket] = str(line.strip()[6:])
498 elif line.strip().startswith("empty"):
499 self.nimNames[lastsocket] = _("N/A")
500 self.nimTypes[lastsocket] = "empty/unknown"
504 def getNimType(self, slotID):
505 if slotID >= self.nimCount:
506 return self.nimType["empty/unknown"]
508 return self.nimType[self.nimTypes[slotID]]
510 def getNimTypeName(self, slotID):
511 if slotID >= self.nimCount:
512 return "empty/unknown"
514 return self.nimTypes[slotID]
516 def getNimName(self, slotID):
517 return self.nimNames[slotID]
519 def getNimSocketCount(self):
520 return self.nimSocketCount
522 def hasNimType(self, chktype):
523 for id, type in self.nimTypes.items():
524 if (chktype == self.nimType[str(type)]):
528 def getNimListOfType(self, type, exception = -1):
530 for x in self.nimslots:
531 if ((x.nimType == type) and (x.slotid != exception)):
532 list.append(x.slotid)
535 def getConfigPrefix(self, slotid):
536 return "config.Nim" + ("A","B","C","D")[slotid] + "."
540 self.nimType = { "empty/unknown": -1,
546 self.terrestrialsList = []
550 self.readSatsfromFile()
552 self.nimCount = self.getNimSocketCount()
556 while x < self.nimCount:
557 tType = self.getNimType(x)
558 tName = self.getNimName(x)
559 tNim = nimSlot(x, tType, tName)
560 self.nimslots.append(tNim)
563 InitNimManager(self) #init config stuff
567 for slot in self.nimslots:
568 nimText = _("Socket ") + ("A", "B", "C", "D")[slot.slotid] + ": "
569 if slot.nimType == -1:
570 nimText += _("empty/unknown")
572 nimText += slot.name + " ("
573 nimText += ("DVB-S", "DVB-C", "DVB-T")[slot.nimType] + ")"
574 list.append((nimText, slot))
577 def getNimConfigMode(self, slotid):
578 return currentConfigSelectionElement(config.Nims[slotid].configMode)
580 def getSatList(self):
583 def getSatListForNim(self, slotid):
585 if (self.getNimType(slotid) == self.nimType["DVB-S"]):
586 #print "slotid:", slotid
588 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
589 #print "diseqcA:", config.Nims[slotid].diseqcA.value
590 configMode = currentConfigSelectionElement(config.Nims[slotid].configMode)
592 if configMode == "equal":
593 slotid=0 #FIXME add handling for more than two tuners !!!
594 configMode = currentConfigSelectionElement(config.Nims[slotid].configMode)
596 if configMode == "simple":
597 if (config.Nims[slotid].diseqcMode.value <= 3):
598 list.append(self.satList[config.Nims[slotid].diseqcA.value])
599 if (0 < config.Nims[slotid].diseqcMode.value <= 3):
600 list.append(self.satList[config.Nims[slotid].diseqcB.value])
601 if (config.Nims[slotid].diseqcMode.value == 3):
602 list.append(self.satList[config.Nims[slotid].diseqcC.value])
603 list.append(self.satList[config.Nims[slotid].diseqcD.value])
604 if (config.Nims[slotid].diseqcMode.value == 4):
605 for x in self.satList:
607 elif configMode == "advanced":
608 for x in self.satList:
609 if config.Nims[slotid].advanced.sat[x[1]].lnb.value != 0:
614 def getRotorSatListForNim(self, slotid):
616 if (self.getNimType(slotid) == self.nimType["DVB-S"]):
617 #print "slotid:", slotid
619 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
620 #print "diseqcA:", config.Nims[slotid].diseqcA.value
621 configMode = currentConfigSelectionElement(config.Nims[slotid].configMode)
622 if configMode == "simple":
623 if (config.Nims[slotid].diseqcMode.value == 4):
624 for x in self.satList:
626 elif configMode == "advanced":
627 for x in self.satList:
628 nim = config.Nims[slotid]
629 lnbnum = nim.advanced.sat[x[1]].lnb.value
631 lnb = nim.advanced.lnb[lnbnum]
632 if lnb.diseqcMode.value == 3: # diseqc 1.2
636 def nimDiseqcModeChanged(self, slotid, mode):
637 #print "nimDiseqcModeChanged set to " + str(mode)
639 def nimPortAChanged(self, slotid, val):
640 #print "nimDiseqcA set to " + str(slotid) + " val:" + str(val)
642 def nimPortBChanged(self, slotid, val):
643 #print "nimDiseqcA set to " + str(slotid) + " val:" + str(val)
644 #print "nimDiseqcB set to " + str(val)
646 def nimPortCChanged(self, slotid, val):
647 #print "nimDiseqcC set to " + str(val)
649 def nimPortDChanged(self, slotid, val):
650 #print "nimDiseqcD set to " + str(val)
653 def InitNimManager(nimmgr):
655 for x in range(nimmgr.nimCount):
656 config.Nims.append(ConfigSubsection())
658 # def nimConfigModeChanged(slotid, configElement):
659 # nimmgr.nimConfigModeChanged(slotid, configElement.value)
660 def nimDiseqcModeChanged(slotid, configElement):
661 nimmgr.nimDiseqcModeChanged(slotid, configElement.value)
663 def nimPortAChanged(slotid, configElement):
664 nimmgr.nimPortAChanged(slotid, configElement.vals[configElement.value][1])
665 def nimPortBChanged(slotid, configElement):
666 nimmgr.nimPortBChanged(slotid, configElement.vals[configElement.value][1])
667 def nimPortCChanged(slotid, configElement):
668 nimmgr.nimPortCChanged(slotid, configElement.vals[configElement.value][1])
669 def nimPortDChanged(slotid, configElement):
670 nimmgr.nimPortDChanged(slotid, configElement.vals[configElement.value][1])
672 for slot in nimmgr.nimslots:
674 cname = nimmgr.getConfigPrefix(x)
677 if slot.nimType == nimmgr.nimType["DVB-S"]:
679 nim.configMode = configElement(cname + "configMode", configSelection, 0, (
680 ("simple", _("Simple")), ("advanced", _("Advanced"))), False)
682 nim.configMode = configElement(cname + "configMode", configSelection, 0, (
683 ("equal", _("Equal to Socket A")),
684 ("loopthrough", _("Loopthrough to Socket A")),
685 ("nothing", _("Nothing connected")),
686 ("satposdepends", _("Secondary cable from motorized LNB")),
687 ("simple", _("Simple")),
688 ("advanced", _("Advanced"))), False)
689 #important - check if just the 2nd one is LT only and the first one is DVB-S
690 if currentConfigSelectionElement(nim.configMode) in ["loopthrough", "satposdepends", "equal"]:
691 if x == 0: #first one can never be linked to anything
692 nim.configMode.value = getConfigSelectionElement(nim.configMode, "simple") #reset to simple
693 nim.configMode.save()
695 #FIXME: make it better
696 for y in nimmgr.nimslots:
698 if y.nimType != nimmgr.nimType["DVB-S"]:
699 nim.configMode.value = getConfigSelectionElement(nim.configMode, "simple") #reset to simple
700 nim.configMode.save()
702 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);
703 nim.diseqcA = configElement(cname + "diseqcA", configSatlist, 192, nimmgr.satList, False);
704 nim.diseqcB = configElement(cname + "diseqcB", configSatlist, 130, nimmgr.satList, False);
705 nim.diseqcC = configElement(cname + "diseqcC", configSatlist, 0, nimmgr.satList, False);
706 nim.diseqcD = configElement(cname + "diseqcD", configSatlist, 0, nimmgr.satList, False);
707 nim.positionerMode = configElement(cname + "positionerMode", configSelection, 0, (("usals", _("USALS")), ("manual", _("manual"))), False);
708 nim.longitude = configElement(cname + "longitude", configSequence, [5,100], configsequencearg.get("FLOAT", [(0,359),(0,999)]), False);
709 nim.longitudeOrientation = configElement(cname + "longitudeOrientation", configSelection, 0, (("east", _("East")), ("west", _("West"))), False)
710 nim.latitude = configElement(cname + "latitude", configSequence, [50,767], configsequencearg.get("FLOAT", [(0,359),(0,999)]), False);
711 nim.latitudeOrientation = configElement(cname + "latitudeOrientation", configSelection, 0, (("north", _("North")), ("south", _("South"))), False)
712 satNimList = nimmgr.getNimListOfType(nimmgr.nimType["DVB-S"], slot.slotid)
715 satNimListNames.append((("Slot_" + ("A", "B", "C", "D")[x] + "_" + nimmgr.getNimName(x)), _("Slot ") + ("A", "B", "C", "D")[x] + ": " + nimmgr.getNimName(x)))
716 nim.equalTo = configElement(cname + "equalTo", configSelection, 0, satNimListNames, False);
717 nim.linkedTo = configElement(cname + "linkedTo", configSelection, 0, satNimListNames, False);
718 nim.satposDependsTo = configElement(cname + "satposDependsTo", configSelection, 0, satNimListNames, False);
720 #perhaps the instance of the slot is more useful?
721 # nim.configMode.addNotifier(boundFunction(nimConfigModeChanged,x))
722 nim.diseqcMode.addNotifier(boundFunction(nimDiseqcModeChanged,x))
723 nim.diseqcA.addNotifier(boundFunction(nimPortAChanged,int(x)))
724 nim.diseqcB.addNotifier(boundFunction(nimPortBChanged,x))
725 nim.diseqcC.addNotifier(boundFunction(nimPortCChanged,x))
726 nim.diseqcD.addNotifier(boundFunction(nimPortDChanged,x))
729 nim.advanced = ConfigSubsection()
730 nim.advanced.sats = configElement(cname + "advanced.sats", configSatlist, 192, nimmgr.satList, False);
731 nim.advanced.sat = {}
732 lnbs = ["not available"]
733 for y in range(1, 33):
734 lnbs.append("LNB " + str(y))
735 for x in nimmgr.satList:
736 nim.advanced.sat[x[1]] = ConfigSubsection()
737 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)
738 nim.advanced.sat[x[1]].tonemode = configElement(cname + "advanced.sat" + str(x[1]) + ".tonemode", configSelection, 0, (("band", _("Band")), ("on", _("On")), ("off", _("Off"))), False)
739 nim.advanced.sat[x[1]].usals = configElement(cname + "advanced.sat" + str(x[1]) + ".usals", configSelection, 0, (("yes", _("Yes")), ("no", _("No"))), False)
740 nim.advanced.sat[x[1]].rotorposition = configElement(cname + "advanced.sat" + str(x[1]) + ".rotorposition", configSequence, [1], configsequencearg.get("INTEGER", (1, 255)), False)
741 nim.advanced.sat[x[1]].lnb = configElement(cname + "advanced.sat" + str(x[1]) + ".lnb", configSelection, 0, lnbs, False)
743 csw = [("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))]
744 for y in range(0, 16):
745 csw.append((str(0xF0|y), "Input " + str(y+1)))
747 ucsw = [("none", _("None"))]
748 for y in range(1, 17):
749 ucsw.append("Input " + str(y))
751 nim.advanced.lnb = [0]
752 for x in range(1, 33):
753 nim.advanced.lnb.append(ConfigSubsection())
754 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)
755 nim.advanced.lnb[x].lofl = configElement(cname + "advanced.lnb" + str(x) + ".lofl", configSequence, [9750], configsequencearg.get("INTEGER", (0, 99999)), False)
756 nim.advanced.lnb[x].lofh = configElement(cname + "advanced.lnb" + str(x) + ".lofh", configSequence, [10600], configsequencearg.get("INTEGER", (0, 99999)), False)
757 nim.advanced.lnb[x].threshold = configElement(cname + "advanced.lnb" + str(x) + ".threshold", configSequence, [11700], configsequencearg.get("INTEGER", (0, 99999)), False)
758 nim.advanced.lnb[x].output_12v = configElement(cname + "advanced.lnb" + str(x) + ".output_12v", configSelection, 0, (("0V", _("0 V")), ("12V", _("12 V"))), False)
759 nim.advanced.lnb[x].increased_voltage = configElement(cname + "advanced.lnb" + str(x) + ".increased_voltage", configSelection, 0, (("no", _("No")), ("yes", _("Yes"))), False)
760 nim.advanced.lnb[x].toneburst = configElement(cname + "advanced.lnb" + str(x) + ".toneburst", configSelection, 0, (("none", _("None")), ("A", _("A")), ("B", _("B"))), False)
761 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)
762 nim.advanced.lnb[x].commitedDiseqcCommand = configElement(cname + "advanced.lnb" + str(x) + ".commitedDiseqcCommand", configSelection, 0, csw, False)
763 nim.advanced.lnb[x].fastDiseqc = configElement(cname + "advanced.lnb" + str(x) + ".fastDiseqc", configSelection, 0, (("no", _("No")), ("yes", _("Yes"))), False)
764 nim.advanced.lnb[x].sequenceRepeat = configElement(cname + "advanced.lnb" + str(x) + ".sequenceRepeat", configSelection, 0, (("no", _("No")), ("yes", _("Yes"))), False)
765 nim.advanced.lnb[x].commandOrder1_0 = configElement(cname + "advanced.lnb" + str(x) + ".commandOrder1_0", configSelection, 0, ("committed, toneburst", "toneburst, committed"), False)
766 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)
767 nim.advanced.lnb[x].uncommittedDiseqcCommand = configElement(cname + "advanced.lnb" + str(x) + ".uncommittedDiseqcCommand", configSelection, 0, ucsw, False)
768 nim.advanced.lnb[x].diseqcRepeats = configElement(cname + "advanced.lnb" + str(x) + ".diseqcRepeats", configSelection, 0, (("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))), False)
769 nim.advanced.lnb[x].longitude = configElement(cname + "advanced.lnb" + str(x) + ".longitude", configSequence, [5,100], configsequencearg.get("FLOAT", [(0,359),(0,999)]), False)
770 nim.advanced.lnb[x].longitudeOrientation = configElement(cname + "advanced.lnb" + str(x) + ".longitudeOrientation", configSelection, 0, (("east", _("East")), ("west", _("West"))), False)
771 nim.advanced.lnb[x].latitude = configElement(cname + "advanced.lnb" + str(x) + ".latitude", configSequence, [50,767], configsequencearg.get("FLOAT", [(0,359),(0,999)]), False)
772 nim.advanced.lnb[x].latitudeOrientation = configElement(cname + "advanced.lnb" + str(x) + ".latitudeOrientation", configSelection, 0, (("north", _("North")), ("south", _("South"))), False)
773 nim.advanced.lnb[x].powerMeasurement = configElement(cname + "advanced.lnb" + str(x) + ".powerMeasurement", configSelection, 0, (("yes", _("Yes")), ("no", _("No"))), False)
774 nim.advanced.lnb[x].powerThreshold = configElement(cname + "advanced.lnb" + str(x) + ".powerThreshold", configSequence, [50], configsequencearg.get("INTEGER", (0, 100)), False)
775 elif slot.nimType == nimmgr.nimType["DVB-C"]:
776 nim.cable = configElement(cname + "cable", configSelection, 0, nimmgr.cablesList, False);
777 elif slot.nimType == nimmgr.nimType["DVB-T"]:
779 for x in nimmgr.terrestrialsList:
781 nim.terrestrial = configElement(cname + "terrestrial", configSelection, 0, list, False);
782 nim.terrestrial_5V = configElement(cname + "terrestrial_5V", configSelection, 1, (("on", _("On")), ("off", _("Off"))), True);
784 print "pls add support for this frontend type!"
786 nimmgr.sec = SecConfigure(nimmgr)
789 nimmanager = NimManager()