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 import xml.dom.minidom
11 from xml.dom import EMPTY_NAMESPACE
12 from skin import elementsWithTag
13 from Tools import XMLTools
15 from xml.sax import make_parser
16 from xml.sax.handler import ContentHandler
18 from Tools.BoundFunction import boundFunction
19 from time import localtime, mktime
20 from datetime import datetime
22 def getConfigSatlist(orbpos, satlist):
26 default_orbpos = orbpos
28 return ConfigSatlist(satlist, default_orbpos)
30 def tryOpen(filename):
32 procFile = open(filename)
38 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):
41 tunermask = 1 << slotid
42 if self.equal.has_key(slotid):
43 tunermask |= (1 << self.equal[slotid])
44 elif self.linked.has_key(slotid):
45 tunermask |= (1 << self.linked[slotid])
46 sec.setLNBLOFL(9750000)
47 sec.setLNBLOFH(10600000)
48 sec.setLNBThreshold(11700000)
49 sec.setLNBIncreasedVoltage(lnbParam.OFF)
53 sec.setVoltageMode(switchParam.HV)
54 sec.setToneMode(switchParam.HILO)
55 sec.setCommandOrder(0)
58 sec.setDiSEqCMode(diseqcmode)
59 sec.setToneburst(toneburstmode)
60 sec.setCommittedCommand(diseqcpos)
61 sec.setUncommittedCommand(0) # SENDNO
62 #print "set orbpos to:" + str(orbpos)
64 if 0 <= diseqcmode < 3:
65 sec.addSatellite(orbpos)
66 self.satList.append(orbpos)
67 elif (diseqcmode == 3): # diseqc 1.2
68 if self.satposdepends.has_key(slotid):
69 tunermask |= (1 << self.satposdepends[slotid])
70 sec.setLatitude(latitude)
71 sec.setLaDirection(laDirection)
72 sec.setLongitude(longitude)
73 sec.setLoDirection(loDirection)
74 sec.setUseInputpower(True)
75 sec.setInputpowerDelta(50)
76 sec.setRotorTurningSpeed(turningSpeed)
78 for x in self.NimManager.satList:
79 print "Add sat " + str(x[0])
80 sec.addSatellite(int(x[0]))
83 sec.setRotorPosNum(0) # USALS
84 self.satList.append(int(x[0]))
86 sec.setLNBSlotMask(tunermask)
88 def setSatposDepends(self, sec, nim1, nim2):
89 print "tuner", nim1, "depends on satpos of", nim2
90 sec.setTunerDepends(nim1, nim2)
92 def linkNIMs(self, sec, nim1, nim2):
93 print "link tuner", nim1, "to tuner", nim2
94 sec.setTunerLinked(nim1, nim2)
100 sec = secClass.getInstance()
101 sec.clear() ## this do unlinking NIMs too !!
102 print "sec config cleared"
106 self.satposdepends = { }
109 nim_slots = self.NimManager.nim_slots
113 for slot in nim_slots:
116 if slot.isCompatible("DVB-S"):
117 # save what nim we link to/are equal to/satposdepends to.
118 # this is stored in the *value* (not index!) of the config list
119 if nim.configMode.value == "equal":
120 self.equal[int(nim.equalTo.value)]=x
121 elif nim.configMode.value == "loopthrough":
122 self.linkNIMs(sec, x, int(nim.linkedTo.value))
123 self.linked[int(nim.linkedTo.value)]=x
124 elif nim.configMode.value == "satposdepends":
125 self.setSatposDepends(sec, x, int(nim.satposDependsTo.value))
126 self.satposdepends[int(nim.satposDependsTo.value)]=x
128 if slot.type is not None:
129 used_nim_slots.append((slot.slot, slot.description, nim.configMode.value != "nothing" and True or False))
131 eDVBResourceManager.getInstance().setFrontendSlotInformations(used_nim_slots)
133 for slot in nim_slots:
136 if slot.isCompatible("DVB-S"):
137 print "slot: " + str(x) + " configmode: " + str(nim.configMode.value)
138 print "diseqcmode: ", nim.configMode.value
139 if nim.configMode.value in [ "loopthrough", "satposdepends", "nothing" ]:
142 sec.setSlotNotLinked(x)
143 if nim.configMode.value == "equal":
145 elif nim.configMode.value == "simple": #simple config
146 if nim.diseqcMode.value == "single": #single
147 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.NONE, diseqcpos = diseqcParam.SENDNO)
148 elif nim.diseqcMode.value == "toneburst_a_b": #Toneburst A/B
149 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.A, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO)
150 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.B, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO)
151 elif nim.diseqcMode.value == "diseqc_a_b": #DiSEqC A/B
152 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA)
153 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB)
154 elif nim.diseqcMode.value == "diseqc_a_b_c_d": #DiSEqC A/B/C/D
155 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA)
156 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB)
157 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcC.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BA)
158 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcD.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BB)
159 elif nim.diseqcMode.value == "positioner": #Positioner
160 if nim.latitudeOrientation.value == "north":
161 laValue = rotorParam.NORTH
163 laValue = rotorParam.SOUTH
164 if nim.longitudeOrientation.value == "east":
165 loValue = rotorParam.EAST
167 loValue = rotorParam.WEST
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 elif nim.configMode.value == "advanced": #advanced config
183 self.updateAdvanced(sec, x)
184 print "sec config completed"
186 def updateAdvanced(self, sec, slotid):
188 for x in range(1,33):
190 for x in self.NimManager.satList:
191 lnb = int(config.Nims[slotid].advanced.sat[x[0]].lnb.value)
193 print "add", x[0], "to", lnb
194 lnbSat[lnb].append(x[0])
195 for x in range(1,33):
196 if len(lnbSat[x]) > 0:
197 currLnb = config.Nims[slotid].advanced.lnb[x]
200 tunermask = 1 << slotid
201 if self.equal.has_key(slotid):
202 tunermask |= (1 << self.equal[slotid])
203 elif self.linked.has_key(slotid):
204 tunermask |= (1 << self.linked[slotid])
206 if currLnb.lof.value == "universal_lnb":
207 sec.setLNBLOFL(9750000)
208 sec.setLNBLOFH(10600000)
209 sec.setLNBThreshold(11700000)
210 elif currLnb.lof.value == "c_band":
211 sec.setLNBLOFL(5150000)
212 sec.setLNBLOFH(5150000)
213 sec.setLNBThreshold(5150000)
214 elif currLnb.lof.value == "user_defined":
215 sec.setLNBLOFL(currLnb.lofl.value * 1000)
216 sec.setLNBLOFH(currLnb.lofh.value * 1000)
217 sec.setLNBThreshold(currLnb.threshold.value * 1000)
219 # if currLnb.output_12v.value == "0V":
220 # pass # nyi in drivers
221 # elif currLnb.output_12v.value == "12V":
222 # pass # nyi in drivers
224 if currLnb.increased_voltage.value:
225 sec.setLNBIncreasedVoltage(lnbParam.ON)
227 sec.setLNBIncreasedVoltage(lnbParam.OFF)
229 dm = currLnb.diseqcMode.value
231 sec.setDiSEqCMode(diseqcParam.NONE)
233 sec.setDiSEqCMode(diseqcParam.V1_0)
235 sec.setDiSEqCMode(diseqcParam.V1_1)
237 sec.setDiSEqCMode(diseqcParam.V1_2)
239 if self.satposdepends.has_key(slotid): # only useable with rotors
240 tunermask |= (1 << self.satposdepends[slotid])
243 if currLnb.toneburst.value == "none":
244 sec.setToneburst(diseqcParam.NO)
245 elif currLnb.toneburst.value == "A":
246 sec.setToneburst(diseqcParam.A)
247 elif currLnb.toneburst.value == "B":
248 sec.setToneburst(diseqcParam.B)
250 # Committed Diseqc Command
251 cdc = currLnb.commitedDiseqcCommand.value
253 c = { "none": diseqcParam.SENDNO,
254 "AA": diseqcParam.AA,
255 "AB": diseqcParam.AB,
256 "BA": diseqcParam.BA,
257 "BB": diseqcParam.BB }
260 sec.setCommittedCommand(c[cdc])
262 sec.setCommittedCommand(long(cdc))
264 sec.setFastDiSEqC(currLnb.fastDiseqc.value)
266 sec.setSeqRepeat(currLnb.sequenceRepeat.value)
268 if currLnb.diseqcMode.value == "1_0":
269 currCO = currLnb.commandOrder1_0.value
271 currCO = currLnb.commandOrder.value
273 udc = int(currLnb.uncommittedDiseqcCommand.value)
275 sec.setUncommittedCommand(0xF0|(udc-1))
277 sec.setUncommittedCommand(0) # SENDNO
279 sec.setRepeats({"none": 0, "one": 1, "two": 2, "three": 3}[currLnb.diseqcRepeats.value])
281 setCommandOrder = False
283 # 0 "committed, toneburst",
284 # 1 "toneburst, committed",
285 # 2 "committed, uncommitted, toneburst",
286 # 3 "toneburst, committed, uncommitted",
287 # 4 "uncommitted, committed, toneburst"
288 # 5 "toneburst, uncommitted, commmitted"
289 order_map = {"ct": 0, "tc": 1, "cut": 2, "tcu": 3, "uct": 4, "tuc": 5}
290 sec.setCommandOrder(order_map[currCO])
293 latitude = currLnb.latitude.float
294 sec.setLatitude(latitude)
295 longitude = currLnb.longitude.float
296 sec.setLongitude(longitude)
297 if currLnb.latitudeOrientation.value == "north":
298 sec.setLaDirection(rotorParam.NORTH)
300 sec.setLaDirection(rotorParam.SOUTH)
301 if currLnb.longitudeOrientation.value == "east":
302 sec.setLoDirection(rotorParam.EAST)
304 sec.setLoDirection(rotorParam.WEST)
306 if currLnb.powerMeasurement.value:
307 sec.setUseInputpower(True)
308 sec.setInputpowerDelta(currLnb.powerThreshold.value)
309 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
310 if turn_speed_dict.has_key(currLnb.turningSpeed.value):
311 turning_speed = turn_speed_dict[currLnb.turningSpeed.value]
313 beg_time = localtime(currLnb.fastTurningBegin.value)
314 end_time = localtime(currLnb.fastTurningEnd.value)
315 turning_speed = ((beg_time.tm_hour + 1) * 60 + beg_time.tm_min + 1) << 16
316 turning_speed |= (end_time.tm_hour + 1) * 60 + end_time.tm_min + 1
317 sec.setRotorTurningSpeed(turning_speed)
319 sec.setUseInputpower(False)
321 sec.setLNBSlotMask(tunermask)
323 # finally add the orbital positions
326 currSat = config.Nims[slotid].advanced.sat[y]
328 if currSat.voltage.value == "polarization":
329 sec.setVoltageMode(switchParam.HV)
330 elif currSat.voltage.value == "13V":
331 sec.setVoltageMode(switchParam._14V)
332 elif currSat.voltage.value == "18V":
333 sec.setVoltageMode(switchParam._18V)
335 if currSat.tonemode == "band":
336 sec.setToneMode(switchParam.HILO)
337 elif currSat.tonemode == "on":
338 sec.setToneMode(switchParam.ON)
339 elif currSat.tonemode == "off":
340 sec.setToneMode(switchParam.OFF)
342 if not currSat.usals.value:
343 sec.setRotorPosNum(currSat.rotorposition.value)
345 sec.setRotorPosNum(0) #USALS
347 def __init__(self, nimmgr):
348 self.NimManager = nimmgr
352 def __init__(self, slot, type, description):
355 if type not in ["DVB-S", "DVB-C", "DVB-T", "DVB-S2", None]:
356 print "warning: unknown NIM type %s, not using." % type
360 self.description = description
362 def isCompatible(self, what):
365 "DVB-S": ["DVB-S", None],
366 "DVB-C": ["DVB-C", None],
367 "DVB-T": ["DVB-T", None],
368 "DVB-S2": ["DVB-S", "DVB-S2", None]
370 return what in compatible[self.type]
372 def getSlotName(self):
373 # get a friendly description for a slot name.
374 # we name them "Tuner A/B/C/...", because that's what's usually written on the back
376 return _("Tuner ") + chr(ord('A') + self.slot)
378 slot_name = property(getSlotName)
381 return chr(ord('A') + self.slot)
383 slot_id = property(getSlotID)
385 def getFriendlyType(self):
394 friendly_type = property(getFriendlyType)
396 def getFriendlyFullDescription(self):
397 nim_text = self.slot_name + ": "
400 nim_text += _("(empty)")
402 nim_text += self.description + " (" + self.friendly_type + ")"
406 friendly_full_description = property(getFriendlyFullDescription)
407 config_mode = property(lambda self: config.Nims[self.slot].configMode.value)
408 config = property(lambda self: config.Nims[self.slot])
409 empty = property(lambda self: self.type is None)
412 class parseSats(ContentHandler):
413 def __init__(self, satList, satellites, transponders):
414 self.isPointsElement, self.isReboundsElement = 0, 0
415 self.satList = satList
416 self.satellites = satellites
417 self.transponders = transponders
419 def startElement(self, name, attrs):
421 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
422 tpos = int(attrs.get('position',""))
425 tname = attrs.get('name',"").encode("UTF-8")
426 self.satellites[tpos] = tname
427 self.satList.append( (tpos, tname) )
428 self.parsedSat = int(tpos)
429 elif (name == "transponder"):
430 modulation = int(attrs.get('modulation',"1")) # QPSK default
431 system = int(attrs.get('system',"0")) # DVB-S default
432 freq = int(attrs.get('frequency',""))
433 sr = int(attrs.get('symbol_rate',""))
434 pol = int(attrs.get('polarization',""))
435 fec = int(attrs.get('fec_inner',"0")) # AUTO default
436 if self.parsedSat in self.transponders:
439 self.transponders[self.parsedSat] = [ ]
441 self.transponders[self.parsedSat].append((0, freq, sr, pol, fec, system, modulation))
443 class parseCables(ContentHandler):
444 def __init__(self, cablesList, transponders):
445 self.isPointsElement, self.isReboundsElement = 0, 0
446 self.cablesList = cablesList
447 for x in self.cablesList:
448 self.cablesList.remove(x)
449 self.transponders = transponders
451 def startElement(self, name, attrs):
452 if (name == "cable"):
453 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
454 tname = attrs.get('name',"").encode("UTF-8")
455 tflags = int(attrs.get('flags',"0"))
456 self.cablesList.append((tname, tflags))
457 self.parsedCab = tname
458 elif (name == "transponder"):
459 freq = int(attrs.get('frequency',""))
462 sr = int(attrs.get('symbol_rate',"0"))
463 mod = int(attrs.get('modulation',"3")) # QAM64 default
464 fec = int(attrs.get('fec_inner',"0")) # AUTO default
465 if self.parsedCab in self.transponders:
468 self.transponders[self.parsedCab] = [ ]
469 self.transponders[self.parsedCab].append((1, freq, sr, mod, fec))
471 class parseTerrestrials(ContentHandler):
472 def __init__(self, terrestrialsList, transponders):
473 self.isPointsElement, self.isReboundsElement = 0, 0
474 self.terrestrialsList = terrestrialsList
475 self.transponders = transponders
477 def startElement(self, name, attrs):
478 if (name == "terrestrial"):
479 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
480 tname = attrs.get('name',"").encode("UTF-8")
481 tflags = attrs.get('flags',"")
482 self.terrestrialsList.append((tname, tflags))
483 self.parsedTer = str(tname)
484 elif (name == "transponder"):
486 freq = int(attrs.get('centre_frequency',""))
487 bw = int(attrs.get('bandwidth',"3")) # AUTO
488 const = int(attrs.get('constellation',"1")) # AUTO
489 crh = int(attrs.get('code_rate_hp',"5")) # AUTO
490 if crh > 5: # our terrestrial.xml is buggy... 6 for AUTO
492 crl = int(attrs.get('code_rate_lp',"5")) # AUTO
493 if crl > 5: # our terrestrial.xml is buggy... 6 for AUTO
495 guard = int(attrs.get('guard_interval',"4")) # AUTO
496 transm = int(attrs.get('transmission_mode',"2")) # AUTO
497 hierarchy = int(attrs.get('hierarchy_information',"4")) # AUTO
498 inv = int(attrs.get('inversion',"2")) # AUTO
499 if self.parsedTer in self.transponders:
502 self.transponders[self.parsedTer] = [ ]
504 self.transponders[self.parsedTer].append((2, freq, bw, const, crh, crl, guard, transm, hierarchy, inv))
506 def getTransponders(self, pos):
507 if self.transponders.has_key(pos):
508 return self.transponders[pos]
512 def getTranspondersCable(self, nim):
513 nimConfig = config.Nims[nim]
514 if nimConfig.configMode.value != "nothing" and nimConfig.cable.scan_type.value == "provider":
515 return self.transponderscable[self.cablesList[nimConfig.cable.scan_provider.index][0]]
518 def getTranspondersTerrestrial(self, region):
519 return self.transpondersterrestrial[region]
521 def getCableDescription(self, nim):
522 return self.cablesList[config.Nims[nim].scan_provider.index][0]
524 def getCableFlags(self, nim):
525 return self.cablesList[config.Nims[nim].scan_provider.index][1]
527 def getTerrestrialDescription(self, nim):
528 return self.terrestrialsList[config.Nims[nim].terrestrial.index][0]
530 def getTerrestrialFlags(self, nim):
531 return self.terrestrialsList[config.Nims[nim].terrestrial.index][1]
533 def getConfiguredSats(self):
534 return self.sec.getSatList()
536 def getSatDescription(self, pos):
537 return self.satellites[pos]
539 def readSatsfromFile(self):
540 # read initial networks from file. we only read files which we are interested in,
541 # which means only these where a compatible tuner exists.
542 self.satellites = { }
543 self.transponders = { }
544 self.transponderscable = { }
545 self.transpondersterrestrial = { }
547 parser = make_parser()
549 if self.hasNimType("DVB-S"):
550 print "Reading satellites.xml"
551 satHandler = self.parseSats(self.satList, self.satellites, self.transponders)
552 parser.setContentHandler(satHandler)
553 parser.parse('/etc/tuxbox/satellites.xml')
555 if self.hasNimType("DVB-C"):
556 print "Reading cables.xml"
557 cabHandler = self.parseCables(self.cablesList, self.transponderscable)
558 parser.setContentHandler(cabHandler)
559 parser.parse('/etc/tuxbox/cables.xml')
561 if self.hasNimType("DVB-T"):
562 print "Reading terrestrial.xml"
563 terHandler = self.parseTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
564 parser.setContentHandler(terHandler)
565 parser.parse('/etc/tuxbox/terrestrial.xml')
567 def enumerateNIMs(self):
568 # enum available NIMs. This is currently very dreambox-centric and uses the /proc/bus/nim_sockets interface.
569 # the result will be stored into nim_slots.
570 # the content of /proc/bus/nim_sockets looks like:
573 # Name: BCM4501 DVB-S2 NIM (internal)
576 # Name: BCM4501 DVB-S2 NIM (internal)
579 # Name: Philips TU1216
582 # Name: Alps BSBE1 702A
585 # Type will be either "DVB-S", "DVB-S2", "DVB-T", "DVB-C" or None.
587 nimfile = tryOpen("/proc/bus/nim_sockets")
595 for line in nimfile.readlines():
598 if line.strip().startswith("NIM Socket"):
599 parts = line.strip().split(" ")
600 current_slot = int(parts[2][:-1])
601 entries[current_slot] = {}
602 elif line.strip().startswith("Type:"):
603 entries[current_slot]["type"] = str(line.strip()[6:])
604 elif line.strip().startswith("Name:"):
605 entries[current_slot]["name"] = str(line.strip()[6:])
606 elif line.strip().startswith("empty"):
607 entries[current_slot]["type"] = None
608 entries[current_slot]["name"] = _("N/A")
611 # nim_slots is an array which has exactly one entry for each slot, even for empty ones.
614 for id, entry in entries.items():
615 if not (entry.has_key("name") and entry.has_key("type")):
616 entry["name"] = _("N/A")
618 self.nim_slots.append(NIM(slot = id, description = entry["name"], type = entry["type"]))
620 def hasNimType(self, chktype):
621 for slot in self.nim_slots:
622 if slot.isCompatible(chktype):
626 def getNimListOfType(self, type, exception = -1):
627 # returns a list of indexes for NIMs compatible to the given type, except for 'exception'
629 for x in self.nim_slots:
630 if x.isCompatible(type) and x.slot != exception:
637 self.terrestrialsList = []
639 self.readSatsfromFile()
641 InitNimManager(self) #init config stuff
643 # get a list with the friendly full description
646 for slot in self.nim_slots:
647 list.append(slot.friendly_full_description)
650 def getSatList(self):
653 def getSatListForNim(self, slotid):
655 if self.nim_slots[slotid].isCompatible("DVB-S"):
656 #print "slotid:", slotid
658 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.index]
659 #print "diseqcA:", config.Nims[slotid].diseqcA.value
660 configMode = config.Nims[slotid].configMode.value
662 if configMode == "equal":
663 slotid=0 #FIXME add handling for more than two tuners !!!
664 configMode = config.Nims[slotid].configMode.value
666 if configMode == "simple":
667 dm = config.Nims[slotid].diseqcMode.value
668 if dm in ["single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
669 list.append(self.satList[config.Nims[slotid].diseqcA.index])
670 if dm in ["toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
671 list.append(self.satList[config.Nims[slotid].diseqcB.index])
672 if dm == "diseqc_a_b_c_d":
673 list.append(self.satList[config.Nims[slotid].diseqcC.index])
674 list.append(self.satList[config.Nims[slotid].diseqcD.index])
675 if dm == "positioner":
676 for x in self.satList:
678 elif configMode == "advanced":
679 for x in self.satList:
680 if int(config.Nims[slotid].advanced.sat[x[0]].lnb.value) != 0:
685 def getRotorSatListForNim(self, slotid):
687 if self.nim_slots[slotid].isCompatible("DVB-S"):
688 #print "slotid:", slotid
690 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
691 #print "diseqcA:", config.Nims[slotid].diseqcA.value
692 configMode = config.Nims[slotid].configMode.value
693 if configMode == "simple":
694 if config.Nims[slotid].diseqcMode.value == "positioner":
695 for x in self.satList:
697 elif configMode == "advanced":
698 for x in self.satList:
699 nim = config.Nims[slotid]
700 lnbnum = int(nim.advanced.sat[x[0]].lnb.value)
702 lnb = nim.advanced.lnb[lnbnum]
703 if lnb.diseqcMode.value == "1_2":
708 config.sec = ConfigSubsection()
710 x = ConfigInteger(default=15, limits = (0, 9999))
711 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_CONT_TONE, configElement.value))
712 config.sec.delay_after_continuous_tone_change = x
714 x = ConfigInteger(default=10, limits = (0, 9999))
715 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_VOLTAGE_CHANGE, configElement.value))
716 config.sec.delay_after_final_voltage_change = x
718 x = ConfigInteger(default=120, limits = (0, 9999))
719 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_DISEQC_REPEATS, configElement.value))
720 config.sec.delay_between_diseqc_repeats = x
722 x = ConfigInteger(default=50, limits = (0, 9999))
723 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_LAST_DISEQC_CMD, configElement.value))
724 config.sec.delay_after_last_diseqc_command = x
726 x = ConfigInteger(default=50, limits = (0, 9999))
727 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value))
728 config.sec.delay_after_toneburst = x
730 x = ConfigInteger(default=200, limits = (0, 9999))
731 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS, configElement.value))
732 config.sec.delay_after_enable_voltage_before_switch_command = x
734 x = ConfigInteger(default=700, limits = (0, 9999))
735 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_SWITCH_AND_MOTOR_CMD, configElement.value))
736 config.sec.delay_between_switch_and_motor_command = x
738 x = ConfigInteger(default=150, limits = (0, 9999))
739 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MEASURE_IDLE_INPUTPOWER, configElement.value))
740 config.sec.delay_after_voltage_change_before_measure_idle_inputpower = x
742 x = ConfigInteger(default=750, limits = (0, 9999))
743 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_MOTOR_CMD, configElement.value))
744 config.sec.delay_after_enable_voltage_before_motor_command = x
746 x = ConfigInteger(default=150, limits = (0, 9999))
747 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_MOTOR_STOP_CMD, configElement.value))
748 config.sec.delay_after_motor_stop_command = x
750 x = ConfigInteger(default=150, limits = (0, 9999))
751 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MOTOR_CMD, configElement.value))
752 config.sec.delay_after_voltage_change_before_motor_command = x
754 x = ConfigInteger(default=120, limits = (0, 9999))
755 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_RUNNING_TIMEOUT, configElement.value))
756 config.sec.motor_running_timeout = x
758 x = ConfigInteger(default=1, limits = (0, 5))
759 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_COMMAND_RETRIES, configElement.value))
760 config.sec.motor_command_retries = x
762 x = ConfigInteger(default=20, limits = (0, 9999))
763 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS, configElement.value))
764 config.sec.delay_after_change_voltage_before_switch_command = x
766 # TODO add support for satpos depending nims to advanced nim configuration
767 # so a second/third/fourth cable from a motorized lnb can used behind a
768 # diseqc 1.0 / diseqc 1.1 / toneburst switch
769 # the C(++) part should can handle this
770 # the configElement should be only visible when diseqc 1.2 is disabled
772 def InitNimManager(nimmgr):
775 config.Nims = ConfigSubList()
776 for x in range(len(nimmgr.nim_slots)):
777 config.Nims.append(ConfigSubsection())
779 for slot in nimmgr.nim_slots:
783 # HACK: currently, we can only looptrough to socket A
785 if slot.isCompatible("DVB-S"):
787 nim.configMode = ConfigSelection(
789 "simple": _("simple"),
790 "advanced": _("advanced"),
791 "nothing": _("nothing connected"),
795 nim.configMode = ConfigSelection(
797 "equal": _("equal to Socket A"),
798 "loopthrough": _("loopthrough to socket A"),
799 "nothing": _("nothing connected"),
800 "satposdepends": _("second cable of motorized LNB"),
801 "simple": _("simple"),
802 "advanced": _("advanced")},
803 default = "loopthrough")
805 #important - check if just the 2nd one is LT only and the first one is DVB-S
806 # CHECKME: is this logic correct for >2 slots?
807 if nim.configMode.value in ["loopthrough", "satposdepends", "equal"]:
808 if x == 0: # first one can never be linked to anything
810 nim.configMode.value = "simple"
811 nim.configMode.save()
813 #FIXME: make it better
814 for y in nimmgr.nim_slots:
816 if not y.isCompatible("DVB-S"):
818 nim.configMode.value = "simple"
819 nim.configMode.save()
821 nim.diseqcMode = ConfigSelection(
823 ("single", _("Single")),
824 ("toneburst_a_b", _("Toneburst A/B")),
825 ("diseqc_a_b", _("DiSEqC A/B")),
826 ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")),
827 ("positioner", _("Positioner"))],
828 default = "diseqc_a_b")
830 nim.diseqcA = getConfigSatlist(192, nimmgr.satList)
831 nim.diseqcB = getConfigSatlist(130, nimmgr.satList)
832 nim.diseqcC = ConfigSatlist(list = nimmgr.satList)
833 nim.diseqcD = ConfigSatlist(list = nimmgr.satList)
834 nim.positionerMode = ConfigSelection(
836 ("usals", _("USALS")),
837 ("manual", _("manual"))],
839 nim.longitude = ConfigFloat(default=[5,100], limits=[(0,359),(0,999)])
840 nim.longitudeOrientation = ConfigSelection(choices={"east": _("East"), "west": _("West")}, default = "east")
841 nim.latitude = ConfigFloat(default=[50,767], limits=[(0,359),(0,999)])
842 nim.latitudeOrientation = ConfigSelection(choices={"north": _("North"), "south": _("South")}, default="north")
843 nim.turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch")) ], default = "fast")
844 btime = datetime(1970, 1, 1, 7, 0);
845 nim.fastTurningBegin = ConfigDateTime(default = mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 900)
846 etime = datetime(1970, 1, 1, 19, 0);
847 nim.fastTurningEnd = ConfigDateTime(default = mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 900)
848 # get other frontends of the same type
850 satNimList = nimmgr.getNimListOfType("DVB-S", slot.slot)
854 n = nimmgr.nim_slots[x]
855 satNimListNames["%d" % n.slot] = n.friendly_full_description
857 if len(satNimListNames):
858 nim.equalTo = ConfigSelection(choices = satNimListNames)
859 nim.linkedTo = ConfigSelection(choices = satNimListNames)
860 nim.satposDependsTo = ConfigSelection(choices = satNimListNames)
863 nim.advanced = ConfigSubsection()
864 nim.advanced.sats = getConfigSatlist(192,nimmgr.satList)
865 nim.advanced.sat = ConfigSubDict()
866 lnbs = [("0", "not available")]
867 for y in range(1, 33):
868 lnbs.append((str(y), "LNB " + str(y)))
870 for x in nimmgr.satList:
871 nim.advanced.sat[x[0]] = ConfigSubsection()
872 nim.advanced.sat[x[0]].voltage = ConfigSelection(choices={"polarization": _("Polarization"), "13V": _("13 V"), "18V": _("18 V")}, default = "polarization")
873 nim.advanced.sat[x[0]].tonemode = ConfigSelection(choices={"band": _("Band"), "on": _("On"), "off": _("Off")}, default = "band")
874 nim.advanced.sat[x[0]].usals = ConfigYesNo(default=True)
875 nim.advanced.sat[x[0]].rotorposition = ConfigInteger(default=1, limits=(1, 255))
876 nim.advanced.sat[x[0]].lnb = ConfigSelection(choices = lnbs)
878 csw = [("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))]
879 for y in range(0, 16):
880 csw.append((str(0xF0|y), "Input " + str(y+1)))
882 ucsw = [("0", _("None"))]
883 for y in range(1, 17):
884 ucsw.append((str(y), "Input " + str(y)))
886 nim.advanced.lnb = ConfigSubList()
887 nim.advanced.lnb.append(ConfigNothing())
888 for x in range(1, 33):
889 nim.advanced.lnb.append(ConfigSubsection())
890 nim.advanced.lnb[x].lof = ConfigSelection(choices={"universal_lnb": _("Universal LNB"), "c_band": _("C-Band"), "user_defined": _("User defined")}, default="universal_lnb")
891 nim.advanced.lnb[x].lofl = ConfigInteger(default=9750, limits = (0, 99999))
892 nim.advanced.lnb[x].lofh = ConfigInteger(default=10600, limits = (0, 99999))
893 nim.advanced.lnb[x].threshold = ConfigInteger(default=11700, limits = (0, 99999))
894 # nim.advanced.lnb[x].output_12v = ConfigSelection(choices = [("0V", _("0 V")), ("12V", _("12 V"))], default="0V")
895 nim.advanced.lnb[x].increased_voltage = ConfigYesNo(default=False)
896 nim.advanced.lnb[x].toneburst = ConfigSelection(choices = [("none", _("None")), ("A", _("A")), ("B", _("B"))], default = "none")
897 nim.advanced.lnb[x].diseqcMode = ConfigSelection(choices = [("none", _("None")), ("1_0", _("1.0")), ("1_1", _("1.1")), ("1_2", _("1.2"))], default = "none")
898 nim.advanced.lnb[x].commitedDiseqcCommand = ConfigSelection(choices = csw)
899 nim.advanced.lnb[x].fastDiseqc = ConfigYesNo(default=False)
900 nim.advanced.lnb[x].sequenceRepeat = ConfigYesNo(default=False)
901 nim.advanced.lnb[x].commandOrder1_0 = ConfigSelection(choices = [("ct", "committed, toneburst"), ("tc", "toneburst, committed")], default = "ct")
902 nim.advanced.lnb[x].commandOrder = ConfigSelection(choices = [
903 ("ct", "committed, toneburst"),
904 ("tc", "toneburst, committed"),
905 ("cut", "committed, uncommitted, toneburst"),
906 ("tcu", "toneburst, committed, uncommitted"),
907 ("uct", "uncommitted, committed, toneburst"),
908 ("tuc", "toneburst, uncommitted, commmitted")],
910 nim.advanced.lnb[x].uncommittedDiseqcCommand = ConfigSelection(choices = ucsw)
911 nim.advanced.lnb[x].diseqcRepeats = ConfigSelection(choices = [("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))], default = "none")
912 nim.advanced.lnb[x].longitude = ConfigFloat(default = [5,100], limits = [(0,359),(0,999)])
913 nim.advanced.lnb[x].longitudeOrientation = ConfigSelection(choices = [("east", _("East")), ("west", _("West"))], default = "east")
914 nim.advanced.lnb[x].latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)])
915 nim.advanced.lnb[x].latitudeOrientation = ConfigSelection(choices = [("north", _("North")), ("south", _("South"))], default = "north")
916 nim.advanced.lnb[x].powerMeasurement = ConfigYesNo(default=True)
917 nim.advanced.lnb[x].powerThreshold = ConfigInteger(default=50, limits=(0, 100))
918 nim.advanced.lnb[x].turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch"))], default = "fast")
919 btime = datetime(1970, 1, 1, 7, 0);
920 nim.advanced.lnb[x].fastTurningBegin = ConfigDateTime(default=mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 600)
921 etime = datetime(1970, 1, 1, 19, 0);
922 nim.advanced.lnb[x].fastTurningEnd = ConfigDateTime(default=mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 600)
923 elif slot.isCompatible("DVB-C"):
924 nim.configMode = ConfigSelection(
926 "enabled": _("enabled"),
927 "nothing": _("nothing connected"),
932 for x in nimmgr.cablesList:
933 list.append((str(n), x[0]))
935 nim.cable = ConfigSubsection()
936 possible_scan_types = [("bands", _("Frequency bands")), ("steps", _("Frequency steps"))]
938 possible_scan_types.append(("provider", _("Provider")))
939 nim.cable.scan_type = ConfigSelection(default = "bands", choices = possible_scan_types)
940 nim.cable.scan_provider = ConfigSelection(default = "0", choices = list)
941 nim.cable.scan_band_EU_VHF_I = ConfigYesNo(default = True)
942 nim.cable.scan_band_EU_MID = ConfigYesNo(default = True)
943 nim.cable.scan_band_EU_VHF_III = ConfigYesNo(default = True)
944 nim.cable.scan_band_EU_UHF_IV = ConfigYesNo(default = True)
945 nim.cable.scan_band_EU_UHF_V = ConfigYesNo(default = True)
946 nim.cable.scan_band_EU_SUPER = ConfigYesNo(default = True)
947 nim.cable.scan_band_EU_HYPER = ConfigYesNo(default = True)
948 nim.cable.scan_band_US_LOW = ConfigYesNo(default = False)
949 nim.cable.scan_band_US_MID = ConfigYesNo(default = False)
950 nim.cable.scan_band_US_HIGH = ConfigYesNo(default = False)
951 nim.cable.scan_band_US_SUPER = ConfigYesNo(default = False)
952 nim.cable.scan_band_US_HYPER = ConfigYesNo(default = False)
953 nim.cable.scan_frequency_steps = ConfigInteger(default = 1000, limits = (1000, 10000))
954 nim.cable.scan_mod_qam16 = ConfigYesNo(default = False)
955 nim.cable.scan_mod_qam32 = ConfigYesNo(default = False)
956 nim.cable.scan_mod_qam64 = ConfigYesNo(default = True)
957 nim.cable.scan_mod_qam128 = ConfigYesNo(default = False)
958 nim.cable.scan_mod_qam256 = ConfigYesNo(default = True)
959 nim.cable.scan_sr_6900 = ConfigYesNo(default = True)
960 nim.cable.scan_sr_6875 = ConfigYesNo(default = True)
961 nim.cable.scan_sr_ext1 = ConfigInteger(default = 0, limits = (0, 7230))
962 nim.cable.scan_sr_ext2 = ConfigInteger(default = 0, limits = (0, 7230))
963 elif slot.isCompatible("DVB-T"):
964 nim.configMode = ConfigSelection(
966 "enabled": _("enabled"),
967 "nothing": _("nothing connected"),
972 for x in nimmgr.terrestrialsList:
973 list.append((str(n), x[0]))
975 nim.terrestrial = ConfigSelection(choices = list)
976 nim.terrestrial_5V = ConfigOnOff()
978 nim.configMode = ConfigSelection(choices = { "nothing": _("disabled") }, default="nothing");
979 print "pls add support for this frontend type!"
982 nimmgr.sec = SecConfigure(nimmgr)
984 nimmanager = NimManager()