1 from Tools.HardwareInfo import HardwareInfo
3 from config import config, ConfigSubsection, ConfigSelection, ConfigFloat, \
4 ConfigSatlist, ConfigYesNo, ConfigInteger, ConfigSubList, ConfigNothing, \
5 ConfigSubDict, ConfigOnOff, ConfigDateTime
7 from enigma import eDVBSatelliteEquipmentControl as secClass, \
8 eDVBSatelliteLNBParameters as lnbParam, \
9 eDVBSatelliteDiseqcParameters as diseqcParam, \
10 eDVBSatelliteSwitchParameters as switchParam, \
11 eDVBSatelliteRotorParameters as rotorParam, \
12 eDVBResourceManager, eDVBDB
14 from time import localtime, mktime
15 from datetime import datetime
17 def getConfigSatlist(orbpos, satlist):
21 default_orbpos = orbpos
23 return ConfigSatlist(satlist, default_orbpos)
25 def tryOpen(filename):
27 procFile = open(filename)
33 def getConfiguredSats(self):
34 return self.configuredSatellites
36 def addSatellite(self, sec, orbpos):
37 sec.addSatellite(orbpos)
38 self.configuredSatellites.add(orbpos)
40 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):
41 if orbpos is None or orbpos == 3601:
45 tunermask = 1 << slotid
46 if self.equal.has_key(slotid):
47 for slot in self.equal[slotid]:
48 tunermask |= (1 << slot)
49 if self.linked.has_key(slotid):
50 for slot in self.linked[slotid]:
51 tunermask |= (1 << slot)
54 sec.setLNBLOFL(9750000)
55 sec.setLNBLOFH(10600000)
56 sec.setLNBThreshold(11700000)
57 sec.setLNBIncreasedVoltage(lnbParam.OFF)
59 sec.setFastDiSEqC(fastDiSEqC)
61 sec.setCommandOrder(0)
64 sec.setDiSEqCMode(diseqcmode)
65 sec.setToneburst(toneburstmode)
66 sec.setCommittedCommand(diseqcpos)
67 sec.setUncommittedCommand(0) # SENDNO
68 #print "set orbpos to:" + str(orbpos)
70 if 0 <= diseqcmode < 3:
71 self.addSatellite(sec, orbpos)
74 sec.setVoltageMode(switchParam.HV_13)
76 sec.setVoltageMode(switchParam.HV)
77 sec.setToneMode(switchParam.HILO)
79 sec.setVoltageMode(switchParam._14V)
80 sec.setToneMode(switchParam.OFF)
81 elif (diseqcmode == 3): # diseqc 1.2
82 if self.satposdepends.has_key(slotid):
83 for slot in self.satposdepends[slotid]:
84 tunermask |= (1 << slot)
85 sec.setLatitude(latitude)
86 sec.setLaDirection(laDirection)
87 sec.setLongitude(longitude)
88 sec.setLoDirection(loDirection)
89 sec.setUseInputpower(useInputPower)
90 sec.setInputpowerDelta(inputPowerDelta)
91 sec.setRotorTurningSpeed(turningSpeed)
93 for x in self.NimManager.satList:
94 print "Add sat " + str(x[0])
95 self.addSatellite(sec, int(x[0]))
97 sec.setVoltageMode(switchParam.HV_13)
99 sec.setVoltageMode(switchParam.HV)
100 sec.setToneMode(switchParam.HILO)
101 sec.setRotorPosNum(0) # USALS
103 sec.setLNBSlotMask(tunermask)
105 def setSatposDepends(self, sec, nim1, nim2):
106 print "tuner", nim1, "depends on satpos of", nim2
107 sec.setTunerDepends(nim1, nim2)
109 def linkNIMs(self, sec, nim1, nim2):
110 print "link tuner", nim1, "to tuner", nim2
111 sec.setTunerLinked(nim1, nim2)
113 def getRoot(self, slotid, connto):
115 while (self.NimManager.getNimConfig(connto).configMode.value in ("satposdepends", "equal", "loopthrough")):
116 connto = int(self.NimManager.getNimConfig(connto).connectedTo.value)
117 if connto in visited: # prevent endless loop
119 visited.append(connto)
123 sec = secClass.getInstance()
124 self.configuredSatellites = set()
125 sec.clear() ## this do unlinking NIMs too !!
126 print "sec config cleared"
129 self.satposdepends = { }
132 nim_slots = self.NimManager.nim_slots
136 for slot in nim_slots:
137 if slot.type is not None:
138 used_nim_slots.append((slot.slot, slot.description, slot.config.configMode.value != "nothing" and True or False, slot.isCompatible("DVB-S2")))
139 eDVBResourceManager.getInstance().setFrontendSlotInformations(used_nim_slots)
141 for slot in nim_slots:
144 if slot.isCompatible("DVB-S"):
145 # save what nim we link to/are equal to/satposdepends to.
146 # this is stored in the *value* (not index!) of the config list
147 if nim.configMode.value == "equal":
148 connto = self.getRoot(x, int(nim.connectedTo.value))
149 if not self.equal.has_key(connto):
150 self.equal[connto] = []
151 self.equal[connto].append(x)
152 elif nim.configMode.value == "loopthrough":
153 self.linkNIMs(sec, x, int(nim.connectedTo.value))
154 connto = self.getRoot(x, int(nim.connectedTo.value))
155 if not self.linked.has_key(connto):
156 self.linked[connto] = []
157 self.linked[connto].append(x)
158 elif nim.configMode.value == "satposdepends":
159 self.setSatposDepends(sec, x, int(nim.connectedTo.value))
160 connto = self.getRoot(x, int(nim.connectedTo.value))
161 if not self.satposdepends.has_key(connto):
162 self.satposdepends[connto] = []
163 self.satposdepends[connto].append(x)
165 for slot in nim_slots:
169 if slot.isCompatible("DVB-S"):
170 print "slot: " + str(x) + " configmode: " + str(nim.configMode.value)
171 if nim.configMode.value in ( "loopthrough", "satposdepends", "nothing" ):
174 sec.setSlotNotLinked(x)
175 if nim.configMode.value == "equal":
177 elif nim.configMode.value == "simple": #simple config
178 print "diseqcmode: ", nim.diseqcMode.value
179 if nim.diseqcMode.value == "single": #single
180 if nim.simpleSingleSendDiSEqC.value:
181 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA, diseqc13V = nim.diseqc13V.value)
183 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.NONE, diseqcpos = diseqcParam.SENDNO, diseqc13V = nim.diseqc13V.value)
184 elif nim.diseqcMode.value == "toneburst_a_b": #Toneburst A/B
185 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.A, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO, diseqc13V = nim.diseqc13V.value)
186 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.B, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO, diseqc13V = nim.diseqc13V.value)
187 elif nim.diseqcMode.value == "diseqc_a_b": #DiSEqC A/B
188 fastDiSEqC = nim.simpleDiSEqCOnlyOnSatChange.value
189 setVoltageTone = nim.simpleDiSEqCSetVoltageTone.value
190 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)
191 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)
192 elif nim.diseqcMode.value == "diseqc_a_b_c_d": #DiSEqC A/B/C/D
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 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)
198 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)
199 elif nim.diseqcMode.value == "positioner": #Positioner
200 if nim.latitudeOrientation.value == "north":
201 laValue = rotorParam.NORTH
203 laValue = rotorParam.SOUTH
204 if nim.longitudeOrientation.value == "east":
205 loValue = rotorParam.EAST
207 loValue = rotorParam.WEST
208 inputPowerDelta=nim.powerThreshold.value
211 if nim.powerMeasurement.value:
213 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
214 if turn_speed_dict.has_key(nim.turningSpeed.value):
215 turning_speed = turn_speed_dict[nim.turningSpeed.value]
217 beg_time = localtime(nim.fastTurningBegin.value)
218 end_time = localtime(nim.fastTurningEnd.value)
219 turning_speed = ((beg_time.tm_hour+1) * 60 + beg_time.tm_min + 1) << 16
220 turning_speed |= (end_time.tm_hour+1) * 60 + end_time.tm_min + 1
221 self.addLNBSimple(sec, slotid = x, diseqcmode = 3,
222 longitude = nim.longitude.float,
223 loDirection = loValue,
224 latitude = nim.latitude.float,
225 laDirection = laValue,
226 turningSpeed = turning_speed,
227 useInputPower = useInputPower,
228 inputPowerDelta = inputPowerDelta,
229 diseqc13V = nim.diseqc13V.value)
230 elif nim.configMode.value == "advanced": #advanced config
231 self.updateAdvanced(sec, x)
232 print "sec config completed"
234 def updateAdvanced(self, sec, slotid):
236 for x in range(1,37):
239 #wildcard for all satellites ( for rotor )
240 for x in range(3601, 3605):
241 lnb = int(config.Nims[slotid].advanced.sat[x].lnb.value)
243 for x in self.NimManager.satList:
244 print "add", x[0], "to", lnb
245 lnbSat[lnb].append(x[0])
247 for x in self.NimManager.satList:
248 lnb = int(config.Nims[slotid].advanced.sat[x[0]].lnb.value)
250 print "add", x[0], "to", lnb
251 lnbSat[lnb].append(x[0])
253 for x in range(1,37):
254 if len(lnbSat[x]) > 0:
255 currLnb = config.Nims[slotid].advanced.lnb[x]
261 tunermask = 1 << slotid
262 if self.equal.has_key(slotid):
263 for slot in self.equal[slotid]:
264 tunermask |= (1 << slot)
265 if self.linked.has_key(slotid):
266 for slot in self.linked[slotid]:
267 tunermask |= (1 << slot)
269 if currLnb.lof.value != "unicable":
272 if currLnb.lof.value == "universal_lnb":
273 sec.setLNBLOFL(9750000)
274 sec.setLNBLOFH(10600000)
275 sec.setLNBThreshold(11700000)
276 elif currLnb.lof.value == "unicable":
277 sec.setLNBLOFL(9750000)
278 sec.setLNBLOFH(10600000)
279 sec.setLNBThreshold(11700000)
280 if currLnb.unicable.value == "unicable_user":
281 sec.setLNBSatCR(currLnb.satcruser.index)
282 sec.setLNBSatCRvco(currLnb.satcrvcouser[currLnb.satcruser.index].value*1000)
283 elif currLnb.unicable.value == "unicable_matrix":
284 manufacturer_name = currLnb.unicableMatrixManufacturer.value
285 manufacturer = currLnb.unicableMatrix[manufacturer_name]
286 product_name = manufacturer.product.value
287 sec.setLNBSatCR(manufacturer.scr[product_name].index)
288 sec.setLNBSatCRvco(manufacturer.vco[product_name][manufacturer.scr[product_name].index].value*1000)
289 elif currLnb.unicable.value == "unicable_lnb":
290 manufacturer_name = currLnb.unicableLnbManufacturer.value
291 manufacturer = currLnb.unicableLnb[manufacturer_name]
292 product_name = manufacturer.product.value
293 sec.setLNBSatCR(manufacturer.scr[product_name].index)
294 sec.setLNBSatCRvco(manufacturer.vco[product_name][manufacturer.scr[product_name].index].value*1000)
295 elif currLnb.lof.value == "c_band":
296 sec.setLNBLOFL(5150000)
297 sec.setLNBLOFH(5150000)
298 sec.setLNBThreshold(5150000)
299 elif currLnb.lof.value == "user_defined":
300 sec.setLNBLOFL(currLnb.lofl.value * 1000)
301 sec.setLNBLOFH(currLnb.lofh.value * 1000)
302 sec.setLNBThreshold(currLnb.threshold.value * 1000)
304 # if currLnb.output_12v.value == "0V":
305 # pass # nyi in drivers
306 # elif currLnb.output_12v.value == "12V":
307 # pass # nyi in drivers
309 if currLnb.increased_voltage.value:
310 sec.setLNBIncreasedVoltage(lnbParam.ON)
312 sec.setLNBIncreasedVoltage(lnbParam.OFF)
314 dm = currLnb.diseqcMode.value
316 sec.setDiSEqCMode(diseqcParam.NONE)
318 sec.setDiSEqCMode(diseqcParam.V1_0)
320 sec.setDiSEqCMode(diseqcParam.V1_1)
322 sec.setDiSEqCMode(diseqcParam.V1_2)
324 if self.satposdepends.has_key(slotid):
325 for slot in self.satposdepends[slotid]:
326 tunermask |= (1 << slot)
329 if currLnb.toneburst.value == "none":
330 sec.setToneburst(diseqcParam.NO)
331 elif currLnb.toneburst.value == "A":
332 sec.setToneburst(diseqcParam.A)
333 elif currLnb.toneburst.value == "B":
334 sec.setToneburst(diseqcParam.B)
336 # Committed Diseqc Command
337 cdc = currLnb.commitedDiseqcCommand.value
339 c = { "none": diseqcParam.SENDNO,
340 "AA": diseqcParam.AA,
341 "AB": diseqcParam.AB,
342 "BA": diseqcParam.BA,
343 "BB": diseqcParam.BB }
346 sec.setCommittedCommand(c[cdc])
348 sec.setCommittedCommand(long(cdc))
350 sec.setFastDiSEqC(currLnb.fastDiseqc.value)
352 sec.setSeqRepeat(currLnb.sequenceRepeat.value)
354 if currLnb.diseqcMode.value == "1_0":
355 currCO = currLnb.commandOrder1_0.value
357 currCO = currLnb.commandOrder.value
359 udc = int(currLnb.uncommittedDiseqcCommand.value)
361 sec.setUncommittedCommand(0xF0|(udc-1))
363 sec.setUncommittedCommand(0) # SENDNO
365 sec.setRepeats({"none": 0, "one": 1, "two": 2, "three": 3}[currLnb.diseqcRepeats.value])
367 setCommandOrder = False
369 # 0 "committed, toneburst",
370 # 1 "toneburst, committed",
371 # 2 "committed, uncommitted, toneburst",
372 # 3 "toneburst, committed, uncommitted",
373 # 4 "uncommitted, committed, toneburst"
374 # 5 "toneburst, uncommitted, commmitted"
375 order_map = {"ct": 0, "tc": 1, "cut": 2, "tcu": 3, "uct": 4, "tuc": 5}
376 sec.setCommandOrder(order_map[currCO])
379 latitude = currLnb.latitude.float
380 sec.setLatitude(latitude)
381 longitude = currLnb.longitude.float
382 sec.setLongitude(longitude)
383 if currLnb.latitudeOrientation.value == "north":
384 sec.setLaDirection(rotorParam.NORTH)
386 sec.setLaDirection(rotorParam.SOUTH)
387 if currLnb.longitudeOrientation.value == "east":
388 sec.setLoDirection(rotorParam.EAST)
390 sec.setLoDirection(rotorParam.WEST)
392 if currLnb.powerMeasurement.value:
393 sec.setUseInputpower(True)
394 sec.setInputpowerDelta(currLnb.powerThreshold.value)
395 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
396 if turn_speed_dict.has_key(currLnb.turningSpeed.value):
397 turning_speed = turn_speed_dict[currLnb.turningSpeed.value]
399 beg_time = localtime(currLnb.fastTurningBegin.value)
400 end_time = localtime(currLnb.fastTurningEnd.value)
401 turning_speed = ((beg_time.tm_hour + 1) * 60 + beg_time.tm_min + 1) << 16
402 turning_speed |= (end_time.tm_hour + 1) * 60 + end_time.tm_min + 1
403 sec.setRotorTurningSpeed(turning_speed)
405 sec.setUseInputpower(False)
407 sec.setLNBSlotMask(tunermask)
409 sec.setLNBPrio(int(currLnb.prio.value))
411 # finally add the orbital positions
413 self.addSatellite(sec, y)
415 satpos = x > 32 and (3604-(36 - x)) or y
418 currSat = config.Nims[slotid].advanced.sat[satpos]
419 if currSat.voltage.value == "polarization":
420 if config.Nims[slotid].diseqc13V.value:
421 sec.setVoltageMode(switchParam.HV_13)
423 sec.setVoltageMode(switchParam.HV)
424 elif currSat.voltage.value == "13V":
425 sec.setVoltageMode(switchParam._14V)
426 elif currSat.voltage.value == "18V":
427 sec.setVoltageMode(switchParam._18V)
429 if currSat.tonemode.value == "band":
430 sec.setToneMode(switchParam.HILO)
431 elif currSat.tonemode.value == "on":
432 sec.setToneMode(switchParam.ON)
433 elif currSat.tonemode.value == "off":
434 sec.setToneMode(switchParam.OFF)
436 if not currSat.usals.value and x < 34:
437 sec.setRotorPosNum(currSat.rotorposition.value)
439 sec.setRotorPosNum(0) #USALS
441 def __init__(self, nimmgr):
442 self.NimManager = nimmgr
443 self.configuredSatellites = set()
447 def __init__(self, slot, type, description, has_outputs = True, internally_connectable = None, multi_type = {}):
450 if type not in ("DVB-S", "DVB-C", "DVB-T", "DVB-S2", None):
451 print "warning: unknown NIM type %s, not using." % type
455 self.description = description
456 self.has_outputs = has_outputs
457 self.internally_connectable = internally_connectable
458 self.multi_type = multi_type
460 def isCompatible(self, what):
463 "DVB-S": ("DVB-S", None),
464 "DVB-C": ("DVB-C", None),
465 "DVB-T": ("DVB-T", None),
466 "DVB-S2": ("DVB-S", "DVB-S2", None)
468 return what in compatible[self.type]
473 def connectableTo(self):
475 "DVB-S": ("DVB-S", "DVB-S2"),
478 "DVB-S2": ("DVB-S", "DVB-S2")
480 return connectable[self.type]
482 def getSlotName(self):
483 # get a friendly description for a slot name.
484 # we name them "Tuner A/B/C/...", because that's what's usually written on the back
486 return _("Tuner ") + chr(ord('A') + self.slot)
488 slot_name = property(getSlotName)
491 return chr(ord('A') + self.slot)
493 def hasOutputs(self):
494 return self.has_outputs
496 def internallyConnectableTo(self):
497 return self.internally_connectable
499 def isMultiType(self):
500 return (len(self.multi_type) > 0)
502 # returns dict {<slotid>: <type>}
503 def getMultiTypeList(self):
504 return self.multi_type
506 slot_id = property(getSlotID)
508 def getFriendlyType(self):
517 friendly_type = property(getFriendlyType)
519 def getFriendlyFullDescription(self):
520 nim_text = self.slot_name + ": "
523 nim_text += _("(empty)")
525 nim_text += self.description + " (" + self.friendly_type + ")"
529 friendly_full_description = property(getFriendlyFullDescription)
530 config_mode = property(lambda self: config.Nims[self.slot].configMode.value)
531 config = property(lambda self: config.Nims[self.slot])
532 empty = property(lambda self: self.type is None)
535 def getConfiguredSats(self):
536 return self.sec.getConfiguredSats()
538 def getTransponders(self, pos):
539 if self.transponders.has_key(pos):
540 return self.transponders[pos]
544 def getTranspondersCable(self, nim):
545 nimConfig = config.Nims[nim]
546 if nimConfig.configMode.value != "nothing" and nimConfig.cable.scan_type.value == "provider":
547 return self.transponderscable[self.cablesList[nimConfig.cable.scan_provider.index][0]]
550 def getTranspondersTerrestrial(self, region):
551 return self.transpondersterrestrial[region]
553 def getCableDescription(self, nim):
554 return self.cablesList[config.Nims[nim].scan_provider.index][0]
556 def getCableFlags(self, nim):
557 return self.cablesList[config.Nims[nim].scan_provider.index][1]
559 def getTerrestrialDescription(self, nim):
560 return self.terrestrialsList[config.Nims[nim].terrestrial.index][0]
562 def getTerrestrialFlags(self, nim):
563 return self.terrestrialsList[config.Nims[nim].terrestrial.index][1]
565 def getSatDescription(self, pos):
566 return self.satellites[pos]
568 def sortFunc(self, x):
575 def readTransponders(self):
576 # read initial networks from file. we only read files which we are interested in,
577 # which means only these where a compatible tuner exists.
578 self.satellites = { }
579 self.transponders = { }
580 self.transponderscable = { }
581 self.transpondersterrestrial = { }
582 db = eDVBDB.getInstance()
583 if self.hasNimType("DVB-S"):
584 print "Reading satellites.xml"
585 db.readSatellites(self.satList, self.satellites, self.transponders)
586 self.satList.sort(key = self.sortFunc) # sort by orbpos
587 #print "SATLIST", self.satList
588 #print "SATS", self.satellites
589 #print "TRANSPONDERS", self.transponders
591 if self.hasNimType("DVB-C"):
592 print "Reading cables.xml"
593 db.readCables(self.cablesList, self.transponderscable)
594 # print "CABLIST", self.cablesList
595 # print "TRANSPONDERS", self.transponders
597 if self.hasNimType("DVB-T"):
598 print "Reading terrestrial.xml"
599 db.readTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
600 # print "TERLIST", self.terrestrialsList
601 # print "TRANSPONDERS", self.transpondersterrestrial
603 def enumerateNIMs(self):
604 # enum available NIMs. This is currently very dreambox-centric and uses the /proc/bus/nim_sockets interface.
605 # the result will be stored into nim_slots.
606 # the content of /proc/bus/nim_sockets looks like:
609 # Name: BCM4501 DVB-S2 NIM (internal)
612 # Name: BCM4501 DVB-S2 NIM (internal)
615 # Name: Philips TU1216
618 # Name: Alps BSBE1 702A
621 # Type will be either "DVB-S", "DVB-S2", "DVB-T", "DVB-C" or None.
623 # nim_slots is an array which has exactly one entry for each slot, even for empty ones.
626 nimfile = tryOpen("/proc/bus/nim_sockets")
634 for line in nimfile.readlines():
637 if line.strip().startswith("NIM Socket"):
638 parts = line.strip().split(" ")
639 current_slot = int(parts[2][:-1])
640 entries[current_slot] = {}
641 elif line.strip().startswith("Type:"):
642 entries[current_slot]["type"] = str(line.strip()[6:])
643 elif line.strip().startswith("Name:"):
644 entries[current_slot]["name"] = str(line.strip()[6:])
645 elif line.strip().startswith("Has_Outputs:"):
646 input = str(line.strip()[len("Has_Outputs:") + 1:])
647 entries[current_slot]["has_outputs"] = (input == "yes")
648 elif line.strip().startswith("Internally_Connectable:"):
649 input = int(line.strip()[len("Internally_Connectable:") + 1:])
650 entries[current_slot]["internally_connectable"] = input
651 elif line.strip().startswith("Mode"):
652 # "Mode 0: DVB-T" -> ["Mode 0", " DVB-T"]
653 split = line.strip().split(":")
654 # "Mode 0" -> ["Mode, "0"]
655 split2 = split[0].split(" ")
656 modes = entries[current_slot].get("multi_type", {})
657 modes[split2[1]] = split[1].strip()
658 entries[current_slot]["multi_type"] = modes
659 elif line.strip().startswith("empty"):
660 entries[current_slot]["type"] = None
661 entries[current_slot]["name"] = _("N/A")
664 for id, entry in entries.items():
665 if not (entry.has_key("name") and entry.has_key("type")):
666 entry["name"] = _("N/A")
668 if not (entry.has_key("has_outputs")):
669 entry["has_outputs"] = True
670 if not (entry.has_key("internally_connectable")):
671 entry["internally_connectable"] = None
672 if not (entry.has_key("multi_type")):
673 entry["multi_type"] = {}
674 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"]))
676 def hasNimType(self, chktype):
677 for slot in self.nim_slots:
678 if slot.isCompatible(chktype):
680 for type in slot.getMultiTypeList().values():
685 def getNimType(self, slotid):
686 return self.nim_slots[slotid].type
688 def getNimDescription(self, slotid):
689 return self.nim_slots[slotid].friendly_full_description
691 def getNimListOfType(self, type, exception = -1):
692 # returns a list of indexes for NIMs compatible to the given type, except for 'exception'
694 for x in self.nim_slots:
695 if x.isCompatible(type) and x.slot != exception:
702 self.terrestrialsList = []
704 self.readTransponders()
705 InitNimManager(self) #init config stuff
707 # get a list with the friendly full description
710 for slot in self.nim_slots:
711 list.append(slot.friendly_full_description)
714 def getSlotCount(self):
715 return len(self.nim_slots)
717 def hasOutputs(self, slotid):
718 return self.nim_slots[slotid].hasOutputs()
720 def canConnectTo(self, slotid):
722 if self.nim_slots[slotid].internallyConnectableTo() is not None:
723 slots.append(self.nim_slots[slotid].internallyConnectableTo())
724 for type in self.nim_slots[slotid].connectableTo():
725 for slot in self.getNimListOfType(type, exception = slotid):
726 if self.hasOutputs(slot):
728 # remove nims, that have a conntectedTo reference on
729 for testnim in slots[:]:
730 for nim in self.getNimListOfType("DVB-S", slotid):
731 nimConfig = self.getNimConfig(nim)
732 if nimConfig.content.items.has_key("configMode") and nimConfig.configMode.value == "loopthrough" and int(nimConfig.connectedTo.value) == testnim:
733 slots.remove(testnim)
739 def canEqualTo(self, slotid):
740 type = self.getNimType(slotid)
743 nimList = self.getNimListOfType(type, slotid)
744 for nim in nimList[:]:
745 mode = self.getNimConfig(nim)
746 if mode.configMode.value == "loopthrough" or mode.configMode.value == "satposdepends":
750 def canDependOn(self, slotid):
751 type = self.getNimType(slotid)
754 nimList = self.getNimListOfType(type, slotid)
756 for nim in nimList[:]:
757 mode = self.getNimConfig(nim)
758 nimHaveRotor = mode.configMode.value == "simple" and mode.diseqcMode.value == "positioner"
759 if not nimHaveRotor and mode.configMode.value == "advanced":
760 for x in range(3601, 3605):
761 lnb = int(mode.advanced.sat[x].lnb.value)
766 for sat in mode.advanced.sat.values():
767 lnb_num = int(sat.lnb.value)
768 diseqcmode = lnb_num and mode.advanced.lnb[lnb_num].diseqcMode.value or ""
769 if diseqcmode == "1_2":
773 alreadyConnected = False
774 for testnim in nimList:
775 testmode = self.getNimConfig(testnim)
776 if testmode.configMode.value == "satposdepends" and int(testmode.connectedTo.value) == int(nim):
777 alreadyConnected = True
779 if not alreadyConnected:
780 positionerList.append(nim)
781 return positionerList
783 def getNimConfig(self, slotid):
784 return config.Nims[slotid]
786 def getSatName(self, pos):
787 for sat in self.satList:
792 def getSatList(self):
795 # returns True if something is configured to be connected to this nim
796 # if slotid == -1, returns if something is connected to ANY nim
797 def somethingConnected(self, slotid = -1):
800 for id in range(self.getSlotCount()):
801 if self.somethingConnected(id):
805 nim = config.Nims[slotid]
806 configMode = nim.configMode.value
808 if self.nim_slots[slotid].isCompatible("DVB-S") or self.nim_slots[slotid].isCompatible("DVB-T") or self.nim_slots[slotid].isCompatible("DVB-C"):
809 return not (configMode == "nothing")
811 def getSatListForNim(self, slotid):
813 if self.nim_slots[slotid].isCompatible("DVB-S"):
814 nim = config.Nims[slotid]
815 #print "slotid:", slotid
817 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.index]
818 #print "diseqcA:", config.Nims[slotid].diseqcA.value
819 configMode = nim.configMode.value
821 if configMode == "equal":
822 slotid = int(nim.connectedTo.value)
823 nim = config.Nims[slotid]
824 configMode = nim.configMode.value
825 elif configMode == "loopthrough":
826 slotid = self.sec.getRoot(slotid, int(nim.connectedTo.value))
827 nim = config.Nims[slotid]
828 configMode = nim.configMode.value
830 if configMode == "simple":
831 dm = nim.diseqcMode.value
832 if dm in ("single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"):
833 if nim.diseqcA.orbital_position != 3601:
834 list.append(self.satList[nim.diseqcA.index-1])
835 if dm in ("toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"):
836 if nim.diseqcB.orbital_position != 3601:
837 list.append(self.satList[nim.diseqcB.index-1])
838 if dm == "diseqc_a_b_c_d":
839 if nim.diseqcC.orbital_position != 3601:
840 list.append(self.satList[nim.diseqcC.index-1])
841 if nim.diseqcD.orbital_position != 3601:
842 list.append(self.satList[nim.diseqcD.index-1])
843 if dm == "positioner":
844 for x in self.satList:
846 elif configMode == "advanced":
847 for x in range(3601, 3605):
848 if int(nim.advanced.sat[x].lnb.value) != 0:
849 for x in self.satList:
852 for x in self.satList:
853 if int(nim.advanced.sat[x[0]].lnb.value) != 0:
857 def getRotorSatListForNim(self, slotid):
859 if self.nim_slots[slotid].isCompatible("DVB-S"):
860 #print "slotid:", slotid
861 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
862 #print "diseqcA:", config.Nims[slotid].diseqcA.value
863 configMode = config.Nims[slotid].configMode.value
864 if configMode == "simple":
865 if config.Nims[slotid].diseqcMode.value == "positioner":
866 for x in self.satList:
868 elif configMode == "advanced":
869 nim = config.Nims[slotid]
870 for x in range(3601, 3605):
871 if int(nim.advanced.sat[x].lnb.value) != 0:
872 for x in self.satList:
875 for x in self.satList:
876 lnbnum = int(nim.advanced.sat[x[0]].lnb.value)
878 lnb = nim.advanced.lnb[lnbnum]
879 if lnb.diseqcMode.value == "1_2":
884 config.sec = ConfigSubsection()
886 x = ConfigInteger(default=25, limits = (0, 9999))
887 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_CONT_TONE_DISABLE_BEFORE_DISEQC, configElement.value))
888 config.sec.delay_after_continuous_tone_disable_before_diseqc = x
890 x = ConfigInteger(default=10, limits = (0, 9999))
891 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_CONT_TONE_CHANGE, configElement.value))
892 config.sec.delay_after_final_continuous_tone_change = x
894 x = ConfigInteger(default=10, limits = (0, 9999))
895 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_VOLTAGE_CHANGE, configElement.value))
896 config.sec.delay_after_final_voltage_change = x
898 x = ConfigInteger(default=120, limits = (0, 9999))
899 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_DISEQC_REPEATS, configElement.value))
900 config.sec.delay_between_diseqc_repeats = x
902 x = ConfigInteger(default=50, limits = (0, 9999))
903 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_LAST_DISEQC_CMD, configElement.value))
904 config.sec.delay_after_last_diseqc_command = x
906 x = ConfigInteger(default=50, limits = (0, 9999))
907 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value))
908 config.sec.delay_after_toneburst = x
910 x = ConfigInteger(default=20, limits = (0, 9999))
911 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS, configElement.value))
912 config.sec.delay_after_change_voltage_before_switch_command = x
914 x = ConfigInteger(default=200, limits = (0, 9999))
915 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS, configElement.value))
916 config.sec.delay_after_enable_voltage_before_switch_command = x
918 x = ConfigInteger(default=700, limits = (0, 9999))
919 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_SWITCH_AND_MOTOR_CMD, configElement.value))
920 config.sec.delay_between_switch_and_motor_command = x
922 x = ConfigInteger(default=500, limits = (0, 9999))
923 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MEASURE_IDLE_INPUTPOWER, configElement.value))
924 config.sec.delay_after_voltage_change_before_measure_idle_inputpower = x
926 x = ConfigInteger(default=900, limits = (0, 9999))
927 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_MOTOR_CMD, configElement.value))
928 config.sec.delay_after_enable_voltage_before_motor_command = x
930 x = ConfigInteger(default=500, limits = (0, 9999))
931 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_MOTOR_STOP_CMD, configElement.value))
932 config.sec.delay_after_motor_stop_command = x
934 x = ConfigInteger(default=500, limits = (0, 9999))
935 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MOTOR_CMD, configElement.value))
936 config.sec.delay_after_voltage_change_before_motor_command = x
938 x = ConfigInteger(default=70, limits = (0, 9999))
939 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BEFORE_SEQUENCE_REPEAT, configElement.value))
940 config.sec.delay_before_sequence_repeat = x
942 x = ConfigInteger(default=360, limits = (0, 9999))
943 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_RUNNING_TIMEOUT, configElement.value))
944 config.sec.motor_running_timeout = x
946 x = ConfigInteger(default=1, limits = (0, 5))
947 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_COMMAND_RETRIES, configElement.value))
948 config.sec.motor_command_retries = x
950 x = ConfigInteger(default=50, limits = (0, 9999))
951 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_DISEQC_RESET_CMD, configElement.value))
952 config.sec.delay_after_diseqc_reset_cmd = x
954 x = ConfigInteger(default=150, limits = (0, 9999))
955 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_DISEQC_PERIPHERIAL_POWERON_CMD, configElement.value))
956 config.sec.delay_after_diseqc_peripherial_poweron_cmd = x
958 # TODO add support for satpos depending nims to advanced nim configuration
959 # so a second/third/fourth cable from a motorized lnb can used behind a
960 # diseqc 1.0 / diseqc 1.1 / toneburst switch
961 # the C(++) part should can handle this
962 # the configElement should be only visible when diseqc 1.2 is disabled
964 def InitNimManager(nimmgr):
968 config.Nims = ConfigSubList()
969 for x in range(len(nimmgr.nim_slots)):
970 config.Nims.append(ConfigSubsection())
973 "universal_lnb": _("Universal LNB"),
974 "unicable": _("Unicable"),
975 "c_band": _("C-Band"),
976 "user_defined": _("User defined")}
978 lnb_choices_default = "universal_lnb"
980 unicablelnbproducts = {
981 "Humax": {"150 SCR":("1210","1420","1680","2040")},
982 "Inverto": {"IDLP-40UNIQD+S":("1680","1420","2040","1210")},
983 "Kathrein": {"UAS481":("1400","1516","1632","1748")},
984 "Kreiling": {"KR1440":("1680","1420","2040","1210")},
985 "Radix": {"Unicable LNB":("1680","1420","2040","1210")},
986 "Wisi": {"OC 05":("1210","1420","1680","2040")}}
987 UnicableLnbManufacturers = unicablelnbproducts.keys()
988 UnicableLnbManufacturers.sort()
990 unicablematrixproducts = {
992 "UCS 51440":("1400","1632","1284","1516"),
993 "UCS 51820":("1400","1632","1284","1516","1864","2096","1748","1980"),
994 "UCS 51840":("1400","1632","1284","1516","1864","2096","1748","1980"),
995 "UCS 52240":("1400","1632"),
996 "UCS 52420":("1400","1632","1284","1516"),
997 "UCS 52440":("1400","1632","1284","1516"),
998 "UCS 91440":("1400","1632","1284","1516"),
999 "UCS 91820":("1400","1632","1284","1516","1864","2096","1748","1980"),
1000 "UCS 91840":("1400","1632","1284","1516","1864","2096","1748","1980"),
1001 "UCS 92240":("1400","1632"),
1002 "UCS 92420":("1400","1632","1284","1516"),
1003 "UCS 92440":("1400","1632","1284","1516")},
1005 "SUM518":("1284","1400","1516","1632","1748","1864","1980","2096"),
1006 "SUM918":("1284","1400","1516","1632","1748","1864","1980","2096"),
1007 "SUM928":("1284","1400","1516","1632","1748","1864","1980","2096")},
1009 "IDLP-UST11O-CUO1O-8PP":("1076","1178","1280","1382","1484","1586","1688","1790")},
1011 "EXR501":("1400","1516","1632","1748"),
1012 "EXR551":("1400","1516","1632","1748"),
1013 "EXR552":("1400","1516")},
1015 "EKL2/1":("1400","1516"),
1016 "EKL2/1E":("0","0","1632","1748")},
1018 "DPA 51":("1284","1400","1516","1632","1748","1864","1980","2096")},
1020 "TechniRouter 5/1x8 G":("1284","1400","1516","1632","1748","1864","1980","2096"),
1021 "TechniRouter 5/1x8 K":("1284","1400","1516","1632","1748","1864","1980","2096"),
1022 "TechniRouter 5/2x4 G":("1284","1400","1516","1632"),
1023 "TechniRouter 5/2x4 K":("1284","1400","1516","1632")},
1025 "SCR 5/1x8 G":("1284","1400","1516","1632","1748","1864","1980","2096"),
1026 "SCR 5/1x8 K":("1284","1400","1516","1632","1748","1864","1980","2096"),
1027 "SCR 5/2x4 G":("1284","1400","1516","1632"),
1028 "SCR 5/2x4 K":("1284","1400","1516","1632")}}
1029 UnicableMatrixManufacturers = unicablematrixproducts.keys()
1030 UnicableMatrixManufacturers.sort()
1032 unicable_choices = {
1033 "unicable_lnb": _("Unicable LNB"),
1034 "unicable_matrix": _("Unicable Martix"),
1035 "unicable_user": "Unicable "+_("User defined")}
1036 unicable_choices_default = "unicable_lnb"
1038 advanced_lnb_satcruser_choices = [ ("1", "SatCR 1"), ("2", "SatCR 2"), ("3", "SatCR 3"), ("4", "SatCR 4"),
1039 ("5", "SatCR 5"), ("6", "SatCR 6"), ("7", "SatCR 7"), ("8", "SatCR 8")]
1041 prio_list = [ ("-1", _("Auto")) ]
1042 prio_list += [(str(prio), str(prio)) for prio in range(65)+range(14000,14065)+range(19000,19065)]
1044 advanced_lnb_csw_choices = [("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))]
1045 advanced_lnb_csw_choices += [(str(0xF0|y), "Input " + str(y+1)) for y in range(0, 16)]
1047 advanced_lnb_ucsw_choices = [("0", _("None"))] + [(str(y), "Input " + str(y)) for y in range(1, 17)]
1049 diseqc_mode_choices = [
1050 ("single", _("Single")), ("toneburst_a_b", _("Toneburst A/B")),
1051 ("diseqc_a_b", _("DiSEqC A/B")), ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")),
1052 ("positioner", _("Positioner"))]
1054 positioner_mode_choices = [("usals", _("USALS")), ("manual", _("manual"))]
1056 diseqc_satlist_choices = [(3601, _('nothing connected'), 1)] + nimmgr.satList
1058 longitude_orientation_choices = [("east", _("East")), ("west", _("West"))]
1059 latitude_orientation_choices = [("north", _("North")), ("south", _("South"))]
1060 turning_speed_choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch"))]
1062 advanced_satlist_choices = nimmgr.satList + [
1063 (3601, _('All Satellites')+' 1', 1), (3602, _('All Satellites')+' 2', 1),
1064 (3603, _('All Satellites')+' 3', 1), (3604, _('All Satellites')+' 4', 1)]
1065 advanced_lnb_choices = [("0", "not available")] + [(str(y), "LNB " + str(y)) for y in range(1, 33)]
1066 advanced_voltage_choices = [("polarization", _("Polarization")), ("13V", _("13 V")), ("18V", _("18 V"))]
1067 advanced_tonemode_choices = [("band", _("Band")), ("on", _("On")), ("off", _("Off"))]
1068 advanced_lnb_toneburst_choices = [("none", _("None")), ("A", _("A")), ("B", _("B"))]
1069 advanced_lnb_allsat_diseqcmode_choices = [("1_2", _("1.2"))]
1070 advanced_lnb_diseqcmode_choices = [("none", _("None")), ("1_0", _("1.0")), ("1_1", _("1.1")), ("1_2", _("1.2"))]
1071 advanced_lnb_commandOrder1_0_choices = [("ct", "committed, toneburst"), ("tc", "toneburst, committed")]
1072 advanced_lnb_commandOrder_choices = [
1073 ("ct", "committed, toneburst"), ("tc", "toneburst, committed"),
1074 ("cut", "committed, uncommitted, toneburst"), ("tcu", "toneburst, committed, uncommitted"),
1075 ("uct", "uncommitted, committed, toneburst"), ("tuc", "toneburst, uncommitted, commmitted")]
1076 advanced_lnb_diseqc_repeat_choices = [("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))]
1077 advanced_lnb_fast_turning_btime = mktime(datetime(1970, 1, 1, 7, 0).timetuple());
1078 advanced_lnb_fast_turning_etime = mktime(datetime(1970, 1, 1, 19, 0).timetuple());
1080 def configLOFChanged(configElement):
1081 if configElement.value == "unicable":
1082 x = configElement.slot_id
1083 lnb = configElement.lnb_id
1084 nim = config.Nims[x]
1085 lnbs = nim.advanced.lnb
1087 if isinstance(section.unicable, ConfigNothing):
1089 section.unicable = ConfigSelection(unicable_choices, unicable_choices_default)
1091 section.unicable = ConfigSelection(choices = {"unicable_matrix": _("Unicable Martix"),"unicable_user": "Unicable "+_("User defined")}, default = "unicable_matrix")
1093 section.unicable = ConfigSelection(choices = {"unicable_user": _("User defined")}, default = "unicable_user")
1096 section.unicableMatrix = ConfigSubDict()
1097 section.unicableMatrixManufacturer = ConfigSelection(choices = UnicableMatrixManufacturers, default = UnicableMatrixManufacturers[0])
1098 for y in unicablematrixproducts:
1099 products = unicablematrixproducts[y].keys()
1101 tmp = ConfigSubsection()
1102 tmp.product = ConfigSelection(choices = products, default = products[0])
1103 tmp.scr = ConfigSubDict()
1104 tmp.vco = ConfigSubDict()
1107 vcolist = unicablematrixproducts[y][z]
1108 tmp.vco[z] = ConfigSubList()
1109 for cnt in range(1,1+len(vcolist)):
1110 vcofreq = int(vcolist[cnt-1])
1112 scrlist.append(("%d" %cnt,"SCR %d " %cnt +_("not used")))
1114 scrlist.append(("%d" %cnt,"SCR %d" %cnt))
1115 tmp.vco[z].append(ConfigInteger(default=vcofreq, limits = (vcofreq, vcofreq)))
1116 tmp.scr[z] = ConfigSelection(choices = scrlist, default = scrlist[0][0])
1117 section.unicableMatrix[y] = tmp
1120 section.unicableLnb = ConfigSubDict()
1121 section.unicableLnbManufacturer = ConfigSelection(UnicableLnbManufacturers, UnicableLnbManufacturers[0])
1122 for y in unicablelnbproducts:
1123 products = unicablelnbproducts[y].keys()
1125 tmp = ConfigSubsection()
1126 tmp.product = ConfigSelection(choices = products, default = products[0])
1127 tmp.scr = ConfigSubDict()
1128 tmp.vco = ConfigSubDict()
1131 vcolist = unicablelnbproducts[y][z]
1132 tmp.vco[z] = ConfigSubList()
1133 for cnt in range(1,1+len(vcolist)):
1134 scrlist.append(("%d" %cnt,"SCR %d" %cnt))
1135 vcofreq = int(vcolist[cnt-1])
1136 tmp.vco[z].append(ConfigInteger(default=vcofreq, limits = (vcofreq, vcofreq)))
1137 tmp.scr[z] = ConfigSelection(choices = scrlist, default = scrlist[0][0])
1138 section.unicableLnb[y] = tmp
1140 section.satcruser = ConfigSelection(advanced_lnb_satcruser_choices, default="1")
1141 tmp = ConfigSubList()
1142 tmp.append(ConfigInteger(default=1284, limits = (0, 9999)))
1143 tmp.append(ConfigInteger(default=1400, limits = (0, 9999)))
1144 tmp.append(ConfigInteger(default=1516, limits = (0, 9999)))
1145 tmp.append(ConfigInteger(default=1632, limits = (0, 9999)))
1146 tmp.append(ConfigInteger(default=1748, limits = (0, 9999)))
1147 tmp.append(ConfigInteger(default=1864, limits = (0, 9999)))
1148 tmp.append(ConfigInteger(default=1980, limits = (0, 9999)))
1149 tmp.append(ConfigInteger(default=2096, limits = (0, 9999)))
1150 section.satcrvcouser = tmp
1152 def configDiSEqCModeChanged(configElement):
1153 section = configElement.section
1154 if configElement.value == "1_2" and isinstance(section.longitude, ConfigNothing):
1155 section.longitude = ConfigFloat(default = [5,100], limits = [(0,359),(0,999)])
1156 section.longitudeOrientation = ConfigSelection(longitude_orientation_choices, "east")
1157 section.latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)])
1158 section.latitudeOrientation = ConfigSelection(latitude_orientation_choices, "north")
1159 section.powerMeasurement = ConfigYesNo(default=True)
1160 section.powerThreshold = ConfigInteger(default=hw.get_device_name() == "dm8000" and 15 or 50, limits=(0, 100))
1161 section.turningSpeed = ConfigSelection(turning_speed_choices, "fast")
1162 section.fastTurningBegin = ConfigDateTime(default=advanced_lnb_fast_turning_btime, formatstring = _("%H:%M"), increment = 600)
1163 section.fastTurningEnd = ConfigDateTime(default=advanced_lnb_fast_turning_etime, formatstring = _("%H:%M"), increment = 600)
1165 def configLNBChanged(configElement):
1166 x = configElement.slot_id
1167 nim = config.Nims[x]
1168 if isinstance(configElement.value, tuple):
1169 lnb = int(configElement.value[0])
1171 lnb = int(configElement.value)
1172 lnbs = nim.advanced.lnb
1173 if lnb and lnb not in lnbs:
1174 section = lnbs[lnb] = ConfigSubsection()
1175 section.lofl = ConfigInteger(default=9750, limits = (0, 99999))
1176 section.lofh = ConfigInteger(default=10600, limits = (0, 99999))
1177 section.threshold = ConfigInteger(default=11700, limits = (0, 99999))
1178 # section.output_12v = ConfigSelection(choices = [("0V", _("0 V")), ("12V", _("12 V"))], default="0V")
1179 section.increased_voltage = ConfigYesNo(False)
1180 section.toneburst = ConfigSelection(advanced_lnb_toneburst_choices, "none")
1181 section.longitude = ConfigNothing()
1183 tmp = ConfigSelection(advanced_lnb_allsat_diseqcmode_choices, "1_2")
1184 tmp.section = section
1185 configDiSEqCModeChanged(tmp)
1187 tmp = ConfigSelection(advanced_lnb_diseqcmode_choices, "none")
1188 tmp.section = section
1189 tmp.addNotifier(configDiSEqCModeChanged)
1190 section.diseqcMode = tmp
1191 section.commitedDiseqcCommand = ConfigSelection(advanced_lnb_csw_choices)
1192 section.fastDiseqc = ConfigYesNo(False)
1193 section.sequenceRepeat = ConfigYesNo(False)
1194 section.commandOrder1_0 = ConfigSelection(advanced_lnb_commandOrder1_0_choices, "ct")
1195 section.commandOrder = ConfigSelection(advanced_lnb_commandOrder_choices, "ct")
1196 section.uncommittedDiseqcCommand = ConfigSelection(advanced_lnb_ucsw_choices)
1197 section.diseqcRepeats = ConfigSelection(advanced_lnb_diseqc_repeat_choices, "none")
1198 section.prio = ConfigSelection(prio_list, "-1")
1199 section.unicable = ConfigNothing()
1200 tmp = ConfigSelection(lnb_choices, lnb_choices_default)
1203 tmp.addNotifier(configLOFChanged, initial_call = False)
1206 def configModeChanged(configMode):
1207 slot_id = configMode.slot_id
1208 nim = config.Nims[slot_id]
1209 if configMode.value == "advanced" and isinstance(nim.advanced, ConfigNothing):
1211 nim.advanced = ConfigSubsection()
1212 nim.advanced.sat = ConfigSubDict()
1213 nim.advanced.sats = getConfigSatlist(192, advanced_satlist_choices)
1214 nim.advanced.lnb = ConfigSubDict()
1215 nim.advanced.lnb[0] = ConfigNothing()
1216 for x in nimmgr.satList:
1217 tmp = ConfigSubsection()
1218 tmp.voltage = ConfigSelection(advanced_voltage_choices, "polarization")
1219 tmp.tonemode = ConfigSelection(advanced_tonemode_choices, "band")
1220 tmp.usals = ConfigYesNo(True)
1221 tmp.rotorposition = ConfigInteger(default=1, limits=(1, 255))
1222 lnb = ConfigSelection(advanced_lnb_choices, "0")
1223 lnb.slot_id = slot_id
1224 lnb.addNotifier(configLNBChanged, initial_call = False)
1226 nim.advanced.sat[x[0]] = tmp
1227 for x in range(3601, 3605):
1228 tmp = ConfigSubsection()
1229 tmp.voltage = ConfigSelection(advanced_voltage_choices, "polarization")
1230 tmp.tonemode = ConfigSelection(advanced_tonemode_choices, "band")
1231 tmp.usals = ConfigYesNo(default=True)
1232 tmp.rotorposition = ConfigInteger(default=1, limits=(1, 255))
1234 lnb = ConfigSelection([("0", "not available"), (str(lnbnum), "LNB %d"%(lnbnum))], "0")
1235 lnb.slot_id = slot_id
1236 lnb.addNotifier(configLNBChanged, initial_call = False)
1238 nim.advanced.sat[x] = tmp
1240 def toneAmplitudeChanged(configElement):
1241 fe_id = configElement.fe_id
1242 slot_id = configElement.slot_id
1243 if nimmgr.nim_slots[slot_id].description == 'Alps BSBE2':
1244 open("/proc/stb/frontend/%d/tone_amplitude" %(fe_id), "w").write(configElement.value)
1246 def tunerTypeChanged(configElement):
1247 fe_id = configElement.fe_id
1248 open("/proc/stb/frontend/%d/mode" % (fe_id), "w").write(configElement.value)
1251 for slot in nimmgr.nim_slots:
1253 nim = config.Nims[x]
1254 if slot.isMultiType():
1257 for id in slot.getMultiTypeList().keys():
1258 type = slot.getMultiTypeList()[id]
1259 typeList.append((id, type))
1260 if type == slot.getType():
1262 nim.multiType = ConfigSelection(typeList, "0")
1263 nim.multiType.value = value
1264 nim.multiType.fe_id = x - empty_slots
1265 nim.multiType.addNotifier(tunerTypeChanged)
1267 if slot.isCompatible("DVB-S"):
1268 nim.toneAmplitude = ConfigSelection([("9", "600mV"), ("8", "700mV"), ("7", "800mV"), ("6", "900mV"), ("5", "1100mV")], "7")
1269 nim.toneAmplitude.fe_id = x - empty_slots
1270 nim.toneAmplitude.slot_id = x
1271 nim.toneAmplitude.addNotifier(toneAmplitudeChanged)
1272 nim.diseqc13V = ConfigYesNo(False)
1273 nim.diseqcMode = ConfigSelection(diseqc_mode_choices, "diseqc_a_b")
1274 nim.connectedTo = ConfigSelection([(str(id), nimmgr.getNimDescription(id)) for id in nimmgr.getNimListOfType("DVB-S") if id != x])
1275 nim.simpleSingleSendDiSEqC = ConfigYesNo(False)
1276 nim.simpleDiSEqCSetVoltageTone = ConfigYesNo(True)
1277 nim.simpleDiSEqCOnlyOnSatChange = ConfigYesNo(False)
1278 nim.diseqcA = getConfigSatlist(192, diseqc_satlist_choices)
1279 nim.diseqcB = getConfigSatlist(130, diseqc_satlist_choices)
1280 nim.diseqcC = ConfigSatlist(list = diseqc_satlist_choices)
1281 nim.diseqcD = ConfigSatlist(list = diseqc_satlist_choices)
1282 nim.positionerMode = ConfigSelection(positioner_mode_choices, "usals")
1283 nim.longitude = ConfigFloat(default=[5,100], limits=[(0,359),(0,999)])
1284 nim.longitudeOrientation = ConfigSelection(longitude_orientation_choices, "east")
1285 nim.latitude = ConfigFloat(default=[50,767], limits=[(0,359),(0,999)])
1286 nim.latitudeOrientation = ConfigSelection(latitude_orientation_choices, "north")
1287 nim.powerMeasurement = ConfigYesNo(True)
1288 nim.powerThreshold = ConfigInteger(default=hw.get_device_name() == "dm8000" and 15 or 50, limits=(0, 100))
1289 nim.turningSpeed = ConfigSelection(turning_speed_choices, "fast")
1290 btime = datetime(1970, 1, 1, 7, 0);
1291 nim.fastTurningBegin = ConfigDateTime(default = mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 900)
1292 etime = datetime(1970, 1, 1, 19, 0);
1293 nim.fastTurningEnd = ConfigDateTime(default = mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 900)
1294 config_mode_choices = [ ("nothing", _("nothing connected")),
1295 ("simple", _("simple")), ("advanced", _("advanced"))]
1296 if len(nimmgr.getNimListOfType(slot.type, exception = x)) > 0:
1297 config_mode_choices.append(("equal", _("equal to")))
1298 config_mode_choices.append(("satposdepends", _("second cable of motorized LNB")))
1299 if len(nimmgr.canConnectTo(x)) > 0:
1300 config_mode_choices.append(("loopthrough", _("loopthrough to")))
1301 nim.advanced = ConfigNothing()
1302 tmp = ConfigSelection(config_mode_choices, "nothing")
1304 tmp.addNotifier(configModeChanged, initial_call = False)
1305 nim.configMode = tmp
1306 elif slot.isCompatible("DVB-C"):
1307 nim.configMode = ConfigSelection(
1309 "enabled": _("enabled"),
1310 "nothing": _("nothing connected"),
1312 default = "enabled")
1315 for x in nimmgr.cablesList:
1316 list.append((str(n), x[0]))
1318 nim.cable = ConfigSubsection()
1319 possible_scan_types = [("bands", _("Frequency bands")), ("steps", _("Frequency steps"))]
1321 possible_scan_types.append(("provider", _("Provider")))
1322 nim.cable.scan_provider = ConfigSelection(default = "0", choices = list)
1323 nim.cable.scan_type = ConfigSelection(default = "bands", choices = possible_scan_types)
1324 nim.cable.scan_band_EU_VHF_I = ConfigYesNo(default = True)
1325 nim.cable.scan_band_EU_MID = ConfigYesNo(default = True)
1326 nim.cable.scan_band_EU_VHF_III = ConfigYesNo(default = True)
1327 nim.cable.scan_band_EU_UHF_IV = ConfigYesNo(default = True)
1328 nim.cable.scan_band_EU_UHF_V = ConfigYesNo(default = True)
1329 nim.cable.scan_band_EU_SUPER = ConfigYesNo(default = True)
1330 nim.cable.scan_band_EU_HYPER = ConfigYesNo(default = True)
1331 nim.cable.scan_band_US_LOW = ConfigYesNo(default = False)
1332 nim.cable.scan_band_US_MID = ConfigYesNo(default = False)
1333 nim.cable.scan_band_US_HIGH = ConfigYesNo(default = False)
1334 nim.cable.scan_band_US_SUPER = ConfigYesNo(default = False)
1335 nim.cable.scan_band_US_HYPER = ConfigYesNo(default = False)
1336 nim.cable.scan_frequency_steps = ConfigInteger(default = 1000, limits = (1000, 10000))
1337 nim.cable.scan_mod_qam16 = ConfigYesNo(default = False)
1338 nim.cable.scan_mod_qam32 = ConfigYesNo(default = False)
1339 nim.cable.scan_mod_qam64 = ConfigYesNo(default = True)
1340 nim.cable.scan_mod_qam128 = ConfigYesNo(default = False)
1341 nim.cable.scan_mod_qam256 = ConfigYesNo(default = True)
1342 nim.cable.scan_sr_6900 = ConfigYesNo(default = True)
1343 nim.cable.scan_sr_6875 = ConfigYesNo(default = True)
1344 nim.cable.scan_sr_ext1 = ConfigInteger(default = 0, limits = (0, 7230))
1345 nim.cable.scan_sr_ext2 = ConfigInteger(default = 0, limits = (0, 7230))
1346 elif slot.isCompatible("DVB-T"):
1347 nim.configMode = ConfigSelection(
1349 "enabled": _("enabled"),
1350 "nothing": _("nothing connected"),
1352 default = "enabled")
1355 for x in nimmgr.terrestrialsList:
1356 list.append((str(n), x[0]))
1358 nim.terrestrial = ConfigSelection(choices = list)
1359 nim.terrestrial_5V = ConfigOnOff()
1362 nim.configMode = ConfigSelection(choices = { "nothing": _("disabled") }, default="nothing");
1363 if slot.type is not None:
1364 print "pls add support for this frontend type!", slot.type
1367 nimmgr.sec = SecConfigure(nimmgr)
1369 nimmanager = NimManager()