1 from config import config, ConfigSubsection, ConfigSelection, ConfigFloat, ConfigSatlist, ConfigYesNo, ConfigInteger, ConfigSubList, ConfigNothing, ConfigSubDict
3 from enigma import eDVBSatelliteEquipmentControl, \
4 eDVBSatelliteLNBParameters as lnbParam, \
5 eDVBSatelliteDiseqcParameters as diseqcParam, \
6 eDVBSatelliteSwitchParameters as switchParam, \
7 eDVBSatelliteRotorParameters as rotorParam
10 from xml.dom import EMPTY_NAMESPACE
11 from skin import elementsWithTag
12 from Tools import XMLTools
14 from xml.sax import make_parser
15 from xml.sax.handler import ContentHandler
17 from Tools.BoundFunction import boundFunction
19 def tryOpen(filename):
21 procFile = open(filename)
27 def addLNBSimple(self, sec, slotid, diseqcmode, toneburstmode = 0, diseqcpos = 0, orbpos = 0, longitude = 0, latitude = 0, loDirection = 0, laDirection = 0):
30 tunermask = 1 << slotid
31 if self.equal.has_key(slotid):
32 tunermask |= (1 << self.equal[slotid])
33 elif self.linked.has_key(slotid):
34 tunermask |= (1 << self.linked[slotid])
35 sec.setLNBTunerMask(tunermask)
36 sec.setLNBLOFL(9750000)
37 sec.setLNBLOFH(10600000)
38 sec.setLNBThreshold(11700000)
39 sec.setLNBIncreasedVoltage(lnbParam.OFF)
43 sec.setVoltageMode(switchParam.HV)
44 sec.setToneMode(switchParam.HILO)
45 sec.setCommandOrder(0)
48 sec.setDiSEqCMode(diseqcmode)
49 sec.setToneburst(toneburstmode)
50 sec.setCommittedCommand(diseqcpos)
51 #print "set orbpos to:" + str(orbpos)
53 if (0 <= diseqcmode < 3):
54 sec.addSatellite(orbpos)
55 self.satList.append(orbpos)
56 elif (diseqcmode == 3): # diseqc 1.2
57 if self.satposdepends.has_key(slotid):
58 tunermask |= (1 << self.satposdepends[slotid])
59 sec.setLNBTunerMask(tunermask)
60 sec.setLatitude(latitude)
61 sec.setLaDirection(laDirection)
62 sec.setLongitude(longitude)
63 sec.setLoDirection(loDirection)
64 sec.setUseInputpower(True)
65 sec.setInputpowerDelta(50)
67 for x in self.NimManager.satList:
68 print "Add sat " + str(x[0])
69 sec.addSatellite(int(x[0]))
72 sec.setRotorPosNum(0) # USALS
73 self.satList.append(int(x[0]))
75 def setSatposDepends(self, sec, nim1, nim2):
76 print "tuner", nim1, "depends on satpos of", nim2
77 sec.setTunerDepends(nim1, nim2)
79 def linkNIMs(self, sec, nim1, nim2):
80 print "link tuner", nim1, "to tuner", nim2
81 sec.setTunerLinked(nim1, nim2)
87 sec = eDVBSatelliteEquipmentControl.getInstance()
88 sec.clear() ## this do unlinking NIMs too !!
89 print "sec config cleared"
93 self.satposdepends = { }
95 for slot in self.NimManager.nimslots:
98 if slot.nimType == self.NimManager.nimType["DVB-S"]:
99 if nim.configMode.value == "equal":
100 self.equal[nim.equalTo.value]=x
101 if nim.configMode.value == "loopthrough":
102 self.linkNIMs(sec, x, nim.linkedTo.value)
103 self.linked[nim.linkedTo.value]=x
104 elif nim.configMode.value == "satposdepends":
105 self.setSatposDepends(sec, x, nim.satposDependsTo.index)
106 self.satposdepends[nim.satposDependsTo.value]=x
108 for slot in self.NimManager.nimslots:
111 if slot.nimType == self.NimManager.nimType["DVB-S"]:
112 print "slot: " + str(x) + " configmode: " + str(nim.configMode.value)
113 print "diseqcmode: ", nim.configMode.value
114 if nim.configMode.value in [ "loopthrough", "satposdepends", "equal", "nothing" ]:
116 elif nim.configMode.value == "simple": #simple config
117 if nim.diseqcMode.value == "single": #single
118 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.NONE, diseqcpos = diseqcParam.SENDNO)
119 elif nim.diseqcMode.value == "toneburst_a_b": #Toneburst A/B
120 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.A, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO)
121 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.B, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO)
122 elif nim.diseqcMode.value == "diseqc_a_b": #DiSEqC A/B
123 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA)
124 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB)
125 elif nim.diseqcMode.value == "diseqc_a_b_c_d": #DiSEqC A/B/C/D
126 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA)
127 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB)
128 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcC.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BA)
129 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcD.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BB)
130 elif nim.diseqcMode.value == "positioner": #Positioner
131 if nim.latitudeOrientation.value == "north":
132 laValue = rotorParam.NORTH
134 laValue = rotorParam.SOUTH
135 if nim.longitudeOrientation.value == "east":
136 loValue = rotorParam.EAST
138 loValue = rotorParam.WEST
139 self.addLNBSimple(sec, slotid = x, diseqcmode = 3,
140 longitude = nim.longitude.float,
141 loDirection = loValue,
142 latitude = nim.latitude.float,
143 laDirection = laValue)
144 elif nim.configMode.value == "advanced": #advanced config
145 self.updateAdvanced(sec, x)
146 print "sec config completed"
148 def updateAdvanced(self, sec, slotid):
150 for x in range(1,33):
152 for x in self.NimManager.satList:
153 lnb = int(config.Nims[slotid].advanced.sat[x[0]].lnb.value)
155 print "add", x[0], "to", lnb
156 lnbSat[lnb].append(x[0])
157 for x in range(1,33):
158 if len(lnbSat[x]) > 0:
159 currLnb = config.Nims[slotid].advanced.lnb[x]
162 tunermask = 1 << slotid
163 if self.equal.has_key(slotid):
164 tunermask |= (1 << self.equal[slotid])
165 elif self.linked.has_key(slotid):
166 tunermask |= (1 << self.linked[slotid])
168 if currLnb.lof.value == "universal_lnb":
169 sec.setLNBLOFL(9750000)
170 sec.setLNBLOFH(10600000)
171 sec.setLNBThreshold(11700000)
172 elif currLnb.lof.value == "c_band":
173 sec.setLNBLOFL(5150000)
174 sec.setLNBLOFH(5150000)
175 sec.setLNBThreshold(5150000)
176 elif currLnb.lof.value == "user_defined":
177 sec.setLNBLOFL(currLnb.lofl.value * 1000)
178 sec.setLNBLOFH(currLnb.lofh.value * 1000)
179 sec.setLNBThreshold(currLnb.threshold.value * 1000)
181 if currLnb.output_12v.value == "0V":
182 pass # nyi in drivers
183 elif currLnb.output_12v.value == "12V":
184 pass # nyi in drivers
186 if currLnb.increased_voltage.value:
187 sec.setLNBIncreasedVoltage(lnbParam.ON)
189 sec.setLNBIncreasedVoltage(lnbParam.OFF)
191 dm = currLnb.diseqcMode.value
193 sec.setDiSEqCMode(diseqcParam.NONE)
195 sec.setDiSEqCMode(diseqcParam.V1_0)
197 sec.setDiSEqCMode(diseqcParam.V1_1)
199 sec.setDiSEqCMode(diseqcParam.V1_2)
201 if self.satposdepends.has_key(slotid): # only useable with rotors
202 tunermask |= (1 << self.satposdepends[slotid])
205 if currLnb.toneburst.value == "none":
206 sec.setToneburst(diseqcParam.NO)
207 elif currLnb.toneburst.value == "A":
208 sec.setToneburst(diseqcParam.A)
209 elif currLnb.toneburst.value == "B":
210 sec.setToneburst(diseqcParam.B)
212 # Committed Diseqc Command
213 cdc = currLnb.commitedDiseqcCommand.value
215 c = { "none": diseqcParam.SENDNO,
216 "AA": diseqcParam.AA,
217 "AB": diseqcParam.AB,
218 "BA": diseqcParam.BA,
219 "BB": diseqcParam.BB }
222 sec.setCommittedCommand(c[cdc])
224 sec.setCommittedCommand(long(cdc))
226 sec.setFastDiSEqC(currLnb.fastDiseqc.value)
228 sec.setSeqRepeat(currLnb.sequenceRepeat.value)
230 if currLnb.diseqcMode.value == "1_0":
231 currCO = currLnb.commandOrder1_0.value
233 currCO = currLnb.commandOrder.value
235 udc = int(currLnb.uncommittedDiseqcCommand.value)
237 sec.setUncommittedCommand(0xF0|(udc-1))
239 sec.setUncommittedCommand(0) # SENDNO
241 sec.setRepeats({"none": 0, "one": 1, "two": 2, "three": 3}[currLnb.diseqcRepeats.value])
243 setCommandOrder = False
245 # 0 "committed, toneburst",
246 # 1 "toneburst, committed",
247 # 2 "committed, uncommitted, toneburst",
248 # 3 "toneburst, committed, uncommitted",
249 # 4 "uncommitted, committed, toneburst"
250 # 5 "toneburst, uncommitted, commmitted"
251 order_map = {"ct": 0, "tc": 1, "cut": 2, "tcu": 3, "uct": 4, "tuc": 5}
252 sec.setCommandOrder(order_map[currCO])
255 latitude = currLnb.latitude.float
256 sec.setLatitude(latitude)
257 longitude = currLnb.longitude.float
258 sec.setLongitude(longitude)
259 if currLnb.latitudeOrientation.value == "north":
260 sec.setLaDirection(rotorParam.NORTH)
262 sec.setLaDirection(rotorParam.SOUTH)
263 if currLnb.longitudeOrientation.value == "east":
264 sec.setLoDirection(rotorParam.EAST)
266 sec.setLoDirection(rotorParam.WEST)
268 if currLnb.powerMeasurement.value:
269 sec.setUseInputpower(True)
270 sec.setInputpowerDelta(currLnb.powerThreshold.value)
272 sec.setUseInputpower(False)
274 sec.setLNBTunerMask(tunermask)
276 # finally add the orbital positions
279 currSat = config.Nims[slotid].advanced.sat[y]
281 if currSat.voltage.value == "polarization":
282 sec.setVoltageMode(switchParam.HV)
283 elif currSat.voltage.value == "13V":
284 sec.setVoltageMode(switchParam._14V)
285 elif currSat.voltage.value == "18V":
286 sec.setVoltageMode(switchParam._18V)
288 if currSat.tonemode == "band":
289 sec.setToneMode(switchParam.HILO)
290 elif currSat.tonemode == "on":
291 sec.setToneMode(switchParam.ON)
292 elif currSat.tonemode == "off":
293 sec.setToneMode(switchParam.OFF)
295 if not currSat.usals.value:
296 sec.setRotorPosNum(currSat.rotorposition.value)
298 sec.setRotorPosNum(0) #USALS
300 def __init__(self, nimmgr):
301 self.NimManager = nimmgr
305 def __init__(self, slotid, nimtype, name):
307 self.nimType = nimtype
311 class parseSats(ContentHandler):
312 def __init__(self, satList, satellites, transponders):
313 self.isPointsElement, self.isReboundsElement = 0, 0
314 self.satList = satList
315 self.satellites = satellites
316 self.transponders = transponders
318 def startElement(self, name, attrs):
320 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
321 tpos = int(attrs.get('position',""))
324 tname = attrs.get('name',"").encode("UTF-8")
325 self.satellites[tpos] = tname
326 self.satList.append( (tpos, tname) )
327 self.parsedSat = int(tpos)
328 elif (name == "transponder"):
329 modulation = int(attrs.get('modulation',"1")) # QPSK default
330 system = int(attrs.get('system',"0")) # DVB-S default
331 freq = int(attrs.get('frequency',""))
332 sr = int(attrs.get('symbol_rate',""))
333 pol = int(attrs.get('polarization',""))
334 fec = int(attrs.get('fec_inner',"0")) # AUTO default
335 if self.parsedSat in self.transponders:
338 self.transponders[self.parsedSat] = [ ]
340 self.transponders[self.parsedSat].append((0, freq, sr, pol, fec, system, modulation))
342 class parseCables(ContentHandler):
343 def __init__(self, cablesList, transponders):
344 self.isPointsElement, self.isReboundsElement = 0, 0
345 self.cablesList = cablesList
346 self.transponders = transponders
348 def startElement(self, name, attrs):
349 if (name == "cable"):
350 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
351 tname = attrs.get('name',"").encode("UTF-8")
352 self.cablesList.append(str(tname))
353 self.parsedCab = str(tname)
354 elif (name == "transponder"):
355 freq = int(attrs.get('frequency',""))
356 sr = int(attrs.get('symbol_rate',""))
357 mod = int(attrs.get('modulation',"3")) # QAM64 default
358 fec = int(attrs.get('fec_inner',"0")) # AUTO default
359 if self.parsedCab in self.transponders:
362 self.transponders[self.parsedCab] = [ ]
363 self.transponders[self.parsedCab].append((1, freq, sr, mod, fec))
365 class parseTerrestrials(ContentHandler):
366 def __init__(self, terrestrialsList, transponders):
367 self.isPointsElement, self.isReboundsElement = 0, 0
368 self.terrestrialsList = terrestrialsList
369 self.transponders = transponders
371 def startElement(self, name, attrs):
372 if (name == "terrestrial"):
373 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
374 tname = attrs.get('name',"").encode("UTF-8")
375 tflags = attrs.get('flags',"")
376 self.terrestrialsList.append((tname, tflags))
377 self.parsedTer = str(tname)
378 elif (name == "transponder"):
380 freq = int(attrs.get('centre_frequency',""))
381 bw = int(attrs.get('bandwidth',"3")) # AUTO
382 const = int(attrs.get('constellation',"1")) # AUTO
383 crh = int(attrs.get('code_rate_hp',"5")) # AUTO
384 if crh > 5: # our terrestrial.xml is buggy... 6 for AUTO
386 crl = int(attrs.get('code_rate_lp',"5")) # AUTO
387 if crl > 5: # our terrestrial.xml is buggy... 6 for AUTO
389 guard = int(attrs.get('guard_interval',"4")) # AUTO
390 transm = int(attrs.get('transmission_mode',"2")) # AUTO
391 hierarchy = int(attrs.get('hierarchy_information',"4")) # AUTO
392 inv = int(attrs.get('inversion',"2")) # AUTO
393 if self.parsedTer in self.transponders:
396 self.transponders[self.parsedTer] = [ ]
398 self.transponders[self.parsedTer].append((2, freq, bw, const, crh, crl, guard, transm, hierarchy, inv))
400 def getTransponders(self, pos):
401 if self.transponders.has_key(pos):
402 return self.transponders[pos]
406 def getTranspondersCable(self, cable):
407 return self.transponderscable[cable]
409 def getTranspondersTerrestrial(self, region):
410 return self.transpondersterrestrial[region]
412 def getCableDescription(self, nim):
413 return self.cablesList[config.Nims[nim].cable.value]
415 def getTerrestrialDescription(self, nim):
416 return self.terrestrialsList[config.Nims[nim].terrestrial.value][0]
418 def getTerrestrialFlags(self, nim):
419 return self.terrestrialsList[config.Nims[nim].terrestrial.value][1]
421 def getConfiguredSats(self):
422 return self.sec.getSatList()
424 def getSatDescription(self, pos):
425 return self.satellites[pos]
427 def readSatsfromFile(self):
428 self.satellites = { }
429 self.transponders = { }
430 self.transponderscable = { }
431 self.transpondersterrestrial = { }
433 parser = make_parser()
434 if (self.hasNimType(self.nimType["DVB-S"])):
435 print "Reading satellites.xml"
436 satHandler = self.parseSats(self.satList, self.satellites, self.transponders)
437 parser.setContentHandler(satHandler)
438 parser.parse('/etc/tuxbox/satellites.xml')
439 if (self.hasNimType(self.nimType["DVB-C"])):
440 print "Reading cables.xml"
441 cabHandler = self.parseCables(self.cablesList, self.transponderscable)
442 parser.setContentHandler(cabHandler)
443 parser.parse('/etc/tuxbox/cables.xml')
445 if (self.hasNimType(self.nimType["DVB-T"])):
446 print "Reading terrestrial.xml"
447 terHandler = self.parseTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
448 parser.setContentHandler(terHandler)
449 parser.parse('/etc/tuxbox/terrestrial.xml')
454 self.nimSocketCount = 0
455 nimfile = tryOpen("/proc/bus/nim_sockets")
458 return self.nimType["empty/unknown"]
463 line = nimfile.readline()
466 if line.strip().startswith("NIM Socket"):
467 parts = line.strip().split(" ")
468 id = int(parts[2][:1])
470 self.nimSocketCount += 1
471 elif line.strip().startswith("Type:"):
472 self.nimTypes[lastsocket] = str(line.strip()[6:])
473 #self.nimTypes[lastsocket] = str("DVB-T")
474 elif line.strip().startswith("Name:"):
475 self.nimNames[lastsocket] = str(line.strip()[6:])
476 elif line.strip().startswith("empty"):
477 self.nimNames[lastsocket] = _("N/A")
478 self.nimTypes[lastsocket] = "empty/unknown"
482 def getNimType(self, slotID):
483 if slotID >= self.nimCount:
484 return self.nimType["empty/unknown"]
486 return self.nimType[self.nimTypes[slotID]]
488 def getNimTypeName(self, slotID):
489 if slotID >= self.nimCount:
490 return "empty/unknown"
492 return self.nimTypes[slotID]
494 def getNimName(self, slotID):
495 return self.nimNames[slotID]
497 def getNimSocketCount(self):
498 return self.nimSocketCount
500 def hasNimType(self, chktype):
501 for id, type in self.nimTypes.items():
502 if (chktype == self.nimType[str(type)]):
506 def getNimListOfType(self, type, exception = -1):
508 for x in self.nimslots:
509 if ((x.nimType == type) and (x.slotid != exception)):
510 list.append(x.slotid)
513 def getConfigPrefix(self, slotid):
514 return "config.Nim" + ("A","B","C","D")[slotid] + "."
518 self.nimType = { "empty/unknown": -1,
524 self.terrestrialsList = []
528 self.readSatsfromFile()
530 self.nimCount = self.getNimSocketCount()
534 while x < self.nimCount:
535 tType = self.getNimType(x)
536 tName = self.getNimName(x)
537 tNim = nimSlot(x, tType, tName)
538 self.nimslots.append(tNim)
541 InitNimManager(self) #init config stuff
545 for slot in self.nimslots:
546 nimText = _("Socket ") + ("A", "B", "C", "D")[slot.slotid] + ": "
547 if slot.nimType == -1:
548 nimText += _("empty/unknown")
550 nimText += slot.name + " ("
551 nimText += ("DVB-S", "DVB-C", "DVB-T")[slot.nimType] + ")"
552 list.append((nimText, slot))
555 def getNimConfigMode(self, slotid):
556 return config.Nims[slotid].configMode.value
558 def getSatList(self):
561 def getSatListForNim(self, slotid):
563 if (self.getNimType(slotid) == self.nimType["DVB-S"]):
564 #print "slotid:", slotid
566 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
567 #print "diseqcA:", config.Nims[slotid].diseqcA.value
568 configMode = config.Nims[slotid].configMode.value
570 if configMode == "equal":
571 slotid=0 #FIXME add handling for more than two tuners !!!
572 configMode = config.Nims[slotid].configMode.value
574 if configMode == "simple":
575 dm = config.Nims[slotid].diseqcMode.value
576 if dm in ["single", "toneburst", "diseqc_a_b", "diseqc_a_b_c_d"]:
577 list.append(self.satList[config.Nims[slotid].diseqcA.index])
578 if dm in ["toneburst", "diseqc_a_b", "diseqc_a_b_c_d"]:
579 list.append(self.satList[config.Nims[slotid].diseqcB.index])
580 if dm == "diseqc_a_b_c_d":
581 list.append(self.satList[config.Nims[slotid].diseqcC.index])
582 list.append(self.satList[config.Nims[slotid].diseqcD.index])
583 if dm == "positioner":
584 for x in self.satList:
586 elif configMode == "advanced":
587 for x in self.satList:
588 if int(config.Nims[slotid].advanced.sat[x[0]].lnb.value) != 0:
593 def getRotorSatListForNim(self, slotid):
595 if (self.getNimType(slotid) == self.nimType["DVB-S"]):
596 #print "slotid:", slotid
598 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
599 #print "diseqcA:", config.Nims[slotid].diseqcA.value
600 configMode = config.Nims[slotid].configMode.value
601 if configMode == "simple":
602 if config.Nims[slotid].diseqcMode.value == "positioner":
603 for x in self.satList:
605 elif configMode == "advanced":
606 for x in self.satList:
607 nim = config.Nims[slotid]
608 lnbnum = int(nim.advanced.sat[x[0]].lnb.value)
610 lnb = nim.advanced.lnb[lnbnum]
611 if lnb.diseqcMode.value == "diseqc_a_b_c_d":
615 def nimDiseqcModeChanged(self, slotid, mode):
616 #print "nimDiseqcModeChanged set to " + str(mode)
618 def nimPortAChanged(self, slotid, val):
619 #print "nimDiseqcA set to " + str(slotid) + " val:" + str(val)
621 def nimPortBChanged(self, slotid, val):
622 #print "nimDiseqcA set to " + str(slotid) + " val:" + str(val)
623 #print "nimDiseqcB set to " + str(val)
625 def nimPortCChanged(self, slotid, val):
626 #print "nimDiseqcC set to " + str(val)
628 def nimPortDChanged(self, slotid, val):
629 #print "nimDiseqcD set to " + str(val)
632 def InitNimManager(nimmgr):
633 config.Nims = ConfigSubList()
634 for x in range(nimmgr.nimCount):
635 config.Nims.append(ConfigSubsection())
637 # def nimConfigModeChanged(slotid, configElement):
638 # nimmgr.nimConfigModeChanged(slotid, configElement.value)
639 def nimDiseqcModeChanged(slotid, configElement):
640 nimmgr.nimDiseqcModeChanged(slotid, configElement.value)
642 def nimPortAChanged(slotid, configElement):
643 nimmgr.nimPortAChanged(slotid, configElement.value)
644 def nimPortBChanged(slotid, configElement):
645 nimmgr.nimPortBChanged(slotid, configElement.value)
646 def nimPortCChanged(slotid, configElement):
647 nimmgr.nimPortCChanged(slotid, configElement.value)
648 def nimPortDChanged(slotid, configElement):
649 nimmgr.nimPortDChanged(slotid, configElement.value)
651 for slot in nimmgr.nimslots:
653 cname = nimmgr.getConfigPrefix(x)
656 if slot.nimType == nimmgr.nimType["DVB-S"]:
658 nim.configMode = ConfigSelection(
660 "simple": _("simple"),
661 "advanced": _("advanced")},
665 nim.configMode = ConfigSelection(
667 "equal": _("equal to Socket A"),
668 "looptrough": _("loopthrough to socket A"),
669 "nothing": _("nothing connected"),
670 "satposdepends": _("second cable of motorized LNB"),
671 "simple": _("simple"),
672 "advanced": _("advanced")},
673 default = "looptrough")
675 #important - check if just the 2nd one is LT only and the first one is DVB-S
676 if nim.configMode.value in ["loopthrough", "satposdepends", "equal"]:
677 if x == 0: # first one can never be linked to anything
679 nim.configMode.value = "simple"
680 nim.configMode.save()
682 #FIXME: make it better
683 for y in nimmgr.nimslots:
685 if y.nimType != nimmgr.nimType["DVB-S"]:
687 nim.configMode.value = "simple"
688 nim.configMode.save()
690 nim.diseqcMode = ConfigSelection(
692 ("single", _("Single")),
693 ("toneburst_a_b", _("Toneburst A/B")),
694 ("diseqc_a_b", _("DiSEqC A/B")),
695 ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")),
696 ("positioner", _("Positioner"))],
697 default = "diseqc_a_b")
698 nim.diseqcA = ConfigSatlist(default = 192, list = nimmgr.satList)
699 nim.diseqcB = ConfigSatlist(default = 130, list = nimmgr.satList)
700 nim.diseqcC = ConfigSatlist(list = nimmgr.satList)
701 nim.diseqcD = ConfigSatlist(list = nimmgr.satList)
702 nim.positionerMode = ConfigSelection(
704 ("usals", _("USALS")),
705 ("manual", _("manual"))],
707 nim.longitude = ConfigFloat(default=[5,100], limits=[(0,359),(0,999)])
708 nim.longitudeOrientation = ConfigSelection(choices={"east": _("East"), "west": _("West")}, default = "east")
709 nim.latitude = ConfigFloat(default=[50,767], limits=[(0,359),(0,999)])
710 nim.latitudeOrientation = ConfigSelection(choices={"north": _("North"), "south": _("South")}, default="north")
711 satNimList = nimmgr.getNimListOfType(nimmgr.nimType["DVB-S"], slot.slotid)
714 satNimListNames["Slot_" + ("A", "B", "C", "D")[x] + "_" + nimmgr.getNimName(x)] = _("Slot ") + ("A", "B", "C", "D")[x] + ": " + nimmgr.getNimName(x)
715 if len(satNimListNames):
716 nim.equalTo = ConfigSelection(choices = satNimListNames)
717 nim.linkedTo = ConfigSelection(choices = satNimListNames)
718 nim.satposDependsTo = ConfigSelection(choices = satNimListNames)
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 = ConfigSatlist(default = 192, list = nimmgr.satList)
731 nim.advanced.sat = ConfigSubDict()
732 lnbs = [("0", "not available")]
733 for y in range(1, 33):
734 lnbs.append((str(y), "LNB " + str(y)))
736 for x in nimmgr.satList:
737 nim.advanced.sat[x[0]] = ConfigSubsection()
738 nim.advanced.sat[x[0]].voltage = ConfigSelection(choices={"polarization": _("Polarization"), "13V": _("13 V"), "18V": _("18 V")}, default = "polarization")
739 nim.advanced.sat[x[0]].tonemode = ConfigSelection(choices={"band": _("Band"), "on": _("On"), "off": _("Off")}, default = "band")
740 nim.advanced.sat[x[0]].usals = ConfigYesNo(default=True)
741 nim.advanced.sat[x[0]].rotorposition = ConfigInteger(default=1, limits=(1, 255))
742 nim.advanced.sat[x[0]].lnb = ConfigSelection(choices = lnbs)
744 csw = [("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))]
745 for y in range(0, 16):
746 csw.append((str(0xF0|y), "Input " + str(y+1)))
748 ucsw = [("0", _("None"))]
749 for y in range(1, 17):
750 ucsw.append((str(y), "Input " + str(y)))
752 nim.advanced.lnb = ConfigSubList()
753 nim.advanced.lnb.append(ConfigNothing())
754 for x in range(1, 33):
755 nim.advanced.lnb.append(ConfigSubsection())
756 nim.advanced.lnb[x].lof = ConfigSelection(choices={"universal_lnb": _("Universal LNB"), "c_band": _("C-Band"), "user_defined": _("User defined")}, default="universal_lnb")
757 nim.advanced.lnb[x].lofl = ConfigInteger(default=9750, limits = (0, 99999))
758 nim.advanced.lnb[x].lofh = ConfigInteger(default=10600, limits = (0, 99999))
759 nim.advanced.lnb[x].threshold = ConfigInteger(default=11700, limits = (0, 99999))
760 nim.advanced.lnb[x].output_12v = ConfigSelection(choices = [("0V", _("0 V")), ("12V", _("12 V"))], default="0V")
761 nim.advanced.lnb[x].increased_voltage = ConfigYesNo(default=False)
762 nim.advanced.lnb[x].toneburst = ConfigSelection(choices = [("none", _("None")), ("A", _("A")), ("B", _("B"))], default = "none")
763 nim.advanced.lnb[x].diseqcMode = ConfigSelection(choices = [("none", _("None")), ("1_0", _("1.0")), ("1_1", _("1.1")), ("1_2", _("1.2"))], default = "none")
764 nim.advanced.lnb[x].commitedDiseqcCommand = ConfigSelection(choices = csw)
765 nim.advanced.lnb[x].fastDiseqc = ConfigYesNo(default=False)
766 nim.advanced.lnb[x].sequenceRepeat = ConfigYesNo(default=False)
767 nim.advanced.lnb[x].commandOrder1_0 = ConfigSelection(choices = [("ct", "committed, toneburst"), ("tc", "toneburst, committed")], default = "ct")
768 nim.advanced.lnb[x].commandOrder = ConfigSelection(choices = [
769 ("ct", "committed, toneburst"),
770 ("tc", "toneburst, committed"),
771 ("cut", "committed, uncommitted, toneburst"),
772 ("tcu", "toneburst, committed, uncommitted"),
773 ("uct", "uncommitted, committed, toneburst"),
774 ("tuc", "toneburst, uncommitted, commmitted")],
776 nim.advanced.lnb[x].uncommittedDiseqcCommand = ConfigSelection(choices = ucsw)
777 nim.advanced.lnb[x].diseqcRepeats = ConfigSelection(choices = [("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))], default = "none")
778 nim.advanced.lnb[x].longitude = ConfigFloat(default = [5,100], limits = [(0,359),(0,999)])
779 nim.advanced.lnb[x].longitudeOrientation = ConfigSelection(choices = [("east", _("East")), ("west", _("West"))], default = "east")
780 nim.advanced.lnb[x].latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)])
781 nim.advanced.lnb[x].latitudeOrientation = ConfigSelection(choices = [("north", _("North")), ("south", _("South"))], default = "north")
782 nim.advanced.lnb[x].powerMeasurement = ConfigYesNo(default=True)
783 nim.advanced.lnb[x].powerThreshold = ConfigInteger(default=50, limits=(0, 100))
785 elif slot.nimType == nimmgr.nimType["DVB-C"]:
786 nim.cable = ConfigSelection(choices = nimmgr.cablesList)
787 elif slot.nimType == nimmgr.nimType["DVB-T"]:
789 for x in nimmgr.terrestrialsList:
791 nim.terrestrial = ConfigSelection(choices = list)
792 nim.terrestrial_5V = ConfigOnOff()
794 print "pls add support for this frontend type!"
797 nimmgr.sec = SecConfigure(nimmgr)
800 nimmanager = NimManager()