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
111 for slot in nim_slots:
114 if slot.isCompatible("DVB-S"):
115 # save what nim we link to/are equal to/satposdepends to.
116 # this is stored in the *value* (not index!) of the config list
117 if nim.configMode.value == "equal":
118 self.equal[int(nim.equalTo.value)]=x
119 if nim.configMode.value == "loopthrough":
120 self.linkNIMs(sec, x, int(nim.linkedTo.value))
121 self.linked[int(nim.linkedTo.value)]=x
122 elif nim.configMode.value == "satposdepends":
123 self.setSatposDepends(sec, x, int(nim.satposDependsTo.value))
124 self.satposdepends[int(nim.satposDependsTo.value)]=x
126 for slot in nim_slots:
129 if slot.isCompatible("DVB-S"):
130 print "slot: " + str(x) + " configmode: " + str(nim.configMode.value)
131 print "diseqcmode: ", nim.configMode.value
132 if nim.configMode.value in [ "loopthrough", "satposdepends", "nothing" ]:
135 sec.setSlotNotLinked(x)
136 if nim.configMode.value == "equal":
138 elif nim.configMode.value == "simple": #simple config
139 if nim.diseqcMode.value == "single": #single
140 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.NONE, diseqcpos = diseqcParam.SENDNO)
141 elif nim.diseqcMode.value == "toneburst_a_b": #Toneburst A/B
142 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.A, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO)
143 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.B, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO)
144 elif nim.diseqcMode.value == "diseqc_a_b": #DiSEqC A/B
145 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA)
146 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB)
147 elif nim.diseqcMode.value == "diseqc_a_b_c_d": #DiSEqC A/B/C/D
148 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA)
149 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB)
150 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcC.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BA)
151 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcD.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BB)
152 elif nim.diseqcMode.value == "positioner": #Positioner
153 if nim.latitudeOrientation.value == "north":
154 laValue = rotorParam.NORTH
156 laValue = rotorParam.SOUTH
157 if nim.longitudeOrientation.value == "east":
158 loValue = rotorParam.EAST
160 loValue = rotorParam.WEST
161 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
162 if turn_speed_dict.has_key(nim.turningSpeed.value):
163 turning_speed = turn_speed_dict[nim.turningSpeed.value]
165 beg_time = localtime(nim.fastTurningBegin.value)
166 end_time = localtime(nim.fastTurningEnd.value)
167 turning_speed = ((beg_time.tm_hour+1) * 60 + beg_time.tm_min + 1) << 16
168 turning_speed |= (end_time.tm_hour+1) * 60 + end_time.tm_min + 1
169 self.addLNBSimple(sec, slotid = x, diseqcmode = 3,
170 longitude = nim.longitude.float,
171 loDirection = loValue,
172 latitude = nim.latitude.float,
173 laDirection = laValue,
174 turningSpeed = turning_speed)
175 elif nim.configMode.value == "advanced": #advanced config
176 self.updateAdvanced(sec, x)
177 print "sec config completed"
179 def updateAdvanced(self, sec, slotid):
181 for x in range(1,33):
183 for x in self.NimManager.satList:
184 lnb = int(config.Nims[slotid].advanced.sat[x[0]].lnb.value)
186 print "add", x[0], "to", lnb
187 lnbSat[lnb].append(x[0])
188 for x in range(1,33):
189 if len(lnbSat[x]) > 0:
190 currLnb = config.Nims[slotid].advanced.lnb[x]
193 tunermask = 1 << slotid
194 if self.equal.has_key(slotid):
195 tunermask |= (1 << self.equal[slotid])
196 elif self.linked.has_key(slotid):
197 tunermask |= (1 << self.linked[slotid])
199 if currLnb.lof.value == "universal_lnb":
200 sec.setLNBLOFL(9750000)
201 sec.setLNBLOFH(10600000)
202 sec.setLNBThreshold(11700000)
203 elif currLnb.lof.value == "c_band":
204 sec.setLNBLOFL(5150000)
205 sec.setLNBLOFH(5150000)
206 sec.setLNBThreshold(5150000)
207 elif currLnb.lof.value == "user_defined":
208 sec.setLNBLOFL(currLnb.lofl.value * 1000)
209 sec.setLNBLOFH(currLnb.lofh.value * 1000)
210 sec.setLNBThreshold(currLnb.threshold.value * 1000)
212 # if currLnb.output_12v.value == "0V":
213 # pass # nyi in drivers
214 # elif currLnb.output_12v.value == "12V":
215 # pass # nyi in drivers
217 if currLnb.increased_voltage.value:
218 sec.setLNBIncreasedVoltage(lnbParam.ON)
220 sec.setLNBIncreasedVoltage(lnbParam.OFF)
222 dm = currLnb.diseqcMode.value
224 sec.setDiSEqCMode(diseqcParam.NONE)
226 sec.setDiSEqCMode(diseqcParam.V1_0)
228 sec.setDiSEqCMode(diseqcParam.V1_1)
230 sec.setDiSEqCMode(diseqcParam.V1_2)
232 if self.satposdepends.has_key(slotid): # only useable with rotors
233 tunermask |= (1 << self.satposdepends[slotid])
236 if currLnb.toneburst.value == "none":
237 sec.setToneburst(diseqcParam.NO)
238 elif currLnb.toneburst.value == "A":
239 sec.setToneburst(diseqcParam.A)
240 elif currLnb.toneburst.value == "B":
241 sec.setToneburst(diseqcParam.B)
243 # Committed Diseqc Command
244 cdc = currLnb.commitedDiseqcCommand.value
246 c = { "none": diseqcParam.SENDNO,
247 "AA": diseqcParam.AA,
248 "AB": diseqcParam.AB,
249 "BA": diseqcParam.BA,
250 "BB": diseqcParam.BB }
253 sec.setCommittedCommand(c[cdc])
255 sec.setCommittedCommand(long(cdc))
257 sec.setFastDiSEqC(currLnb.fastDiseqc.value)
259 sec.setSeqRepeat(currLnb.sequenceRepeat.value)
261 if currLnb.diseqcMode.value == "1_0":
262 currCO = currLnb.commandOrder1_0.value
264 currCO = currLnb.commandOrder.value
266 udc = int(currLnb.uncommittedDiseqcCommand.value)
268 sec.setUncommittedCommand(0xF0|(udc-1))
270 sec.setUncommittedCommand(0) # SENDNO
272 sec.setRepeats({"none": 0, "one": 1, "two": 2, "three": 3}[currLnb.diseqcRepeats.value])
274 setCommandOrder = False
276 # 0 "committed, toneburst",
277 # 1 "toneburst, committed",
278 # 2 "committed, uncommitted, toneburst",
279 # 3 "toneburst, committed, uncommitted",
280 # 4 "uncommitted, committed, toneburst"
281 # 5 "toneburst, uncommitted, commmitted"
282 order_map = {"ct": 0, "tc": 1, "cut": 2, "tcu": 3, "uct": 4, "tuc": 5}
283 sec.setCommandOrder(order_map[currCO])
286 latitude = currLnb.latitude.float
287 sec.setLatitude(latitude)
288 longitude = currLnb.longitude.float
289 sec.setLongitude(longitude)
290 if currLnb.latitudeOrientation.value == "north":
291 sec.setLaDirection(rotorParam.NORTH)
293 sec.setLaDirection(rotorParam.SOUTH)
294 if currLnb.longitudeOrientation.value == "east":
295 sec.setLoDirection(rotorParam.EAST)
297 sec.setLoDirection(rotorParam.WEST)
299 if currLnb.powerMeasurement.value:
300 sec.setUseInputpower(True)
301 sec.setInputpowerDelta(currLnb.powerThreshold.value)
302 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
303 if turn_speed_dict.has_key(currLnb.turningSpeed.value):
304 turning_speed = turn_speed_dict[currLnb.turningSpeed.value]
306 beg_time = localtime(currLnb.fastTurningBegin.value)
307 end_time = localtime(currLnb.fastTurningEnd.value)
308 turning_speed = ((beg_time.tm_hour + 1) * 60 + beg_time.tm_min + 1) << 16
309 turning_speed |= (end_time.tm_hour + 1) * 60 + end_time.tm_min + 1
310 sec.setRotorTurningSpeed(turning_speed)
312 sec.setUseInputpower(False)
314 sec.setLNBSlotMask(tunermask)
316 # finally add the orbital positions
319 currSat = config.Nims[slotid].advanced.sat[y]
321 if currSat.voltage.value == "polarization":
322 sec.setVoltageMode(switchParam.HV)
323 elif currSat.voltage.value == "13V":
324 sec.setVoltageMode(switchParam._14V)
325 elif currSat.voltage.value == "18V":
326 sec.setVoltageMode(switchParam._18V)
328 if currSat.tonemode == "band":
329 sec.setToneMode(switchParam.HILO)
330 elif currSat.tonemode == "on":
331 sec.setToneMode(switchParam.ON)
332 elif currSat.tonemode == "off":
333 sec.setToneMode(switchParam.OFF)
335 if not currSat.usals.value:
336 sec.setRotorPosNum(currSat.rotorposition.value)
338 sec.setRotorPosNum(0) #USALS
340 def __init__(self, nimmgr):
341 self.NimManager = nimmgr
345 def __init__(self, slot, type, description):
348 if type not in ["DVB-S", "DVB-C", "DVB-T", "DVB-S2", None]:
349 print "warning: unknown NIM type %s, not using." % type
353 self.description = description
355 def isCompatible(self, what):
358 "DVB-S": ["DVB-S", None],
359 "DVB-C": ["DVB-C", None],
360 "DVB-T": ["DVB-T", None],
361 "DVB-S2": ["DVB-S", "DVB-S2", None]
363 return what in compatible[self.type]
365 def getSlotName(self):
366 # get a friendly description for a slot name.
367 # we name them "Tuner A/B/C/...", because that's what's usually written on the back
369 return _("Tuner ") + chr(ord('A') + self.slot)
371 slot_name = property(getSlotName)
374 return chr(ord('A') + self.slot)
376 slot_id = property(getSlotID)
378 def getFriendlyType(self):
387 friendly_type = property(getFriendlyType)
389 def getFriendlyFullDescription(self):
390 nim_text = self.slot_name + ": "
393 nim_text += _("(empty)")
395 nim_text += self.description + " (" + self.friendly_type + ")"
399 friendly_full_description = property(getFriendlyFullDescription)
400 config_mode = property(lambda self: config.Nims[self.slot].configMode.value)
401 config = property(lambda self: config.Nims[self.slot])
402 empty = property(lambda self: self.type is None)
405 class parseSats(ContentHandler):
406 def __init__(self, satList, satellites, transponders):
407 self.isPointsElement, self.isReboundsElement = 0, 0
408 self.satList = satList
409 self.satellites = satellites
410 self.transponders = transponders
412 def startElement(self, name, attrs):
414 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
415 tpos = int(attrs.get('position',""))
418 tname = attrs.get('name',"").encode("UTF-8")
419 self.satellites[tpos] = tname
420 self.satList.append( (tpos, tname) )
421 self.parsedSat = int(tpos)
422 elif (name == "transponder"):
423 modulation = int(attrs.get('modulation',"1")) # QPSK default
424 system = int(attrs.get('system',"0")) # DVB-S default
425 freq = int(attrs.get('frequency',""))
426 sr = int(attrs.get('symbol_rate',""))
427 pol = int(attrs.get('polarization',""))
428 fec = int(attrs.get('fec_inner',"0")) # AUTO default
429 if self.parsedSat in self.transponders:
432 self.transponders[self.parsedSat] = [ ]
434 self.transponders[self.parsedSat].append((0, freq, sr, pol, fec, system, modulation))
436 class parseCables(ContentHandler):
437 def __init__(self, cablesList, transponders):
438 self.isPointsElement, self.isReboundsElement = 0, 0
439 self.cablesList = cablesList
440 for x in self.cablesList:
441 self.cablesList.remove(x)
442 self.transponders = transponders
444 def startElement(self, name, attrs):
445 if (name == "cable"):
446 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
447 tname = attrs.get('name',"").encode("UTF-8")
448 tflags = int(attrs.get('flags',"0"))
449 self.cablesList.append((tname, tflags))
450 self.parsedCab = tname
451 elif (name == "transponder"):
452 freq = int(attrs.get('frequency',""))
455 sr = int(attrs.get('symbol_rate',"0"))
456 mod = int(attrs.get('modulation',"3")) # QAM64 default
457 fec = int(attrs.get('fec_inner',"0")) # AUTO default
458 if self.parsedCab in self.transponders:
461 self.transponders[self.parsedCab] = [ ]
462 self.transponders[self.parsedCab].append((1, freq, sr, mod, fec))
464 class parseTerrestrials(ContentHandler):
465 def __init__(self, terrestrialsList, transponders):
466 self.isPointsElement, self.isReboundsElement = 0, 0
467 self.terrestrialsList = terrestrialsList
468 self.transponders = transponders
470 def startElement(self, name, attrs):
471 if (name == "terrestrial"):
472 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
473 tname = attrs.get('name',"").encode("UTF-8")
474 tflags = attrs.get('flags',"")
475 self.terrestrialsList.append((tname, tflags))
476 self.parsedTer = str(tname)
477 elif (name == "transponder"):
479 freq = int(attrs.get('centre_frequency',""))
480 bw = int(attrs.get('bandwidth',"3")) # AUTO
481 const = int(attrs.get('constellation',"1")) # AUTO
482 crh = int(attrs.get('code_rate_hp',"5")) # AUTO
483 if crh > 5: # our terrestrial.xml is buggy... 6 for AUTO
485 crl = int(attrs.get('code_rate_lp',"5")) # AUTO
486 if crl > 5: # our terrestrial.xml is buggy... 6 for AUTO
488 guard = int(attrs.get('guard_interval',"4")) # AUTO
489 transm = int(attrs.get('transmission_mode',"2")) # AUTO
490 hierarchy = int(attrs.get('hierarchy_information',"4")) # AUTO
491 inv = int(attrs.get('inversion',"2")) # AUTO
492 if self.parsedTer in self.transponders:
495 self.transponders[self.parsedTer] = [ ]
497 self.transponders[self.parsedTer].append((2, freq, bw, const, crh, crl, guard, transm, hierarchy, inv))
499 def getTransponders(self, pos):
500 if self.transponders.has_key(pos):
501 return self.transponders[pos]
505 def getTranspondersCable(self, nim):
506 nimConfig = config.Nims[nim]
507 if nimConfig.configMode.value != "nothing" and nimConfig.cable.scan_type.value == "provider":
508 return self.transponderscable[self.cablesList[nimConfig.cable.scan_provider.index][0]]
511 def getTranspondersTerrestrial(self, region):
512 return self.transpondersterrestrial[region]
514 def getCableDescription(self, nim):
515 return self.cablesList[config.Nims[nim].scan_provider.index][0]
517 def getCableFlags(self, nim):
518 return self.cablesList[config.Nims[nim].scan_provider.index][1]
520 def getTerrestrialDescription(self, nim):
521 return self.terrestrialsList[config.Nims[nim].terrestrial.index][0]
523 def getTerrestrialFlags(self, nim):
524 return self.terrestrialsList[config.Nims[nim].terrestrial.index][1]
526 def getConfiguredSats(self):
527 return self.sec.getSatList()
529 def getSatDescription(self, pos):
530 return self.satellites[pos]
532 def readSatsfromFile(self):
533 # read initial networks from file. we only read files which we are interested in,
534 # which means only these where a compatible tuner exists.
535 self.satellites = { }
536 self.transponders = { }
537 self.transponderscable = { }
538 self.transpondersterrestrial = { }
540 parser = make_parser()
542 if self.hasNimType("DVB-S"):
543 print "Reading satellites.xml"
544 satHandler = self.parseSats(self.satList, self.satellites, self.transponders)
545 parser.setContentHandler(satHandler)
546 parser.parse('/etc/tuxbox/satellites.xml')
548 if self.hasNimType("DVB-C"):
549 print "Reading cables.xml"
550 cabHandler = self.parseCables(self.cablesList, self.transponderscable)
551 parser.setContentHandler(cabHandler)
552 parser.parse('/etc/tuxbox/cables.xml')
554 if self.hasNimType("DVB-T"):
555 print "Reading terrestrial.xml"
556 terHandler = self.parseTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
557 parser.setContentHandler(terHandler)
558 parser.parse('/etc/tuxbox/terrestrial.xml')
560 def enumerateNIMs(self):
561 # enum available NIMs. This is currently very dreambox-centric and uses the /proc/bus/nim_sockets interface.
562 # the result will be stored into nim_slots.
563 # the content of /proc/bus/nim_sockets looks like:
566 # Name: BCM4501 DVB-S2 NIM (internal)
569 # Name: BCM4501 DVB-S2 NIM (internal)
572 # Name: Philips TU1216
575 # Name: Alps BSBE1 702A
578 # Type will be either "DVB-S", "DVB-S2", "DVB-T", "DVB-C" or None.
580 nimfile = tryOpen("/proc/bus/nim_sockets")
588 for line in nimfile.readlines():
591 if line.strip().startswith("NIM Socket"):
592 parts = line.strip().split(" ")
593 current_slot = int(parts[2][:-1])
594 entries[current_slot] = {}
595 elif line.strip().startswith("Type:"):
596 entries[current_slot]["type"] = str(line.strip()[6:])
597 elif line.strip().startswith("Name:"):
598 entries[current_slot]["name"] = str(line.strip()[6:])
599 elif line.strip().startswith("empty"):
600 entries[current_slot]["type"] = None
601 entries[current_slot]["name"] = _("N/A")
604 # nim_slots is an array which has exactly one entry for each slot, even for empty ones.
607 for id, entry in entries.items():
608 if not (entry.has_key("name") and entry.has_key("type")):
609 entry["name"] = _("N/A")
611 self.nim_slots.append(NIM(slot = id, description = entry["name"], type = entry["type"]))
613 def hasNimType(self, chktype):
614 for slot in self.nim_slots:
615 if slot.isCompatible(chktype):
619 def getNimListOfType(self, type, exception = -1):
620 # returns a list of indexes for NIMs compatible to the given type, except for 'exception'
622 for x in self.nim_slots:
623 if x.isCompatible(type) and x.slot != exception:
630 self.terrestrialsList = []
632 self.readSatsfromFile()
634 InitNimManager(self) #init config stuff
636 # get a list with the friendly full description
639 for slot in self.nim_slots:
640 list.append(slot.friendly_full_description)
643 def getSatList(self):
646 def getSatListForNim(self, slotid):
648 if self.nim_slots[slotid].isCompatible("DVB-S"):
649 #print "slotid:", slotid
651 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.index]
652 #print "diseqcA:", config.Nims[slotid].diseqcA.value
653 configMode = config.Nims[slotid].configMode.value
655 if configMode == "equal":
656 slotid=0 #FIXME add handling for more than two tuners !!!
657 configMode = config.Nims[slotid].configMode.value
659 if configMode == "simple":
660 dm = config.Nims[slotid].diseqcMode.value
661 if dm in ["single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
662 list.append(self.satList[config.Nims[slotid].diseqcA.index])
663 if dm in ["toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
664 list.append(self.satList[config.Nims[slotid].diseqcB.index])
665 if dm == "diseqc_a_b_c_d":
666 list.append(self.satList[config.Nims[slotid].diseqcC.index])
667 list.append(self.satList[config.Nims[slotid].diseqcD.index])
668 if dm == "positioner":
669 for x in self.satList:
671 elif configMode == "advanced":
672 for x in self.satList:
673 if int(config.Nims[slotid].advanced.sat[x[0]].lnb.value) != 0:
678 def getRotorSatListForNim(self, slotid):
680 if self.nim_slots[slotid].isCompatible("DVB-S"):
681 #print "slotid:", slotid
683 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
684 #print "diseqcA:", config.Nims[slotid].diseqcA.value
685 configMode = config.Nims[slotid].configMode.value
686 if configMode == "simple":
687 if config.Nims[slotid].diseqcMode.value == "positioner":
688 for x in self.satList:
690 elif configMode == "advanced":
691 for x in self.satList:
692 nim = config.Nims[slotid]
693 lnbnum = int(nim.advanced.sat[x[0]].lnb.value)
695 lnb = nim.advanced.lnb[lnbnum]
696 if lnb.diseqcMode.value == "1_2":
701 config.sec = ConfigSubsection()
703 x = ConfigInteger(default=15, limits = (0, 9999))
704 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_CONT_TONE, configElement.value))
705 config.sec.delay_after_continuous_tone_change = x
707 x = ConfigInteger(default=10, limits = (0, 9999))
708 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_VOLTAGE_CHANGE, configElement.value))
709 config.sec.delay_after_final_voltage_change = x
711 x = ConfigInteger(default=120, limits = (0, 9999))
712 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_DISEQC_REPEATS, configElement.value))
713 config.sec.delay_between_diseqc_repeats = x
715 x = ConfigInteger(default=50, limits = (0, 9999))
716 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_LAST_DISEQC_CMD, configElement.value))
717 config.sec.delay_after_last_diseqc_command = x
719 x = ConfigInteger(default=50, limits = (0, 9999))
720 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value))
721 config.sec.delay_after_toneburst = x
723 x = ConfigInteger(default=200, limits = (0, 9999))
724 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS, configElement.value))
725 config.sec.delay_after_enable_voltage_before_switch_command = x
727 x = ConfigInteger(default=200, limits = (0, 9999))
728 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_SWITCH_AND_MOTOR_CMD, configElement.value))
729 config.sec.delay_between_switch_and_motor_command = x
731 x = ConfigInteger(default=150, limits = (0, 9999))
732 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MEASURE_IDLE_INPUTPOWER, configElement.value))
733 config.sec.delay_after_voltage_change_before_measure_idle_inputpower = x
735 x = ConfigInteger(default=200, limits = (0, 9999))
736 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_MOTOR_CMD, configElement.value))
737 config.sec.delay_after_enable_voltage_before_motor_command = x
739 x = ConfigInteger(default=150, limits = (0, 9999))
740 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_MOTOR_STOP_CMD, configElement.value))
741 config.sec.delay_after_motor_stop_command = x
743 x = ConfigInteger(default=150, limits = (0, 9999))
744 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MOTOR_CMD, configElement.value))
745 config.sec.delay_after_voltage_change_before_motor_command = x
747 x = ConfigInteger(default=120, limits = (0, 9999))
748 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_RUNNING_TIMEOUT, configElement.value))
749 config.sec.motor_running_timeout = x
751 x = ConfigInteger(default=1, limits = (0, 5))
752 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_COMMAND_RETRIES, configElement.value))
753 config.sec.motor_command_retries = x
755 x = ConfigInteger(default=20, limits = (0, 9999))
756 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS, configElement.value))
757 config.sec.delay_after_change_voltage_before_switch_command = x
759 # TODO add support for satpos depending nims to advanced nim configuration
760 # so a second/third/fourth cable from a motorized lnb can used behind a
761 # diseqc 1.0 / diseqc 1.1 / toneburst switch
762 # the C(++) part should can handle this
763 # the configElement should be only visible when diseqc 1.2 is disabled
765 def InitNimManager(nimmgr):
768 config.Nims = ConfigSubList()
769 for x in range(len(nimmgr.nim_slots)):
770 config.Nims.append(ConfigSubsection())
774 for slot in nimmgr.nim_slots:
778 # HACK: currently, we can only looptrough to socket A
780 if slot.type is not None:
781 used_nim_slots.append((slot.slot, slot.description))
783 if slot.isCompatible("DVB-S"):
785 nim.configMode = ConfigSelection(
787 "simple": _("simple"),
788 "advanced": _("advanced"),
789 "nothing": _("nothing connected"),
793 nim.configMode = ConfigSelection(
795 "equal": _("equal to Socket A"),
796 "loopthrough": _("loopthrough to socket A"),
797 "nothing": _("nothing connected"),
798 "satposdepends": _("second cable of motorized LNB"),
799 "simple": _("simple"),
800 "advanced": _("advanced")},
801 default = "loopthrough")
803 #important - check if just the 2nd one is LT only and the first one is DVB-S
804 # CHECKME: is this logic correct for >2 slots?
805 if nim.configMode.value in ["loopthrough", "satposdepends", "equal"]:
806 if x == 0: # first one can never be linked to anything
808 nim.configMode.value = "simple"
809 nim.configMode.save()
811 #FIXME: make it better
812 for y in nimmgr.nim_slots:
814 if not y.isCompatible("DVB-S"):
816 nim.configMode.value = "simple"
817 nim.configMode.save()
819 nim.diseqcMode = ConfigSelection(
821 ("single", _("Single")),
822 ("toneburst_a_b", _("Toneburst A/B")),
823 ("diseqc_a_b", _("DiSEqC A/B")),
824 ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")),
825 ("positioner", _("Positioner"))],
826 default = "diseqc_a_b")
828 nim.diseqcA = getConfigSatlist(192, nimmgr.satList)
829 nim.diseqcB = getConfigSatlist(130, nimmgr.satList)
830 nim.diseqcC = ConfigSatlist(list = nimmgr.satList)
831 nim.diseqcD = ConfigSatlist(list = nimmgr.satList)
832 nim.positionerMode = ConfigSelection(
834 ("usals", _("USALS")),
835 ("manual", _("manual"))],
837 nim.longitude = ConfigFloat(default=[5,100], limits=[(0,359),(0,999)])
838 nim.longitudeOrientation = ConfigSelection(choices={"east": _("East"), "west": _("West")}, default = "east")
839 nim.latitude = ConfigFloat(default=[50,767], limits=[(0,359),(0,999)])
840 nim.latitudeOrientation = ConfigSelection(choices={"north": _("North"), "south": _("South")}, default="north")
841 nim.turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch")) ], default = "fast")
842 btime = datetime(1970, 1, 1, 7, 0);
843 nim.fastTurningBegin = ConfigDateTime(default = mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 900)
844 etime = datetime(1970, 1, 1, 19, 0);
845 nim.fastTurningEnd = ConfigDateTime(default = mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 900)
846 # get other frontends of the same type
847 satNimList = nimmgr.getNimListOfType(slot.type, slot.slot)
851 n = nimmgr.nim_slots[x]
852 satNimListNames["%d" % n.slot] = n.friendly_full_description
854 if len(satNimListNames):
855 nim.equalTo = ConfigSelection(choices = satNimListNames)
856 nim.linkedTo = ConfigSelection(choices = satNimListNames)
857 nim.satposDependsTo = ConfigSelection(choices = satNimListNames)
860 nim.advanced = ConfigSubsection()
861 nim.advanced.sats = getConfigSatlist(192,nimmgr.satList)
862 nim.advanced.sat = ConfigSubDict()
863 lnbs = [("0", "not available")]
864 for y in range(1, 33):
865 lnbs.append((str(y), "LNB " + str(y)))
867 for x in nimmgr.satList:
868 nim.advanced.sat[x[0]] = ConfigSubsection()
869 nim.advanced.sat[x[0]].voltage = ConfigSelection(choices={"polarization": _("Polarization"), "13V": _("13 V"), "18V": _("18 V")}, default = "polarization")
870 nim.advanced.sat[x[0]].tonemode = ConfigSelection(choices={"band": _("Band"), "on": _("On"), "off": _("Off")}, default = "band")
871 nim.advanced.sat[x[0]].usals = ConfigYesNo(default=True)
872 nim.advanced.sat[x[0]].rotorposition = ConfigInteger(default=1, limits=(1, 255))
873 nim.advanced.sat[x[0]].lnb = ConfigSelection(choices = lnbs)
875 csw = [("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))]
876 for y in range(0, 16):
877 csw.append((str(0xF0|y), "Input " + str(y+1)))
879 ucsw = [("0", _("None"))]
880 for y in range(1, 17):
881 ucsw.append((str(y), "Input " + str(y)))
883 nim.advanced.lnb = ConfigSubList()
884 nim.advanced.lnb.append(ConfigNothing())
885 for x in range(1, 33):
886 nim.advanced.lnb.append(ConfigSubsection())
887 nim.advanced.lnb[x].lof = ConfigSelection(choices={"universal_lnb": _("Universal LNB"), "c_band": _("C-Band"), "user_defined": _("User defined")}, default="universal_lnb")
888 nim.advanced.lnb[x].lofl = ConfigInteger(default=9750, limits = (0, 99999))
889 nim.advanced.lnb[x].lofh = ConfigInteger(default=10600, limits = (0, 99999))
890 nim.advanced.lnb[x].threshold = ConfigInteger(default=11700, limits = (0, 99999))
891 # nim.advanced.lnb[x].output_12v = ConfigSelection(choices = [("0V", _("0 V")), ("12V", _("12 V"))], default="0V")
892 nim.advanced.lnb[x].increased_voltage = ConfigYesNo(default=False)
893 nim.advanced.lnb[x].toneburst = ConfigSelection(choices = [("none", _("None")), ("A", _("A")), ("B", _("B"))], default = "none")
894 nim.advanced.lnb[x].diseqcMode = ConfigSelection(choices = [("none", _("None")), ("1_0", _("1.0")), ("1_1", _("1.1")), ("1_2", _("1.2"))], default = "none")
895 nim.advanced.lnb[x].commitedDiseqcCommand = ConfigSelection(choices = csw)
896 nim.advanced.lnb[x].fastDiseqc = ConfigYesNo(default=False)
897 nim.advanced.lnb[x].sequenceRepeat = ConfigYesNo(default=False)
898 nim.advanced.lnb[x].commandOrder1_0 = ConfigSelection(choices = [("ct", "committed, toneburst"), ("tc", "toneburst, committed")], default = "ct")
899 nim.advanced.lnb[x].commandOrder = ConfigSelection(choices = [
900 ("ct", "committed, toneburst"),
901 ("tc", "toneburst, committed"),
902 ("cut", "committed, uncommitted, toneburst"),
903 ("tcu", "toneburst, committed, uncommitted"),
904 ("uct", "uncommitted, committed, toneburst"),
905 ("tuc", "toneburst, uncommitted, commmitted")],
907 nim.advanced.lnb[x].uncommittedDiseqcCommand = ConfigSelection(choices = ucsw)
908 nim.advanced.lnb[x].diseqcRepeats = ConfigSelection(choices = [("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))], default = "none")
909 nim.advanced.lnb[x].longitude = ConfigFloat(default = [5,100], limits = [(0,359),(0,999)])
910 nim.advanced.lnb[x].longitudeOrientation = ConfigSelection(choices = [("east", _("East")), ("west", _("West"))], default = "east")
911 nim.advanced.lnb[x].latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)])
912 nim.advanced.lnb[x].latitudeOrientation = ConfigSelection(choices = [("north", _("North")), ("south", _("South"))], default = "north")
913 nim.advanced.lnb[x].powerMeasurement = ConfigYesNo(default=True)
914 nim.advanced.lnb[x].powerThreshold = ConfigInteger(default=50, limits=(0, 100))
915 nim.advanced.lnb[x].turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch"))], default = "fast")
916 btime = datetime(1970, 1, 1, 7, 0);
917 nim.advanced.lnb[x].fastTurningBegin = ConfigDateTime(default=mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 600)
918 etime = datetime(1970, 1, 1, 19, 0);
919 nim.advanced.lnb[x].fastTurningEnd = ConfigDateTime(default=mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 600)
920 elif slot.isCompatible("DVB-C"):
921 nim.configMode = ConfigSelection(
923 "enabled": _("enabled"),
924 "nothing": _("nothing connected"),
929 for x in nimmgr.cablesList:
930 list.append((str(n), x[0]))
932 nim.cable = ConfigSubsection()
933 possible_scan_types = [("bands", _("Frequency bands")), ("steps", _("Frequency steps"))]
935 possible_scan_types.append(("provider", _("Provider")))
936 nim.cable.scan_type = ConfigSelection(default = "bands", choices = possible_scan_types)
937 nim.cable.scan_provider = ConfigSelection(default = "0", choices = list)
938 nim.cable.scan_band_EU_VHF_I = ConfigYesNo(default = True)
939 nim.cable.scan_band_EU_MID = ConfigYesNo(default = True)
940 nim.cable.scan_band_EU_VHF_III = ConfigYesNo(default = True)
941 nim.cable.scan_band_EU_UHF_IV = ConfigYesNo(default = True)
942 nim.cable.scan_band_EU_UHF_V = ConfigYesNo(default = True)
943 nim.cable.scan_band_EU_SUPER = ConfigYesNo(default = True)
944 nim.cable.scan_band_EU_HYPER = ConfigYesNo(default = True)
945 nim.cable.scan_band_US_LOW = ConfigYesNo(default = False)
946 nim.cable.scan_band_US_MID = ConfigYesNo(default = False)
947 nim.cable.scan_band_US_HIGH = ConfigYesNo(default = False)
948 nim.cable.scan_band_US_SUPER = ConfigYesNo(default = False)
949 nim.cable.scan_band_US_HYPER = ConfigYesNo(default = False)
950 nim.cable.scan_frequency_steps = ConfigInteger(default = 1000, limits = (1000, 10000))
951 nim.cable.scan_mod_qam16 = ConfigYesNo(default = False)
952 nim.cable.scan_mod_qam32 = ConfigYesNo(default = False)
953 nim.cable.scan_mod_qam64 = ConfigYesNo(default = True)
954 nim.cable.scan_mod_qam128 = ConfigYesNo(default = False)
955 nim.cable.scan_mod_qam256 = ConfigYesNo(default = True)
956 nim.cable.scan_sr_6900 = ConfigYesNo(default = True)
957 nim.cable.scan_sr_6875 = ConfigYesNo(default = True)
958 nim.cable.scan_sr_ext1 = ConfigInteger(default = 0, limits = (0, 7230))
959 nim.cable.scan_sr_ext2 = ConfigInteger(default = 0, limits = (0, 7230))
960 elif slot.isCompatible("DVB-T"):
961 nim.configMode = ConfigSelection(
963 "enabled": _("enabled"),
964 "nothing": _("nothing connected"),
969 for x in nimmgr.terrestrialsList:
970 list.append((str(n), x[0]))
972 nim.terrestrial = ConfigSelection(choices = list)
973 nim.terrestrial_5V = ConfigOnOff()
975 nim.configMode = ConfigSelection(choices = { "nothing": _("disabled") }, default="nothing");
976 print "pls add support for this frontend type!"
979 eDVBResourceManager.getInstance().setFrontendSlotInformations(used_nim_slots)
981 nimmgr.sec = SecConfigure(nimmgr)
983 nimmanager = NimManager()