1 from config import config, ConfigSubsection, ConfigSelection, ConfigFloat, ConfigSatlist, ConfigYesNo, ConfigInteger, ConfigSubList, ConfigNothing, ConfigSubDict, ConfigOnOff
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 getConfigSatlist(orbpos, satlist):
23 default_orbpos = orbpos
25 return ConfigSatlist(satlist, default_orbpos)
27 def tryOpen(filename):
29 procFile = open(filename)
35 def addLNBSimple(self, sec, slotid, diseqcmode, toneburstmode = 0, diseqcpos = 0, orbpos = 0, longitude = 0, latitude = 0, loDirection = 0, laDirection = 0):
38 tunermask = 1 << slotid
39 if self.equal.has_key(slotid):
40 tunermask |= (1 << self.equal[slotid])
41 elif self.linked.has_key(slotid):
42 tunermask |= (1 << self.linked[slotid])
43 sec.setLNBLOFL(9750000)
44 sec.setLNBLOFH(10600000)
45 sec.setLNBThreshold(11700000)
46 sec.setLNBIncreasedVoltage(lnbParam.OFF)
50 sec.setVoltageMode(switchParam.HV)
51 sec.setToneMode(switchParam.HILO)
52 sec.setCommandOrder(0)
55 sec.setDiSEqCMode(diseqcmode)
56 sec.setToneburst(toneburstmode)
57 sec.setCommittedCommand(diseqcpos)
58 #print "set orbpos to:" + str(orbpos)
60 if (0 <= diseqcmode < 3):
61 sec.addSatellite(orbpos)
62 self.satList.append(orbpos)
63 elif (diseqcmode == 3): # diseqc 1.2
64 if self.satposdepends.has_key(slotid):
65 tunermask |= (1 << self.satposdepends[slotid])
66 sec.setLatitude(latitude)
67 sec.setLaDirection(laDirection)
68 sec.setLongitude(longitude)
69 sec.setLoDirection(loDirection)
70 sec.setUseInputpower(True)
71 sec.setInputpowerDelta(50)
73 for x in self.NimManager.satList:
74 print "Add sat " + str(x[0])
75 sec.addSatellite(int(x[0]))
78 sec.setRotorPosNum(0) # USALS
79 self.satList.append(int(x[0]))
81 sec.setLNBTunerMask(tunermask)
83 def setSatposDepends(self, sec, nim1, nim2):
84 print "tuner", nim1, "depends on satpos of", nim2
85 sec.setTunerDepends(nim1, nim2)
87 def linkNIMs(self, sec, nim1, nim2):
88 print "link tuner", nim1, "to tuner", nim2
89 sec.setTunerLinked(nim1, nim2)
95 sec = eDVBSatelliteEquipmentControl.getInstance()
96 sec.clear() ## this do unlinking NIMs too !!
97 print "sec config cleared"
101 self.satposdepends = { }
103 for slot in self.NimManager.nimslots:
106 if slot.nimType == self.NimManager.nimType["DVB-S"]:
107 if nim.configMode.value == "equal":
108 self.equal[nim.equalTo.index]=x
109 if nim.configMode.value == "loopthrough":
110 self.linkNIMs(sec, x, nim.linkedTo.index)
111 self.linked[nim.linkedTo.index]=x
112 elif nim.configMode.value == "satposdepends":
113 self.setSatposDepends(sec, x, nim.satposDependsTo.index)
114 self.satposdepends[nim.satposDependsTo.index]=x
116 for slot in self.NimManager.nimslots:
119 if slot.nimType == self.NimManager.nimType["DVB-S"]:
120 print "slot: " + str(x) + " configmode: " + str(nim.configMode.value)
121 print "diseqcmode: ", nim.configMode.value
122 if nim.configMode.value in [ "loopthrough", "satposdepends", "equal", "nothing" ]:
124 elif nim.configMode.value == "simple": #simple config
125 if nim.diseqcMode.value == "single": #single
126 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.NONE, diseqcpos = diseqcParam.SENDNO)
127 elif nim.diseqcMode.value == "toneburst_a_b": #Toneburst A/B
128 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.A, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO)
129 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.B, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO)
130 elif nim.diseqcMode.value == "diseqc_a_b": #DiSEqC A/B
131 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA)
132 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB)
133 elif nim.diseqcMode.value == "diseqc_a_b_c_d": #DiSEqC A/B/C/D
134 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA)
135 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB)
136 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcC.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BA)
137 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcD.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BB)
138 elif nim.diseqcMode.value == "positioner": #Positioner
139 if nim.latitudeOrientation.value == "north":
140 laValue = rotorParam.NORTH
142 laValue = rotorParam.SOUTH
143 if nim.longitudeOrientation.value == "east":
144 loValue = rotorParam.EAST
146 loValue = rotorParam.WEST
147 self.addLNBSimple(sec, slotid = x, diseqcmode = 3,
148 longitude = nim.longitude.float,
149 loDirection = loValue,
150 latitude = nim.latitude.float,
151 laDirection = laValue)
152 elif nim.configMode.value == "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 = int(config.Nims[slotid].advanced.sat[x[0]].lnb.value)
163 print "add", x[0], "to", lnb
164 lnbSat[lnb].append(x[0])
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 currLnb.lof.value == "universal_lnb":
177 sec.setLNBLOFL(9750000)
178 sec.setLNBLOFH(10600000)
179 sec.setLNBThreshold(11700000)
180 elif currLnb.lof.value == "c_band":
181 sec.setLNBLOFL(5150000)
182 sec.setLNBLOFH(5150000)
183 sec.setLNBThreshold(5150000)
184 elif currLnb.lof.value == "user_defined":
185 sec.setLNBLOFL(currLnb.lofl.value * 1000)
186 sec.setLNBLOFH(currLnb.lofh.value * 1000)
187 sec.setLNBThreshold(currLnb.threshold.value * 1000)
189 if currLnb.output_12v.value == "0V":
190 pass # nyi in drivers
191 elif currLnb.output_12v.value == "12V":
192 pass # nyi in drivers
194 if currLnb.increased_voltage.value:
195 sec.setLNBIncreasedVoltage(lnbParam.ON)
197 sec.setLNBIncreasedVoltage(lnbParam.OFF)
199 dm = currLnb.diseqcMode.value
201 sec.setDiSEqCMode(diseqcParam.NONE)
203 sec.setDiSEqCMode(diseqcParam.V1_0)
205 sec.setDiSEqCMode(diseqcParam.V1_1)
207 sec.setDiSEqCMode(diseqcParam.V1_2)
209 if self.satposdepends.has_key(slotid): # only useable with rotors
210 tunermask |= (1 << self.satposdepends[slotid])
213 if currLnb.toneburst.value == "none":
214 sec.setToneburst(diseqcParam.NO)
215 elif currLnb.toneburst.value == "A":
216 sec.setToneburst(diseqcParam.A)
217 elif currLnb.toneburst.value == "B":
218 sec.setToneburst(diseqcParam.B)
220 # Committed Diseqc Command
221 cdc = currLnb.commitedDiseqcCommand.value
223 c = { "none": diseqcParam.SENDNO,
224 "AA": diseqcParam.AA,
225 "AB": diseqcParam.AB,
226 "BA": diseqcParam.BA,
227 "BB": diseqcParam.BB }
230 sec.setCommittedCommand(c[cdc])
232 sec.setCommittedCommand(long(cdc))
234 sec.setFastDiSEqC(currLnb.fastDiseqc.value)
236 sec.setSeqRepeat(currLnb.sequenceRepeat.value)
238 if currLnb.diseqcMode.value == "1_0":
239 currCO = currLnb.commandOrder1_0.value
241 currCO = currLnb.commandOrder.value
243 udc = int(currLnb.uncommittedDiseqcCommand.value)
245 sec.setUncommittedCommand(0xF0|(udc-1))
247 sec.setUncommittedCommand(0) # SENDNO
249 sec.setRepeats({"none": 0, "one": 1, "two": 2, "three": 3}[currLnb.diseqcRepeats.value])
251 setCommandOrder = False
253 # 0 "committed, toneburst",
254 # 1 "toneburst, committed",
255 # 2 "committed, uncommitted, toneburst",
256 # 3 "toneburst, committed, uncommitted",
257 # 4 "uncommitted, committed, toneburst"
258 # 5 "toneburst, uncommitted, commmitted"
259 order_map = {"ct": 0, "tc": 1, "cut": 2, "tcu": 3, "uct": 4, "tuc": 5}
260 sec.setCommandOrder(order_map[currCO])
263 latitude = currLnb.latitude.float
264 sec.setLatitude(latitude)
265 longitude = currLnb.longitude.float
266 sec.setLongitude(longitude)
267 if currLnb.latitudeOrientation.value == "north":
268 sec.setLaDirection(rotorParam.NORTH)
270 sec.setLaDirection(rotorParam.SOUTH)
271 if currLnb.longitudeOrientation.value == "east":
272 sec.setLoDirection(rotorParam.EAST)
274 sec.setLoDirection(rotorParam.WEST)
276 if currLnb.powerMeasurement.value:
277 sec.setUseInputpower(True)
278 sec.setInputpowerDelta(currLnb.powerThreshold.value)
280 sec.setUseInputpower(False)
282 sec.setLNBTunerMask(tunermask)
284 # finally add the orbital positions
287 currSat = config.Nims[slotid].advanced.sat[y]
289 if currSat.voltage.value == "polarization":
290 sec.setVoltageMode(switchParam.HV)
291 elif currSat.voltage.value == "13V":
292 sec.setVoltageMode(switchParam._14V)
293 elif currSat.voltage.value == "18V":
294 sec.setVoltageMode(switchParam._18V)
296 if currSat.tonemode == "band":
297 sec.setToneMode(switchParam.HILO)
298 elif currSat.tonemode == "on":
299 sec.setToneMode(switchParam.ON)
300 elif currSat.tonemode == "off":
301 sec.setToneMode(switchParam.OFF)
303 if not currSat.usals.value:
304 sec.setRotorPosNum(currSat.rotorposition.value)
306 sec.setRotorPosNum(0) #USALS
308 def __init__(self, nimmgr):
309 self.NimManager = nimmgr
313 def __init__(self, slotid, nimtype, name):
315 self.nimType = nimtype
319 class parseSats(ContentHandler):
320 def __init__(self, satList, satellites, transponders):
321 self.isPointsElement, self.isReboundsElement = 0, 0
322 self.satList = satList
323 self.satellites = satellites
324 self.transponders = transponders
326 def startElement(self, name, attrs):
328 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
329 tpos = int(attrs.get('position',""))
332 tname = attrs.get('name',"").encode("UTF-8")
333 self.satellites[tpos] = tname
334 self.satList.append( (tpos, tname) )
335 self.parsedSat = int(tpos)
336 elif (name == "transponder"):
337 modulation = int(attrs.get('modulation',"1")) # QPSK default
338 system = int(attrs.get('system',"0")) # DVB-S default
339 freq = int(attrs.get('frequency',""))
340 sr = int(attrs.get('symbol_rate',""))
341 pol = int(attrs.get('polarization',""))
342 fec = int(attrs.get('fec_inner',"0")) # AUTO default
343 if self.parsedSat in self.transponders:
346 self.transponders[self.parsedSat] = [ ]
348 self.transponders[self.parsedSat].append((0, freq, sr, pol, fec, system, modulation))
350 class parseCables(ContentHandler):
351 def __init__(self, cablesList, transponders):
352 self.isPointsElement, self.isReboundsElement = 0, 0
353 self.cablesList = cablesList
354 self.transponders = transponders
356 def startElement(self, name, attrs):
357 if (name == "cable"):
358 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
359 tname = attrs.get('name',"").encode("UTF-8")
360 self.cablesList.append(str(tname))
361 self.parsedCab = str(tname)
362 elif (name == "transponder"):
363 freq = int(attrs.get('frequency',""))
364 #sr = int(attrs.get('symbol_rate',""))
365 #mod = int(attrs.get('modulation',"3")) # QAM64 default
366 #fec = int(attrs.get('fec_inner',"0")) # AUTO default
367 if self.parsedCab in self.transponders:
370 self.transponders[self.parsedCab] = [ ]
371 self.transponders[self.parsedCab].append((1, freq))
373 class parseTerrestrials(ContentHandler):
374 def __init__(self, terrestrialsList, transponders):
375 self.isPointsElement, self.isReboundsElement = 0, 0
376 self.terrestrialsList = terrestrialsList
377 self.transponders = transponders
379 def startElement(self, name, attrs):
380 if (name == "terrestrial"):
381 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
382 tname = attrs.get('name',"").encode("UTF-8")
383 tflags = attrs.get('flags',"")
384 self.terrestrialsList.append((tname, tflags))
385 self.parsedTer = str(tname)
386 elif (name == "transponder"):
388 freq = int(attrs.get('centre_frequency',""))
389 bw = int(attrs.get('bandwidth',"3")) # AUTO
390 const = int(attrs.get('constellation',"1")) # AUTO
391 crh = int(attrs.get('code_rate_hp',"5")) # AUTO
392 if crh > 5: # our terrestrial.xml is buggy... 6 for AUTO
394 crl = int(attrs.get('code_rate_lp',"5")) # AUTO
395 if crl > 5: # our terrestrial.xml is buggy... 6 for AUTO
397 guard = int(attrs.get('guard_interval',"4")) # AUTO
398 transm = int(attrs.get('transmission_mode',"2")) # AUTO
399 hierarchy = int(attrs.get('hierarchy_information',"4")) # AUTO
400 inv = int(attrs.get('inversion',"2")) # AUTO
401 if self.parsedTer in self.transponders:
404 self.transponders[self.parsedTer] = [ ]
406 self.transponders[self.parsedTer].append((2, freq, bw, const, crh, crl, guard, transm, hierarchy, inv))
408 def getTransponders(self, pos):
409 if self.transponders.has_key(pos):
410 return self.transponders[pos]
414 def getTranspondersCable(self, cable):
415 return self.transponderscable[cable]
417 def getTranspondersTerrestrial(self, region):
418 return self.transpondersterrestrial[region]
420 def getCableDescription(self, nim):
421 return self.cablesList[0]
423 def getCableTrustNit(self, nim):
424 return config.Nims[nim].cabletype.value == "quick"
426 def getTerrestrialDescription(self, nim):
427 return self.terrestrialsList[config.Nims[nim].terrestrial.index][0]
429 def getTerrestrialFlags(self, nim):
430 return self.terrestrialsList[config.Nims[nim].terrestrial.index][1]
432 def getConfiguredSats(self):
433 return self.sec.getSatList()
435 def getSatDescription(self, pos):
436 return self.satellites[pos]
438 def readSatsfromFile(self):
439 self.satellites = { }
440 self.transponders = { }
441 self.transponderscable = { }
442 self.transpondersterrestrial = { }
444 parser = make_parser()
445 if (self.hasNimType(self.nimType["DVB-S"])):
446 print "Reading satellites.xml"
447 satHandler = self.parseSats(self.satList, self.satellites, self.transponders)
448 parser.setContentHandler(satHandler)
449 parser.parse('/etc/tuxbox/satellites.xml')
450 if (self.hasNimType(self.nimType["DVB-C"])):
451 print "Reading cables.xml"
452 cabHandler = self.parseCables(self.cablesList, self.transponderscable)
453 parser.setContentHandler(cabHandler)
454 parser.parse('/etc/tuxbox/cables.xml')
456 if (self.hasNimType(self.nimType["DVB-T"])):
457 print "Reading terrestrial.xml"
458 terHandler = self.parseTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
459 parser.setContentHandler(terHandler)
460 parser.parse('/etc/tuxbox/terrestrial.xml')
465 self.nimSocketCount = 0
466 nimfile = tryOpen("/proc/bus/nim_sockets")
469 return self.nimType["empty/unknown"]
474 line = nimfile.readline()
477 if line.strip().startswith("NIM Socket"):
478 parts = line.strip().split(" ")
479 id = int(parts[2][:1])
481 self.nimSocketCount += 1
482 elif line.strip().startswith("Type:"):
483 self.nimTypes[lastsocket] = str(line.strip()[6:])
484 #self.nimTypes[lastsocket] = str("DVB-T")
485 elif line.strip().startswith("Name:"):
486 self.nimNames[lastsocket] = str(line.strip()[6:])
487 elif line.strip().startswith("empty"):
488 self.nimNames[lastsocket] = _("N/A")
489 self.nimTypes[lastsocket] = "empty/unknown"
493 def getNimType(self, slotID):
494 if slotID >= self.nimCount:
495 return self.nimType["empty/unknown"]
497 return self.nimType[self.nimTypes[slotID]]
499 def getNimTypeName(self, slotID):
500 if slotID >= self.nimCount:
501 return "empty/unknown"
503 return self.nimTypes[slotID]
505 def getNimName(self, slotID):
506 return self.nimNames[slotID]
508 def getNimSocketCount(self):
509 return self.nimSocketCount
511 def hasNimType(self, chktype):
512 for id, type in self.nimTypes.items():
513 if (chktype == self.nimType[str(type)]):
517 def getNimListOfType(self, type, exception = -1):
519 for x in self.nimslots:
520 if ((x.nimType == type) and (x.slotid != exception)):
521 list.append(x.slotid)
524 def getConfigPrefix(self, slotid):
525 return "config.Nim" + ("A","B","C","D")[slotid] + "."
529 self.nimType = { "empty/unknown": -1,
535 self.terrestrialsList = []
539 self.readSatsfromFile()
541 self.nimCount = self.getNimSocketCount()
545 while x < self.nimCount:
546 tType = self.getNimType(x)
547 tName = self.getNimName(x)
548 tNim = nimSlot(x, tType, tName)
549 self.nimslots.append(tNim)
552 InitNimManager(self) #init config stuff
556 for slot in self.nimslots:
557 nimText = _("Socket ") + ("A", "B", "C", "D")[slot.slotid] + ": "
558 if slot.nimType == -1:
559 nimText += _("empty/unknown")
561 nimText += slot.name + " ("
562 nimText += ("DVB-S", "DVB-C", "DVB-T")[slot.nimType] + ")"
563 list.append((nimText, slot))
566 def getNimConfigMode(self, slotid):
567 return config.Nims[slotid].configMode.value
569 def getSatList(self):
572 def getSatListForNim(self, slotid):
574 if (self.getNimType(slotid) == self.nimType["DVB-S"]):
575 #print "slotid:", slotid
577 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
578 #print "diseqcA:", config.Nims[slotid].diseqcA.value
579 configMode = config.Nims[slotid].configMode.value
581 if configMode == "equal":
582 slotid=0 #FIXME add handling for more than two tuners !!!
583 configMode = config.Nims[slotid].configMode.value
585 if configMode == "simple":
586 dm = config.Nims[slotid].diseqcMode.value
587 if dm in ["single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
588 list.append(self.satList[config.Nims[slotid].diseqcA.index])
589 if dm in ["toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
590 list.append(self.satList[config.Nims[slotid].diseqcB.index])
591 if dm == "diseqc_a_b_c_d":
592 list.append(self.satList[config.Nims[slotid].diseqcC.index])
593 list.append(self.satList[config.Nims[slotid].diseqcD.index])
594 if dm == "positioner":
595 for x in self.satList:
597 elif configMode == "advanced":
598 for x in self.satList:
599 if int(config.Nims[slotid].advanced.sat[x[0]].lnb.value) != 0:
604 def getRotorSatListForNim(self, slotid):
606 if (self.getNimType(slotid) == self.nimType["DVB-S"]):
607 #print "slotid:", slotid
609 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
610 #print "diseqcA:", config.Nims[slotid].diseqcA.value
611 configMode = config.Nims[slotid].configMode.value
612 if configMode == "simple":
613 if config.Nims[slotid].diseqcMode.value == "positioner":
614 for x in self.satList:
616 elif configMode == "advanced":
617 for x in self.satList:
618 nim = config.Nims[slotid]
619 lnbnum = int(nim.advanced.sat[x[0]].lnb.value)
621 lnb = nim.advanced.lnb[lnbnum]
622 if lnb.diseqcMode.value == "1_2":
626 def nimDiseqcModeChanged(self, slotid, mode):
627 #print "nimDiseqcModeChanged set to " + str(mode)
629 def nimPortAChanged(self, slotid, val):
630 #print "nimDiseqcA set to " + str(slotid) + " val:" + str(val)
632 def nimPortBChanged(self, slotid, val):
633 #print "nimDiseqcA set to " + str(slotid) + " val:" + str(val)
634 #print "nimDiseqcB set to " + str(val)
636 def nimPortCChanged(self, slotid, val):
637 #print "nimDiseqcC set to " + str(val)
639 def nimPortDChanged(self, slotid, val):
640 #print "nimDiseqcD set to " + str(val)
643 def InitNimManager(nimmgr):
644 config.Nims = ConfigSubList()
645 for x in range(nimmgr.nimCount):
646 config.Nims.append(ConfigSubsection())
648 # def nimConfigModeChanged(slotid, configElement):
649 # nimmgr.nimConfigModeChanged(slotid, configElement.value)
650 def nimDiseqcModeChanged(slotid, configElement):
651 nimmgr.nimDiseqcModeChanged(slotid, configElement.value)
653 def nimPortAChanged(slotid, configElement):
654 nimmgr.nimPortAChanged(slotid, configElement.value)
655 def nimPortBChanged(slotid, configElement):
656 nimmgr.nimPortBChanged(slotid, configElement.value)
657 def nimPortCChanged(slotid, configElement):
658 nimmgr.nimPortCChanged(slotid, configElement.value)
659 def nimPortDChanged(slotid, configElement):
660 nimmgr.nimPortDChanged(slotid, configElement.value)
662 for slot in nimmgr.nimslots:
664 cname = nimmgr.getConfigPrefix(x)
667 if slot.nimType == nimmgr.nimType["DVB-S"]:
669 nim.configMode = ConfigSelection(
671 "simple": _("simple"),
672 "advanced": _("advanced")},
675 nim.configMode = ConfigSelection(
677 "equal": _("equal to Socket A"),
678 "loopthrough": _("loopthrough to socket A"),
679 "nothing": _("nothing connected"),
680 "satposdepends": _("second cable of motorized LNB"),
681 "simple": _("simple"),
682 "advanced": _("advanced")},
683 default = "loopthrough")
685 #important - check if just the 2nd one is LT only and the first one is DVB-S
686 if nim.configMode.value in ["loopthrough", "satposdepends", "equal"]:
687 if x == 0: # first one can never be linked to anything
689 nim.configMode.value = "simple"
690 nim.configMode.save()
692 #FIXME: make it better
693 for y in nimmgr.nimslots:
695 if y.nimType != nimmgr.nimType["DVB-S"]:
697 nim.configMode.value = "simple"
698 nim.configMode.save()
700 nim.diseqcMode = ConfigSelection(
702 ("single", _("Single")),
703 ("toneburst_a_b", _("Toneburst A/B")),
704 ("diseqc_a_b", _("DiSEqC A/B")),
705 ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")),
706 ("positioner", _("Positioner"))],
707 default = "diseqc_a_b")
709 nim.diseqcA = getConfigSatlist(192, nimmgr.satList)
710 nim.diseqcB = getConfigSatlist(130, nimmgr.satList)
711 nim.diseqcC = ConfigSatlist(list = nimmgr.satList)
712 nim.diseqcD = ConfigSatlist(list = nimmgr.satList)
713 nim.positionerMode = ConfigSelection(
715 ("usals", _("USALS")),
716 ("manual", _("manual"))],
718 nim.longitude = ConfigFloat(default=[5,100], limits=[(0,359),(0,999)])
719 nim.longitudeOrientation = ConfigSelection(choices={"east": _("East"), "west": _("West")}, default = "east")
720 nim.latitude = ConfigFloat(default=[50,767], limits=[(0,359),(0,999)])
721 nim.latitudeOrientation = ConfigSelection(choices={"north": _("North"), "south": _("South")}, default="north")
722 satNimList = nimmgr.getNimListOfType(nimmgr.nimType["DVB-S"], slot.slotid)
725 satNimListNames["Slot_" + ("A", "B", "C", "D")[x] + "_" + nimmgr.getNimName(x)] = _("Slot ") + ("A", "B", "C", "D")[x] + ": " + nimmgr.getNimName(x)
726 if len(satNimListNames):
727 nim.equalTo = ConfigSelection(choices = satNimListNames)
728 nim.linkedTo = ConfigSelection(choices = satNimListNames)
729 nim.satposDependsTo = ConfigSelection(choices = satNimListNames)
731 #perhaps the instance of the slot is more useful?
732 # nim.configMode.addNotifier(boundFunction(nimConfigModeChanged,x))
733 nim.diseqcMode.addNotifier(boundFunction(nimDiseqcModeChanged,x))
734 nim.diseqcA.addNotifier(boundFunction(nimPortAChanged,int(x)))
735 nim.diseqcB.addNotifier(boundFunction(nimPortBChanged,x))
736 nim.diseqcC.addNotifier(boundFunction(nimPortCChanged,x))
737 nim.diseqcD.addNotifier(boundFunction(nimPortDChanged,x))
740 nim.advanced = ConfigSubsection()
741 nim.advanced.sats = getConfigSatlist(192,nimmgr.satList)
742 nim.advanced.sat = ConfigSubDict()
743 lnbs = [("0", "not available")]
744 for y in range(1, 33):
745 lnbs.append((str(y), "LNB " + str(y)))
747 for x in nimmgr.satList:
748 nim.advanced.sat[x[0]] = ConfigSubsection()
749 nim.advanced.sat[x[0]].voltage = ConfigSelection(choices={"polarization": _("Polarization"), "13V": _("13 V"), "18V": _("18 V")}, default = "polarization")
750 nim.advanced.sat[x[0]].tonemode = ConfigSelection(choices={"band": _("Band"), "on": _("On"), "off": _("Off")}, default = "band")
751 nim.advanced.sat[x[0]].usals = ConfigYesNo(default=True)
752 nim.advanced.sat[x[0]].rotorposition = ConfigInteger(default=1, limits=(1, 255))
753 nim.advanced.sat[x[0]].lnb = ConfigSelection(choices = lnbs)
755 csw = [("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))]
756 for y in range(0, 16):
757 csw.append((str(0xF0|y), "Input " + str(y+1)))
759 ucsw = [("0", _("None"))]
760 for y in range(1, 17):
761 ucsw.append((str(y), "Input " + str(y)))
763 nim.advanced.lnb = ConfigSubList()
764 nim.advanced.lnb.append(ConfigNothing())
765 for x in range(1, 33):
766 nim.advanced.lnb.append(ConfigSubsection())
767 nim.advanced.lnb[x].lof = ConfigSelection(choices={"universal_lnb": _("Universal LNB"), "c_band": _("C-Band"), "user_defined": _("User defined")}, default="universal_lnb")
768 nim.advanced.lnb[x].lofl = ConfigInteger(default=9750, limits = (0, 99999))
769 nim.advanced.lnb[x].lofh = ConfigInteger(default=10600, limits = (0, 99999))
770 nim.advanced.lnb[x].threshold = ConfigInteger(default=11700, limits = (0, 99999))
771 nim.advanced.lnb[x].output_12v = ConfigSelection(choices = [("0V", _("0 V")), ("12V", _("12 V"))], default="0V")
772 nim.advanced.lnb[x].increased_voltage = ConfigYesNo(default=False)
773 nim.advanced.lnb[x].toneburst = ConfigSelection(choices = [("none", _("None")), ("A", _("A")), ("B", _("B"))], default = "none")
774 nim.advanced.lnb[x].diseqcMode = ConfigSelection(choices = [("none", _("None")), ("1_0", _("1.0")), ("1_1", _("1.1")), ("1_2", _("1.2"))], default = "none")
775 nim.advanced.lnb[x].commitedDiseqcCommand = ConfigSelection(choices = csw)
776 nim.advanced.lnb[x].fastDiseqc = ConfigYesNo(default=False)
777 nim.advanced.lnb[x].sequenceRepeat = ConfigYesNo(default=False)
778 nim.advanced.lnb[x].commandOrder1_0 = ConfigSelection(choices = [("ct", "committed, toneburst"), ("tc", "toneburst, committed")], default = "ct")
779 nim.advanced.lnb[x].commandOrder = ConfigSelection(choices = [
780 ("ct", "committed, toneburst"),
781 ("tc", "toneburst, committed"),
782 ("cut", "committed, uncommitted, toneburst"),
783 ("tcu", "toneburst, committed, uncommitted"),
784 ("uct", "uncommitted, committed, toneburst"),
785 ("tuc", "toneburst, uncommitted, commmitted")],
787 nim.advanced.lnb[x].uncommittedDiseqcCommand = ConfigSelection(choices = ucsw)
788 nim.advanced.lnb[x].diseqcRepeats = ConfigSelection(choices = [("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))], default = "none")
789 nim.advanced.lnb[x].longitude = ConfigFloat(default = [5,100], limits = [(0,359),(0,999)])
790 nim.advanced.lnb[x].longitudeOrientation = ConfigSelection(choices = [("east", _("East")), ("west", _("West"))], default = "east")
791 nim.advanced.lnb[x].latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)])
792 nim.advanced.lnb[x].latitudeOrientation = ConfigSelection(choices = [("north", _("North")), ("south", _("South"))], default = "north")
793 nim.advanced.lnb[x].powerMeasurement = ConfigYesNo(default=True)
794 nim.advanced.lnb[x].powerThreshold = ConfigInteger(default=50, limits=(0, 100))
796 elif slot.nimType == nimmgr.nimType["DVB-C"]:
797 nim.cabletype = ConfigSelection(choices = [("quick", _("Quick")), ("complete", _("Complete"))], default = "complete")
798 elif slot.nimType == nimmgr.nimType["DVB-T"]:
801 for x in nimmgr.terrestrialsList:
802 list.append((str(n), x[0]))
804 nim.terrestrial = ConfigSelection(choices = list)
805 nim.terrestrial_5V = ConfigOnOff()
807 print "pls add support for this frontend type!"
810 nimmgr.sec = SecConfigure(nimmgr)
813 nimmanager = NimManager()