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):
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)
73 sec.setVoltageMode(switchParam.HV)
74 sec.setToneMode(switchParam.HILO)
76 sec.setVoltageMode(switchParam._14V)
77 sec.setToneMode(switchParam.OFF)
78 elif (diseqcmode == 3): # diseqc 1.2
79 if self.satposdepends.has_key(slotid):
80 for slot in self.satposdepends[slotid]:
81 tunermask |= (1 << slot)
82 sec.setLatitude(latitude)
83 sec.setLaDirection(laDirection)
84 sec.setLongitude(longitude)
85 sec.setLoDirection(loDirection)
86 sec.setUseInputpower(useInputPower)
87 sec.setInputpowerDelta(inputPowerDelta)
88 sec.setRotorTurningSpeed(turningSpeed)
90 for x in self.NimManager.satList:
91 print "Add sat " + str(x[0])
92 self.addSatellite(sec, int(x[0]))
93 sec.setVoltageMode(switchParam.HV)
94 sec.setToneMode(switchParam.HILO)
95 sec.setRotorPosNum(0) # USALS
97 sec.setLNBSlotMask(tunermask)
99 def setSatposDepends(self, sec, nim1, nim2):
100 print "tuner", nim1, "depends on satpos of", nim2
101 sec.setTunerDepends(nim1, nim2)
103 def linkNIMs(self, sec, nim1, nim2):
104 print "link tuner", nim1, "to tuner", nim2
105 sec.setTunerLinked(nim1, nim2)
107 def getRoot(self, slotid, connto):
109 while (self.NimManager.getNimConfig(connto).configMode.value in ["satposdepends", "equal", "loopthrough"]):
110 connto = int(self.NimManager.getNimConfig(connto).connectedTo.value)
111 if connto in visited: # prevent endless loop
113 visited.append(connto)
117 sec = secClass.getInstance()
118 self.configuredSatellites = Set()
119 sec.clear() ## this do unlinking NIMs too !!
120 print "sec config cleared"
123 self.satposdepends = { }
126 nim_slots = self.NimManager.nim_slots
130 for slot in nim_slots:
131 if slot.type is not None:
132 used_nim_slots.append((slot.slot, slot.description, slot.config.configMode.value != "nothing" and True or False, slot.isCompatible("DVB-S2")))
133 eDVBResourceManager.getInstance().setFrontendSlotInformations(used_nim_slots)
135 for slot in nim_slots:
138 if slot.isCompatible("DVB-S"):
139 # save what nim we link to/are equal to/satposdepends to.
140 # this is stored in the *value* (not index!) of the config list
141 if nim.configMode.value == "equal":
142 connto = self.getRoot(x, int(nim.connectedTo.value))
143 if not self.equal.has_key(connto):
144 self.equal[connto] = []
145 self.equal[connto].append(x)
146 elif nim.configMode.value == "loopthrough":
147 self.linkNIMs(sec, x, int(nim.connectedTo.value))
148 connto = self.getRoot(x, int(nim.connectedTo.value))
149 if not self.linked.has_key(connto):
150 self.linked[connto] = []
151 self.linked[connto].append(x)
152 elif nim.configMode.value == "satposdepends":
153 self.setSatposDepends(sec, x, int(nim.connectedTo.value))
154 connto = self.getRoot(x, int(nim.connectedTo.value))
155 if not self.satposdepends.has_key(connto):
156 self.satposdepends[connto] = []
157 self.satposdepends[connto].append(x)
159 for slot in nim_slots:
163 if slot.isCompatible("DVB-S"):
164 print "slot: " + str(x) + " configmode: " + str(nim.configMode.value)
165 if nim.configMode.value in [ "loopthrough", "satposdepends", "nothing" ]:
168 sec.setSlotNotLinked(x)
169 if nim.configMode.value == "equal":
171 elif nim.configMode.value == "simple": #simple config
172 print "diseqcmode: ", nim.diseqcMode.value
173 if nim.diseqcMode.value == "single": #single
174 if nim.simpleSingleSendDiSEqC.value:
175 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA)
177 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.NONE, diseqcpos = diseqcParam.SENDNO)
178 elif nim.diseqcMode.value == "toneburst_a_b": #Toneburst A/B
179 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.A, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO)
180 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.B, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO)
181 elif nim.diseqcMode.value == "diseqc_a_b": #DiSEqC A/B
182 fastDiSEqC = nim.simpleDiSEqCOnlyOnSatChange.value
183 setVoltageTone = nim.simpleDiSEqCSetVoltageTone.value
184 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone)
185 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone)
186 elif nim.diseqcMode.value == "diseqc_a_b_c_d": #DiSEqC A/B/C/D
187 fastDiSEqC = nim.simpleDiSEqCOnlyOnSatChange.value
188 setVoltageTone = nim.simpleDiSEqCSetVoltageTone.value
189 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone)
190 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone)
191 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcC.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BA, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone)
192 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcD.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BB, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone)
193 elif nim.diseqcMode.value == "positioner": #Positioner
194 if nim.latitudeOrientation.value == "north":
195 laValue = rotorParam.NORTH
197 laValue = rotorParam.SOUTH
198 if nim.longitudeOrientation.value == "east":
199 loValue = rotorParam.EAST
201 loValue = rotorParam.WEST
202 inputPowerDelta=nim.powerThreshold.value
205 if nim.powerMeasurement.value:
207 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
208 if turn_speed_dict.has_key(nim.turningSpeed.value):
209 turning_speed = turn_speed_dict[nim.turningSpeed.value]
211 beg_time = localtime(nim.fastTurningBegin.value)
212 end_time = localtime(nim.fastTurningEnd.value)
213 turning_speed = ((beg_time.tm_hour+1) * 60 + beg_time.tm_min + 1) << 16
214 turning_speed |= (end_time.tm_hour+1) * 60 + end_time.tm_min + 1
215 self.addLNBSimple(sec, slotid = x, diseqcmode = 3,
216 longitude = nim.longitude.float,
217 loDirection = loValue,
218 latitude = nim.latitude.float,
219 laDirection = laValue,
220 turningSpeed = turning_speed,
221 useInputPower = useInputPower,
222 inputPowerDelta = inputPowerDelta)
223 elif nim.configMode.value == "advanced": #advanced config
224 self.updateAdvanced(sec, x)
225 print "sec config completed"
227 def updateAdvanced(self, sec, slotid):
229 for x in range(1,37):
232 #wildcard for all satellites ( for rotor )
233 for x in range(3601, 3605):
234 lnb = int(config.Nims[slotid].advanced.sat[x].lnb.value)
236 for x in self.NimManager.satList:
237 print "add", x[0], "to", lnb
238 lnbSat[lnb].append(x[0])
240 for x in self.NimManager.satList:
241 lnb = int(config.Nims[slotid].advanced.sat[x[0]].lnb.value)
243 print "add", x[0], "to", lnb
244 lnbSat[lnb].append(x[0])
246 for x in range(1,37):
247 if len(lnbSat[x]) > 0:
248 currLnb = config.Nims[slotid].advanced.lnb[x]
251 tunermask = 1 << slotid
252 if self.equal.has_key(slotid):
253 for slot in self.equal[slotid]:
254 tunermask |= (1 << slot)
255 elif self.linked.has_key(slotid):
256 for slot in self.linked[slotid]:
257 tunermask |= (1 << slot)
259 if currLnb.lof.value == "universal_lnb":
260 sec.setLNBLOFL(9750000)
261 sec.setLNBLOFH(10600000)
262 sec.setLNBThreshold(11700000)
263 elif currLnb.lof.value == "c_band":
264 sec.setLNBLOFL(5150000)
265 sec.setLNBLOFH(5150000)
266 sec.setLNBThreshold(5150000)
267 elif currLnb.lof.value == "user_defined":
268 sec.setLNBLOFL(currLnb.lofl.value * 1000)
269 sec.setLNBLOFH(currLnb.lofh.value * 1000)
270 sec.setLNBThreshold(currLnb.threshold.value * 1000)
272 # if currLnb.output_12v.value == "0V":
273 # pass # nyi in drivers
274 # elif currLnb.output_12v.value == "12V":
275 # pass # nyi in drivers
277 if currLnb.increased_voltage.value:
278 sec.setLNBIncreasedVoltage(lnbParam.ON)
280 sec.setLNBIncreasedVoltage(lnbParam.OFF)
282 dm = currLnb.diseqcMode.value
284 sec.setDiSEqCMode(diseqcParam.NONE)
286 sec.setDiSEqCMode(diseqcParam.V1_0)
288 sec.setDiSEqCMode(diseqcParam.V1_1)
290 sec.setDiSEqCMode(diseqcParam.V1_2)
292 if self.satposdepends.has_key(slotid):
293 for slot in self.satposdepends[slotid]:
294 tunermask |= (1 << slot)
297 if currLnb.toneburst.value == "none":
298 sec.setToneburst(diseqcParam.NO)
299 elif currLnb.toneburst.value == "A":
300 sec.setToneburst(diseqcParam.A)
301 elif currLnb.toneburst.value == "B":
302 sec.setToneburst(diseqcParam.B)
304 # Committed Diseqc Command
305 cdc = currLnb.commitedDiseqcCommand.value
307 c = { "none": diseqcParam.SENDNO,
308 "AA": diseqcParam.AA,
309 "AB": diseqcParam.AB,
310 "BA": diseqcParam.BA,
311 "BB": diseqcParam.BB }
314 sec.setCommittedCommand(c[cdc])
316 sec.setCommittedCommand(long(cdc))
318 sec.setFastDiSEqC(currLnb.fastDiseqc.value)
320 sec.setSeqRepeat(currLnb.sequenceRepeat.value)
322 if currLnb.diseqcMode.value == "1_0":
323 currCO = currLnb.commandOrder1_0.value
325 currCO = currLnb.commandOrder.value
327 udc = int(currLnb.uncommittedDiseqcCommand.value)
329 sec.setUncommittedCommand(0xF0|(udc-1))
331 sec.setUncommittedCommand(0) # SENDNO
333 sec.setRepeats({"none": 0, "one": 1, "two": 2, "three": 3}[currLnb.diseqcRepeats.value])
335 setCommandOrder = False
337 # 0 "committed, toneburst",
338 # 1 "toneburst, committed",
339 # 2 "committed, uncommitted, toneburst",
340 # 3 "toneburst, committed, uncommitted",
341 # 4 "uncommitted, committed, toneburst"
342 # 5 "toneburst, uncommitted, commmitted"
343 order_map = {"ct": 0, "tc": 1, "cut": 2, "tcu": 3, "uct": 4, "tuc": 5}
344 sec.setCommandOrder(order_map[currCO])
347 latitude = currLnb.latitude.float
348 sec.setLatitude(latitude)
349 longitude = currLnb.longitude.float
350 sec.setLongitude(longitude)
351 if currLnb.latitudeOrientation.value == "north":
352 sec.setLaDirection(rotorParam.NORTH)
354 sec.setLaDirection(rotorParam.SOUTH)
355 if currLnb.longitudeOrientation.value == "east":
356 sec.setLoDirection(rotorParam.EAST)
358 sec.setLoDirection(rotorParam.WEST)
360 if currLnb.powerMeasurement.value:
361 sec.setUseInputpower(True)
362 sec.setInputpowerDelta(currLnb.powerThreshold.value)
363 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
364 if turn_speed_dict.has_key(currLnb.turningSpeed.value):
365 turning_speed = turn_speed_dict[currLnb.turningSpeed.value]
367 beg_time = localtime(currLnb.fastTurningBegin.value)
368 end_time = localtime(currLnb.fastTurningEnd.value)
369 turning_speed = ((beg_time.tm_hour + 1) * 60 + beg_time.tm_min + 1) << 16
370 turning_speed |= (end_time.tm_hour + 1) * 60 + end_time.tm_min + 1
371 sec.setRotorTurningSpeed(turning_speed)
373 sec.setUseInputpower(False)
375 sec.setLNBSlotMask(tunermask)
377 # finally add the orbital positions
379 self.addSatellite(sec, y)
381 satpos = x > 32 and (3604-(36 - x)) or y
384 currSat = config.Nims[slotid].advanced.sat[satpos]
385 if currSat.voltage.value == "polarization":
386 sec.setVoltageMode(switchParam.HV)
387 elif currSat.voltage.value == "13V":
388 sec.setVoltageMode(switchParam._14V)
389 elif currSat.voltage.value == "18V":
390 sec.setVoltageMode(switchParam._18V)
392 if currSat.tonemode.value == "band":
393 sec.setToneMode(switchParam.HILO)
394 elif currSat.tonemode.value == "on":
395 sec.setToneMode(switchParam.ON)
396 elif currSat.tonemode.value == "off":
397 sec.setToneMode(switchParam.OFF)
399 if not currSat.usals.value and x < 34:
400 sec.setRotorPosNum(currSat.rotorposition.value)
402 sec.setRotorPosNum(0) #USALS
404 def __init__(self, nimmgr):
405 self.NimManager = nimmgr
406 self.configuredSatellites = Set()
410 def __init__(self, slot, type, description, has_outputs = True, internally_connectable = None):
413 if type not in ["DVB-S", "DVB-C", "DVB-T", "DVB-S2", None]:
414 print "warning: unknown NIM type %s, not using." % type
418 self.description = description
419 self.has_outputs = has_outputs
420 self.internally_connectable = internally_connectable
422 def isCompatible(self, what):
425 "DVB-S": ["DVB-S", None],
426 "DVB-C": ["DVB-C", None],
427 "DVB-T": ["DVB-T", None],
428 "DVB-S2": ["DVB-S", "DVB-S2", None]
430 return what in compatible[self.type]
432 def connectableTo(self):
434 "DVB-S": ["DVB-S", "DVB-S2"],
437 "DVB-S2": ["DVB-S", "DVB-S2"]
439 return connectable[self.type]
441 def getSlotName(self):
442 # get a friendly description for a slot name.
443 # we name them "Tuner A/B/C/...", because that's what's usually written on the back
445 return _("Tuner ") + chr(ord('A') + self.slot)
447 slot_name = property(getSlotName)
450 return chr(ord('A') + self.slot)
452 def hasOutputs(self):
453 return self.has_outputs
455 def internallyConnectableTo(self):
456 return self.internally_connectable
458 slot_id = property(getSlotID)
460 def getFriendlyType(self):
469 friendly_type = property(getFriendlyType)
471 def getFriendlyFullDescription(self):
472 nim_text = self.slot_name + ": "
475 nim_text += _("(empty)")
477 nim_text += self.description + " (" + self.friendly_type + ")"
481 friendly_full_description = property(getFriendlyFullDescription)
482 config_mode = property(lambda self: config.Nims[self.slot].configMode.value)
483 config = property(lambda self: config.Nims[self.slot])
484 empty = property(lambda self: self.type is None)
487 def getConfiguredSats(self):
488 return self.sec.getConfiguredSats()
490 def getTransponders(self, pos):
491 if self.transponders.has_key(pos):
492 return self.transponders[pos]
496 def getTranspondersCable(self, nim):
497 nimConfig = config.Nims[nim]
498 if nimConfig.configMode.value != "nothing" and nimConfig.cable.scan_type.value == "provider":
499 return self.transponderscable[self.cablesList[nimConfig.cable.scan_provider.index][0]]
502 def getTranspondersTerrestrial(self, region):
503 return self.transpondersterrestrial[region]
505 def getCableDescription(self, nim):
506 return self.cablesList[config.Nims[nim].scan_provider.index][0]
508 def getCableFlags(self, nim):
509 return self.cablesList[config.Nims[nim].scan_provider.index][1]
511 def getTerrestrialDescription(self, nim):
512 return self.terrestrialsList[config.Nims[nim].terrestrial.index][0]
514 def getTerrestrialFlags(self, nim):
515 return self.terrestrialsList[config.Nims[nim].terrestrial.index][1]
517 def getSatDescription(self, pos):
518 return self.satellites[pos]
520 def readTransponders(self):
521 # read initial networks from file. we only read files which we are interested in,
522 # which means only these where a compatible tuner exists.
523 self.satellites = { }
524 self.transponders = { }
525 self.transponderscable = { }
526 self.transpondersterrestrial = { }
527 db = eDVBDB.getInstance()
528 if self.hasNimType("DVB-S"):
529 print "Reading satellites.xml"
530 db.readSatellites(self.satList, self.satellites, self.transponders)
531 # print "SATLIST", self.satList
532 # print "SATS", self.satellites
533 # print "TRANSPONDERS", self.transponders
535 if self.hasNimType("DVB-C"):
536 print "Reading cables.xml"
537 db.readCables(self.cablesList, self.transponderscable)
538 # print "CABLIST", self.cablesList
539 # print "TRANSPONDERS", self.transponders
541 if self.hasNimType("DVB-T"):
542 print "Reading terrestrial.xml"
543 db.readTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
544 # print "TERLIST", self.terrestrialsList
545 # print "TRANSPONDERS", self.transpondersterrestrial
547 def enumerateNIMs(self):
548 # enum available NIMs. This is currently very dreambox-centric and uses the /proc/bus/nim_sockets interface.
549 # the result will be stored into nim_slots.
550 # the content of /proc/bus/nim_sockets looks like:
553 # Name: BCM4501 DVB-S2 NIM (internal)
556 # Name: BCM4501 DVB-S2 NIM (internal)
559 # Name: Philips TU1216
562 # Name: Alps BSBE1 702A
565 # Type will be either "DVB-S", "DVB-S2", "DVB-T", "DVB-C" or None.
567 # nim_slots is an array which has exactly one entry for each slot, even for empty ones.
570 nimfile = tryOpen("/proc/bus/nim_sockets")
578 for line in nimfile.readlines():
581 if line.strip().startswith("NIM Socket"):
582 parts = line.strip().split(" ")
583 current_slot = int(parts[2][:-1])
584 entries[current_slot] = {}
585 elif line.strip().startswith("Type:"):
586 entries[current_slot]["type"] = str(line.strip()[6:])
587 elif line.strip().startswith("Name:"):
588 entries[current_slot]["name"] = str(line.strip()[6:])
589 elif line.strip().startswith("Has_Outputs:"):
590 input = str(line.strip()[len("Has_Outputs:") + 1:])
591 entries[current_slot]["has_outputs"] = (input == "yes")
592 elif line.strip().startswith("Internally_Connectable:"):
593 input = int(line.strip()[len("Internally_Connectable:") + 1:])
594 entries[current_slot]["internally_connectable"] = input
595 elif line.strip().startswith("empty"):
596 entries[current_slot]["type"] = None
597 entries[current_slot]["name"] = _("N/A")
600 for id, entry in entries.items():
601 if not (entry.has_key("name") and entry.has_key("type")):
602 entry["name"] = _("N/A")
604 if not (entry.has_key("has_outputs")):
605 entry["has_outputs"] = True
606 if not (entry.has_key("internally_connectable")):
607 entry["internally_connectable"] = None
608 self.nim_slots.append(NIM(slot = id, description = entry["name"], type = entry["type"], has_outputs = entry["has_outputs"], internally_connectable = entry["internally_connectable"]))
610 def hasNimType(self, chktype):
611 for slot in self.nim_slots:
612 if slot.isCompatible(chktype):
616 def getNimType(self, slotid):
617 return self.nim_slots[slotid].type
619 def getNimDescription(self, slotid):
620 return self.nim_slots[slotid].friendly_full_description
622 def getNimListOfType(self, type, exception = -1):
623 # returns a list of indexes for NIMs compatible to the given type, except for 'exception'
625 for x in self.nim_slots:
626 if x.isCompatible(type) and x.slot != exception:
633 self.terrestrialsList = []
635 self.readTransponders()
636 InitNimManager(self) #init config stuff
638 # get a list with the friendly full description
641 for slot in self.nim_slots:
642 list.append(slot.friendly_full_description)
645 def getSlotCount(self):
646 return len(self.nim_slots)
648 def hasOutputs(self, slotid):
649 return self.nim_slots[slotid].hasOutputs()
651 def canConnectTo(self, slotid):
653 if self.nim_slots[slotid].internallyConnectableTo() is not None:
654 slots.append(self.nim_slots[slotid].internallyConnectableTo())
655 for type in self.nim_slots[slotid].connectableTo():
656 for slot in self.getNimListOfType(type, exception = slotid):
657 if self.hasOutputs(slot):
659 # remove nims, that have a conntectedTo reference on
660 for testnim in slots[:]:
661 for nim in self.getNimListOfType("DVB-S", slotid):
662 nimConfig = self.getNimConfig(nim)
663 if nimConfig.content.items.has_key("configMode") and nimConfig.configMode.value == "loopthrough" and int(nimConfig.connectedTo.value) == testnim:
664 slots.remove(testnim)
670 def canEqualTo(self, slotid):
671 type = self.getNimType(slotid)
674 nimList = self.getNimListOfType(type, slotid)
675 for nim in nimList[:]:
676 mode = self.getNimConfig(nim)
677 if mode.configMode.value == "loopthrough" or mode.configMode.value == "satposdepends":
681 def canDependOn(self, slotid):
682 type = self.getNimType(slotid)
685 nimList = self.getNimListOfType(type, slotid)
687 for nim in nimList[:]:
688 mode = self.getNimConfig(nim)
689 nimHaveRotor = mode.configMode.value == "simple" and mode.diseqcMode.value == "positioner"
690 if not nimHaveRotor and mode.configMode.value == "advanced":
691 for x in range(3601, 3605):
692 lnb = int(mode.advanced.sat[x].lnb.value)
697 for sat in mode.advanced.sat.values():
698 lnb_num = int(sat.lnb.value)
699 diseqcmode = lnb_num and mode.advanced.lnb[lnb_num].diseqcMode.value or ""
700 if diseqcmode == "1_2":
704 alreadyConnected = False
705 for testnim in nimList:
706 testmode = self.getNimConfig(testnim)
707 if testmode.configMode.value == "satposdepends" and int(testmode.connectedTo.value) == int(nim):
708 alreadyConnected = True
710 if not alreadyConnected:
711 positionerList.append(nim)
712 return positionerList
714 def getNimConfig(self, slotid):
715 return config.Nims[slotid]
717 def getSatName(self, pos):
718 for sat in self.satList:
723 def getSatList(self):
726 def getSatListForNim(self, slotid):
728 if self.nim_slots[slotid].isCompatible("DVB-S"):
729 nim = config.Nims[slotid]
730 #print "slotid:", slotid
732 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.index]
733 #print "diseqcA:", config.Nims[slotid].diseqcA.value
734 configMode = nim.configMode.value
736 if configMode == "equal":
737 slotid = int(nim.connectedTo.value)
738 nim = config.Nims[slotid]
739 configMode = nim.configMode.value
740 elif configMode == "loopthrough":
741 slotid = self.sec.getRoot(slotid, int(nim.connectedTo.value))
742 nim = config.Nims[slotid]
743 configMode = nim.configMode.value
745 if configMode == "simple":
746 dm = nim.diseqcMode.value
747 if dm in ["single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
748 if nim.diseqcA.orbital_position != 3601:
749 list.append(self.satList[nim.diseqcA.index-1])
750 if dm in ["toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
751 if nim.diseqcB.orbital_position != 3601:
752 list.append(self.satList[nim.diseqcB.index-1])
753 if dm == "diseqc_a_b_c_d":
754 if nim.diseqcC.orbital_position != 3601:
755 list.append(self.satList[nim.diseqcC.index-1])
756 if nim.diseqcD.orbital_position != 3601:
757 list.append(self.satList[nim.diseqcD.index-1])
758 if dm == "positioner":
759 for x in self.satList:
761 elif configMode == "advanced":
762 for x in range(3601, 3605):
763 if int(nim.advanced.sat[x].lnb.value) != 0:
764 for x in self.satList:
767 for x in self.satList:
768 if int(nim.advanced.sat[x[0]].lnb.value) != 0:
772 def getRotorSatListForNim(self, slotid):
774 if self.nim_slots[slotid].isCompatible("DVB-S"):
775 #print "slotid:", slotid
776 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
777 #print "diseqcA:", config.Nims[slotid].diseqcA.value
778 configMode = config.Nims[slotid].configMode.value
779 if configMode == "simple":
780 if config.Nims[slotid].diseqcMode.value == "positioner":
781 for x in self.satList:
783 elif configMode == "advanced":
784 nim = config.Nims[slotid]
785 for x in range(3601, 3605):
786 if int(nim.advanced.sat[x].lnb.value) != 0:
787 for x in self.satList:
790 for x in self.satList:
791 lnbnum = int(nim.advanced.sat[x[0]].lnb.value)
793 lnb = nim.advanced.lnb[lnbnum]
794 if lnb.diseqcMode.value == "1_2":
799 config.sec = ConfigSubsection()
801 x = ConfigInteger(default=15, limits = (0, 9999))
802 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_CONT_TONE, configElement.value))
803 config.sec.delay_after_continuous_tone_change = x
805 x = ConfigInteger(default=10, limits = (0, 9999))
806 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_VOLTAGE_CHANGE, configElement.value))
807 config.sec.delay_after_final_voltage_change = x
809 x = ConfigInteger(default=120, limits = (0, 9999))
810 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_DISEQC_REPEATS, configElement.value))
811 config.sec.delay_between_diseqc_repeats = x
813 x = ConfigInteger(default=50, limits = (0, 9999))
814 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_LAST_DISEQC_CMD, configElement.value))
815 config.sec.delay_after_last_diseqc_command = x
817 x = ConfigInteger(default=50, limits = (0, 9999))
818 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value))
819 config.sec.delay_after_toneburst = x
821 x = ConfigInteger(default=20, limits = (0, 9999))
822 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS, configElement.value))
823 config.sec.delay_after_change_voltage_before_switch_command = x
825 x = ConfigInteger(default=200, limits = (0, 9999))
826 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS, configElement.value))
827 config.sec.delay_after_enable_voltage_before_switch_command = x
829 x = ConfigInteger(default=700, limits = (0, 9999))
830 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_SWITCH_AND_MOTOR_CMD, configElement.value))
831 config.sec.delay_between_switch_and_motor_command = x
833 x = ConfigInteger(default=500, limits = (0, 9999))
834 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MEASURE_IDLE_INPUTPOWER, configElement.value))
835 config.sec.delay_after_voltage_change_before_measure_idle_inputpower = x
837 x = ConfigInteger(default=750, limits = (0, 9999))
838 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_MOTOR_CMD, configElement.value))
839 config.sec.delay_after_enable_voltage_before_motor_command = x
841 x = ConfigInteger(default=500, limits = (0, 9999))
842 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_MOTOR_STOP_CMD, configElement.value))
843 config.sec.delay_after_motor_stop_command = x
845 x = ConfigInteger(default=500, limits = (0, 9999))
846 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MOTOR_CMD, configElement.value))
847 config.sec.delay_after_voltage_change_before_motor_command = x
849 x = ConfigInteger(default=70, limits = (0, 9999))
850 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BEFORE_SEQUENCE_REPEAT, configElement.value))
851 config.sec.delay_before_sequence_repeat = x
853 x = ConfigInteger(default=360, limits = (0, 9999))
854 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_RUNNING_TIMEOUT, configElement.value))
855 config.sec.motor_running_timeout = x
857 x = ConfigInteger(default=1, limits = (0, 5))
858 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_COMMAND_RETRIES, configElement.value))
859 config.sec.motor_command_retries = x
861 # TODO add support for satpos depending nims to advanced nim configuration
862 # so a second/third/fourth cable from a motorized lnb can used behind a
863 # diseqc 1.0 / diseqc 1.1 / toneburst switch
864 # the C(++) part should can handle this
865 # the configElement should be only visible when diseqc 1.2 is disabled
867 def InitNimManager(nimmgr):
871 config.Nims = ConfigSubList()
872 for x in range(len(nimmgr.nim_slots)):
873 config.Nims.append(ConfigSubsection())
875 for slot in nimmgr.nim_slots:
879 if slot.isCompatible("DVB-S"):
880 choices = { "nothing": _("nothing connected"),
881 "simple": _("simple"),
882 "advanced": _("advanced")}
883 if len(nimmgr.getNimListOfType(slot.type, exception = x)) > 0:
884 choices["equal"] = _("equal to")
885 choices["satposdepends"] = _("second cable of motorized LNB")
886 if len(nimmgr.canConnectTo(x)) > 0:
887 choices["loopthrough"] = _("loopthrough to")
888 nim.configMode = ConfigSelection(choices = choices, default = "nothing")
890 # for y in nimmgr.nim_slots:
892 # if not y.isCompatible("DVB-S"):
894 # nim.configMode.value = "simple"
895 # nim.configMode.save()
897 nim.diseqcMode = ConfigSelection(
899 ("single", _("Single")),
900 ("toneburst_a_b", _("Toneburst A/B")),
901 ("diseqc_a_b", _("DiSEqC A/B")),
902 ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")),
903 ("positioner", _("Positioner"))],
904 default = "diseqc_a_b")
907 for id in nimmgr.getNimListOfType("DVB-S"):
909 choices.append((str(id), nimmgr.getNimDescription(id)))
910 nim.connectedTo = ConfigSelection(choices = choices)
911 nim.simpleSingleSendDiSEqC = ConfigYesNo(default=False)
912 nim.simpleDiSEqCSetVoltageTone = ConfigYesNo(default=True)
913 nim.simpleDiSEqCOnlyOnSatChange = ConfigYesNo(default=False)
914 nim.diseqcA = getConfigSatlist(192, [(3601, _('nothing connected'), 1)] + nimmgr.satList)
915 nim.diseqcB = getConfigSatlist(130, [(3601, _('nothing connected'), 1)] + nimmgr.satList)
916 nim.diseqcC = ConfigSatlist(list = [(3601, _('nothing connected'), 1)] + nimmgr.satList)
917 nim.diseqcD = ConfigSatlist(list = [(3601, _('nothing connected'), 1)] + nimmgr.satList)
918 nim.positionerMode = ConfigSelection(
920 ("usals", _("USALS")),
921 ("manual", _("manual"))],
923 nim.longitude = ConfigFloat(default=[5,100], limits=[(0,359),(0,999)])
924 nim.longitudeOrientation = ConfigSelection(choices={"east": _("East"), "west": _("West")}, default = "east")
925 nim.latitude = ConfigFloat(default=[50,767], limits=[(0,359),(0,999)])
926 nim.latitudeOrientation = ConfigSelection(choices={"north": _("North"), "south": _("South")}, default="north")
927 nim.powerMeasurement = ConfigYesNo(default=True)
928 nim.powerThreshold = ConfigInteger(default=hw.get_device_name() == "dm8000" and 15 or 50, limits=(0, 100))
929 nim.turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch")) ], default = "fast")
930 btime = datetime(1970, 1, 1, 7, 0);
931 nim.fastTurningBegin = ConfigDateTime(default = mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 900)
932 etime = datetime(1970, 1, 1, 19, 0);
933 nim.fastTurningEnd = ConfigDateTime(default = mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 900)
936 nim.advanced = ConfigSubsection()
937 tmp = [(3601, _('All Satellites')+' 1', 1), (3602, _('All Satellites')+' 2', 1), (3603, _('All Satellites')+' 3', 1), (3604, _('All Satellites')+' 4', 1)]
938 nim.advanced.sats = getConfigSatlist(192,nimmgr.satList+tmp)
939 nim.advanced.sat = ConfigSubDict()
940 lnbs = [("0", "not available")]
941 for y in range(1, 33):
942 lnbs.append((str(y), "LNB " + str(y)))
944 for x in nimmgr.satList:
945 nim.advanced.sat[x[0]] = ConfigSubsection()
946 nim.advanced.sat[x[0]].voltage = ConfigSelection(choices={"polarization": _("Polarization"), "13V": _("13 V"), "18V": _("18 V")}, default = "polarization")
947 nim.advanced.sat[x[0]].tonemode = ConfigSelection(choices={"band": _("Band"), "on": _("On"), "off": _("Off")}, default = "band")
948 nim.advanced.sat[x[0]].usals = ConfigYesNo(default=True)
949 nim.advanced.sat[x[0]].rotorposition = ConfigInteger(default=1, limits=(1, 255))
950 nim.advanced.sat[x[0]].lnb = ConfigSelection(choices = lnbs)
952 for x in range(3601, 3605):
953 nim.advanced.sat[x] = ConfigSubsection()
954 nim.advanced.sat[x].voltage = ConfigSelection(choices={"polarization": _("Polarization"), "13V": _("13 V"), "18V": _("18 V")}, default = "polarization")
955 nim.advanced.sat[x].tonemode = ConfigSelection(choices={"band": _("Band"), "on": _("On"), "off": _("Off")}, default = "band")
956 nim.advanced.sat[x].usals = ConfigYesNo(default=True)
957 nim.advanced.sat[x].rotorposition = ConfigInteger(default=1, limits=(1, 255))
959 nim.advanced.sat[x].lnb = ConfigSelection(choices = [("0", "not available"), (str(lnbnum), "LNB %d"%(lnbnum))], default="0")
961 csw = [("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))]
962 for y in range(0, 16):
963 csw.append((str(0xF0|y), "Input " + str(y+1)))
965 ucsw = [("0", _("None"))]
966 for y in range(1, 17):
967 ucsw.append((str(y), "Input " + str(y)))
969 nim.advanced.lnb = ConfigSubList()
970 nim.advanced.lnb.append(ConfigNothing())
971 for x in range(1, 37):
972 nim.advanced.lnb.append(ConfigSubsection())
973 nim.advanced.lnb[x].lof = ConfigSelection(choices={"universal_lnb": _("Universal LNB"), "c_band": _("C-Band"), "user_defined": _("User defined")}, default="universal_lnb")
974 nim.advanced.lnb[x].lofl = ConfigInteger(default=9750, limits = (0, 99999))
975 nim.advanced.lnb[x].lofh = ConfigInteger(default=10600, limits = (0, 99999))
976 nim.advanced.lnb[x].threshold = ConfigInteger(default=11700, limits = (0, 99999))
977 # nim.advanced.lnb[x].output_12v = ConfigSelection(choices = [("0V", _("0 V")), ("12V", _("12 V"))], default="0V")
978 nim.advanced.lnb[x].increased_voltage = ConfigYesNo(default=False)
979 nim.advanced.lnb[x].toneburst = ConfigSelection(choices = [("none", _("None")), ("A", _("A")), ("B", _("B"))], default = "none")
981 nim.advanced.lnb[x].diseqcMode = ConfigSelection(choices = [("1_2", _("1.2"))], default = "1_2")
983 nim.advanced.lnb[x].diseqcMode = ConfigSelection(choices = [("none", _("None")), ("1_0", _("1.0")), ("1_1", _("1.1")), ("1_2", _("1.2"))], default = "none")
984 nim.advanced.lnb[x].commitedDiseqcCommand = ConfigSelection(choices = csw)
985 nim.advanced.lnb[x].fastDiseqc = ConfigYesNo(default=False)
986 nim.advanced.lnb[x].sequenceRepeat = ConfigYesNo(default=False)
987 nim.advanced.lnb[x].commandOrder1_0 = ConfigSelection(choices = [("ct", "committed, toneburst"), ("tc", "toneburst, committed")], default = "ct")
988 nim.advanced.lnb[x].commandOrder = ConfigSelection(choices = [
989 ("ct", "committed, toneburst"),
990 ("tc", "toneburst, committed"),
991 ("cut", "committed, uncommitted, toneburst"),
992 ("tcu", "toneburst, committed, uncommitted"),
993 ("uct", "uncommitted, committed, toneburst"),
994 ("tuc", "toneburst, uncommitted, commmitted")],
996 nim.advanced.lnb[x].uncommittedDiseqcCommand = ConfigSelection(choices = ucsw)
997 nim.advanced.lnb[x].diseqcRepeats = ConfigSelection(choices = [("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))], default = "none")
998 nim.advanced.lnb[x].longitude = ConfigFloat(default = [5,100], limits = [(0,359),(0,999)])
999 nim.advanced.lnb[x].longitudeOrientation = ConfigSelection(choices = [("east", _("East")), ("west", _("West"))], default = "east")
1000 nim.advanced.lnb[x].latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)])
1001 nim.advanced.lnb[x].latitudeOrientation = ConfigSelection(choices = [("north", _("North")), ("south", _("South"))], default = "north")
1002 nim.advanced.lnb[x].powerMeasurement = ConfigYesNo(default=True)
1003 nim.advanced.lnb[x].powerThreshold = ConfigInteger(default=hw.get_device_name() == "dm8000" and 15 or 50, limits=(0, 100))
1004 nim.advanced.lnb[x].turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch"))], default = "fast")
1005 btime = datetime(1970, 1, 1, 7, 0);
1006 nim.advanced.lnb[x].fastTurningBegin = ConfigDateTime(default=mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 600)
1007 etime = datetime(1970, 1, 1, 19, 0);
1008 nim.advanced.lnb[x].fastTurningEnd = ConfigDateTime(default=mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 600)
1009 elif slot.isCompatible("DVB-C"):
1010 nim.configMode = ConfigSelection(
1012 "enabled": _("enabled"),
1013 "nothing": _("nothing connected"),
1015 default = "enabled")
1018 for x in nimmgr.cablesList:
1019 list.append((str(n), x[0]))
1021 nim.cable = ConfigSubsection()
1022 possible_scan_types = [("bands", _("Frequency bands")), ("steps", _("Frequency steps"))]
1024 possible_scan_types.append(("provider", _("Provider")))
1025 nim.cable.scan_provider = ConfigSelection(default = "0", choices = list)
1026 nim.cable.scan_type = ConfigSelection(default = "bands", choices = possible_scan_types)
1027 nim.cable.scan_band_EU_VHF_I = ConfigYesNo(default = True)
1028 nim.cable.scan_band_EU_MID = ConfigYesNo(default = True)
1029 nim.cable.scan_band_EU_VHF_III = ConfigYesNo(default = True)
1030 nim.cable.scan_band_EU_UHF_IV = ConfigYesNo(default = True)
1031 nim.cable.scan_band_EU_UHF_V = ConfigYesNo(default = True)
1032 nim.cable.scan_band_EU_SUPER = ConfigYesNo(default = True)
1033 nim.cable.scan_band_EU_HYPER = ConfigYesNo(default = True)
1034 nim.cable.scan_band_US_LOW = ConfigYesNo(default = False)
1035 nim.cable.scan_band_US_MID = ConfigYesNo(default = False)
1036 nim.cable.scan_band_US_HIGH = ConfigYesNo(default = False)
1037 nim.cable.scan_band_US_SUPER = ConfigYesNo(default = False)
1038 nim.cable.scan_band_US_HYPER = ConfigYesNo(default = False)
1039 nim.cable.scan_frequency_steps = ConfigInteger(default = 1000, limits = (1000, 10000))
1040 nim.cable.scan_mod_qam16 = ConfigYesNo(default = False)
1041 nim.cable.scan_mod_qam32 = ConfigYesNo(default = False)
1042 nim.cable.scan_mod_qam64 = ConfigYesNo(default = True)
1043 nim.cable.scan_mod_qam128 = ConfigYesNo(default = False)
1044 nim.cable.scan_mod_qam256 = ConfigYesNo(default = True)
1045 nim.cable.scan_sr_6900 = ConfigYesNo(default = True)
1046 nim.cable.scan_sr_6875 = ConfigYesNo(default = True)
1047 nim.cable.scan_sr_ext1 = ConfigInteger(default = 0, limits = (0, 7230))
1048 nim.cable.scan_sr_ext2 = ConfigInteger(default = 0, limits = (0, 7230))
1049 elif slot.isCompatible("DVB-T"):
1050 nim.configMode = ConfigSelection(
1052 "enabled": _("enabled"),
1053 "nothing": _("nothing connected"),
1055 default = "enabled")
1058 for x in nimmgr.terrestrialsList:
1059 list.append((str(n), x[0]))
1061 nim.terrestrial = ConfigSelection(choices = list)
1062 nim.terrestrial_5V = ConfigOnOff()
1064 nim.configMode = ConfigSelection(choices = { "nothing": _("disabled") }, default="nothing");
1065 if slot.type is not None:
1066 print "pls add support for this frontend type!", slot.type
1069 nimmgr.sec = SecConfigure(nimmgr)
1071 nimmanager = NimManager()