1 from config import config, ConfigSubsection, ConfigSelection, ConfigFloat, ConfigSatlist, ConfigYesNo, ConfigInteger, ConfigSubList, ConfigNothing, ConfigSubDict, ConfigOnOff, ConfigDateTime
3 from enigma import eDVBSatelliteEquipmentControl as secClass, \
4 eDVBSatelliteLNBParameters as lnbParam, \
5 eDVBSatelliteDiseqcParameters as diseqcParam, \
6 eDVBSatelliteSwitchParameters as switchParam, \
7 eDVBSatelliteRotorParameters as rotorParam, \
8 eDVBResourceManager, eDVBDB
10 #from xml.sax import make_parser
11 #from xml.sax.handler import ContentHandler
13 from time import localtime, mktime
14 from datetime import datetime
16 def getConfigSatlist(orbpos, satlist):
20 default_orbpos = orbpos
22 return ConfigSatlist(satlist, default_orbpos)
24 def tryOpen(filename):
26 procFile = open(filename)
32 def addLNBSimple(self, sec, slotid, diseqcmode, toneburstmode = diseqcParam.NO, diseqcpos = diseqcParam.SENDNO, orbpos = 0, longitude = 0, latitude = 0, loDirection = 0, laDirection = 0, turningSpeed = rotorParam.FAST, useInputPower=True, inputPowerDelta=50):
35 tunermask = 1 << slotid
36 if self.equal.has_key(slotid):
37 tunermask |= (1 << self.equal[slotid])
38 elif self.linked.has_key(slotid):
39 tunermask |= (1 << self.linked[slotid])
40 sec.setLNBLOFL(9750000)
41 sec.setLNBLOFH(10600000)
42 sec.setLNBThreshold(11700000)
43 sec.setLNBIncreasedVoltage(lnbParam.OFF)
47 sec.setVoltageMode(switchParam.HV)
48 sec.setToneMode(switchParam.HILO)
49 sec.setCommandOrder(0)
52 sec.setDiSEqCMode(diseqcmode)
53 sec.setToneburst(toneburstmode)
54 sec.setCommittedCommand(diseqcpos)
55 sec.setUncommittedCommand(0) # SENDNO
56 #print "set orbpos to:" + str(orbpos)
58 if 0 <= diseqcmode < 3:
59 sec.addSatellite(orbpos)
60 self.satList.append(orbpos)
61 elif (diseqcmode == 3): # diseqc 1.2
62 if self.satposdepends.has_key(slotid):
63 tunermask |= (1 << self.satposdepends[slotid])
64 sec.setLatitude(latitude)
65 sec.setLaDirection(laDirection)
66 sec.setLongitude(longitude)
67 sec.setLoDirection(loDirection)
68 sec.setUseInputpower(useInputPower)
69 sec.setInputpowerDelta(inputPowerDelta)
70 sec.setRotorTurningSpeed(turningSpeed)
72 for x in self.NimManager.satList:
73 print "Add sat " + str(x[0])
74 sec.addSatellite(int(x[0]))
77 sec.setRotorPosNum(0) # USALS
78 self.satList.append(int(x[0]))
80 sec.setLNBSlotMask(tunermask)
82 def setSatposDepends(self, sec, nim1, nim2):
83 print "tuner", nim1, "depends on satpos of", nim2
84 sec.setTunerDepends(nim1, nim2)
86 def linkNIMs(self, sec, nim1, nim2):
87 print "link tuner", nim1, "to tuner", nim2
88 sec.setTunerLinked(nim1, nim2)
94 sec = secClass.getInstance()
95 sec.clear() ## this do unlinking NIMs too !!
96 print "sec config cleared"
100 self.satposdepends = { }
103 nim_slots = self.NimManager.nim_slots
107 for slot in nim_slots:
108 if slot.type is not None:
109 used_nim_slots.append((slot.slot, slot.description, slot.config.configMode.value != "nothing" and True or False))
110 eDVBResourceManager.getInstance().setFrontendSlotInformations(used_nim_slots)
112 for slot in nim_slots:
115 if slot.isCompatible("DVB-S"):
116 # save what nim we link to/are equal to/satposdepends to.
117 # this is stored in the *value* (not index!) of the config list
118 if nim.configMode.value == "equal":
119 self.equal[int(nim.equalTo.value)]=x
120 elif nim.configMode.value == "loopthrough":
121 self.linkNIMs(sec, x, int(nim.linkedTo.value))
122 self.linked[int(nim.linkedTo.value)]=x
123 elif nim.configMode.value == "satposdepends":
124 self.setSatposDepends(sec, x, int(nim.satposDependsTo.value))
125 self.satposdepends[int(nim.satposDependsTo.value)]=x
127 for slot in nim_slots:
130 if slot.isCompatible("DVB-S"):
131 print "slot: " + str(x) + " configmode: " + str(nim.configMode.value)
132 print "diseqcmode: ", nim.configMode.value
133 if nim.configMode.value in [ "loopthrough", "satposdepends", "nothing" ]:
136 sec.setSlotNotLinked(x)
137 if nim.configMode.value == "equal":
139 elif nim.configMode.value == "simple": #simple config
140 if nim.diseqcMode.value == "single": #single
141 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.NONE, diseqcpos = diseqcParam.SENDNO)
142 elif nim.diseqcMode.value == "toneburst_a_b": #Toneburst A/B
143 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.A, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO)
144 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.B, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO)
145 elif nim.diseqcMode.value == "diseqc_a_b": #DiSEqC A/B
146 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA)
147 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB)
148 elif nim.diseqcMode.value == "diseqc_a_b_c_d": #DiSEqC A/B/C/D
149 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA)
150 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB)
151 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcC.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BA)
152 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcD.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BB)
153 elif nim.diseqcMode.value == "positioner": #Positioner
154 if nim.latitudeOrientation.value == "north":
155 laValue = rotorParam.NORTH
157 laValue = rotorParam.SOUTH
158 if nim.longitudeOrientation.value == "east":
159 loValue = rotorParam.EAST
161 loValue = rotorParam.WEST
165 if nim.powerMeasurement.value:
167 inputPowerDelta=nim.powerThreshold.value
168 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
169 if turn_speed_dict.has_key(nim.turningSpeed.value):
170 turning_speed = turn_speed_dict[nim.turningSpeed.value]
172 beg_time = localtime(nim.fastTurningBegin.value)
173 end_time = localtime(nim.fastTurningEnd.value)
174 turning_speed = ((beg_time.tm_hour+1) * 60 + beg_time.tm_min + 1) << 16
175 turning_speed |= (end_time.tm_hour+1) * 60 + end_time.tm_min + 1
176 self.addLNBSimple(sec, slotid = x, diseqcmode = 3,
177 longitude = nim.longitude.float,
178 loDirection = loValue,
179 latitude = nim.latitude.float,
180 laDirection = laValue,
181 turningSpeed = turning_speed,
182 useInputPower = useInputPower,
183 inputPowerDelta = inputPowerDelta)
184 elif nim.configMode.value == "advanced": #advanced config
185 self.updateAdvanced(sec, x)
186 print "sec config completed"
188 def updateAdvanced(self, sec, slotid):
190 for x in range(1,33):
192 for x in self.NimManager.satList:
193 lnb = int(config.Nims[slotid].advanced.sat[x[0]].lnb.value)
195 print "add", x[0], "to", lnb
196 lnbSat[lnb].append(x[0])
197 for x in range(1,33):
198 if len(lnbSat[x]) > 0:
199 currLnb = config.Nims[slotid].advanced.lnb[x]
202 tunermask = 1 << slotid
203 if self.equal.has_key(slotid):
204 tunermask |= (1 << self.equal[slotid])
205 elif self.linked.has_key(slotid):
206 tunermask |= (1 << self.linked[slotid])
208 if currLnb.lof.value == "universal_lnb":
209 sec.setLNBLOFL(9750000)
210 sec.setLNBLOFH(10600000)
211 sec.setLNBThreshold(11700000)
212 elif currLnb.lof.value == "c_band":
213 sec.setLNBLOFL(5150000)
214 sec.setLNBLOFH(5150000)
215 sec.setLNBThreshold(5150000)
216 elif currLnb.lof.value == "user_defined":
217 sec.setLNBLOFL(currLnb.lofl.value * 1000)
218 sec.setLNBLOFH(currLnb.lofh.value * 1000)
219 sec.setLNBThreshold(currLnb.threshold.value * 1000)
221 # if currLnb.output_12v.value == "0V":
222 # pass # nyi in drivers
223 # elif currLnb.output_12v.value == "12V":
224 # pass # nyi in drivers
226 if currLnb.increased_voltage.value:
227 sec.setLNBIncreasedVoltage(lnbParam.ON)
229 sec.setLNBIncreasedVoltage(lnbParam.OFF)
231 dm = currLnb.diseqcMode.value
233 sec.setDiSEqCMode(diseqcParam.NONE)
235 sec.setDiSEqCMode(diseqcParam.V1_0)
237 sec.setDiSEqCMode(diseqcParam.V1_1)
239 sec.setDiSEqCMode(diseqcParam.V1_2)
241 if self.satposdepends.has_key(slotid): # only useable with rotors
242 tunermask |= (1 << self.satposdepends[slotid])
245 if currLnb.toneburst.value == "none":
246 sec.setToneburst(diseqcParam.NO)
247 elif currLnb.toneburst.value == "A":
248 sec.setToneburst(diseqcParam.A)
249 elif currLnb.toneburst.value == "B":
250 sec.setToneburst(diseqcParam.B)
252 # Committed Diseqc Command
253 cdc = currLnb.commitedDiseqcCommand.value
255 c = { "none": diseqcParam.SENDNO,
256 "AA": diseqcParam.AA,
257 "AB": diseqcParam.AB,
258 "BA": diseqcParam.BA,
259 "BB": diseqcParam.BB }
262 sec.setCommittedCommand(c[cdc])
264 sec.setCommittedCommand(long(cdc))
266 sec.setFastDiSEqC(currLnb.fastDiseqc.value)
268 sec.setSeqRepeat(currLnb.sequenceRepeat.value)
270 if currLnb.diseqcMode.value == "1_0":
271 currCO = currLnb.commandOrder1_0.value
273 currCO = currLnb.commandOrder.value
275 udc = int(currLnb.uncommittedDiseqcCommand.value)
277 sec.setUncommittedCommand(0xF0|(udc-1))
279 sec.setUncommittedCommand(0) # SENDNO
281 sec.setRepeats({"none": 0, "one": 1, "two": 2, "three": 3}[currLnb.diseqcRepeats.value])
283 setCommandOrder = False
285 # 0 "committed, toneburst",
286 # 1 "toneburst, committed",
287 # 2 "committed, uncommitted, toneburst",
288 # 3 "toneburst, committed, uncommitted",
289 # 4 "uncommitted, committed, toneburst"
290 # 5 "toneburst, uncommitted, commmitted"
291 order_map = {"ct": 0, "tc": 1, "cut": 2, "tcu": 3, "uct": 4, "tuc": 5}
292 sec.setCommandOrder(order_map[currCO])
295 latitude = currLnb.latitude.float
296 sec.setLatitude(latitude)
297 longitude = currLnb.longitude.float
298 sec.setLongitude(longitude)
299 if currLnb.latitudeOrientation.value == "north":
300 sec.setLaDirection(rotorParam.NORTH)
302 sec.setLaDirection(rotorParam.SOUTH)
303 if currLnb.longitudeOrientation.value == "east":
304 sec.setLoDirection(rotorParam.EAST)
306 sec.setLoDirection(rotorParam.WEST)
308 if currLnb.powerMeasurement.value:
309 sec.setUseInputpower(True)
310 sec.setInputpowerDelta(currLnb.powerThreshold.value)
311 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
312 if turn_speed_dict.has_key(currLnb.turningSpeed.value):
313 turning_speed = turn_speed_dict[currLnb.turningSpeed.value]
315 beg_time = localtime(currLnb.fastTurningBegin.value)
316 end_time = localtime(currLnb.fastTurningEnd.value)
317 turning_speed = ((beg_time.tm_hour + 1) * 60 + beg_time.tm_min + 1) << 16
318 turning_speed |= (end_time.tm_hour + 1) * 60 + end_time.tm_min + 1
319 sec.setRotorTurningSpeed(turning_speed)
321 sec.setUseInputpower(False)
323 sec.setLNBSlotMask(tunermask)
325 # finally add the orbital positions
328 currSat = config.Nims[slotid].advanced.sat[y]
330 if currSat.voltage.value == "polarization":
331 sec.setVoltageMode(switchParam.HV)
332 elif currSat.voltage.value == "13V":
333 sec.setVoltageMode(switchParam._14V)
334 elif currSat.voltage.value == "18V":
335 sec.setVoltageMode(switchParam._18V)
337 if currSat.tonemode == "band":
338 sec.setToneMode(switchParam.HILO)
339 elif currSat.tonemode == "on":
340 sec.setToneMode(switchParam.ON)
341 elif currSat.tonemode == "off":
342 sec.setToneMode(switchParam.OFF)
344 if not currSat.usals.value:
345 sec.setRotorPosNum(currSat.rotorposition.value)
347 sec.setRotorPosNum(0) #USALS
349 def __init__(self, nimmgr):
350 self.NimManager = nimmgr
354 def __init__(self, slot, type, description):
357 if type not in ["DVB-S", "DVB-C", "DVB-T", "DVB-S2", None]:
358 print "warning: unknown NIM type %s, not using." % type
362 self.description = description
364 def isCompatible(self, what):
367 "DVB-S": ["DVB-S", None],
368 "DVB-C": ["DVB-C", None],
369 "DVB-T": ["DVB-T", None],
370 "DVB-S2": ["DVB-S", "DVB-S2", None]
372 return what in compatible[self.type]
374 def getSlotName(self):
375 # get a friendly description for a slot name.
376 # we name them "Tuner A/B/C/...", because that's what's usually written on the back
378 return _("Tuner ") + chr(ord('A') + self.slot)
380 slot_name = property(getSlotName)
383 return chr(ord('A') + self.slot)
385 slot_id = property(getSlotID)
387 def getFriendlyType(self):
396 friendly_type = property(getFriendlyType)
398 def getFriendlyFullDescription(self):
399 nim_text = self.slot_name + ": "
402 nim_text += _("(empty)")
404 nim_text += self.description + " (" + self.friendly_type + ")"
408 friendly_full_description = property(getFriendlyFullDescription)
409 config_mode = property(lambda self: config.Nims[self.slot].configMode.value)
410 config = property(lambda self: config.Nims[self.slot])
411 empty = property(lambda self: self.type is None)
414 # class parseSats(ContentHandler):
415 # def __init__(self, satList, satellites, transponders):
416 # self.isPointsElement, self.isReboundsElement = 0, 0
417 # self.satList = satList
418 # self.satellites = satellites
419 # self.transponders = transponders
421 # def startElement(self, name, attrs):
422 # if (name == "sat"):
423 # #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
424 # tpos = int(attrs.get('position',""))
427 # tname = attrs.get('name',"").encode("UTF-8")
428 # tflags = int(attrs.get('flags', '0'))
429 # self.satellites[tpos] = tname
430 # self.satList.append( (tpos, tname, tflags) )
431 # self.parsedSat = int(tpos)
432 # elif (name == "transponder"):
433 # modulation = int(attrs.get('modulation',"1")) # QPSK default
434 # system = int(attrs.get('system',"0")) # DVB-S default
435 # freq = int(attrs.get('frequency',""))
436 # sr = int(attrs.get('symbol_rate',""))
437 # pol = int(attrs.get('polarization',""))
438 # fec = int(attrs.get('fec_inner',"0")) # AUTO default
439 # if self.parsedSat in self.transponders:
442 # self.transponders[self.parsedSat] = [ ]
444 # self.transponders[self.parsedSat].append((0, freq, sr, pol, fec, system, modulation))
446 # class parseCables(ContentHandler):
447 # def __init__(self, cablesList, transponders):
448 # self.isPointsElement, self.isReboundsElement = 0, 0
449 # self.cablesList = cablesList
450 # for x in self.cablesList:
451 # self.cablesList.remove(x)
452 # self.transponders = transponders
454 # def startElement(self, name, attrs):
455 # if (name == "cable"):
456 # #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
457 # tname = attrs.get('name',"").encode("UTF-8")
458 # tflags = int(attrs.get('flags', '0'))
459 # self.cablesList.append((tname, tflags))
460 # self.parsedCab = tname
461 # elif (name == "transponder"):
462 # freq = int(attrs.get('frequency',""))
463 # while freq > 999999:
465 # sr = int(attrs.get('symbol_rate',"0"))
466 # mod = int(attrs.get('modulation',"3")) # QAM64 default
467 # fec = int(attrs.get('fec_inner',"0")) # AUTO default
468 # if self.parsedCab in self.transponders:
471 # self.transponders[self.parsedCab] = [ ]
472 # self.transponders[self.parsedCab].append((1, freq, sr, mod, fec))
474 # class parseTerrestrials(ContentHandler):
475 # def __init__(self, terrestrialsList, transponders):
476 # self.isPointsElement, self.isReboundsElement = 0, 0
477 # self.terrestrialsList = terrestrialsList
478 # self.transponders = transponders
480 # def startElement(self, name, attrs):
481 # if (name == "terrestrial"):
482 # #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
483 # tname = attrs.get('name',"").encode("UTF-8")
484 # tflags = int(attrs.get('flags', '0'))
485 # self.terrestrialsList.append((tname, tflags))
486 # self.parsedTer = str(tname)
487 # elif (name == "transponder"):
488 # # TODO finish this!
489 # freq = int(attrs.get('centre_frequency',""))
490 # bw = int(attrs.get('bandwidth',"3")) # AUTO
491 # const = int(attrs.get('constellation',"1")) # AUTO
492 # crh = int(attrs.get('code_rate_hp',"5")) # AUTO
493 # if crh > 5: # our terrestrial.xml is buggy... 6 for AUTO
495 # crl = int(attrs.get('code_rate_lp',"5")) # AUTO
496 # if crl > 5: # our terrestrial.xml is buggy... 6 for AUTO
498 # guard = int(attrs.get('guard_interval',"4")) # AUTO
499 # transm = int(attrs.get('transmission_mode',"2")) # AUTO
500 # hierarchy = int(attrs.get('hierarchy_information',"4")) # AUTO
501 # inv = int(attrs.get('inversion',"2")) # AUTO
502 # if self.parsedTer in self.transponders:
505 # self.transponders[self.parsedTer] = [ ]
507 # self.transponders[self.parsedTer].append((2, freq, bw, const, crh, crl, guard, transm, hierarchy, inv))
509 def getTransponders(self, pos):
510 if self.transponders.has_key(pos):
511 return self.transponders[pos]
515 def getTranspondersCable(self, nim):
516 nimConfig = config.Nims[nim]
517 if nimConfig.configMode.value != "nothing" and nimConfig.cable.scan_type.value == "provider":
518 return self.transponderscable[self.cablesList[nimConfig.cable.scan_provider.index][0]]
521 def getTranspondersTerrestrial(self, region):
522 return self.transpondersterrestrial[region]
524 def getCableDescription(self, nim):
525 return self.cablesList[config.Nims[nim].scan_provider.index][0]
527 def getCableFlags(self, nim):
528 return self.cablesList[config.Nims[nim].scan_provider.index][1]
530 def getTerrestrialDescription(self, nim):
531 return self.terrestrialsList[config.Nims[nim].terrestrial.index][0]
533 def getTerrestrialFlags(self, nim):
534 return self.terrestrialsList[config.Nims[nim].terrestrial.index][1]
536 def getConfiguredSats(self):
537 return self.sec.getSatList()
539 def getSatDescription(self, pos):
540 return self.satellites[pos]
542 def readTransponders(self):
543 # read initial networks from file. we only read files which we are interested in,
544 # which means only these where a compatible tuner exists.
545 self.satellites = { }
546 self.transponders = { }
547 self.transponderscable = { }
548 self.transpondersterrestrial = { }
549 db = eDVBDB.getInstance()
551 # parser = make_parser()
552 if self.hasNimType("DVB-S"):
553 print "Reading satellites.xml"
554 # satHandler = self.parseSats(self.satList, self.satellites, self.transponders)
555 # parser.setContentHandler(satHandler)
556 # parser.parse('/etc/tuxbox/satellites.xml')
557 db.readSatellites(self.satList, self.satellites, self.transponders)
558 # print "SATLIST", self.satList
559 # print "SATS", self.satellites
560 # print "TRANSPONDERS", self.transponders
562 if self.hasNimType("DVB-C"):
563 print "Reading cables.xml"
564 # cabHandler = self.parseCables(self.cablesList, self.transponderscable)
565 # parser.setContentHandler(cabHandler)
566 # parser.parse('/etc/tuxbox/cables.xml')
567 db.readCables(self.cablesList, self.transponderscable)
568 # print "CABLIST", self.cablesList
569 # print "TRANSPONDERS", self.transponders
571 if self.hasNimType("DVB-T"):
572 print "Reading terrestrial.xml"
573 # terHandler = self.parseTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
574 # parser.setContentHandler(terHandler)
575 # parser.parse('/etc/tuxbox/terrestrial.xml')
576 db.readTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
577 # print "TERLIST", self.terrestrialsList
578 # print "TRANSPONDERS", self.transpondersterrestrial
580 def enumerateNIMs(self):
581 # enum available NIMs. This is currently very dreambox-centric and uses the /proc/bus/nim_sockets interface.
582 # the result will be stored into nim_slots.
583 # the content of /proc/bus/nim_sockets looks like:
586 # Name: BCM4501 DVB-S2 NIM (internal)
589 # Name: BCM4501 DVB-S2 NIM (internal)
592 # Name: Philips TU1216
595 # Name: Alps BSBE1 702A
598 # Type will be either "DVB-S", "DVB-S2", "DVB-T", "DVB-C" or None.
600 # nim_slots is an array which has exactly one entry for each slot, even for empty ones.
603 nimfile = tryOpen("/proc/bus/nim_sockets")
611 for line in nimfile.readlines():
614 if line.strip().startswith("NIM Socket"):
615 parts = line.strip().split(" ")
616 current_slot = int(parts[2][:-1])
617 entries[current_slot] = {}
618 elif line.strip().startswith("Type:"):
619 entries[current_slot]["type"] = str(line.strip()[6:])
620 elif line.strip().startswith("Name:"):
621 entries[current_slot]["name"] = str(line.strip()[6:])
622 elif line.strip().startswith("empty"):
623 entries[current_slot]["type"] = None
624 entries[current_slot]["name"] = _("N/A")
627 for id, entry in entries.items():
628 if not (entry.has_key("name") and entry.has_key("type")):
629 entry["name"] = _("N/A")
631 self.nim_slots.append(NIM(slot = id, description = entry["name"], type = entry["type"]))
633 def hasNimType(self, chktype):
634 for slot in self.nim_slots:
635 if slot.isCompatible(chktype):
639 def getNimListOfType(self, type, exception = -1):
640 # returns a list of indexes for NIMs compatible to the given type, except for 'exception'
642 for x in self.nim_slots:
643 if x.isCompatible(type) and x.slot != exception:
650 self.terrestrialsList = []
652 self.readTransponders()
653 InitNimManager(self) #init config stuff
655 # get a list with the friendly full description
658 for slot in self.nim_slots:
659 list.append(slot.friendly_full_description)
662 def getSatList(self):
665 def getSatListForNim(self, slotid):
667 if self.nim_slots[slotid].isCompatible("DVB-S"):
668 #print "slotid:", slotid
670 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.index]
671 #print "diseqcA:", config.Nims[slotid].diseqcA.value
672 configMode = config.Nims[slotid].configMode.value
674 if configMode == "equal":
675 slotid=0 #FIXME add handling for more than two tuners !!!
676 configMode = config.Nims[slotid].configMode.value
678 if configMode == "simple":
679 dm = config.Nims[slotid].diseqcMode.value
680 if dm in ["single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
681 list.append(self.satList[config.Nims[slotid].diseqcA.index])
682 if dm in ["toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
683 list.append(self.satList[config.Nims[slotid].diseqcB.index])
684 if dm == "diseqc_a_b_c_d":
685 list.append(self.satList[config.Nims[slotid].diseqcC.index])
686 list.append(self.satList[config.Nims[slotid].diseqcD.index])
687 if dm == "positioner":
688 for x in self.satList:
690 elif configMode == "advanced":
691 for x in self.satList:
692 if int(config.Nims[slotid].advanced.sat[x[0]].lnb.value) != 0:
697 def getRotorSatListForNim(self, slotid):
699 if self.nim_slots[slotid].isCompatible("DVB-S"):
700 #print "slotid:", slotid
702 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
703 #print "diseqcA:", config.Nims[slotid].diseqcA.value
704 configMode = config.Nims[slotid].configMode.value
705 if configMode == "simple":
706 if config.Nims[slotid].diseqcMode.value == "positioner":
707 for x in self.satList:
709 elif configMode == "advanced":
710 for x in self.satList:
711 nim = config.Nims[slotid]
712 lnbnum = int(nim.advanced.sat[x[0]].lnb.value)
714 lnb = nim.advanced.lnb[lnbnum]
715 if lnb.diseqcMode.value == "1_2":
720 config.sec = ConfigSubsection()
722 x = ConfigInteger(default=15, limits = (0, 9999))
723 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_CONT_TONE, configElement.value))
724 config.sec.delay_after_continuous_tone_change = x
726 x = ConfigInteger(default=10, limits = (0, 9999))
727 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_VOLTAGE_CHANGE, configElement.value))
728 config.sec.delay_after_final_voltage_change = x
730 x = ConfigInteger(default=120, limits = (0, 9999))
731 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_DISEQC_REPEATS, configElement.value))
732 config.sec.delay_between_diseqc_repeats = x
734 x = ConfigInteger(default=50, limits = (0, 9999))
735 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_LAST_DISEQC_CMD, configElement.value))
736 config.sec.delay_after_last_diseqc_command = x
738 x = ConfigInteger(default=50, limits = (0, 9999))
739 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value))
740 config.sec.delay_after_toneburst = x
742 x = ConfigInteger(default=200, limits = (0, 9999))
743 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS, configElement.value))
744 config.sec.delay_after_enable_voltage_before_switch_command = x
746 x = ConfigInteger(default=700, limits = (0, 9999))
747 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_SWITCH_AND_MOTOR_CMD, configElement.value))
748 config.sec.delay_between_switch_and_motor_command = x
750 x = ConfigInteger(default=150, limits = (0, 9999))
751 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MEASURE_IDLE_INPUTPOWER, configElement.value))
752 config.sec.delay_after_voltage_change_before_measure_idle_inputpower = x
754 x = ConfigInteger(default=750, limits = (0, 9999))
755 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_MOTOR_CMD, configElement.value))
756 config.sec.delay_after_enable_voltage_before_motor_command = x
758 x = ConfigInteger(default=150, limits = (0, 9999))
759 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_MOTOR_STOP_CMD, configElement.value))
760 config.sec.delay_after_motor_stop_command = x
762 x = ConfigInteger(default=150, limits = (0, 9999))
763 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MOTOR_CMD, configElement.value))
764 config.sec.delay_after_voltage_change_before_motor_command = x
766 x = ConfigInteger(default=120, limits = (0, 9999))
767 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_RUNNING_TIMEOUT, configElement.value))
768 config.sec.motor_running_timeout = x
770 x = ConfigInteger(default=1, limits = (0, 5))
771 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_COMMAND_RETRIES, configElement.value))
772 config.sec.motor_command_retries = x
774 x = ConfigInteger(default=20, limits = (0, 9999))
775 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS, configElement.value))
776 config.sec.delay_after_change_voltage_before_switch_command = x
778 # TODO add support for satpos depending nims to advanced nim configuration
779 # so a second/third/fourth cable from a motorized lnb can used behind a
780 # diseqc 1.0 / diseqc 1.1 / toneburst switch
781 # the C(++) part should can handle this
782 # the configElement should be only visible when diseqc 1.2 is disabled
784 def InitNimManager(nimmgr):
787 config.Nims = ConfigSubList()
788 for x in range(len(nimmgr.nim_slots)):
789 config.Nims.append(ConfigSubsection())
791 for slot in nimmgr.nim_slots:
795 # HACK: currently, we can only looptrough to socket A
797 if slot.isCompatible("DVB-S"):
799 nim.configMode = ConfigSelection(
801 "simple": _("simple"),
802 "advanced": _("advanced"),
803 "nothing": _("nothing connected"),
807 nim.configMode = ConfigSelection(
809 "equal": _("equal to Socket A"),
810 "loopthrough": _("loopthrough to socket A"),
811 "nothing": _("nothing connected"),
812 "satposdepends": _("second cable of motorized LNB"),
813 "simple": _("simple"),
814 "advanced": _("advanced")},
815 default = "loopthrough")
817 #important - check if just the 2nd one is LT only and the first one is DVB-S
818 # CHECKME: is this logic correct for >2 slots?
819 if nim.configMode.value in ["loopthrough", "satposdepends", "equal"]:
820 if x == 0: # first one can never be linked to anything
822 nim.configMode.value = "simple"
823 nim.configMode.save()
825 #FIXME: make it better
826 for y in nimmgr.nim_slots:
828 if not y.isCompatible("DVB-S"):
830 nim.configMode.value = "simple"
831 nim.configMode.save()
833 nim.diseqcMode = ConfigSelection(
835 ("single", _("Single")),
836 ("toneburst_a_b", _("Toneburst A/B")),
837 ("diseqc_a_b", _("DiSEqC A/B")),
838 ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")),
839 ("positioner", _("Positioner"))],
840 default = "diseqc_a_b")
842 nim.diseqcA = getConfigSatlist(192, nimmgr.satList)
843 nim.diseqcB = getConfigSatlist(130, nimmgr.satList)
844 nim.diseqcC = ConfigSatlist(list = nimmgr.satList)
845 nim.diseqcD = ConfigSatlist(list = nimmgr.satList)
846 nim.positionerMode = ConfigSelection(
848 ("usals", _("USALS")),
849 ("manual", _("manual"))],
851 nim.longitude = ConfigFloat(default=[5,100], limits=[(0,359),(0,999)])
852 nim.longitudeOrientation = ConfigSelection(choices={"east": _("East"), "west": _("West")}, default = "east")
853 nim.latitude = ConfigFloat(default=[50,767], limits=[(0,359),(0,999)])
854 nim.latitudeOrientation = ConfigSelection(choices={"north": _("North"), "south": _("South")}, default="north")
855 nim.powerMeasurement = ConfigYesNo(default=True)
856 nim.powerThreshold = ConfigInteger(default=50, limits=(0, 100))
857 nim.turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch")) ], default = "fast")
858 btime = datetime(1970, 1, 1, 7, 0);
859 nim.fastTurningBegin = ConfigDateTime(default = mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 900)
860 etime = datetime(1970, 1, 1, 19, 0);
861 nim.fastTurningEnd = ConfigDateTime(default = mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 900)
862 # get other frontends of the same type
864 satNimList = nimmgr.getNimListOfType("DVB-S", slot.slot)
868 n = nimmgr.nim_slots[x]
869 satNimListNames["%d" % n.slot] = n.friendly_full_description
871 if len(satNimListNames):
872 nim.equalTo = ConfigSelection(choices = satNimListNames)
873 nim.linkedTo = ConfigSelection(choices = satNimListNames)
874 nim.satposDependsTo = ConfigSelection(choices = satNimListNames)
877 nim.advanced = ConfigSubsection()
878 nim.advanced.sats = getConfigSatlist(192,nimmgr.satList)
879 nim.advanced.sat = ConfigSubDict()
880 lnbs = [("0", "not available")]
881 for y in range(1, 33):
882 lnbs.append((str(y), "LNB " + str(y)))
884 for x in nimmgr.satList:
885 nim.advanced.sat[x[0]] = ConfigSubsection()
886 nim.advanced.sat[x[0]].voltage = ConfigSelection(choices={"polarization": _("Polarization"), "13V": _("13 V"), "18V": _("18 V")}, default = "polarization")
887 nim.advanced.sat[x[0]].tonemode = ConfigSelection(choices={"band": _("Band"), "on": _("On"), "off": _("Off")}, default = "band")
888 nim.advanced.sat[x[0]].usals = ConfigYesNo(default=True)
889 nim.advanced.sat[x[0]].rotorposition = ConfigInteger(default=1, limits=(1, 255))
890 nim.advanced.sat[x[0]].lnb = ConfigSelection(choices = lnbs)
892 csw = [("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))]
893 for y in range(0, 16):
894 csw.append((str(0xF0|y), "Input " + str(y+1)))
896 ucsw = [("0", _("None"))]
897 for y in range(1, 17):
898 ucsw.append((str(y), "Input " + str(y)))
900 nim.advanced.lnb = ConfigSubList()
901 nim.advanced.lnb.append(ConfigNothing())
902 for x in range(1, 33):
903 nim.advanced.lnb.append(ConfigSubsection())
904 nim.advanced.lnb[x].lof = ConfigSelection(choices={"universal_lnb": _("Universal LNB"), "c_band": _("C-Band"), "user_defined": _("User defined")}, default="universal_lnb")
905 nim.advanced.lnb[x].lofl = ConfigInteger(default=9750, limits = (0, 99999))
906 nim.advanced.lnb[x].lofh = ConfigInteger(default=10600, limits = (0, 99999))
907 nim.advanced.lnb[x].threshold = ConfigInteger(default=11700, limits = (0, 99999))
908 # nim.advanced.lnb[x].output_12v = ConfigSelection(choices = [("0V", _("0 V")), ("12V", _("12 V"))], default="0V")
909 nim.advanced.lnb[x].increased_voltage = ConfigYesNo(default=False)
910 nim.advanced.lnb[x].toneburst = ConfigSelection(choices = [("none", _("None")), ("A", _("A")), ("B", _("B"))], default = "none")
911 nim.advanced.lnb[x].diseqcMode = ConfigSelection(choices = [("none", _("None")), ("1_0", _("1.0")), ("1_1", _("1.1")), ("1_2", _("1.2"))], default = "none")
912 nim.advanced.lnb[x].commitedDiseqcCommand = ConfigSelection(choices = csw)
913 nim.advanced.lnb[x].fastDiseqc = ConfigYesNo(default=False)
914 nim.advanced.lnb[x].sequenceRepeat = ConfigYesNo(default=False)
915 nim.advanced.lnb[x].commandOrder1_0 = ConfigSelection(choices = [("ct", "committed, toneburst"), ("tc", "toneburst, committed")], default = "ct")
916 nim.advanced.lnb[x].commandOrder = ConfigSelection(choices = [
917 ("ct", "committed, toneburst"),
918 ("tc", "toneburst, committed"),
919 ("cut", "committed, uncommitted, toneburst"),
920 ("tcu", "toneburst, committed, uncommitted"),
921 ("uct", "uncommitted, committed, toneburst"),
922 ("tuc", "toneburst, uncommitted, commmitted")],
924 nim.advanced.lnb[x].uncommittedDiseqcCommand = ConfigSelection(choices = ucsw)
925 nim.advanced.lnb[x].diseqcRepeats = ConfigSelection(choices = [("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))], default = "none")
926 nim.advanced.lnb[x].longitude = ConfigFloat(default = [5,100], limits = [(0,359),(0,999)])
927 nim.advanced.lnb[x].longitudeOrientation = ConfigSelection(choices = [("east", _("East")), ("west", _("West"))], default = "east")
928 nim.advanced.lnb[x].latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)])
929 nim.advanced.lnb[x].latitudeOrientation = ConfigSelection(choices = [("north", _("North")), ("south", _("South"))], default = "north")
930 nim.advanced.lnb[x].powerMeasurement = ConfigYesNo(default=True)
931 nim.advanced.lnb[x].powerThreshold = ConfigInteger(default=50, limits=(0, 100))
932 nim.advanced.lnb[x].turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch"))], default = "fast")
933 btime = datetime(1970, 1, 1, 7, 0);
934 nim.advanced.lnb[x].fastTurningBegin = ConfigDateTime(default=mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 600)
935 etime = datetime(1970, 1, 1, 19, 0);
936 nim.advanced.lnb[x].fastTurningEnd = ConfigDateTime(default=mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 600)
937 elif slot.isCompatible("DVB-C"):
938 nim.configMode = ConfigSelection(
940 "enabled": _("enabled"),
941 "nothing": _("nothing connected"),
946 for x in nimmgr.cablesList:
947 list.append((str(n), x[0]))
949 nim.cable = ConfigSubsection()
950 possible_scan_types = [("bands", _("Frequency bands")), ("steps", _("Frequency steps"))]
952 possible_scan_types.append(("provider", _("Provider")))
953 nim.cable.scan_type = ConfigSelection(default = "bands", choices = possible_scan_types)
954 nim.cable.scan_provider = ConfigSelection(default = "0", choices = list)
955 nim.cable.scan_band_EU_VHF_I = ConfigYesNo(default = True)
956 nim.cable.scan_band_EU_MID = ConfigYesNo(default = True)
957 nim.cable.scan_band_EU_VHF_III = ConfigYesNo(default = True)
958 nim.cable.scan_band_EU_UHF_IV = ConfigYesNo(default = True)
959 nim.cable.scan_band_EU_UHF_V = ConfigYesNo(default = True)
960 nim.cable.scan_band_EU_SUPER = ConfigYesNo(default = True)
961 nim.cable.scan_band_EU_HYPER = ConfigYesNo(default = True)
962 nim.cable.scan_band_US_LOW = ConfigYesNo(default = False)
963 nim.cable.scan_band_US_MID = ConfigYesNo(default = False)
964 nim.cable.scan_band_US_HIGH = ConfigYesNo(default = False)
965 nim.cable.scan_band_US_SUPER = ConfigYesNo(default = False)
966 nim.cable.scan_band_US_HYPER = ConfigYesNo(default = False)
967 nim.cable.scan_frequency_steps = ConfigInteger(default = 1000, limits = (1000, 10000))
968 nim.cable.scan_mod_qam16 = ConfigYesNo(default = False)
969 nim.cable.scan_mod_qam32 = ConfigYesNo(default = False)
970 nim.cable.scan_mod_qam64 = ConfigYesNo(default = True)
971 nim.cable.scan_mod_qam128 = ConfigYesNo(default = False)
972 nim.cable.scan_mod_qam256 = ConfigYesNo(default = True)
973 nim.cable.scan_sr_6900 = ConfigYesNo(default = True)
974 nim.cable.scan_sr_6875 = ConfigYesNo(default = True)
975 nim.cable.scan_sr_ext1 = ConfigInteger(default = 0, limits = (0, 7230))
976 nim.cable.scan_sr_ext2 = ConfigInteger(default = 0, limits = (0, 7230))
977 elif slot.isCompatible("DVB-T"):
978 nim.configMode = ConfigSelection(
980 "enabled": _("enabled"),
981 "nothing": _("nothing connected"),
986 for x in nimmgr.terrestrialsList:
987 list.append((str(n), x[0]))
989 nim.terrestrial = ConfigSelection(choices = list)
990 nim.terrestrial_5V = ConfigOnOff()
992 nim.configMode = ConfigSelection(choices = { "nothing": _("disabled") }, default="nothing");
993 print "pls add support for this frontend type!"
996 nimmgr.sec = SecConfigure(nimmgr)
998 nimmanager = NimManager()