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
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 linkNIMs(self, sec, nim1, nim2):
115 print "link tuner", nim1, "to tuner", nim2
116 sec.setTunerLinked(nim1, nim2)
118 def getRoot(self, slotid, connto):
120 while (self.NimManager.getNimConfig(connto).configMode.value in ("satposdepends", "equal", "loopthrough")):
121 connto = int(self.NimManager.getNimConfig(connto).connectedTo.value)
122 if connto in visited: # prevent endless loop
124 visited.append(connto)
128 sec = secClass.getInstance()
129 self.configuredSatellites = set()
130 sec.clear() ## this do unlinking NIMs too !!
131 print "sec config cleared"
134 self.satposdepends = { }
137 nim_slots = self.NimManager.nim_slots
141 for slot in nim_slots:
142 if slot.type is not None:
143 used_nim_slots.append((slot.slot, slot.description, slot.config.configMode.value != "nothing" and True or False, slot.isCompatible("DVB-S2")))
144 eDVBResourceManager.getInstance().setFrontendSlotInformations(used_nim_slots)
146 for slot in nim_slots:
149 if slot.isCompatible("DVB-S"):
150 # save what nim we link to/are equal to/satposdepends to.
151 # this is stored in the *value* (not index!) of the config list
152 if nim.configMode.value == "equal":
153 connto = self.getRoot(x, int(nim.connectedTo.value))
154 if not self.equal.has_key(connto):
155 self.equal[connto] = []
156 self.equal[connto].append(x)
157 elif nim.configMode.value == "loopthrough":
158 self.linkNIMs(sec, x, int(nim.connectedTo.value))
159 connto = self.getRoot(x, int(nim.connectedTo.value))
160 if not self.linked.has_key(connto):
161 self.linked[connto] = []
162 self.linked[connto].append(x)
163 elif nim.configMode.value == "satposdepends":
164 self.setSatposDepends(sec, x, int(nim.connectedTo.value))
165 connto = self.getRoot(x, int(nim.connectedTo.value))
166 if not self.satposdepends.has_key(connto):
167 self.satposdepends[connto] = []
168 self.satposdepends[connto].append(x)
170 for slot in nim_slots:
174 if slot.isCompatible("DVB-S"):
175 print "slot: " + str(x) + " configmode: " + str(nim.configMode.value)
176 if nim.configMode.value in ( "loopthrough", "satposdepends", "nothing" ):
179 sec.setSlotNotLinked(x)
180 if nim.configMode.value == "equal":
182 elif nim.configMode.value == "simple": #simple config
183 print "diseqcmode: ", nim.diseqcMode.value
184 if nim.diseqcMode.value == "single": #single
185 if nim.simpleSingleSendDiSEqC.value:
186 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA, diseqc13V = nim.diseqc13V.value)
188 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.NONE, diseqcpos = diseqcParam.SENDNO, diseqc13V = nim.diseqc13V.value)
189 elif nim.diseqcMode.value == "toneburst_a_b": #Toneburst A/B
190 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.A, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO, diseqc13V = nim.diseqc13V.value)
191 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.B, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO, diseqc13V = nim.diseqc13V.value)
192 elif nim.diseqcMode.value == "diseqc_a_b": #DiSEqC A/B
193 fastDiSEqC = nim.simpleDiSEqCOnlyOnSatChange.value
194 setVoltageTone = nim.simpleDiSEqCSetVoltageTone.value
195 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)
196 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)
197 elif nim.diseqcMode.value == "diseqc_a_b_c_d": #DiSEqC A/B/C/D
198 fastDiSEqC = nim.simpleDiSEqCOnlyOnSatChange.value
199 setVoltageTone = nim.simpleDiSEqCSetVoltageTone.value
200 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)
201 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)
202 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)
203 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)
204 elif nim.diseqcMode.value == "positioner": #Positioner
205 if nim.latitudeOrientation.value == "north":
206 laValue = rotorParam.NORTH
208 laValue = rotorParam.SOUTH
209 if nim.longitudeOrientation.value == "east":
210 loValue = rotorParam.EAST
212 loValue = rotorParam.WEST
213 inputPowerDelta=nim.powerThreshold.value
216 if nim.powerMeasurement.value:
218 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
219 if turn_speed_dict.has_key(nim.turningSpeed.value):
220 turning_speed = turn_speed_dict[nim.turningSpeed.value]
222 beg_time = localtime(nim.fastTurningBegin.value)
223 end_time = localtime(nim.fastTurningEnd.value)
224 turning_speed = ((beg_time.tm_hour+1) * 60 + beg_time.tm_min + 1) << 16
225 turning_speed |= (end_time.tm_hour+1) * 60 + end_time.tm_min + 1
226 self.addLNBSimple(sec, slotid = x, diseqcmode = 3,
227 longitude = nim.longitude.float,
228 loDirection = loValue,
229 latitude = nim.latitude.float,
230 laDirection = laValue,
231 turningSpeed = turning_speed,
232 useInputPower = useInputPower,
233 inputPowerDelta = inputPowerDelta,
234 diseqc13V = nim.diseqc13V.value)
235 elif nim.configMode.value == "advanced": #advanced config
236 self.updateAdvanced(sec, x)
237 print "sec config completed"
239 def updateAdvanced(self, sec, slotid):
241 if config.Nims[slotid].advanced.unicableconnected is not None:
242 if config.Nims[slotid].advanced.unicableconnected.value == True:
243 config.Nims[slotid].advanced.unicableconnectedTo.save_forced = True
244 self.linkNIMs(sec, slotid, int(config.Nims[slotid].advanced.unicableconnectedTo.value))
245 connto = self.getRoot(slotid, int(config.Nims[slotid].advanced.unicableconnectedTo.value))
246 if not self.linked.has_key(connto):
247 self.linked[connto] = []
248 self.linked[connto].append(slotid)
250 config.Nims[slotid].advanced.unicableconnectedTo.save_forced = False
255 for x in range(1,37):
258 #wildcard for all satellites ( for rotor )
259 for x in range(3601, 3605):
260 lnb = int(config.Nims[slotid].advanced.sat[x].lnb.value)
262 for x in self.NimManager.satList:
263 print "add", x[0], "to", lnb
264 lnbSat[lnb].append(x[0])
266 for x in self.NimManager.satList:
267 lnb = int(config.Nims[slotid].advanced.sat[x[0]].lnb.value)
269 print "add", x[0], "to", lnb
270 lnbSat[lnb].append(x[0])
272 for x in range(1,37):
273 if len(lnbSat[x]) > 0:
274 currLnb = config.Nims[slotid].advanced.lnb[x]
280 tunermask = 1 << slotid
281 if self.equal.has_key(slotid):
282 for slot in self.equal[slotid]:
283 tunermask |= (1 << slot)
284 if self.linked.has_key(slotid):
285 for slot in self.linked[slotid]:
286 tunermask |= (1 << slot)
288 if currLnb.lof.value != "unicable":
291 if currLnb.lof.value == "universal_lnb":
292 sec.setLNBLOFL(9750000)
293 sec.setLNBLOFH(10600000)
294 sec.setLNBThreshold(11700000)
295 elif currLnb.lof.value == "unicable":
296 def setupUnicable(configManufacturer, ProductDict):
297 manufacturer_name = configManufacturer.value
298 manufacturer = ProductDict[manufacturer_name]
299 product_name = manufacturer.product.value
300 sec.setLNBSatCR(manufacturer.scr[product_name].index)
301 sec.setLNBSatCRvco(manufacturer.vco[product_name][manufacturer.scr[product_name].index].value*1000)
302 sec.setLNBSatCRpositions(manufacturer.positions[product_name][0].value)
303 sec.setLNBLOFL(manufacturer.lofl[product_name][0].value * 1000)
304 sec.setLNBLOFH(manufacturer.lofh[product_name][0].value * 1000)
305 sec.setLNBThreshold(manufacturer.loft[product_name][0].value * 1000)
306 configManufacturer.save_forced = True
307 manufacturer.product.save_forced = True
308 manufacturer.vco[product_name][manufacturer.scr[product_name].index].save_forced = True
310 if currLnb.unicable.value == "unicable_user":
311 #TODO satpositions for satcruser
312 sec.setLNBLOFL(currLnb.lofl.value * 1000)
313 sec.setLNBLOFH(currLnb.lofh.value * 1000)
314 sec.setLNBThreshold(currLnb.threshold.value * 1000)
315 sec.setLNBSatCR(currLnb.satcruser.index)
316 sec.setLNBSatCRvco(currLnb.satcrvcouser[currLnb.satcruser.index].value*1000)
317 sec.setLNBSatCRpositions(1) #HACK
318 elif currLnb.unicable.value == "unicable_matrix":
319 setupUnicable(currLnb.unicableMatrixManufacturer, currLnb.unicableMatrix)
320 elif currLnb.unicable.value == "unicable_lnb":
321 setupUnicable(currLnb.unicableLnbManufacturer, currLnb.unicableLnb)
322 elif currLnb.lof.value == "c_band":
323 sec.setLNBLOFL(5150000)
324 sec.setLNBLOFH(5150000)
325 sec.setLNBThreshold(5150000)
326 elif currLnb.lof.value == "user_defined":
327 sec.setLNBLOFL(currLnb.lofl.value * 1000)
328 sec.setLNBLOFH(currLnb.lofh.value * 1000)
329 sec.setLNBThreshold(currLnb.threshold.value * 1000)
331 # if currLnb.output_12v.value == "0V":
332 # pass # nyi in drivers
333 # elif currLnb.output_12v.value == "12V":
334 # pass # nyi in drivers
336 if currLnb.increased_voltage.value:
337 sec.setLNBIncreasedVoltage(lnbParam.ON)
339 sec.setLNBIncreasedVoltage(lnbParam.OFF)
341 dm = currLnb.diseqcMode.value
343 sec.setDiSEqCMode(diseqcParam.NONE)
345 sec.setDiSEqCMode(diseqcParam.V1_0)
347 sec.setDiSEqCMode(diseqcParam.V1_1)
349 sec.setDiSEqCMode(diseqcParam.V1_2)
351 if self.satposdepends.has_key(slotid):
352 for slot in self.satposdepends[slotid]:
353 tunermask |= (1 << slot)
356 if currLnb.toneburst.value == "none":
357 sec.setToneburst(diseqcParam.NO)
358 elif currLnb.toneburst.value == "A":
359 sec.setToneburst(diseqcParam.A)
360 elif currLnb.toneburst.value == "B":
361 sec.setToneburst(diseqcParam.B)
363 # Committed Diseqc Command
364 cdc = currLnb.commitedDiseqcCommand.value
366 c = { "none": diseqcParam.SENDNO,
367 "AA": diseqcParam.AA,
368 "AB": diseqcParam.AB,
369 "BA": diseqcParam.BA,
370 "BB": diseqcParam.BB }
373 sec.setCommittedCommand(c[cdc])
375 sec.setCommittedCommand(long(cdc))
377 sec.setFastDiSEqC(currLnb.fastDiseqc.value)
379 sec.setSeqRepeat(currLnb.sequenceRepeat.value)
381 if currLnb.diseqcMode.value == "1_0":
382 currCO = currLnb.commandOrder1_0.value
384 currCO = currLnb.commandOrder.value
386 udc = int(currLnb.uncommittedDiseqcCommand.value)
388 sec.setUncommittedCommand(0xF0|(udc-1))
390 sec.setUncommittedCommand(0) # SENDNO
392 sec.setRepeats({"none": 0, "one": 1, "two": 2, "three": 3}[currLnb.diseqcRepeats.value])
394 setCommandOrder = False
396 # 0 "committed, toneburst",
397 # 1 "toneburst, committed",
398 # 2 "committed, uncommitted, toneburst",
399 # 3 "toneburst, committed, uncommitted",
400 # 4 "uncommitted, committed, toneburst"
401 # 5 "toneburst, uncommitted, commmitted"
402 order_map = {"ct": 0, "tc": 1, "cut": 2, "tcu": 3, "uct": 4, "tuc": 5}
403 sec.setCommandOrder(order_map[currCO])
406 latitude = currLnb.latitude.float
407 sec.setLatitude(latitude)
408 longitude = currLnb.longitude.float
409 sec.setLongitude(longitude)
410 if currLnb.latitudeOrientation.value == "north":
411 sec.setLaDirection(rotorParam.NORTH)
413 sec.setLaDirection(rotorParam.SOUTH)
414 if currLnb.longitudeOrientation.value == "east":
415 sec.setLoDirection(rotorParam.EAST)
417 sec.setLoDirection(rotorParam.WEST)
419 if currLnb.powerMeasurement.value:
420 sec.setUseInputpower(True)
421 sec.setInputpowerDelta(currLnb.powerThreshold.value)
422 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
423 if turn_speed_dict.has_key(currLnb.turningSpeed.value):
424 turning_speed = turn_speed_dict[currLnb.turningSpeed.value]
426 beg_time = localtime(currLnb.fastTurningBegin.value)
427 end_time = localtime(currLnb.fastTurningEnd.value)
428 turning_speed = ((beg_time.tm_hour + 1) * 60 + beg_time.tm_min + 1) << 16
429 turning_speed |= (end_time.tm_hour + 1) * 60 + end_time.tm_min + 1
430 sec.setRotorTurningSpeed(turning_speed)
432 sec.setUseInputpower(False)
434 sec.setLNBSlotMask(tunermask)
436 sec.setLNBPrio(int(currLnb.prio.value))
438 # finally add the orbital positions
440 self.addSatellite(sec, y)
442 satpos = x > 32 and (3604-(36 - x)) or y
445 currSat = config.Nims[slotid].advanced.sat[satpos]
446 if currSat.voltage.value == "polarization":
447 if config.Nims[slotid].diseqc13V.value:
448 sec.setVoltageMode(switchParam.HV_13)
450 sec.setVoltageMode(switchParam.HV)
451 elif currSat.voltage.value == "13V":
452 sec.setVoltageMode(switchParam._14V)
453 elif currSat.voltage.value == "18V":
454 sec.setVoltageMode(switchParam._18V)
456 if currSat.tonemode.value == "band":
457 sec.setToneMode(switchParam.HILO)
458 elif currSat.tonemode.value == "on":
459 sec.setToneMode(switchParam.ON)
460 elif currSat.tonemode.value == "off":
461 sec.setToneMode(switchParam.OFF)
463 if not currSat.usals.value and x < 34:
464 sec.setRotorPosNum(currSat.rotorposition.value)
466 sec.setRotorPosNum(0) #USALS
468 def __init__(self, nimmgr):
469 self.NimManager = nimmgr
470 self.configuredSatellites = set()
474 def __init__(self, slot, type, description, has_outputs = True, internally_connectable = None, multi_type = {}):
477 if type not in ("DVB-S", "DVB-C", "DVB-T", "DVB-S2", None):
478 print "warning: unknown NIM type %s, not using." % type
482 self.description = description
483 self.has_outputs = has_outputs
484 self.internally_connectable = internally_connectable
485 self.multi_type = multi_type
487 def isCompatible(self, what):
490 "DVB-S": ("DVB-S", None),
491 "DVB-C": ("DVB-C", None),
492 "DVB-T": ("DVB-T", None),
493 "DVB-S2": ("DVB-S", "DVB-S2", None)
495 return what in compatible[self.type]
500 def connectableTo(self):
502 "DVB-S": ("DVB-S", "DVB-S2"),
505 "DVB-S2": ("DVB-S", "DVB-S2")
507 return connectable[self.type]
509 def getSlotName(self):
510 # get a friendly description for a slot name.
511 # we name them "Tuner A/B/C/...", because that's what's usually written on the back
513 return _("Tuner ") + chr(ord('A') + self.slot)
515 slot_name = property(getSlotName)
518 return chr(ord('A') + self.slot)
520 def hasOutputs(self):
521 return self.has_outputs
523 def internallyConnectableTo(self):
524 return self.internally_connectable
526 def isMultiType(self):
527 return (len(self.multi_type) > 0)
529 # returns dict {<slotid>: <type>}
530 def getMultiTypeList(self):
531 return self.multi_type
533 slot_id = property(getSlotID)
535 def getFriendlyType(self):
544 friendly_type = property(getFriendlyType)
546 def getFriendlyFullDescription(self):
547 nim_text = self.slot_name + ": "
550 nim_text += _("(empty)")
552 nim_text += self.description + " (" + self.friendly_type + ")"
556 friendly_full_description = property(getFriendlyFullDescription)
557 config_mode = property(lambda self: config.Nims[self.slot].configMode.value)
558 config = property(lambda self: config.Nims[self.slot])
559 empty = property(lambda self: self.type is None)
562 def getConfiguredSats(self):
563 return self.sec.getConfiguredSats()
565 def getTransponders(self, pos):
566 if self.transponders.has_key(pos):
567 return self.transponders[pos]
571 def getTranspondersCable(self, nim):
572 nimConfig = config.Nims[nim]
573 if nimConfig.configMode.value != "nothing" and nimConfig.cable.scan_type.value == "provider":
574 return self.transponderscable[self.cablesList[nimConfig.cable.scan_provider.index][0]]
577 def getTranspondersTerrestrial(self, region):
578 return self.transpondersterrestrial[region]
580 def getCableDescription(self, nim):
581 return self.cablesList[config.Nims[nim].scan_provider.index][0]
583 def getCableFlags(self, nim):
584 return self.cablesList[config.Nims[nim].scan_provider.index][1]
586 def getTerrestrialDescription(self, nim):
587 return self.terrestrialsList[config.Nims[nim].terrestrial.index][0]
589 def getTerrestrialFlags(self, nim):
590 return self.terrestrialsList[config.Nims[nim].terrestrial.index][1]
592 def getSatDescription(self, pos):
593 return self.satellites[pos]
595 def sortFunc(self, x):
602 def readTransponders(self):
603 # read initial networks from file. we only read files which we are interested in,
604 # which means only these where a compatible tuner exists.
605 self.satellites = { }
606 self.transponders = { }
607 self.transponderscable = { }
608 self.transpondersterrestrial = { }
609 db = eDVBDB.getInstance()
610 if self.hasNimType("DVB-S"):
611 print "Reading satellites.xml"
612 db.readSatellites(self.satList, self.satellites, self.transponders)
613 self.satList.sort(key = self.sortFunc) # sort by orbpos
614 #print "SATLIST", self.satList
615 #print "SATS", self.satellites
616 #print "TRANSPONDERS", self.transponders
618 if self.hasNimType("DVB-C"):
619 print "Reading cables.xml"
620 db.readCables(self.cablesList, self.transponderscable)
621 # print "CABLIST", self.cablesList
622 # print "TRANSPONDERS", self.transponders
624 if self.hasNimType("DVB-T"):
625 print "Reading terrestrial.xml"
626 db.readTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
627 # print "TERLIST", self.terrestrialsList
628 # print "TRANSPONDERS", self.transpondersterrestrial
630 def enumerateNIMs(self):
631 # enum available NIMs. This is currently very dreambox-centric and uses the /proc/bus/nim_sockets interface.
632 # the result will be stored into nim_slots.
633 # the content of /proc/bus/nim_sockets looks like:
636 # Name: BCM4501 DVB-S2 NIM (internal)
639 # Name: BCM4501 DVB-S2 NIM (internal)
642 # Name: Philips TU1216
645 # Name: Alps BSBE1 702A
648 # Type will be either "DVB-S", "DVB-S2", "DVB-T", "DVB-C" or None.
650 # nim_slots is an array which has exactly one entry for each slot, even for empty ones.
653 nimfile = tryOpen("/proc/bus/nim_sockets")
661 for line in nimfile.readlines():
664 if line.strip().startswith("NIM Socket"):
665 parts = line.strip().split(" ")
666 current_slot = int(parts[2][:-1])
667 entries[current_slot] = {}
668 elif line.strip().startswith("Type:"):
669 entries[current_slot]["type"] = str(line.strip()[6:])
670 elif line.strip().startswith("Name:"):
671 entries[current_slot]["name"] = str(line.strip()[6:])
672 elif line.strip().startswith("Has_Outputs:"):
673 input = str(line.strip()[len("Has_Outputs:") + 1:])
674 entries[current_slot]["has_outputs"] = (input == "yes")
675 elif line.strip().startswith("Internally_Connectable:"):
676 input = int(line.strip()[len("Internally_Connectable:") + 1:])
677 entries[current_slot]["internally_connectable"] = input
678 elif line.strip().startswith("Mode"):
679 # "Mode 0: DVB-T" -> ["Mode 0", " DVB-T"]
680 split = line.strip().split(":")
681 # "Mode 0" -> ["Mode, "0"]
682 split2 = split[0].split(" ")
683 modes = entries[current_slot].get("multi_type", {})
684 modes[split2[1]] = split[1].strip()
685 entries[current_slot]["multi_type"] = modes
686 elif line.strip().startswith("empty"):
687 entries[current_slot]["type"] = None
688 entries[current_slot]["name"] = _("N/A")
691 for id, entry in entries.items():
692 if not (entry.has_key("name") and entry.has_key("type")):
693 entry["name"] = _("N/A")
695 if not (entry.has_key("has_outputs")):
696 entry["has_outputs"] = True
697 if not (entry.has_key("internally_connectable")):
698 entry["internally_connectable"] = None
699 if not (entry.has_key("multi_type")):
700 entry["multi_type"] = {}
701 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"]))
703 def hasNimType(self, chktype):
704 for slot in self.nim_slots:
705 if slot.isCompatible(chktype):
707 for type in slot.getMultiTypeList().values():
712 def getNimType(self, slotid):
713 return self.nim_slots[slotid].type
715 def getNimDescription(self, slotid):
716 return self.nim_slots[slotid].friendly_full_description
718 def getNimName(self, slotid):
719 return self.nim_slots[slotid].description
721 def getNimListOfType(self, type, exception = -1):
722 # returns a list of indexes for NIMs compatible to the given type, except for 'exception'
724 for x in self.nim_slots:
725 if x.isCompatible(type) and x.slot != exception:
732 self.terrestrialsList = []
734 self.readTransponders()
735 InitNimManager(self) #init config stuff
737 # get a list with the friendly full description
740 for slot in self.nim_slots:
741 list.append(slot.friendly_full_description)
744 def getSlotCount(self):
745 return len(self.nim_slots)
747 def hasOutputs(self, slotid):
748 return self.nim_slots[slotid].hasOutputs()
750 def canConnectTo(self, slotid):
752 if self.nim_slots[slotid].internallyConnectableTo() is not None:
753 slots.append(self.nim_slots[slotid].internallyConnectableTo())
754 for type in self.nim_slots[slotid].connectableTo():
755 for slot in self.getNimListOfType(type, exception = slotid):
756 if self.hasOutputs(slot):
758 # remove nims, that have a conntectedTo reference on
759 for testnim in slots[:]:
760 for nim in self.getNimListOfType("DVB-S", slotid):
761 nimConfig = self.getNimConfig(nim)
762 if nimConfig.content.items.has_key("configMode") and nimConfig.configMode.value == "loopthrough" and int(nimConfig.connectedTo.value) == testnim:
763 slots.remove(testnim)
769 def canEqualTo(self, slotid):
770 type = self.getNimType(slotid)
773 nimList = self.getNimListOfType(type, slotid)
774 for nim in nimList[:]:
775 mode = self.getNimConfig(nim)
776 if mode.configMode.value == "loopthrough" or mode.configMode.value == "satposdepends":
780 def canDependOn(self, slotid):
781 type = self.getNimType(slotid)
784 nimList = self.getNimListOfType(type, slotid)
786 for nim in nimList[:]:
787 mode = self.getNimConfig(nim)
788 nimHaveRotor = mode.configMode.value == "simple" and mode.diseqcMode.value == "positioner"
789 if not nimHaveRotor and mode.configMode.value == "advanced":
790 for x in range(3601, 3605):
791 lnb = int(mode.advanced.sat[x].lnb.value)
796 for sat in mode.advanced.sat.values():
797 lnb_num = int(sat.lnb.value)
798 diseqcmode = lnb_num and mode.advanced.lnb[lnb_num].diseqcMode.value or ""
799 if diseqcmode == "1_2":
803 alreadyConnected = False
804 for testnim in nimList:
805 testmode = self.getNimConfig(testnim)
806 if testmode.configMode.value == "satposdepends" and int(testmode.connectedTo.value) == int(nim):
807 alreadyConnected = True
809 if not alreadyConnected:
810 positionerList.append(nim)
811 return positionerList
813 def getNimConfig(self, slotid):
814 return config.Nims[slotid]
816 def getSatName(self, pos):
817 for sat in self.satList:
822 def getSatList(self):
825 # returns True if something is configured to be connected to this nim
826 # if slotid == -1, returns if something is connected to ANY nim
827 def somethingConnected(self, slotid = -1):
830 for id in range(self.getSlotCount()):
831 if self.somethingConnected(id):
835 nim = config.Nims[slotid]
836 configMode = nim.configMode.value
838 if self.nim_slots[slotid].isCompatible("DVB-S") or self.nim_slots[slotid].isCompatible("DVB-T") or self.nim_slots[slotid].isCompatible("DVB-C"):
839 return not (configMode == "nothing")
841 def getSatListForNim(self, slotid):
843 if self.nim_slots[slotid].isCompatible("DVB-S"):
844 nim = config.Nims[slotid]
845 #print "slotid:", slotid
847 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.index]
848 #print "diseqcA:", config.Nims[slotid].diseqcA.value
849 configMode = nim.configMode.value
851 if configMode == "equal":
852 slotid = int(nim.connectedTo.value)
853 nim = config.Nims[slotid]
854 configMode = nim.configMode.value
855 elif configMode == "loopthrough":
856 slotid = self.sec.getRoot(slotid, int(nim.connectedTo.value))
857 nim = config.Nims[slotid]
858 configMode = nim.configMode.value
860 if configMode == "simple":
861 dm = nim.diseqcMode.value
862 if dm in ("single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"):
863 if nim.diseqcA.orbital_position != 3601:
864 list.append(self.satList[nim.diseqcA.index-1])
865 if dm in ("toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"):
866 if nim.diseqcB.orbital_position != 3601:
867 list.append(self.satList[nim.diseqcB.index-1])
868 if dm == "diseqc_a_b_c_d":
869 if nim.diseqcC.orbital_position != 3601:
870 list.append(self.satList[nim.diseqcC.index-1])
871 if nim.diseqcD.orbital_position != 3601:
872 list.append(self.satList[nim.diseqcD.index-1])
873 if dm == "positioner":
874 for x in self.satList:
876 elif configMode == "advanced":
877 for x in range(3601, 3605):
878 if int(nim.advanced.sat[x].lnb.value) != 0:
879 for x in self.satList:
882 for x in self.satList:
883 if int(nim.advanced.sat[x[0]].lnb.value) != 0:
887 def getRotorSatListForNim(self, slotid):
889 if self.nim_slots[slotid].isCompatible("DVB-S"):
890 #print "slotid:", slotid
891 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
892 #print "diseqcA:", config.Nims[slotid].diseqcA.value
893 configMode = config.Nims[slotid].configMode.value
894 if configMode == "simple":
895 if config.Nims[slotid].diseqcMode.value == "positioner":
896 for x in self.satList:
898 elif configMode == "advanced":
899 nim = config.Nims[slotid]
900 for x in range(3601, 3605):
901 if int(nim.advanced.sat[x].lnb.value) != 0:
902 for x in self.satList:
905 for x in self.satList:
906 lnbnum = int(nim.advanced.sat[x[0]].lnb.value)
908 lnb = nim.advanced.lnb[lnbnum]
909 if lnb.diseqcMode.value == "1_2":
914 config.sec = ConfigSubsection()
916 x = ConfigInteger(default=25, limits = (0, 9999))
917 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_CONT_TONE_DISABLE_BEFORE_DISEQC, configElement.value))
918 config.sec.delay_after_continuous_tone_disable_before_diseqc = x
920 x = ConfigInteger(default=10, limits = (0, 9999))
921 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_CONT_TONE_CHANGE, configElement.value))
922 config.sec.delay_after_final_continuous_tone_change = x
924 x = ConfigInteger(default=10, limits = (0, 9999))
925 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_VOLTAGE_CHANGE, configElement.value))
926 config.sec.delay_after_final_voltage_change = x
928 x = ConfigInteger(default=120, limits = (0, 9999))
929 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_DISEQC_REPEATS, configElement.value))
930 config.sec.delay_between_diseqc_repeats = x
932 x = ConfigInteger(default=50, limits = (0, 9999))
933 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_LAST_DISEQC_CMD, configElement.value))
934 config.sec.delay_after_last_diseqc_command = x
936 x = ConfigInteger(default=50, limits = (0, 9999))
937 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value))
938 config.sec.delay_after_toneburst = x
940 x = ConfigInteger(default=20, limits = (0, 9999))
941 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS, configElement.value))
942 config.sec.delay_after_change_voltage_before_switch_command = x
944 x = ConfigInteger(default=200, limits = (0, 9999))
945 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS, configElement.value))
946 config.sec.delay_after_enable_voltage_before_switch_command = x
948 x = ConfigInteger(default=700, limits = (0, 9999))
949 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_SWITCH_AND_MOTOR_CMD, configElement.value))
950 config.sec.delay_between_switch_and_motor_command = x
952 x = ConfigInteger(default=500, limits = (0, 9999))
953 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MEASURE_IDLE_INPUTPOWER, configElement.value))
954 config.sec.delay_after_voltage_change_before_measure_idle_inputpower = x
956 x = ConfigInteger(default=900, limits = (0, 9999))
957 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_MOTOR_CMD, configElement.value))
958 config.sec.delay_after_enable_voltage_before_motor_command = x
960 x = ConfigInteger(default=500, limits = (0, 9999))
961 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_MOTOR_STOP_CMD, configElement.value))
962 config.sec.delay_after_motor_stop_command = x
964 x = ConfigInteger(default=500, limits = (0, 9999))
965 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MOTOR_CMD, configElement.value))
966 config.sec.delay_after_voltage_change_before_motor_command = x
968 x = ConfigInteger(default=70, limits = (0, 9999))
969 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BEFORE_SEQUENCE_REPEAT, configElement.value))
970 config.sec.delay_before_sequence_repeat = x
972 x = ConfigInteger(default=360, limits = (0, 9999))
973 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_RUNNING_TIMEOUT, configElement.value))
974 config.sec.motor_running_timeout = x
976 x = ConfigInteger(default=1, limits = (0, 5))
977 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_COMMAND_RETRIES, configElement.value))
978 config.sec.motor_command_retries = x
980 x = ConfigInteger(default=50, limits = (0, 9999))
981 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_DISEQC_RESET_CMD, configElement.value))
982 config.sec.delay_after_diseqc_reset_cmd = x
984 x = ConfigInteger(default=150, limits = (0, 9999))
985 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_DISEQC_PERIPHERIAL_POWERON_CMD, configElement.value))
986 config.sec.delay_after_diseqc_peripherial_poweron_cmd = x
988 # TODO add support for satpos depending nims to advanced nim configuration
989 # so a second/third/fourth cable from a motorized lnb can used behind a
990 # diseqc 1.0 / diseqc 1.1 / toneburst switch
991 # the C(++) part should can handle this
992 # the configElement should be only visible when diseqc 1.2 is disabled
994 def InitNimManager(nimmgr):
1004 config.Nims = ConfigSubList()
1005 for x in range(len(nimmgr.nim_slots)):
1006 config.Nims.append(ConfigSubsection())
1009 "universal_lnb": _("Universal LNB"),
1010 "unicable": _("Unicable"),
1011 "c_band": _("C-Band"),
1012 "user_defined": _("User defined")}
1014 lnb_choices_default = "universal_lnb"
1016 unicablelnbproducts = {}
1017 unicablematrixproducts = {}
1018 doc = xml.etree.cElementTree.parse("/usr/share/enigma2/unicable.xml")
1019 root = doc.getroot()
1021 entry = root.find("lnb")
1022 for manufacturer in entry.getchildren():
1024 for product in manufacturer.getchildren():
1026 lscr=("scr1","scr2","scr3","scr4","scr5","scr6","scr7","scr8")
1027 for i in range(len(lscr)):
1028 scr.append(product.get(lscr[i],"0"))
1029 for i in range(len(lscr)):
1030 if scr[len(lscr)-i-1] == "0":
1035 lof.append(int(product.get("positions",1)))
1036 lof.append(int(product.get("lofl",9750)))
1037 lof.append(int(product.get("lofh",10600)))
1038 lof.append(int(product.get("threshold",11700)))
1039 scr.append(tuple(lof))
1040 m.update({product.get("name"):tuple(scr)})
1041 unicablelnbproducts.update({manufacturer.get("name"):m})
1043 entry = root.find("matrix")
1044 for manufacturer in entry.getchildren():
1046 for product in manufacturer.getchildren():
1048 lscr=("scr1","scr2","scr3","scr4","scr5","scr6","scr7","scr8")
1049 for i in range(len(lscr)):
1050 scr.append(product.get(lscr[i],"0"))
1051 for i in range(len(lscr)):
1052 if scr[len(lscr)-i-1] == "0":
1057 lof.append(int(product.get("positions",1)))
1058 lof.append(int(product.get("lofl",9750)))
1059 lof.append(int(product.get("lofh",10600)))
1060 lof.append(int(product.get("threshold",11700)))
1061 scr.append(tuple(lof))
1062 m.update({product.get("name"):tuple(scr)})
1063 unicablematrixproducts.update({manufacturer.get("name"):m})
1065 UnicableLnbManufacturers = unicablelnbproducts.keys()
1066 UnicableLnbManufacturers.sort()
1067 UnicableMatrixManufacturers = unicablematrixproducts.keys()
1068 UnicableMatrixManufacturers.sort()
1070 unicable_choices = {
1071 "unicable_lnb": _("Unicable LNB"),
1072 "unicable_matrix": _("Unicable Martix"),
1073 "unicable_user": "Unicable "+_("User defined")}
1074 unicable_choices_default = "unicable_lnb"
1076 advanced_lnb_satcruser_choices = [ ("1", "SatCR 1"), ("2", "SatCR 2"), ("3", "SatCR 3"), ("4", "SatCR 4"),
1077 ("5", "SatCR 5"), ("6", "SatCR 6"), ("7", "SatCR 7"), ("8", "SatCR 8")]
1079 prio_list = [ ("-1", _("Auto")) ]
1080 prio_list += [(str(prio), str(prio)) for prio in range(65)+range(14000,14065)+range(19000,19065)]
1082 advanced_lnb_csw_choices = [("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))]
1083 advanced_lnb_csw_choices += [(str(0xF0|y), "Input " + str(y+1)) for y in range(0, 16)]
1085 advanced_lnb_ucsw_choices = [("0", _("None"))] + [(str(y), "Input " + str(y)) for y in range(1, 17)]
1087 diseqc_mode_choices = [
1088 ("single", _("Single")), ("toneburst_a_b", _("Toneburst A/B")),
1089 ("diseqc_a_b", _("DiSEqC A/B")), ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")),
1090 ("positioner", _("Positioner"))]
1092 positioner_mode_choices = [("usals", _("USALS")), ("manual", _("manual"))]
1094 diseqc_satlist_choices = [(3601, _('nothing connected'), 1)] + nimmgr.satList
1096 longitude_orientation_choices = [("east", _("East")), ("west", _("West"))]
1097 latitude_orientation_choices = [("north", _("North")), ("south", _("South"))]
1098 turning_speed_choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch"))]
1100 advanced_satlist_choices = nimmgr.satList + [
1101 (3601, _('All Satellites')+' 1', 1), (3602, _('All Satellites')+' 2', 1),
1102 (3603, _('All Satellites')+' 3', 1), (3604, _('All Satellites')+' 4', 1)]
1103 advanced_lnb_choices = [("0", "not available")] + [(str(y), "LNB " + str(y)) for y in range(1, 33)]
1104 advanced_voltage_choices = [("polarization", _("Polarization")), ("13V", _("13 V")), ("18V", _("18 V"))]
1105 advanced_tonemode_choices = [("band", _("Band")), ("on", _("On")), ("off", _("Off"))]
1106 advanced_lnb_toneburst_choices = [("none", _("None")), ("A", _("A")), ("B", _("B"))]
1107 advanced_lnb_allsat_diseqcmode_choices = [("1_2", _("1.2"))]
1108 advanced_lnb_diseqcmode_choices = [("none", _("None")), ("1_0", _("1.0")), ("1_1", _("1.1")), ("1_2", _("1.2"))]
1109 advanced_lnb_commandOrder1_0_choices = [("ct", "committed, toneburst"), ("tc", "toneburst, committed")]
1110 advanced_lnb_commandOrder_choices = [
1111 ("ct", "committed, toneburst"), ("tc", "toneburst, committed"),
1112 ("cut", "committed, uncommitted, toneburst"), ("tcu", "toneburst, committed, uncommitted"),
1113 ("uct", "uncommitted, committed, toneburst"), ("tuc", "toneburst, uncommitted, commmitted")]
1114 advanced_lnb_diseqc_repeat_choices = [("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))]
1115 advanced_lnb_fast_turning_btime = mktime(datetime(1970, 1, 1, 7, 0).timetuple());
1116 advanced_lnb_fast_turning_etime = mktime(datetime(1970, 1, 1, 19, 0).timetuple());
1118 def configLOFChanged(configElement):
1119 if configElement.value == "unicable":
1120 x = configElement.slot_id
1121 lnb = configElement.lnb_id
1122 nim = config.Nims[x]
1123 lnbs = nim.advanced.lnb
1125 if isinstance(section.unicable, ConfigNothing):
1127 section.unicable = ConfigSelection(unicable_choices, unicable_choices_default)
1129 section.unicable = ConfigSelection(choices = {"unicable_matrix": _("Unicable Martix"),"unicable_user": "Unicable "+_("User defined")}, default = "unicable_matrix")
1131 section.unicable = ConfigSelection(choices = {"unicable_user": _("User defined")}, default = "unicable_user")
1133 def fillUnicableConf(sectionDict, unicableproducts, vco_null_check):
1134 for y in unicableproducts:
1135 products = unicableproducts[y].keys()
1137 tmp = ConfigSubsection()
1138 tmp.product = ConfigSelection(choices = products, default = products[0])
1139 tmp.scr = ConfigSubDict()
1140 tmp.vco = ConfigSubDict()
1141 tmp.lofl = ConfigSubDict()
1142 tmp.lofh = ConfigSubDict()
1143 tmp.loft = ConfigSubDict()
1144 tmp.positions = ConfigSubDict()
1147 vcolist = unicableproducts[y][z]
1148 tmp.vco[z] = ConfigSubList()
1149 for cnt in range(1,1+len(vcolist)-1):
1150 vcofreq = int(vcolist[cnt-1])
1151 if vcofreq == 0 and vco_null_check:
1152 scrlist.append(("%d" %cnt,"SCR %d " %cnt +_("not used")))
1154 scrlist.append(("%d" %cnt,"SCR %d" %cnt))
1155 tmp.vco[z].append(ConfigInteger(default=vcofreq, limits = (vcofreq, vcofreq)))
1156 tmp.scr[z] = ConfigSelection(choices = scrlist, default = scrlist[0][0])
1158 positions = int(vcolist[len(vcolist)-1][0])
1159 tmp.positions[z] = ConfigSubList()
1160 tmp.positions[z].append(ConfigInteger(default=positions, limits = (positions, positions)))
1162 lofl = vcolist[len(vcolist)-1][1]
1163 tmp.lofl[z] = ConfigSubList()
1164 tmp.lofl[z].append(ConfigInteger(default=lofl, limits = (lofl, lofl)))
1166 lofh = int(vcolist[len(vcolist)-1][2])
1167 tmp.lofh[z] = ConfigSubList()
1168 tmp.lofh[z].append(ConfigInteger(default=lofh, limits = (lofh, lofh)))
1170 loft = int(vcolist[len(vcolist)-1][3])
1171 tmp.loft[z] = ConfigSubList()
1172 tmp.loft[z].append(ConfigInteger(default=loft, limits = (loft, loft)))
1173 sectionDict[y] = tmp
1177 section.unicableMatrix = ConfigSubDict()
1178 section.unicableMatrixManufacturer = ConfigSelection(UnicableMatrixManufacturers, UnicableMatrixManufacturers[0])
1179 fillUnicableConf(section.unicableMatrix, unicablematrixproducts, True)
1183 section.unicableLnb = ConfigSubDict()
1184 section.unicableLnbManufacturer = ConfigSelection(UnicableLnbManufacturers, UnicableLnbManufacturers[0])
1185 fillUnicableConf(section.unicableLnb, unicablelnbproducts, False)
1187 #TODO satpositions for satcruser
1188 section.satcruser = ConfigSelection(advanced_lnb_satcruser_choices, default="1")
1189 tmp = ConfigSubList()
1190 tmp.append(ConfigInteger(default=1284, limits = (950, 2150)))
1191 tmp.append(ConfigInteger(default=1400, limits = (950, 2150)))
1192 tmp.append(ConfigInteger(default=1516, limits = (950, 2150)))
1193 tmp.append(ConfigInteger(default=1632, limits = (950, 2150)))
1194 tmp.append(ConfigInteger(default=1748, limits = (950, 2150)))
1195 tmp.append(ConfigInteger(default=1864, limits = (950, 2150)))
1196 tmp.append(ConfigInteger(default=1980, limits = (950, 2150)))
1197 tmp.append(ConfigInteger(default=2096, limits = (950, 2150)))
1198 section.satcrvcouser = tmp
1200 nim.advanced.unicableconnected = ConfigYesNo(default=False)
1201 nim.advanced.unicableconnectedTo = ConfigSelection([(str(id), nimmgr.getNimDescription(id)) for id in nimmgr.getNimListOfType("DVB-S") if id != x])
1203 def configDiSEqCModeChanged(configElement):
1204 section = configElement.section
1205 if configElement.value == "1_2" and isinstance(section.longitude, ConfigNothing):
1206 section.longitude = ConfigFloat(default = [5,100], limits = [(0,359),(0,999)])
1207 section.longitudeOrientation = ConfigSelection(longitude_orientation_choices, "east")
1208 section.latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)])
1209 section.latitudeOrientation = ConfigSelection(latitude_orientation_choices, "north")
1210 section.powerMeasurement = ConfigYesNo(default=True)
1211 section.powerThreshold = ConfigInteger(default=hw.get_device_name() == "dm7025" and 50 or 15, limits=(0, 100))
1212 section.turningSpeed = ConfigSelection(turning_speed_choices, "fast")
1213 section.fastTurningBegin = ConfigDateTime(default=advanced_lnb_fast_turning_btime, formatstring = _("%H:%M"), increment = 600)
1214 section.fastTurningEnd = ConfigDateTime(default=advanced_lnb_fast_turning_etime, formatstring = _("%H:%M"), increment = 600)
1216 def configLNBChanged(configElement):
1217 x = configElement.slot_id
1218 nim = config.Nims[x]
1219 if isinstance(configElement.value, tuple):
1220 lnb = int(configElement.value[0])
1222 lnb = int(configElement.value)
1223 lnbs = nim.advanced.lnb
1224 if lnb and lnb not in lnbs:
1225 section = lnbs[lnb] = ConfigSubsection()
1226 section.lofl = ConfigInteger(default=9750, limits = (0, 99999))
1227 section.lofh = ConfigInteger(default=10600, limits = (0, 99999))
1228 section.threshold = ConfigInteger(default=11700, limits = (0, 99999))
1229 # section.output_12v = ConfigSelection(choices = [("0V", _("0 V")), ("12V", _("12 V"))], default="0V")
1230 section.increased_voltage = ConfigYesNo(False)
1231 section.toneburst = ConfigSelection(advanced_lnb_toneburst_choices, "none")
1232 section.longitude = ConfigNothing()
1234 tmp = ConfigSelection(advanced_lnb_allsat_diseqcmode_choices, "1_2")
1235 tmp.section = section
1236 configDiSEqCModeChanged(tmp)
1238 tmp = ConfigSelection(advanced_lnb_diseqcmode_choices, "none")
1239 tmp.section = section
1240 tmp.addNotifier(configDiSEqCModeChanged)
1241 section.diseqcMode = tmp
1242 section.commitedDiseqcCommand = ConfigSelection(advanced_lnb_csw_choices)
1243 section.fastDiseqc = ConfigYesNo(False)
1244 section.sequenceRepeat = ConfigYesNo(False)
1245 section.commandOrder1_0 = ConfigSelection(advanced_lnb_commandOrder1_0_choices, "ct")
1246 section.commandOrder = ConfigSelection(advanced_lnb_commandOrder_choices, "ct")
1247 section.uncommittedDiseqcCommand = ConfigSelection(advanced_lnb_ucsw_choices)
1248 section.diseqcRepeats = ConfigSelection(advanced_lnb_diseqc_repeat_choices, "none")
1249 section.prio = ConfigSelection(prio_list, "-1")
1250 section.unicable = ConfigNothing()
1251 tmp = ConfigSelection(lnb_choices, lnb_choices_default)
1254 tmp.addNotifier(configLOFChanged, initial_call = False)
1257 def configModeChanged(configMode):
1258 slot_id = configMode.slot_id
1259 nim = config.Nims[slot_id]
1260 if configMode.value == "advanced" and isinstance(nim.advanced, ConfigNothing):
1262 nim.advanced = ConfigSubsection()
1263 nim.advanced.sat = ConfigSubDict()
1264 nim.advanced.sats = getConfigSatlist(192, advanced_satlist_choices)
1265 nim.advanced.lnb = ConfigSubDict()
1266 nim.advanced.lnb[0] = ConfigNothing()
1267 for x in nimmgr.satList:
1268 tmp = ConfigSubsection()
1269 tmp.voltage = ConfigSelection(advanced_voltage_choices, "polarization")
1270 tmp.tonemode = ConfigSelection(advanced_tonemode_choices, "band")
1271 tmp.usals = ConfigYesNo(True)
1272 tmp.rotorposition = ConfigInteger(default=1, limits=(1, 255))
1273 lnb = ConfigSelection(advanced_lnb_choices, "0")
1274 lnb.slot_id = slot_id
1275 lnb.addNotifier(configLNBChanged, initial_call = False)
1277 nim.advanced.sat[x[0]] = tmp
1278 for x in range(3601, 3605):
1279 tmp = ConfigSubsection()
1280 tmp.voltage = ConfigSelection(advanced_voltage_choices, "polarization")
1281 tmp.tonemode = ConfigSelection(advanced_tonemode_choices, "band")
1282 tmp.usals = ConfigYesNo(default=True)
1283 tmp.rotorposition = ConfigInteger(default=1, limits=(1, 255))
1285 lnb = ConfigSelection([("0", "not available"), (str(lnbnum), "LNB %d"%(lnbnum))], "0")
1286 lnb.slot_id = slot_id
1287 lnb.addNotifier(configLNBChanged, initial_call = False)
1289 nim.advanced.sat[x] = tmp
1291 def toneAmplitudeChanged(configElement):
1292 fe_id = configElement.fe_id
1293 slot_id = configElement.slot_id
1294 if nimmgr.nim_slots[slot_id].description == 'Alps BSBE2':
1295 open("/proc/stb/frontend/%d/tone_amplitude" %(fe_id), "w").write(configElement.value)
1297 def tunerTypeChanged(nimmgr, configElement):
1298 fe_id = configElement.fe_id
1299 print "tunerTypeChanged feid %d to mode %s" % (fe_id, configElement.value)
1301 oldvalue = open("/sys/module/dvb_core/parameters/dvb_shutdown_timeout", "r").readline()
1302 open("/sys/module/dvb_core/parameters/dvb_shutdown_timeout", "w").write("0")
1304 print "[info] no /sys/module/dvb_core/parameters/dvb_shutdown_timeout available"
1305 frontend = eDVBResourceManager.getInstance().allocateRawChannel(fe_id).getFrontend()
1306 frontend.closeFrontend()
1307 open("/proc/stb/frontend/%d/mode" % (fe_id), "w").write(configElement.value)
1308 frontend.reopenFrontend()
1310 open("/sys/module/dvb_core/parameters/dvb_shutdown_timeout", "w").write(oldvalue)
1312 print "[info] no /sys/module/dvb_core/parameters/dvb_shutdown_timeout available"
1313 nimmgr.enumerateNIMs()
1316 for slot in nimmgr.nim_slots:
1318 nim = config.Nims[x]
1319 addMultiType = False
1324 if slot.isMultiType() and addMultiType:
1326 for id in slot.getMultiTypeList().keys():
1327 type = slot.getMultiTypeList()[id]
1328 typeList.append((id, type))
1329 nim.multiType = ConfigSelection(typeList, "0")
1331 nim.multiType.fe_id = x - empty_slots
1332 nim.multiType.addNotifier(boundFunction(tunerTypeChanged, nimmgr))
1335 for slot in nimmgr.nim_slots:
1337 nim = config.Nims[x]
1339 if slot.isCompatible("DVB-S"):
1340 nim.toneAmplitude = ConfigSelection([("11", "340mV"), ("10", "360mV"), ("9", "600mV"), ("8", "700mV"), ("7", "800mV"), ("6", "900mV"), ("5", "1100mV")], "7")
1341 nim.toneAmplitude.fe_id = x - empty_slots
1342 nim.toneAmplitude.slot_id = x
1343 nim.toneAmplitude.addNotifier(toneAmplitudeChanged)
1344 nim.diseqc13V = ConfigYesNo(False)
1345 nim.diseqcMode = ConfigSelection(diseqc_mode_choices, "diseqc_a_b")
1346 nim.connectedTo = ConfigSelection([(str(id), nimmgr.getNimDescription(id)) for id in nimmgr.getNimListOfType("DVB-S") if id != x])
1347 nim.simpleSingleSendDiSEqC = ConfigYesNo(False)
1348 nim.simpleDiSEqCSetVoltageTone = ConfigYesNo(True)
1349 nim.simpleDiSEqCOnlyOnSatChange = ConfigYesNo(False)
1350 nim.diseqcA = getConfigSatlist(192, diseqc_satlist_choices)
1351 nim.diseqcB = getConfigSatlist(130, diseqc_satlist_choices)
1352 nim.diseqcC = ConfigSatlist(list = diseqc_satlist_choices)
1353 nim.diseqcD = ConfigSatlist(list = diseqc_satlist_choices)
1354 nim.positionerMode = ConfigSelection(positioner_mode_choices, "usals")
1355 nim.longitude = ConfigFloat(default=[5,100], limits=[(0,359),(0,999)])
1356 nim.longitudeOrientation = ConfigSelection(longitude_orientation_choices, "east")
1357 nim.latitude = ConfigFloat(default=[50,767], limits=[(0,359),(0,999)])
1358 nim.latitudeOrientation = ConfigSelection(latitude_orientation_choices, "north")
1359 nim.powerMeasurement = ConfigYesNo(True)
1360 nim.powerThreshold = ConfigInteger(default=hw.get_device_name() == "dm8000" and 15 or 50, limits=(0, 100))
1361 nim.turningSpeed = ConfigSelection(turning_speed_choices, "fast")
1362 btime = datetime(1970, 1, 1, 7, 0);
1363 nim.fastTurningBegin = ConfigDateTime(default = mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 900)
1364 etime = datetime(1970, 1, 1, 19, 0);
1365 nim.fastTurningEnd = ConfigDateTime(default = mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 900)
1366 config_mode_choices = [ ("nothing", _("nothing connected")),
1367 ("simple", _("simple")), ("advanced", _("advanced"))]
1368 if len(nimmgr.getNimListOfType(slot.type, exception = x)) > 0:
1369 config_mode_choices.append(("equal", _("equal to")))
1370 config_mode_choices.append(("satposdepends", _("second cable of motorized LNB")))
1371 if len(nimmgr.canConnectTo(x)) > 0:
1372 config_mode_choices.append(("loopthrough", _("loopthrough to")))
1373 nim.advanced = ConfigNothing()
1374 tmp = ConfigSelection(config_mode_choices, "nothing")
1376 tmp.addNotifier(configModeChanged, initial_call = False)
1377 nim.configMode = tmp
1378 elif slot.isCompatible("DVB-C"):
1379 nim.configMode = ConfigSelection(
1381 "enabled": _("enabled"),
1382 "nothing": _("nothing connected"),
1384 default = "enabled")
1387 for x in nimmgr.cablesList:
1388 list.append((str(n), x[0]))
1390 nim.cable = ConfigSubsection()
1391 possible_scan_types = [("bands", _("Frequency bands")), ("steps", _("Frequency steps"))]
1393 possible_scan_types.append(("provider", _("Provider")))
1394 nim.cable.scan_provider = ConfigSelection(default = "0", choices = list)
1395 nim.cable.scan_type = ConfigSelection(default = "bands", choices = possible_scan_types)
1396 nim.cable.scan_band_EU_VHF_I = ConfigYesNo(default = True)
1397 nim.cable.scan_band_EU_MID = ConfigYesNo(default = True)
1398 nim.cable.scan_band_EU_VHF_III = ConfigYesNo(default = True)
1399 nim.cable.scan_band_EU_UHF_IV = ConfigYesNo(default = True)
1400 nim.cable.scan_band_EU_UHF_V = ConfigYesNo(default = True)
1401 nim.cable.scan_band_EU_SUPER = ConfigYesNo(default = True)
1402 nim.cable.scan_band_EU_HYPER = ConfigYesNo(default = True)
1403 nim.cable.scan_band_US_LOW = ConfigYesNo(default = False)
1404 nim.cable.scan_band_US_MID = ConfigYesNo(default = False)
1405 nim.cable.scan_band_US_HIGH = ConfigYesNo(default = False)
1406 nim.cable.scan_band_US_SUPER = ConfigYesNo(default = False)
1407 nim.cable.scan_band_US_HYPER = ConfigYesNo(default = False)
1408 nim.cable.scan_frequency_steps = ConfigInteger(default = 1000, limits = (1000, 10000))
1409 nim.cable.scan_mod_qam16 = ConfigYesNo(default = False)
1410 nim.cable.scan_mod_qam32 = ConfigYesNo(default = False)
1411 nim.cable.scan_mod_qam64 = ConfigYesNo(default = True)
1412 nim.cable.scan_mod_qam128 = ConfigYesNo(default = False)
1413 nim.cable.scan_mod_qam256 = ConfigYesNo(default = True)
1414 nim.cable.scan_sr_6900 = ConfigYesNo(default = True)
1415 nim.cable.scan_sr_6875 = ConfigYesNo(default = True)
1416 nim.cable.scan_sr_ext1 = ConfigInteger(default = 0, limits = (0, 7230))
1417 nim.cable.scan_sr_ext2 = ConfigInteger(default = 0, limits = (0, 7230))
1418 elif slot.isCompatible("DVB-T"):
1419 nim.configMode = ConfigSelection(
1421 "enabled": _("enabled"),
1422 "nothing": _("nothing connected"),
1424 default = "enabled")
1427 for x in nimmgr.terrestrialsList:
1428 list.append((str(n), x[0]))
1430 nim.terrestrial = ConfigSelection(choices = list)
1431 nim.terrestrial_5V = ConfigOnOff()
1434 nim.configMode = ConfigSelection(choices = { "nothing": _("disabled") }, default="nothing");
1435 if slot.type is not None:
1436 print "pls add support for this frontend type!", slot.type
1439 nimmgr.sec = SecConfigure(nimmgr)
1441 nimmanager = NimManager()