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, \
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:
110 if slot.isCompatible("DVB-S"):
111 # save what nim we link to/are equal to/satposdepends to.
112 # this is stored in the *value* (not index!) of the config list
113 if nim.configMode.value == "equal":
114 self.equal[int(nim.equalTo.value)]=x
115 elif nim.configMode.value == "loopthrough":
116 self.linkNIMs(sec, x, int(nim.linkedTo.value))
117 self.linked[int(nim.linkedTo.value)]=x
118 elif nim.configMode.value == "satposdepends":
119 self.setSatposDepends(sec, x, int(nim.satposDependsTo.value))
120 self.satposdepends[int(nim.satposDependsTo.value)]=x
122 if slot.type is not None:
123 used_nim_slots.append((slot.slot, slot.description, nim.configMode.value != "nothing" and True or False))
125 eDVBResourceManager.getInstance().setFrontendSlotInformations(used_nim_slots)
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):
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 self.satellites[tpos] = tname
429 self.satList.append( (tpos, tname) )
430 self.parsedSat = int(tpos)
431 elif (name == "transponder"):
432 modulation = int(attrs.get('modulation',"1")) # QPSK default
433 system = int(attrs.get('system',"0")) # DVB-S default
434 freq = int(attrs.get('frequency',""))
435 sr = int(attrs.get('symbol_rate',""))
436 pol = int(attrs.get('polarization',""))
437 fec = int(attrs.get('fec_inner',"0")) # AUTO default
438 if self.parsedSat in self.transponders:
441 self.transponders[self.parsedSat] = [ ]
443 self.transponders[self.parsedSat].append((0, freq, sr, pol, fec, system, modulation))
445 class parseCables(ContentHandler):
446 def __init__(self, cablesList, transponders):
447 self.isPointsElement, self.isReboundsElement = 0, 0
448 self.cablesList = cablesList
449 for x in self.cablesList:
450 self.cablesList.remove(x)
451 self.transponders = transponders
453 def startElement(self, name, attrs):
454 if (name == "cable"):
455 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
456 tname = attrs.get('name',"").encode("UTF-8")
457 tflags = int(attrs.get('flags',"0"))
458 self.cablesList.append((tname, tflags))
459 self.parsedCab = tname
460 elif (name == "transponder"):
461 freq = int(attrs.get('frequency',""))
464 sr = int(attrs.get('symbol_rate',"0"))
465 mod = int(attrs.get('modulation',"3")) # QAM64 default
466 fec = int(attrs.get('fec_inner',"0")) # AUTO default
467 if self.parsedCab in self.transponders:
470 self.transponders[self.parsedCab] = [ ]
471 self.transponders[self.parsedCab].append((1, freq, sr, mod, fec))
473 class parseTerrestrials(ContentHandler):
474 def __init__(self, terrestrialsList, transponders):
475 self.isPointsElement, self.isReboundsElement = 0, 0
476 self.terrestrialsList = terrestrialsList
477 self.transponders = transponders
479 def startElement(self, name, attrs):
480 if (name == "terrestrial"):
481 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
482 tname = attrs.get('name',"").encode("UTF-8")
483 tflags = attrs.get('flags',"")
484 self.terrestrialsList.append((tname, tflags))
485 self.parsedTer = str(tname)
486 elif (name == "transponder"):
488 freq = int(attrs.get('centre_frequency',""))
489 bw = int(attrs.get('bandwidth',"3")) # AUTO
490 const = int(attrs.get('constellation',"1")) # AUTO
491 crh = int(attrs.get('code_rate_hp',"5")) # AUTO
492 if crh > 5: # our terrestrial.xml is buggy... 6 for AUTO
494 crl = int(attrs.get('code_rate_lp',"5")) # AUTO
495 if crl > 5: # our terrestrial.xml is buggy... 6 for AUTO
497 guard = int(attrs.get('guard_interval',"4")) # AUTO
498 transm = int(attrs.get('transmission_mode',"2")) # AUTO
499 hierarchy = int(attrs.get('hierarchy_information',"4")) # AUTO
500 inv = int(attrs.get('inversion',"2")) # AUTO
501 if self.parsedTer in self.transponders:
504 self.transponders[self.parsedTer] = [ ]
506 self.transponders[self.parsedTer].append((2, freq, bw, const, crh, crl, guard, transm, hierarchy, inv))
508 def getTransponders(self, pos):
509 if self.transponders.has_key(pos):
510 return self.transponders[pos]
514 def getTranspondersCable(self, nim):
515 nimConfig = config.Nims[nim]
516 if nimConfig.configMode.value != "nothing" and nimConfig.cable.scan_type.value == "provider":
517 return self.transponderscable[self.cablesList[nimConfig.cable.scan_provider.index][0]]
520 def getTranspondersTerrestrial(self, region):
521 return self.transpondersterrestrial[region]
523 def getCableDescription(self, nim):
524 return self.cablesList[config.Nims[nim].scan_provider.index][0]
526 def getCableFlags(self, nim):
527 return self.cablesList[config.Nims[nim].scan_provider.index][1]
529 def getTerrestrialDescription(self, nim):
530 return self.terrestrialsList[config.Nims[nim].terrestrial.index][0]
532 def getTerrestrialFlags(self, nim):
533 return self.terrestrialsList[config.Nims[nim].terrestrial.index][1]
535 def getConfiguredSats(self):
536 return self.sec.getSatList()
538 def getSatDescription(self, pos):
539 return self.satellites[pos]
541 def readSatsfromFile(self):
542 # read initial networks from file. we only read files which we are interested in,
543 # which means only these where a compatible tuner exists.
544 self.satellites = { }
545 self.transponders = { }
546 self.transponderscable = { }
547 self.transpondersterrestrial = { }
549 parser = make_parser()
551 if self.hasNimType("DVB-S"):
552 print "Reading satellites.xml"
553 satHandler = self.parseSats(self.satList, self.satellites, self.transponders)
554 parser.setContentHandler(satHandler)
555 parser.parse('/etc/tuxbox/satellites.xml')
557 if self.hasNimType("DVB-C"):
558 print "Reading cables.xml"
559 cabHandler = self.parseCables(self.cablesList, self.transponderscable)
560 parser.setContentHandler(cabHandler)
561 parser.parse('/etc/tuxbox/cables.xml')
563 if self.hasNimType("DVB-T"):
564 print "Reading terrestrial.xml"
565 terHandler = self.parseTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
566 parser.setContentHandler(terHandler)
567 parser.parse('/etc/tuxbox/terrestrial.xml')
569 def enumerateNIMs(self):
570 # enum available NIMs. This is currently very dreambox-centric and uses the /proc/bus/nim_sockets interface.
571 # the result will be stored into nim_slots.
572 # the content of /proc/bus/nim_sockets looks like:
575 # Name: BCM4501 DVB-S2 NIM (internal)
578 # Name: BCM4501 DVB-S2 NIM (internal)
581 # Name: Philips TU1216
584 # Name: Alps BSBE1 702A
587 # Type will be either "DVB-S", "DVB-S2", "DVB-T", "DVB-C" or None.
589 nimfile = tryOpen("/proc/bus/nim_sockets")
597 for line in nimfile.readlines():
600 if line.strip().startswith("NIM Socket"):
601 parts = line.strip().split(" ")
602 current_slot = int(parts[2][:-1])
603 entries[current_slot] = {}
604 elif line.strip().startswith("Type:"):
605 entries[current_slot]["type"] = str(line.strip()[6:])
606 elif line.strip().startswith("Name:"):
607 entries[current_slot]["name"] = str(line.strip()[6:])
608 elif line.strip().startswith("empty"):
609 entries[current_slot]["type"] = None
610 entries[current_slot]["name"] = _("N/A")
613 # nim_slots is an array which has exactly one entry for each slot, even for empty ones.
616 for id, entry in entries.items():
617 if not (entry.has_key("name") and entry.has_key("type")):
618 entry["name"] = _("N/A")
620 self.nim_slots.append(NIM(slot = id, description = entry["name"], type = entry["type"]))
622 def hasNimType(self, chktype):
623 for slot in self.nim_slots:
624 if slot.isCompatible(chktype):
628 def getNimListOfType(self, type, exception = -1):
629 # returns a list of indexes for NIMs compatible to the given type, except for 'exception'
631 for x in self.nim_slots:
632 if x.isCompatible(type) and x.slot != exception:
639 self.terrestrialsList = []
641 self.readSatsfromFile()
643 InitNimManager(self) #init config stuff
645 # get a list with the friendly full description
648 for slot in self.nim_slots:
649 list.append(slot.friendly_full_description)
652 def getSatList(self):
655 def getSatListForNim(self, slotid):
657 if self.nim_slots[slotid].isCompatible("DVB-S"):
658 #print "slotid:", slotid
660 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.index]
661 #print "diseqcA:", config.Nims[slotid].diseqcA.value
662 configMode = config.Nims[slotid].configMode.value
664 if configMode == "equal":
665 slotid=0 #FIXME add handling for more than two tuners !!!
666 configMode = config.Nims[slotid].configMode.value
668 if configMode == "simple":
669 dm = config.Nims[slotid].diseqcMode.value
670 if dm in ["single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
671 list.append(self.satList[config.Nims[slotid].diseqcA.index])
672 if dm in ["toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
673 list.append(self.satList[config.Nims[slotid].diseqcB.index])
674 if dm == "diseqc_a_b_c_d":
675 list.append(self.satList[config.Nims[slotid].diseqcC.index])
676 list.append(self.satList[config.Nims[slotid].diseqcD.index])
677 if dm == "positioner":
678 for x in self.satList:
680 elif configMode == "advanced":
681 for x in self.satList:
682 if int(config.Nims[slotid].advanced.sat[x[0]].lnb.value) != 0:
687 def getRotorSatListForNim(self, slotid):
689 if self.nim_slots[slotid].isCompatible("DVB-S"):
690 #print "slotid:", slotid
692 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
693 #print "diseqcA:", config.Nims[slotid].diseqcA.value
694 configMode = config.Nims[slotid].configMode.value
695 if configMode == "simple":
696 if config.Nims[slotid].diseqcMode.value == "positioner":
697 for x in self.satList:
699 elif configMode == "advanced":
700 for x in self.satList:
701 nim = config.Nims[slotid]
702 lnbnum = int(nim.advanced.sat[x[0]].lnb.value)
704 lnb = nim.advanced.lnb[lnbnum]
705 if lnb.diseqcMode.value == "1_2":
710 config.sec = ConfigSubsection()
712 x = ConfigInteger(default=15, limits = (0, 9999))
713 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_CONT_TONE, configElement.value))
714 config.sec.delay_after_continuous_tone_change = x
716 x = ConfigInteger(default=10, limits = (0, 9999))
717 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_VOLTAGE_CHANGE, configElement.value))
718 config.sec.delay_after_final_voltage_change = x
720 x = ConfigInteger(default=120, limits = (0, 9999))
721 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_DISEQC_REPEATS, configElement.value))
722 config.sec.delay_between_diseqc_repeats = x
724 x = ConfigInteger(default=50, limits = (0, 9999))
725 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_LAST_DISEQC_CMD, configElement.value))
726 config.sec.delay_after_last_diseqc_command = x
728 x = ConfigInteger(default=50, limits = (0, 9999))
729 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value))
730 config.sec.delay_after_toneburst = x
732 x = ConfigInteger(default=200, limits = (0, 9999))
733 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS, configElement.value))
734 config.sec.delay_after_enable_voltage_before_switch_command = x
736 x = ConfigInteger(default=700, limits = (0, 9999))
737 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_SWITCH_AND_MOTOR_CMD, configElement.value))
738 config.sec.delay_between_switch_and_motor_command = x
740 x = ConfigInteger(default=150, limits = (0, 9999))
741 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MEASURE_IDLE_INPUTPOWER, configElement.value))
742 config.sec.delay_after_voltage_change_before_measure_idle_inputpower = x
744 x = ConfigInteger(default=750, limits = (0, 9999))
745 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_MOTOR_CMD, configElement.value))
746 config.sec.delay_after_enable_voltage_before_motor_command = x
748 x = ConfigInteger(default=150, limits = (0, 9999))
749 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_MOTOR_STOP_CMD, configElement.value))
750 config.sec.delay_after_motor_stop_command = x
752 x = ConfigInteger(default=150, limits = (0, 9999))
753 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MOTOR_CMD, configElement.value))
754 config.sec.delay_after_voltage_change_before_motor_command = x
756 x = ConfigInteger(default=120, limits = (0, 9999))
757 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_RUNNING_TIMEOUT, configElement.value))
758 config.sec.motor_running_timeout = x
760 x = ConfigInteger(default=1, limits = (0, 5))
761 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_COMMAND_RETRIES, configElement.value))
762 config.sec.motor_command_retries = x
764 x = ConfigInteger(default=20, limits = (0, 9999))
765 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS, configElement.value))
766 config.sec.delay_after_change_voltage_before_switch_command = x
768 # TODO add support for satpos depending nims to advanced nim configuration
769 # so a second/third/fourth cable from a motorized lnb can used behind a
770 # diseqc 1.0 / diseqc 1.1 / toneburst switch
771 # the C(++) part should can handle this
772 # the configElement should be only visible when diseqc 1.2 is disabled
774 def InitNimManager(nimmgr):
777 config.Nims = ConfigSubList()
778 for x in range(len(nimmgr.nim_slots)):
779 config.Nims.append(ConfigSubsection())
781 for slot in nimmgr.nim_slots:
785 # HACK: currently, we can only looptrough to socket A
787 if slot.isCompatible("DVB-S"):
789 nim.configMode = ConfigSelection(
791 "simple": _("simple"),
792 "advanced": _("advanced"),
793 "nothing": _("nothing connected"),
797 nim.configMode = ConfigSelection(
799 "equal": _("equal to Socket A"),
800 "loopthrough": _("loopthrough to socket A"),
801 "nothing": _("nothing connected"),
802 "satposdepends": _("second cable of motorized LNB"),
803 "simple": _("simple"),
804 "advanced": _("advanced")},
805 default = "loopthrough")
807 #important - check if just the 2nd one is LT only and the first one is DVB-S
808 # CHECKME: is this logic correct for >2 slots?
809 if nim.configMode.value in ["loopthrough", "satposdepends", "equal"]:
810 if x == 0: # first one can never be linked to anything
812 nim.configMode.value = "simple"
813 nim.configMode.save()
815 #FIXME: make it better
816 for y in nimmgr.nim_slots:
818 if not y.isCompatible("DVB-S"):
820 nim.configMode.value = "simple"
821 nim.configMode.save()
823 nim.diseqcMode = ConfigSelection(
825 ("single", _("Single")),
826 ("toneburst_a_b", _("Toneburst A/B")),
827 ("diseqc_a_b", _("DiSEqC A/B")),
828 ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")),
829 ("positioner", _("Positioner"))],
830 default = "diseqc_a_b")
832 nim.diseqcA = getConfigSatlist(192, nimmgr.satList)
833 nim.diseqcB = getConfigSatlist(130, nimmgr.satList)
834 nim.diseqcC = ConfigSatlist(list = nimmgr.satList)
835 nim.diseqcD = ConfigSatlist(list = nimmgr.satList)
836 nim.positionerMode = ConfigSelection(
838 ("usals", _("USALS")),
839 ("manual", _("manual"))],
841 nim.longitude = ConfigFloat(default=[5,100], limits=[(0,359),(0,999)])
842 nim.longitudeOrientation = ConfigSelection(choices={"east": _("East"), "west": _("West")}, default = "east")
843 nim.latitude = ConfigFloat(default=[50,767], limits=[(0,359),(0,999)])
844 nim.latitudeOrientation = ConfigSelection(choices={"north": _("North"), "south": _("South")}, default="north")
845 nim.powerMeasurement = ConfigYesNo(default=True)
846 nim.powerThreshold = ConfigInteger(default=50, limits=(0, 100))
847 nim.turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch")) ], default = "fast")
848 btime = datetime(1970, 1, 1, 7, 0);
849 nim.fastTurningBegin = ConfigDateTime(default = mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 900)
850 etime = datetime(1970, 1, 1, 19, 0);
851 nim.fastTurningEnd = ConfigDateTime(default = mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 900)
852 # get other frontends of the same type
854 satNimList = nimmgr.getNimListOfType("DVB-S", slot.slot)
858 n = nimmgr.nim_slots[x]
859 satNimListNames["%d" % n.slot] = n.friendly_full_description
861 if len(satNimListNames):
862 nim.equalTo = ConfigSelection(choices = satNimListNames)
863 nim.linkedTo = ConfigSelection(choices = satNimListNames)
864 nim.satposDependsTo = ConfigSelection(choices = satNimListNames)
867 nim.advanced = ConfigSubsection()
868 nim.advanced.sats = getConfigSatlist(192,nimmgr.satList)
869 nim.advanced.sat = ConfigSubDict()
870 lnbs = [("0", "not available")]
871 for y in range(1, 33):
872 lnbs.append((str(y), "LNB " + str(y)))
874 for x in nimmgr.satList:
875 nim.advanced.sat[x[0]] = ConfigSubsection()
876 nim.advanced.sat[x[0]].voltage = ConfigSelection(choices={"polarization": _("Polarization"), "13V": _("13 V"), "18V": _("18 V")}, default = "polarization")
877 nim.advanced.sat[x[0]].tonemode = ConfigSelection(choices={"band": _("Band"), "on": _("On"), "off": _("Off")}, default = "band")
878 nim.advanced.sat[x[0]].usals = ConfigYesNo(default=True)
879 nim.advanced.sat[x[0]].rotorposition = ConfigInteger(default=1, limits=(1, 255))
880 nim.advanced.sat[x[0]].lnb = ConfigSelection(choices = lnbs)
882 csw = [("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))]
883 for y in range(0, 16):
884 csw.append((str(0xF0|y), "Input " + str(y+1)))
886 ucsw = [("0", _("None"))]
887 for y in range(1, 17):
888 ucsw.append((str(y), "Input " + str(y)))
890 nim.advanced.lnb = ConfigSubList()
891 nim.advanced.lnb.append(ConfigNothing())
892 for x in range(1, 33):
893 nim.advanced.lnb.append(ConfigSubsection())
894 nim.advanced.lnb[x].lof = ConfigSelection(choices={"universal_lnb": _("Universal LNB"), "c_band": _("C-Band"), "user_defined": _("User defined")}, default="universal_lnb")
895 nim.advanced.lnb[x].lofl = ConfigInteger(default=9750, limits = (0, 99999))
896 nim.advanced.lnb[x].lofh = ConfigInteger(default=10600, limits = (0, 99999))
897 nim.advanced.lnb[x].threshold = ConfigInteger(default=11700, limits = (0, 99999))
898 # nim.advanced.lnb[x].output_12v = ConfigSelection(choices = [("0V", _("0 V")), ("12V", _("12 V"))], default="0V")
899 nim.advanced.lnb[x].increased_voltage = ConfigYesNo(default=False)
900 nim.advanced.lnb[x].toneburst = ConfigSelection(choices = [("none", _("None")), ("A", _("A")), ("B", _("B"))], default = "none")
901 nim.advanced.lnb[x].diseqcMode = ConfigSelection(choices = [("none", _("None")), ("1_0", _("1.0")), ("1_1", _("1.1")), ("1_2", _("1.2"))], default = "none")
902 nim.advanced.lnb[x].commitedDiseqcCommand = ConfigSelection(choices = csw)
903 nim.advanced.lnb[x].fastDiseqc = ConfigYesNo(default=False)
904 nim.advanced.lnb[x].sequenceRepeat = ConfigYesNo(default=False)
905 nim.advanced.lnb[x].commandOrder1_0 = ConfigSelection(choices = [("ct", "committed, toneburst"), ("tc", "toneburst, committed")], default = "ct")
906 nim.advanced.lnb[x].commandOrder = ConfigSelection(choices = [
907 ("ct", "committed, toneburst"),
908 ("tc", "toneburst, committed"),
909 ("cut", "committed, uncommitted, toneburst"),
910 ("tcu", "toneburst, committed, uncommitted"),
911 ("uct", "uncommitted, committed, toneburst"),
912 ("tuc", "toneburst, uncommitted, commmitted")],
914 nim.advanced.lnb[x].uncommittedDiseqcCommand = ConfigSelection(choices = ucsw)
915 nim.advanced.lnb[x].diseqcRepeats = ConfigSelection(choices = [("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))], default = "none")
916 nim.advanced.lnb[x].longitude = ConfigFloat(default = [5,100], limits = [(0,359),(0,999)])
917 nim.advanced.lnb[x].longitudeOrientation = ConfigSelection(choices = [("east", _("East")), ("west", _("West"))], default = "east")
918 nim.advanced.lnb[x].latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)])
919 nim.advanced.lnb[x].latitudeOrientation = ConfigSelection(choices = [("north", _("North")), ("south", _("South"))], default = "north")
920 nim.advanced.lnb[x].powerMeasurement = ConfigYesNo(default=True)
921 nim.advanced.lnb[x].powerThreshold = ConfigInteger(default=50, limits=(0, 100))
922 nim.advanced.lnb[x].turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch"))], default = "fast")
923 btime = datetime(1970, 1, 1, 7, 0);
924 nim.advanced.lnb[x].fastTurningBegin = ConfigDateTime(default=mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 600)
925 etime = datetime(1970, 1, 1, 19, 0);
926 nim.advanced.lnb[x].fastTurningEnd = ConfigDateTime(default=mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 600)
927 elif slot.isCompatible("DVB-C"):
928 nim.configMode = ConfigSelection(
930 "enabled": _("enabled"),
931 "nothing": _("nothing connected"),
936 for x in nimmgr.cablesList:
937 list.append((str(n), x[0]))
939 nim.cable = ConfigSubsection()
940 possible_scan_types = [("bands", _("Frequency bands")), ("steps", _("Frequency steps"))]
942 possible_scan_types.append(("provider", _("Provider")))
943 nim.cable.scan_type = ConfigSelection(default = "bands", choices = possible_scan_types)
944 nim.cable.scan_provider = ConfigSelection(default = "0", choices = list)
945 nim.cable.scan_band_EU_VHF_I = ConfigYesNo(default = True)
946 nim.cable.scan_band_EU_MID = ConfigYesNo(default = True)
947 nim.cable.scan_band_EU_VHF_III = ConfigYesNo(default = True)
948 nim.cable.scan_band_EU_UHF_IV = ConfigYesNo(default = True)
949 nim.cable.scan_band_EU_UHF_V = ConfigYesNo(default = True)
950 nim.cable.scan_band_EU_SUPER = ConfigYesNo(default = True)
951 nim.cable.scan_band_EU_HYPER = ConfigYesNo(default = True)
952 nim.cable.scan_band_US_LOW = ConfigYesNo(default = False)
953 nim.cable.scan_band_US_MID = ConfigYesNo(default = False)
954 nim.cable.scan_band_US_HIGH = ConfigYesNo(default = False)
955 nim.cable.scan_band_US_SUPER = ConfigYesNo(default = False)
956 nim.cable.scan_band_US_HYPER = ConfigYesNo(default = False)
957 nim.cable.scan_frequency_steps = ConfigInteger(default = 1000, limits = (1000, 10000))
958 nim.cable.scan_mod_qam16 = ConfigYesNo(default = False)
959 nim.cable.scan_mod_qam32 = ConfigYesNo(default = False)
960 nim.cable.scan_mod_qam64 = ConfigYesNo(default = True)
961 nim.cable.scan_mod_qam128 = ConfigYesNo(default = False)
962 nim.cable.scan_mod_qam256 = ConfigYesNo(default = True)
963 nim.cable.scan_sr_6900 = ConfigYesNo(default = True)
964 nim.cable.scan_sr_6875 = ConfigYesNo(default = True)
965 nim.cable.scan_sr_ext1 = ConfigInteger(default = 0, limits = (0, 7230))
966 nim.cable.scan_sr_ext2 = ConfigInteger(default = 0, limits = (0, 7230))
967 elif slot.isCompatible("DVB-T"):
968 nim.configMode = ConfigSelection(
970 "enabled": _("enabled"),
971 "nothing": _("nothing connected"),
976 for x in nimmgr.terrestrialsList:
977 list.append((str(n), x[0]))
979 nim.terrestrial = ConfigSelection(choices = list)
980 nim.terrestrial_5V = ConfigOnOff()
982 nim.configMode = ConfigSelection(choices = { "nothing": _("disabled") }, default="nothing");
983 print "pls add support for this frontend type!"
986 nimmgr.sec = SecConfigure(nimmgr)
988 nimmanager = NimManager()