1 from Tools.HardwareInfo import HardwareInfo
2 from Tools.BoundFunction import boundFunction
4 from config import config, ConfigSubsection, ConfigSelection, ConfigFloat, \
5 ConfigSatlist, ConfigYesNo, ConfigInteger, ConfigSubList, ConfigNothing, \
6 ConfigSubDict, ConfigOnOff, ConfigDateTime
8 from enigma import eDVBSatelliteEquipmentControl as secClass, \
9 eDVBSatelliteLNBParameters as lnbParam, \
10 eDVBSatelliteDiseqcParameters as diseqcParam, \
11 eDVBSatelliteSwitchParameters as switchParam, \
12 eDVBSatelliteRotorParameters as rotorParam, \
13 eDVBResourceManager, eDVBDB, eEnv
15 from time import localtime, mktime
16 from datetime import datetime
17 from Tools.BoundFunction import boundFunction
19 from Tools import Directories
20 import xml.etree.cElementTree
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 getConfiguredSats(self):
39 return self.configuredSatellites
41 def addSatellite(self, sec, orbpos):
42 sec.addSatellite(orbpos)
43 self.configuredSatellites.add(orbpos)
45 def addLNBSimple(self, sec, slotid, diseqcmode, toneburstmode = diseqcParam.NO, diseqcpos = diseqcParam.SENDNO, orbpos = 0, longitude = 0, latitude = 0, loDirection = 0, laDirection = 0, turningSpeed = rotorParam.FAST, useInputPower=True, inputPowerDelta=50, fastDiSEqC = False, setVoltageTone = True, diseqc13V = False):
46 if orbpos is None or orbpos == 3601:
50 tunermask = 1 << slotid
51 if self.equal.has_key(slotid):
52 for slot in self.equal[slotid]:
53 tunermask |= (1 << slot)
54 if self.linked.has_key(slotid):
55 for slot in self.linked[slotid]:
56 tunermask |= (1 << slot)
59 sec.setLNBLOFL(9750000)
60 sec.setLNBLOFH(10600000)
61 sec.setLNBThreshold(11700000)
62 sec.setLNBIncreasedVoltage(lnbParam.OFF)
64 sec.setFastDiSEqC(fastDiSEqC)
66 sec.setCommandOrder(0)
69 sec.setDiSEqCMode(diseqcmode)
70 sec.setToneburst(toneburstmode)
71 sec.setCommittedCommand(diseqcpos)
72 sec.setUncommittedCommand(0) # SENDNO
73 #print "set orbpos to:" + str(orbpos)
75 if 0 <= diseqcmode < 3:
76 self.addSatellite(sec, orbpos)
79 sec.setVoltageMode(switchParam.HV_13)
81 sec.setVoltageMode(switchParam.HV)
82 sec.setToneMode(switchParam.HILO)
84 sec.setVoltageMode(switchParam._14V)
85 sec.setToneMode(switchParam.OFF)
86 elif (diseqcmode == 3): # diseqc 1.2
87 if self.satposdepends.has_key(slotid):
88 for slot in self.satposdepends[slotid]:
89 tunermask |= (1 << slot)
90 sec.setLatitude(latitude)
91 sec.setLaDirection(laDirection)
92 sec.setLongitude(longitude)
93 sec.setLoDirection(loDirection)
94 sec.setUseInputpower(useInputPower)
95 sec.setInputpowerDelta(inputPowerDelta)
96 sec.setRotorTurningSpeed(turningSpeed)
98 for x in self.NimManager.satList:
99 print "Add sat " + str(x[0])
100 self.addSatellite(sec, int(x[0]))
102 sec.setVoltageMode(switchParam.HV_13)
104 sec.setVoltageMode(switchParam.HV)
105 sec.setToneMode(switchParam.HILO)
106 sec.setRotorPosNum(0) # USALS
108 sec.setLNBSlotMask(tunermask)
110 def setSatposDepends(self, sec, nim1, nim2):
111 print "tuner", nim1, "depends on satpos of", nim2
112 sec.setTunerDepends(nim1, nim2)
114 def linkInternally(self, slotid):
115 nim = self.NimManager.getNim(slotid)
116 if nim.internallyConnectableTo is not None:
117 nim.setInternalLink()
119 def linkNIMs(self, sec, nim1, nim2):
120 print "link tuner", nim1, "to tuner", nim2
121 # if nim2 == (nim1 - 1):
122 # self.linkInternally(nim1)
124 # for internally connect tuner A to B
125 self.linkInternally(nim1)
126 sec.setTunerLinked(nim1, nim2)
128 def getRoot(self, slotid, connto):
130 while (self.NimManager.getNimConfig(connto).configMode.value in ("satposdepends", "equal", "loopthrough")):
131 connto = int(self.NimManager.getNimConfig(connto).connectedTo.value)
132 if connto in visited: # prevent endless loop
134 visited.append(connto)
138 sec = secClass.getInstance()
139 self.configuredSatellites = set()
140 for slotid in self.NimManager.getNimListOfType("DVB-S"):
141 if self.NimManager.nimInternallyConnectableTo(slotid) is not None:
142 self.NimManager.nimRemoveInternalLink(slotid)
143 sec.clear() ## this do unlinking NIMs too !!
144 print "sec config cleared"
147 self.satposdepends = { }
150 nim_slots = self.NimManager.nim_slots
154 for slot in nim_slots:
155 if slot.type is not None:
156 used_nim_slots.append((slot.slot, slot.description, slot.config.configMode.value != "nothing" and True or False, slot.isCompatible("DVB-S2"), slot.isCompatible("DVB-T2"), slot.frontend_id is None and -1 or slot.frontend_id))
157 eDVBResourceManager.getInstance().setFrontendSlotInformations(used_nim_slots)
159 for slot in nim_slots:
162 if slot.isCompatible("DVB-S"):
163 # save what nim we link to/are equal to/satposdepends to.
164 # this is stored in the *value* (not index!) of the config list
165 if nim.configMode.value == "equal":
166 connto = self.getRoot(x, int(nim.connectedTo.value))
167 if not self.equal.has_key(connto):
168 self.equal[connto] = []
169 self.equal[connto].append(x)
170 elif nim.configMode.value == "loopthrough":
171 self.linkNIMs(sec, x, int(nim.connectedTo.value))
172 connto = self.getRoot(x, int(nim.connectedTo.value))
173 if not self.linked.has_key(connto):
174 self.linked[connto] = []
175 self.linked[connto].append(x)
176 elif nim.configMode.value == "satposdepends":
177 self.setSatposDepends(sec, x, int(nim.connectedTo.value))
178 connto = self.getRoot(x, int(nim.connectedTo.value))
179 if not self.satposdepends.has_key(connto):
180 self.satposdepends[connto] = []
181 self.satposdepends[connto].append(x)
183 for slot in nim_slots:
187 if slot.isCompatible("DVB-S"):
188 print "slot: " + str(x) + " configmode: " + str(nim.configMode.value)
189 if nim.configMode.value in ( "loopthrough", "satposdepends", "nothing" ):
192 sec.setSlotNotLinked(x)
193 if nim.configMode.value == "equal":
195 elif nim.configMode.value == "simple": #simple config
196 print "diseqcmode: ", nim.diseqcMode.value
197 if nim.diseqcMode.value == "single": #single
198 if nim.simpleSingleSendDiSEqC.value:
199 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA, diseqc13V = nim.diseqc13V.value)
201 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.NONE, diseqcpos = diseqcParam.SENDNO, diseqc13V = nim.diseqc13V.value)
202 elif nim.diseqcMode.value == "toneburst_a_b": #Toneburst A/B
203 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.A, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO, diseqc13V = nim.diseqc13V.value)
204 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.B, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO, diseqc13V = nim.diseqc13V.value)
205 elif nim.diseqcMode.value == "diseqc_a_b": #DiSEqC A/B
206 fastDiSEqC = nim.simpleDiSEqCOnlyOnSatChange.value
207 setVoltageTone = nim.simpleDiSEqCSetVoltageTone.value
208 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone, diseqc13V = nim.diseqc13V.value)
209 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone, diseqc13V = nim.diseqc13V.value)
210 elif nim.diseqcMode.value == "diseqc_a_b_c_d": #DiSEqC A/B/C/D
211 fastDiSEqC = nim.simpleDiSEqCOnlyOnSatChange.value
212 setVoltageTone = nim.simpleDiSEqCSetVoltageTone.value
213 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone, diseqc13V = nim.diseqc13V.value)
214 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone, diseqc13V = nim.diseqc13V.value)
215 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcC.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BA, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone, diseqc13V = nim.diseqc13V.value)
216 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcD.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BB, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone, diseqc13V = nim.diseqc13V.value)
217 elif nim.diseqcMode.value == "positioner": #Positioner
218 if nim.latitudeOrientation.value == "north":
219 laValue = rotorParam.NORTH
221 laValue = rotorParam.SOUTH
222 if nim.longitudeOrientation.value == "east":
223 loValue = rotorParam.EAST
225 loValue = rotorParam.WEST
226 inputPowerDelta=nim.powerThreshold.value
229 if nim.powerMeasurement.value:
231 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
232 if turn_speed_dict.has_key(nim.turningSpeed.value):
233 turning_speed = turn_speed_dict[nim.turningSpeed.value]
235 beg_time = localtime(nim.fastTurningBegin.value)
236 end_time = localtime(nim.fastTurningEnd.value)
237 turning_speed = ((beg_time.tm_hour+1) * 60 + beg_time.tm_min + 1) << 16
238 turning_speed |= (end_time.tm_hour+1) * 60 + end_time.tm_min + 1
239 self.addLNBSimple(sec, slotid = x, diseqcmode = 3,
240 longitude = nim.longitude.float,
241 loDirection = loValue,
242 latitude = nim.latitude.float,
243 laDirection = laValue,
244 turningSpeed = turning_speed,
245 useInputPower = useInputPower,
246 inputPowerDelta = inputPowerDelta,
247 diseqc13V = nim.diseqc13V.value)
248 elif nim.configMode.value == "advanced": #advanced config
249 self.updateAdvanced(sec, x)
250 print "sec config completed"
252 def updateAdvanced(self, sec, slotid):
254 if config.Nims[slotid].advanced.unicableconnected is not None:
255 if config.Nims[slotid].advanced.unicableconnected.value == True:
256 config.Nims[slotid].advanced.unicableconnectedTo.save_forced = True
257 self.linkNIMs(sec, slotid, int(config.Nims[slotid].advanced.unicableconnectedTo.value))
258 connto = self.getRoot(slotid, int(config.Nims[slotid].advanced.unicableconnectedTo.value))
259 if not self.linked.has_key(connto):
260 self.linked[connto] = []
261 self.linked[connto].append(slotid)
263 config.Nims[slotid].advanced.unicableconnectedTo.save_forced = False
268 for x in range(1,37):
271 #wildcard for all satellites ( for rotor )
272 for x in range(3601, 3605):
273 lnb = int(config.Nims[slotid].advanced.sat[x].lnb.value)
275 for x in self.NimManager.satList:
276 print "add", x[0], "to", lnb
277 lnbSat[lnb].append(x[0])
279 for x in self.NimManager.satList:
280 lnb = int(config.Nims[slotid].advanced.sat[x[0]].lnb.value)
282 print "add", x[0], "to", lnb
283 lnbSat[lnb].append(x[0])
285 for x in range(1,37):
286 if len(lnbSat[x]) > 0:
287 currLnb = config.Nims[slotid].advanced.lnb[x]
293 tunermask = 1 << slotid
294 if self.equal.has_key(slotid):
295 for slot in self.equal[slotid]:
296 tunermask |= (1 << slot)
297 if self.linked.has_key(slotid):
298 for slot in self.linked[slotid]:
299 tunermask |= (1 << slot)
301 if currLnb.lof.value != "unicable":
304 if currLnb.lof.value == "universal_lnb":
305 sec.setLNBLOFL(9750000)
306 sec.setLNBLOFH(10600000)
307 sec.setLNBThreshold(11700000)
308 elif currLnb.lof.value == "unicable":
309 def setupUnicable(configManufacturer, ProductDict):
310 manufacturer_name = configManufacturer.value
311 manufacturer = ProductDict[manufacturer_name]
312 product_name = manufacturer.product.value
313 sec.setLNBSatCR(manufacturer.scr[product_name].index)
314 sec.setLNBSatCRvco(manufacturer.vco[product_name][manufacturer.scr[product_name].index].value*1000)
315 sec.setLNBSatCRpositions(manufacturer.positions[product_name][0].value)
316 sec.setLNBLOFL(manufacturer.lofl[product_name][0].value * 1000)
317 sec.setLNBLOFH(manufacturer.lofh[product_name][0].value * 1000)
318 sec.setLNBThreshold(manufacturer.loft[product_name][0].value * 1000)
319 configManufacturer.save_forced = True
320 manufacturer.product.save_forced = True
321 manufacturer.vco[product_name][manufacturer.scr[product_name].index].save_forced = True
323 if currLnb.unicable.value == "unicable_user":
324 #TODO satpositions for satcruser
325 sec.setLNBLOFL(currLnb.lofl.value * 1000)
326 sec.setLNBLOFH(currLnb.lofh.value * 1000)
327 sec.setLNBThreshold(currLnb.threshold.value * 1000)
328 sec.setLNBSatCR(currLnb.satcruser.index)
329 sec.setLNBSatCRvco(currLnb.satcrvcouser[currLnb.satcruser.index].value*1000)
330 sec.setLNBSatCRpositions(1) #HACK
331 elif currLnb.unicable.value == "unicable_matrix":
332 setupUnicable(currLnb.unicableMatrixManufacturer, currLnb.unicableMatrix)
333 elif currLnb.unicable.value == "unicable_lnb":
334 setupUnicable(currLnb.unicableLnbManufacturer, currLnb.unicableLnb)
335 elif currLnb.lof.value == "c_band":
336 sec.setLNBLOFL(5150000)
337 sec.setLNBLOFH(5150000)
338 sec.setLNBThreshold(5150000)
339 elif currLnb.lof.value == "user_defined":
340 sec.setLNBLOFL(currLnb.lofl.value * 1000)
341 sec.setLNBLOFH(currLnb.lofh.value * 1000)
342 sec.setLNBThreshold(currLnb.threshold.value * 1000)
344 # if currLnb.output_12v.value == "0V":
345 # pass # nyi in drivers
346 # elif currLnb.output_12v.value == "12V":
347 # pass # nyi in drivers
349 if currLnb.increased_voltage.value:
350 sec.setLNBIncreasedVoltage(lnbParam.ON)
352 sec.setLNBIncreasedVoltage(lnbParam.OFF)
354 dm = currLnb.diseqcMode.value
356 sec.setDiSEqCMode(diseqcParam.NONE)
358 sec.setDiSEqCMode(diseqcParam.V1_0)
360 sec.setDiSEqCMode(diseqcParam.V1_1)
362 sec.setDiSEqCMode(diseqcParam.V1_2)
364 if self.satposdepends.has_key(slotid):
365 for slot in self.satposdepends[slotid]:
366 tunermask |= (1 << slot)
369 if currLnb.toneburst.value == "none":
370 sec.setToneburst(diseqcParam.NO)
371 elif currLnb.toneburst.value == "A":
372 sec.setToneburst(diseqcParam.A)
373 elif currLnb.toneburst.value == "B":
374 sec.setToneburst(diseqcParam.B)
376 # Committed Diseqc Command
377 cdc = currLnb.commitedDiseqcCommand.value
379 c = { "none": diseqcParam.SENDNO,
380 "AA": diseqcParam.AA,
381 "AB": diseqcParam.AB,
382 "BA": diseqcParam.BA,
383 "BB": diseqcParam.BB }
386 sec.setCommittedCommand(c[cdc])
388 sec.setCommittedCommand(long(cdc))
390 sec.setFastDiSEqC(currLnb.fastDiseqc.value)
392 sec.setSeqRepeat(currLnb.sequenceRepeat.value)
394 if currLnb.diseqcMode.value == "1_0":
395 currCO = currLnb.commandOrder1_0.value
398 currCO = currLnb.commandOrder.value
400 udc = int(currLnb.uncommittedDiseqcCommand.value)
402 sec.setUncommittedCommand(0xF0|(udc-1))
404 sec.setUncommittedCommand(0) # SENDNO
406 sec.setRepeats({"none": 0, "one": 1, "two": 2, "three": 3}[currLnb.diseqcRepeats.value])
408 setCommandOrder = False
410 # 0 "committed, toneburst",
411 # 1 "toneburst, committed",
412 # 2 "committed, uncommitted, toneburst",
413 # 3 "toneburst, committed, uncommitted",
414 # 4 "uncommitted, committed, toneburst"
415 # 5 "toneburst, uncommitted, commmitted"
416 order_map = {"ct": 0, "tc": 1, "cut": 2, "tcu": 3, "uct": 4, "tuc": 5}
417 sec.setCommandOrder(order_map[currCO])
420 latitude = currLnb.latitude.float
421 sec.setLatitude(latitude)
422 longitude = currLnb.longitude.float
423 sec.setLongitude(longitude)
424 if currLnb.latitudeOrientation.value == "north":
425 sec.setLaDirection(rotorParam.NORTH)
427 sec.setLaDirection(rotorParam.SOUTH)
428 if currLnb.longitudeOrientation.value == "east":
429 sec.setLoDirection(rotorParam.EAST)
431 sec.setLoDirection(rotorParam.WEST)
433 if currLnb.powerMeasurement.value:
434 sec.setUseInputpower(True)
435 sec.setInputpowerDelta(currLnb.powerThreshold.value)
436 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
437 if turn_speed_dict.has_key(currLnb.turningSpeed.value):
438 turning_speed = turn_speed_dict[currLnb.turningSpeed.value]
440 beg_time = localtime(currLnb.fastTurningBegin.value)
441 end_time = localtime(currLnb.fastTurningEnd.value)
442 turning_speed = ((beg_time.tm_hour + 1) * 60 + beg_time.tm_min + 1) << 16
443 turning_speed |= (end_time.tm_hour + 1) * 60 + end_time.tm_min + 1
444 sec.setRotorTurningSpeed(turning_speed)
446 sec.setUseInputpower(False)
448 sec.setLNBSlotMask(tunermask)
450 sec.setLNBPrio(int(currLnb.prio.value))
452 # finally add the orbital positions
454 self.addSatellite(sec, y)
456 satpos = x > 32 and (3604-(36 - x)) or y
459 currSat = config.Nims[slotid].advanced.sat[satpos]
460 if currSat.voltage.value == "polarization":
461 if config.Nims[slotid].diseqc13V.value:
462 sec.setVoltageMode(switchParam.HV_13)
464 sec.setVoltageMode(switchParam.HV)
465 elif currSat.voltage.value == "13V":
466 sec.setVoltageMode(switchParam._14V)
467 elif currSat.voltage.value == "18V":
468 sec.setVoltageMode(switchParam._18V)
470 if currSat.tonemode.value == "band":
471 sec.setToneMode(switchParam.HILO)
472 elif currSat.tonemode.value == "on":
473 sec.setToneMode(switchParam.ON)
474 elif currSat.tonemode.value == "off":
475 sec.setToneMode(switchParam.OFF)
477 if not currSat.usals.value and x < 34:
478 sec.setRotorPosNum(currSat.rotorposition.value)
480 sec.setRotorPosNum(0) #USALS
482 def __init__(self, nimmgr):
483 self.NimManager = nimmgr
484 self.configuredSatellites = set()
488 def __init__(self, slot, type, description, has_outputs = True, internally_connectable = None, multi_type = {}, frontend_id = None, i2c = None, is_empty = False):
491 if type not in ("DVB-S", "DVB-C", "DVB-T", "DVB-S2", "DVB-T2", None):
492 print "warning: unknown NIM type %s, not using." % type
496 self.description = description
497 self.has_outputs = has_outputs
498 self.internally_connectable = internally_connectable
499 self.multi_type = multi_type
501 self.frontend_id = frontend_id
502 self.__is_empty = is_empty
504 def isCompatible(self, what):
505 if not self.isSupported():
509 "DVB-S": ("DVB-S", None),
510 "DVB-C": ("DVB-C", None),
511 "DVB-T": ("DVB-T", None),
512 "DVB-S2": ("DVB-S", "DVB-S2", None),
513 "DVB-T2": ("DVB-T", "DVB-T2", None)
515 return what in compatible[self.type]
520 def connectableTo(self):
522 "DVB-S": ("DVB-S", "DVB-S2"),
525 "DVB-S2": ("DVB-S", "DVB-S2"),
526 "DVB-T2": ("DVB-T", "DVB-T2",)
528 return connectable[self.type]
530 def getSlotName(self):
531 # get a friendly description for a slot name.
532 # we name them "Tuner A/B/C/...", because that's what's usually written on the back
534 return _("Tuner ") + chr(ord('A') + self.slot)
536 slot_name = property(getSlotName)
539 return chr(ord('A') + self.slot)
544 def hasOutputs(self):
545 return self.has_outputs
547 def internallyConnectableTo(self):
548 return self.internally_connectable
550 def setInternalLink(self):
551 if self.internally_connectable is not None:
552 print "setting internal link on frontend id", self.frontend_id
553 open("/proc/stb/frontend/%d/rf_switch" % self.frontend_id, "w").write("internal")
555 def removeInternalLink(self):
556 if self.internally_connectable is not None:
557 print "removing internal link on frontend id", self.frontend_id
558 open("/proc/stb/frontend/%d/rf_switch" % self.frontend_id, "w").write("external")
560 def isMultiType(self):
561 return (len(self.multi_type) > 0)
564 return self.__is_empty
566 # empty tuners are supported!
567 def isSupported(self):
568 return (self.frontend_id is not None) or self.__is_empty
570 # returns dict {<slotid>: <type>}
571 def getMultiTypeList(self):
572 return self.multi_type
574 slot_id = property(getSlotID)
576 def getFriendlyType(self):
586 friendly_type = property(getFriendlyType)
588 def getFriendlyFullDescription(self):
589 nim_text = self.slot_name + ": "
592 nim_text += _("(empty)")
593 elif not self.isSupported():
594 nim_text += self.description + " (" + _("not supported") + ")"
596 nim_text += self.description + " (" + self.friendly_type + ")"
600 friendly_full_description = property(getFriendlyFullDescription)
601 config_mode = property(lambda self: config.Nims[self.slot].configMode.value)
602 config = property(lambda self: config.Nims[self.slot])
603 empty = property(lambda self: self.type is None)
606 def getConfiguredSats(self):
607 return self.sec.getConfiguredSats()
609 def getTransponders(self, pos):
610 if self.transponders.has_key(pos):
611 return self.transponders[pos]
615 def getTranspondersCable(self, nim):
616 nimConfig = config.Nims[nim]
617 if nimConfig.configMode.value != "nothing" and nimConfig.cable.scan_type.value == "provider":
618 return self.transponderscable[self.cablesList[nimConfig.cable.scan_provider.index][0]]
621 def getTranspondersTerrestrial(self, region):
622 return self.transpondersterrestrial[region]
624 def getCableDescription(self, nim):
625 return self.cablesList[config.Nims[nim].scan_provider.index][0]
627 def getCableFlags(self, nim):
628 return self.cablesList[config.Nims[nim].scan_provider.index][1]
630 def getTerrestrialDescription(self, nim):
631 return self.terrestrialsList[config.Nims[nim].terrestrial.index][0]
633 def getTerrestrialFlags(self, nim):
634 return self.terrestrialsList[config.Nims[nim].terrestrial.index][1]
636 def getSatDescription(self, pos):
637 return self.satellites[pos]
639 def sortFunc(self, x):
646 def readTransponders(self):
647 # read initial networks from file. we only read files which we are interested in,
648 # which means only these where a compatible tuner exists.
649 self.satellites = { }
650 self.transponders = { }
651 self.transponderscable = { }
652 self.transpondersterrestrial = { }
653 db = eDVBDB.getInstance()
654 if self.hasNimType("DVB-S"):
655 print "Reading satellites.xml"
656 db.readSatellites(self.satList, self.satellites, self.transponders)
657 self.satList.sort(key = self.sortFunc) # sort by orbpos
658 #print "SATLIST", self.satList
659 #print "SATS", self.satellites
660 #print "TRANSPONDERS", self.transponders
662 if self.hasNimType("DVB-C"):
663 print "Reading cables.xml"
664 db.readCables(self.cablesList, self.transponderscable)
665 # print "CABLIST", self.cablesList
666 # print "TRANSPONDERS", self.transponders
668 if self.hasNimType("DVB-T"):
669 print "Reading terrestrial.xml"
670 db.readTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
671 # print "TERLIST", self.terrestrialsList
672 # print "TRANSPONDERS", self.transpondersterrestrial
674 def enumerateNIMs(self):
675 # enum available NIMs. This is currently very dreambox-centric and uses the /proc/bus/nim_sockets interface.
676 # the result will be stored into nim_slots.
677 # the content of /proc/bus/nim_sockets looks like:
680 # Name: BCM4501 DVB-S2 NIM (internal)
683 # Name: BCM4501 DVB-S2 NIM (internal)
686 # Name: Philips TU1216
689 # Name: Alps BSBE1 702A
692 # Type will be either "DVB-S", "DVB-S2", "DVB-T", "DVB-C" or None.
694 # nim_slots is an array which has exactly one entry for each slot, even for empty ones.
697 nimfile = tryOpen("/proc/bus/nim_sockets")
705 for line in nimfile.readlines():
708 if line.strip().startswith("NIM Socket"):
709 parts = line.strip().split(" ")
710 current_slot = int(parts[2][:-1])
711 entries[current_slot] = {}
712 elif line.strip().startswith("Type:"):
713 entries[current_slot]["type"] = str(line.strip()[6:])
714 entries[current_slot]["isempty"] = False
715 elif line.strip().startswith("Name:"):
716 entries[current_slot]["name"] = str(line.strip()[6:])
717 entries[current_slot]["isempty"] = False
718 elif line.strip().startswith("Has_Outputs:"):
719 input = str(line.strip()[len("Has_Outputs:") + 1:])
720 entries[current_slot]["has_outputs"] = (input == "yes")
721 elif line.strip().startswith("Internally_Connectable:"):
722 input = int(line.strip()[len("Internally_Connectable:") + 1:])
723 entries[current_slot]["internally_connectable"] = input
724 elif line.strip().startswith("Frontend_Device:"):
725 input = int(line.strip()[len("Frontend_Device:") + 1:])
726 entries[current_slot]["frontend_device"] = input
727 elif line.strip().startswith("Mode"):
728 # "Mode 0: DVB-T" -> ["Mode 0", " DVB-T"]
729 split = line.strip().split(":")
730 # "Mode 0" -> ["Mode, "0"]
731 split2 = split[0].split(" ")
732 modes = entries[current_slot].get("multi_type", {})
733 modes[split2[1]] = split[1].strip()
734 entries[current_slot]["multi_type"] = modes
735 elif line.strip().startswith("I2C_Device:"):
736 input = int(line.strip()[len("I2C_Device:") + 1:])
737 entries[current_slot]["i2c"] = input
738 elif line.strip().startswith("empty"):
739 entries[current_slot]["type"] = None
740 entries[current_slot]["name"] = _("N/A")
741 entries[current_slot]["isempty"] = True
746 for id, entry in entries.items():
747 if not (entry.has_key("name") and entry.has_key("type")):
748 entry["name"] = _("N/A")
750 if not (entry.has_key("i2c")):
752 if not (entry.has_key("has_outputs")):
753 entry["has_outputs"] = True
754 if entry.has_key("frontend_device"): # check if internally connectable
755 if path.exists("/proc/stb/frontend/%d/rf_switch" % entry["frontend_device"]):
756 entry["internally_connectable"] = entry["frontend_device"] - 1
758 entry["internally_connectable"] = None
760 entry["frontend_device"] = entry["internally_connectable"] = None
761 if not (entry.has_key("multi_type")):
762 entry["multi_type"] = {}
763 self.nim_slots.append(NIM(slot = id, description = entry["name"], type = entry["type"], has_outputs = entry["has_outputs"], internally_connectable = entry["internally_connectable"], multi_type = entry["multi_type"], frontend_id = entry["frontend_device"], i2c = entry["i2c"], is_empty = entry["isempty"]))
765 def hasNimType(self, chktype):
766 for slot in self.nim_slots:
767 if slot.isCompatible(chktype):
769 for type in slot.getMultiTypeList().values():
774 def getNimType(self, slotid):
775 return self.nim_slots[slotid].type
777 def getNimDescription(self, slotid):
778 return self.nim_slots[slotid].friendly_full_description
780 def getNimName(self, slotid):
781 return self.nim_slots[slotid].description
783 def getNim(self, slotid):
784 return self.nim_slots[slotid]
786 def getI2CDevice(self, slotid):
787 return self.nim_slots[slotid].getI2C()
789 def getNimListOfType(self, type, exception = -1):
790 # returns a list of indexes for NIMs compatible to the given type, except for 'exception'
792 for x in self.nim_slots:
793 if x.isCompatible(type) and x.slot != exception:
800 self.terrestrialsList = []
802 self.readTransponders()
803 InitNimManager(self) #init config stuff
805 # get a list with the friendly full description
808 for slot in self.nim_slots:
809 list.append(slot.friendly_full_description)
812 def getSlotCount(self):
813 return len(self.nim_slots)
815 def hasOutputs(self, slotid):
816 return self.nim_slots[slotid].hasOutputs()
818 def nimInternallyConnectableTo(self, slotid):
819 return self.nim_slots[slotid].internallyConnectableTo()
821 def nimRemoveInternalLink(self, slotid):
822 self.nim_slots[slotid].removeInternalLink()
824 def canConnectTo(self, slotid):
826 if self.nim_slots[slotid].internallyConnectableTo() is not None:
827 slots.append(self.nim_slots[slotid].internallyConnectableTo())
828 for type in self.nim_slots[slotid].connectableTo():
829 for slot in self.getNimListOfType(type, exception = slotid):
830 if self.hasOutputs(slot):
832 # remove nims, that have a conntectedTo reference on
833 for testnim in slots[:]:
834 for nim in self.getNimListOfType("DVB-S", slotid):
835 nimConfig = self.getNimConfig(nim)
836 if nimConfig.content.items.has_key("configMode") and nimConfig.configMode.value == "loopthrough" and int(nimConfig.connectedTo.value) == testnim:
837 slots.remove(testnim)
843 def canEqualTo(self, slotid):
844 type = self.getNimType(slotid)
847 elif type == "DVB-T2":
849 nimList = self.getNimListOfType(type, slotid)
850 for nim in nimList[:]:
851 mode = self.getNimConfig(nim)
852 if mode.configMode.value == "loopthrough" or mode.configMode.value == "satposdepends":
856 def canDependOn(self, slotid):
857 type = self.getNimType(slotid)
860 elif type == "DVB-T2":
862 nimList = self.getNimListOfType(type, slotid)
864 for nim in nimList[:]:
865 mode = self.getNimConfig(nim)
866 nimHaveRotor = mode.configMode.value == "simple" and mode.diseqcMode.value == "positioner"
867 if not nimHaveRotor and mode.configMode.value == "advanced":
868 for x in range(3601, 3605):
869 lnb = int(mode.advanced.sat[x].lnb.value)
874 for sat in mode.advanced.sat.values():
875 lnb_num = int(sat.lnb.value)
876 diseqcmode = lnb_num and mode.advanced.lnb[lnb_num].diseqcMode.value or ""
877 if diseqcmode == "1_2":
881 alreadyConnected = False
882 for testnim in nimList:
883 testmode = self.getNimConfig(testnim)
884 if testmode.configMode.value == "satposdepends" and int(testmode.connectedTo.value) == int(nim):
885 alreadyConnected = True
887 if not alreadyConnected:
888 positionerList.append(nim)
889 return positionerList
891 def getNimConfig(self, slotid):
892 return config.Nims[slotid]
894 def getSatName(self, pos):
895 for sat in self.satList:
900 def getSatList(self):
903 # returns True if something is configured to be connected to this nim
904 # if slotid == -1, returns if something is connected to ANY nim
905 def somethingConnected(self, slotid = -1):
908 for id in range(self.getSlotCount()):
909 if self.somethingConnected(id):
913 nim = config.Nims[slotid]
914 configMode = nim.configMode.value
916 if self.nim_slots[slotid].isCompatible("DVB-S") or self.nim_slots[slotid].isCompatible("DVB-T") or self.nim_slots[slotid].isCompatible("DVB-C") or self.nim_slots[slotid].isCompatible("DVB-T2"):
917 return not (configMode == "nothing")
919 def getSatListForNim(self, slotid):
921 if self.nim_slots[slotid].isCompatible("DVB-S"):
922 nim = config.Nims[slotid]
923 #print "slotid:", slotid
925 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.index]
926 #print "diseqcA:", config.Nims[slotid].diseqcA.value
927 configMode = nim.configMode.value
929 if configMode == "equal":
930 slotid = int(nim.connectedTo.value)
931 nim = config.Nims[slotid]
932 configMode = nim.configMode.value
933 elif configMode == "loopthrough":
934 slotid = self.sec.getRoot(slotid, int(nim.connectedTo.value))
935 nim = config.Nims[slotid]
936 configMode = nim.configMode.value
938 if configMode == "simple":
939 dm = nim.diseqcMode.value
940 if dm in ("single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"):
941 if nim.diseqcA.orbital_position != 3601:
942 list.append(self.satList[nim.diseqcA.index-1])
943 if dm in ("toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"):
944 if nim.diseqcB.orbital_position != 3601:
945 list.append(self.satList[nim.diseqcB.index-1])
946 if dm == "diseqc_a_b_c_d":
947 if nim.diseqcC.orbital_position != 3601:
948 list.append(self.satList[nim.diseqcC.index-1])
949 if nim.diseqcD.orbital_position != 3601:
950 list.append(self.satList[nim.diseqcD.index-1])
951 if dm == "positioner":
952 for x in self.satList:
954 elif configMode == "advanced":
955 for x in range(3601, 3605):
956 if int(nim.advanced.sat[x].lnb.value) != 0:
957 for x in self.satList:
960 for x in self.satList:
961 if int(nim.advanced.sat[x[0]].lnb.value) != 0:
965 def getRotorSatListForNim(self, slotid):
967 if self.nim_slots[slotid].isCompatible("DVB-S"):
968 #print "slotid:", slotid
969 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
970 #print "diseqcA:", config.Nims[slotid].diseqcA.value
971 configMode = config.Nims[slotid].configMode.value
972 if configMode == "simple":
973 if config.Nims[slotid].diseqcMode.value == "positioner":
974 for x in self.satList:
976 elif configMode == "advanced":
977 nim = config.Nims[slotid]
978 for x in range(3601, 3605):
979 if int(nim.advanced.sat[x].lnb.value) != 0:
980 for x in self.satList:
983 for x in self.satList:
984 lnbnum = int(nim.advanced.sat[x[0]].lnb.value)
986 lnb = nim.advanced.lnb[lnbnum]
987 if lnb.diseqcMode.value == "1_2":
992 config.sec = ConfigSubsection()
994 x = ConfigInteger(default=25, limits = (0, 9999))
995 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_CONT_TONE_DISABLE_BEFORE_DISEQC, configElement.value))
996 config.sec.delay_after_continuous_tone_disable_before_diseqc = x
998 x = ConfigInteger(default=10, limits = (0, 9999))
999 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_CONT_TONE_CHANGE, configElement.value))
1000 config.sec.delay_after_final_continuous_tone_change = x
1002 x = ConfigInteger(default=10, limits = (0, 9999))
1003 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_VOLTAGE_CHANGE, configElement.value))
1004 config.sec.delay_after_final_voltage_change = x
1006 x = ConfigInteger(default=120, limits = (0, 9999))
1007 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_DISEQC_REPEATS, configElement.value))
1008 config.sec.delay_between_diseqc_repeats = x
1010 x = ConfigInteger(default=50, limits = (0, 9999))
1011 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_LAST_DISEQC_CMD, configElement.value))
1012 config.sec.delay_after_last_diseqc_command = x
1014 x = ConfigInteger(default=50, limits = (0, 9999))
1015 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value))
1016 config.sec.delay_after_toneburst = x
1018 x = ConfigInteger(default=20, limits = (0, 9999))
1019 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS, configElement.value))
1020 config.sec.delay_after_change_voltage_before_switch_command = x
1022 x = ConfigInteger(default=200, limits = (0, 9999))
1023 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS, configElement.value))
1024 config.sec.delay_after_enable_voltage_before_switch_command = x
1026 x = ConfigInteger(default=700, limits = (0, 9999))
1027 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_SWITCH_AND_MOTOR_CMD, configElement.value))
1028 config.sec.delay_between_switch_and_motor_command = x
1030 x = ConfigInteger(default=500, limits = (0, 9999))
1031 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MEASURE_IDLE_INPUTPOWER, configElement.value))
1032 config.sec.delay_after_voltage_change_before_measure_idle_inputpower = x
1034 x = ConfigInteger(default=900, limits = (0, 9999))
1035 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_MOTOR_CMD, configElement.value))
1036 config.sec.delay_after_enable_voltage_before_motor_command = x
1038 x = ConfigInteger(default=500, limits = (0, 9999))
1039 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_MOTOR_STOP_CMD, configElement.value))
1040 config.sec.delay_after_motor_stop_command = x
1042 x = ConfigInteger(default=500, limits = (0, 9999))
1043 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MOTOR_CMD, configElement.value))
1044 config.sec.delay_after_voltage_change_before_motor_command = x
1046 x = ConfigInteger(default=70, limits = (0, 9999))
1047 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BEFORE_SEQUENCE_REPEAT, configElement.value))
1048 config.sec.delay_before_sequence_repeat = x
1050 x = ConfigInteger(default=360, limits = (0, 9999))
1051 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_RUNNING_TIMEOUT, configElement.value))
1052 config.sec.motor_running_timeout = x
1054 x = ConfigInteger(default=1, limits = (0, 5))
1055 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_COMMAND_RETRIES, configElement.value))
1056 config.sec.motor_command_retries = x
1058 x = ConfigInteger(default=50, limits = (0, 9999))
1059 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_DISEQC_RESET_CMD, configElement.value))
1060 config.sec.delay_after_diseqc_reset_cmd = x
1062 x = ConfigInteger(default=150, limits = (0, 9999))
1063 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_DISEQC_PERIPHERIAL_POWERON_CMD, configElement.value))
1064 config.sec.delay_after_diseqc_peripherial_poweron_cmd = x
1066 # TODO add support for satpos depending nims to advanced nim configuration
1067 # so a second/third/fourth cable from a motorized lnb can used behind a
1068 # diseqc 1.0 / diseqc 1.1 / toneburst switch
1069 # the C(++) part should can handle this
1070 # the configElement should be only visible when diseqc 1.2 is disabled
1072 def InitNimManager(nimmgr):
1074 addNimConfig = False
1082 config.Nims = ConfigSubList()
1083 for x in range(len(nimmgr.nim_slots)):
1084 config.Nims.append(ConfigSubsection())
1087 "universal_lnb": _("Universal LNB"),
1088 "unicable": _("Unicable"),
1089 "c_band": _("C-Band"),
1090 "user_defined": _("User defined")}
1092 lnb_choices_default = "universal_lnb"
1094 unicablelnbproducts = {}
1095 unicablematrixproducts = {}
1096 doc = xml.etree.cElementTree.parse(eEnv.resolve("${datadir}/enigma2/unicable.xml"))
1097 root = doc.getroot()
1099 entry = root.find("lnb")
1100 for manufacturer in entry.getchildren():
1102 for product in manufacturer.getchildren():
1104 lscr=("scr1","scr2","scr3","scr4","scr5","scr6","scr7","scr8")
1105 for i in range(len(lscr)):
1106 scr.append(product.get(lscr[i],"0"))
1107 for i in range(len(lscr)):
1108 if scr[len(lscr)-i-1] == "0":
1113 lof.append(int(product.get("positions",1)))
1114 lof.append(int(product.get("lofl",9750)))
1115 lof.append(int(product.get("lofh",10600)))
1116 lof.append(int(product.get("threshold",11700)))
1117 scr.append(tuple(lof))
1118 m.update({product.get("name"):tuple(scr)})
1119 unicablelnbproducts.update({manufacturer.get("name"):m})
1121 entry = root.find("matrix")
1122 for manufacturer in entry.getchildren():
1124 for product in manufacturer.getchildren():
1126 lscr=("scr1","scr2","scr3","scr4","scr5","scr6","scr7","scr8")
1127 for i in range(len(lscr)):
1128 scr.append(product.get(lscr[i],"0"))
1129 for i in range(len(lscr)):
1130 if scr[len(lscr)-i-1] == "0":
1135 lof.append(int(product.get("positions",1)))
1136 lof.append(int(product.get("lofl",9750)))
1137 lof.append(int(product.get("lofh",10600)))
1138 lof.append(int(product.get("threshold",11700)))
1139 scr.append(tuple(lof))
1140 m.update({product.get("name"):tuple(scr)})
1141 unicablematrixproducts.update({manufacturer.get("name"):m})
1143 UnicableLnbManufacturers = unicablelnbproducts.keys()
1144 UnicableLnbManufacturers.sort()
1145 UnicableMatrixManufacturers = unicablematrixproducts.keys()
1146 UnicableMatrixManufacturers.sort()
1148 unicable_choices = {
1149 "unicable_lnb": _("Unicable LNB"),
1150 "unicable_matrix": _("Unicable Martix"),
1151 "unicable_user": "Unicable "+_("User defined")}
1152 unicable_choices_default = "unicable_lnb"
1154 advanced_lnb_satcruser_choices = [ ("1", "SatCR 1"), ("2", "SatCR 2"), ("3", "SatCR 3"), ("4", "SatCR 4"),
1155 ("5", "SatCR 5"), ("6", "SatCR 6"), ("7", "SatCR 7"), ("8", "SatCR 8")]
1157 prio_list = [ ("-1", _("Auto")) ]
1158 prio_list += [(str(prio), str(prio)) for prio in range(65)+range(14000,14065)+range(19000,19065)]
1160 advanced_lnb_csw_choices = [("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))]
1161 advanced_lnb_csw_choices += [(str(0xF0|y), "Input " + str(y+1)) for y in range(0, 16)]
1163 advanced_lnb_ucsw_choices = [("0", _("None"))] + [(str(y), "Input " + str(y)) for y in range(1, 17)]
1165 diseqc_mode_choices = [
1166 ("single", _("Single")), ("toneburst_a_b", _("Toneburst A/B")),
1167 ("diseqc_a_b", _("DiSEqC A/B")), ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")),
1168 ("positioner", _("Positioner"))]
1170 positioner_mode_choices = [("usals", _("USALS")), ("manual", _("manual"))]
1172 diseqc_satlist_choices = [(3601, _('nothing connected'), 1)] + nimmgr.satList
1174 longitude_orientation_choices = [("east", _("East")), ("west", _("West"))]
1175 latitude_orientation_choices = [("north", _("North")), ("south", _("South"))]
1176 turning_speed_choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch"))]
1178 advanced_satlist_choices = nimmgr.satList + [
1179 (3601, _('All Satellites')+' 1', 1), (3602, _('All Satellites')+' 2', 1),
1180 (3603, _('All Satellites')+' 3', 1), (3604, _('All Satellites')+' 4', 1)]
1181 advanced_lnb_choices = [("0", "not available")] + [(str(y), "LNB " + str(y)) for y in range(1, 33)]
1182 advanced_voltage_choices = [("polarization", _("Polarization")), ("13V", _("13 V")), ("18V", _("18 V"))]
1183 advanced_tonemode_choices = [("band", _("Band")), ("on", _("On")), ("off", _("Off"))]
1184 advanced_lnb_toneburst_choices = [("none", _("None")), ("A", _("A")), ("B", _("B"))]
1185 advanced_lnb_allsat_diseqcmode_choices = [("1_2", _("1.2"))]
1186 advanced_lnb_diseqcmode_choices = [("none", _("None")), ("1_0", _("1.0")), ("1_1", _("1.1")), ("1_2", _("1.2"))]
1187 advanced_lnb_commandOrder1_0_choices = [("ct", "committed, toneburst"), ("tc", "toneburst, committed")]
1188 advanced_lnb_commandOrder_choices = [
1189 ("ct", "committed, toneburst"), ("tc", "toneburst, committed"),
1190 ("cut", "committed, uncommitted, toneburst"), ("tcu", "toneburst, committed, uncommitted"),
1191 ("uct", "uncommitted, committed, toneburst"), ("tuc", "toneburst, uncommitted, commmitted")]
1192 advanced_lnb_diseqc_repeat_choices = [("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))]
1193 advanced_lnb_fast_turning_btime = mktime(datetime(1970, 1, 1, 7, 0).timetuple());
1194 advanced_lnb_fast_turning_etime = mktime(datetime(1970, 1, 1, 19, 0).timetuple());
1196 def configLOFChanged(configElement):
1197 if configElement.value == "unicable":
1198 x = configElement.slot_id
1199 lnb = configElement.lnb_id
1200 nim = config.Nims[x]
1201 lnbs = nim.advanced.lnb
1203 if isinstance(section.unicable, ConfigNothing):
1205 section.unicable = ConfigSelection(unicable_choices, unicable_choices_default)
1207 section.unicable = ConfigSelection(choices = {"unicable_matrix": _("Unicable Martix"),"unicable_user": "Unicable "+_("User defined")}, default = "unicable_matrix")
1209 section.unicable = ConfigSelection(choices = {"unicable_user": _("User defined")}, default = "unicable_user")
1211 def fillUnicableConf(sectionDict, unicableproducts, vco_null_check):
1212 for y in unicableproducts:
1213 products = unicableproducts[y].keys()
1215 tmp = ConfigSubsection()
1216 tmp.product = ConfigSelection(choices = products, default = products[0])
1217 tmp.scr = ConfigSubDict()
1218 tmp.vco = ConfigSubDict()
1219 tmp.lofl = ConfigSubDict()
1220 tmp.lofh = ConfigSubDict()
1221 tmp.loft = ConfigSubDict()
1222 tmp.positions = ConfigSubDict()
1225 vcolist = unicableproducts[y][z]
1226 tmp.vco[z] = ConfigSubList()
1227 for cnt in range(1,1+len(vcolist)-1):
1228 vcofreq = int(vcolist[cnt-1])
1229 if vcofreq == 0 and vco_null_check:
1230 scrlist.append(("%d" %cnt,"SCR %d " %cnt +_("not used")))
1232 scrlist.append(("%d" %cnt,"SCR %d" %cnt))
1233 tmp.vco[z].append(ConfigInteger(default=vcofreq, limits = (vcofreq, vcofreq)))
1234 tmp.scr[z] = ConfigSelection(choices = scrlist, default = scrlist[0][0])
1236 positions = int(vcolist[len(vcolist)-1][0])
1237 tmp.positions[z] = ConfigSubList()
1238 tmp.positions[z].append(ConfigInteger(default=positions, limits = (positions, positions)))
1240 lofl = vcolist[len(vcolist)-1][1]
1241 tmp.lofl[z] = ConfigSubList()
1242 tmp.lofl[z].append(ConfigInteger(default=lofl, limits = (lofl, lofl)))
1244 lofh = int(vcolist[len(vcolist)-1][2])
1245 tmp.lofh[z] = ConfigSubList()
1246 tmp.lofh[z].append(ConfigInteger(default=lofh, limits = (lofh, lofh)))
1248 loft = int(vcolist[len(vcolist)-1][3])
1249 tmp.loft[z] = ConfigSubList()
1250 tmp.loft[z].append(ConfigInteger(default=loft, limits = (loft, loft)))
1251 sectionDict[y] = tmp
1255 section.unicableMatrix = ConfigSubDict()
1256 section.unicableMatrixManufacturer = ConfigSelection(UnicableMatrixManufacturers, UnicableMatrixManufacturers[0])
1257 fillUnicableConf(section.unicableMatrix, unicablematrixproducts, True)
1261 section.unicableLnb = ConfigSubDict()
1262 section.unicableLnbManufacturer = ConfigSelection(UnicableLnbManufacturers, UnicableLnbManufacturers[0])
1263 fillUnicableConf(section.unicableLnb, unicablelnbproducts, False)
1265 #TODO satpositions for satcruser
1266 section.satcruser = ConfigSelection(advanced_lnb_satcruser_choices, default="1")
1267 tmp = ConfigSubList()
1268 tmp.append(ConfigInteger(default=1284, limits = (950, 2150)))
1269 tmp.append(ConfigInteger(default=1400, limits = (950, 2150)))
1270 tmp.append(ConfigInteger(default=1516, limits = (950, 2150)))
1271 tmp.append(ConfigInteger(default=1632, limits = (950, 2150)))
1272 tmp.append(ConfigInteger(default=1748, limits = (950, 2150)))
1273 tmp.append(ConfigInteger(default=1864, limits = (950, 2150)))
1274 tmp.append(ConfigInteger(default=1980, limits = (950, 2150)))
1275 tmp.append(ConfigInteger(default=2096, limits = (950, 2150)))
1276 section.satcrvcouser = tmp
1278 nim.advanced.unicableconnected = ConfigYesNo(default=False)
1279 nim.advanced.unicableconnectedTo = ConfigSelection([(str(id), nimmgr.getNimDescription(id)) for id in nimmgr.getNimListOfType("DVB-S") if id != x])
1281 def configDiSEqCModeChanged(configElement):
1282 section = configElement.section
1283 if configElement.value == "1_2" and isinstance(section.longitude, ConfigNothing):
1284 section.longitude = ConfigFloat(default = [5,100], limits = [(0,359),(0,999)])
1285 section.longitudeOrientation = ConfigSelection(longitude_orientation_choices, "east")
1286 section.latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)])
1287 section.latitudeOrientation = ConfigSelection(latitude_orientation_choices, "north")
1288 section.powerMeasurement = ConfigYesNo(default=True)
1289 section.powerThreshold = ConfigInteger(default=hw.get_device_name() == "dm7025" and 50 or 15, limits=(0, 100))
1290 section.turningSpeed = ConfigSelection(turning_speed_choices, "fast")
1291 section.fastTurningBegin = ConfigDateTime(default=advanced_lnb_fast_turning_btime, formatstring = _("%H:%M"), increment = 600)
1292 section.fastTurningEnd = ConfigDateTime(default=advanced_lnb_fast_turning_etime, formatstring = _("%H:%M"), increment = 600)
1294 def configLNBChanged(configElement):
1295 x = configElement.slot_id
1296 nim = config.Nims[x]
1297 if isinstance(configElement.value, tuple):
1298 lnb = int(configElement.value[0])
1300 lnb = int(configElement.value)
1301 lnbs = nim.advanced.lnb
1302 if lnb and lnb not in lnbs:
1303 section = lnbs[lnb] = ConfigSubsection()
1304 section.lofl = ConfigInteger(default=9750, limits = (0, 99999))
1305 section.lofh = ConfigInteger(default=10600, limits = (0, 99999))
1306 section.threshold = ConfigInteger(default=11700, limits = (0, 99999))
1307 # section.output_12v = ConfigSelection(choices = [("0V", _("0 V")), ("12V", _("12 V"))], default="0V")
1308 section.increased_voltage = ConfigYesNo(False)
1309 section.toneburst = ConfigSelection(advanced_lnb_toneburst_choices, "none")
1310 section.longitude = ConfigNothing()
1312 tmp = ConfigSelection(advanced_lnb_allsat_diseqcmode_choices, "1_2")
1313 tmp.section = section
1314 configDiSEqCModeChanged(tmp)
1316 tmp = ConfigSelection(advanced_lnb_diseqcmode_choices, "none")
1317 tmp.section = section
1318 tmp.addNotifier(configDiSEqCModeChanged)
1319 section.diseqcMode = tmp
1320 section.commitedDiseqcCommand = ConfigSelection(advanced_lnb_csw_choices)
1321 section.fastDiseqc = ConfigYesNo(False)
1322 section.sequenceRepeat = ConfigYesNo(False)
1323 section.commandOrder1_0 = ConfigSelection(advanced_lnb_commandOrder1_0_choices, "ct")
1324 section.commandOrder = ConfigSelection(advanced_lnb_commandOrder_choices, "ct")
1325 section.uncommittedDiseqcCommand = ConfigSelection(advanced_lnb_ucsw_choices)
1326 section.diseqcRepeats = ConfigSelection(advanced_lnb_diseqc_repeat_choices, "none")
1327 section.prio = ConfigSelection(prio_list, "-1")
1328 section.unicable = ConfigNothing()
1329 tmp = ConfigSelection(lnb_choices, lnb_choices_default)
1332 tmp.addNotifier(configLOFChanged, initial_call = False)
1335 def configModeChanged(configMode):
1336 slot_id = configMode.slot_id
1337 nim = config.Nims[slot_id]
1338 if configMode.value == "advanced" and isinstance(nim.advanced, ConfigNothing):
1340 nim.advanced = ConfigSubsection()
1341 nim.advanced.sat = ConfigSubDict()
1342 nim.advanced.sats = getConfigSatlist(192, advanced_satlist_choices)
1343 nim.advanced.lnb = ConfigSubDict()
1344 nim.advanced.lnb[0] = ConfigNothing()
1345 for x in nimmgr.satList:
1346 tmp = ConfigSubsection()
1347 tmp.voltage = ConfigSelection(advanced_voltage_choices, "polarization")
1348 tmp.tonemode = ConfigSelection(advanced_tonemode_choices, "band")
1349 tmp.usals = ConfigYesNo(True)
1350 tmp.rotorposition = ConfigInteger(default=1, limits=(1, 255))
1351 lnb = ConfigSelection(advanced_lnb_choices, "0")
1352 lnb.slot_id = slot_id
1353 lnb.addNotifier(configLNBChanged, initial_call = False)
1355 nim.advanced.sat[x[0]] = tmp
1356 for x in range(3601, 3605):
1357 tmp = ConfigSubsection()
1358 tmp.voltage = ConfigSelection(advanced_voltage_choices, "polarization")
1359 tmp.tonemode = ConfigSelection(advanced_tonemode_choices, "band")
1360 tmp.usals = ConfigYesNo(default=True)
1361 tmp.rotorposition = ConfigInteger(default=1, limits=(1, 255))
1363 lnb = ConfigSelection([("0", "not available"), (str(lnbnum), "LNB %d"%(lnbnum))], "0")
1364 lnb.slot_id = slot_id
1365 lnb.addNotifier(configLNBChanged, initial_call = False)
1367 nim.advanced.sat[x] = tmp
1369 def toneAmplitudeChanged(configElement):
1370 fe_id = configElement.fe_id
1371 slot_id = configElement.slot_id
1372 if nimmgr.nim_slots[slot_id].description == 'Alps BSBE2':
1373 open("/proc/stb/frontend/%d/tone_amplitude" %(fe_id), "w").write(configElement.value)
1375 def tunerTypeChanged(nimmgr, configElement):
1376 fe_id = configElement.fe_id
1378 cur_type = int(open("/proc/stb/frontend/%d/mode" % (fe_id), "r").read())
1379 if cur_type != int(configElement.value):
1380 print "tunerTypeChanged feid %d from %d to mode %d" % (fe_id, cur_type, int(configElement.value))
1383 oldvalue = open("/sys/module/dvb_core/parameters/dvb_shutdown_timeout", "r").readline()
1384 open("/sys/module/dvb_core/parameters/dvb_shutdown_timeout", "w").write("0")
1386 print "[info] no /sys/module/dvb_core/parameters/dvb_shutdown_timeout available"
1388 frontend = eDVBResourceManager.getInstance().allocateRawChannel(fe_id).getFrontend()
1389 frontend.closeFrontend()
1390 open("/proc/stb/frontend/%d/mode" % (fe_id), "w").write(configElement.value)
1391 frontend.reopenFrontend()
1393 open("/sys/module/dvb_core/parameters/dvb_shutdown_timeout", "w").write(oldvalue)
1395 print "[info] no /sys/module/dvb_core/parameters/dvb_shutdown_timeout available"
1396 nimmgr.enumerateNIMs()
1398 print "tuner type is already already %d" %cur_type
1401 for slot in nimmgr.nim_slots:
1403 nim = config.Nims[x]
1404 addMultiType = False
1409 if slot.isMultiType() and addMultiType:
1411 for id in slot.getMultiTypeList().keys():
1412 type = slot.getMultiTypeList()[id]
1413 typeList.append((id, type))
1414 nim.multiType = ConfigSelection(typeList, "0")
1416 nim.multiType.fe_id = x - empty_slots
1417 nim.multiType.addNotifier(boundFunction(tunerTypeChanged, nimmgr))
1420 for slot in nimmgr.nim_slots:
1422 nim = config.Nims[x]
1424 if slot.isCompatible("DVB-S"):
1425 nim.toneAmplitude = ConfigSelection([("11", "340mV"), ("10", "360mV"), ("9", "600mV"), ("8", "700mV"), ("7", "800mV"), ("6", "900mV"), ("5", "1100mV")], "7")
1426 nim.toneAmplitude.fe_id = x - empty_slots
1427 nim.toneAmplitude.slot_id = x
1428 nim.toneAmplitude.addNotifier(toneAmplitudeChanged)
1429 nim.diseqc13V = ConfigYesNo(False)
1430 nim.diseqcMode = ConfigSelection(diseqc_mode_choices, "diseqc_a_b")
1431 nim.connectedTo = ConfigSelection([(str(id), nimmgr.getNimDescription(id)) for id in nimmgr.getNimListOfType("DVB-S") if id != x])
1432 nim.simpleSingleSendDiSEqC = ConfigYesNo(False)
1433 nim.simpleDiSEqCSetVoltageTone = ConfigYesNo(True)
1434 nim.simpleDiSEqCOnlyOnSatChange = ConfigYesNo(False)
1435 nim.diseqcA = getConfigSatlist(192, diseqc_satlist_choices)
1436 nim.diseqcB = getConfigSatlist(130, diseqc_satlist_choices)
1437 nim.diseqcC = ConfigSatlist(list = diseqc_satlist_choices)
1438 nim.diseqcD = ConfigSatlist(list = diseqc_satlist_choices)
1439 nim.positionerMode = ConfigSelection(positioner_mode_choices, "usals")
1440 nim.longitude = ConfigFloat(default=[5,100], limits=[(0,359),(0,999)])
1441 nim.longitudeOrientation = ConfigSelection(longitude_orientation_choices, "east")
1442 nim.latitude = ConfigFloat(default=[50,767], limits=[(0,359),(0,999)])
1443 nim.latitudeOrientation = ConfigSelection(latitude_orientation_choices, "north")
1444 nim.powerMeasurement = ConfigYesNo(True)
1445 nim.powerThreshold = ConfigInteger(default=hw.get_device_name() == "dm8000" and 15 or 50, limits=(0, 100))
1446 nim.turningSpeed = ConfigSelection(turning_speed_choices, "fast")
1447 btime = datetime(1970, 1, 1, 7, 0);
1448 nim.fastTurningBegin = ConfigDateTime(default = mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 900)
1449 etime = datetime(1970, 1, 1, 19, 0);
1450 nim.fastTurningEnd = ConfigDateTime(default = mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 900)
1451 config_mode_choices = [ ("nothing", _("nothing connected")),
1452 ("simple", _("simple")), ("advanced", _("advanced"))]
1453 if len(nimmgr.getNimListOfType(slot.type, exception = x)) > 0:
1454 config_mode_choices.append(("equal", _("equal to")))
1455 config_mode_choices.append(("satposdepends", _("second cable of motorized LNB")))
1456 if len(nimmgr.canConnectTo(x)) > 0:
1457 config_mode_choices.append(("loopthrough", _("loopthrough to")))
1458 nim.advanced = ConfigNothing()
1459 tmp = ConfigSelection(config_mode_choices, "nothing")
1461 tmp.addNotifier(configModeChanged, initial_call = False)
1462 nim.configMode = tmp
1463 elif slot.isCompatible("DVB-C"):
1464 nim.configMode = ConfigSelection(
1466 "enabled": _("enabled"),
1467 "nothing": _("nothing connected"),
1469 default = "enabled")
1472 for x in nimmgr.cablesList:
1473 list.append((str(n), x[0]))
1475 nim.cable = ConfigSubsection()
1476 possible_scan_types = [("bands", _("Frequency bands")), ("steps", _("Frequency steps"))]
1478 possible_scan_types.append(("provider", _("Provider")))
1479 nim.cable.scan_provider = ConfigSelection(default = "0", choices = list)
1480 nim.cable.scan_type = ConfigSelection(default = "bands", choices = possible_scan_types)
1481 nim.cable.scan_band_EU_VHF_I = ConfigYesNo(default = True)
1482 nim.cable.scan_band_EU_MID = ConfigYesNo(default = True)
1483 nim.cable.scan_band_EU_VHF_III = ConfigYesNo(default = True)
1484 nim.cable.scan_band_EU_UHF_IV = ConfigYesNo(default = True)
1485 nim.cable.scan_band_EU_UHF_V = ConfigYesNo(default = True)
1486 nim.cable.scan_band_EU_SUPER = ConfigYesNo(default = True)
1487 nim.cable.scan_band_EU_HYPER = ConfigYesNo(default = True)
1488 nim.cable.scan_band_US_LOW = ConfigYesNo(default = False)
1489 nim.cable.scan_band_US_MID = ConfigYesNo(default = False)
1490 nim.cable.scan_band_US_HIGH = ConfigYesNo(default = False)
1491 nim.cable.scan_band_US_SUPER = ConfigYesNo(default = False)
1492 nim.cable.scan_band_US_HYPER = ConfigYesNo(default = False)
1493 nim.cable.scan_frequency_steps = ConfigInteger(default = 1000, limits = (1000, 10000))
1494 nim.cable.scan_mod_qam16 = ConfigYesNo(default = False)
1495 nim.cable.scan_mod_qam32 = ConfigYesNo(default = False)
1496 nim.cable.scan_mod_qam64 = ConfigYesNo(default = True)
1497 nim.cable.scan_mod_qam128 = ConfigYesNo(default = False)
1498 nim.cable.scan_mod_qam256 = ConfigYesNo(default = True)
1499 nim.cable.scan_sr_6900 = ConfigYesNo(default = True)
1500 nim.cable.scan_sr_6875 = ConfigYesNo(default = True)
1501 nim.cable.scan_sr_ext1 = ConfigInteger(default = 0, limits = (0, 7230))
1502 nim.cable.scan_sr_ext2 = ConfigInteger(default = 0, limits = (0, 7230))
1503 elif slot.isCompatible("DVB-T"):
1504 nim.configMode = ConfigSelection(
1506 "enabled": _("enabled"),
1507 "nothing": _("nothing connected"),
1509 default = "enabled")
1512 for x in nimmgr.terrestrialsList:
1513 list.append((str(n), x[0]))
1515 nim.terrestrial = ConfigSelection(choices = list)
1516 nim.terrestrial_5V = ConfigOnOff()
1517 elif slot.isCompatible("DVB-T2"):
1518 nim.configMode = ConfigSelection(
1520 "enabled": _("enabled"),
1521 "nothing": _("nothing connected"),
1523 default = "enabled")
1526 for x in nimmgr.terrestrialsList:
1527 list.append((str(n), x[0]))
1529 nim.terrestrial = ConfigSelection(choices = list)
1530 nim.terrestrial_5V = ConfigOnOff()
1533 nim.configMode = ConfigSelection(choices = { "nothing": _("disabled") }, default="nothing");
1534 if slot.type is not None:
1535 print "pls add support for this frontend type!", slot.type
1538 nimmgr.sec = SecConfigure(nimmgr)
1540 nimmanager = NimManager()