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):
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(True)
69 sec.setInputpowerDelta(50)
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
162 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
163 if turn_speed_dict.has_key(nim.turningSpeed.value):
164 turning_speed = turn_speed_dict[nim.turningSpeed.value]
166 beg_time = localtime(nim.fastTurningBegin.value)
167 end_time = localtime(nim.fastTurningEnd.value)
168 turning_speed = ((beg_time.tm_hour+1) * 60 + beg_time.tm_min + 1) << 16
169 turning_speed |= (end_time.tm_hour+1) * 60 + end_time.tm_min + 1
170 self.addLNBSimple(sec, slotid = x, diseqcmode = 3,
171 longitude = nim.longitude.float,
172 loDirection = loValue,
173 latitude = nim.latitude.float,
174 laDirection = laValue,
175 turningSpeed = turning_speed)
176 elif nim.configMode.value == "advanced": #advanced config
177 self.updateAdvanced(sec, x)
178 print "sec config completed"
180 def updateAdvanced(self, sec, slotid):
182 for x in range(1,33):
184 for x in self.NimManager.satList:
185 lnb = int(config.Nims[slotid].advanced.sat[x[0]].lnb.value)
187 print "add", x[0], "to", lnb
188 lnbSat[lnb].append(x[0])
189 for x in range(1,33):
190 if len(lnbSat[x]) > 0:
191 currLnb = config.Nims[slotid].advanced.lnb[x]
194 tunermask = 1 << slotid
195 if self.equal.has_key(slotid):
196 tunermask |= (1 << self.equal[slotid])
197 elif self.linked.has_key(slotid):
198 tunermask |= (1 << self.linked[slotid])
200 if currLnb.lof.value == "universal_lnb":
201 sec.setLNBLOFL(9750000)
202 sec.setLNBLOFH(10600000)
203 sec.setLNBThreshold(11700000)
204 elif currLnb.lof.value == "c_band":
205 sec.setLNBLOFL(5150000)
206 sec.setLNBLOFH(5150000)
207 sec.setLNBThreshold(5150000)
208 elif currLnb.lof.value == "user_defined":
209 sec.setLNBLOFL(currLnb.lofl.value * 1000)
210 sec.setLNBLOFH(currLnb.lofh.value * 1000)
211 sec.setLNBThreshold(currLnb.threshold.value * 1000)
213 # if currLnb.output_12v.value == "0V":
214 # pass # nyi in drivers
215 # elif currLnb.output_12v.value == "12V":
216 # pass # nyi in drivers
218 if currLnb.increased_voltage.value:
219 sec.setLNBIncreasedVoltage(lnbParam.ON)
221 sec.setLNBIncreasedVoltage(lnbParam.OFF)
223 dm = currLnb.diseqcMode.value
225 sec.setDiSEqCMode(diseqcParam.NONE)
227 sec.setDiSEqCMode(diseqcParam.V1_0)
229 sec.setDiSEqCMode(diseqcParam.V1_1)
231 sec.setDiSEqCMode(diseqcParam.V1_2)
233 if self.satposdepends.has_key(slotid): # only useable with rotors
234 tunermask |= (1 << self.satposdepends[slotid])
237 if currLnb.toneburst.value == "none":
238 sec.setToneburst(diseqcParam.NO)
239 elif currLnb.toneburst.value == "A":
240 sec.setToneburst(diseqcParam.A)
241 elif currLnb.toneburst.value == "B":
242 sec.setToneburst(diseqcParam.B)
244 # Committed Diseqc Command
245 cdc = currLnb.commitedDiseqcCommand.value
247 c = { "none": diseqcParam.SENDNO,
248 "AA": diseqcParam.AA,
249 "AB": diseqcParam.AB,
250 "BA": diseqcParam.BA,
251 "BB": diseqcParam.BB }
254 sec.setCommittedCommand(c[cdc])
256 sec.setCommittedCommand(long(cdc))
258 sec.setFastDiSEqC(currLnb.fastDiseqc.value)
260 sec.setSeqRepeat(currLnb.sequenceRepeat.value)
262 if currLnb.diseqcMode.value == "1_0":
263 currCO = currLnb.commandOrder1_0.value
265 currCO = currLnb.commandOrder.value
267 udc = int(currLnb.uncommittedDiseqcCommand.value)
269 sec.setUncommittedCommand(0xF0|(udc-1))
271 sec.setUncommittedCommand(0) # SENDNO
273 sec.setRepeats({"none": 0, "one": 1, "two": 2, "three": 3}[currLnb.diseqcRepeats.value])
275 setCommandOrder = False
277 # 0 "committed, toneburst",
278 # 1 "toneburst, committed",
279 # 2 "committed, uncommitted, toneburst",
280 # 3 "toneburst, committed, uncommitted",
281 # 4 "uncommitted, committed, toneburst"
282 # 5 "toneburst, uncommitted, commmitted"
283 order_map = {"ct": 0, "tc": 1, "cut": 2, "tcu": 3, "uct": 4, "tuc": 5}
284 sec.setCommandOrder(order_map[currCO])
287 latitude = currLnb.latitude.float
288 sec.setLatitude(latitude)
289 longitude = currLnb.longitude.float
290 sec.setLongitude(longitude)
291 if currLnb.latitudeOrientation.value == "north":
292 sec.setLaDirection(rotorParam.NORTH)
294 sec.setLaDirection(rotorParam.SOUTH)
295 if currLnb.longitudeOrientation.value == "east":
296 sec.setLoDirection(rotorParam.EAST)
298 sec.setLoDirection(rotorParam.WEST)
300 if currLnb.powerMeasurement.value:
301 sec.setUseInputpower(True)
302 sec.setInputpowerDelta(currLnb.powerThreshold.value)
303 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
304 if turn_speed_dict.has_key(currLnb.turningSpeed.value):
305 turning_speed = turn_speed_dict[currLnb.turningSpeed.value]
307 beg_time = localtime(currLnb.fastTurningBegin.value)
308 end_time = localtime(currLnb.fastTurningEnd.value)
309 turning_speed = ((beg_time.tm_hour + 1) * 60 + beg_time.tm_min + 1) << 16
310 turning_speed |= (end_time.tm_hour + 1) * 60 + end_time.tm_min + 1
311 sec.setRotorTurningSpeed(turning_speed)
313 sec.setUseInputpower(False)
315 sec.setLNBSlotMask(tunermask)
317 # finally add the orbital positions
320 currSat = config.Nims[slotid].advanced.sat[y]
322 if currSat.voltage.value == "polarization":
323 sec.setVoltageMode(switchParam.HV)
324 elif currSat.voltage.value == "13V":
325 sec.setVoltageMode(switchParam._14V)
326 elif currSat.voltage.value == "18V":
327 sec.setVoltageMode(switchParam._18V)
329 if currSat.tonemode == "band":
330 sec.setToneMode(switchParam.HILO)
331 elif currSat.tonemode == "on":
332 sec.setToneMode(switchParam.ON)
333 elif currSat.tonemode == "off":
334 sec.setToneMode(switchParam.OFF)
336 if not currSat.usals.value:
337 sec.setRotorPosNum(currSat.rotorposition.value)
339 sec.setRotorPosNum(0) #USALS
341 def __init__(self, nimmgr):
342 self.NimManager = nimmgr
346 def __init__(self, slot, type, description):
349 if type not in ["DVB-S", "DVB-C", "DVB-T", "DVB-S2", None]:
350 print "warning: unknown NIM type %s, not using." % type
354 self.description = description
356 def isCompatible(self, what):
359 "DVB-S": ["DVB-S", None],
360 "DVB-C": ["DVB-C", None],
361 "DVB-T": ["DVB-T", None],
362 "DVB-S2": ["DVB-S", "DVB-S2", None]
364 return what in compatible[self.type]
366 def getSlotName(self):
367 # get a friendly description for a slot name.
368 # we name them "Tuner A/B/C/...", because that's what's usually written on the back
370 return _("Tuner ") + chr(ord('A') + self.slot)
372 slot_name = property(getSlotName)
375 return chr(ord('A') + self.slot)
377 slot_id = property(getSlotID)
379 def getFriendlyType(self):
388 friendly_type = property(getFriendlyType)
390 def getFriendlyFullDescription(self):
391 nim_text = self.slot_name + ": "
394 nim_text += _("(empty)")
396 nim_text += self.description + " (" + self.friendly_type + ")"
400 friendly_full_description = property(getFriendlyFullDescription)
401 config_mode = property(lambda self: config.Nims[self.slot].configMode.value)
402 config = property(lambda self: config.Nims[self.slot])
403 empty = property(lambda self: self.type is None)
406 class parseSats(ContentHandler):
407 def __init__(self, satList, satellites, transponders):
408 self.isPointsElement, self.isReboundsElement = 0, 0
409 self.satList = satList
410 self.satellites = satellites
411 self.transponders = transponders
413 def startElement(self, name, attrs):
415 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
416 tpos = int(attrs.get('position',""))
419 tname = attrs.get('name',"").encode("UTF-8")
420 self.satellites[tpos] = tname
421 self.satList.append( (tpos, tname) )
422 self.parsedSat = int(tpos)
423 elif (name == "transponder"):
424 modulation = int(attrs.get('modulation',"1")) # QPSK default
425 system = int(attrs.get('system',"0")) # DVB-S default
426 freq = int(attrs.get('frequency',""))
427 sr = int(attrs.get('symbol_rate',""))
428 pol = int(attrs.get('polarization',""))
429 fec = int(attrs.get('fec_inner',"0")) # AUTO default
430 if self.parsedSat in self.transponders:
433 self.transponders[self.parsedSat] = [ ]
435 self.transponders[self.parsedSat].append((0, freq, sr, pol, fec, system, modulation))
437 class parseCables(ContentHandler):
438 def __init__(self, cablesList, transponders):
439 self.isPointsElement, self.isReboundsElement = 0, 0
440 self.cablesList = cablesList
441 for x in self.cablesList:
442 self.cablesList.remove(x)
443 self.transponders = transponders
445 def startElement(self, name, attrs):
446 if (name == "cable"):
447 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
448 tname = attrs.get('name',"").encode("UTF-8")
449 tflags = int(attrs.get('flags',"0"))
450 self.cablesList.append((tname, tflags))
451 self.parsedCab = tname
452 elif (name == "transponder"):
453 freq = int(attrs.get('frequency',""))
456 sr = int(attrs.get('symbol_rate',"0"))
457 mod = int(attrs.get('modulation',"3")) # QAM64 default
458 fec = int(attrs.get('fec_inner',"0")) # AUTO default
459 if self.parsedCab in self.transponders:
462 self.transponders[self.parsedCab] = [ ]
463 self.transponders[self.parsedCab].append((1, freq, sr, mod, fec))
465 class parseTerrestrials(ContentHandler):
466 def __init__(self, terrestrialsList, transponders):
467 self.isPointsElement, self.isReboundsElement = 0, 0
468 self.terrestrialsList = terrestrialsList
469 self.transponders = transponders
471 def startElement(self, name, attrs):
472 if (name == "terrestrial"):
473 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
474 tname = attrs.get('name',"").encode("UTF-8")
475 tflags = attrs.get('flags',"")
476 self.terrestrialsList.append((tname, tflags))
477 self.parsedTer = str(tname)
478 elif (name == "transponder"):
480 freq = int(attrs.get('centre_frequency',""))
481 bw = int(attrs.get('bandwidth',"3")) # AUTO
482 const = int(attrs.get('constellation',"1")) # AUTO
483 crh = int(attrs.get('code_rate_hp',"5")) # AUTO
484 if crh > 5: # our terrestrial.xml is buggy... 6 for AUTO
486 crl = int(attrs.get('code_rate_lp',"5")) # AUTO
487 if crl > 5: # our terrestrial.xml is buggy... 6 for AUTO
489 guard = int(attrs.get('guard_interval',"4")) # AUTO
490 transm = int(attrs.get('transmission_mode',"2")) # AUTO
491 hierarchy = int(attrs.get('hierarchy_information',"4")) # AUTO
492 inv = int(attrs.get('inversion',"2")) # AUTO
493 if self.parsedTer in self.transponders:
496 self.transponders[self.parsedTer] = [ ]
498 self.transponders[self.parsedTer].append((2, freq, bw, const, crh, crl, guard, transm, hierarchy, inv))
500 def getTransponders(self, pos):
501 if self.transponders.has_key(pos):
502 return self.transponders[pos]
506 def getTranspondersCable(self, nim):
507 nimConfig = config.Nims[nim]
508 if nimConfig.configMode.value != "nothing" and nimConfig.cable.scan_type.value == "provider":
509 return self.transponderscable[self.cablesList[nimConfig.cable.scan_provider.index][0]]
512 def getTranspondersTerrestrial(self, region):
513 return self.transpondersterrestrial[region]
515 def getCableDescription(self, nim):
516 return self.cablesList[config.Nims[nim].scan_provider.index][0]
518 def getCableFlags(self, nim):
519 return self.cablesList[config.Nims[nim].scan_provider.index][1]
521 def getTerrestrialDescription(self, nim):
522 return self.terrestrialsList[config.Nims[nim].terrestrial.index][0]
524 def getTerrestrialFlags(self, nim):
525 return self.terrestrialsList[config.Nims[nim].terrestrial.index][1]
527 def getConfiguredSats(self):
528 return self.sec.getSatList()
530 def getSatDescription(self, pos):
531 return self.satellites[pos]
533 def readSatsfromFile(self):
534 # read initial networks from file. we only read files which we are interested in,
535 # which means only these where a compatible tuner exists.
536 self.satellites = { }
537 self.transponders = { }
538 self.transponderscable = { }
539 self.transpondersterrestrial = { }
541 parser = make_parser()
543 if self.hasNimType("DVB-S"):
544 print "Reading satellites.xml"
545 satHandler = self.parseSats(self.satList, self.satellites, self.transponders)
546 parser.setContentHandler(satHandler)
547 parser.parse('/etc/tuxbox/satellites.xml')
549 if self.hasNimType("DVB-C"):
550 print "Reading cables.xml"
551 cabHandler = self.parseCables(self.cablesList, self.transponderscable)
552 parser.setContentHandler(cabHandler)
553 parser.parse('/etc/tuxbox/cables.xml')
555 if self.hasNimType("DVB-T"):
556 print "Reading terrestrial.xml"
557 terHandler = self.parseTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
558 parser.setContentHandler(terHandler)
559 parser.parse('/etc/tuxbox/terrestrial.xml')
561 def enumerateNIMs(self):
562 # enum available NIMs. This is currently very dreambox-centric and uses the /proc/bus/nim_sockets interface.
563 # the result will be stored into nim_slots.
564 # the content of /proc/bus/nim_sockets looks like:
567 # Name: BCM4501 DVB-S2 NIM (internal)
570 # Name: BCM4501 DVB-S2 NIM (internal)
573 # Name: Philips TU1216
576 # Name: Alps BSBE1 702A
579 # Type will be either "DVB-S", "DVB-S2", "DVB-T", "DVB-C" or None.
581 nimfile = tryOpen("/proc/bus/nim_sockets")
589 for line in nimfile.readlines():
592 if line.strip().startswith("NIM Socket"):
593 parts = line.strip().split(" ")
594 current_slot = int(parts[2][:-1])
595 entries[current_slot] = {}
596 elif line.strip().startswith("Type:"):
597 entries[current_slot]["type"] = str(line.strip()[6:])
598 elif line.strip().startswith("Name:"):
599 entries[current_slot]["name"] = str(line.strip()[6:])
600 elif line.strip().startswith("empty"):
601 entries[current_slot]["type"] = None
602 entries[current_slot]["name"] = _("N/A")
605 # nim_slots is an array which has exactly one entry for each slot, even for empty ones.
608 for id, entry in entries.items():
609 if not (entry.has_key("name") and entry.has_key("type")):
610 entry["name"] = _("N/A")
612 self.nim_slots.append(NIM(slot = id, description = entry["name"], type = entry["type"]))
614 def hasNimType(self, chktype):
615 for slot in self.nim_slots:
616 if slot.isCompatible(chktype):
620 def getNimListOfType(self, type, exception = -1):
621 # returns a list of indexes for NIMs compatible to the given type, except for 'exception'
623 for x in self.nim_slots:
624 if x.isCompatible(type) and x.slot != exception:
631 self.terrestrialsList = []
633 self.readSatsfromFile()
635 InitNimManager(self) #init config stuff
637 # get a list with the friendly full description
640 for slot in self.nim_slots:
641 list.append(slot.friendly_full_description)
644 def getSatList(self):
647 def getSatListForNim(self, slotid):
649 if self.nim_slots[slotid].isCompatible("DVB-S"):
650 #print "slotid:", slotid
652 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.index]
653 #print "diseqcA:", config.Nims[slotid].diseqcA.value
654 configMode = config.Nims[slotid].configMode.value
656 if configMode == "equal":
657 slotid=0 #FIXME add handling for more than two tuners !!!
658 configMode = config.Nims[slotid].configMode.value
660 if configMode == "simple":
661 dm = config.Nims[slotid].diseqcMode.value
662 if dm in ["single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
663 list.append(self.satList[config.Nims[slotid].diseqcA.index])
664 if dm in ["toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
665 list.append(self.satList[config.Nims[slotid].diseqcB.index])
666 if dm == "diseqc_a_b_c_d":
667 list.append(self.satList[config.Nims[slotid].diseqcC.index])
668 list.append(self.satList[config.Nims[slotid].diseqcD.index])
669 if dm == "positioner":
670 for x in self.satList:
672 elif configMode == "advanced":
673 for x in self.satList:
674 if int(config.Nims[slotid].advanced.sat[x[0]].lnb.value) != 0:
679 def getRotorSatListForNim(self, slotid):
681 if self.nim_slots[slotid].isCompatible("DVB-S"):
682 #print "slotid:", slotid
684 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
685 #print "diseqcA:", config.Nims[slotid].diseqcA.value
686 configMode = config.Nims[slotid].configMode.value
687 if configMode == "simple":
688 if config.Nims[slotid].diseqcMode.value == "positioner":
689 for x in self.satList:
691 elif configMode == "advanced":
692 for x in self.satList:
693 nim = config.Nims[slotid]
694 lnbnum = int(nim.advanced.sat[x[0]].lnb.value)
696 lnb = nim.advanced.lnb[lnbnum]
697 if lnb.diseqcMode.value == "1_2":
702 config.sec = ConfigSubsection()
704 x = ConfigInteger(default=15, limits = (0, 9999))
705 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_CONT_TONE, configElement.value))
706 config.sec.delay_after_continuous_tone_change = x
708 x = ConfigInteger(default=10, limits = (0, 9999))
709 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_VOLTAGE_CHANGE, configElement.value))
710 config.sec.delay_after_final_voltage_change = x
712 x = ConfigInteger(default=120, limits = (0, 9999))
713 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_DISEQC_REPEATS, configElement.value))
714 config.sec.delay_between_diseqc_repeats = x
716 x = ConfigInteger(default=50, limits = (0, 9999))
717 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_LAST_DISEQC_CMD, configElement.value))
718 config.sec.delay_after_last_diseqc_command = x
720 x = ConfigInteger(default=50, limits = (0, 9999))
721 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value))
722 config.sec.delay_after_toneburst = x
724 x = ConfigInteger(default=200, limits = (0, 9999))
725 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS, configElement.value))
726 config.sec.delay_after_enable_voltage_before_switch_command = x
728 x = ConfigInteger(default=700, limits = (0, 9999))
729 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_SWITCH_AND_MOTOR_CMD, configElement.value))
730 config.sec.delay_between_switch_and_motor_command = x
732 x = ConfigInteger(default=150, limits = (0, 9999))
733 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MEASURE_IDLE_INPUTPOWER, configElement.value))
734 config.sec.delay_after_voltage_change_before_measure_idle_inputpower = x
736 x = ConfigInteger(default=750, limits = (0, 9999))
737 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_MOTOR_CMD, configElement.value))
738 config.sec.delay_after_enable_voltage_before_motor_command = x
740 x = ConfigInteger(default=150, limits = (0, 9999))
741 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_MOTOR_STOP_CMD, configElement.value))
742 config.sec.delay_after_motor_stop_command = x
744 x = ConfigInteger(default=150, limits = (0, 9999))
745 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MOTOR_CMD, configElement.value))
746 config.sec.delay_after_voltage_change_before_motor_command = x
748 x = ConfigInteger(default=120, limits = (0, 9999))
749 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_RUNNING_TIMEOUT, configElement.value))
750 config.sec.motor_running_timeout = x
752 x = ConfigInteger(default=1, limits = (0, 5))
753 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_COMMAND_RETRIES, configElement.value))
754 config.sec.motor_command_retries = x
756 x = ConfigInteger(default=20, limits = (0, 9999))
757 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS, configElement.value))
758 config.sec.delay_after_change_voltage_before_switch_command = x
760 # TODO add support for satpos depending nims to advanced nim configuration
761 # so a second/third/fourth cable from a motorized lnb can used behind a
762 # diseqc 1.0 / diseqc 1.1 / toneburst switch
763 # the C(++) part should can handle this
764 # the configElement should be only visible when diseqc 1.2 is disabled
766 def InitNimManager(nimmgr):
769 config.Nims = ConfigSubList()
770 for x in range(len(nimmgr.nim_slots)):
771 config.Nims.append(ConfigSubsection())
773 for slot in nimmgr.nim_slots:
777 # HACK: currently, we can only looptrough to socket A
779 if slot.isCompatible("DVB-S"):
781 nim.configMode = ConfigSelection(
783 "simple": _("simple"),
784 "advanced": _("advanced"),
785 "nothing": _("nothing connected"),
789 nim.configMode = ConfigSelection(
791 "equal": _("equal to Socket A"),
792 "loopthrough": _("loopthrough to socket A"),
793 "nothing": _("nothing connected"),
794 "satposdepends": _("second cable of motorized LNB"),
795 "simple": _("simple"),
796 "advanced": _("advanced")},
797 default = "loopthrough")
799 #important - check if just the 2nd one is LT only and the first one is DVB-S
800 # CHECKME: is this logic correct for >2 slots?
801 if nim.configMode.value in ["loopthrough", "satposdepends", "equal"]:
802 if x == 0: # first one can never be linked to anything
804 nim.configMode.value = "simple"
805 nim.configMode.save()
807 #FIXME: make it better
808 for y in nimmgr.nim_slots:
810 if not y.isCompatible("DVB-S"):
812 nim.configMode.value = "simple"
813 nim.configMode.save()
815 nim.diseqcMode = ConfigSelection(
817 ("single", _("Single")),
818 ("toneburst_a_b", _("Toneburst A/B")),
819 ("diseqc_a_b", _("DiSEqC A/B")),
820 ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")),
821 ("positioner", _("Positioner"))],
822 default = "diseqc_a_b")
824 nim.diseqcA = getConfigSatlist(192, nimmgr.satList)
825 nim.diseqcB = getConfigSatlist(130, nimmgr.satList)
826 nim.diseqcC = ConfigSatlist(list = nimmgr.satList)
827 nim.diseqcD = ConfigSatlist(list = nimmgr.satList)
828 nim.positionerMode = ConfigSelection(
830 ("usals", _("USALS")),
831 ("manual", _("manual"))],
833 nim.longitude = ConfigFloat(default=[5,100], limits=[(0,359),(0,999)])
834 nim.longitudeOrientation = ConfigSelection(choices={"east": _("East"), "west": _("West")}, default = "east")
835 nim.latitude = ConfigFloat(default=[50,767], limits=[(0,359),(0,999)])
836 nim.latitudeOrientation = ConfigSelection(choices={"north": _("North"), "south": _("South")}, default="north")
837 nim.turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch")) ], default = "fast")
838 btime = datetime(1970, 1, 1, 7, 0);
839 nim.fastTurningBegin = ConfigDateTime(default = mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 900)
840 etime = datetime(1970, 1, 1, 19, 0);
841 nim.fastTurningEnd = ConfigDateTime(default = mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 900)
842 # get other frontends of the same type
844 satNimList = nimmgr.getNimListOfType("DVB-S", slot.slot)
848 n = nimmgr.nim_slots[x]
849 satNimListNames["%d" % n.slot] = n.friendly_full_description
851 if len(satNimListNames):
852 nim.equalTo = ConfigSelection(choices = satNimListNames)
853 nim.linkedTo = ConfigSelection(choices = satNimListNames)
854 nim.satposDependsTo = ConfigSelection(choices = satNimListNames)
857 nim.advanced = ConfigSubsection()
858 nim.advanced.sats = getConfigSatlist(192,nimmgr.satList)
859 nim.advanced.sat = ConfigSubDict()
860 lnbs = [("0", "not available")]
861 for y in range(1, 33):
862 lnbs.append((str(y), "LNB " + str(y)))
864 for x in nimmgr.satList:
865 nim.advanced.sat[x[0]] = ConfigSubsection()
866 nim.advanced.sat[x[0]].voltage = ConfigSelection(choices={"polarization": _("Polarization"), "13V": _("13 V"), "18V": _("18 V")}, default = "polarization")
867 nim.advanced.sat[x[0]].tonemode = ConfigSelection(choices={"band": _("Band"), "on": _("On"), "off": _("Off")}, default = "band")
868 nim.advanced.sat[x[0]].usals = ConfigYesNo(default=True)
869 nim.advanced.sat[x[0]].rotorposition = ConfigInteger(default=1, limits=(1, 255))
870 nim.advanced.sat[x[0]].lnb = ConfigSelection(choices = lnbs)
872 csw = [("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))]
873 for y in range(0, 16):
874 csw.append((str(0xF0|y), "Input " + str(y+1)))
876 ucsw = [("0", _("None"))]
877 for y in range(1, 17):
878 ucsw.append((str(y), "Input " + str(y)))
880 nim.advanced.lnb = ConfigSubList()
881 nim.advanced.lnb.append(ConfigNothing())
882 for x in range(1, 33):
883 nim.advanced.lnb.append(ConfigSubsection())
884 nim.advanced.lnb[x].lof = ConfigSelection(choices={"universal_lnb": _("Universal LNB"), "c_band": _("C-Band"), "user_defined": _("User defined")}, default="universal_lnb")
885 nim.advanced.lnb[x].lofl = ConfigInteger(default=9750, limits = (0, 99999))
886 nim.advanced.lnb[x].lofh = ConfigInteger(default=10600, limits = (0, 99999))
887 nim.advanced.lnb[x].threshold = ConfigInteger(default=11700, limits = (0, 99999))
888 # nim.advanced.lnb[x].output_12v = ConfigSelection(choices = [("0V", _("0 V")), ("12V", _("12 V"))], default="0V")
889 nim.advanced.lnb[x].increased_voltage = ConfigYesNo(default=False)
890 nim.advanced.lnb[x].toneburst = ConfigSelection(choices = [("none", _("None")), ("A", _("A")), ("B", _("B"))], default = "none")
891 nim.advanced.lnb[x].diseqcMode = ConfigSelection(choices = [("none", _("None")), ("1_0", _("1.0")), ("1_1", _("1.1")), ("1_2", _("1.2"))], default = "none")
892 nim.advanced.lnb[x].commitedDiseqcCommand = ConfigSelection(choices = csw)
893 nim.advanced.lnb[x].fastDiseqc = ConfigYesNo(default=False)
894 nim.advanced.lnb[x].sequenceRepeat = ConfigYesNo(default=False)
895 nim.advanced.lnb[x].commandOrder1_0 = ConfigSelection(choices = [("ct", "committed, toneburst"), ("tc", "toneburst, committed")], default = "ct")
896 nim.advanced.lnb[x].commandOrder = ConfigSelection(choices = [
897 ("ct", "committed, toneburst"),
898 ("tc", "toneburst, committed"),
899 ("cut", "committed, uncommitted, toneburst"),
900 ("tcu", "toneburst, committed, uncommitted"),
901 ("uct", "uncommitted, committed, toneburst"),
902 ("tuc", "toneburst, uncommitted, commmitted")],
904 nim.advanced.lnb[x].uncommittedDiseqcCommand = ConfigSelection(choices = ucsw)
905 nim.advanced.lnb[x].diseqcRepeats = ConfigSelection(choices = [("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))], default = "none")
906 nim.advanced.lnb[x].longitude = ConfigFloat(default = [5,100], limits = [(0,359),(0,999)])
907 nim.advanced.lnb[x].longitudeOrientation = ConfigSelection(choices = [("east", _("East")), ("west", _("West"))], default = "east")
908 nim.advanced.lnb[x].latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)])
909 nim.advanced.lnb[x].latitudeOrientation = ConfigSelection(choices = [("north", _("North")), ("south", _("South"))], default = "north")
910 nim.advanced.lnb[x].powerMeasurement = ConfigYesNo(default=True)
911 nim.advanced.lnb[x].powerThreshold = ConfigInteger(default=50, limits=(0, 100))
912 nim.advanced.lnb[x].turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch"))], default = "fast")
913 btime = datetime(1970, 1, 1, 7, 0);
914 nim.advanced.lnb[x].fastTurningBegin = ConfigDateTime(default=mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 600)
915 etime = datetime(1970, 1, 1, 19, 0);
916 nim.advanced.lnb[x].fastTurningEnd = ConfigDateTime(default=mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 600)
917 elif slot.isCompatible("DVB-C"):
918 nim.configMode = ConfigSelection(
920 "enabled": _("enabled"),
921 "nothing": _("nothing connected"),
926 for x in nimmgr.cablesList:
927 list.append((str(n), x[0]))
929 nim.cable = ConfigSubsection()
930 possible_scan_types = [("bands", _("Frequency bands")), ("steps", _("Frequency steps"))]
932 possible_scan_types.append(("provider", _("Provider")))
933 nim.cable.scan_type = ConfigSelection(default = "bands", choices = possible_scan_types)
934 nim.cable.scan_provider = ConfigSelection(default = "0", choices = list)
935 nim.cable.scan_band_EU_VHF_I = ConfigYesNo(default = True)
936 nim.cable.scan_band_EU_MID = ConfigYesNo(default = True)
937 nim.cable.scan_band_EU_VHF_III = ConfigYesNo(default = True)
938 nim.cable.scan_band_EU_UHF_IV = ConfigYesNo(default = True)
939 nim.cable.scan_band_EU_UHF_V = ConfigYesNo(default = True)
940 nim.cable.scan_band_EU_SUPER = ConfigYesNo(default = True)
941 nim.cable.scan_band_EU_HYPER = ConfigYesNo(default = True)
942 nim.cable.scan_band_US_LOW = ConfigYesNo(default = False)
943 nim.cable.scan_band_US_MID = ConfigYesNo(default = False)
944 nim.cable.scan_band_US_HIGH = ConfigYesNo(default = False)
945 nim.cable.scan_band_US_SUPER = ConfigYesNo(default = False)
946 nim.cable.scan_band_US_HYPER = ConfigYesNo(default = False)
947 nim.cable.scan_frequency_steps = ConfigInteger(default = 1000, limits = (1000, 10000))
948 nim.cable.scan_mod_qam16 = ConfigYesNo(default = False)
949 nim.cable.scan_mod_qam32 = ConfigYesNo(default = False)
950 nim.cable.scan_mod_qam64 = ConfigYesNo(default = True)
951 nim.cable.scan_mod_qam128 = ConfigYesNo(default = False)
952 nim.cable.scan_mod_qam256 = ConfigYesNo(default = True)
953 nim.cable.scan_sr_6900 = ConfigYesNo(default = True)
954 nim.cable.scan_sr_6875 = ConfigYesNo(default = True)
955 nim.cable.scan_sr_ext1 = ConfigInteger(default = 0, limits = (0, 7230))
956 nim.cable.scan_sr_ext2 = ConfigInteger(default = 0, limits = (0, 7230))
957 elif slot.isCompatible("DVB-T"):
958 nim.configMode = ConfigSelection(
960 "enabled": _("enabled"),
961 "nothing": _("nothing connected"),
966 for x in nimmgr.terrestrialsList:
967 list.append((str(n), x[0]))
969 nim.terrestrial = ConfigSelection(choices = list)
970 nim.terrestrial_5V = ConfigOnOff()
972 nim.configMode = ConfigSelection(choices = { "nothing": _("disabled") }, default="nothing");
973 print "pls add support for this frontend type!"
976 nimmgr.sec = SecConfigure(nimmgr)
978 nimmanager = NimManager()