1 from config import config, ConfigSubsection, ConfigSelection, ConfigFloat, ConfigSatlist, ConfigYesNo, ConfigInteger, ConfigSubList, ConfigDummy, 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
216 ("none", diseqcParam.SENDNO),
217 ("AA", diseqcParam.AA),
218 ("AB", diseqcParam.AB),
219 ("BA", diseqcParam.BA),
220 ("BB", diseqcParam.BB)]
223 sec.setCommittedCommand(c[cdc])
225 sec.setCommittedCommand(long(cdc))
227 sec.setFastDiSEqC(currLnb.fastDiseqc.value)
229 sec.setSeqRepeat(currLnb.sequenceRepeat.value)
231 if currLnb.diseqcMode.value == "1_0":
232 currCO = currLnb.commandOrder1_0.value
234 currCO = currLnb.commandOrder.value
236 udc = int(currLnb.uncommittedDiseqcCommand.value)
238 sec.setUncommittedCommand(0xF0|(udc-1))
240 sec.setUncommittedCommand(0) # SENDNO
242 sec.setRepeats({"none": 0, "one": 1, "two": 2, "three": 3}[currLnb.diseqcRepeats.value])
244 setCommandOrder = False
246 # 0 "committed, toneburst",
247 # 1 "toneburst, committed",
248 # 2 "committed, uncommitted, toneburst",
249 # 3 "toneburst, committed, uncommitted",
250 # 4 "uncommitted, committed, toneburst"
251 # 5 "toneburst, uncommitted, commmitted"
252 order_map = {"ct": 0, "tc": 1, "cut": 2, "tcu": 3, "uct": 4, "tuc": 5}
253 sec.setCommandOrder(order_map[currCO])
256 latitude = currLnb.latitude.float
257 sec.setLatitude(latitude)
258 longitude = currLnb.longitude.float
259 sec.setLongitude(longitude)
260 if currLnb.latitudeOrientation.value == "north":
261 sec.setLaDirection(rotorParam.NORTH)
263 sec.setLaDirection(rotorParam.SOUTH)
264 if currLnb.longitudeOrientation.value == "east":
265 sec.setLoDirection(rotorParam.EAST)
267 sec.setLoDirection(rotorParam.WEST)
269 if currLnb.powerMeasurement.value:
270 sec.setUseInputpower(True)
271 sec.setInputpowerDelta(currLnb.powerThreshold.value)
273 sec.setUseInputpower(False)
275 sec.setLNBTunerMask(tunermask)
277 # finally add the orbital positions
280 currSat = config.Nims[slotid].advanced.sat[y]
282 if currSat.voltage.value == "polarization":
283 sec.setVoltageMode(switchParam.HV)
284 elif currSat.voltage.value == "13V":
285 sec.setVoltageMode(switchParam._14V)
286 elif currSat.voltage.value == "18V":
287 sec.setVoltageMode(switchParam._18V)
289 if currSat.tonemode == "band":
290 sec.setToneMode(switchParam.HILO)
291 elif currSat.tonemode == "on":
292 sec.setToneMode(switchParam.ON)
293 elif currSat.tonemode == "off":
294 sec.setToneMode(switchParam.OFF)
296 if not currSat.usals.value:
297 sec.setRotorPosNum(currSat.rotorposition.value)
299 sec.setRotorPosNum(0) #USALS
301 def __init__(self, nimmgr):
302 self.NimManager = nimmgr
306 def __init__(self, slotid, nimtype, name):
308 self.nimType = nimtype
312 class parseSats(ContentHandler):
313 def __init__(self, satList, satellites, transponders):
314 self.isPointsElement, self.isReboundsElement = 0, 0
315 self.satList = satList
316 self.satellites = satellites
317 self.transponders = transponders
319 def startElement(self, name, attrs):
321 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
322 tpos = int(attrs.get('position',""))
325 tname = attrs.get('name',"").encode("UTF-8")
326 self.satellites[tpos] = tname
327 self.satList.append( (tpos, tname) )
328 self.parsedSat = int(tpos)
329 elif (name == "transponder"):
330 modulation = int(attrs.get('modulation',"1")) # QPSK default
331 system = int(attrs.get('system',"0")) # DVB-S default
332 freq = int(attrs.get('frequency',""))
333 sr = int(attrs.get('symbol_rate',""))
334 pol = int(attrs.get('polarization',""))
335 fec = int(attrs.get('fec_inner',"0")) # AUTO default
336 if self.parsedSat in self.transponders:
339 self.transponders[self.parsedSat] = [ ]
341 self.transponders[self.parsedSat].append((0, freq, sr, pol, fec, system, modulation))
343 class parseCables(ContentHandler):
344 def __init__(self, cablesList, transponders):
345 self.isPointsElement, self.isReboundsElement = 0, 0
346 self.cablesList = cablesList
347 self.transponders = transponders
349 def startElement(self, name, attrs):
350 if (name == "cable"):
351 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
352 tname = attrs.get('name',"").encode("UTF-8")
353 self.cablesList.append(str(tname))
354 self.parsedCab = str(tname)
355 elif (name == "transponder"):
356 freq = int(attrs.get('frequency',""))
357 sr = int(attrs.get('symbol_rate',""))
358 mod = int(attrs.get('modulation',"3")) # QAM64 default
359 fec = int(attrs.get('fec_inner',"0")) # AUTO default
360 if self.parsedCab in self.transponders:
363 self.transponders[self.parsedCab] = [ ]
364 self.transponders[self.parsedCab].append((1, freq, sr, mod, fec))
366 class parseTerrestrials(ContentHandler):
367 def __init__(self, terrestrialsList, transponders):
368 self.isPointsElement, self.isReboundsElement = 0, 0
369 self.terrestrialsList = terrestrialsList
370 self.transponders = transponders
372 def startElement(self, name, attrs):
373 if (name == "terrestrial"):
374 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
375 tname = attrs.get('name',"").encode("UTF-8")
376 tflags = attrs.get('flags',"")
377 self.terrestrialsList.append((tname, tflags))
378 self.parsedTer = str(tname)
379 elif (name == "transponder"):
381 freq = int(attrs.get('centre_frequency',""))
382 bw = int(attrs.get('bandwidth',"3")) # AUTO
383 const = int(attrs.get('constellation',"1")) # AUTO
384 crh = int(attrs.get('code_rate_hp',"5")) # AUTO
385 if crh > 5: # our terrestrial.xml is buggy... 6 for AUTO
387 crl = int(attrs.get('code_rate_lp',"5")) # AUTO
388 if crl > 5: # our terrestrial.xml is buggy... 6 for AUTO
390 guard = int(attrs.get('guard_interval',"4")) # AUTO
391 transm = int(attrs.get('transmission_mode',"2")) # AUTO
392 hierarchy = int(attrs.get('hierarchy_information',"4")) # AUTO
393 inv = int(attrs.get('inversion',"2")) # AUTO
394 if self.parsedTer in self.transponders:
397 self.transponders[self.parsedTer] = [ ]
399 self.transponders[self.parsedTer].append((2, freq, bw, const, crh, crl, guard, transm, hierarchy, inv))
401 def getTransponders(self, pos):
402 if self.transponders.has_key(pos):
403 return self.transponders[pos]
407 def getTranspondersCable(self, cable):
408 return self.transponderscable[cable]
410 def getTranspondersTerrestrial(self, region):
411 return self.transpondersterrestrial[region]
413 def getCableDescription(self, nim):
414 return self.cablesList[config.Nims[nim].cable.value]
416 def getTerrestrialDescription(self, nim):
417 return self.terrestrialsList[config.Nims[nim].terrestrial.value][0]
419 def getTerrestrialFlags(self, nim):
420 return self.terrestrialsList[config.Nims[nim].terrestrial.value][1]
422 def getConfiguredSats(self):
423 return self.sec.getSatList()
425 def getSatDescription(self, pos):
426 return self.satellites[pos]
428 def readSatsfromFile(self):
429 self.satellites = { }
430 self.transponders = { }
431 self.transponderscable = { }
432 self.transpondersterrestrial = { }
434 parser = make_parser()
435 if (self.hasNimType(self.nimType["DVB-S"])):
436 print "Reading satellites.xml"
437 satHandler = self.parseSats(self.satList, self.satellites, self.transponders)
438 parser.setContentHandler(satHandler)
439 parser.parse('/etc/tuxbox/satellites.xml')
440 if (self.hasNimType(self.nimType["DVB-C"])):
441 print "Reading cables.xml"
442 cabHandler = self.parseCables(self.cablesList, self.transponderscable)
443 parser.setContentHandler(cabHandler)
444 parser.parse('/etc/tuxbox/cables.xml')
446 if (self.hasNimType(self.nimType["DVB-T"])):
447 print "Reading terrestrial.xml"
448 terHandler = self.parseTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
449 parser.setContentHandler(terHandler)
450 parser.parse('/etc/tuxbox/terrestrial.xml')
455 self.nimSocketCount = 0
456 nimfile = tryOpen("/proc/bus/nim_sockets")
459 return self.nimType["empty/unknown"]
464 line = nimfile.readline()
467 if line.strip().startswith("NIM Socket"):
468 parts = line.strip().split(" ")
469 id = int(parts[2][:1])
471 self.nimSocketCount += 1
472 elif line.strip().startswith("Type:"):
473 self.nimTypes[lastsocket] = str(line.strip()[6:])
474 #self.nimTypes[lastsocket] = str("DVB-T")
475 elif line.strip().startswith("Name:"):
476 self.nimNames[lastsocket] = str(line.strip()[6:])
477 elif line.strip().startswith("empty"):
478 self.nimNames[lastsocket] = _("N/A")
479 self.nimTypes[lastsocket] = "empty/unknown"
483 def getNimType(self, slotID):
484 if slotID >= self.nimCount:
485 return self.nimType["empty/unknown"]
487 return self.nimType[self.nimTypes[slotID]]
489 def getNimTypeName(self, slotID):
490 if slotID >= self.nimCount:
491 return "empty/unknown"
493 return self.nimTypes[slotID]
495 def getNimName(self, slotID):
496 return self.nimNames[slotID]
498 def getNimSocketCount(self):
499 return self.nimSocketCount
501 def hasNimType(self, chktype):
502 for id, type in self.nimTypes.items():
503 if (chktype == self.nimType[str(type)]):
507 def getNimListOfType(self, type, exception = -1):
509 for x in self.nimslots:
510 if ((x.nimType == type) and (x.slotid != exception)):
511 list.append(x.slotid)
514 def getConfigPrefix(self, slotid):
515 return "config.Nim" + ("A","B","C","D")[slotid] + "."
519 self.nimType = { "empty/unknown": -1,
525 self.terrestrialsList = []
529 self.readSatsfromFile()
531 self.nimCount = self.getNimSocketCount()
535 while x < self.nimCount:
536 tType = self.getNimType(x)
537 tName = self.getNimName(x)
538 tNim = nimSlot(x, tType, tName)
539 self.nimslots.append(tNim)
542 InitNimManager(self) #init config stuff
546 for slot in self.nimslots:
547 nimText = _("Socket ") + ("A", "B", "C", "D")[slot.slotid] + ": "
548 if slot.nimType == -1:
549 nimText += _("empty/unknown")
551 nimText += slot.name + " ("
552 nimText += ("DVB-S", "DVB-C", "DVB-T")[slot.nimType] + ")"
553 list.append((nimText, slot))
556 def getNimConfigMode(self, slotid):
557 return config.Nims[slotid].configMode.value
559 def getSatList(self):
562 def getSatListForNim(self, slotid):
564 if (self.getNimType(slotid) == self.nimType["DVB-S"]):
565 #print "slotid:", slotid
567 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
568 #print "diseqcA:", config.Nims[slotid].diseqcA.value
569 configMode = config.Nims[slotid].configMode.value
571 if configMode == "equal":
572 slotid=0 #FIXME add handling for more than two tuners !!!
573 configMode = config.Nims[slotid].configMode.value
575 if configMode == "simple":
576 dm = config.Nims[slotid].diseqcMode.value
577 if dm in ["single", "toneburst", "diseqc_a_b", "diseqc_a_b_c_d"]:
578 list.append(self.satList[config.Nims[slotid].diseqcA.index])
579 if dm in ["toneburst", "diseqc_a_b", "diseqc_a_b_c_d"]:
580 list.append(self.satList[config.Nims[slotid].diseqcB.index])
581 if dm == "diseqc_a_b_c_d":
582 list.append(self.satList[config.Nims[slotid].diseqcC.index])
583 list.append(self.satList[config.Nims[slotid].diseqcD.index])
584 if dm == "positioner":
585 for x in self.satList:
587 elif configMode == "advanced":
588 for x in self.satList:
589 if int(config.Nims[slotid].advanced.sat[x[0]].lnb.value) != 0:
594 def getRotorSatListForNim(self, slotid):
596 if (self.getNimType(slotid) == self.nimType["DVB-S"]):
597 #print "slotid:", slotid
599 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
600 #print "diseqcA:", config.Nims[slotid].diseqcA.value
601 configMode = config.Nims[slotid].configMode.value
602 if configMode == "simple":
603 if config.Nims[slotid].diseqcMode.value == "positioner":
604 for x in self.satList:
606 elif configMode == "advanced":
607 for x in self.satList:
608 nim = config.Nims[slotid]
609 lnbnum = int(nim.advanced.sat[x[0]].lnb.value)
611 lnb = nim.advanced.lnb[lnbnum]
612 if lnb.diseqcMode.value == "diseqc_a_b_c_d":
616 def nimDiseqcModeChanged(self, slotid, mode):
617 #print "nimDiseqcModeChanged set to " + str(mode)
619 def nimPortAChanged(self, slotid, val):
620 #print "nimDiseqcA set to " + str(slotid) + " val:" + str(val)
622 def nimPortBChanged(self, slotid, val):
623 #print "nimDiseqcA set to " + str(slotid) + " val:" + str(val)
624 #print "nimDiseqcB set to " + str(val)
626 def nimPortCChanged(self, slotid, val):
627 #print "nimDiseqcC set to " + str(val)
629 def nimPortDChanged(self, slotid, val):
630 #print "nimDiseqcD set to " + str(val)
633 def InitNimManager(nimmgr):
634 config.Nims = ConfigSubList()
635 for x in range(nimmgr.nimCount):
636 config.Nims.append(ConfigSubsection())
638 # def nimConfigModeChanged(slotid, configElement):
639 # nimmgr.nimConfigModeChanged(slotid, configElement.value)
640 def nimDiseqcModeChanged(slotid, configElement):
641 nimmgr.nimDiseqcModeChanged(slotid, configElement.value)
643 def nimPortAChanged(slotid, configElement):
644 nimmgr.nimPortAChanged(slotid, configElement.value)
645 def nimPortBChanged(slotid, configElement):
646 nimmgr.nimPortBChanged(slotid, configElement.value)
647 def nimPortCChanged(slotid, configElement):
648 nimmgr.nimPortCChanged(slotid, configElement.value)
649 def nimPortDChanged(slotid, configElement):
650 nimmgr.nimPortDChanged(slotid, configElement.value)
652 for slot in nimmgr.nimslots:
654 cname = nimmgr.getConfigPrefix(x)
657 if slot.nimType == nimmgr.nimType["DVB-S"]:
659 nim.configMode = ConfigSelection(
661 "simple": _("simple"),
662 "advanced": _("advanced")},
666 nim.configMode = ConfigSelection(
668 "equal": _("equal to Socket A"),
669 "looptrough": _("loopthrough to socket A"),
670 "nothing": _("nothing connected"),
671 "satposdepends": _("second cable of motorized LNB"),
672 "simple": _("simple"),
673 "advanced": _("advanced")},
674 default = "looptrough")
676 #important - check if just the 2nd one is LT only and the first one is DVB-S
677 if nim.configMode.value in ["loopthrough", "satposdepends", "equal"]:
678 if x == 0: # first one can never be linked to anything
680 nim.configMode.value = "simple"
681 nim.configMode.save()
683 #FIXME: make it better
684 for y in nimmgr.nimslots:
686 if y.nimType != nimmgr.nimType["DVB-S"]:
688 nim.configMode.value = "simple"
689 nim.configMode.save()
691 nim.diseqcMode = ConfigSelection(
693 ("single", _("Single")),
694 ("toneburst_a_b", _("Toneburst A/B")),
695 ("diseqc_a_b", _("DiSEqC A/B")),
696 ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")),
697 ("positioner", _("Positioner"))],
698 default = "diseqc_a_b")
699 nim.diseqcA = ConfigSatlist(default = 192, list = nimmgr.satList)
700 nim.diseqcB = ConfigSatlist(default = 130, list = nimmgr.satList)
701 nim.diseqcC = ConfigSatlist(list = nimmgr.satList)
702 nim.diseqcD = ConfigSatlist(list = nimmgr.satList)
703 nim.positionerMode = ConfigSelection(
705 ("usals", _("USALS")),
706 ("manual", _("manual"))],
708 nim.longitude = ConfigFloat(default=[5,100], limits=[(0,359),(0,999)])
709 nim.longitudeOrientation = ConfigSelection(choices={"east": _("East"), "west": _("West")}, default = "east")
710 nim.latitude = ConfigFloat(default=[50,767], limits=[(0,359),(0,999)])
711 nim.latitudeOrientation = ConfigSelection(choices={"north": _("North"), "south": _("South")}, default="north")
712 satNimList = nimmgr.getNimListOfType(nimmgr.nimType["DVB-S"], slot.slotid)
715 satNimListNames["Slot_" + ("A", "B", "C", "D")[x] + "_" + nimmgr.getNimName(x)] = _("Slot ") + ("A", "B", "C", "D")[x] + ": " + nimmgr.getNimName(x)
716 if len(satNimListNames):
717 nim.equalTo = ConfigSelection(choices = satNimListNames)
718 nim.linkedTo = ConfigSelection(choices = satNimListNames)
719 nim.satposDependsTo = ConfigSelection(choices = satNimListNames)
721 #perhaps the instance of the slot is more useful?
722 # nim.configMode.addNotifier(boundFunction(nimConfigModeChanged,x))
723 nim.diseqcMode.addNotifier(boundFunction(nimDiseqcModeChanged,x))
724 nim.diseqcA.addNotifier(boundFunction(nimPortAChanged,int(x)))
725 nim.diseqcB.addNotifier(boundFunction(nimPortBChanged,x))
726 nim.diseqcC.addNotifier(boundFunction(nimPortCChanged,x))
727 nim.diseqcD.addNotifier(boundFunction(nimPortDChanged,x))
730 nim.advanced = ConfigSubsection()
731 nim.advanced.sats = ConfigSatlist(default = 192, list = nimmgr.satList)
732 nim.advanced.sat = ConfigSubDict()
733 lnbs = [("0", "not available")]
734 for y in range(1, 33):
735 lnbs.append((str(y), "LNB " + str(y)))
737 for x in nimmgr.satList:
738 nim.advanced.sat[x[0]] = ConfigSubsection()
739 nim.advanced.sat[x[0]].voltage = ConfigSelection(choices={"polarization": _("Polarization"), "13V": _("13 V"), "18V": _("18 V")}, default = "polarization")
740 nim.advanced.sat[x[0]].tonemode = ConfigSelection(choices={"band": _("Band"), "on": _("On"), "off": _("Off")}, default = "band")
741 nim.advanced.sat[x[0]].usals = ConfigYesNo(default=True)
742 nim.advanced.sat[x[0]].rotorposition = ConfigInteger(default=1, limits=(1, 255))
743 nim.advanced.sat[x[0]].lnb = ConfigSelection(choices = lnbs)
745 csw = [("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))]
746 for y in range(0, 16):
747 csw.append((str(0xF0|y), "Input " + str(y+1)))
749 ucsw = [("0", _("None"))]
750 for y in range(1, 17):
751 ucsw.append((str(y), "Input " + str(y)))
753 nim.advanced.lnb = ConfigSubList()
754 nim.advanced.lnb.append(ConfigDummy())
755 for x in range(1, 33):
756 nim.advanced.lnb.append(ConfigSubsection())
757 nim.advanced.lnb[x].lof = ConfigSelection(choices={"universal_lnb": _("Universal LNB"), "c_band": _("C-Band"), "user_defined": _("User defined")}, default="universal_lnb")
758 nim.advanced.lnb[x].lofl = ConfigInteger(default=9750, limits = (0, 99999))
759 nim.advanced.lnb[x].lofh = ConfigInteger(default=10600, limits = (0, 99999))
760 nim.advanced.lnb[x].threshold = ConfigInteger(default=11700, limits = (0, 99999))
761 nim.advanced.lnb[x].output_12v = ConfigSelection(choices = [("0V", _("0 V")), ("12V", _("12 V"))], default="0V")
762 nim.advanced.lnb[x].increased_voltage = ConfigYesNo(default=False)
763 nim.advanced.lnb[x].toneburst = ConfigSelection(choices = [("none", _("None")), ("A", _("A")), ("B", _("B"))], default = "none")
764 nim.advanced.lnb[x].diseqcMode = ConfigSelection(choices = [("none", _("None")), ("1_0", _("1.0")), ("1_1", _("1.1")), ("1_2", _("1.2"))], default = "none")
765 nim.advanced.lnb[x].commitedDiseqcCommand = ConfigSelection(choices = csw)
766 nim.advanced.lnb[x].fastDiseqc = ConfigYesNo(default=False)
767 nim.advanced.lnb[x].sequenceRepeat = ConfigYesNo(default=False)
768 nim.advanced.lnb[x].commandOrder1_0 = ConfigSelection(choices = [("ct", "committed, toneburst"), ("tc", "toneburst, committed")], default = "ct")
769 nim.advanced.lnb[x].commandOrder = ConfigSelection(choices = [
770 ("ct", "committed, toneburst"),
771 ("tc", "toneburst, committed"),
772 ("cut", "committed, uncommitted, toneburst"),
773 ("tcu", "toneburst, committed, uncommitted"),
774 ("uct", "uncommitted, committed, toneburst"),
775 ("tuc", "toneburst, uncommitted, commmitted")],
777 nim.advanced.lnb[x].uncommittedDiseqcCommand = ConfigSelection(choices = ucsw)
778 nim.advanced.lnb[x].diseqcRepeats = ConfigSelection(choices = [("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))], default = "none")
779 nim.advanced.lnb[x].longitude = ConfigFloat(default = [5,100], limits = [(0,359),(0,999)])
780 nim.advanced.lnb[x].longitudeOrientation = ConfigSelection(choices = [("east", _("East")), ("west", _("West"))], default = "east")
781 nim.advanced.lnb[x].latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)])
782 nim.advanced.lnb[x].latitudeOrientation = ConfigSelection(choices = [("north", _("North")), ("south", _("South"))], default = "north")
783 nim.advanced.lnb[x].powerMeasurement = ConfigYesNo(default=True)
784 nim.advanced.lnb[x].powerThreshold = ConfigInteger(default=50, limits=(0, 100))
786 elif slot.nimType == nimmgr.nimType["DVB-C"]:
787 nim.cable = ConfigSelection(choices = nimmgr.cablesList)
788 elif slot.nimType == nimmgr.nimType["DVB-T"]:
790 for x in nimmgr.terrestrialsList:
792 nim.terrestrial = ConfigSelection(choices = list)
793 nim.terrestrial_5V = ConfigOnOff()
795 print "pls add support for this frontend type!"
798 nimmgr.sec = SecConfigure(nimmgr)
801 nimmanager = NimManager()