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)
63 sec.setVoltageMode(switchParam.HV)
64 sec.setToneMode(switchParam.HILO)
66 sec.setVoltageMode(switchParam._14V)
67 sec.setToneMode(switchParam.OFF)
69 sec.setCommandOrder(0)
72 sec.setDiSEqCMode(diseqcmode)
73 sec.setToneburst(toneburstmode)
74 sec.setCommittedCommand(diseqcpos)
75 sec.setUncommittedCommand(0) # SENDNO
76 #print "set orbpos to:" + str(orbpos)
78 if 0 <= diseqcmode < 3:
79 self.addSatellite(sec, orbpos)
80 elif (diseqcmode == 3): # diseqc 1.2
81 if self.satposdepends.has_key(slotid):
82 for slot in self.satposdepends[slotid]:
83 tunermask |= (1 << slot)
84 sec.setLatitude(latitude)
85 sec.setLaDirection(laDirection)
86 sec.setLongitude(longitude)
87 sec.setLoDirection(loDirection)
88 sec.setUseInputpower(useInputPower)
89 sec.setInputpowerDelta(inputPowerDelta)
90 sec.setRotorTurningSpeed(turningSpeed)
92 for x in self.NimManager.satList:
93 print "Add sat " + str(x[0])
94 self.addSatellite(sec, int(x[0]))
95 sec.setVoltageMode(switchParam.HV)
96 sec.setToneMode(switchParam.HILO)
97 sec.setRotorPosNum(0) # USALS
99 sec.setLNBSlotMask(tunermask)
101 def setSatposDepends(self, sec, nim1, nim2):
102 print "tuner", nim1, "depends on satpos of", nim2
103 sec.setTunerDepends(nim1, nim2)
105 def linkNIMs(self, sec, nim1, nim2):
106 print "link tuner", nim1, "to tuner", nim2
107 sec.setTunerLinked(nim1, nim2)
109 def getRoot(self, slotid, connto):
111 while (self.NimManager.getNimConfig(connto).configMode.value in ["satposdepends", "equal", "loopthrough"]):
112 connto = int(self.NimManager.getNimConfig(connto).connectedTo.value)
113 if connto in visited: # prevent endless loop
115 visited.append(connto)
119 sec = secClass.getInstance()
120 self.configuredSatellites = Set()
121 sec.clear() ## this do unlinking NIMs too !!
122 print "sec config cleared"
125 self.satposdepends = { }
128 nim_slots = self.NimManager.nim_slots
132 for slot in nim_slots:
133 if slot.type is not None:
134 used_nim_slots.append((slot.slot, slot.description, slot.config.configMode.value != "nothing" and True or False, slot.isCompatible("DVB-S2")))
135 eDVBResourceManager.getInstance().setFrontendSlotInformations(used_nim_slots)
137 for slot in nim_slots:
140 if slot.isCompatible("DVB-S"):
141 # save what nim we link to/are equal to/satposdepends to.
142 # this is stored in the *value* (not index!) of the config list
143 if nim.configMode.value == "equal":
144 connto = self.getRoot(x, int(nim.connectedTo.value))
145 if not self.equal.has_key(connto):
146 self.equal[connto] = []
147 self.equal[connto].append(x)
148 elif nim.configMode.value == "loopthrough":
149 self.linkNIMs(sec, x, int(nim.connectedTo.value))
150 connto = self.getRoot(x, int(nim.connectedTo.value))
151 if not self.linked.has_key(connto):
152 self.linked[connto] = []
153 self.linked[connto].append(x)
154 elif nim.configMode.value == "satposdepends":
155 self.setSatposDepends(sec, x, int(nim.connectedTo.value))
156 connto = self.getRoot(x, int(nim.connectedTo.value))
157 if not self.satposdepends.has_key(connto):
158 self.satposdepends[connto] = []
159 self.satposdepends[connto].append(x)
161 for slot in nim_slots:
165 if slot.isCompatible("DVB-S"):
166 print "slot: " + str(x) + " configmode: " + str(nim.configMode.value)
167 if nim.configMode.value in [ "loopthrough", "satposdepends", "nothing" ]:
170 sec.setSlotNotLinked(x)
171 if nim.configMode.value == "equal":
173 elif nim.configMode.value == "simple": #simple config
174 print "diseqcmode: ", nim.diseqcMode.value
175 if nim.diseqcMode.value == "single": #single
176 if nim.simpleSingleSendDiSEqC.value:
177 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA)
179 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.NONE, diseqcpos = diseqcParam.SENDNO)
180 elif nim.diseqcMode.value == "toneburst_a_b": #Toneburst A/B
181 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.A, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO)
182 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.B, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO)
183 elif nim.diseqcMode.value == "diseqc_a_b": #DiSEqC A/B
184 fastDiSEqC = nim.simpleDiSEqCOnlyOnSatChange.value
185 setVoltageTone = nim.simpleDiSEqCSetVoltageTone.value
186 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone)
187 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone)
188 elif nim.diseqcMode.value == "diseqc_a_b_c_d": #DiSEqC A/B/C/D
189 fastDiSEqC = nim.simpleDiSEqCOnlyOnSatChange.value
190 setVoltageTone = nim.simpleDiSEqCSetVoltageTone.value
191 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone)
192 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone)
193 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcC.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BA, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone)
194 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcD.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BB, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone)
195 elif nim.diseqcMode.value == "positioner": #Positioner
196 if nim.latitudeOrientation.value == "north":
197 laValue = rotorParam.NORTH
199 laValue = rotorParam.SOUTH
200 if nim.longitudeOrientation.value == "east":
201 loValue = rotorParam.EAST
203 loValue = rotorParam.WEST
204 inputPowerDelta=nim.powerThreshold.value
207 if nim.powerMeasurement.value:
209 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
210 if turn_speed_dict.has_key(nim.turningSpeed.value):
211 turning_speed = turn_speed_dict[nim.turningSpeed.value]
213 beg_time = localtime(nim.fastTurningBegin.value)
214 end_time = localtime(nim.fastTurningEnd.value)
215 turning_speed = ((beg_time.tm_hour+1) * 60 + beg_time.tm_min + 1) << 16
216 turning_speed |= (end_time.tm_hour+1) * 60 + end_time.tm_min + 1
217 self.addLNBSimple(sec, slotid = x, diseqcmode = 3,
218 longitude = nim.longitude.float,
219 loDirection = loValue,
220 latitude = nim.latitude.float,
221 laDirection = laValue,
222 turningSpeed = turning_speed,
223 useInputPower = useInputPower,
224 inputPowerDelta = inputPowerDelta)
225 elif nim.configMode.value == "advanced": #advanced config
226 self.updateAdvanced(sec, x)
227 print "sec config completed"
229 def updateAdvanced(self, sec, slotid):
231 for x in range(1,37):
234 #wildcard for all satellites ( for rotor )
235 for x in range(3601, 3605):
236 lnb = int(config.Nims[slotid].advanced.sat[x].lnb.value)
238 for x in self.NimManager.satList:
239 print "add", x[0], "to", lnb
240 lnbSat[lnb].append(x[0])
242 for x in self.NimManager.satList:
243 lnb = int(config.Nims[slotid].advanced.sat[x[0]].lnb.value)
245 print "add", x[0], "to", lnb
246 lnbSat[lnb].append(x[0])
248 for x in range(1,37):
249 if len(lnbSat[x]) > 0:
250 currLnb = config.Nims[slotid].advanced.lnb[x]
253 tunermask = 1 << slotid
254 if self.equal.has_key(slotid):
255 for slot in self.equal[slotid]:
256 tunermask |= (1 << slot)
257 elif self.linked.has_key(slotid):
258 for slot in self.linked[slotid]:
259 tunermask |= (1 << slot)
261 if currLnb.lof.value == "universal_lnb":
262 sec.setLNBLOFL(9750000)
263 sec.setLNBLOFH(10600000)
264 sec.setLNBThreshold(11700000)
265 elif currLnb.lof.value == "c_band":
266 sec.setLNBLOFL(5150000)
267 sec.setLNBLOFH(5150000)
268 sec.setLNBThreshold(5150000)
269 elif currLnb.lof.value == "user_defined":
270 sec.setLNBLOFL(currLnb.lofl.value * 1000)
271 sec.setLNBLOFH(currLnb.lofh.value * 1000)
272 sec.setLNBThreshold(currLnb.threshold.value * 1000)
274 # if currLnb.output_12v.value == "0V":
275 # pass # nyi in drivers
276 # elif currLnb.output_12v.value == "12V":
277 # pass # nyi in drivers
279 if currLnb.increased_voltage.value:
280 sec.setLNBIncreasedVoltage(lnbParam.ON)
282 sec.setLNBIncreasedVoltage(lnbParam.OFF)
284 dm = currLnb.diseqcMode.value
286 sec.setDiSEqCMode(diseqcParam.NONE)
288 sec.setDiSEqCMode(diseqcParam.V1_0)
290 sec.setDiSEqCMode(diseqcParam.V1_1)
292 sec.setDiSEqCMode(diseqcParam.V1_2)
294 if self.satposdepends.has_key(slotid):
295 for slot in self.satposdepends[slotid]:
296 tunermask |= (1 << slot)
299 if currLnb.toneburst.value == "none":
300 sec.setToneburst(diseqcParam.NO)
301 elif currLnb.toneburst.value == "A":
302 sec.setToneburst(diseqcParam.A)
303 elif currLnb.toneburst.value == "B":
304 sec.setToneburst(diseqcParam.B)
306 # Committed Diseqc Command
307 cdc = currLnb.commitedDiseqcCommand.value
309 c = { "none": diseqcParam.SENDNO,
310 "AA": diseqcParam.AA,
311 "AB": diseqcParam.AB,
312 "BA": diseqcParam.BA,
313 "BB": diseqcParam.BB }
316 sec.setCommittedCommand(c[cdc])
318 sec.setCommittedCommand(long(cdc))
320 sec.setFastDiSEqC(currLnb.fastDiseqc.value)
322 sec.setSeqRepeat(currLnb.sequenceRepeat.value)
324 if currLnb.diseqcMode.value == "1_0":
325 currCO = currLnb.commandOrder1_0.value
327 currCO = currLnb.commandOrder.value
329 udc = int(currLnb.uncommittedDiseqcCommand.value)
331 sec.setUncommittedCommand(0xF0|(udc-1))
333 sec.setUncommittedCommand(0) # SENDNO
335 sec.setRepeats({"none": 0, "one": 1, "two": 2, "three": 3}[currLnb.diseqcRepeats.value])
337 setCommandOrder = False
339 # 0 "committed, toneburst",
340 # 1 "toneburst, committed",
341 # 2 "committed, uncommitted, toneburst",
342 # 3 "toneburst, committed, uncommitted",
343 # 4 "uncommitted, committed, toneburst"
344 # 5 "toneburst, uncommitted, commmitted"
345 order_map = {"ct": 0, "tc": 1, "cut": 2, "tcu": 3, "uct": 4, "tuc": 5}
346 sec.setCommandOrder(order_map[currCO])
349 latitude = currLnb.latitude.float
350 sec.setLatitude(latitude)
351 longitude = currLnb.longitude.float
352 sec.setLongitude(longitude)
353 if currLnb.latitudeOrientation.value == "north":
354 sec.setLaDirection(rotorParam.NORTH)
356 sec.setLaDirection(rotorParam.SOUTH)
357 if currLnb.longitudeOrientation.value == "east":
358 sec.setLoDirection(rotorParam.EAST)
360 sec.setLoDirection(rotorParam.WEST)
362 if currLnb.powerMeasurement.value:
363 sec.setUseInputpower(True)
364 sec.setInputpowerDelta(currLnb.powerThreshold.value)
365 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
366 if turn_speed_dict.has_key(currLnb.turningSpeed.value):
367 turning_speed = turn_speed_dict[currLnb.turningSpeed.value]
369 beg_time = localtime(currLnb.fastTurningBegin.value)
370 end_time = localtime(currLnb.fastTurningEnd.value)
371 turning_speed = ((beg_time.tm_hour + 1) * 60 + beg_time.tm_min + 1) << 16
372 turning_speed |= (end_time.tm_hour + 1) * 60 + end_time.tm_min + 1
373 sec.setRotorTurningSpeed(turning_speed)
375 sec.setUseInputpower(False)
377 sec.setLNBSlotMask(tunermask)
379 # finally add the orbital positions
381 self.addSatellite(sec, y)
383 satpos = x > 32 and (3604-(36 - x)) or y
386 currSat = config.Nims[slotid].advanced.sat[satpos]
387 if currSat.voltage.value == "polarization":
388 sec.setVoltageMode(switchParam.HV)
389 elif currSat.voltage.value == "13V":
390 sec.setVoltageMode(switchParam._14V)
391 elif currSat.voltage.value == "18V":
392 sec.setVoltageMode(switchParam._18V)
394 if currSat.tonemode.value == "band":
395 sec.setToneMode(switchParam.HILO)
396 elif currSat.tonemode.value == "on":
397 sec.setToneMode(switchParam.ON)
398 elif currSat.tonemode.value == "off":
399 sec.setToneMode(switchParam.OFF)
401 if not currSat.usals.value and x < 34:
402 sec.setRotorPosNum(currSat.rotorposition.value)
404 sec.setRotorPosNum(0) #USALS
406 def __init__(self, nimmgr):
407 self.NimManager = nimmgr
408 self.configuredSatellites = Set()
412 def __init__(self, slot, type, description, has_outputs = True, internally_connectable = None):
415 if type not in ["DVB-S", "DVB-C", "DVB-T", "DVB-S2", None]:
416 print "warning: unknown NIM type %s, not using." % type
420 self.description = description
421 self.has_outputs = has_outputs
422 self.internally_connectable = internally_connectable
424 def isCompatible(self, what):
427 "DVB-S": ["DVB-S", None],
428 "DVB-C": ["DVB-C", None],
429 "DVB-T": ["DVB-T", None],
430 "DVB-S2": ["DVB-S", "DVB-S2", None]
432 return what in compatible[self.type]
434 def connectableTo(self):
436 "DVB-S": ["DVB-S", "DVB-S2"],
439 "DVB-S2": ["DVB-S", "DVB-S2"]
441 return connectable[self.type]
443 def getSlotName(self):
444 # get a friendly description for a slot name.
445 # we name them "Tuner A/B/C/...", because that's what's usually written on the back
447 return _("Tuner ") + chr(ord('A') + self.slot)
449 slot_name = property(getSlotName)
452 return chr(ord('A') + self.slot)
454 def hasOutputs(self):
455 return self.has_outputs
457 def internallyConnectableTo(self):
458 return self.internally_connectable
460 slot_id = property(getSlotID)
462 def getFriendlyType(self):
471 friendly_type = property(getFriendlyType)
473 def getFriendlyFullDescription(self):
474 nim_text = self.slot_name + ": "
477 nim_text += _("(empty)")
479 nim_text += self.description + " (" + self.friendly_type + ")"
483 friendly_full_description = property(getFriendlyFullDescription)
484 config_mode = property(lambda self: config.Nims[self.slot].configMode.value)
485 config = property(lambda self: config.Nims[self.slot])
486 empty = property(lambda self: self.type is None)
489 def getConfiguredSats(self):
490 return self.sec.getConfiguredSats()
492 def getTransponders(self, pos):
493 if self.transponders.has_key(pos):
494 return self.transponders[pos]
498 def getTranspondersCable(self, nim):
499 nimConfig = config.Nims[nim]
500 if nimConfig.configMode.value != "nothing" and nimConfig.cable.scan_type.value == "provider":
501 return self.transponderscable[self.cablesList[nimConfig.cable.scan_provider.index][0]]
504 def getTranspondersTerrestrial(self, region):
505 return self.transpondersterrestrial[region]
507 def getCableDescription(self, nim):
508 return self.cablesList[config.Nims[nim].scan_provider.index][0]
510 def getCableFlags(self, nim):
511 return self.cablesList[config.Nims[nim].scan_provider.index][1]
513 def getTerrestrialDescription(self, nim):
514 return self.terrestrialsList[config.Nims[nim].terrestrial.index][0]
516 def getTerrestrialFlags(self, nim):
517 return self.terrestrialsList[config.Nims[nim].terrestrial.index][1]
519 def getSatDescription(self, pos):
520 return self.satellites[pos]
522 def readTransponders(self):
523 # read initial networks from file. we only read files which we are interested in,
524 # which means only these where a compatible tuner exists.
525 self.satellites = { }
526 self.transponders = { }
527 self.transponderscable = { }
528 self.transpondersterrestrial = { }
529 db = eDVBDB.getInstance()
530 if self.hasNimType("DVB-S"):
531 print "Reading satellites.xml"
532 db.readSatellites(self.satList, self.satellites, self.transponders)
533 # print "SATLIST", self.satList
534 # print "SATS", self.satellites
535 # print "TRANSPONDERS", self.transponders
537 if self.hasNimType("DVB-C"):
538 print "Reading cables.xml"
539 db.readCables(self.cablesList, self.transponderscable)
540 # print "CABLIST", self.cablesList
541 # print "TRANSPONDERS", self.transponders
543 if self.hasNimType("DVB-T"):
544 print "Reading terrestrial.xml"
545 db.readTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
546 # print "TERLIST", self.terrestrialsList
547 # print "TRANSPONDERS", self.transpondersterrestrial
549 def enumerateNIMs(self):
550 # enum available NIMs. This is currently very dreambox-centric and uses the /proc/bus/nim_sockets interface.
551 # the result will be stored into nim_slots.
552 # the content of /proc/bus/nim_sockets looks like:
555 # Name: BCM4501 DVB-S2 NIM (internal)
558 # Name: BCM4501 DVB-S2 NIM (internal)
561 # Name: Philips TU1216
564 # Name: Alps BSBE1 702A
567 # Type will be either "DVB-S", "DVB-S2", "DVB-T", "DVB-C" or None.
569 # nim_slots is an array which has exactly one entry for each slot, even for empty ones.
572 nimfile = tryOpen("/proc/bus/nim_sockets")
580 for line in nimfile.readlines():
583 if line.strip().startswith("NIM Socket"):
584 parts = line.strip().split(" ")
585 current_slot = int(parts[2][:-1])
586 entries[current_slot] = {}
587 elif line.strip().startswith("Type:"):
588 entries[current_slot]["type"] = str(line.strip()[6:])
589 elif line.strip().startswith("Name:"):
590 entries[current_slot]["name"] = str(line.strip()[6:])
591 elif line.strip().startswith("Has_Outputs:"):
592 input = str(line.strip()[len("Has_Outputs:") + 1:])
593 entries[current_slot]["has_outputs"] = (input == "yes")
594 elif line.strip().startswith("Internally_Connectable:"):
595 input = int(line.strip()[len("Internally_Connectable:") + 1:])
596 entries[current_slot]["internally_connectable"] = input
597 elif line.strip().startswith("empty"):
598 entries[current_slot]["type"] = None
599 entries[current_slot]["name"] = _("N/A")
602 for id, entry in entries.items():
603 if not (entry.has_key("name") and entry.has_key("type")):
604 entry["name"] = _("N/A")
606 if not (entry.has_key("has_outputs")):
607 entry["has_outputs"] = True
608 if not (entry.has_key("internally_connectable")):
609 entry["internally_connectable"] = None
610 self.nim_slots.append(NIM(slot = id, description = entry["name"], type = entry["type"], has_outputs = entry["has_outputs"], internally_connectable = entry["internally_connectable"]))
612 def hasNimType(self, chktype):
613 for slot in self.nim_slots:
614 if slot.isCompatible(chktype):
618 def getNimType(self, slotid):
619 return self.nim_slots[slotid].type
621 def getNimDescription(self, slotid):
622 return self.nim_slots[slotid].friendly_full_description
624 def getNimListOfType(self, type, exception = -1):
625 # returns a list of indexes for NIMs compatible to the given type, except for 'exception'
627 for x in self.nim_slots:
628 if x.isCompatible(type) and x.slot != exception:
635 self.terrestrialsList = []
637 self.readTransponders()
638 InitNimManager(self) #init config stuff
640 # get a list with the friendly full description
643 for slot in self.nim_slots:
644 list.append(slot.friendly_full_description)
647 def getSlotCount(self):
648 return len(self.nim_slots)
650 def hasOutputs(self, slotid):
651 return self.nim_slots[slotid].hasOutputs()
653 def canConnectTo(self, slotid):
655 if self.nim_slots[slotid].internallyConnectableTo() is not None:
656 slots.append(self.nim_slots[slotid].internallyConnectableTo())
657 for type in self.nim_slots[slotid].connectableTo():
658 for slot in self.getNimListOfType(type, exception = slotid):
659 if self.hasOutputs(slot):
661 # remove nims, that have a conntectedTo reference on
662 for testnim in slots[:]:
663 for nim in self.getNimListOfType("DVB-S", slotid):
664 nimConfig = self.getNimConfig(nim)
665 if nimConfig.content.items.has_key("configMode") and nimConfig.configMode.value == "loopthrough" and int(nimConfig.connectedTo.value) == testnim:
666 slots.remove(testnim)
672 def canEqualTo(self, slotid):
673 type = self.getNimType(slotid)
676 nimList = self.getNimListOfType(type, slotid)
677 for nim in nimList[:]:
678 mode = self.getNimConfig(nim)
679 if mode.configMode.value == "loopthrough" or mode.configMode.value == "satposdepends":
683 def canDependOn(self, slotid):
684 type = self.getNimType(slotid)
687 nimList = self.getNimListOfType(type, slotid)
689 for nim in nimList[:]:
690 mode = self.getNimConfig(nim)
691 nimHaveRotor = mode.configMode.value == "simple" and mode.diseqcMode.value == "positioner"
692 if not nimHaveRotor and mode.configMode.value == "advanced":
693 for x in range(3601, 3605):
694 lnb = int(mode.advanced.sat[x].lnb.value)
699 for sat in mode.advanced.sat.values():
700 lnb_num = int(sat.lnb.value)
701 diseqcmode = lnb_num and mode.advanced.lnb[lnb_num].diseqcMode.value or ""
702 if diseqcmode == "1_2":
706 alreadyConnected = False
707 for testnim in nimList:
708 testmode = self.getNimConfig(testnim)
709 if testmode.configMode.value == "satposdepends" and int(testmode.connectedTo.value) == int(nim):
710 alreadyConnected = True
712 if not alreadyConnected:
713 positionerList.append(nim)
714 return positionerList
716 def getNimConfig(self, slotid):
717 return config.Nims[slotid]
719 def getSatName(self, pos):
720 for sat in self.satList:
725 def getSatList(self):
728 def getSatListForNim(self, slotid):
730 if self.nim_slots[slotid].isCompatible("DVB-S"):
731 nim = config.Nims[slotid]
732 #print "slotid:", slotid
734 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.index]
735 #print "diseqcA:", config.Nims[slotid].diseqcA.value
736 configMode = nim.configMode.value
738 if configMode == "equal":
739 slotid = int(nim.connectedTo.value)
740 nim = config.Nims[slotid]
741 configMode = nim.configMode.value
742 elif configMode == "loopthrough":
743 slotid = self.sec.getRoot(slotid, int(nim.connectedTo.value))
744 nim = config.Nims[slotid]
745 configMode = nim.configMode.value
747 if configMode == "simple":
748 dm = nim.diseqcMode.value
749 if dm in ["single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
750 list.append(self.satList[nim.diseqcA.index])
751 if dm in ["toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
752 list.append(self.satList[nim.diseqcB.index])
753 if dm == "diseqc_a_b_c_d":
754 list.append(self.satList[nim.diseqcC.index])
755 list.append(self.satList[nim.diseqcD.index])
756 if dm == "positioner":
757 for x in self.satList:
759 elif configMode == "advanced":
760 for x in range(3601, 3605):
761 if int(nim.advanced.sat[x].lnb.value) != 0:
762 for x in self.satList:
765 for x in self.satList:
766 if int(nim.advanced.sat[x[0]].lnb.value) != 0:
770 def getRotorSatListForNim(self, slotid):
772 if self.nim_slots[slotid].isCompatible("DVB-S"):
773 #print "slotid:", slotid
774 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
775 #print "diseqcA:", config.Nims[slotid].diseqcA.value
776 configMode = config.Nims[slotid].configMode.value
777 if configMode == "simple":
778 if config.Nims[slotid].diseqcMode.value == "positioner":
779 for x in self.satList:
781 elif configMode == "advanced":
782 nim = config.Nims[slotid]
783 for x in range(3601, 3605):
784 if int(nim.advanced.sat[x].lnb.value) != 0:
785 for x in self.satList:
788 for x in self.satList:
789 lnbnum = int(nim.advanced.sat[x[0]].lnb.value)
791 lnb = nim.advanced.lnb[lnbnum]
792 if lnb.diseqcMode.value == "1_2":
797 config.sec = ConfigSubsection()
799 x = ConfigInteger(default=15, limits = (0, 9999))
800 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_CONT_TONE, configElement.value))
801 config.sec.delay_after_continuous_tone_change = x
803 x = ConfigInteger(default=10, limits = (0, 9999))
804 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_VOLTAGE_CHANGE, configElement.value))
805 config.sec.delay_after_final_voltage_change = x
807 x = ConfigInteger(default=120, limits = (0, 9999))
808 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_DISEQC_REPEATS, configElement.value))
809 config.sec.delay_between_diseqc_repeats = x
811 x = ConfigInteger(default=50, limits = (0, 9999))
812 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_LAST_DISEQC_CMD, configElement.value))
813 config.sec.delay_after_last_diseqc_command = x
815 x = ConfigInteger(default=50, limits = (0, 9999))
816 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value))
817 config.sec.delay_after_toneburst = x
819 x = ConfigInteger(default=20, limits = (0, 9999))
820 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS, configElement.value))
821 config.sec.delay_after_change_voltage_before_switch_command = x
823 x = ConfigInteger(default=200, limits = (0, 9999))
824 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS, configElement.value))
825 config.sec.delay_after_enable_voltage_before_switch_command = x
827 x = ConfigInteger(default=700, limits = (0, 9999))
828 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_SWITCH_AND_MOTOR_CMD, configElement.value))
829 config.sec.delay_between_switch_and_motor_command = x
831 x = ConfigInteger(default=500, limits = (0, 9999))
832 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MEASURE_IDLE_INPUTPOWER, configElement.value))
833 config.sec.delay_after_voltage_change_before_measure_idle_inputpower = x
835 x = ConfigInteger(default=750, limits = (0, 9999))
836 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_MOTOR_CMD, configElement.value))
837 config.sec.delay_after_enable_voltage_before_motor_command = x
839 x = ConfigInteger(default=500, limits = (0, 9999))
840 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_MOTOR_STOP_CMD, configElement.value))
841 config.sec.delay_after_motor_stop_command = x
843 x = ConfigInteger(default=500, limits = (0, 9999))
844 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MOTOR_CMD, configElement.value))
845 config.sec.delay_after_voltage_change_before_motor_command = x
847 x = ConfigInteger(default=70, limits = (0, 9999))
848 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BEFORE_SEQUENCE_REPEAT, configElement.value))
849 config.sec.delay_before_sequence_repeat = x
851 x = ConfigInteger(default=360, limits = (0, 9999))
852 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_RUNNING_TIMEOUT, configElement.value))
853 config.sec.motor_running_timeout = x
855 x = ConfigInteger(default=1, limits = (0, 5))
856 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_COMMAND_RETRIES, configElement.value))
857 config.sec.motor_command_retries = x
859 # TODO add support for satpos depending nims to advanced nim configuration
860 # so a second/third/fourth cable from a motorized lnb can used behind a
861 # diseqc 1.0 / diseqc 1.1 / toneburst switch
862 # the C(++) part should can handle this
863 # the configElement should be only visible when diseqc 1.2 is disabled
865 def InitNimManager(nimmgr):
869 config.Nims = ConfigSubList()
870 for x in range(len(nimmgr.nim_slots)):
871 config.Nims.append(ConfigSubsection())
873 for slot in nimmgr.nim_slots:
877 if slot.isCompatible("DVB-S"):
878 choices = { "nothing": _("nothing connected"),
879 "simple": _("simple"),
880 "advanced": _("advanced")}
881 if len(nimmgr.getNimListOfType(slot.type, exception = x)) > 0:
882 choices["equal"] = _("equal to")
883 choices["satposdepends"] = _("second cable of motorized LNB")
884 if len(nimmgr.canConnectTo(x)) > 0:
885 choices["loopthrough"] = _("loopthrough to")
886 nim.configMode = ConfigSelection(choices = choices, default = "nothing")
888 # for y in nimmgr.nim_slots:
890 # if not y.isCompatible("DVB-S"):
892 # nim.configMode.value = "simple"
893 # nim.configMode.save()
895 nim.diseqcMode = ConfigSelection(
897 ("single", _("Single")),
898 ("toneburst_a_b", _("Toneburst A/B")),
899 ("diseqc_a_b", _("DiSEqC A/B")),
900 ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")),
901 ("positioner", _("Positioner"))],
902 default = "diseqc_a_b")
905 for id in nimmgr.getNimListOfType("DVB-S"):
907 choices.append((str(id), nimmgr.getNimDescription(id)))
908 nim.connectedTo = ConfigSelection(choices = choices)
909 nim.simpleSingleSendDiSEqC = ConfigYesNo(default=False)
910 nim.simpleDiSEqCSetVoltageTone = ConfigYesNo(default=True)
911 nim.simpleDiSEqCOnlyOnSatChange = ConfigYesNo(default=False)
912 nim.diseqcA = getConfigSatlist(192, [(3601, _('nothing connected'), 1)] + nimmgr.satList)
913 nim.diseqcB = getConfigSatlist(130, [(3601, _('nothing connected'), 1)] + nimmgr.satList)
914 nim.diseqcC = ConfigSatlist(list = [(3601, _('nothing connected'), 1)] + nimmgr.satList)
915 nim.diseqcD = ConfigSatlist(list = [(3601, _('nothing connected'), 1)] + nimmgr.satList)
916 nim.positionerMode = ConfigSelection(
918 ("usals", _("USALS")),
919 ("manual", _("manual"))],
921 nim.longitude = ConfigFloat(default=[5,100], limits=[(0,359),(0,999)])
922 nim.longitudeOrientation = ConfigSelection(choices={"east": _("East"), "west": _("West")}, default = "east")
923 nim.latitude = ConfigFloat(default=[50,767], limits=[(0,359),(0,999)])
924 nim.latitudeOrientation = ConfigSelection(choices={"north": _("North"), "south": _("South")}, default="north")
925 nim.powerMeasurement = ConfigYesNo(default=True)
926 nim.powerThreshold = ConfigInteger(default=hw.get_device_name() == "dm8000" and 15 or 50, limits=(0, 100))
927 nim.turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch")) ], default = "fast")
928 btime = datetime(1970, 1, 1, 7, 0);
929 nim.fastTurningBegin = ConfigDateTime(default = mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 900)
930 etime = datetime(1970, 1, 1, 19, 0);
931 nim.fastTurningEnd = ConfigDateTime(default = mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 900)
934 nim.advanced = ConfigSubsection()
935 tmp = [(3601, _('All Satellites')+' 1', 1), (3602, _('All Satellites')+' 2', 1), (3603, _('All Satellites')+' 3', 1), (3604, _('All Satellites')+' 4', 1)]
936 nim.advanced.sats = getConfigSatlist(192,nimmgr.satList+tmp)
937 nim.advanced.sat = ConfigSubDict()
938 lnbs = [("0", "not available")]
939 for y in range(1, 33):
940 lnbs.append((str(y), "LNB " + str(y)))
942 for x in nimmgr.satList:
943 nim.advanced.sat[x[0]] = ConfigSubsection()
944 nim.advanced.sat[x[0]].voltage = ConfigSelection(choices={"polarization": _("Polarization"), "13V": _("13 V"), "18V": _("18 V")}, default = "polarization")
945 nim.advanced.sat[x[0]].tonemode = ConfigSelection(choices={"band": _("Band"), "on": _("On"), "off": _("Off")}, default = "band")
946 nim.advanced.sat[x[0]].usals = ConfigYesNo(default=True)
947 nim.advanced.sat[x[0]].rotorposition = ConfigInteger(default=1, limits=(1, 255))
948 nim.advanced.sat[x[0]].lnb = ConfigSelection(choices = lnbs)
950 for x in range(3601, 3605):
951 nim.advanced.sat[x] = ConfigSubsection()
952 nim.advanced.sat[x].voltage = ConfigSelection(choices={"polarization": _("Polarization"), "13V": _("13 V"), "18V": _("18 V")}, default = "polarization")
953 nim.advanced.sat[x].tonemode = ConfigSelection(choices={"band": _("Band"), "on": _("On"), "off": _("Off")}, default = "band")
954 nim.advanced.sat[x].usals = ConfigYesNo(default=True)
955 nim.advanced.sat[x].rotorposition = ConfigInteger(default=1, limits=(1, 255))
957 nim.advanced.sat[x].lnb = ConfigSelection(choices = [("0", "not available"), (str(lnbnum), "LNB %d"%(lnbnum))], default="0")
959 csw = [("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))]
960 for y in range(0, 16):
961 csw.append((str(0xF0|y), "Input " + str(y+1)))
963 ucsw = [("0", _("None"))]
964 for y in range(1, 17):
965 ucsw.append((str(y), "Input " + str(y)))
967 nim.advanced.lnb = ConfigSubList()
968 nim.advanced.lnb.append(ConfigNothing())
969 for x in range(1, 37):
970 nim.advanced.lnb.append(ConfigSubsection())
971 nim.advanced.lnb[x].lof = ConfigSelection(choices={"universal_lnb": _("Universal LNB"), "c_band": _("C-Band"), "user_defined": _("User defined")}, default="universal_lnb")
972 nim.advanced.lnb[x].lofl = ConfigInteger(default=9750, limits = (0, 99999))
973 nim.advanced.lnb[x].lofh = ConfigInteger(default=10600, limits = (0, 99999))
974 nim.advanced.lnb[x].threshold = ConfigInteger(default=11700, limits = (0, 99999))
975 # nim.advanced.lnb[x].output_12v = ConfigSelection(choices = [("0V", _("0 V")), ("12V", _("12 V"))], default="0V")
976 nim.advanced.lnb[x].increased_voltage = ConfigYesNo(default=False)
977 nim.advanced.lnb[x].toneburst = ConfigSelection(choices = [("none", _("None")), ("A", _("A")), ("B", _("B"))], default = "none")
979 nim.advanced.lnb[x].diseqcMode = ConfigSelection(choices = [("1_2", _("1.2"))], default = "1_2")
981 nim.advanced.lnb[x].diseqcMode = ConfigSelection(choices = [("none", _("None")), ("1_0", _("1.0")), ("1_1", _("1.1")), ("1_2", _("1.2"))], default = "none")
982 nim.advanced.lnb[x].commitedDiseqcCommand = ConfigSelection(choices = csw)
983 nim.advanced.lnb[x].fastDiseqc = ConfigYesNo(default=False)
984 nim.advanced.lnb[x].sequenceRepeat = ConfigYesNo(default=False)
985 nim.advanced.lnb[x].commandOrder1_0 = ConfigSelection(choices = [("ct", "committed, toneburst"), ("tc", "toneburst, committed")], default = "ct")
986 nim.advanced.lnb[x].commandOrder = ConfigSelection(choices = [
987 ("ct", "committed, toneburst"),
988 ("tc", "toneburst, committed"),
989 ("cut", "committed, uncommitted, toneburst"),
990 ("tcu", "toneburst, committed, uncommitted"),
991 ("uct", "uncommitted, committed, toneburst"),
992 ("tuc", "toneburst, uncommitted, commmitted")],
994 nim.advanced.lnb[x].uncommittedDiseqcCommand = ConfigSelection(choices = ucsw)
995 nim.advanced.lnb[x].diseqcRepeats = ConfigSelection(choices = [("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))], default = "none")
996 nim.advanced.lnb[x].longitude = ConfigFloat(default = [5,100], limits = [(0,359),(0,999)])
997 nim.advanced.lnb[x].longitudeOrientation = ConfigSelection(choices = [("east", _("East")), ("west", _("West"))], default = "east")
998 nim.advanced.lnb[x].latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)])
999 nim.advanced.lnb[x].latitudeOrientation = ConfigSelection(choices = [("north", _("North")), ("south", _("South"))], default = "north")
1000 nim.advanced.lnb[x].powerMeasurement = ConfigYesNo(default=True)
1001 nim.advanced.lnb[x].powerThreshold = ConfigInteger(default=hw.get_device_name() == "dm8000" and 15 or 50, limits=(0, 100))
1002 nim.advanced.lnb[x].turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch"))], default = "fast")
1003 btime = datetime(1970, 1, 1, 7, 0);
1004 nim.advanced.lnb[x].fastTurningBegin = ConfigDateTime(default=mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 600)
1005 etime = datetime(1970, 1, 1, 19, 0);
1006 nim.advanced.lnb[x].fastTurningEnd = ConfigDateTime(default=mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 600)
1007 elif slot.isCompatible("DVB-C"):
1008 nim.configMode = ConfigSelection(
1010 "enabled": _("enabled"),
1011 "nothing": _("nothing connected"),
1013 default = "enabled")
1016 for x in nimmgr.cablesList:
1017 list.append((str(n), x[0]))
1019 nim.cable = ConfigSubsection()
1020 possible_scan_types = [("bands", _("Frequency bands")), ("steps", _("Frequency steps"))]
1022 possible_scan_types.append(("provider", _("Provider")))
1023 nim.cable.scan_provider = ConfigSelection(default = "0", choices = list)
1024 nim.cable.scan_type = ConfigSelection(default = "bands", choices = possible_scan_types)
1025 nim.cable.scan_band_EU_VHF_I = ConfigYesNo(default = True)
1026 nim.cable.scan_band_EU_MID = ConfigYesNo(default = True)
1027 nim.cable.scan_band_EU_VHF_III = ConfigYesNo(default = True)
1028 nim.cable.scan_band_EU_UHF_IV = ConfigYesNo(default = True)
1029 nim.cable.scan_band_EU_UHF_V = ConfigYesNo(default = True)
1030 nim.cable.scan_band_EU_SUPER = ConfigYesNo(default = True)
1031 nim.cable.scan_band_EU_HYPER = ConfigYesNo(default = True)
1032 nim.cable.scan_band_US_LOW = ConfigYesNo(default = False)
1033 nim.cable.scan_band_US_MID = ConfigYesNo(default = False)
1034 nim.cable.scan_band_US_HIGH = ConfigYesNo(default = False)
1035 nim.cable.scan_band_US_SUPER = ConfigYesNo(default = False)
1036 nim.cable.scan_band_US_HYPER = ConfigYesNo(default = False)
1037 nim.cable.scan_frequency_steps = ConfigInteger(default = 1000, limits = (1000, 10000))
1038 nim.cable.scan_mod_qam16 = ConfigYesNo(default = False)
1039 nim.cable.scan_mod_qam32 = ConfigYesNo(default = False)
1040 nim.cable.scan_mod_qam64 = ConfigYesNo(default = True)
1041 nim.cable.scan_mod_qam128 = ConfigYesNo(default = False)
1042 nim.cable.scan_mod_qam256 = ConfigYesNo(default = True)
1043 nim.cable.scan_sr_6900 = ConfigYesNo(default = True)
1044 nim.cable.scan_sr_6875 = ConfigYesNo(default = True)
1045 nim.cable.scan_sr_ext1 = ConfigInteger(default = 0, limits = (0, 7230))
1046 nim.cable.scan_sr_ext2 = ConfigInteger(default = 0, limits = (0, 7230))
1047 elif slot.isCompatible("DVB-T"):
1048 nim.configMode = ConfigSelection(
1050 "enabled": _("enabled"),
1051 "nothing": _("nothing connected"),
1053 default = "enabled")
1056 for x in nimmgr.terrestrialsList:
1057 list.append((str(n), x[0]))
1059 nim.terrestrial = ConfigSelection(choices = list)
1060 nim.terrestrial_5V = ConfigOnOff()
1062 nim.configMode = ConfigSelection(choices = { "nothing": _("disabled") }, default="nothing");
1063 if slot.type is not None:
1064 print "pls add support for this frontend type!", slot.type
1067 nimmgr.sec = SecConfigure(nimmgr)
1069 nimmanager = NimManager()