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):
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)
61 sec.setVoltageMode(switchParam.HV)
62 sec.setToneMode(switchParam.HILO)
63 sec.setCommandOrder(0)
66 sec.setDiSEqCMode(diseqcmode)
67 sec.setToneburst(toneburstmode)
68 sec.setCommittedCommand(diseqcpos)
69 sec.setUncommittedCommand(0) # SENDNO
70 #print "set orbpos to:" + str(orbpos)
72 if 0 <= diseqcmode < 3:
73 self.addSatellite(sec, orbpos)
74 elif (diseqcmode == 3): # diseqc 1.2
75 if self.satposdepends.has_key(slotid):
76 for slot in self.satposdepends[slotid]:
77 tunermask |= (1 << slot)
78 sec.setLatitude(latitude)
79 sec.setLaDirection(laDirection)
80 sec.setLongitude(longitude)
81 sec.setLoDirection(loDirection)
82 sec.setUseInputpower(useInputPower)
83 sec.setInputpowerDelta(inputPowerDelta)
84 sec.setRotorTurningSpeed(turningSpeed)
86 for x in self.NimManager.satList:
87 print "Add sat " + str(x[0])
88 self.addSatellite(sec, int(x[0]))
89 sec.setVoltageMode(switchParam.HV)
90 sec.setToneMode(switchParam.HILO)
91 sec.setRotorPosNum(0) # USALS
93 sec.setLNBSlotMask(tunermask)
95 def setSatposDepends(self, sec, nim1, nim2):
96 print "tuner", nim1, "depends on satpos of", nim2
97 sec.setTunerDepends(nim1, nim2)
99 def linkNIMs(self, sec, nim1, nim2):
100 print "link tuner", nim1, "to tuner", nim2
101 sec.setTunerLinked(nim1, nim2)
103 def getRoot(self, slotid, connto):
105 while (self.NimManager.getNimConfig(connto).configMode.value in ["satposdepends", "equal", "loopthrough"]):
106 connto = int(self.NimManager.getNimConfig(connto).connectedTo.value)
107 if connto in visited: # prevent endless loop
109 visited.append(connto)
113 sec = secClass.getInstance()
114 self.configuredSatellites = Set()
115 sec.clear() ## this do unlinking NIMs too !!
116 print "sec config cleared"
119 self.satposdepends = { }
122 nim_slots = self.NimManager.nim_slots
126 for slot in nim_slots:
127 if slot.type is not None:
128 used_nim_slots.append((slot.slot, slot.description, slot.config.configMode.value != "nothing" and True or False, slot.isCompatible("DVB-S2")))
129 eDVBResourceManager.getInstance().setFrontendSlotInformations(used_nim_slots)
131 for slot in nim_slots:
134 if slot.isCompatible("DVB-S"):
135 # save what nim we link to/are equal to/satposdepends to.
136 # this is stored in the *value* (not index!) of the config list
137 if nim.configMode.value == "equal":
138 connto = self.getRoot(x, int(nim.connectedTo.value))
139 if not self.equal.has_key(connto):
140 self.equal[connto] = []
141 self.equal[connto].append(x)
142 elif nim.configMode.value == "loopthrough":
143 self.linkNIMs(sec, x, int(nim.connectedTo.value))
144 connto = self.getRoot(x, int(nim.connectedTo.value))
145 if not self.linked.has_key(connto):
146 self.linked[connto] = []
147 self.linked[connto].append(x)
148 elif nim.configMode.value == "satposdepends":
149 self.setSatposDepends(sec, x, int(nim.connectedTo.value))
150 connto = self.getRoot(x, int(nim.connectedTo.value))
151 if not self.satposdepends.has_key(connto):
152 self.satposdepends[connto] = []
153 self.satposdepends[connto].append(x)
155 for slot in nim_slots:
159 if slot.isCompatible("DVB-S"):
160 print "slot: " + str(x) + " configmode: " + str(nim.configMode.value)
161 if nim.configMode.value in [ "loopthrough", "satposdepends", "nothing" ]:
164 sec.setSlotNotLinked(x)
165 if nim.configMode.value == "equal":
167 elif nim.configMode.value == "simple": #simple config
168 print "diseqcmode: ", nim.diseqcMode.value
169 if nim.diseqcMode.value == "single": #single
170 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.NONE, diseqcpos = diseqcParam.SENDNO)
171 elif nim.diseqcMode.value == "toneburst_a_b": #Toneburst A/B
172 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.A, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO)
173 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.B, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO)
174 elif nim.diseqcMode.value == "diseqc_a_b": #DiSEqC A/B
175 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA)
176 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB)
177 elif nim.diseqcMode.value == "diseqc_a_b_c_d": #DiSEqC A/B/C/D
178 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.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB)
180 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcC.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BA)
181 self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcD.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BB)
182 elif nim.diseqcMode.value == "positioner": #Positioner
183 if nim.latitudeOrientation.value == "north":
184 laValue = rotorParam.NORTH
186 laValue = rotorParam.SOUTH
187 if nim.longitudeOrientation.value == "east":
188 loValue = rotorParam.EAST
190 loValue = rotorParam.WEST
191 inputPowerDelta=nim.powerThreshold.value
194 if nim.powerMeasurement.value:
196 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
197 if turn_speed_dict.has_key(nim.turningSpeed.value):
198 turning_speed = turn_speed_dict[nim.turningSpeed.value]
200 beg_time = localtime(nim.fastTurningBegin.value)
201 end_time = localtime(nim.fastTurningEnd.value)
202 turning_speed = ((beg_time.tm_hour+1) * 60 + beg_time.tm_min + 1) << 16
203 turning_speed |= (end_time.tm_hour+1) * 60 + end_time.tm_min + 1
204 self.addLNBSimple(sec, slotid = x, diseqcmode = 3,
205 longitude = nim.longitude.float,
206 loDirection = loValue,
207 latitude = nim.latitude.float,
208 laDirection = laValue,
209 turningSpeed = turning_speed,
210 useInputPower = useInputPower,
211 inputPowerDelta = inputPowerDelta)
212 elif nim.configMode.value == "advanced": #advanced config
213 self.updateAdvanced(sec, x)
214 print "sec config completed"
216 def updateAdvanced(self, sec, slotid):
218 for x in range(1,37):
221 #wildcard for all satellites ( for rotor )
222 for x in range(3601, 3605):
223 lnb = int(config.Nims[slotid].advanced.sat[x].lnb.value)
225 for x in self.NimManager.satList:
226 print "add", x[0], "to", lnb
227 lnbSat[lnb].append(x[0])
229 for x in self.NimManager.satList:
230 lnb = int(config.Nims[slotid].advanced.sat[x[0]].lnb.value)
232 print "add", x[0], "to", lnb
233 lnbSat[lnb].append(x[0])
235 for x in range(1,37):
236 if len(lnbSat[x]) > 0:
237 currLnb = config.Nims[slotid].advanced.lnb[x]
240 tunermask = 1 << slotid
241 if self.equal.has_key(slotid):
242 for slot in self.equal[slotid]:
243 tunermask |= (1 << slot)
244 elif self.linked.has_key(slotid):
245 for slot in self.linked[slotid]:
246 tunermask |= (1 << slot)
248 if currLnb.lof.value == "universal_lnb":
249 sec.setLNBLOFL(9750000)
250 sec.setLNBLOFH(10600000)
251 sec.setLNBThreshold(11700000)
252 elif currLnb.lof.value == "c_band":
253 sec.setLNBLOFL(5150000)
254 sec.setLNBLOFH(5150000)
255 sec.setLNBThreshold(5150000)
256 elif currLnb.lof.value == "user_defined":
257 sec.setLNBLOFL(currLnb.lofl.value * 1000)
258 sec.setLNBLOFH(currLnb.lofh.value * 1000)
259 sec.setLNBThreshold(currLnb.threshold.value * 1000)
261 # if currLnb.output_12v.value == "0V":
262 # pass # nyi in drivers
263 # elif currLnb.output_12v.value == "12V":
264 # pass # nyi in drivers
266 if currLnb.increased_voltage.value:
267 sec.setLNBIncreasedVoltage(lnbParam.ON)
269 sec.setLNBIncreasedVoltage(lnbParam.OFF)
271 dm = currLnb.diseqcMode.value
273 sec.setDiSEqCMode(diseqcParam.NONE)
275 sec.setDiSEqCMode(diseqcParam.V1_0)
277 sec.setDiSEqCMode(diseqcParam.V1_1)
279 sec.setDiSEqCMode(diseqcParam.V1_2)
281 if self.satposdepends.has_key(slotid):
282 for slot in self.satposdepends[slotid]:
283 tunermask |= (1 << slot)
286 if currLnb.toneburst.value == "none":
287 sec.setToneburst(diseqcParam.NO)
288 elif currLnb.toneburst.value == "A":
289 sec.setToneburst(diseqcParam.A)
290 elif currLnb.toneburst.value == "B":
291 sec.setToneburst(diseqcParam.B)
293 # Committed Diseqc Command
294 cdc = currLnb.commitedDiseqcCommand.value
296 c = { "none": diseqcParam.SENDNO,
297 "AA": diseqcParam.AA,
298 "AB": diseqcParam.AB,
299 "BA": diseqcParam.BA,
300 "BB": diseqcParam.BB }
303 sec.setCommittedCommand(c[cdc])
305 sec.setCommittedCommand(long(cdc))
307 sec.setFastDiSEqC(currLnb.fastDiseqc.value)
309 sec.setSeqRepeat(currLnb.sequenceRepeat.value)
311 if currLnb.diseqcMode.value == "1_0":
312 currCO = currLnb.commandOrder1_0.value
314 currCO = currLnb.commandOrder.value
316 udc = int(currLnb.uncommittedDiseqcCommand.value)
318 sec.setUncommittedCommand(0xF0|(udc-1))
320 sec.setUncommittedCommand(0) # SENDNO
322 sec.setRepeats({"none": 0, "one": 1, "two": 2, "three": 3}[currLnb.diseqcRepeats.value])
324 setCommandOrder = False
326 # 0 "committed, toneburst",
327 # 1 "toneburst, committed",
328 # 2 "committed, uncommitted, toneburst",
329 # 3 "toneburst, committed, uncommitted",
330 # 4 "uncommitted, committed, toneburst"
331 # 5 "toneburst, uncommitted, commmitted"
332 order_map = {"ct": 0, "tc": 1, "cut": 2, "tcu": 3, "uct": 4, "tuc": 5}
333 sec.setCommandOrder(order_map[currCO])
336 latitude = currLnb.latitude.float
337 sec.setLatitude(latitude)
338 longitude = currLnb.longitude.float
339 sec.setLongitude(longitude)
340 if currLnb.latitudeOrientation.value == "north":
341 sec.setLaDirection(rotorParam.NORTH)
343 sec.setLaDirection(rotorParam.SOUTH)
344 if currLnb.longitudeOrientation.value == "east":
345 sec.setLoDirection(rotorParam.EAST)
347 sec.setLoDirection(rotorParam.WEST)
349 if currLnb.powerMeasurement.value:
350 sec.setUseInputpower(True)
351 sec.setInputpowerDelta(currLnb.powerThreshold.value)
352 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
353 if turn_speed_dict.has_key(currLnb.turningSpeed.value):
354 turning_speed = turn_speed_dict[currLnb.turningSpeed.value]
356 beg_time = localtime(currLnb.fastTurningBegin.value)
357 end_time = localtime(currLnb.fastTurningEnd.value)
358 turning_speed = ((beg_time.tm_hour + 1) * 60 + beg_time.tm_min + 1) << 16
359 turning_speed |= (end_time.tm_hour + 1) * 60 + end_time.tm_min + 1
360 sec.setRotorTurningSpeed(turning_speed)
362 sec.setUseInputpower(False)
364 sec.setLNBSlotMask(tunermask)
366 # finally add the orbital positions
368 self.addSatellite(sec, y)
370 satpos = x > 32 and (3604-(36 - x)) or y
373 currSat = config.Nims[slotid].advanced.sat[satpos]
374 if currSat.voltage.value == "polarization":
375 sec.setVoltageMode(switchParam.HV)
376 elif currSat.voltage.value == "13V":
377 sec.setVoltageMode(switchParam._14V)
378 elif currSat.voltage.value == "18V":
379 sec.setVoltageMode(switchParam._18V)
381 if currSat.tonemode.value == "band":
382 sec.setToneMode(switchParam.HILO)
383 elif currSat.tonemode.value == "on":
384 sec.setToneMode(switchParam.ON)
385 elif currSat.tonemode.value == "off":
386 sec.setToneMode(switchParam.OFF)
388 if not currSat.usals.value and x < 34:
389 sec.setRotorPosNum(currSat.rotorposition.value)
391 sec.setRotorPosNum(0) #USALS
393 def __init__(self, nimmgr):
394 self.NimManager = nimmgr
395 self.configuredSatellites = Set()
399 def __init__(self, slot, type, description, has_outputs = True, internally_connectable = None):
402 if type not in ["DVB-S", "DVB-C", "DVB-T", "DVB-S2", None]:
403 print "warning: unknown NIM type %s, not using." % type
407 self.description = description
408 self.has_outputs = has_outputs
409 self.internally_connectable = internally_connectable
411 def isCompatible(self, what):
414 "DVB-S": ["DVB-S", None],
415 "DVB-C": ["DVB-C", None],
416 "DVB-T": ["DVB-T", None],
417 "DVB-S2": ["DVB-S", "DVB-S2", None]
419 return what in compatible[self.type]
421 def connectableTo(self):
423 "DVB-S": ["DVB-S", "DVB-S2"],
426 "DVB-S2": ["DVB-S", "DVB-S2"]
428 return connectable[self.type]
430 def getSlotName(self):
431 # get a friendly description for a slot name.
432 # we name them "Tuner A/B/C/...", because that's what's usually written on the back
434 return _("Tuner ") + chr(ord('A') + self.slot)
436 slot_name = property(getSlotName)
439 return chr(ord('A') + self.slot)
441 def hasOutputs(self):
442 return self.has_outputs
444 def internallyConnectableTo(self):
445 return self.internally_connectable
447 slot_id = property(getSlotID)
449 def getFriendlyType(self):
458 friendly_type = property(getFriendlyType)
460 def getFriendlyFullDescription(self):
461 nim_text = self.slot_name + ": "
464 nim_text += _("(empty)")
466 nim_text += self.description + " (" + self.friendly_type + ")"
470 friendly_full_description = property(getFriendlyFullDescription)
471 config_mode = property(lambda self: config.Nims[self.slot].configMode.value)
472 config = property(lambda self: config.Nims[self.slot])
473 empty = property(lambda self: self.type is None)
476 def getConfiguredSats(self):
477 return self.sec.getConfiguredSats()
479 def getTransponders(self, pos):
480 if self.transponders.has_key(pos):
481 return self.transponders[pos]
485 def getTranspondersCable(self, nim):
486 nimConfig = config.Nims[nim]
487 if nimConfig.configMode.value != "nothing" and nimConfig.cable.scan_type.value == "provider":
488 return self.transponderscable[self.cablesList[nimConfig.cable.scan_provider.index][0]]
491 def getTranspondersTerrestrial(self, region):
492 return self.transpondersterrestrial[region]
494 def getCableDescription(self, nim):
495 return self.cablesList[config.Nims[nim].scan_provider.index][0]
497 def getCableFlags(self, nim):
498 return self.cablesList[config.Nims[nim].scan_provider.index][1]
500 def getTerrestrialDescription(self, nim):
501 return self.terrestrialsList[config.Nims[nim].terrestrial.index][0]
503 def getTerrestrialFlags(self, nim):
504 return self.terrestrialsList[config.Nims[nim].terrestrial.index][1]
506 def getSatDescription(self, pos):
507 return self.satellites[pos]
509 def readTransponders(self):
510 # read initial networks from file. we only read files which we are interested in,
511 # which means only these where a compatible tuner exists.
512 self.satellites = { }
513 self.transponders = { }
514 self.transponderscable = { }
515 self.transpondersterrestrial = { }
516 db = eDVBDB.getInstance()
517 if self.hasNimType("DVB-S"):
518 print "Reading satellites.xml"
519 db.readSatellites(self.satList, self.satellites, self.transponders)
520 # print "SATLIST", self.satList
521 # print "SATS", self.satellites
522 # print "TRANSPONDERS", self.transponders
524 if self.hasNimType("DVB-C"):
525 print "Reading cables.xml"
526 db.readCables(self.cablesList, self.transponderscable)
527 # print "CABLIST", self.cablesList
528 # print "TRANSPONDERS", self.transponders
530 if self.hasNimType("DVB-T"):
531 print "Reading terrestrial.xml"
532 db.readTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
533 # print "TERLIST", self.terrestrialsList
534 # print "TRANSPONDERS", self.transpondersterrestrial
536 def enumerateNIMs(self):
537 # enum available NIMs. This is currently very dreambox-centric and uses the /proc/bus/nim_sockets interface.
538 # the result will be stored into nim_slots.
539 # the content of /proc/bus/nim_sockets looks like:
542 # Name: BCM4501 DVB-S2 NIM (internal)
545 # Name: BCM4501 DVB-S2 NIM (internal)
548 # Name: Philips TU1216
551 # Name: Alps BSBE1 702A
554 # Type will be either "DVB-S", "DVB-S2", "DVB-T", "DVB-C" or None.
556 # nim_slots is an array which has exactly one entry for each slot, even for empty ones.
559 nimfile = tryOpen("/proc/bus/nim_sockets")
567 for line in nimfile.readlines():
570 if line.strip().startswith("NIM Socket"):
571 parts = line.strip().split(" ")
572 current_slot = int(parts[2][:-1])
573 entries[current_slot] = {}
574 elif line.strip().startswith("Type:"):
575 entries[current_slot]["type"] = str(line.strip()[6:])
576 elif line.strip().startswith("Name:"):
577 entries[current_slot]["name"] = str(line.strip()[6:])
578 elif line.strip().startswith("Has_Outputs:"):
579 input = str(line.strip()[len("Has_Outputs:") + 1:])
580 entries[current_slot]["has_outputs"] = (input == "yes")
581 elif line.strip().startswith("Internally_Connectable:"):
582 input = int(line.strip()[len("Internally_Connectable:") + 1:])
583 entries[current_slot]["internally_connectable"] = input
584 elif line.strip().startswith("empty"):
585 entries[current_slot]["type"] = None
586 entries[current_slot]["name"] = _("N/A")
589 for id, entry in entries.items():
590 if not (entry.has_key("name") and entry.has_key("type")):
591 entry["name"] = _("N/A")
593 if not (entry.has_key("has_outputs")):
594 entry["has_outputs"] = True
595 if not (entry.has_key("internally_connectable")):
596 entry["internally_connectable"] = None
597 self.nim_slots.append(NIM(slot = id, description = entry["name"], type = entry["type"], has_outputs = entry["has_outputs"], internally_connectable = entry["internally_connectable"]))
599 def hasNimType(self, chktype):
600 for slot in self.nim_slots:
601 if slot.isCompatible(chktype):
605 def getNimType(self, slotid):
606 return self.nim_slots[slotid].type
608 def getNimDescription(self, slotid):
609 return self.nim_slots[slotid].friendly_full_description
611 def getNimListOfType(self, type, exception = -1):
612 # returns a list of indexes for NIMs compatible to the given type, except for 'exception'
614 for x in self.nim_slots:
615 if x.isCompatible(type) and x.slot != exception:
622 self.terrestrialsList = []
624 self.readTransponders()
625 InitNimManager(self) #init config stuff
627 # get a list with the friendly full description
630 for slot in self.nim_slots:
631 list.append(slot.friendly_full_description)
634 def getSlotCount(self):
635 return len(self.nim_slots)
637 def hasOutputs(self, slotid):
638 return self.nim_slots[slotid].hasOutputs()
640 def canConnectTo(self, slotid):
642 if self.nim_slots[slotid].internallyConnectableTo() is not None:
643 slots.append(self.nim_slots[slotid].internallyConnectableTo())
644 for type in self.nim_slots[slotid].connectableTo():
645 for slot in self.getNimListOfType(type, exception = slotid):
646 if self.hasOutputs(slot):
648 # remove nims, that have a conntectedTo reference on
649 for testnim in slots[:]:
650 for nim in self.getNimListOfType("DVB-S", slotid):
651 nimConfig = self.getNimConfig(nim)
652 if nimConfig.content.items.has_key("configMode") and nimConfig.configMode.value == "loopthrough" and int(nimConfig.connectedTo.value) == testnim:
653 slots.remove(testnim)
659 def canEqualTo(self, slotid):
660 type = self.getNimType(slotid)
663 nimList = self.getNimListOfType(type, slotid)
664 for nim in nimList[:]:
665 mode = self.getNimConfig(nim)
666 if mode.configMode.value == "loopthrough" or mode.configMode.value == "satposdepends":
670 def canDependOn(self, slotid):
671 type = self.getNimType(slotid)
674 nimList = self.getNimListOfType(type, slotid)
676 for nim in nimList[:]:
677 mode = self.getNimConfig(nim)
678 nimHaveRotor = mode.configMode.value == "simple" and mode.diseqcMode.value == "positioner"
679 if not nimHaveRotor and mode.configMode.value == "advanced":
680 for x in range(3601, 3605):
681 lnb = int(mode.advanced.sat[x].lnb.value)
686 for sat in mode.advanced.sat.values():
687 lnb_num = int(sat.lnb.value)
688 diseqcmode = lnb_num and mode.advanced.lnb[lnb_num].diseqcMode.value or ""
689 if diseqcmode == "1_2":
693 alreadyConnected = False
694 for testnim in nimList:
695 testmode = self.getNimConfig(testnim)
696 if testmode.configMode.value == "satposdepends" and int(testmode.connectedTo.value) == int(nim):
697 alreadyConnected = True
699 if not alreadyConnected:
700 positionerList.append(nim)
701 return positionerList
703 def getNimConfig(self, slotid):
704 return config.Nims[slotid]
706 def getSatName(self, pos):
707 for sat in self.satList:
712 def getSatList(self):
715 def getSatListForNim(self, slotid):
717 if self.nim_slots[slotid].isCompatible("DVB-S"):
718 nim = config.Nims[slotid]
719 #print "slotid:", slotid
721 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.index]
722 #print "diseqcA:", config.Nims[slotid].diseqcA.value
723 configMode = nim.configMode.value
725 if configMode == "equal":
726 slotid = int(nim.connectedTo.value)
727 nim = config.Nims[slotid]
728 configMode = nim.configMode.value
729 elif configMode == "loopthrough":
730 slotid = self.sec.getRoot(slotid, int(nim.connectedTo.value))
731 nim = config.Nims[slotid]
732 configMode = nim.configMode.value
734 if configMode == "simple":
735 dm = nim.diseqcMode.value
736 if dm in ["single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
737 list.append(self.satList[nim.diseqcA.index])
738 if dm in ["toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
739 list.append(self.satList[nim.diseqcB.index])
740 if dm == "diseqc_a_b_c_d":
741 list.append(self.satList[nim.diseqcC.index])
742 list.append(self.satList[nim.diseqcD.index])
743 if dm == "positioner":
744 for x in self.satList:
746 elif configMode == "advanced":
747 for x in range(3601, 3605):
748 if int(nim.advanced.sat[x].lnb.value) != 0:
749 for x in self.satList:
752 for x in self.satList:
753 if int(nim.advanced.sat[x[0]].lnb.value) != 0:
757 def getRotorSatListForNim(self, slotid):
759 if self.nim_slots[slotid].isCompatible("DVB-S"):
760 #print "slotid:", slotid
761 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
762 #print "diseqcA:", config.Nims[slotid].diseqcA.value
763 configMode = config.Nims[slotid].configMode.value
764 if configMode == "simple":
765 if config.Nims[slotid].diseqcMode.value == "positioner":
766 for x in self.satList:
768 elif configMode == "advanced":
769 nim = config.Nims[slotid]
770 for x in range(3601, 3605):
771 if int(nim.advanced.sat[x].lnb.value) != 0:
772 for x in self.satList:
775 for x in self.satList:
776 lnbnum = int(nim.advanced.sat[x[0]].lnb.value)
778 lnb = nim.advanced.lnb[lnbnum]
779 if lnb.diseqcMode.value == "1_2":
784 config.sec = ConfigSubsection()
786 x = ConfigInteger(default=15, limits = (0, 9999))
787 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_CONT_TONE, configElement.value))
788 config.sec.delay_after_continuous_tone_change = x
790 x = ConfigInteger(default=10, limits = (0, 9999))
791 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_VOLTAGE_CHANGE, configElement.value))
792 config.sec.delay_after_final_voltage_change = x
794 x = ConfigInteger(default=120, limits = (0, 9999))
795 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_DISEQC_REPEATS, configElement.value))
796 config.sec.delay_between_diseqc_repeats = x
798 x = ConfigInteger(default=50, limits = (0, 9999))
799 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_LAST_DISEQC_CMD, configElement.value))
800 config.sec.delay_after_last_diseqc_command = x
802 x = ConfigInteger(default=50, limits = (0, 9999))
803 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value))
804 config.sec.delay_after_toneburst = x
806 x = ConfigInteger(default=20, limits = (0, 9999))
807 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS, configElement.value))
808 config.sec.delay_after_change_voltage_before_switch_command = x
810 x = ConfigInteger(default=200, limits = (0, 9999))
811 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS, configElement.value))
812 config.sec.delay_after_enable_voltage_before_switch_command = x
814 x = ConfigInteger(default=700, limits = (0, 9999))
815 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_SWITCH_AND_MOTOR_CMD, configElement.value))
816 config.sec.delay_between_switch_and_motor_command = x
818 x = ConfigInteger(default=500, limits = (0, 9999))
819 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MEASURE_IDLE_INPUTPOWER, configElement.value))
820 config.sec.delay_after_voltage_change_before_measure_idle_inputpower = x
822 x = ConfigInteger(default=750, limits = (0, 9999))
823 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_MOTOR_CMD, configElement.value))
824 config.sec.delay_after_enable_voltage_before_motor_command = x
826 x = ConfigInteger(default=500, limits = (0, 9999))
827 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_MOTOR_STOP_CMD, configElement.value))
828 config.sec.delay_after_motor_stop_command = x
830 x = ConfigInteger(default=500, limits = (0, 9999))
831 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MOTOR_CMD, configElement.value))
832 config.sec.delay_after_voltage_change_before_motor_command = x
834 x = ConfigInteger(default=70, limits = (0, 9999))
835 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BEFORE_SEQUENCE_REPEAT, configElement.value))
836 config.sec.delay_before_sequence_repeat = x
838 x = ConfigInteger(default=360, limits = (0, 9999))
839 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_RUNNING_TIMEOUT, configElement.value))
840 config.sec.motor_running_timeout = x
842 x = ConfigInteger(default=1, limits = (0, 5))
843 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_COMMAND_RETRIES, configElement.value))
844 config.sec.motor_command_retries = x
846 # TODO add support for satpos depending nims to advanced nim configuration
847 # so a second/third/fourth cable from a motorized lnb can used behind a
848 # diseqc 1.0 / diseqc 1.1 / toneburst switch
849 # the C(++) part should can handle this
850 # the configElement should be only visible when diseqc 1.2 is disabled
852 def InitNimManager(nimmgr):
856 config.Nims = ConfigSubList()
857 for x in range(len(nimmgr.nim_slots)):
858 config.Nims.append(ConfigSubsection())
860 for slot in nimmgr.nim_slots:
864 if slot.isCompatible("DVB-S"):
865 choices = { "nothing": _("nothing connected"),
866 "simple": _("simple"),
867 "advanced": _("advanced")}
868 if len(nimmgr.getNimListOfType(slot.type, exception = x)) > 0:
869 choices["equal"] = _("equal to")
870 choices["satposdepends"] = _("second cable of motorized LNB")
871 if len(nimmgr.canConnectTo(x)) > 0:
872 choices["loopthrough"] = _("loopthrough to")
873 nim.configMode = ConfigSelection(choices = choices, default = "nothing")
875 # for y in nimmgr.nim_slots:
877 # if not y.isCompatible("DVB-S"):
879 # nim.configMode.value = "simple"
880 # nim.configMode.save()
882 nim.diseqcMode = ConfigSelection(
884 ("single", _("Single")),
885 ("toneburst_a_b", _("Toneburst A/B")),
886 ("diseqc_a_b", _("DiSEqC A/B")),
887 ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")),
888 ("positioner", _("Positioner"))],
889 default = "diseqc_a_b")
892 for id in nimmgr.getNimListOfType("DVB-S"):
894 choices.append((str(id), nimmgr.getNimDescription(id)))
895 nim.connectedTo = ConfigSelection(choices = choices)
896 nim.diseqcA = getConfigSatlist(192, nimmgr.satList)
897 nim.diseqcB = getConfigSatlist(130, nimmgr.satList)
898 nim.diseqcC = ConfigSatlist(list = nimmgr.satList)
899 nim.diseqcD = ConfigSatlist(list = nimmgr.satList)
900 nim.positionerMode = ConfigSelection(
902 ("usals", _("USALS")),
903 ("manual", _("manual"))],
905 nim.longitude = ConfigFloat(default=[5,100], limits=[(0,359),(0,999)])
906 nim.longitudeOrientation = ConfigSelection(choices={"east": _("East"), "west": _("West")}, default = "east")
907 nim.latitude = ConfigFloat(default=[50,767], limits=[(0,359),(0,999)])
908 nim.latitudeOrientation = ConfigSelection(choices={"north": _("North"), "south": _("South")}, default="north")
909 nim.powerMeasurement = ConfigYesNo(default=True)
910 nim.powerThreshold = ConfigInteger(default=hw.get_device_name() == "dm8000" and 15 or 50, limits=(0, 100))
911 nim.turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch")) ], default = "fast")
912 btime = datetime(1970, 1, 1, 7, 0);
913 nim.fastTurningBegin = ConfigDateTime(default = mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 900)
914 etime = datetime(1970, 1, 1, 19, 0);
915 nim.fastTurningEnd = ConfigDateTime(default = mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 900)
918 nim.advanced = ConfigSubsection()
919 tmp = [(3601, _('All Satellites')+' 1', 1), (3602, _('All Satellites')+' 2', 1), (3603, _('All Satellites')+' 3', 1), (3604, _('All Satellites')+' 4', 1)]
920 nim.advanced.sats = getConfigSatlist(192,nimmgr.satList+tmp)
921 nim.advanced.sat = ConfigSubDict()
922 lnbs = [("0", "not available")]
923 for y in range(1, 33):
924 lnbs.append((str(y), "LNB " + str(y)))
926 for x in nimmgr.satList:
927 nim.advanced.sat[x[0]] = ConfigSubsection()
928 nim.advanced.sat[x[0]].voltage = ConfigSelection(choices={"polarization": _("Polarization"), "13V": _("13 V"), "18V": _("18 V")}, default = "polarization")
929 nim.advanced.sat[x[0]].tonemode = ConfigSelection(choices={"band": _("Band"), "on": _("On"), "off": _("Off")}, default = "band")
930 nim.advanced.sat[x[0]].usals = ConfigYesNo(default=True)
931 nim.advanced.sat[x[0]].rotorposition = ConfigInteger(default=1, limits=(1, 255))
932 nim.advanced.sat[x[0]].lnb = ConfigSelection(choices = lnbs)
934 for x in range(3601, 3605):
935 nim.advanced.sat[x] = ConfigSubsection()
936 nim.advanced.sat[x].voltage = ConfigSelection(choices={"polarization": _("Polarization"), "13V": _("13 V"), "18V": _("18 V")}, default = "polarization")
937 nim.advanced.sat[x].tonemode = ConfigSelection(choices={"band": _("Band"), "on": _("On"), "off": _("Off")}, default = "band")
938 nim.advanced.sat[x].usals = ConfigYesNo(default=True)
939 nim.advanced.sat[x].rotorposition = ConfigInteger(default=1, limits=(1, 255))
941 nim.advanced.sat[x].lnb = ConfigSelection(choices = [("0", "not available"), (str(lnbnum), "LNB %d"%(lnbnum))], default="0")
943 csw = [("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))]
944 for y in range(0, 16):
945 csw.append((str(0xF0|y), "Input " + str(y+1)))
947 ucsw = [("0", _("None"))]
948 for y in range(1, 17):
949 ucsw.append((str(y), "Input " + str(y)))
951 nim.advanced.lnb = ConfigSubList()
952 nim.advanced.lnb.append(ConfigNothing())
953 for x in range(1, 37):
954 nim.advanced.lnb.append(ConfigSubsection())
955 nim.advanced.lnb[x].lof = ConfigSelection(choices={"universal_lnb": _("Universal LNB"), "c_band": _("C-Band"), "user_defined": _("User defined")}, default="universal_lnb")
956 nim.advanced.lnb[x].lofl = ConfigInteger(default=9750, limits = (0, 99999))
957 nim.advanced.lnb[x].lofh = ConfigInteger(default=10600, limits = (0, 99999))
958 nim.advanced.lnb[x].threshold = ConfigInteger(default=11700, limits = (0, 99999))
959 # nim.advanced.lnb[x].output_12v = ConfigSelection(choices = [("0V", _("0 V")), ("12V", _("12 V"))], default="0V")
960 nim.advanced.lnb[x].increased_voltage = ConfigYesNo(default=False)
961 nim.advanced.lnb[x].toneburst = ConfigSelection(choices = [("none", _("None")), ("A", _("A")), ("B", _("B"))], default = "none")
963 nim.advanced.lnb[x].diseqcMode = ConfigSelection(choices = [("1_2", _("1.2"))], default = "1_2")
965 nim.advanced.lnb[x].diseqcMode = ConfigSelection(choices = [("none", _("None")), ("1_0", _("1.0")), ("1_1", _("1.1")), ("1_2", _("1.2"))], default = "none")
966 nim.advanced.lnb[x].commitedDiseqcCommand = ConfigSelection(choices = csw)
967 nim.advanced.lnb[x].fastDiseqc = ConfigYesNo(default=False)
968 nim.advanced.lnb[x].sequenceRepeat = ConfigYesNo(default=False)
969 nim.advanced.lnb[x].commandOrder1_0 = ConfigSelection(choices = [("ct", "committed, toneburst"), ("tc", "toneburst, committed")], default = "ct")
970 nim.advanced.lnb[x].commandOrder = ConfigSelection(choices = [
971 ("ct", "committed, toneburst"),
972 ("tc", "toneburst, committed"),
973 ("cut", "committed, uncommitted, toneburst"),
974 ("tcu", "toneburst, committed, uncommitted"),
975 ("uct", "uncommitted, committed, toneburst"),
976 ("tuc", "toneburst, uncommitted, commmitted")],
978 nim.advanced.lnb[x].uncommittedDiseqcCommand = ConfigSelection(choices = ucsw)
979 nim.advanced.lnb[x].diseqcRepeats = ConfigSelection(choices = [("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))], default = "none")
980 nim.advanced.lnb[x].longitude = ConfigFloat(default = [5,100], limits = [(0,359),(0,999)])
981 nim.advanced.lnb[x].longitudeOrientation = ConfigSelection(choices = [("east", _("East")), ("west", _("West"))], default = "east")
982 nim.advanced.lnb[x].latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)])
983 nim.advanced.lnb[x].latitudeOrientation = ConfigSelection(choices = [("north", _("North")), ("south", _("South"))], default = "north")
984 nim.advanced.lnb[x].powerMeasurement = ConfigYesNo(default=True)
985 nim.advanced.lnb[x].powerThreshold = ConfigInteger(default=hw.get_device_name() == "dm8000" and 15 or 50, limits=(0, 100))
986 nim.advanced.lnb[x].turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch"))], default = "fast")
987 btime = datetime(1970, 1, 1, 7, 0);
988 nim.advanced.lnb[x].fastTurningBegin = ConfigDateTime(default=mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 600)
989 etime = datetime(1970, 1, 1, 19, 0);
990 nim.advanced.lnb[x].fastTurningEnd = ConfigDateTime(default=mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 600)
991 elif slot.isCompatible("DVB-C"):
992 nim.configMode = ConfigSelection(
994 "enabled": _("enabled"),
995 "nothing": _("nothing connected"),
1000 for x in nimmgr.cablesList:
1001 list.append((str(n), x[0]))
1003 nim.cable = ConfigSubsection()
1004 possible_scan_types = [("bands", _("Frequency bands")), ("steps", _("Frequency steps"))]
1006 possible_scan_types.append(("provider", _("Provider")))
1007 nim.cable.scan_provider = ConfigSelection(default = "0", choices = list)
1008 nim.cable.scan_type = ConfigSelection(default = "bands", choices = possible_scan_types)
1009 nim.cable.scan_band_EU_VHF_I = ConfigYesNo(default = True)
1010 nim.cable.scan_band_EU_MID = ConfigYesNo(default = True)
1011 nim.cable.scan_band_EU_VHF_III = ConfigYesNo(default = True)
1012 nim.cable.scan_band_EU_UHF_IV = ConfigYesNo(default = True)
1013 nim.cable.scan_band_EU_UHF_V = ConfigYesNo(default = True)
1014 nim.cable.scan_band_EU_SUPER = ConfigYesNo(default = True)
1015 nim.cable.scan_band_EU_HYPER = ConfigYesNo(default = True)
1016 nim.cable.scan_band_US_LOW = ConfigYesNo(default = False)
1017 nim.cable.scan_band_US_MID = ConfigYesNo(default = False)
1018 nim.cable.scan_band_US_HIGH = ConfigYesNo(default = False)
1019 nim.cable.scan_band_US_SUPER = ConfigYesNo(default = False)
1020 nim.cable.scan_band_US_HYPER = ConfigYesNo(default = False)
1021 nim.cable.scan_frequency_steps = ConfigInteger(default = 1000, limits = (1000, 10000))
1022 nim.cable.scan_mod_qam16 = ConfigYesNo(default = False)
1023 nim.cable.scan_mod_qam32 = ConfigYesNo(default = False)
1024 nim.cable.scan_mod_qam64 = ConfigYesNo(default = True)
1025 nim.cable.scan_mod_qam128 = ConfigYesNo(default = False)
1026 nim.cable.scan_mod_qam256 = ConfigYesNo(default = True)
1027 nim.cable.scan_sr_6900 = ConfigYesNo(default = True)
1028 nim.cable.scan_sr_6875 = ConfigYesNo(default = True)
1029 nim.cable.scan_sr_ext1 = ConfigInteger(default = 0, limits = (0, 7230))
1030 nim.cable.scan_sr_ext2 = ConfigInteger(default = 0, limits = (0, 7230))
1031 elif slot.isCompatible("DVB-T"):
1032 nim.configMode = ConfigSelection(
1034 "enabled": _("enabled"),
1035 "nothing": _("nothing connected"),
1037 default = "enabled")
1040 for x in nimmgr.terrestrialsList:
1041 list.append((str(n), x[0]))
1043 nim.terrestrial = ConfigSelection(choices = list)
1044 nim.terrestrial_5V = ConfigOnOff()
1046 nim.configMode = ConfigSelection(choices = { "nothing": _("disabled") }, default="nothing");
1047 if slot.type is not None:
1048 print "pls add support for this frontend type!", slot.type
1051 nimmgr.sec = SecConfigure(nimmgr)
1053 nimmanager = NimManager()