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
19 def getConfigSatlist(orbpos, satlist):
23 default_orbpos = orbpos
25 return ConfigSatlist(satlist, default_orbpos)
27 def tryOpen(filename):
29 procFile = open(filename)
35 def getConfiguredSats(self):
36 return self.configuredSatellites
38 def addSatellite(self, sec, orbpos):
39 sec.addSatellite(orbpos)
40 self.configuredSatellites.add(orbpos)
42 def addLNBSimple(self, sec, slotid, diseqcmode, toneburstmode = diseqcParam.NO, diseqcpos = diseqcParam.SENDNO, orbpos = 0, longitude = 0, latitude = 0, loDirection = 0, laDirection = 0, turningSpeed = rotorParam.FAST, useInputPower=True, inputPowerDelta=50, fastDiSEqC = False, setVoltageTone = True, diseqc13V = False):
43 if orbpos is None or orbpos == 3601:
47 tunermask = 1 << slotid
48 if self.equal.has_key(slotid):
49 for slot in self.equal[slotid]:
50 tunermask |= (1 << slot)
51 elif self.linked.has_key(slotid):
52 for slot in self.linked[slotid]:
53 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]
258 tunermask = 1 << slotid
259 if self.equal.has_key(slotid):
260 for slot in self.equal[slotid]:
261 tunermask |= (1 << slot)
262 elif self.linked.has_key(slotid):
263 for slot in self.linked[slotid]:
264 tunermask |= (1 << slot)
266 if currLnb.lof.value == "universal_lnb":
267 sec.setLNBLOFL(9750000)
268 sec.setLNBLOFH(10600000)
269 sec.setLNBThreshold(11700000)
270 elif currLnb.lof.value == "c_band":
271 sec.setLNBLOFL(5150000)
272 sec.setLNBLOFH(5150000)
273 sec.setLNBThreshold(5150000)
274 elif currLnb.lof.value == "user_defined":
275 sec.setLNBLOFL(currLnb.lofl.value * 1000)
276 sec.setLNBLOFH(currLnb.lofh.value * 1000)
277 sec.setLNBThreshold(currLnb.threshold.value * 1000)
279 # if currLnb.output_12v.value == "0V":
280 # pass # nyi in drivers
281 # elif currLnb.output_12v.value == "12V":
282 # pass # nyi in drivers
284 if currLnb.increased_voltage.value:
285 sec.setLNBIncreasedVoltage(lnbParam.ON)
287 sec.setLNBIncreasedVoltage(lnbParam.OFF)
289 dm = currLnb.diseqcMode.value
291 sec.setDiSEqCMode(diseqcParam.NONE)
293 sec.setDiSEqCMode(diseqcParam.V1_0)
295 sec.setDiSEqCMode(diseqcParam.V1_1)
297 sec.setDiSEqCMode(diseqcParam.V1_2)
299 if self.satposdepends.has_key(slotid):
300 for slot in self.satposdepends[slotid]:
301 tunermask |= (1 << slot)
304 if currLnb.toneburst.value == "none":
305 sec.setToneburst(diseqcParam.NO)
306 elif currLnb.toneburst.value == "A":
307 sec.setToneburst(diseqcParam.A)
308 elif currLnb.toneburst.value == "B":
309 sec.setToneburst(diseqcParam.B)
311 # Committed Diseqc Command
312 cdc = currLnb.commitedDiseqcCommand.value
314 c = { "none": diseqcParam.SENDNO,
315 "AA": diseqcParam.AA,
316 "AB": diseqcParam.AB,
317 "BA": diseqcParam.BA,
318 "BB": diseqcParam.BB }
321 sec.setCommittedCommand(c[cdc])
323 sec.setCommittedCommand(long(cdc))
325 sec.setFastDiSEqC(currLnb.fastDiseqc.value)
327 sec.setSeqRepeat(currLnb.sequenceRepeat.value)
329 if currLnb.diseqcMode.value == "1_0":
330 currCO = currLnb.commandOrder1_0.value
332 currCO = currLnb.commandOrder.value
334 udc = int(currLnb.uncommittedDiseqcCommand.value)
336 sec.setUncommittedCommand(0xF0|(udc-1))
338 sec.setUncommittedCommand(0) # SENDNO
340 sec.setRepeats({"none": 0, "one": 1, "two": 2, "three": 3}[currLnb.diseqcRepeats.value])
342 setCommandOrder = False
344 # 0 "committed, toneburst",
345 # 1 "toneburst, committed",
346 # 2 "committed, uncommitted, toneburst",
347 # 3 "toneburst, committed, uncommitted",
348 # 4 "uncommitted, committed, toneburst"
349 # 5 "toneburst, uncommitted, commmitted"
350 order_map = {"ct": 0, "tc": 1, "cut": 2, "tcu": 3, "uct": 4, "tuc": 5}
351 sec.setCommandOrder(order_map[currCO])
354 latitude = currLnb.latitude.float
355 sec.setLatitude(latitude)
356 longitude = currLnb.longitude.float
357 sec.setLongitude(longitude)
358 if currLnb.latitudeOrientation.value == "north":
359 sec.setLaDirection(rotorParam.NORTH)
361 sec.setLaDirection(rotorParam.SOUTH)
362 if currLnb.longitudeOrientation.value == "east":
363 sec.setLoDirection(rotorParam.EAST)
365 sec.setLoDirection(rotorParam.WEST)
367 if currLnb.powerMeasurement.value:
368 sec.setUseInputpower(True)
369 sec.setInputpowerDelta(currLnb.powerThreshold.value)
370 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
371 if turn_speed_dict.has_key(currLnb.turningSpeed.value):
372 turning_speed = turn_speed_dict[currLnb.turningSpeed.value]
374 beg_time = localtime(currLnb.fastTurningBegin.value)
375 end_time = localtime(currLnb.fastTurningEnd.value)
376 turning_speed = ((beg_time.tm_hour + 1) * 60 + beg_time.tm_min + 1) << 16
377 turning_speed |= (end_time.tm_hour + 1) * 60 + end_time.tm_min + 1
378 sec.setRotorTurningSpeed(turning_speed)
380 sec.setUseInputpower(False)
382 sec.setLNBSlotMask(tunermask)
384 # finally add the orbital positions
386 self.addSatellite(sec, y)
388 satpos = x > 32 and (3604-(36 - x)) or y
391 currSat = config.Nims[slotid].advanced.sat[satpos]
392 if currSat.voltage.value == "polarization":
393 if config.Nims[slotid].diseqc13V.value:
394 sec.setVoltageMode(switchParam.HV_13)
396 sec.setVoltageMode(switchParam.HV)
397 elif currSat.voltage.value == "13V":
398 sec.setVoltageMode(switchParam._14V)
399 elif currSat.voltage.value == "18V":
400 sec.setVoltageMode(switchParam._18V)
402 if currSat.tonemode.value == "band":
403 sec.setToneMode(switchParam.HILO)
404 elif currSat.tonemode.value == "on":
405 sec.setToneMode(switchParam.ON)
406 elif currSat.tonemode.value == "off":
407 sec.setToneMode(switchParam.OFF)
409 if not currSat.usals.value and x < 34:
410 sec.setRotorPosNum(currSat.rotorposition.value)
412 sec.setRotorPosNum(0) #USALS
414 def __init__(self, nimmgr):
415 self.NimManager = nimmgr
416 self.configuredSatellites = Set()
420 def __init__(self, slot, type, description, has_outputs = True, internally_connectable = None):
423 if type not in ["DVB-S", "DVB-C", "DVB-T", "DVB-S2", None]:
424 print "warning: unknown NIM type %s, not using." % type
428 self.description = description
429 self.has_outputs = has_outputs
430 self.internally_connectable = internally_connectable
432 def isCompatible(self, what):
435 "DVB-S": ["DVB-S", None],
436 "DVB-C": ["DVB-C", None],
437 "DVB-T": ["DVB-T", None],
438 "DVB-S2": ["DVB-S", "DVB-S2", None]
440 return what in compatible[self.type]
442 def connectableTo(self):
444 "DVB-S": ["DVB-S", "DVB-S2"],
447 "DVB-S2": ["DVB-S", "DVB-S2"]
449 return connectable[self.type]
451 def getSlotName(self):
452 # get a friendly description for a slot name.
453 # we name them "Tuner A/B/C/...", because that's what's usually written on the back
455 return _("Tuner ") + chr(ord('A') + self.slot)
457 slot_name = property(getSlotName)
460 return chr(ord('A') + self.slot)
462 def hasOutputs(self):
463 return self.has_outputs
465 def internallyConnectableTo(self):
466 return self.internally_connectable
468 slot_id = property(getSlotID)
470 def getFriendlyType(self):
479 friendly_type = property(getFriendlyType)
481 def getFriendlyFullDescription(self):
482 nim_text = self.slot_name + ": "
485 nim_text += _("(empty)")
487 nim_text += self.description + " (" + self.friendly_type + ")"
491 friendly_full_description = property(getFriendlyFullDescription)
492 config_mode = property(lambda self: config.Nims[self.slot].configMode.value)
493 config = property(lambda self: config.Nims[self.slot])
494 empty = property(lambda self: self.type is None)
497 def getConfiguredSats(self):
498 return self.sec.getConfiguredSats()
500 def getTransponders(self, pos):
501 if self.transponders.has_key(pos):
502 return self.transponders[pos]
506 def getTranspondersCable(self, nim):
507 nimConfig = config.Nims[nim]
508 if nimConfig.configMode.value != "nothing" and nimConfig.cable.scan_type.value == "provider":
509 return self.transponderscable[self.cablesList[nimConfig.cable.scan_provider.index][0]]
512 def getTranspondersTerrestrial(self, region):
513 return self.transpondersterrestrial[region]
515 def getCableDescription(self, nim):
516 return self.cablesList[config.Nims[nim].scan_provider.index][0]
518 def getCableFlags(self, nim):
519 return self.cablesList[config.Nims[nim].scan_provider.index][1]
521 def getTerrestrialDescription(self, nim):
522 return self.terrestrialsList[config.Nims[nim].terrestrial.index][0]
524 def getTerrestrialFlags(self, nim):
525 return self.terrestrialsList[config.Nims[nim].terrestrial.index][1]
527 def getSatDescription(self, pos):
528 return self.satellites[pos]
530 def readTransponders(self):
531 # read initial networks from file. we only read files which we are interested in,
532 # which means only these where a compatible tuner exists.
533 self.satellites = { }
534 self.transponders = { }
535 self.transponderscable = { }
536 self.transpondersterrestrial = { }
537 db = eDVBDB.getInstance()
538 if self.hasNimType("DVB-S"):
539 print "Reading satellites.xml"
540 db.readSatellites(self.satList, self.satellites, self.transponders)
541 # print "SATLIST", self.satList
542 # print "SATS", self.satellites
543 # print "TRANSPONDERS", self.transponders
545 if self.hasNimType("DVB-C"):
546 print "Reading cables.xml"
547 db.readCables(self.cablesList, self.transponderscable)
548 # print "CABLIST", self.cablesList
549 # print "TRANSPONDERS", self.transponders
551 if self.hasNimType("DVB-T"):
552 print "Reading terrestrial.xml"
553 db.readTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
554 # print "TERLIST", self.terrestrialsList
555 # print "TRANSPONDERS", self.transpondersterrestrial
557 def enumerateNIMs(self):
558 # enum available NIMs. This is currently very dreambox-centric and uses the /proc/bus/nim_sockets interface.
559 # the result will be stored into nim_slots.
560 # the content of /proc/bus/nim_sockets looks like:
563 # Name: BCM4501 DVB-S2 NIM (internal)
566 # Name: BCM4501 DVB-S2 NIM (internal)
569 # Name: Philips TU1216
572 # Name: Alps BSBE1 702A
575 # Type will be either "DVB-S", "DVB-S2", "DVB-T", "DVB-C" or None.
577 # nim_slots is an array which has exactly one entry for each slot, even for empty ones.
580 nimfile = tryOpen("/proc/bus/nim_sockets")
588 for line in nimfile.readlines():
591 if line.strip().startswith("NIM Socket"):
592 parts = line.strip().split(" ")
593 current_slot = int(parts[2][:-1])
594 entries[current_slot] = {}
595 elif line.strip().startswith("Type:"):
596 entries[current_slot]["type"] = str(line.strip()[6:])
597 elif line.strip().startswith("Name:"):
598 entries[current_slot]["name"] = str(line.strip()[6:])
599 elif line.strip().startswith("Has_Outputs:"):
600 input = str(line.strip()[len("Has_Outputs:") + 1:])
601 entries[current_slot]["has_outputs"] = (input == "yes")
602 elif line.strip().startswith("Internally_Connectable:"):
603 input = int(line.strip()[len("Internally_Connectable:") + 1:])
604 entries[current_slot]["internally_connectable"] = input
605 elif line.strip().startswith("empty"):
606 entries[current_slot]["type"] = None
607 entries[current_slot]["name"] = _("N/A")
610 for id, entry in entries.items():
611 if not (entry.has_key("name") and entry.has_key("type")):
612 entry["name"] = _("N/A")
614 if not (entry.has_key("has_outputs")):
615 entry["has_outputs"] = True
616 if not (entry.has_key("internally_connectable")):
617 entry["internally_connectable"] = None
618 self.nim_slots.append(NIM(slot = id, description = entry["name"], type = entry["type"], has_outputs = entry["has_outputs"], internally_connectable = entry["internally_connectable"]))
620 def hasNimType(self, chktype):
621 for slot in self.nim_slots:
622 if slot.isCompatible(chktype):
626 def getNimType(self, slotid):
627 return self.nim_slots[slotid].type
629 def getNimDescription(self, slotid):
630 return self.nim_slots[slotid].friendly_full_description
632 def getNimListOfType(self, type, exception = -1):
633 # returns a list of indexes for NIMs compatible to the given type, except for 'exception'
635 for x in self.nim_slots:
636 if x.isCompatible(type) and x.slot != exception:
643 self.terrestrialsList = []
645 self.readTransponders()
646 InitNimManager(self) #init config stuff
648 # get a list with the friendly full description
651 for slot in self.nim_slots:
652 list.append(slot.friendly_full_description)
655 def getSlotCount(self):
656 return len(self.nim_slots)
658 def hasOutputs(self, slotid):
659 return self.nim_slots[slotid].hasOutputs()
661 def canConnectTo(self, slotid):
663 if self.nim_slots[slotid].internallyConnectableTo() is not None:
664 slots.append(self.nim_slots[slotid].internallyConnectableTo())
665 for type in self.nim_slots[slotid].connectableTo():
666 for slot in self.getNimListOfType(type, exception = slotid):
667 if self.hasOutputs(slot):
669 # remove nims, that have a conntectedTo reference on
670 for testnim in slots[:]:
671 for nim in self.getNimListOfType("DVB-S", slotid):
672 nimConfig = self.getNimConfig(nim)
673 if nimConfig.content.items.has_key("configMode") and nimConfig.configMode.value == "loopthrough" and int(nimConfig.connectedTo.value) == testnim:
674 slots.remove(testnim)
680 def canEqualTo(self, slotid):
681 type = self.getNimType(slotid)
684 nimList = self.getNimListOfType(type, slotid)
685 for nim in nimList[:]:
686 mode = self.getNimConfig(nim)
687 if mode.configMode.value == "loopthrough" or mode.configMode.value == "satposdepends":
691 def canDependOn(self, slotid):
692 type = self.getNimType(slotid)
695 nimList = self.getNimListOfType(type, slotid)
697 for nim in nimList[:]:
698 mode = self.getNimConfig(nim)
699 nimHaveRotor = mode.configMode.value == "simple" and mode.diseqcMode.value == "positioner"
700 if not nimHaveRotor and mode.configMode.value == "advanced":
701 for x in range(3601, 3605):
702 lnb = int(mode.advanced.sat[x].lnb.value)
707 for sat in mode.advanced.sat.values():
708 lnb_num = int(sat.lnb.value)
709 diseqcmode = lnb_num and mode.advanced.lnb[lnb_num].diseqcMode.value or ""
710 if diseqcmode == "1_2":
714 alreadyConnected = False
715 for testnim in nimList:
716 testmode = self.getNimConfig(testnim)
717 if testmode.configMode.value == "satposdepends" and int(testmode.connectedTo.value) == int(nim):
718 alreadyConnected = True
720 if not alreadyConnected:
721 positionerList.append(nim)
722 return positionerList
724 def getNimConfig(self, slotid):
725 return config.Nims[slotid]
727 def getSatName(self, pos):
728 for sat in self.satList:
733 def getSatList(self):
736 def getSatListForNim(self, slotid):
738 if self.nim_slots[slotid].isCompatible("DVB-S"):
739 nim = config.Nims[slotid]
740 #print "slotid:", slotid
742 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.index]
743 #print "diseqcA:", config.Nims[slotid].diseqcA.value
744 configMode = nim.configMode.value
746 if configMode == "equal":
747 slotid = int(nim.connectedTo.value)
748 nim = config.Nims[slotid]
749 configMode = nim.configMode.value
750 elif configMode == "loopthrough":
751 slotid = self.sec.getRoot(slotid, int(nim.connectedTo.value))
752 nim = config.Nims[slotid]
753 configMode = nim.configMode.value
755 if configMode == "simple":
756 dm = nim.diseqcMode.value
757 if dm in ["single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
758 if nim.diseqcA.orbital_position != 3601:
759 list.append(self.satList[nim.diseqcA.index-1])
760 if dm in ["toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
761 if nim.diseqcB.orbital_position != 3601:
762 list.append(self.satList[nim.diseqcB.index-1])
763 if dm == "diseqc_a_b_c_d":
764 if nim.diseqcC.orbital_position != 3601:
765 list.append(self.satList[nim.diseqcC.index-1])
766 if nim.diseqcD.orbital_position != 3601:
767 list.append(self.satList[nim.diseqcD.index-1])
768 if dm == "positioner":
769 for x in self.satList:
771 elif configMode == "advanced":
772 for x in range(3601, 3605):
773 if int(nim.advanced.sat[x].lnb.value) != 0:
774 for x in self.satList:
777 for x in self.satList:
778 if int(nim.advanced.sat[x[0]].lnb.value) != 0:
782 def getRotorSatListForNim(self, slotid):
784 if self.nim_slots[slotid].isCompatible("DVB-S"):
785 #print "slotid:", slotid
786 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
787 #print "diseqcA:", config.Nims[slotid].diseqcA.value
788 configMode = config.Nims[slotid].configMode.value
789 if configMode == "simple":
790 if config.Nims[slotid].diseqcMode.value == "positioner":
791 for x in self.satList:
793 elif configMode == "advanced":
794 nim = config.Nims[slotid]
795 for x in range(3601, 3605):
796 if int(nim.advanced.sat[x].lnb.value) != 0:
797 for x in self.satList:
800 for x in self.satList:
801 lnbnum = int(nim.advanced.sat[x[0]].lnb.value)
803 lnb = nim.advanced.lnb[lnbnum]
804 if lnb.diseqcMode.value == "1_2":
809 config.sec = ConfigSubsection()
811 x = ConfigInteger(default=15, limits = (0, 9999))
812 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_CONT_TONE, configElement.value))
813 config.sec.delay_after_continuous_tone_change = x
815 x = ConfigInteger(default=10, limits = (0, 9999))
816 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_VOLTAGE_CHANGE, configElement.value))
817 config.sec.delay_after_final_voltage_change = x
819 x = ConfigInteger(default=120, limits = (0, 9999))
820 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_DISEQC_REPEATS, configElement.value))
821 config.sec.delay_between_diseqc_repeats = x
823 x = ConfigInteger(default=50, limits = (0, 9999))
824 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_LAST_DISEQC_CMD, configElement.value))
825 config.sec.delay_after_last_diseqc_command = x
827 x = ConfigInteger(default=50, limits = (0, 9999))
828 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value))
829 config.sec.delay_after_toneburst = x
831 x = ConfigInteger(default=20, limits = (0, 9999))
832 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS, configElement.value))
833 config.sec.delay_after_change_voltage_before_switch_command = x
835 x = ConfigInteger(default=200, limits = (0, 9999))
836 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS, configElement.value))
837 config.sec.delay_after_enable_voltage_before_switch_command = x
839 x = ConfigInteger(default=700, limits = (0, 9999))
840 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_SWITCH_AND_MOTOR_CMD, configElement.value))
841 config.sec.delay_between_switch_and_motor_command = x
843 x = ConfigInteger(default=500, limits = (0, 9999))
844 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MEASURE_IDLE_INPUTPOWER, configElement.value))
845 config.sec.delay_after_voltage_change_before_measure_idle_inputpower = x
847 x = ConfigInteger(default=750, limits = (0, 9999))
848 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_MOTOR_CMD, configElement.value))
849 config.sec.delay_after_enable_voltage_before_motor_command = x
851 x = ConfigInteger(default=500, limits = (0, 9999))
852 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_MOTOR_STOP_CMD, configElement.value))
853 config.sec.delay_after_motor_stop_command = x
855 x = ConfigInteger(default=500, limits = (0, 9999))
856 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MOTOR_CMD, configElement.value))
857 config.sec.delay_after_voltage_change_before_motor_command = x
859 x = ConfigInteger(default=70, limits = (0, 9999))
860 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BEFORE_SEQUENCE_REPEAT, configElement.value))
861 config.sec.delay_before_sequence_repeat = x
863 x = ConfigInteger(default=360, limits = (0, 9999))
864 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_RUNNING_TIMEOUT, configElement.value))
865 config.sec.motor_running_timeout = x
867 x = ConfigInteger(default=1, limits = (0, 5))
868 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_COMMAND_RETRIES, configElement.value))
869 config.sec.motor_command_retries = x
871 x = ConfigInteger(default=50, limits = (0, 9999))
872 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_DISEQC_RESET_CMD, configElement.value))
873 config.sec.delay_after_diseqc_reset_cmd = x
875 x = ConfigInteger(default=150, limits = (0, 9999))
876 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_DISEQC_PERIPHERIAL_POWERON_CMD, configElement.value))
877 config.sec.delay_after_diseqc_peripherial_poweron_cmd = x
879 # TODO add support for satpos depending nims to advanced nim configuration
880 # so a second/third/fourth cable from a motorized lnb can used behind a
881 # diseqc 1.0 / diseqc 1.1 / toneburst switch
882 # the C(++) part should can handle this
883 # the configElement should be only visible when diseqc 1.2 is disabled
885 def InitNimManager(nimmgr):
889 config.Nims = ConfigSubList()
890 for x in range(len(nimmgr.nim_slots)):
891 config.Nims.append(ConfigSubsection())
893 for slot in nimmgr.nim_slots:
897 if slot.isCompatible("DVB-S"):
898 choices = { "nothing": _("nothing connected"),
899 "simple": _("simple"),
900 "advanced": _("advanced")}
901 if len(nimmgr.getNimListOfType(slot.type, exception = x)) > 0:
902 choices["equal"] = _("equal to")
903 choices["satposdepends"] = _("second cable of motorized LNB")
904 if len(nimmgr.canConnectTo(x)) > 0:
905 choices["loopthrough"] = _("loopthrough to")
906 nim.configMode = ConfigSelection(choices = choices, default = "nothing")
908 # for y in nimmgr.nim_slots:
910 # if not y.isCompatible("DVB-S"):
912 # nim.configMode.value = "simple"
913 # nim.configMode.save()
915 nim.diseqc13V = ConfigYesNo(default = False)
917 nim.diseqcMode = ConfigSelection(
919 ("single", _("Single")),
920 ("toneburst_a_b", _("Toneburst A/B")),
921 ("diseqc_a_b", _("DiSEqC A/B")),
922 ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")),
923 ("positioner", _("Positioner"))],
924 default = "diseqc_a_b")
927 for id in nimmgr.getNimListOfType("DVB-S"):
929 choices.append((str(id), nimmgr.getNimDescription(id)))
930 nim.connectedTo = ConfigSelection(choices = choices)
931 nim.simpleSingleSendDiSEqC = ConfigYesNo(default=False)
932 nim.simpleDiSEqCSetVoltageTone = ConfigYesNo(default=True)
933 nim.simpleDiSEqCOnlyOnSatChange = ConfigYesNo(default=False)
934 nim.diseqcA = getConfigSatlist(192, [(3601, _('nothing connected'), 1)] + nimmgr.satList)
935 nim.diseqcB = getConfigSatlist(130, [(3601, _('nothing connected'), 1)] + nimmgr.satList)
936 nim.diseqcC = ConfigSatlist(list = [(3601, _('nothing connected'), 1)] + nimmgr.satList)
937 nim.diseqcD = ConfigSatlist(list = [(3601, _('nothing connected'), 1)] + nimmgr.satList)
938 nim.positionerMode = ConfigSelection(
940 ("usals", _("USALS")),
941 ("manual", _("manual"))],
943 nim.longitude = ConfigFloat(default=[5,100], limits=[(0,359),(0,999)])
944 nim.longitudeOrientation = ConfigSelection(choices={"east": _("East"), "west": _("West")}, default = "east")
945 nim.latitude = ConfigFloat(default=[50,767], limits=[(0,359),(0,999)])
946 nim.latitudeOrientation = ConfigSelection(choices={"north": _("North"), "south": _("South")}, default="north")
947 nim.powerMeasurement = ConfigYesNo(default=True)
948 nim.powerThreshold = ConfigInteger(default=hw.get_device_name() == "dm8000" and 15 or 50, limits=(0, 100))
949 nim.turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch")) ], default = "fast")
950 btime = datetime(1970, 1, 1, 7, 0);
951 nim.fastTurningBegin = ConfigDateTime(default = mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 900)
952 etime = datetime(1970, 1, 1, 19, 0);
953 nim.fastTurningEnd = ConfigDateTime(default = mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 900)
956 nim.advanced = ConfigSubsection()
957 tmp = [(3601, _('All Satellites')+' 1', 1), (3602, _('All Satellites')+' 2', 1), (3603, _('All Satellites')+' 3', 1), (3604, _('All Satellites')+' 4', 1)]
958 nim.advanced.sats = getConfigSatlist(192,nimmgr.satList+tmp)
959 nim.advanced.sat = ConfigSubDict()
960 lnbs = [("0", "not available")]
961 for y in range(1, 33):
962 lnbs.append((str(y), "LNB " + str(y)))
964 for x in nimmgr.satList:
965 nim.advanced.sat[x[0]] = ConfigSubsection()
966 nim.advanced.sat[x[0]].voltage = ConfigSelection(choices={"polarization": _("Polarization"), "13V": _("13 V"), "18V": _("18 V")}, default = "polarization")
967 nim.advanced.sat[x[0]].tonemode = ConfigSelection(choices={"band": _("Band"), "on": _("On"), "off": _("Off")}, default = "band")
968 nim.advanced.sat[x[0]].usals = ConfigYesNo(default=True)
969 nim.advanced.sat[x[0]].rotorposition = ConfigInteger(default=1, limits=(1, 255))
970 nim.advanced.sat[x[0]].lnb = ConfigSelection(choices = lnbs)
972 for x in range(3601, 3605):
973 nim.advanced.sat[x] = ConfigSubsection()
974 nim.advanced.sat[x].voltage = ConfigSelection(choices={"polarization": _("Polarization"), "13V": _("13 V"), "18V": _("18 V")}, default = "polarization")
975 nim.advanced.sat[x].tonemode = ConfigSelection(choices={"band": _("Band"), "on": _("On"), "off": _("Off")}, default = "band")
976 nim.advanced.sat[x].usals = ConfigYesNo(default=True)
977 nim.advanced.sat[x].rotorposition = ConfigInteger(default=1, limits=(1, 255))
979 nim.advanced.sat[x].lnb = ConfigSelection(choices = [("0", "not available"), (str(lnbnum), "LNB %d"%(lnbnum))], default="0")
981 csw = [("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))]
982 for y in range(0, 16):
983 csw.append((str(0xF0|y), "Input " + str(y+1)))
985 ucsw = [("0", _("None"))]
986 for y in range(1, 17):
987 ucsw.append((str(y), "Input " + str(y)))
989 nim.advanced.lnb = ConfigSubList()
990 nim.advanced.lnb.append(ConfigNothing())
991 for x in range(1, 37):
992 nim.advanced.lnb.append(ConfigSubsection())
993 nim.advanced.lnb[x].lof = ConfigSelection(choices={"universal_lnb": _("Universal LNB"), "c_band": _("C-Band"), "user_defined": _("User defined")}, default="universal_lnb")
994 nim.advanced.lnb[x].lofl = ConfigInteger(default=9750, limits = (0, 99999))
995 nim.advanced.lnb[x].lofh = ConfigInteger(default=10600, limits = (0, 99999))
996 nim.advanced.lnb[x].threshold = ConfigInteger(default=11700, limits = (0, 99999))
997 # nim.advanced.lnb[x].output_12v = ConfigSelection(choices = [("0V", _("0 V")), ("12V", _("12 V"))], default="0V")
998 nim.advanced.lnb[x].increased_voltage = ConfigYesNo(default=False)
999 nim.advanced.lnb[x].toneburst = ConfigSelection(choices = [("none", _("None")), ("A", _("A")), ("B", _("B"))], default = "none")
1001 nim.advanced.lnb[x].diseqcMode = ConfigSelection(choices = [("1_2", _("1.2"))], default = "1_2")
1003 nim.advanced.lnb[x].diseqcMode = ConfigSelection(choices = [("none", _("None")), ("1_0", _("1.0")), ("1_1", _("1.1")), ("1_2", _("1.2"))], default = "none")
1004 nim.advanced.lnb[x].commitedDiseqcCommand = ConfigSelection(choices = csw)
1005 nim.advanced.lnb[x].fastDiseqc = ConfigYesNo(default=False)
1006 nim.advanced.lnb[x].sequenceRepeat = ConfigYesNo(default=False)
1007 nim.advanced.lnb[x].commandOrder1_0 = ConfigSelection(choices = [("ct", "committed, toneburst"), ("tc", "toneburst, committed")], default = "ct")
1008 nim.advanced.lnb[x].commandOrder = ConfigSelection(choices = [
1009 ("ct", "committed, toneburst"),
1010 ("tc", "toneburst, committed"),
1011 ("cut", "committed, uncommitted, toneburst"),
1012 ("tcu", "toneburst, committed, uncommitted"),
1013 ("uct", "uncommitted, committed, toneburst"),
1014 ("tuc", "toneburst, uncommitted, commmitted")],
1016 nim.advanced.lnb[x].uncommittedDiseqcCommand = ConfigSelection(choices = ucsw)
1017 nim.advanced.lnb[x].diseqcRepeats = ConfigSelection(choices = [("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))], default = "none")
1018 nim.advanced.lnb[x].longitude = ConfigFloat(default = [5,100], limits = [(0,359),(0,999)])
1019 nim.advanced.lnb[x].longitudeOrientation = ConfigSelection(choices = [("east", _("East")), ("west", _("West"))], default = "east")
1020 nim.advanced.lnb[x].latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)])
1021 nim.advanced.lnb[x].latitudeOrientation = ConfigSelection(choices = [("north", _("North")), ("south", _("South"))], default = "north")
1022 nim.advanced.lnb[x].powerMeasurement = ConfigYesNo(default=True)
1023 nim.advanced.lnb[x].powerThreshold = ConfigInteger(default=hw.get_device_name() == "dm8000" and 15 or 50, limits=(0, 100))
1024 nim.advanced.lnb[x].turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch"))], default = "fast")
1025 btime = datetime(1970, 1, 1, 7, 0);
1026 nim.advanced.lnb[x].fastTurningBegin = ConfigDateTime(default=mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 600)
1027 etime = datetime(1970, 1, 1, 19, 0);
1028 nim.advanced.lnb[x].fastTurningEnd = ConfigDateTime(default=mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 600)
1029 elif slot.isCompatible("DVB-C"):
1030 nim.configMode = ConfigSelection(
1032 "enabled": _("enabled"),
1033 "nothing": _("nothing connected"),
1035 default = "enabled")
1038 for x in nimmgr.cablesList:
1039 list.append((str(n), x[0]))
1041 nim.cable = ConfigSubsection()
1042 possible_scan_types = [("bands", _("Frequency bands")), ("steps", _("Frequency steps"))]
1044 possible_scan_types.append(("provider", _("Provider")))
1045 nim.cable.scan_provider = ConfigSelection(default = "0", choices = list)
1046 nim.cable.scan_type = ConfigSelection(default = "bands", choices = possible_scan_types)
1047 nim.cable.scan_band_EU_VHF_I = ConfigYesNo(default = True)
1048 nim.cable.scan_band_EU_MID = ConfigYesNo(default = True)
1049 nim.cable.scan_band_EU_VHF_III = ConfigYesNo(default = True)
1050 nim.cable.scan_band_EU_UHF_IV = ConfigYesNo(default = True)
1051 nim.cable.scan_band_EU_UHF_V = ConfigYesNo(default = True)
1052 nim.cable.scan_band_EU_SUPER = ConfigYesNo(default = True)
1053 nim.cable.scan_band_EU_HYPER = ConfigYesNo(default = True)
1054 nim.cable.scan_band_US_LOW = ConfigYesNo(default = False)
1055 nim.cable.scan_band_US_MID = ConfigYesNo(default = False)
1056 nim.cable.scan_band_US_HIGH = ConfigYesNo(default = False)
1057 nim.cable.scan_band_US_SUPER = ConfigYesNo(default = False)
1058 nim.cable.scan_band_US_HYPER = ConfigYesNo(default = False)
1059 nim.cable.scan_frequency_steps = ConfigInteger(default = 1000, limits = (1000, 10000))
1060 nim.cable.scan_mod_qam16 = ConfigYesNo(default = False)
1061 nim.cable.scan_mod_qam32 = ConfigYesNo(default = False)
1062 nim.cable.scan_mod_qam64 = ConfigYesNo(default = True)
1063 nim.cable.scan_mod_qam128 = ConfigYesNo(default = False)
1064 nim.cable.scan_mod_qam256 = ConfigYesNo(default = True)
1065 nim.cable.scan_sr_6900 = ConfigYesNo(default = True)
1066 nim.cable.scan_sr_6875 = ConfigYesNo(default = True)
1067 nim.cable.scan_sr_ext1 = ConfigInteger(default = 0, limits = (0, 7230))
1068 nim.cable.scan_sr_ext2 = ConfigInteger(default = 0, limits = (0, 7230))
1069 elif slot.isCompatible("DVB-T"):
1070 nim.configMode = ConfigSelection(
1072 "enabled": _("enabled"),
1073 "nothing": _("nothing connected"),
1075 default = "enabled")
1078 for x in nimmgr.terrestrialsList:
1079 list.append((str(n), x[0]))
1081 nim.terrestrial = ConfigSelection(choices = list)
1082 nim.terrestrial_5V = ConfigOnOff()
1084 nim.configMode = ConfigSelection(choices = { "nothing": _("disabled") }, default="nothing");
1085 if slot.type is not None:
1086 print "pls add support for this frontend type!", slot.type
1089 nimmgr.sec = SecConfigure(nimmgr)
1091 nimmanager = NimManager()