1 from config import config, ConfigSubsection, ConfigSelection, ConfigFloat, \
2 ConfigSatlist, ConfigYesNo, ConfigInteger, ConfigSubList, ConfigNothing, \
3 ConfigSubDict, ConfigOnOff, ConfigDateTime
5 from enigma import eDVBSatelliteEquipmentControl as secClass, \
6 eDVBSatelliteLNBParameters as lnbParam, \
7 eDVBSatelliteDiseqcParameters as diseqcParam, \
8 eDVBSatelliteSwitchParameters as switchParam, \
9 eDVBSatelliteRotorParameters as rotorParam, \
10 eDVBResourceManager, eDVBDB
12 from time import localtime, mktime
13 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):
45 tunermask = 1 << slotid
46 if self.equal.has_key(slotid):
47 for slot in self.equal[slotid]:
48 tunermask |= (1 << slot)
49 elif self.linked.has_key(slotid):
50 for slot in self.linked[slotid]:
51 tunermask |= (1 << slot)
52 sec.setLNBLOFL(9750000)
53 sec.setLNBLOFH(10600000)
54 sec.setLNBThreshold(11700000)
55 sec.setLNBIncreasedVoltage(lnbParam.OFF)
59 sec.setVoltageMode(switchParam.HV)
60 sec.setToneMode(switchParam.HILO)
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)
72 elif (diseqcmode == 3): # diseqc 1.2
73 if self.satposdepends.has_key(slotid):
74 tunermask |= (1 << self.satposdepends[slotid])
75 sec.setLatitude(latitude)
76 sec.setLaDirection(laDirection)
77 sec.setLongitude(longitude)
78 sec.setLoDirection(loDirection)
79 sec.setUseInputpower(useInputPower)
80 sec.setInputpowerDelta(inputPowerDelta)
81 sec.setRotorTurningSpeed(turningSpeed)
83 for x in self.NimManager.satList:
84 print "Add sat " + str(x[0])
85 self.addSatellite(sec, int(x[0]))
88 sec.setRotorPosNum(0) # USALS
90 sec.setLNBSlotMask(tunermask)
92 def setSatposDepends(self, sec, nim1, nim2):
93 print "tuner", nim1, "depends on satpos of", nim2
94 sec.setTunerDepends(nim1, nim2)
96 def linkNIMs(self, sec, nim1, nim2):
97 print "link tuner", nim1, "to tuner", nim2
98 sec.setTunerLinked(nim1, nim2)
100 def getRoot(self, slotid, connto):
102 while (self.NimManager.getNimConfig(connto).configMode.value in ["satposdepends", "equal", "loopthrough"]):
103 connto = int(self.NimManager.getNimConfig(connto).connectedTo.value)
104 if connto in visited: # prevent endless loop
106 visited.append(connto)
110 sec = secClass.getInstance()
111 self.configuredSatellites = Set()
112 sec.clear() ## this do unlinking NIMs too !!
113 print "sec config cleared"
116 self.satposdepends = { }
119 nim_slots = self.NimManager.nim_slots
123 for slot in nim_slots:
124 if slot.type is not None:
125 used_nim_slots.append((slot.slot, slot.description, slot.config.configMode.value != "nothing" and True or False))
126 eDVBResourceManager.getInstance().setFrontendSlotInformations(used_nim_slots)
128 for slot in nim_slots:
131 if slot.isCompatible("DVB-S"):
132 # save what nim we link to/are equal to/satposdepends to.
133 # this is stored in the *value* (not index!) of the config list
134 if nim.configMode.value == "equal":
135 connto = self.getRoot(x, int(nim.connectedTo.value))
136 if not self.equal.has_key(connto):
137 self.equal[connto] = []
138 self.equal[connto].append(x)
139 elif nim.configMode.value == "loopthrough":
140 self.linkNIMs(sec, x, int(nim.connectedTo.value))
141 connto = self.getRoot(x, int(nim.connectedTo.value))
142 if not self.linked.has_key(connto):
143 self.linked[connto] = []
144 self.linked[connto].append(x)
145 elif nim.configMode.value == "satposdepends":
146 self.setSatposDepends(sec, x, int(nim.connectedTo.value))
147 connto = self.getRoot(x, int(nim.connectedTo.value))
148 if not self.satposdepends.has_key(connto):
149 self.satposdepends[connto] = []
150 self.satposdepends[connto].append(x)
153 for slot in nim_slots:
156 if slot.isCompatible("DVB-S"):
157 print "slot: " + str(x) + " configmode: " + str(nim.configMode.value)
158 print "diseqcmode: ", nim.diseqcMode.value
159 if nim.configMode.value in [ "loopthrough", "satposdepends", "nothing" ]:
162 sec.setSlotNotLinked(x)
163 if nim.configMode.value == "equal":
165 elif nim.configMode.value == "simple": #simple config
166 if nim.diseqcMode.value == "single": #single
167 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.NONE, diseqcpos = diseqcParam.SENDNO)
168 elif nim.diseqcMode.value == "toneburst_a_b": #Toneburst A/B
169 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.A, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO)
170 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.B, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO)
171 elif nim.diseqcMode.value == "diseqc_a_b": #DiSEqC A/B
172 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA)
173 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB)
174 elif nim.diseqcMode.value == "diseqc_a_b_c_d": #DiSEqC A/B/C/D
175 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA)
176 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB)
177 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcC.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BA)
178 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcD.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BB)
179 elif nim.diseqcMode.value == "positioner": #Positioner
180 if nim.latitudeOrientation.value == "north":
181 laValue = rotorParam.NORTH
183 laValue = rotorParam.SOUTH
184 if nim.longitudeOrientation.value == "east":
185 loValue = rotorParam.EAST
187 loValue = rotorParam.WEST
191 if nim.powerMeasurement.value:
193 inputPowerDelta=nim.powerThreshold.value
194 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
195 if turn_speed_dict.has_key(nim.turningSpeed.value):
196 turning_speed = turn_speed_dict[nim.turningSpeed.value]
198 beg_time = localtime(nim.fastTurningBegin.value)
199 end_time = localtime(nim.fastTurningEnd.value)
200 turning_speed = ((beg_time.tm_hour+1) * 60 + beg_time.tm_min + 1) << 16
201 turning_speed |= (end_time.tm_hour+1) * 60 + end_time.tm_min + 1
202 self.addLNBSimple(sec, slotid = x, diseqcmode = 3,
203 longitude = nim.longitude.float,
204 loDirection = loValue,
205 latitude = nim.latitude.float,
206 laDirection = laValue,
207 turningSpeed = turning_speed,
208 useInputPower = useInputPower,
209 inputPowerDelta = inputPowerDelta)
210 elif nim.configMode.value == "advanced": #advanced config
211 self.updateAdvanced(sec, x)
212 print "sec config completed"
214 def updateAdvanced(self, sec, slotid):
216 for x in range(1,33):
218 for x in self.NimManager.satList:
219 lnb = int(config.Nims[slotid].advanced.sat[x[0]].lnb.value)
221 print "add", x[0], "to", lnb
222 lnbSat[lnb].append(x[0])
223 for x in range(1,33):
224 if len(lnbSat[x]) > 0:
225 currLnb = config.Nims[slotid].advanced.lnb[x]
228 tunermask = 1 << slotid
229 if self.equal.has_key(slotid):
230 tunermask |= (1 << self.equal[slotid])
231 elif self.linked.has_key(slotid):
232 tunermask |= (1 << self.linked[slotid])
234 if currLnb.lof.value == "universal_lnb":
235 sec.setLNBLOFL(9750000)
236 sec.setLNBLOFH(10600000)
237 sec.setLNBThreshold(11700000)
238 elif currLnb.lof.value == "c_band":
239 sec.setLNBLOFL(5150000)
240 sec.setLNBLOFH(5150000)
241 sec.setLNBThreshold(5150000)
242 elif currLnb.lof.value == "user_defined":
243 sec.setLNBLOFL(currLnb.lofl.value * 1000)
244 sec.setLNBLOFH(currLnb.lofh.value * 1000)
245 sec.setLNBThreshold(currLnb.threshold.value * 1000)
247 # if currLnb.output_12v.value == "0V":
248 # pass # nyi in drivers
249 # elif currLnb.output_12v.value == "12V":
250 # pass # nyi in drivers
252 if currLnb.increased_voltage.value:
253 sec.setLNBIncreasedVoltage(lnbParam.ON)
255 sec.setLNBIncreasedVoltage(lnbParam.OFF)
257 dm = currLnb.diseqcMode.value
259 sec.setDiSEqCMode(diseqcParam.NONE)
261 sec.setDiSEqCMode(diseqcParam.V1_0)
263 sec.setDiSEqCMode(diseqcParam.V1_1)
265 sec.setDiSEqCMode(diseqcParam.V1_2)
267 if self.satposdepends.has_key(slotid): # only useable with rotors
268 tunermask |= (1 << self.satposdepends[slotid])
271 if currLnb.toneburst.value == "none":
272 sec.setToneburst(diseqcParam.NO)
273 elif currLnb.toneburst.value == "A":
274 sec.setToneburst(diseqcParam.A)
275 elif currLnb.toneburst.value == "B":
276 sec.setToneburst(diseqcParam.B)
278 # Committed Diseqc Command
279 cdc = currLnb.commitedDiseqcCommand.value
281 c = { "none": diseqcParam.SENDNO,
282 "AA": diseqcParam.AA,
283 "AB": diseqcParam.AB,
284 "BA": diseqcParam.BA,
285 "BB": diseqcParam.BB }
288 sec.setCommittedCommand(c[cdc])
290 sec.setCommittedCommand(long(cdc))
292 sec.setFastDiSEqC(currLnb.fastDiseqc.value)
294 sec.setSeqRepeat(currLnb.sequenceRepeat.value)
296 if currLnb.diseqcMode.value == "1_0":
297 currCO = currLnb.commandOrder1_0.value
299 currCO = currLnb.commandOrder.value
301 udc = int(currLnb.uncommittedDiseqcCommand.value)
303 sec.setUncommittedCommand(0xF0|(udc-1))
305 sec.setUncommittedCommand(0) # SENDNO
307 sec.setRepeats({"none": 0, "one": 1, "two": 2, "three": 3}[currLnb.diseqcRepeats.value])
309 setCommandOrder = False
311 # 0 "committed, toneburst",
312 # 1 "toneburst, committed",
313 # 2 "committed, uncommitted, toneburst",
314 # 3 "toneburst, committed, uncommitted",
315 # 4 "uncommitted, committed, toneburst"
316 # 5 "toneburst, uncommitted, commmitted"
317 order_map = {"ct": 0, "tc": 1, "cut": 2, "tcu": 3, "uct": 4, "tuc": 5}
318 sec.setCommandOrder(order_map[currCO])
321 latitude = currLnb.latitude.float
322 sec.setLatitude(latitude)
323 longitude = currLnb.longitude.float
324 sec.setLongitude(longitude)
325 if currLnb.latitudeOrientation.value == "north":
326 sec.setLaDirection(rotorParam.NORTH)
328 sec.setLaDirection(rotorParam.SOUTH)
329 if currLnb.longitudeOrientation.value == "east":
330 sec.setLoDirection(rotorParam.EAST)
332 sec.setLoDirection(rotorParam.WEST)
334 if currLnb.powerMeasurement.value:
335 sec.setUseInputpower(True)
336 sec.setInputpowerDelta(currLnb.powerThreshold.value)
337 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
338 if turn_speed_dict.has_key(currLnb.turningSpeed.value):
339 turning_speed = turn_speed_dict[currLnb.turningSpeed.value]
341 beg_time = localtime(currLnb.fastTurningBegin.value)
342 end_time = localtime(currLnb.fastTurningEnd.value)
343 turning_speed = ((beg_time.tm_hour + 1) * 60 + beg_time.tm_min + 1) << 16
344 turning_speed |= (end_time.tm_hour + 1) * 60 + end_time.tm_min + 1
345 sec.setRotorTurningSpeed(turning_speed)
347 sec.setUseInputpower(False)
349 sec.setLNBSlotMask(tunermask)
351 # finally add the orbital positions
353 self.addSatellite(sec, y)
354 currSat = config.Nims[slotid].advanced.sat[y]
356 if currSat.voltage.value == "polarization":
357 sec.setVoltageMode(switchParam.HV)
358 elif currSat.voltage.value == "13V":
359 sec.setVoltageMode(switchParam._14V)
360 elif currSat.voltage.value == "18V":
361 sec.setVoltageMode(switchParam._18V)
363 if currSat.tonemode == "band":
364 sec.setToneMode(switchParam.HILO)
365 elif currSat.tonemode == "on":
366 sec.setToneMode(switchParam.ON)
367 elif currSat.tonemode == "off":
368 sec.setToneMode(switchParam.OFF)
370 if not currSat.usals.value:
371 sec.setRotorPosNum(currSat.rotorposition.value)
373 sec.setRotorPosNum(0) #USALS
375 def __init__(self, nimmgr):
376 self.NimManager = nimmgr
377 self.configuredSatellites = Set()
381 def __init__(self, slot, type, description, has_outputs = True, internally_connectable = None):
384 if type not in ["DVB-S", "DVB-C", "DVB-T", "DVB-S2", None]:
385 print "warning: unknown NIM type %s, not using." % type
389 self.description = description
390 self.has_outputs = has_outputs
391 self.internally_connectable = internally_connectable
393 def isCompatible(self, what):
396 "DVB-S": ["DVB-S", None],
397 "DVB-C": ["DVB-C", None],
398 "DVB-T": ["DVB-T", None],
399 "DVB-S2": ["DVB-S", "DVB-S2", None]
401 return what in compatible[self.type]
403 def connectableTo(self):
405 "DVB-S": ["DVB-S", "DVB-S2"],
408 "DVB-S2": ["DVB-S", "DVB-S2"]
410 return connectable[self.type]
412 def getSlotName(self):
413 # get a friendly description for a slot name.
414 # we name them "Tuner A/B/C/...", because that's what's usually written on the back
416 return _("Tuner ") + chr(ord('A') + self.slot)
418 slot_name = property(getSlotName)
421 return chr(ord('A') + self.slot)
423 def hasOutputs(self):
424 return self.has_outputs
426 def internallyConnectableTo(self):
427 return self.internally_connectable
429 slot_id = property(getSlotID)
431 def getFriendlyType(self):
440 friendly_type = property(getFriendlyType)
442 def getFriendlyFullDescription(self):
443 nim_text = self.slot_name + ": "
446 nim_text += _("(empty)")
448 nim_text += self.description + " (" + self.friendly_type + ")"
452 friendly_full_description = property(getFriendlyFullDescription)
453 config_mode = property(lambda self: config.Nims[self.slot].configMode.value)
454 config = property(lambda self: config.Nims[self.slot])
455 empty = property(lambda self: self.type is None)
458 def getConfiguredSats(self):
459 return self.sec.getConfiguredSats()
461 def getTransponders(self, pos):
462 if self.transponders.has_key(pos):
463 return self.transponders[pos]
467 def getTranspondersCable(self, nim):
468 nimConfig = config.Nims[nim]
469 if nimConfig.configMode.value != "nothing" and nimConfig.cable.scan_type.value == "provider":
470 return self.transponderscable[self.cablesList[nimConfig.cable.scan_provider.index][0]]
473 def getTranspondersTerrestrial(self, region):
474 return self.transpondersterrestrial[region]
476 def getCableDescription(self, nim):
477 return self.cablesList[config.Nims[nim].scan_provider.index][0]
479 def getCableFlags(self, nim):
480 return self.cablesList[config.Nims[nim].scan_provider.index][1]
482 def getTerrestrialDescription(self, nim):
483 return self.terrestrialsList[config.Nims[nim].terrestrial.index][0]
485 def getTerrestrialFlags(self, nim):
486 return self.terrestrialsList[config.Nims[nim].terrestrial.index][1]
488 def getSatDescription(self, pos):
489 return self.satellites[pos]
491 def readTransponders(self):
492 # read initial networks from file. we only read files which we are interested in,
493 # which means only these where a compatible tuner exists.
494 self.satellites = { }
495 self.transponders = { }
496 self.transponderscable = { }
497 self.transpondersterrestrial = { }
498 db = eDVBDB.getInstance()
499 if self.hasNimType("DVB-S"):
500 print "Reading satellites.xml"
501 db.readSatellites(self.satList, self.satellites, self.transponders)
502 # print "SATLIST", self.satList
503 # print "SATS", self.satellites
504 # print "TRANSPONDERS", self.transponders
506 if self.hasNimType("DVB-C"):
507 print "Reading cables.xml"
508 db.readCables(self.cablesList, self.transponderscable)
509 # print "CABLIST", self.cablesList
510 # print "TRANSPONDERS", self.transponders
512 if self.hasNimType("DVB-T"):
513 print "Reading terrestrial.xml"
514 db.readTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
515 # print "TERLIST", self.terrestrialsList
516 # print "TRANSPONDERS", self.transpondersterrestrial
518 def enumerateNIMs(self):
519 # enum available NIMs. This is currently very dreambox-centric and uses the /proc/bus/nim_sockets interface.
520 # the result will be stored into nim_slots.
521 # the content of /proc/bus/nim_sockets looks like:
524 # Name: BCM4501 DVB-S2 NIM (internal)
527 # Name: BCM4501 DVB-S2 NIM (internal)
530 # Name: Philips TU1216
533 # Name: Alps BSBE1 702A
536 # Type will be either "DVB-S", "DVB-S2", "DVB-T", "DVB-C" or None.
538 # nim_slots is an array which has exactly one entry for each slot, even for empty ones.
541 nimfile = tryOpen("/proc/bus/nim_sockets")
549 for line in nimfile.readlines():
552 if line.strip().startswith("NIM Socket"):
553 parts = line.strip().split(" ")
554 current_slot = int(parts[2][:-1])
555 entries[current_slot] = {}
556 elif line.strip().startswith("Type:"):
557 entries[current_slot]["type"] = str(line.strip()[6:])
558 elif line.strip().startswith("Name:"):
559 entries[current_slot]["name"] = str(line.strip()[6:])
560 elif line.strip().startswith("Has_Outputs:"):
561 input = str(line.strip()[len("Has_Outputs:") + 1:])
562 entries[current_slot]["has_outputs"] = (input == "yes")
563 elif line.strip().startswith("Internally_Connectable:"):
564 input = int(line.strip()[len("Internally_Connectable:") + 1:])
565 entries[current_slot]["internally_connectable"] = input
566 elif line.strip().startswith("empty"):
567 entries[current_slot]["type"] = None
568 entries[current_slot]["name"] = _("N/A")
571 for id, entry in entries.items():
572 if not (entry.has_key("name") and entry.has_key("type")):
573 entry["name"] = _("N/A")
575 if not (entry.has_key("has_outputs")):
576 entry["has_outputs"] = True
577 if not (entry.has_key("internally_connectable")):
578 entry["internally_connectable"] = None
579 self.nim_slots.append(NIM(slot = id, description = entry["name"], type = entry["type"], has_outputs = entry["has_outputs"], internally_connectable = entry["internally_connectable"]))
581 def hasNimType(self, chktype):
582 for slot in self.nim_slots:
583 if slot.isCompatible(chktype):
587 def getNimType(self, slotid):
588 return self.nim_slots[slotid].type
590 def getNimDescription(self, slotid):
591 return self.nim_slots[slotid].friendly_full_description
593 def getNimListOfType(self, type, exception = -1):
594 # returns a list of indexes for NIMs compatible to the given type, except for 'exception'
596 for x in self.nim_slots:
597 if x.isCompatible(type) and x.slot != exception:
604 self.terrestrialsList = []
606 self.readTransponders()
607 InitNimManager(self) #init config stuff
609 # get a list with the friendly full description
612 for slot in self.nim_slots:
613 list.append(slot.friendly_full_description)
616 def getSlotCount(self):
617 return len(self.nim_slots)
619 def hasOutputs(self, slotid):
620 return self.nim_slots[slotid].hasOutputs()
622 def canConnectTo(self, slotid):
624 if self.nim_slots[slotid].internallyConnectableTo() is not None:
625 slots.append(self.nim_slots[slotid].internallyConnectableTo())
626 for type in self.nim_slots[slotid].connectableTo():
627 for slot in self.getNimListOfType(type, exception = slotid):
628 # FIXME we restrict loopthrough from dvb-s2 to dvb-s, because the c++ part can't handle it
629 if not (type == "DVB-S" and self.getNimType(slot)):
630 if self.hasOutputs(slot):
636 def canEqualTo(self, slotid):
637 type = self.getNimType(slotid)
638 if self.getNimConfig(slotid) == "DVB-S2":
640 nimList = self.getNimListOfType(type, slotid)
641 for nim in nimList[:]:
642 mode = self.getNimConfig(nim)
643 if mode.configMode.value == "loopthrough" or mode.configMode.value == "satposdepends":
647 def canDependOn(self, slotid):
648 type = self.getNimType(slotid)
649 if self.getNimConfig(slotid) == "DVB-S2":
651 nimList = self.getNimListOfType(type, slotid)
653 for nim in nimList[:]:
654 mode = self.getNimConfig(nim)
655 if mode.configMode.value == "simple" and mode.diseqcMode.value == "positioner":
656 alreadyConnected = False
657 for testnim in nimList:
658 testmode = self.getNimConfig(testnim)
659 if testmode.configMode.value == "satposdepends" and int(testmode.connectedTo.value) == int(nim):
660 alreadyConnected = True
662 if not alreadyConnected:
663 positionerList.append(nim)
664 return positionerList
666 def getNimConfig(self, slotid):
667 return config.Nims[slotid]
669 def getSatList(self):
672 def getSatListForNim(self, slotid):
674 if self.nim_slots[slotid].isCompatible("DVB-S"):
675 #print "slotid:", slotid
677 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.index]
678 #print "diseqcA:", config.Nims[slotid].diseqcA.value
679 configMode = config.Nims[slotid].configMode.value
681 if configMode == "equal":
682 slotid=0 #FIXME add handling for more than two tuners !!!
683 configMode = config.Nims[slotid].configMode.value
685 if configMode == "simple":
686 dm = config.Nims[slotid].diseqcMode.value
687 if dm in ["single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
688 list.append(self.satList[config.Nims[slotid].diseqcA.index])
689 if dm in ["toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
690 list.append(self.satList[config.Nims[slotid].diseqcB.index])
691 if dm == "diseqc_a_b_c_d":
692 list.append(self.satList[config.Nims[slotid].diseqcC.index])
693 list.append(self.satList[config.Nims[slotid].diseqcD.index])
694 if dm == "positioner":
695 for x in self.satList:
697 elif configMode == "advanced":
698 for x in self.satList:
699 if int(config.Nims[slotid].advanced.sat[x[0]].lnb.value) != 0:
704 def getRotorSatListForNim(self, slotid):
706 if self.nim_slots[slotid].isCompatible("DVB-S"):
707 #print "slotid:", slotid
709 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
710 #print "diseqcA:", config.Nims[slotid].diseqcA.value
711 configMode = config.Nims[slotid].configMode.value
712 if configMode == "simple":
713 if config.Nims[slotid].diseqcMode.value == "positioner":
714 for x in self.satList:
716 elif configMode == "advanced":
717 for x in self.satList:
718 nim = config.Nims[slotid]
719 lnbnum = int(nim.advanced.sat[x[0]].lnb.value)
721 lnb = nim.advanced.lnb[lnbnum]
722 if lnb.diseqcMode.value == "1_2":
727 config.sec = ConfigSubsection()
729 x = ConfigInteger(default=15, limits = (0, 9999))
730 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_CONT_TONE, configElement.value))
731 config.sec.delay_after_continuous_tone_change = x
733 x = ConfigInteger(default=10, limits = (0, 9999))
734 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_VOLTAGE_CHANGE, configElement.value))
735 config.sec.delay_after_final_voltage_change = x
737 x = ConfigInteger(default=120, limits = (0, 9999))
738 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_DISEQC_REPEATS, configElement.value))
739 config.sec.delay_between_diseqc_repeats = x
741 x = ConfigInteger(default=50, limits = (0, 9999))
742 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_LAST_DISEQC_CMD, configElement.value))
743 config.sec.delay_after_last_diseqc_command = x
745 x = ConfigInteger(default=50, limits = (0, 9999))
746 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value))
747 config.sec.delay_after_toneburst = x
749 x = ConfigInteger(default=200, limits = (0, 9999))
750 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS, configElement.value))
751 config.sec.delay_after_enable_voltage_before_switch_command = x
753 x = ConfigInteger(default=700, limits = (0, 9999))
754 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_SWITCH_AND_MOTOR_CMD, configElement.value))
755 config.sec.delay_between_switch_and_motor_command = x
757 x = ConfigInteger(default=150, limits = (0, 9999))
758 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MEASURE_IDLE_INPUTPOWER, configElement.value))
759 config.sec.delay_after_voltage_change_before_measure_idle_inputpower = x
761 x = ConfigInteger(default=750, limits = (0, 9999))
762 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_MOTOR_CMD, configElement.value))
763 config.sec.delay_after_enable_voltage_before_motor_command = x
765 x = ConfigInteger(default=150, limits = (0, 9999))
766 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_MOTOR_STOP_CMD, configElement.value))
767 config.sec.delay_after_motor_stop_command = x
769 x = ConfigInteger(default=150, limits = (0, 9999))
770 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MOTOR_CMD, configElement.value))
771 config.sec.delay_after_voltage_change_before_motor_command = x
773 x = ConfigInteger(default=360, limits = (0, 9999))
774 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_RUNNING_TIMEOUT, configElement.value))
775 config.sec.motor_running_timeout = x
777 x = ConfigInteger(default=1, limits = (0, 5))
778 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_COMMAND_RETRIES, configElement.value))
779 config.sec.motor_command_retries = x
781 x = ConfigInteger(default=20, limits = (0, 9999))
782 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS, configElement.value))
783 config.sec.delay_after_change_voltage_before_switch_command = x
785 # TODO add support for satpos depending nims to advanced nim configuration
786 # so a second/third/fourth cable from a motorized lnb can used behind a
787 # diseqc 1.0 / diseqc 1.1 / toneburst switch
788 # the C(++) part should can handle this
789 # the configElement should be only visible when diseqc 1.2 is disabled
791 def InitNimManager(nimmgr):
794 config.Nims = ConfigSubList()
795 for x in range(len(nimmgr.nim_slots)):
796 config.Nims.append(ConfigSubsection())
798 for slot in nimmgr.nim_slots:
802 if slot.isCompatible("DVB-S"):
803 choices = { "nothing": _("nothing connected"),
804 "simple": _("simple"),
805 "advanced": _("advanced")}
806 if len(nimmgr.getNimListOfType(slot.type, exception = x)) > 0:
807 choices["equal"] = _("equal to")
808 choices["satposdepends"] = _("second cable of motorized LNB")
809 if len(nimmgr.canConnectTo(x)) > 0:
810 choices["loopthrough"] = _("loopthrough to")
811 nim.configMode = ConfigSelection(choices = choices, default = "nothing")
813 #important - check if just the 2nd one is LT only and the first one is DVB-S
814 # CHECKME: is this logic correct for >2 slots?
815 # if nim.configMode.value in ["loopthrough", "satposdepends", "equal"]:
816 # if x == 0: # first one can never be linked to anything
818 # nim.configMode.value = "simple"
819 # nim.configMode.save()
821 #FIXME: make it better
822 for y in nimmgr.nim_slots:
824 if not y.isCompatible("DVB-S"):
826 nim.configMode.value = "simple"
827 nim.configMode.save()
829 nim.diseqcMode = ConfigSelection(
831 ("single", _("Single")),
832 ("toneburst_a_b", _("Toneburst A/B")),
833 ("diseqc_a_b", _("DiSEqC A/B")),
834 ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")),
835 ("positioner", _("Positioner"))],
836 default = "diseqc_a_b")
839 for id in nimmgr.getNimListOfType("DVB-S"):
841 choices.append((str(id), nimmgr.getNimDescription(id)))
842 nim.connectedTo = ConfigSelection(choices = choices)
843 nim.diseqcA = getConfigSatlist(192, nimmgr.satList)
844 nim.diseqcB = getConfigSatlist(130, nimmgr.satList)
845 nim.diseqcC = ConfigSatlist(list = nimmgr.satList)
846 nim.diseqcD = ConfigSatlist(list = nimmgr.satList)
847 nim.positionerMode = ConfigSelection(
849 ("usals", _("USALS")),
850 ("manual", _("manual"))],
852 nim.longitude = ConfigFloat(default=[5,100], limits=[(0,359),(0,999)])
853 nim.longitudeOrientation = ConfigSelection(choices={"east": _("East"), "west": _("West")}, default = "east")
854 nim.latitude = ConfigFloat(default=[50,767], limits=[(0,359),(0,999)])
855 nim.latitudeOrientation = ConfigSelection(choices={"north": _("North"), "south": _("South")}, default="north")
856 nim.powerMeasurement = ConfigYesNo(default=True)
857 nim.powerThreshold = ConfigInteger(default=50, limits=(0, 100))
858 nim.turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch")) ], default = "fast")
859 btime = datetime(1970, 1, 1, 7, 0);
860 nim.fastTurningBegin = ConfigDateTime(default = mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 900)
861 etime = datetime(1970, 1, 1, 19, 0);
862 nim.fastTurningEnd = ConfigDateTime(default = mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 900)
865 nim.advanced = ConfigSubsection()
866 nim.advanced.sats = getConfigSatlist(192,nimmgr.satList)
867 nim.advanced.sat = ConfigSubDict()
868 lnbs = [("0", "not available")]
869 for y in range(1, 33):
870 lnbs.append((str(y), "LNB " + str(y)))
872 for x in nimmgr.satList:
873 nim.advanced.sat[x[0]] = ConfigSubsection()
874 nim.advanced.sat[x[0]].voltage = ConfigSelection(choices={"polarization": _("Polarization"), "13V": _("13 V"), "18V": _("18 V")}, default = "polarization")
875 nim.advanced.sat[x[0]].tonemode = ConfigSelection(choices={"band": _("Band"), "on": _("On"), "off": _("Off")}, default = "band")
876 nim.advanced.sat[x[0]].usals = ConfigYesNo(default=True)
877 nim.advanced.sat[x[0]].rotorposition = ConfigInteger(default=1, limits=(1, 255))
878 nim.advanced.sat[x[0]].lnb = ConfigSelection(choices = lnbs)
880 csw = [("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))]
881 for y in range(0, 16):
882 csw.append((str(0xF0|y), "Input " + str(y+1)))
884 ucsw = [("0", _("None"))]
885 for y in range(1, 17):
886 ucsw.append((str(y), "Input " + str(y)))
888 nim.advanced.lnb = ConfigSubList()
889 nim.advanced.lnb.append(ConfigNothing())
890 for x in range(1, 33):
891 nim.advanced.lnb.append(ConfigSubsection())
892 nim.advanced.lnb[x].lof = ConfigSelection(choices={"universal_lnb": _("Universal LNB"), "c_band": _("C-Band"), "user_defined": _("User defined")}, default="universal_lnb")
893 nim.advanced.lnb[x].lofl = ConfigInteger(default=9750, limits = (0, 99999))
894 nim.advanced.lnb[x].lofh = ConfigInteger(default=10600, limits = (0, 99999))
895 nim.advanced.lnb[x].threshold = ConfigInteger(default=11700, limits = (0, 99999))
896 # nim.advanced.lnb[x].output_12v = ConfigSelection(choices = [("0V", _("0 V")), ("12V", _("12 V"))], default="0V")
897 nim.advanced.lnb[x].increased_voltage = ConfigYesNo(default=False)
898 nim.advanced.lnb[x].toneburst = ConfigSelection(choices = [("none", _("None")), ("A", _("A")), ("B", _("B"))], default = "none")
899 nim.advanced.lnb[x].diseqcMode = ConfigSelection(choices = [("none", _("None")), ("1_0", _("1.0")), ("1_1", _("1.1")), ("1_2", _("1.2"))], default = "none")
900 nim.advanced.lnb[x].commitedDiseqcCommand = ConfigSelection(choices = csw)
901 nim.advanced.lnb[x].fastDiseqc = ConfigYesNo(default=False)
902 nim.advanced.lnb[x].sequenceRepeat = ConfigYesNo(default=False)
903 nim.advanced.lnb[x].commandOrder1_0 = ConfigSelection(choices = [("ct", "committed, toneburst"), ("tc", "toneburst, committed")], default = "ct")
904 nim.advanced.lnb[x].commandOrder = ConfigSelection(choices = [
905 ("ct", "committed, toneburst"),
906 ("tc", "toneburst, committed"),
907 ("cut", "committed, uncommitted, toneburst"),
908 ("tcu", "toneburst, committed, uncommitted"),
909 ("uct", "uncommitted, committed, toneburst"),
910 ("tuc", "toneburst, uncommitted, commmitted")],
912 nim.advanced.lnb[x].uncommittedDiseqcCommand = ConfigSelection(choices = ucsw)
913 nim.advanced.lnb[x].diseqcRepeats = ConfigSelection(choices = [("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))], default = "none")
914 nim.advanced.lnb[x].longitude = ConfigFloat(default = [5,100], limits = [(0,359),(0,999)])
915 nim.advanced.lnb[x].longitudeOrientation = ConfigSelection(choices = [("east", _("East")), ("west", _("West"))], default = "east")
916 nim.advanced.lnb[x].latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)])
917 nim.advanced.lnb[x].latitudeOrientation = ConfigSelection(choices = [("north", _("North")), ("south", _("South"))], default = "north")
918 nim.advanced.lnb[x].powerMeasurement = ConfigYesNo(default=True)
919 nim.advanced.lnb[x].powerThreshold = ConfigInteger(default=50, limits=(0, 100))
920 nim.advanced.lnb[x].turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch"))], default = "fast")
921 btime = datetime(1970, 1, 1, 7, 0);
922 nim.advanced.lnb[x].fastTurningBegin = ConfigDateTime(default=mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 600)
923 etime = datetime(1970, 1, 1, 19, 0);
924 nim.advanced.lnb[x].fastTurningEnd = ConfigDateTime(default=mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 600)
925 elif slot.isCompatible("DVB-C"):
926 nim.configMode = ConfigSelection(
928 "enabled": _("enabled"),
929 "nothing": _("nothing connected"),
934 for x in nimmgr.cablesList:
935 list.append((str(n), x[0]))
937 nim.cable = ConfigSubsection()
938 possible_scan_types = [("bands", _("Frequency bands")), ("steps", _("Frequency steps"))]
940 possible_scan_types.append(("provider", _("Provider")))
941 nim.cable.scan_provider = ConfigSelection(default = "0", choices = list)
942 nim.cable.scan_type = ConfigSelection(default = "bands", choices = possible_scan_types)
943 nim.cable.scan_band_EU_VHF_I = ConfigYesNo(default = True)
944 nim.cable.scan_band_EU_MID = ConfigYesNo(default = True)
945 nim.cable.scan_band_EU_VHF_III = ConfigYesNo(default = True)
946 nim.cable.scan_band_EU_UHF_IV = ConfigYesNo(default = True)
947 nim.cable.scan_band_EU_UHF_V = ConfigYesNo(default = True)
948 nim.cable.scan_band_EU_SUPER = ConfigYesNo(default = True)
949 nim.cable.scan_band_EU_HYPER = ConfigYesNo(default = True)
950 nim.cable.scan_band_US_LOW = ConfigYesNo(default = False)
951 nim.cable.scan_band_US_MID = ConfigYesNo(default = False)
952 nim.cable.scan_band_US_HIGH = ConfigYesNo(default = False)
953 nim.cable.scan_band_US_SUPER = ConfigYesNo(default = False)
954 nim.cable.scan_band_US_HYPER = ConfigYesNo(default = False)
955 nim.cable.scan_frequency_steps = ConfigInteger(default = 1000, limits = (1000, 10000))
956 nim.cable.scan_mod_qam16 = ConfigYesNo(default = False)
957 nim.cable.scan_mod_qam32 = ConfigYesNo(default = False)
958 nim.cable.scan_mod_qam64 = ConfigYesNo(default = True)
959 nim.cable.scan_mod_qam128 = ConfigYesNo(default = False)
960 nim.cable.scan_mod_qam256 = ConfigYesNo(default = True)
961 nim.cable.scan_sr_6900 = ConfigYesNo(default = True)
962 nim.cable.scan_sr_6875 = ConfigYesNo(default = True)
963 nim.cable.scan_sr_ext1 = ConfigInteger(default = 0, limits = (0, 7230))
964 nim.cable.scan_sr_ext2 = ConfigInteger(default = 0, limits = (0, 7230))
965 elif slot.isCompatible("DVB-T"):
966 nim.configMode = ConfigSelection(
968 "enabled": _("enabled"),
969 "nothing": _("nothing connected"),
974 for x in nimmgr.terrestrialsList:
975 list.append((str(n), x[0]))
977 nim.terrestrial = ConfigSelection(choices = list)
978 nim.terrestrial_5V = ConfigOnOff()
980 nim.configMode = ConfigSelection(choices = { "nothing": _("disabled") }, default="nothing");
981 print "pls add support for this frontend type!"
984 nimmgr.sec = SecConfigure(nimmgr)
986 nimmanager = NimManager()