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 for slot in self.satposdepends[slotid]:
75 tunermask |= (1 << slot)
76 sec.setLatitude(latitude)
77 sec.setLaDirection(laDirection)
78 sec.setLongitude(longitude)
79 sec.setLoDirection(loDirection)
80 sec.setUseInputpower(useInputPower)
81 sec.setInputpowerDelta(inputPowerDelta)
82 sec.setRotorTurningSpeed(turningSpeed)
84 for x in self.NimManager.satList:
85 print "Add sat " + str(x[0])
86 self.addSatellite(sec, int(x[0]))
87 sec.setVoltageMode(switchParam.HV)
88 sec.setToneMode(switchParam.HILO)
89 sec.setRotorPosNum(0) # USALS
91 sec.setLNBSlotMask(tunermask)
93 def setSatposDepends(self, sec, nim1, nim2):
94 print "tuner", nim1, "depends on satpos of", nim2
95 sec.setTunerDepends(nim1, nim2)
97 def linkNIMs(self, sec, nim1, nim2):
98 print "link tuner", nim1, "to tuner", nim2
99 sec.setTunerLinked(nim1, nim2)
101 def getRoot(self, slotid, connto):
103 while (self.NimManager.getNimConfig(connto).configMode.value in ["satposdepends", "equal", "loopthrough"]):
104 connto = int(self.NimManager.getNimConfig(connto).connectedTo.value)
105 if connto in visited: # prevent endless loop
107 visited.append(connto)
111 sec = secClass.getInstance()
112 self.configuredSatellites = Set()
113 sec.clear() ## this do unlinking NIMs too !!
114 print "sec config cleared"
117 self.satposdepends = { }
120 nim_slots = self.NimManager.nim_slots
124 for slot in nim_slots:
125 if slot.type is not None:
126 used_nim_slots.append((slot.slot, slot.description, slot.config.configMode.value != "nothing" and True or False, slot.isCompatible("DVB-S2")))
127 eDVBResourceManager.getInstance().setFrontendSlotInformations(used_nim_slots)
129 for slot in nim_slots:
132 if slot.isCompatible("DVB-S"):
133 # save what nim we link to/are equal to/satposdepends to.
134 # this is stored in the *value* (not index!) of the config list
135 if nim.configMode.value == "equal":
136 connto = self.getRoot(x, int(nim.connectedTo.value))
137 if not self.equal.has_key(connto):
138 self.equal[connto] = []
139 self.equal[connto].append(x)
140 elif nim.configMode.value == "loopthrough":
141 self.linkNIMs(sec, x, int(nim.connectedTo.value))
142 connto = self.getRoot(x, int(nim.connectedTo.value))
143 if not self.linked.has_key(connto):
144 self.linked[connto] = []
145 self.linked[connto].append(x)
146 elif nim.configMode.value == "satposdepends":
147 self.setSatposDepends(sec, x, int(nim.connectedTo.value))
148 connto = self.getRoot(x, int(nim.connectedTo.value))
149 if not self.satposdepends.has_key(connto):
150 self.satposdepends[connto] = []
151 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 if nim.configMode.value in [ "loopthrough", "satposdepends", "nothing" ]:
161 sec.setSlotNotLinked(x)
162 if nim.configMode.value == "equal":
164 elif nim.configMode.value == "simple": #simple config
165 print "diseqcmode: ", nim.diseqcMode.value
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,37):
219 #wildcard for all satellites ( for rotor )
220 for x in range(3601, 3605):
221 lnb = int(config.Nims[slotid].advanced.sat[x].lnb.value)
223 for x in self.NimManager.satList:
224 print "add", x[0], "to", lnb
225 lnbSat[lnb].append(x[0])
227 for x in self.NimManager.satList:
228 lnb = int(config.Nims[slotid].advanced.sat[x[0]].lnb.value)
230 print "add", x[0], "to", lnb
231 lnbSat[lnb].append(x[0])
233 for x in range(1,37):
234 if len(lnbSat[x]) > 0:
235 currLnb = config.Nims[slotid].advanced.lnb[x]
238 tunermask = 1 << slotid
239 if self.equal.has_key(slotid):
240 for slot in self.equal[slotid]:
241 tunermask |= (1 << slot)
242 elif self.linked.has_key(slotid):
243 for slot in self.linked[slotid]:
244 tunermask |= (1 << slot)
246 if currLnb.lof.value == "universal_lnb":
247 sec.setLNBLOFL(9750000)
248 sec.setLNBLOFH(10600000)
249 sec.setLNBThreshold(11700000)
250 elif currLnb.lof.value == "c_band":
251 sec.setLNBLOFL(5150000)
252 sec.setLNBLOFH(5150000)
253 sec.setLNBThreshold(5150000)
254 elif currLnb.lof.value == "user_defined":
255 sec.setLNBLOFL(currLnb.lofl.value * 1000)
256 sec.setLNBLOFH(currLnb.lofh.value * 1000)
257 sec.setLNBThreshold(currLnb.threshold.value * 1000)
259 # if currLnb.output_12v.value == "0V":
260 # pass # nyi in drivers
261 # elif currLnb.output_12v.value == "12V":
262 # pass # nyi in drivers
264 if currLnb.increased_voltage.value:
265 sec.setLNBIncreasedVoltage(lnbParam.ON)
267 sec.setLNBIncreasedVoltage(lnbParam.OFF)
269 dm = currLnb.diseqcMode.value
271 sec.setDiSEqCMode(diseqcParam.NONE)
273 sec.setDiSEqCMode(diseqcParam.V1_0)
275 sec.setDiSEqCMode(diseqcParam.V1_1)
277 sec.setDiSEqCMode(diseqcParam.V1_2)
279 if self.satposdepends.has_key(slotid):
280 for slot in self.satposdepends[slotid]:
281 tunermask |= (1 << slot)
284 if currLnb.toneburst.value == "none":
285 sec.setToneburst(diseqcParam.NO)
286 elif currLnb.toneburst.value == "A":
287 sec.setToneburst(diseqcParam.A)
288 elif currLnb.toneburst.value == "B":
289 sec.setToneburst(diseqcParam.B)
291 # Committed Diseqc Command
292 cdc = currLnb.commitedDiseqcCommand.value
294 c = { "none": diseqcParam.SENDNO,
295 "AA": diseqcParam.AA,
296 "AB": diseqcParam.AB,
297 "BA": diseqcParam.BA,
298 "BB": diseqcParam.BB }
301 sec.setCommittedCommand(c[cdc])
303 sec.setCommittedCommand(long(cdc))
305 sec.setFastDiSEqC(currLnb.fastDiseqc.value)
307 sec.setSeqRepeat(currLnb.sequenceRepeat.value)
309 if currLnb.diseqcMode.value == "1_0":
310 currCO = currLnb.commandOrder1_0.value
312 currCO = currLnb.commandOrder.value
314 udc = int(currLnb.uncommittedDiseqcCommand.value)
316 sec.setUncommittedCommand(0xF0|(udc-1))
318 sec.setUncommittedCommand(0) # SENDNO
320 sec.setRepeats({"none": 0, "one": 1, "two": 2, "three": 3}[currLnb.diseqcRepeats.value])
322 setCommandOrder = False
324 # 0 "committed, toneburst",
325 # 1 "toneburst, committed",
326 # 2 "committed, uncommitted, toneburst",
327 # 3 "toneburst, committed, uncommitted",
328 # 4 "uncommitted, committed, toneburst"
329 # 5 "toneburst, uncommitted, commmitted"
330 order_map = {"ct": 0, "tc": 1, "cut": 2, "tcu": 3, "uct": 4, "tuc": 5}
331 sec.setCommandOrder(order_map[currCO])
334 latitude = currLnb.latitude.float
335 sec.setLatitude(latitude)
336 longitude = currLnb.longitude.float
337 sec.setLongitude(longitude)
338 if currLnb.latitudeOrientation.value == "north":
339 sec.setLaDirection(rotorParam.NORTH)
341 sec.setLaDirection(rotorParam.SOUTH)
342 if currLnb.longitudeOrientation.value == "east":
343 sec.setLoDirection(rotorParam.EAST)
345 sec.setLoDirection(rotorParam.WEST)
347 if currLnb.powerMeasurement.value:
348 sec.setUseInputpower(True)
349 sec.setInputpowerDelta(currLnb.powerThreshold.value)
350 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
351 if turn_speed_dict.has_key(currLnb.turningSpeed.value):
352 turning_speed = turn_speed_dict[currLnb.turningSpeed.value]
354 beg_time = localtime(currLnb.fastTurningBegin.value)
355 end_time = localtime(currLnb.fastTurningEnd.value)
356 turning_speed = ((beg_time.tm_hour + 1) * 60 + beg_time.tm_min + 1) << 16
357 turning_speed |= (end_time.tm_hour + 1) * 60 + end_time.tm_min + 1
358 sec.setRotorTurningSpeed(turning_speed)
360 sec.setUseInputpower(False)
362 sec.setLNBSlotMask(tunermask)
364 # finally add the orbital positions
366 self.addSatellite(sec, y)
368 satpos = x > 32 and (3604-(36 - x)) or y
371 currSat = config.Nims[slotid].advanced.sat[satpos]
372 if currSat.voltage.value == "polarization":
373 sec.setVoltageMode(switchParam.HV)
374 elif currSat.voltage.value == "13V":
375 sec.setVoltageMode(switchParam._14V)
376 elif currSat.voltage.value == "18V":
377 sec.setVoltageMode(switchParam._18V)
379 if currSat.tonemode.value == "band":
380 sec.setToneMode(switchParam.HILO)
381 elif currSat.tonemode.value == "on":
382 sec.setToneMode(switchParam.ON)
383 elif currSat.tonemode.value == "off":
384 sec.setToneMode(switchParam.OFF)
386 if not currSat.usals.value and x < 34:
387 sec.setRotorPosNum(currSat.rotorposition.value)
389 sec.setRotorPosNum(0) #USALS
391 def __init__(self, nimmgr):
392 self.NimManager = nimmgr
393 self.configuredSatellites = Set()
397 def __init__(self, slot, type, description, has_outputs = True, internally_connectable = None):
400 if type not in ["DVB-S", "DVB-C", "DVB-T", "DVB-S2", None]:
401 print "warning: unknown NIM type %s, not using." % type
405 self.description = description
406 self.has_outputs = has_outputs
407 self.internally_connectable = internally_connectable
409 def isCompatible(self, what):
412 "DVB-S": ["DVB-S", None],
413 "DVB-C": ["DVB-C", None],
414 "DVB-T": ["DVB-T", None],
415 "DVB-S2": ["DVB-S", "DVB-S2", None]
417 return what in compatible[self.type]
419 def connectableTo(self):
421 "DVB-S": ["DVB-S", "DVB-S2"],
424 "DVB-S2": ["DVB-S", "DVB-S2"]
426 return connectable[self.type]
428 def getSlotName(self):
429 # get a friendly description for a slot name.
430 # we name them "Tuner A/B/C/...", because that's what's usually written on the back
432 return _("Tuner ") + chr(ord('A') + self.slot)
434 slot_name = property(getSlotName)
437 return chr(ord('A') + self.slot)
439 def hasOutputs(self):
440 return self.has_outputs
442 def internallyConnectableTo(self):
443 return self.internally_connectable
445 slot_id = property(getSlotID)
447 def getFriendlyType(self):
456 friendly_type = property(getFriendlyType)
458 def getFriendlyFullDescription(self):
459 nim_text = self.slot_name + ": "
462 nim_text += _("(empty)")
464 nim_text += self.description + " (" + self.friendly_type + ")"
468 friendly_full_description = property(getFriendlyFullDescription)
469 config_mode = property(lambda self: config.Nims[self.slot].configMode.value)
470 config = property(lambda self: config.Nims[self.slot])
471 empty = property(lambda self: self.type is None)
474 def getConfiguredSats(self):
475 return self.sec.getConfiguredSats()
477 def getTransponders(self, pos):
478 if self.transponders.has_key(pos):
479 return self.transponders[pos]
483 def getTranspondersCable(self, nim):
484 nimConfig = config.Nims[nim]
485 if nimConfig.configMode.value != "nothing" and nimConfig.cable.scan_type.value == "provider":
486 return self.transponderscable[self.cablesList[nimConfig.cable.scan_provider.index][0]]
489 def getTranspondersTerrestrial(self, region):
490 return self.transpondersterrestrial[region]
492 def getCableDescription(self, nim):
493 return self.cablesList[config.Nims[nim].scan_provider.index][0]
495 def getCableFlags(self, nim):
496 return self.cablesList[config.Nims[nim].scan_provider.index][1]
498 def getTerrestrialDescription(self, nim):
499 return self.terrestrialsList[config.Nims[nim].terrestrial.index][0]
501 def getTerrestrialFlags(self, nim):
502 return self.terrestrialsList[config.Nims[nim].terrestrial.index][1]
504 def getSatDescription(self, pos):
505 return self.satellites[pos]
507 def readTransponders(self):
508 # read initial networks from file. we only read files which we are interested in,
509 # which means only these where a compatible tuner exists.
510 self.satellites = { }
511 self.transponders = { }
512 self.transponderscable = { }
513 self.transpondersterrestrial = { }
514 db = eDVBDB.getInstance()
515 if self.hasNimType("DVB-S"):
516 print "Reading satellites.xml"
517 db.readSatellites(self.satList, self.satellites, self.transponders)
518 # print "SATLIST", self.satList
519 # print "SATS", self.satellites
520 # print "TRANSPONDERS", self.transponders
522 if self.hasNimType("DVB-C"):
523 print "Reading cables.xml"
524 db.readCables(self.cablesList, self.transponderscable)
525 # print "CABLIST", self.cablesList
526 # print "TRANSPONDERS", self.transponders
528 if self.hasNimType("DVB-T"):
529 print "Reading terrestrial.xml"
530 db.readTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
531 # print "TERLIST", self.terrestrialsList
532 # print "TRANSPONDERS", self.transpondersterrestrial
534 def enumerateNIMs(self):
535 # enum available NIMs. This is currently very dreambox-centric and uses the /proc/bus/nim_sockets interface.
536 # the result will be stored into nim_slots.
537 # the content of /proc/bus/nim_sockets looks like:
540 # Name: BCM4501 DVB-S2 NIM (internal)
543 # Name: BCM4501 DVB-S2 NIM (internal)
546 # Name: Philips TU1216
549 # Name: Alps BSBE1 702A
552 # Type will be either "DVB-S", "DVB-S2", "DVB-T", "DVB-C" or None.
554 # nim_slots is an array which has exactly one entry for each slot, even for empty ones.
557 nimfile = tryOpen("/proc/bus/nim_sockets")
565 for line in nimfile.readlines():
568 if line.strip().startswith("NIM Socket"):
569 parts = line.strip().split(" ")
570 current_slot = int(parts[2][:-1])
571 entries[current_slot] = {}
572 elif line.strip().startswith("Type:"):
573 entries[current_slot]["type"] = str(line.strip()[6:])
574 elif line.strip().startswith("Name:"):
575 entries[current_slot]["name"] = str(line.strip()[6:])
576 elif line.strip().startswith("Has_Outputs:"):
577 input = str(line.strip()[len("Has_Outputs:") + 1:])
578 entries[current_slot]["has_outputs"] = (input == "yes")
579 elif line.strip().startswith("Internally_Connectable:"):
580 input = int(line.strip()[len("Internally_Connectable:") + 1:])
581 entries[current_slot]["internally_connectable"] = input
582 elif line.strip().startswith("empty"):
583 entries[current_slot]["type"] = None
584 entries[current_slot]["name"] = _("N/A")
587 for id, entry in entries.items():
588 if not (entry.has_key("name") and entry.has_key("type")):
589 entry["name"] = _("N/A")
591 if not (entry.has_key("has_outputs")):
592 entry["has_outputs"] = True
593 if not (entry.has_key("internally_connectable")):
594 entry["internally_connectable"] = None
595 self.nim_slots.append(NIM(slot = id, description = entry["name"], type = entry["type"], has_outputs = entry["has_outputs"], internally_connectable = entry["internally_connectable"]))
597 def hasNimType(self, chktype):
598 for slot in self.nim_slots:
599 if slot.isCompatible(chktype):
603 def getNimType(self, slotid):
604 return self.nim_slots[slotid].type
606 def getNimDescription(self, slotid):
607 return self.nim_slots[slotid].friendly_full_description
609 def getNimListOfType(self, type, exception = -1):
610 # returns a list of indexes for NIMs compatible to the given type, except for 'exception'
612 for x in self.nim_slots:
613 if x.isCompatible(type) and x.slot != exception:
620 self.terrestrialsList = []
622 self.readTransponders()
623 InitNimManager(self) #init config stuff
625 # get a list with the friendly full description
628 for slot in self.nim_slots:
629 list.append(slot.friendly_full_description)
632 def getSlotCount(self):
633 return len(self.nim_slots)
635 def hasOutputs(self, slotid):
636 return self.nim_slots[slotid].hasOutputs()
638 def canConnectTo(self, slotid):
640 if self.nim_slots[slotid].internallyConnectableTo() is not None:
641 slots.append(self.nim_slots[slotid].internallyConnectableTo())
642 for type in self.nim_slots[slotid].connectableTo():
643 for slot in self.getNimListOfType(type, exception = slotid):
644 if self.hasOutputs(slot):
646 # remove nims, that have a conntectedTo reference on
647 for testnim in slots[:]:
648 for nim in self.getNimListOfType("DVB-S", slotid):
649 nimConfig = self.getNimConfig(nim)
650 if nimConfig.content.items.has_key("configMode") and nimConfig.configMode.value == "loopthrough" and int(nimConfig.connectedTo.value) == testnim:
651 slots.remove(testnim)
657 def canEqualTo(self, slotid):
658 type = self.getNimType(slotid)
659 if self.getNimConfig(slotid) == "DVB-S2":
661 nimList = self.getNimListOfType(type, slotid)
662 for nim in nimList[:]:
663 mode = self.getNimConfig(nim)
664 if mode.configMode.value == "loopthrough" or mode.configMode.value == "satposdepends":
668 def canDependOn(self, slotid):
669 type = self.getNimType(slotid)
670 if self.getNimConfig(slotid) == "DVB-S2":
672 nimList = self.getNimListOfType(type, slotid)
674 for nim in nimList[:]:
675 mode = self.getNimConfig(nim)
676 nimHaveRotor = mode.configMode.value == "simple" and mode.diseqcMode.value == "positioner"
677 if not nimHaveRotor and mode.configMode.value == "advanced":
678 for x in range(3601, 3605):
679 lnb = int(mode.advanced.sat[x].lnb.value)
684 alreadyConnected = False
685 for testnim in nimList:
686 testmode = self.getNimConfig(testnim)
687 if testmode.configMode.value == "satposdepends" and int(testmode.connectedTo.value) == int(nim):
688 alreadyConnected = True
690 if not alreadyConnected:
691 positionerList.append(nim)
692 return positionerList
694 def getNimConfig(self, slotid):
695 return config.Nims[slotid]
697 def getSatName(self, pos):
698 for sat in self.satList:
703 def getSatList(self):
706 def getSatListForNim(self, slotid):
708 if self.nim_slots[slotid].isCompatible("DVB-S"):
709 nim = config.Nims[slotid]
710 #print "slotid:", slotid
712 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.index]
713 #print "diseqcA:", config.Nims[slotid].diseqcA.value
714 configMode = nim.configMode.value
716 if configMode == "equal":
717 slotid = int(nim.connectedTo.value)
718 nim = config.Nims[slotid]
719 configMode = nim.configMode.value
720 elif configMode == "loopthrough":
721 slotid = self.sec.getRoot(slotid, int(nim.connectedTo.value))
722 nim = config.Nims[slotid]
723 configMode = nim.configMode.value
725 if configMode == "simple":
726 dm = nim.diseqcMode.value
727 if dm in ["single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
728 list.append(self.satList[nim.diseqcA.index])
729 if dm in ["toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
730 list.append(self.satList[nim.diseqcB.index])
731 if dm == "diseqc_a_b_c_d":
732 list.append(self.satList[nim.diseqcC.index])
733 list.append(self.satList[nim.diseqcD.index])
734 if dm == "positioner":
735 for x in self.satList:
737 elif configMode == "advanced":
738 for x in range(3601, 3605):
739 if int(nim.advanced.sat[x].lnb.value) != 0:
740 for x in self.satList:
743 for x in self.satList:
744 if int(nim.advanced.sat[x[0]].lnb.value) != 0:
748 def getRotorSatListForNim(self, slotid):
750 if self.nim_slots[slotid].isCompatible("DVB-S"):
751 #print "slotid:", slotid
752 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
753 #print "diseqcA:", config.Nims[slotid].diseqcA.value
754 configMode = config.Nims[slotid].configMode.value
755 if configMode == "simple":
756 if config.Nims[slotid].diseqcMode.value == "positioner":
757 for x in self.satList:
759 elif configMode == "advanced":
760 nim = config.Nims[slotid]
761 for x in range(3601, 3605):
762 if int(nim.advanced.sat[x].lnb.value) != 0:
763 for x in self.satList:
766 for x in self.satList:
767 lnbnum = int(nim.advanced.sat[x[0]].lnb.value)
769 lnb = nim.advanced.lnb[lnbnum]
770 if lnb.diseqcMode.value == "1_2":
775 config.sec = ConfigSubsection()
777 x = ConfigInteger(default=15, limits = (0, 9999))
778 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_CONT_TONE, configElement.value))
779 config.sec.delay_after_continuous_tone_change = x
781 x = ConfigInteger(default=10, limits = (0, 9999))
782 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_VOLTAGE_CHANGE, configElement.value))
783 config.sec.delay_after_final_voltage_change = x
785 x = ConfigInteger(default=120, limits = (0, 9999))
786 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_DISEQC_REPEATS, configElement.value))
787 config.sec.delay_between_diseqc_repeats = x
789 x = ConfigInteger(default=50, limits = (0, 9999))
790 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_LAST_DISEQC_CMD, configElement.value))
791 config.sec.delay_after_last_diseqc_command = x
793 x = ConfigInteger(default=50, limits = (0, 9999))
794 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value))
795 config.sec.delay_after_toneburst = x
797 x = ConfigInteger(default=20, limits = (0, 9999))
798 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS, configElement.value))
799 config.sec.delay_after_change_voltage_before_switch_command = x
801 x = ConfigInteger(default=200, limits = (0, 9999))
802 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS, configElement.value))
803 config.sec.delay_after_enable_voltage_before_switch_command = x
805 x = ConfigInteger(default=700, limits = (0, 9999))
806 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_SWITCH_AND_MOTOR_CMD, configElement.value))
807 config.sec.delay_between_switch_and_motor_command = x
809 x = ConfigInteger(default=500, limits = (0, 9999))
810 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MEASURE_IDLE_INPUTPOWER, configElement.value))
811 config.sec.delay_after_voltage_change_before_measure_idle_inputpower = x
813 x = ConfigInteger(default=750, limits = (0, 9999))
814 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_MOTOR_CMD, configElement.value))
815 config.sec.delay_after_enable_voltage_before_motor_command = x
817 x = ConfigInteger(default=500, limits = (0, 9999))
818 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_MOTOR_STOP_CMD, configElement.value))
819 config.sec.delay_after_motor_stop_command = x
821 x = ConfigInteger(default=500, limits = (0, 9999))
822 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MOTOR_CMD, configElement.value))
823 config.sec.delay_after_voltage_change_before_motor_command = x
825 x = ConfigInteger(default=360, limits = (0, 9999))
826 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_RUNNING_TIMEOUT, configElement.value))
827 config.sec.motor_running_timeout = x
829 x = ConfigInteger(default=1, limits = (0, 5))
830 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_COMMAND_RETRIES, configElement.value))
831 config.sec.motor_command_retries = x
833 # TODO add support for satpos depending nims to advanced nim configuration
834 # so a second/third/fourth cable from a motorized lnb can used behind a
835 # diseqc 1.0 / diseqc 1.1 / toneburst switch
836 # the C(++) part should can handle this
837 # the configElement should be only visible when diseqc 1.2 is disabled
839 def InitNimManager(nimmgr):
842 config.Nims = ConfigSubList()
843 for x in range(len(nimmgr.nim_slots)):
844 config.Nims.append(ConfigSubsection())
846 for slot in nimmgr.nim_slots:
850 if slot.isCompatible("DVB-S"):
851 choices = { "nothing": _("nothing connected"),
852 "simple": _("simple"),
853 "advanced": _("advanced")}
854 if len(nimmgr.getNimListOfType(slot.type, exception = x)) > 0:
855 choices["equal"] = _("equal to")
856 choices["satposdepends"] = _("second cable of motorized LNB")
857 if len(nimmgr.canConnectTo(x)) > 0:
858 choices["loopthrough"] = _("loopthrough to")
859 nim.configMode = ConfigSelection(choices = choices, default = "nothing")
861 # for y in nimmgr.nim_slots:
863 # if not y.isCompatible("DVB-S"):
865 # nim.configMode.value = "simple"
866 # nim.configMode.save()
868 nim.diseqcMode = ConfigSelection(
870 ("single", _("Single")),
871 ("toneburst_a_b", _("Toneburst A/B")),
872 ("diseqc_a_b", _("DiSEqC A/B")),
873 ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")),
874 ("positioner", _("Positioner"))],
875 default = "diseqc_a_b")
878 for id in nimmgr.getNimListOfType("DVB-S"):
880 choices.append((str(id), nimmgr.getNimDescription(id)))
881 nim.connectedTo = ConfigSelection(choices = choices)
882 nim.diseqcA = getConfigSatlist(192, nimmgr.satList)
883 nim.diseqcB = getConfigSatlist(130, nimmgr.satList)
884 nim.diseqcC = ConfigSatlist(list = nimmgr.satList)
885 nim.diseqcD = ConfigSatlist(list = nimmgr.satList)
886 nim.positionerMode = ConfigSelection(
888 ("usals", _("USALS")),
889 ("manual", _("manual"))],
891 nim.longitude = ConfigFloat(default=[5,100], limits=[(0,359),(0,999)])
892 nim.longitudeOrientation = ConfigSelection(choices={"east": _("East"), "west": _("West")}, default = "east")
893 nim.latitude = ConfigFloat(default=[50,767], limits=[(0,359),(0,999)])
894 nim.latitudeOrientation = ConfigSelection(choices={"north": _("North"), "south": _("South")}, default="north")
895 nim.powerMeasurement = ConfigYesNo(default=True)
896 nim.powerThreshold = ConfigInteger(default=50, limits=(0, 100))
897 nim.turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch")) ], default = "fast")
898 btime = datetime(1970, 1, 1, 7, 0);
899 nim.fastTurningBegin = ConfigDateTime(default = mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 900)
900 etime = datetime(1970, 1, 1, 19, 0);
901 nim.fastTurningEnd = ConfigDateTime(default = mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 900)
904 nim.advanced = ConfigSubsection()
905 tmp = [(3601, _('All Satellites')+' 1', 1), (3602, _('All Satellites')+' 2', 1), (3603, _('All Satellites')+' 3', 1), (3604, _('All Satellites')+' 4', 1)]
906 nim.advanced.sats = getConfigSatlist(192,nimmgr.satList+tmp)
907 nim.advanced.sat = ConfigSubDict()
908 lnbs = [("0", "not available")]
909 for y in range(1, 33):
910 lnbs.append((str(y), "LNB " + str(y)))
912 for x in nimmgr.satList:
913 nim.advanced.sat[x[0]] = ConfigSubsection()
914 nim.advanced.sat[x[0]].voltage = ConfigSelection(choices={"polarization": _("Polarization"), "13V": _("13 V"), "18V": _("18 V")}, default = "polarization")
915 nim.advanced.sat[x[0]].tonemode = ConfigSelection(choices={"band": _("Band"), "on": _("On"), "off": _("Off")}, default = "band")
916 nim.advanced.sat[x[0]].usals = ConfigYesNo(default=True)
917 nim.advanced.sat[x[0]].rotorposition = ConfigInteger(default=1, limits=(1, 255))
918 nim.advanced.sat[x[0]].lnb = ConfigSelection(choices = lnbs)
920 for x in range(3601, 3605):
921 nim.advanced.sat[x] = ConfigSubsection()
922 nim.advanced.sat[x].voltage = ConfigSelection(choices={"polarization": _("Polarization"), "13V": _("13 V"), "18V": _("18 V")}, default = "polarization")
923 nim.advanced.sat[x].tonemode = ConfigSelection(choices={"band": _("Band"), "on": _("On"), "off": _("Off")}, default = "band")
924 nim.advanced.sat[x].usals = ConfigYesNo(default=True)
925 nim.advanced.sat[x].rotorposition = ConfigInteger(default=1, limits=(1, 255))
927 nim.advanced.sat[x].lnb = ConfigSelection(choices = [("0", "not available"), (str(lnbnum), "LNB %d"%(lnbnum))], default="0")
929 csw = [("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))]
930 for y in range(0, 16):
931 csw.append((str(0xF0|y), "Input " + str(y+1)))
933 ucsw = [("0", _("None"))]
934 for y in range(1, 17):
935 ucsw.append((str(y), "Input " + str(y)))
937 nim.advanced.lnb = ConfigSubList()
938 nim.advanced.lnb.append(ConfigNothing())
939 for x in range(1, 37):
940 nim.advanced.lnb.append(ConfigSubsection())
941 nim.advanced.lnb[x].lof = ConfigSelection(choices={"universal_lnb": _("Universal LNB"), "c_band": _("C-Band"), "user_defined": _("User defined")}, default="universal_lnb")
942 nim.advanced.lnb[x].lofl = ConfigInteger(default=9750, limits = (0, 99999))
943 nim.advanced.lnb[x].lofh = ConfigInteger(default=10600, limits = (0, 99999))
944 nim.advanced.lnb[x].threshold = ConfigInteger(default=11700, limits = (0, 99999))
945 # nim.advanced.lnb[x].output_12v = ConfigSelection(choices = [("0V", _("0 V")), ("12V", _("12 V"))], default="0V")
946 nim.advanced.lnb[x].increased_voltage = ConfigYesNo(default=False)
947 nim.advanced.lnb[x].toneburst = ConfigSelection(choices = [("none", _("None")), ("A", _("A")), ("B", _("B"))], default = "none")
949 nim.advanced.lnb[x].diseqcMode = ConfigSelection(choices = [("1_2", _("1.2"))], default = "1_2")
951 nim.advanced.lnb[x].diseqcMode = ConfigSelection(choices = [("none", _("None")), ("1_0", _("1.0")), ("1_1", _("1.1")), ("1_2", _("1.2"))], default = "none")
952 nim.advanced.lnb[x].commitedDiseqcCommand = ConfigSelection(choices = csw)
953 nim.advanced.lnb[x].fastDiseqc = ConfigYesNo(default=False)
954 nim.advanced.lnb[x].sequenceRepeat = ConfigYesNo(default=False)
955 nim.advanced.lnb[x].commandOrder1_0 = ConfigSelection(choices = [("ct", "committed, toneburst"), ("tc", "toneburst, committed")], default = "ct")
956 nim.advanced.lnb[x].commandOrder = ConfigSelection(choices = [
957 ("ct", "committed, toneburst"),
958 ("tc", "toneburst, committed"),
959 ("cut", "committed, uncommitted, toneburst"),
960 ("tcu", "toneburst, committed, uncommitted"),
961 ("uct", "uncommitted, committed, toneburst"),
962 ("tuc", "toneburst, uncommitted, commmitted")],
964 nim.advanced.lnb[x].uncommittedDiseqcCommand = ConfigSelection(choices = ucsw)
965 nim.advanced.lnb[x].diseqcRepeats = ConfigSelection(choices = [("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))], default = "none")
966 nim.advanced.lnb[x].longitude = ConfigFloat(default = [5,100], limits = [(0,359),(0,999)])
967 nim.advanced.lnb[x].longitudeOrientation = ConfigSelection(choices = [("east", _("East")), ("west", _("West"))], default = "east")
968 nim.advanced.lnb[x].latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)])
969 nim.advanced.lnb[x].latitudeOrientation = ConfigSelection(choices = [("north", _("North")), ("south", _("South"))], default = "north")
970 nim.advanced.lnb[x].powerMeasurement = ConfigYesNo(default=True)
971 nim.advanced.lnb[x].powerThreshold = ConfigInteger(default=50, limits=(0, 100))
972 nim.advanced.lnb[x].turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch"))], default = "fast")
973 btime = datetime(1970, 1, 1, 7, 0);
974 nim.advanced.lnb[x].fastTurningBegin = ConfigDateTime(default=mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 600)
975 etime = datetime(1970, 1, 1, 19, 0);
976 nim.advanced.lnb[x].fastTurningEnd = ConfigDateTime(default=mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 600)
977 elif slot.isCompatible("DVB-C"):
978 nim.configMode = ConfigSelection(
980 "enabled": _("enabled"),
981 "nothing": _("nothing connected"),
986 for x in nimmgr.cablesList:
987 list.append((str(n), x[0]))
989 nim.cable = ConfigSubsection()
990 possible_scan_types = [("bands", _("Frequency bands")), ("steps", _("Frequency steps"))]
992 possible_scan_types.append(("provider", _("Provider")))
993 nim.cable.scan_provider = ConfigSelection(default = "0", choices = list)
994 nim.cable.scan_type = ConfigSelection(default = "bands", choices = possible_scan_types)
995 nim.cable.scan_band_EU_VHF_I = ConfigYesNo(default = True)
996 nim.cable.scan_band_EU_MID = ConfigYesNo(default = True)
997 nim.cable.scan_band_EU_VHF_III = ConfigYesNo(default = True)
998 nim.cable.scan_band_EU_UHF_IV = ConfigYesNo(default = True)
999 nim.cable.scan_band_EU_UHF_V = ConfigYesNo(default = True)
1000 nim.cable.scan_band_EU_SUPER = ConfigYesNo(default = True)
1001 nim.cable.scan_band_EU_HYPER = ConfigYesNo(default = True)
1002 nim.cable.scan_band_US_LOW = ConfigYesNo(default = False)
1003 nim.cable.scan_band_US_MID = ConfigYesNo(default = False)
1004 nim.cable.scan_band_US_HIGH = ConfigYesNo(default = False)
1005 nim.cable.scan_band_US_SUPER = ConfigYesNo(default = False)
1006 nim.cable.scan_band_US_HYPER = ConfigYesNo(default = False)
1007 nim.cable.scan_frequency_steps = ConfigInteger(default = 1000, limits = (1000, 10000))
1008 nim.cable.scan_mod_qam16 = ConfigYesNo(default = False)
1009 nim.cable.scan_mod_qam32 = ConfigYesNo(default = False)
1010 nim.cable.scan_mod_qam64 = ConfigYesNo(default = True)
1011 nim.cable.scan_mod_qam128 = ConfigYesNo(default = False)
1012 nim.cable.scan_mod_qam256 = ConfigYesNo(default = True)
1013 nim.cable.scan_sr_6900 = ConfigYesNo(default = True)
1014 nim.cable.scan_sr_6875 = ConfigYesNo(default = True)
1015 nim.cable.scan_sr_ext1 = ConfigInteger(default = 0, limits = (0, 7230))
1016 nim.cable.scan_sr_ext2 = ConfigInteger(default = 0, limits = (0, 7230))
1017 elif slot.isCompatible("DVB-T"):
1018 nim.configMode = ConfigSelection(
1020 "enabled": _("enabled"),
1021 "nothing": _("nothing connected"),
1023 default = "enabled")
1026 for x in nimmgr.terrestrialsList:
1027 list.append((str(n), x[0]))
1029 nim.terrestrial = ConfigSelection(choices = list)
1030 nim.terrestrial_5V = ConfigOnOff()
1032 nim.configMode = ConfigSelection(choices = { "nothing": _("disabled") }, default="nothing");
1033 print "pls add support for this frontend type!"
1036 nimmgr.sec = SecConfigure(nimmgr)
1038 nimmanager = NimManager()