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 def getConfigSatlist(orbpos, satlist):
23 default_orbpos = orbpos
25 return ConfigSatlist(satlist, default_orbpos)
27 def tryOpen(filename):
29 procFile = open(filename)
35 def getConfiguredSats(self):
36 return self.configuredSatellites
38 def addSatellite(self, sec, orbpos):
39 sec.addSatellite(orbpos)
40 self.configuredSatellites.add(orbpos)
42 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):
43 if orbpos is None or orbpos == 3601:
47 tunermask = 1 << slotid
48 if self.equal.has_key(slotid):
49 for slot in self.equal[slotid]:
50 tunermask |= (1 << slot)
51 if self.linked.has_key(slotid):
52 for slot in self.linked[slotid]:
53 tunermask |= (1 << slot)
56 sec.setLNBLOFL(9750000)
57 sec.setLNBLOFH(10600000)
58 sec.setLNBThreshold(11700000)
59 sec.setLNBIncreasedVoltage(lnbParam.OFF)
61 sec.setFastDiSEqC(fastDiSEqC)
63 sec.setCommandOrder(0)
66 sec.setDiSEqCMode(diseqcmode)
67 sec.setToneburst(toneburstmode)
68 sec.setCommittedCommand(diseqcpos)
69 sec.setUncommittedCommand(0) # SENDNO
70 #print "set orbpos to:" + str(orbpos)
72 if 0 <= diseqcmode < 3:
73 self.addSatellite(sec, orbpos)
76 sec.setVoltageMode(switchParam.HV_13)
78 sec.setVoltageMode(switchParam.HV)
79 sec.setToneMode(switchParam.HILO)
81 sec.setVoltageMode(switchParam._14V)
82 sec.setToneMode(switchParam.OFF)
83 elif (diseqcmode == 3): # diseqc 1.2
84 if self.satposdepends.has_key(slotid):
85 for slot in self.satposdepends[slotid]:
86 tunermask |= (1 << slot)
87 sec.setLatitude(latitude)
88 sec.setLaDirection(laDirection)
89 sec.setLongitude(longitude)
90 sec.setLoDirection(loDirection)
91 sec.setUseInputpower(useInputPower)
92 sec.setInputpowerDelta(inputPowerDelta)
93 sec.setRotorTurningSpeed(turningSpeed)
95 for x in self.NimManager.satList:
96 print "Add sat " + str(x[0])
97 self.addSatellite(sec, int(x[0]))
99 sec.setVoltageMode(switchParam.HV_13)
101 sec.setVoltageMode(switchParam.HV)
102 sec.setToneMode(switchParam.HILO)
103 sec.setRotorPosNum(0) # USALS
105 sec.setLNBSlotMask(tunermask)
107 def setSatposDepends(self, sec, nim1, nim2):
108 print "tuner", nim1, "depends on satpos of", nim2
109 sec.setTunerDepends(nim1, nim2)
111 def linkNIMs(self, sec, nim1, nim2):
112 print "link tuner", nim1, "to tuner", nim2
113 sec.setTunerLinked(nim1, nim2)
115 def getRoot(self, slotid, connto):
117 while (self.NimManager.getNimConfig(connto).configMode.value in ("satposdepends", "equal", "loopthrough")):
118 connto = int(self.NimManager.getNimConfig(connto).connectedTo.value)
119 if connto in visited: # prevent endless loop
121 visited.append(connto)
125 sec = secClass.getInstance()
126 self.configuredSatellites = set()
127 sec.clear() ## this do unlinking NIMs too !!
128 print "sec config cleared"
131 self.satposdepends = { }
134 nim_slots = self.NimManager.nim_slots
138 for slot in nim_slots:
139 if slot.type is not None:
140 used_nim_slots.append((slot.slot, slot.description, slot.config.configMode.value != "nothing" and True or False, slot.isCompatible("DVB-S2")))
141 eDVBResourceManager.getInstance().setFrontendSlotInformations(used_nim_slots)
143 for slot in nim_slots:
146 if slot.isCompatible("DVB-S"):
147 # save what nim we link to/are equal to/satposdepends to.
148 # this is stored in the *value* (not index!) of the config list
149 if nim.configMode.value == "equal":
150 connto = self.getRoot(x, int(nim.connectedTo.value))
151 if not self.equal.has_key(connto):
152 self.equal[connto] = []
153 self.equal[connto].append(x)
154 elif nim.configMode.value == "loopthrough":
155 self.linkNIMs(sec, x, int(nim.connectedTo.value))
156 connto = self.getRoot(x, int(nim.connectedTo.value))
157 if not self.linked.has_key(connto):
158 self.linked[connto] = []
159 self.linked[connto].append(x)
160 elif nim.configMode.value == "satposdepends":
161 self.setSatposDepends(sec, x, int(nim.connectedTo.value))
162 connto = self.getRoot(x, int(nim.connectedTo.value))
163 if not self.satposdepends.has_key(connto):
164 self.satposdepends[connto] = []
165 self.satposdepends[connto].append(x)
167 for slot in nim_slots:
171 if slot.isCompatible("DVB-S"):
172 print "slot: " + str(x) + " configmode: " + str(nim.configMode.value)
173 if nim.configMode.value in ( "loopthrough", "satposdepends", "nothing" ):
176 sec.setSlotNotLinked(x)
177 if nim.configMode.value == "equal":
179 elif nim.configMode.value == "simple": #simple config
180 print "diseqcmode: ", nim.diseqcMode.value
181 if nim.diseqcMode.value == "single": #single
182 if nim.simpleSingleSendDiSEqC.value:
183 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA, diseqc13V = nim.diseqc13V.value)
185 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.NONE, diseqcpos = diseqcParam.SENDNO, diseqc13V = nim.diseqc13V.value)
186 elif nim.diseqcMode.value == "toneburst_a_b": #Toneburst A/B
187 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.A, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO, diseqc13V = nim.diseqc13V.value)
188 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.B, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO, diseqc13V = nim.diseqc13V.value)
189 elif nim.diseqcMode.value == "diseqc_a_b": #DiSEqC A/B
190 fastDiSEqC = nim.simpleDiSEqCOnlyOnSatChange.value
191 setVoltageTone = nim.simpleDiSEqCSetVoltageTone.value
192 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)
193 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)
194 elif nim.diseqcMode.value == "diseqc_a_b_c_d": #DiSEqC A/B/C/D
195 fastDiSEqC = nim.simpleDiSEqCOnlyOnSatChange.value
196 setVoltageTone = nim.simpleDiSEqCSetVoltageTone.value
197 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)
198 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)
199 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)
200 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)
201 elif nim.diseqcMode.value == "positioner": #Positioner
202 if nim.latitudeOrientation.value == "north":
203 laValue = rotorParam.NORTH
205 laValue = rotorParam.SOUTH
206 if nim.longitudeOrientation.value == "east":
207 loValue = rotorParam.EAST
209 loValue = rotorParam.WEST
210 inputPowerDelta=nim.powerThreshold.value
213 if nim.powerMeasurement.value:
215 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
216 if turn_speed_dict.has_key(nim.turningSpeed.value):
217 turning_speed = turn_speed_dict[nim.turningSpeed.value]
219 beg_time = localtime(nim.fastTurningBegin.value)
220 end_time = localtime(nim.fastTurningEnd.value)
221 turning_speed = ((beg_time.tm_hour+1) * 60 + beg_time.tm_min + 1) << 16
222 turning_speed |= (end_time.tm_hour+1) * 60 + end_time.tm_min + 1
223 self.addLNBSimple(sec, slotid = x, diseqcmode = 3,
224 longitude = nim.longitude.float,
225 loDirection = loValue,
226 latitude = nim.latitude.float,
227 laDirection = laValue,
228 turningSpeed = turning_speed,
229 useInputPower = useInputPower,
230 inputPowerDelta = inputPowerDelta,
231 diseqc13V = nim.diseqc13V.value)
232 elif nim.configMode.value == "advanced": #advanced config
233 self.updateAdvanced(sec, x)
234 print "sec config completed"
236 def updateAdvanced(self, sec, slotid):
238 for x in range(1,37):
241 #wildcard for all satellites ( for rotor )
242 for x in range(3601, 3605):
243 lnb = int(config.Nims[slotid].advanced.sat[x].lnb.value)
245 for x in self.NimManager.satList:
246 print "add", x[0], "to", lnb
247 lnbSat[lnb].append(x[0])
249 for x in self.NimManager.satList:
250 lnb = int(config.Nims[slotid].advanced.sat[x[0]].lnb.value)
252 print "add", x[0], "to", lnb
253 lnbSat[lnb].append(x[0])
255 for x in range(1,37):
256 if len(lnbSat[x]) > 0:
257 currLnb = config.Nims[slotid].advanced.lnb[x]
263 tunermask = 1 << slotid
264 if self.equal.has_key(slotid):
265 for slot in self.equal[slotid]:
266 tunermask |= (1 << slot)
267 if self.linked.has_key(slotid):
268 for slot in self.linked[slotid]:
269 tunermask |= (1 << slot)
271 if currLnb.lof.value != "unicable":
274 if currLnb.lof.value == "universal_lnb":
275 sec.setLNBLOFL(9750000)
276 sec.setLNBLOFH(10600000)
277 sec.setLNBThreshold(11700000)
278 elif currLnb.lof.value == "unicable":
279 sec.setLNBLOFL(9750000)
280 sec.setLNBLOFH(10600000)
281 sec.setLNBThreshold(11700000)
282 if currLnb.unicable.value == "unicable_user":
283 sec.setLNBSatCR(currLnb.satcruser.index)
284 sec.setLNBSatCRvco(currLnb.satcrvcouser[currLnb.satcruser.index].value*1000)
285 elif currLnb.unicable.value == "unicable_matrix":
286 manufacturer_name = currLnb.unicableMatrixManufacturer.value
287 manufacturer = currLnb.unicableMatrix[manufacturer_name]
288 product_name = manufacturer.product.value
289 sec.setLNBSatCR(manufacturer.scr[product_name].index)
290 sec.setLNBSatCRvco(manufacturer.vco[product_name][manufacturer.scr[product_name].index].value*1000)
291 elif currLnb.unicable.value == "unicable_lnb":
292 manufacturer_name = currLnb.unicableLnbManufacturer.value
293 manufacturer = currLnb.unicableLnb[manufacturer_name]
294 product_name = manufacturer.product.value
295 sec.setLNBSatCR(manufacturer.scr[product_name].index)
296 sec.setLNBSatCRvco(manufacturer.vco[product_name][manufacturer.scr[product_name].index].value*1000)
297 elif currLnb.lof.value == "c_band":
298 sec.setLNBLOFL(5150000)
299 sec.setLNBLOFH(5150000)
300 sec.setLNBThreshold(5150000)
301 elif currLnb.lof.value == "user_defined":
302 sec.setLNBLOFL(currLnb.lofl.value * 1000)
303 sec.setLNBLOFH(currLnb.lofh.value * 1000)
304 sec.setLNBThreshold(currLnb.threshold.value * 1000)
306 # if currLnb.output_12v.value == "0V":
307 # pass # nyi in drivers
308 # elif currLnb.output_12v.value == "12V":
309 # pass # nyi in drivers
311 if currLnb.increased_voltage.value:
312 sec.setLNBIncreasedVoltage(lnbParam.ON)
314 sec.setLNBIncreasedVoltage(lnbParam.OFF)
316 dm = currLnb.diseqcMode.value
318 sec.setDiSEqCMode(diseqcParam.NONE)
320 sec.setDiSEqCMode(diseqcParam.V1_0)
322 sec.setDiSEqCMode(diseqcParam.V1_1)
324 sec.setDiSEqCMode(diseqcParam.V1_2)
326 if self.satposdepends.has_key(slotid):
327 for slot in self.satposdepends[slotid]:
328 tunermask |= (1 << slot)
331 if currLnb.toneburst.value == "none":
332 sec.setToneburst(diseqcParam.NO)
333 elif currLnb.toneburst.value == "A":
334 sec.setToneburst(diseqcParam.A)
335 elif currLnb.toneburst.value == "B":
336 sec.setToneburst(diseqcParam.B)
338 # Committed Diseqc Command
339 cdc = currLnb.commitedDiseqcCommand.value
341 c = { "none": diseqcParam.SENDNO,
342 "AA": diseqcParam.AA,
343 "AB": diseqcParam.AB,
344 "BA": diseqcParam.BA,
345 "BB": diseqcParam.BB }
348 sec.setCommittedCommand(c[cdc])
350 sec.setCommittedCommand(long(cdc))
352 sec.setFastDiSEqC(currLnb.fastDiseqc.value)
354 sec.setSeqRepeat(currLnb.sequenceRepeat.value)
356 if currLnb.diseqcMode.value == "1_0":
357 currCO = currLnb.commandOrder1_0.value
359 currCO = currLnb.commandOrder.value
361 udc = int(currLnb.uncommittedDiseqcCommand.value)
363 sec.setUncommittedCommand(0xF0|(udc-1))
365 sec.setUncommittedCommand(0) # SENDNO
367 sec.setRepeats({"none": 0, "one": 1, "two": 2, "three": 3}[currLnb.diseqcRepeats.value])
369 setCommandOrder = False
371 # 0 "committed, toneburst",
372 # 1 "toneburst, committed",
373 # 2 "committed, uncommitted, toneburst",
374 # 3 "toneburst, committed, uncommitted",
375 # 4 "uncommitted, committed, toneburst"
376 # 5 "toneburst, uncommitted, commmitted"
377 order_map = {"ct": 0, "tc": 1, "cut": 2, "tcu": 3, "uct": 4, "tuc": 5}
378 sec.setCommandOrder(order_map[currCO])
381 latitude = currLnb.latitude.float
382 sec.setLatitude(latitude)
383 longitude = currLnb.longitude.float
384 sec.setLongitude(longitude)
385 if currLnb.latitudeOrientation.value == "north":
386 sec.setLaDirection(rotorParam.NORTH)
388 sec.setLaDirection(rotorParam.SOUTH)
389 if currLnb.longitudeOrientation.value == "east":
390 sec.setLoDirection(rotorParam.EAST)
392 sec.setLoDirection(rotorParam.WEST)
394 if currLnb.powerMeasurement.value:
395 sec.setUseInputpower(True)
396 sec.setInputpowerDelta(currLnb.powerThreshold.value)
397 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
398 if turn_speed_dict.has_key(currLnb.turningSpeed.value):
399 turning_speed = turn_speed_dict[currLnb.turningSpeed.value]
401 beg_time = localtime(currLnb.fastTurningBegin.value)
402 end_time = localtime(currLnb.fastTurningEnd.value)
403 turning_speed = ((beg_time.tm_hour + 1) * 60 + beg_time.tm_min + 1) << 16
404 turning_speed |= (end_time.tm_hour + 1) * 60 + end_time.tm_min + 1
405 sec.setRotorTurningSpeed(turning_speed)
407 sec.setUseInputpower(False)
409 sec.setLNBSlotMask(tunermask)
411 sec.setLNBPrio(int(currLnb.prio.value))
413 # finally add the orbital positions
415 self.addSatellite(sec, y)
417 satpos = x > 32 and (3604-(36 - x)) or y
420 currSat = config.Nims[slotid].advanced.sat[satpos]
421 if currSat.voltage.value == "polarization":
422 if config.Nims[slotid].diseqc13V.value:
423 sec.setVoltageMode(switchParam.HV_13)
425 sec.setVoltageMode(switchParam.HV)
426 elif currSat.voltage.value == "13V":
427 sec.setVoltageMode(switchParam._14V)
428 elif currSat.voltage.value == "18V":
429 sec.setVoltageMode(switchParam._18V)
431 if currSat.tonemode.value == "band":
432 sec.setToneMode(switchParam.HILO)
433 elif currSat.tonemode.value == "on":
434 sec.setToneMode(switchParam.ON)
435 elif currSat.tonemode.value == "off":
436 sec.setToneMode(switchParam.OFF)
438 if not currSat.usals.value and x < 34:
439 sec.setRotorPosNum(currSat.rotorposition.value)
441 sec.setRotorPosNum(0) #USALS
443 def __init__(self, nimmgr):
444 self.NimManager = nimmgr
445 self.configuredSatellites = set()
449 def __init__(self, slot, type, description, has_outputs = True, internally_connectable = None, multi_type = {}):
452 if type not in ("DVB-S", "DVB-C", "DVB-T", "DVB-S2", None):
453 print "warning: unknown NIM type %s, not using." % type
457 self.description = description
458 self.has_outputs = has_outputs
459 self.internally_connectable = internally_connectable
460 self.multi_type = multi_type
462 def isCompatible(self, what):
465 "DVB-S": ("DVB-S", None),
466 "DVB-C": ("DVB-C", None),
467 "DVB-T": ("DVB-T", None),
468 "DVB-S2": ("DVB-S", "DVB-S2", None)
470 return what in compatible[self.type]
475 def connectableTo(self):
477 "DVB-S": ("DVB-S", "DVB-S2"),
480 "DVB-S2": ("DVB-S", "DVB-S2")
482 return connectable[self.type]
484 def getSlotName(self):
485 # get a friendly description for a slot name.
486 # we name them "Tuner A/B/C/...", because that's what's usually written on the back
488 return _("Tuner ") + chr(ord('A') + self.slot)
490 slot_name = property(getSlotName)
493 return chr(ord('A') + self.slot)
495 def hasOutputs(self):
496 return self.has_outputs
498 def internallyConnectableTo(self):
499 return self.internally_connectable
501 def isMultiType(self):
502 return (len(self.multi_type) > 0)
504 # returns dict {<slotid>: <type>}
505 def getMultiTypeList(self):
506 return self.multi_type
508 slot_id = property(getSlotID)
510 def getFriendlyType(self):
519 friendly_type = property(getFriendlyType)
521 def getFriendlyFullDescription(self):
522 nim_text = self.slot_name + ": "
525 nim_text += _("(empty)")
527 nim_text += self.description + " (" + self.friendly_type + ")"
531 friendly_full_description = property(getFriendlyFullDescription)
532 config_mode = property(lambda self: config.Nims[self.slot].configMode.value)
533 config = property(lambda self: config.Nims[self.slot])
534 empty = property(lambda self: self.type is None)
537 def getConfiguredSats(self):
538 return self.sec.getConfiguredSats()
540 def getTransponders(self, pos):
541 if self.transponders.has_key(pos):
542 return self.transponders[pos]
546 def getTranspondersCable(self, nim):
547 nimConfig = config.Nims[nim]
548 if nimConfig.configMode.value != "nothing" and nimConfig.cable.scan_type.value == "provider":
549 return self.transponderscable[self.cablesList[nimConfig.cable.scan_provider.index][0]]
552 def getTranspondersTerrestrial(self, region):
553 return self.transpondersterrestrial[region]
555 def getCableDescription(self, nim):
556 return self.cablesList[config.Nims[nim].scan_provider.index][0]
558 def getCableFlags(self, nim):
559 return self.cablesList[config.Nims[nim].scan_provider.index][1]
561 def getTerrestrialDescription(self, nim):
562 return self.terrestrialsList[config.Nims[nim].terrestrial.index][0]
564 def getTerrestrialFlags(self, nim):
565 return self.terrestrialsList[config.Nims[nim].terrestrial.index][1]
567 def getSatDescription(self, pos):
568 return self.satellites[pos]
570 def sortFunc(self, x):
577 def readTransponders(self):
578 # read initial networks from file. we only read files which we are interested in,
579 # which means only these where a compatible tuner exists.
580 self.satellites = { }
581 self.transponders = { }
582 self.transponderscable = { }
583 self.transpondersterrestrial = { }
584 db = eDVBDB.getInstance()
585 if self.hasNimType("DVB-S"):
586 print "Reading satellites.xml"
587 db.readSatellites(self.satList, self.satellites, self.transponders)
588 self.satList.sort(key = self.sortFunc) # sort by orbpos
589 #print "SATLIST", self.satList
590 #print "SATS", self.satellites
591 #print "TRANSPONDERS", self.transponders
593 if self.hasNimType("DVB-C"):
594 print "Reading cables.xml"
595 db.readCables(self.cablesList, self.transponderscable)
596 # print "CABLIST", self.cablesList
597 # print "TRANSPONDERS", self.transponders
599 if self.hasNimType("DVB-T"):
600 print "Reading terrestrial.xml"
601 db.readTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
602 # print "TERLIST", self.terrestrialsList
603 # print "TRANSPONDERS", self.transpondersterrestrial
605 def enumerateNIMs(self):
606 # enum available NIMs. This is currently very dreambox-centric and uses the /proc/bus/nim_sockets interface.
607 # the result will be stored into nim_slots.
608 # the content of /proc/bus/nim_sockets looks like:
611 # Name: BCM4501 DVB-S2 NIM (internal)
614 # Name: BCM4501 DVB-S2 NIM (internal)
617 # Name: Philips TU1216
620 # Name: Alps BSBE1 702A
623 # Type will be either "DVB-S", "DVB-S2", "DVB-T", "DVB-C" or None.
625 # nim_slots is an array which has exactly one entry for each slot, even for empty ones.
628 nimfile = tryOpen("/proc/bus/nim_sockets")
636 for line in nimfile.readlines():
639 if line.strip().startswith("NIM Socket"):
640 parts = line.strip().split(" ")
641 current_slot = int(parts[2][:-1])
642 entries[current_slot] = {}
643 elif line.strip().startswith("Type:"):
644 entries[current_slot]["type"] = str(line.strip()[6:])
645 elif line.strip().startswith("Name:"):
646 entries[current_slot]["name"] = str(line.strip()[6:])
647 elif line.strip().startswith("Has_Outputs:"):
648 input = str(line.strip()[len("Has_Outputs:") + 1:])
649 entries[current_slot]["has_outputs"] = (input == "yes")
650 elif line.strip().startswith("Internally_Connectable:"):
651 input = int(line.strip()[len("Internally_Connectable:") + 1:])
652 entries[current_slot]["internally_connectable"] = input
653 elif line.strip().startswith("Mode"):
654 # "Mode 0: DVB-T" -> ["Mode 0", " DVB-T"]
655 split = line.strip().split(":")
656 # "Mode 0" -> ["Mode, "0"]
657 split2 = split[0].split(" ")
658 modes = entries[current_slot].get("multi_type", {})
659 modes[split2[1]] = split[1].strip()
660 entries[current_slot]["multi_type"] = modes
661 elif line.strip().startswith("empty"):
662 entries[current_slot]["type"] = None
663 entries[current_slot]["name"] = _("N/A")
666 for id, entry in entries.items():
667 if not (entry.has_key("name") and entry.has_key("type")):
668 entry["name"] = _("N/A")
670 if not (entry.has_key("has_outputs")):
671 entry["has_outputs"] = True
672 if not (entry.has_key("internally_connectable")):
673 entry["internally_connectable"] = None
674 if not (entry.has_key("multi_type")):
675 entry["multi_type"] = {}
676 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"]))
678 def hasNimType(self, chktype):
679 for slot in self.nim_slots:
680 if slot.isCompatible(chktype):
682 for type in slot.getMultiTypeList().values():
687 def getNimType(self, slotid):
688 return self.nim_slots[slotid].type
690 def getNimDescription(self, slotid):
691 return self.nim_slots[slotid].friendly_full_description
693 def getNimName(self, slotid):
694 return self.nim_slots[slotid].description
696 def getNimListOfType(self, type, exception = -1):
697 # returns a list of indexes for NIMs compatible to the given type, except for 'exception'
699 for x in self.nim_slots:
700 if x.isCompatible(type) and x.slot != exception:
707 self.terrestrialsList = []
709 self.readTransponders()
710 InitNimManager(self) #init config stuff
712 # get a list with the friendly full description
715 for slot in self.nim_slots:
716 list.append(slot.friendly_full_description)
719 def getSlotCount(self):
720 return len(self.nim_slots)
722 def hasOutputs(self, slotid):
723 return self.nim_slots[slotid].hasOutputs()
725 def canConnectTo(self, slotid):
727 if self.nim_slots[slotid].internallyConnectableTo() is not None:
728 slots.append(self.nim_slots[slotid].internallyConnectableTo())
729 for type in self.nim_slots[slotid].connectableTo():
730 for slot in self.getNimListOfType(type, exception = slotid):
731 if self.hasOutputs(slot):
733 # remove nims, that have a conntectedTo reference on
734 for testnim in slots[:]:
735 for nim in self.getNimListOfType("DVB-S", slotid):
736 nimConfig = self.getNimConfig(nim)
737 if nimConfig.content.items.has_key("configMode") and nimConfig.configMode.value == "loopthrough" and int(nimConfig.connectedTo.value) == testnim:
738 slots.remove(testnim)
744 def canEqualTo(self, slotid):
745 type = self.getNimType(slotid)
748 nimList = self.getNimListOfType(type, slotid)
749 for nim in nimList[:]:
750 mode = self.getNimConfig(nim)
751 if mode.configMode.value == "loopthrough" or mode.configMode.value == "satposdepends":
755 def canDependOn(self, slotid):
756 type = self.getNimType(slotid)
759 nimList = self.getNimListOfType(type, slotid)
761 for nim in nimList[:]:
762 mode = self.getNimConfig(nim)
763 nimHaveRotor = mode.configMode.value == "simple" and mode.diseqcMode.value == "positioner"
764 if not nimHaveRotor and mode.configMode.value == "advanced":
765 for x in range(3601, 3605):
766 lnb = int(mode.advanced.sat[x].lnb.value)
771 for sat in mode.advanced.sat.values():
772 lnb_num = int(sat.lnb.value)
773 diseqcmode = lnb_num and mode.advanced.lnb[lnb_num].diseqcMode.value or ""
774 if diseqcmode == "1_2":
778 alreadyConnected = False
779 for testnim in nimList:
780 testmode = self.getNimConfig(testnim)
781 if testmode.configMode.value == "satposdepends" and int(testmode.connectedTo.value) == int(nim):
782 alreadyConnected = True
784 if not alreadyConnected:
785 positionerList.append(nim)
786 return positionerList
788 def getNimConfig(self, slotid):
789 return config.Nims[slotid]
791 def getSatName(self, pos):
792 for sat in self.satList:
797 def getSatList(self):
800 # returns True if something is configured to be connected to this nim
801 # if slotid == -1, returns if something is connected to ANY nim
802 def somethingConnected(self, slotid = -1):
805 for id in range(self.getSlotCount()):
806 if self.somethingConnected(id):
810 nim = config.Nims[slotid]
811 configMode = nim.configMode.value
813 if self.nim_slots[slotid].isCompatible("DVB-S") or self.nim_slots[slotid].isCompatible("DVB-T") or self.nim_slots[slotid].isCompatible("DVB-C"):
814 return not (configMode == "nothing")
816 def getSatListForNim(self, slotid):
818 if self.nim_slots[slotid].isCompatible("DVB-S"):
819 nim = config.Nims[slotid]
820 #print "slotid:", slotid
822 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.index]
823 #print "diseqcA:", config.Nims[slotid].diseqcA.value
824 configMode = nim.configMode.value
826 if configMode == "equal":
827 slotid = int(nim.connectedTo.value)
828 nim = config.Nims[slotid]
829 configMode = nim.configMode.value
830 elif configMode == "loopthrough":
831 slotid = self.sec.getRoot(slotid, int(nim.connectedTo.value))
832 nim = config.Nims[slotid]
833 configMode = nim.configMode.value
835 if configMode == "simple":
836 dm = nim.diseqcMode.value
837 if dm in ("single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"):
838 if nim.diseqcA.orbital_position != 3601:
839 list.append(self.satList[nim.diseqcA.index-1])
840 if dm in ("toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"):
841 if nim.diseqcB.orbital_position != 3601:
842 list.append(self.satList[nim.diseqcB.index-1])
843 if dm == "diseqc_a_b_c_d":
844 if nim.diseqcC.orbital_position != 3601:
845 list.append(self.satList[nim.diseqcC.index-1])
846 if nim.diseqcD.orbital_position != 3601:
847 list.append(self.satList[nim.diseqcD.index-1])
848 if dm == "positioner":
849 for x in self.satList:
851 elif configMode == "advanced":
852 for x in range(3601, 3605):
853 if int(nim.advanced.sat[x].lnb.value) != 0:
854 for x in self.satList:
857 for x in self.satList:
858 if int(nim.advanced.sat[x[0]].lnb.value) != 0:
862 def getRotorSatListForNim(self, slotid):
864 if self.nim_slots[slotid].isCompatible("DVB-S"):
865 #print "slotid:", slotid
866 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
867 #print "diseqcA:", config.Nims[slotid].diseqcA.value
868 configMode = config.Nims[slotid].configMode.value
869 if configMode == "simple":
870 if config.Nims[slotid].diseqcMode.value == "positioner":
871 for x in self.satList:
873 elif configMode == "advanced":
874 nim = config.Nims[slotid]
875 for x in range(3601, 3605):
876 if int(nim.advanced.sat[x].lnb.value) != 0:
877 for x in self.satList:
880 for x in self.satList:
881 lnbnum = int(nim.advanced.sat[x[0]].lnb.value)
883 lnb = nim.advanced.lnb[lnbnum]
884 if lnb.diseqcMode.value == "1_2":
889 config.sec = ConfigSubsection()
891 x = ConfigInteger(default=25, limits = (0, 9999))
892 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_CONT_TONE_DISABLE_BEFORE_DISEQC, configElement.value))
893 config.sec.delay_after_continuous_tone_disable_before_diseqc = x
895 x = ConfigInteger(default=10, limits = (0, 9999))
896 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_CONT_TONE_CHANGE, configElement.value))
897 config.sec.delay_after_final_continuous_tone_change = x
899 x = ConfigInteger(default=10, limits = (0, 9999))
900 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_VOLTAGE_CHANGE, configElement.value))
901 config.sec.delay_after_final_voltage_change = x
903 x = ConfigInteger(default=120, limits = (0, 9999))
904 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_DISEQC_REPEATS, configElement.value))
905 config.sec.delay_between_diseqc_repeats = x
907 x = ConfigInteger(default=50, limits = (0, 9999))
908 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_LAST_DISEQC_CMD, configElement.value))
909 config.sec.delay_after_last_diseqc_command = x
911 x = ConfigInteger(default=50, limits = (0, 9999))
912 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value))
913 config.sec.delay_after_toneburst = x
915 x = ConfigInteger(default=20, limits = (0, 9999))
916 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS, configElement.value))
917 config.sec.delay_after_change_voltage_before_switch_command = x
919 x = ConfigInteger(default=200, limits = (0, 9999))
920 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS, configElement.value))
921 config.sec.delay_after_enable_voltage_before_switch_command = x
923 x = ConfigInteger(default=700, limits = (0, 9999))
924 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_SWITCH_AND_MOTOR_CMD, configElement.value))
925 config.sec.delay_between_switch_and_motor_command = x
927 x = ConfigInteger(default=500, limits = (0, 9999))
928 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MEASURE_IDLE_INPUTPOWER, configElement.value))
929 config.sec.delay_after_voltage_change_before_measure_idle_inputpower = x
931 x = ConfigInteger(default=900, limits = (0, 9999))
932 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_MOTOR_CMD, configElement.value))
933 config.sec.delay_after_enable_voltage_before_motor_command = x
935 x = ConfigInteger(default=500, limits = (0, 9999))
936 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_MOTOR_STOP_CMD, configElement.value))
937 config.sec.delay_after_motor_stop_command = x
939 x = ConfigInteger(default=500, limits = (0, 9999))
940 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MOTOR_CMD, configElement.value))
941 config.sec.delay_after_voltage_change_before_motor_command = x
943 x = ConfigInteger(default=70, limits = (0, 9999))
944 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BEFORE_SEQUENCE_REPEAT, configElement.value))
945 config.sec.delay_before_sequence_repeat = x
947 x = ConfigInteger(default=360, limits = (0, 9999))
948 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_RUNNING_TIMEOUT, configElement.value))
949 config.sec.motor_running_timeout = x
951 x = ConfigInteger(default=1, limits = (0, 5))
952 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_COMMAND_RETRIES, configElement.value))
953 config.sec.motor_command_retries = x
955 x = ConfigInteger(default=50, limits = (0, 9999))
956 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_DISEQC_RESET_CMD, configElement.value))
957 config.sec.delay_after_diseqc_reset_cmd = x
959 x = ConfigInteger(default=150, limits = (0, 9999))
960 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_DISEQC_PERIPHERIAL_POWERON_CMD, configElement.value))
961 config.sec.delay_after_diseqc_peripherial_poweron_cmd = x
963 # TODO add support for satpos depending nims to advanced nim configuration
964 # so a second/third/fourth cable from a motorized lnb can used behind a
965 # diseqc 1.0 / diseqc 1.1 / toneburst switch
966 # the C(++) part should can handle this
967 # the configElement should be only visible when diseqc 1.2 is disabled
969 def InitNimManager(nimmgr):
979 config.Nims = ConfigSubList()
980 for x in range(len(nimmgr.nim_slots)):
981 config.Nims.append(ConfigSubsection())
984 "universal_lnb": _("Universal LNB"),
985 # "unicable": _("Unicable"),
986 "c_band": _("C-Band"),
987 "user_defined": _("User defined")}
989 lnb_choices_default = "universal_lnb"
991 unicablelnbproducts = {
992 "Humax": {"150 SCR":("1210","1420","1680","2040")},
993 "Inverto": {"IDLP-40UNIQD+S":("1680","1420","2040","1210")},
994 "Kathrein": {"UAS481":("1400","1516","1632","1748")},
995 "Kreiling": {"KR1440":("1680","1420","2040","1210")},
996 "Radix": {"Unicable LNB":("1680","1420","2040","1210")},
997 "Wisi": {"OC 05":("1210","1420","1680","2040")}}
998 UnicableLnbManufacturers = unicablelnbproducts.keys()
999 UnicableLnbManufacturers.sort()
1001 unicablematrixproducts = {
1003 "UCS 51440":("1400","1632","1284","1516"),
1004 "UCS 51820":("1400","1632","1284","1516","1864","2096","1748","1980"),
1005 "UCS 51840":("1400","1632","1284","1516","1864","2096","1748","1980"),
1006 "UCS 52240":("1400","1632"),
1007 "UCS 52420":("1400","1632","1284","1516"),
1008 "UCS 52440":("1400","1632","1284","1516"),
1009 "UCS 91440":("1400","1632","1284","1516"),
1010 "UCS 91820":("1400","1632","1284","1516","1864","2096","1748","1980"),
1011 "UCS 91840":("1400","1632","1284","1516","1864","2096","1748","1980"),
1012 "UCS 92240":("1400","1632"),
1013 "UCS 92420":("1400","1632","1284","1516"),
1014 "UCS 92440":("1400","1632","1284","1516")},
1016 "SUM518":("1284","1400","1516","1632","1748","1864","1980","2096"),
1017 "SUM918":("1284","1400","1516","1632","1748","1864","1980","2096"),
1018 "SUM928":("1284","1400","1516","1632","1748","1864","1980","2096")},
1020 "IDLP-UST11O-CUO1O-8PP":("1076","1178","1280","1382","1484","1586","1688","1790")},
1022 "EXR501":("1400","1516","1632","1748"),
1023 "EXR551":("1400","1516","1632","1748"),
1024 "EXR552":("1400","1516")},
1026 "EKL2/1":("1400","1516"),
1027 "EKL2/1E":("0","0","1632","1748")},
1029 "DPA 51":("1284","1400","1516","1632","1748","1864","1980","2096")},
1031 "TechniRouter 5/1x8 G":("1284","1400","1516","1632","1748","1864","1980","2096"),
1032 "TechniRouter 5/1x8 K":("1284","1400","1516","1632","1748","1864","1980","2096"),
1033 "TechniRouter 5/2x4 G":("1284","1400","1516","1632"),
1034 "TechniRouter 5/2x4 K":("1284","1400","1516","1632")},
1036 "SCR 5/1x8 G":("1284","1400","1516","1632","1748","1864","1980","2096"),
1037 "SCR 5/1x8 K":("1284","1400","1516","1632","1748","1864","1980","2096"),
1038 "SCR 5/2x4 G":("1284","1400","1516","1632"),
1039 "SCR 5/2x4 K":("1284","1400","1516","1632")}}
1040 UnicableMatrixManufacturers = unicablematrixproducts.keys()
1041 UnicableMatrixManufacturers.sort()
1043 unicable_choices = {
1044 "unicable_lnb": _("Unicable LNB"),
1045 "unicable_matrix": _("Unicable Martix"),
1046 "unicable_user": "Unicable "+_("User defined")}
1047 unicable_choices_default = "unicable_lnb"
1049 advanced_lnb_satcruser_choices = [ ("1", "SatCR 1"), ("2", "SatCR 2"), ("3", "SatCR 3"), ("4", "SatCR 4"),
1050 ("5", "SatCR 5"), ("6", "SatCR 6"), ("7", "SatCR 7"), ("8", "SatCR 8")]
1052 prio_list = [ ("-1", _("Auto")) ]
1053 prio_list += [(str(prio), str(prio)) for prio in range(65)+range(14000,14065)+range(19000,19065)]
1055 advanced_lnb_csw_choices = [("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))]
1056 advanced_lnb_csw_choices += [(str(0xF0|y), "Input " + str(y+1)) for y in range(0, 16)]
1058 advanced_lnb_ucsw_choices = [("0", _("None"))] + [(str(y), "Input " + str(y)) for y in range(1, 17)]
1060 diseqc_mode_choices = [
1061 ("single", _("Single")), ("toneburst_a_b", _("Toneburst A/B")),
1062 ("diseqc_a_b", _("DiSEqC A/B")), ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")),
1063 ("positioner", _("Positioner"))]
1065 positioner_mode_choices = [("usals", _("USALS")), ("manual", _("manual"))]
1067 diseqc_satlist_choices = [(3601, _('nothing connected'), 1)] + nimmgr.satList
1069 longitude_orientation_choices = [("east", _("East")), ("west", _("West"))]
1070 latitude_orientation_choices = [("north", _("North")), ("south", _("South"))]
1071 turning_speed_choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch"))]
1073 advanced_satlist_choices = nimmgr.satList + [
1074 (3601, _('All Satellites')+' 1', 1), (3602, _('All Satellites')+' 2', 1),
1075 (3603, _('All Satellites')+' 3', 1), (3604, _('All Satellites')+' 4', 1)]
1076 advanced_lnb_choices = [("0", "not available")] + [(str(y), "LNB " + str(y)) for y in range(1, 33)]
1077 advanced_voltage_choices = [("polarization", _("Polarization")), ("13V", _("13 V")), ("18V", _("18 V"))]
1078 advanced_tonemode_choices = [("band", _("Band")), ("on", _("On")), ("off", _("Off"))]
1079 advanced_lnb_toneburst_choices = [("none", _("None")), ("A", _("A")), ("B", _("B"))]
1080 advanced_lnb_allsat_diseqcmode_choices = [("1_2", _("1.2"))]
1081 advanced_lnb_diseqcmode_choices = [("none", _("None")), ("1_0", _("1.0")), ("1_1", _("1.1")), ("1_2", _("1.2"))]
1082 advanced_lnb_commandOrder1_0_choices = [("ct", "committed, toneburst"), ("tc", "toneburst, committed")]
1083 advanced_lnb_commandOrder_choices = [
1084 ("ct", "committed, toneburst"), ("tc", "toneburst, committed"),
1085 ("cut", "committed, uncommitted, toneburst"), ("tcu", "toneburst, committed, uncommitted"),
1086 ("uct", "uncommitted, committed, toneburst"), ("tuc", "toneburst, uncommitted, commmitted")]
1087 advanced_lnb_diseqc_repeat_choices = [("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))]
1088 advanced_lnb_fast_turning_btime = mktime(datetime(1970, 1, 1, 7, 0).timetuple());
1089 advanced_lnb_fast_turning_etime = mktime(datetime(1970, 1, 1, 19, 0).timetuple());
1091 def configLOFChanged(configElement):
1092 if configElement.value == "unicable":
1093 x = configElement.slot_id
1094 lnb = configElement.lnb_id
1095 nim = config.Nims[x]
1096 lnbs = nim.advanced.lnb
1098 if isinstance(section.unicable, ConfigNothing):
1100 section.unicable = ConfigSelection(unicable_choices, unicable_choices_default)
1102 section.unicable = ConfigSelection(choices = {"unicable_matrix": _("Unicable Martix"),"unicable_user": "Unicable "+_("User defined")}, default = "unicable_matrix")
1104 section.unicable = ConfigSelection(choices = {"unicable_user": _("User defined")}, default = "unicable_user")
1107 section.unicableMatrix = ConfigSubDict()
1108 section.unicableMatrixManufacturer = ConfigSelection(choices = UnicableMatrixManufacturers, default = UnicableMatrixManufacturers[0])
1109 for y in unicablematrixproducts:
1110 products = unicablematrixproducts[y].keys()
1112 tmp = ConfigSubsection()
1113 tmp.product = ConfigSelection(choices = products, default = products[0])
1114 tmp.scr = ConfigSubDict()
1115 tmp.vco = ConfigSubDict()
1118 vcolist = unicablematrixproducts[y][z]
1119 tmp.vco[z] = ConfigSubList()
1120 for cnt in range(1,1+len(vcolist)):
1121 vcofreq = int(vcolist[cnt-1])
1123 scrlist.append(("%d" %cnt,"SCR %d " %cnt +_("not used")))
1125 scrlist.append(("%d" %cnt,"SCR %d" %cnt))
1126 tmp.vco[z].append(ConfigInteger(default=vcofreq, limits = (vcofreq, vcofreq)))
1127 tmp.scr[z] = ConfigSelection(choices = scrlist, default = scrlist[0][0])
1128 section.unicableMatrix[y] = tmp
1131 section.unicableLnb = ConfigSubDict()
1132 section.unicableLnbManufacturer = ConfigSelection(UnicableLnbManufacturers, UnicableLnbManufacturers[0])
1133 for y in unicablelnbproducts:
1134 products = unicablelnbproducts[y].keys()
1136 tmp = ConfigSubsection()
1137 tmp.product = ConfigSelection(choices = products, default = products[0])
1138 tmp.scr = ConfigSubDict()
1139 tmp.vco = ConfigSubDict()
1142 vcolist = unicablelnbproducts[y][z]
1143 tmp.vco[z] = ConfigSubList()
1144 for cnt in range(1,1+len(vcolist)):
1145 scrlist.append(("%d" %cnt,"SCR %d" %cnt))
1146 vcofreq = int(vcolist[cnt-1])
1147 tmp.vco[z].append(ConfigInteger(default=vcofreq, limits = (vcofreq, vcofreq)))
1148 tmp.scr[z] = ConfigSelection(choices = scrlist, default = scrlist[0][0])
1149 section.unicableLnb[y] = tmp
1151 section.satcruser = ConfigSelection(advanced_lnb_satcruser_choices, default="1")
1152 tmp = ConfigSubList()
1153 tmp.append(ConfigInteger(default=1284, limits = (0, 9999)))
1154 tmp.append(ConfigInteger(default=1400, limits = (0, 9999)))
1155 tmp.append(ConfigInteger(default=1516, limits = (0, 9999)))
1156 tmp.append(ConfigInteger(default=1632, limits = (0, 9999)))
1157 tmp.append(ConfigInteger(default=1748, limits = (0, 9999)))
1158 tmp.append(ConfigInteger(default=1864, limits = (0, 9999)))
1159 tmp.append(ConfigInteger(default=1980, limits = (0, 9999)))
1160 tmp.append(ConfigInteger(default=2096, limits = (0, 9999)))
1161 section.satcrvcouser = tmp
1163 def configDiSEqCModeChanged(configElement):
1164 section = configElement.section
1165 if configElement.value == "1_2" and isinstance(section.longitude, ConfigNothing):
1166 section.longitude = ConfigFloat(default = [5,100], limits = [(0,359),(0,999)])
1167 section.longitudeOrientation = ConfigSelection(longitude_orientation_choices, "east")
1168 section.latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)])
1169 section.latitudeOrientation = ConfigSelection(latitude_orientation_choices, "north")
1170 section.powerMeasurement = ConfigYesNo(default=True)
1171 section.powerThreshold = ConfigInteger(default=hw.get_device_name() == "dm8000" and 15 or 50, limits=(0, 100))
1172 section.turningSpeed = ConfigSelection(turning_speed_choices, "fast")
1173 section.fastTurningBegin = ConfigDateTime(default=advanced_lnb_fast_turning_btime, formatstring = _("%H:%M"), increment = 600)
1174 section.fastTurningEnd = ConfigDateTime(default=advanced_lnb_fast_turning_etime, formatstring = _("%H:%M"), increment = 600)
1176 def configLNBChanged(configElement):
1177 x = configElement.slot_id
1178 nim = config.Nims[x]
1179 if isinstance(configElement.value, tuple):
1180 lnb = int(configElement.value[0])
1182 lnb = int(configElement.value)
1183 lnbs = nim.advanced.lnb
1184 if lnb and lnb not in lnbs:
1185 section = lnbs[lnb] = ConfigSubsection()
1186 section.lofl = ConfigInteger(default=9750, limits = (0, 99999))
1187 section.lofh = ConfigInteger(default=10600, limits = (0, 99999))
1188 section.threshold = ConfigInteger(default=11700, limits = (0, 99999))
1189 # section.output_12v = ConfigSelection(choices = [("0V", _("0 V")), ("12V", _("12 V"))], default="0V")
1190 section.increased_voltage = ConfigYesNo(False)
1191 section.toneburst = ConfigSelection(advanced_lnb_toneburst_choices, "none")
1192 section.longitude = ConfigNothing()
1194 tmp = ConfigSelection(advanced_lnb_allsat_diseqcmode_choices, "1_2")
1195 tmp.section = section
1196 configDiSEqCModeChanged(tmp)
1198 tmp = ConfigSelection(advanced_lnb_diseqcmode_choices, "none")
1199 tmp.section = section
1200 tmp.addNotifier(configDiSEqCModeChanged)
1201 section.diseqcMode = tmp
1202 section.commitedDiseqcCommand = ConfigSelection(advanced_lnb_csw_choices)
1203 section.fastDiseqc = ConfigYesNo(False)
1204 section.sequenceRepeat = ConfigYesNo(False)
1205 section.commandOrder1_0 = ConfigSelection(advanced_lnb_commandOrder1_0_choices, "ct")
1206 section.commandOrder = ConfigSelection(advanced_lnb_commandOrder_choices, "ct")
1207 section.uncommittedDiseqcCommand = ConfigSelection(advanced_lnb_ucsw_choices)
1208 section.diseqcRepeats = ConfigSelection(advanced_lnb_diseqc_repeat_choices, "none")
1209 section.prio = ConfigSelection(prio_list, "-1")
1210 section.unicable = ConfigNothing()
1211 tmp = ConfigSelection(lnb_choices, lnb_choices_default)
1214 tmp.addNotifier(configLOFChanged, initial_call = False)
1217 def configModeChanged(configMode):
1218 slot_id = configMode.slot_id
1219 nim = config.Nims[slot_id]
1220 if configMode.value == "advanced" and isinstance(nim.advanced, ConfigNothing):
1222 nim.advanced = ConfigSubsection()
1223 nim.advanced.sat = ConfigSubDict()
1224 nim.advanced.sats = getConfigSatlist(192, advanced_satlist_choices)
1225 nim.advanced.lnb = ConfigSubDict()
1226 nim.advanced.lnb[0] = ConfigNothing()
1227 for x in nimmgr.satList:
1228 tmp = ConfigSubsection()
1229 tmp.voltage = ConfigSelection(advanced_voltage_choices, "polarization")
1230 tmp.tonemode = ConfigSelection(advanced_tonemode_choices, "band")
1231 tmp.usals = ConfigYesNo(True)
1232 tmp.rotorposition = ConfigInteger(default=1, limits=(1, 255))
1233 lnb = ConfigSelection(advanced_lnb_choices, "0")
1234 lnb.slot_id = slot_id
1235 lnb.addNotifier(configLNBChanged, initial_call = False)
1237 nim.advanced.sat[x[0]] = tmp
1238 for x in range(3601, 3605):
1239 tmp = ConfigSubsection()
1240 tmp.voltage = ConfigSelection(advanced_voltage_choices, "polarization")
1241 tmp.tonemode = ConfigSelection(advanced_tonemode_choices, "band")
1242 tmp.usals = ConfigYesNo(default=True)
1243 tmp.rotorposition = ConfigInteger(default=1, limits=(1, 255))
1245 lnb = ConfigSelection([("0", "not available"), (str(lnbnum), "LNB %d"%(lnbnum))], "0")
1246 lnb.slot_id = slot_id
1247 lnb.addNotifier(configLNBChanged, initial_call = False)
1249 nim.advanced.sat[x] = tmp
1251 def toneAmplitudeChanged(configElement):
1252 fe_id = configElement.fe_id
1253 slot_id = configElement.slot_id
1254 if nimmgr.nim_slots[slot_id].description == 'Alps BSBE2':
1255 open("/proc/stb/frontend/%d/tone_amplitude" %(fe_id), "w").write(configElement.value)
1257 def tunerTypeChanged(nimmgr, configElement):
1258 fe_id = configElement.fe_id
1259 print "tunerTypeChanged feid %d to mode %s" % (fe_id, configElement.value)
1260 open("/proc/stb/frontend/%d/mode" % (fe_id), "w").write(configElement.value)
1261 frontend = eDVBResourceManager.getInstance().allocateRawChannel(fe_id).getFrontend()
1262 frontend.reopenFrontend()
1263 nimmgr.enumerateNIMs()
1266 for slot in nimmgr.nim_slots:
1268 nim = config.Nims[x]
1269 addMultiType = False
1274 if slot.isMultiType() and addMultiType:
1276 for id in slot.getMultiTypeList().keys():
1277 type = slot.getMultiTypeList()[id]
1278 typeList.append((id, type))
1279 nim.multiType = ConfigSelection(typeList, "0")
1281 nim.multiType.fe_id = x - empty_slots
1282 nim.multiType.addNotifier(boundFunction(tunerTypeChanged, nimmgr))
1285 for slot in nimmgr.nim_slots:
1287 nim = config.Nims[x]
1289 if slot.isCompatible("DVB-S"):
1290 nim.toneAmplitude = ConfigSelection([("9", "600mV"), ("8", "700mV"), ("7", "800mV"), ("6", "900mV"), ("5", "1100mV")], "7")
1291 nim.toneAmplitude.fe_id = x - empty_slots
1292 nim.toneAmplitude.slot_id = x
1293 nim.toneAmplitude.addNotifier(toneAmplitudeChanged)
1294 nim.diseqc13V = ConfigYesNo(False)
1295 nim.diseqcMode = ConfigSelection(diseqc_mode_choices, "diseqc_a_b")
1296 nim.connectedTo = ConfigSelection([(str(id), nimmgr.getNimDescription(id)) for id in nimmgr.getNimListOfType("DVB-S") if id != x])
1297 nim.simpleSingleSendDiSEqC = ConfigYesNo(False)
1298 nim.simpleDiSEqCSetVoltageTone = ConfigYesNo(True)
1299 nim.simpleDiSEqCOnlyOnSatChange = ConfigYesNo(False)
1300 nim.diseqcA = getConfigSatlist(192, diseqc_satlist_choices)
1301 nim.diseqcB = getConfigSatlist(130, diseqc_satlist_choices)
1302 nim.diseqcC = ConfigSatlist(list = diseqc_satlist_choices)
1303 nim.diseqcD = ConfigSatlist(list = diseqc_satlist_choices)
1304 nim.positionerMode = ConfigSelection(positioner_mode_choices, "usals")
1305 nim.longitude = ConfigFloat(default=[5,100], limits=[(0,359),(0,999)])
1306 nim.longitudeOrientation = ConfigSelection(longitude_orientation_choices, "east")
1307 nim.latitude = ConfigFloat(default=[50,767], limits=[(0,359),(0,999)])
1308 nim.latitudeOrientation = ConfigSelection(latitude_orientation_choices, "north")
1309 nim.powerMeasurement = ConfigYesNo(True)
1310 nim.powerThreshold = ConfigInteger(default=hw.get_device_name() == "dm8000" and 15 or 50, limits=(0, 100))
1311 nim.turningSpeed = ConfigSelection(turning_speed_choices, "fast")
1312 btime = datetime(1970, 1, 1, 7, 0);
1313 nim.fastTurningBegin = ConfigDateTime(default = mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 900)
1314 etime = datetime(1970, 1, 1, 19, 0);
1315 nim.fastTurningEnd = ConfigDateTime(default = mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 900)
1316 config_mode_choices = [ ("nothing", _("nothing connected")),
1317 ("simple", _("simple")), ("advanced", _("advanced"))]
1318 if len(nimmgr.getNimListOfType(slot.type, exception = x)) > 0:
1319 config_mode_choices.append(("equal", _("equal to")))
1320 config_mode_choices.append(("satposdepends", _("second cable of motorized LNB")))
1321 if len(nimmgr.canConnectTo(x)) > 0:
1322 config_mode_choices.append(("loopthrough", _("loopthrough to")))
1323 nim.advanced = ConfigNothing()
1324 tmp = ConfigSelection(config_mode_choices, "nothing")
1326 tmp.addNotifier(configModeChanged, initial_call = False)
1327 nim.configMode = tmp
1328 elif slot.isCompatible("DVB-C"):
1329 nim.configMode = ConfigSelection(
1331 "enabled": _("enabled"),
1332 "nothing": _("nothing connected"),
1334 default = "enabled")
1337 for x in nimmgr.cablesList:
1338 list.append((str(n), x[0]))
1340 nim.cable = ConfigSubsection()
1341 possible_scan_types = [("bands", _("Frequency bands")), ("steps", _("Frequency steps"))]
1343 possible_scan_types.append(("provider", _("Provider")))
1344 nim.cable.scan_provider = ConfigSelection(default = "0", choices = list)
1345 nim.cable.scan_type = ConfigSelection(default = "bands", choices = possible_scan_types)
1346 nim.cable.scan_band_EU_VHF_I = ConfigYesNo(default = True)
1347 nim.cable.scan_band_EU_MID = ConfigYesNo(default = True)
1348 nim.cable.scan_band_EU_VHF_III = ConfigYesNo(default = True)
1349 nim.cable.scan_band_EU_UHF_IV = ConfigYesNo(default = True)
1350 nim.cable.scan_band_EU_UHF_V = ConfigYesNo(default = True)
1351 nim.cable.scan_band_EU_SUPER = ConfigYesNo(default = True)
1352 nim.cable.scan_band_EU_HYPER = ConfigYesNo(default = True)
1353 nim.cable.scan_band_US_LOW = ConfigYesNo(default = False)
1354 nim.cable.scan_band_US_MID = ConfigYesNo(default = False)
1355 nim.cable.scan_band_US_HIGH = ConfigYesNo(default = False)
1356 nim.cable.scan_band_US_SUPER = ConfigYesNo(default = False)
1357 nim.cable.scan_band_US_HYPER = ConfigYesNo(default = False)
1358 nim.cable.scan_frequency_steps = ConfigInteger(default = 1000, limits = (1000, 10000))
1359 nim.cable.scan_mod_qam16 = ConfigYesNo(default = False)
1360 nim.cable.scan_mod_qam32 = ConfigYesNo(default = False)
1361 nim.cable.scan_mod_qam64 = ConfigYesNo(default = True)
1362 nim.cable.scan_mod_qam128 = ConfigYesNo(default = False)
1363 nim.cable.scan_mod_qam256 = ConfigYesNo(default = True)
1364 nim.cable.scan_sr_6900 = ConfigYesNo(default = True)
1365 nim.cable.scan_sr_6875 = ConfigYesNo(default = True)
1366 nim.cable.scan_sr_ext1 = ConfigInteger(default = 0, limits = (0, 7230))
1367 nim.cable.scan_sr_ext2 = ConfigInteger(default = 0, limits = (0, 7230))
1368 elif slot.isCompatible("DVB-T"):
1369 nim.configMode = ConfigSelection(
1371 "enabled": _("enabled"),
1372 "nothing": _("nothing connected"),
1374 default = "enabled")
1377 for x in nimmgr.terrestrialsList:
1378 list.append((str(n), x[0]))
1380 nim.terrestrial = ConfigSelection(choices = list)
1381 nim.terrestrial_5V = ConfigOnOff()
1384 nim.configMode = ConfigSelection(choices = { "nothing": _("disabled") }, default="nothing");
1385 if slot.type is not None:
1386 print "pls add support for this frontend type!", slot.type
1389 nimmgr.sec = SecConfigure(nimmgr)
1391 nimmanager = NimManager()