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=hw.get_device_name() == "dm8000" and 15 or 50
194 if nim.powerMeasurement.value:
196 inputPowerDelta=nim.powerThreshold.value
197 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
198 if turn_speed_dict.has_key(nim.turningSpeed.value):
199 turning_speed = turn_speed_dict[nim.turningSpeed.value]
201 beg_time = localtime(nim.fastTurningBegin.value)
202 end_time = localtime(nim.fastTurningEnd.value)
203 turning_speed = ((beg_time.tm_hour+1) * 60 + beg_time.tm_min + 1) << 16
204 turning_speed |= (end_time.tm_hour+1) * 60 + end_time.tm_min + 1
205 self.addLNBSimple(sec, slotid = x, diseqcmode = 3,
206 longitude = nim.longitude.float,
207 loDirection = loValue,
208 latitude = nim.latitude.float,
209 laDirection = laValue,
210 turningSpeed = turning_speed,
211 useInputPower = useInputPower,
212 inputPowerDelta = inputPowerDelta)
213 elif nim.configMode.value == "advanced": #advanced config
214 self.updateAdvanced(sec, x)
215 print "sec config completed"
217 def updateAdvanced(self, sec, slotid):
219 for x in range(1,37):
222 #wildcard for all satellites ( for rotor )
223 for x in range(3601, 3605):
224 lnb = int(config.Nims[slotid].advanced.sat[x].lnb.value)
226 for x in self.NimManager.satList:
227 print "add", x[0], "to", lnb
228 lnbSat[lnb].append(x[0])
230 for x in self.NimManager.satList:
231 lnb = int(config.Nims[slotid].advanced.sat[x[0]].lnb.value)
233 print "add", x[0], "to", lnb
234 lnbSat[lnb].append(x[0])
236 for x in range(1,37):
237 if len(lnbSat[x]) > 0:
238 currLnb = config.Nims[slotid].advanced.lnb[x]
241 tunermask = 1 << slotid
242 if self.equal.has_key(slotid):
243 for slot in self.equal[slotid]:
244 tunermask |= (1 << slot)
245 elif self.linked.has_key(slotid):
246 for slot in self.linked[slotid]:
247 tunermask |= (1 << slot)
249 if currLnb.lof.value == "universal_lnb":
250 sec.setLNBLOFL(9750000)
251 sec.setLNBLOFH(10600000)
252 sec.setLNBThreshold(11700000)
253 elif currLnb.lof.value == "c_band":
254 sec.setLNBLOFL(5150000)
255 sec.setLNBLOFH(5150000)
256 sec.setLNBThreshold(5150000)
257 elif currLnb.lof.value == "user_defined":
258 sec.setLNBLOFL(currLnb.lofl.value * 1000)
259 sec.setLNBLOFH(currLnb.lofh.value * 1000)
260 sec.setLNBThreshold(currLnb.threshold.value * 1000)
262 # if currLnb.output_12v.value == "0V":
263 # pass # nyi in drivers
264 # elif currLnb.output_12v.value == "12V":
265 # pass # nyi in drivers
267 if currLnb.increased_voltage.value:
268 sec.setLNBIncreasedVoltage(lnbParam.ON)
270 sec.setLNBIncreasedVoltage(lnbParam.OFF)
272 dm = currLnb.diseqcMode.value
274 sec.setDiSEqCMode(diseqcParam.NONE)
276 sec.setDiSEqCMode(diseqcParam.V1_0)
278 sec.setDiSEqCMode(diseqcParam.V1_1)
280 sec.setDiSEqCMode(diseqcParam.V1_2)
282 if self.satposdepends.has_key(slotid):
283 for slot in self.satposdepends[slotid]:
284 tunermask |= (1 << slot)
287 if currLnb.toneburst.value == "none":
288 sec.setToneburst(diseqcParam.NO)
289 elif currLnb.toneburst.value == "A":
290 sec.setToneburst(diseqcParam.A)
291 elif currLnb.toneburst.value == "B":
292 sec.setToneburst(diseqcParam.B)
294 # Committed Diseqc Command
295 cdc = currLnb.commitedDiseqcCommand.value
297 c = { "none": diseqcParam.SENDNO,
298 "AA": diseqcParam.AA,
299 "AB": diseqcParam.AB,
300 "BA": diseqcParam.BA,
301 "BB": diseqcParam.BB }
304 sec.setCommittedCommand(c[cdc])
306 sec.setCommittedCommand(long(cdc))
308 sec.setFastDiSEqC(currLnb.fastDiseqc.value)
310 sec.setSeqRepeat(currLnb.sequenceRepeat.value)
312 if currLnb.diseqcMode.value == "1_0":
313 currCO = currLnb.commandOrder1_0.value
315 currCO = currLnb.commandOrder.value
317 udc = int(currLnb.uncommittedDiseqcCommand.value)
319 sec.setUncommittedCommand(0xF0|(udc-1))
321 sec.setUncommittedCommand(0) # SENDNO
323 sec.setRepeats({"none": 0, "one": 1, "two": 2, "three": 3}[currLnb.diseqcRepeats.value])
325 setCommandOrder = False
327 # 0 "committed, toneburst",
328 # 1 "toneburst, committed",
329 # 2 "committed, uncommitted, toneburst",
330 # 3 "toneburst, committed, uncommitted",
331 # 4 "uncommitted, committed, toneburst"
332 # 5 "toneburst, uncommitted, commmitted"
333 order_map = {"ct": 0, "tc": 1, "cut": 2, "tcu": 3, "uct": 4, "tuc": 5}
334 sec.setCommandOrder(order_map[currCO])
337 latitude = currLnb.latitude.float
338 sec.setLatitude(latitude)
339 longitude = currLnb.longitude.float
340 sec.setLongitude(longitude)
341 if currLnb.latitudeOrientation.value == "north":
342 sec.setLaDirection(rotorParam.NORTH)
344 sec.setLaDirection(rotorParam.SOUTH)
345 if currLnb.longitudeOrientation.value == "east":
346 sec.setLoDirection(rotorParam.EAST)
348 sec.setLoDirection(rotorParam.WEST)
350 if currLnb.powerMeasurement.value:
351 sec.setUseInputpower(True)
352 sec.setInputpowerDelta(currLnb.powerThreshold.value)
353 turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
354 if turn_speed_dict.has_key(currLnb.turningSpeed.value):
355 turning_speed = turn_speed_dict[currLnb.turningSpeed.value]
357 beg_time = localtime(currLnb.fastTurningBegin.value)
358 end_time = localtime(currLnb.fastTurningEnd.value)
359 turning_speed = ((beg_time.tm_hour + 1) * 60 + beg_time.tm_min + 1) << 16
360 turning_speed |= (end_time.tm_hour + 1) * 60 + end_time.tm_min + 1
361 sec.setRotorTurningSpeed(turning_speed)
363 sec.setUseInputpower(False)
365 sec.setLNBSlotMask(tunermask)
367 # finally add the orbital positions
369 self.addSatellite(sec, y)
371 satpos = x > 32 and (3604-(36 - x)) or y
374 currSat = config.Nims[slotid].advanced.sat[satpos]
375 if currSat.voltage.value == "polarization":
376 sec.setVoltageMode(switchParam.HV)
377 elif currSat.voltage.value == "13V":
378 sec.setVoltageMode(switchParam._14V)
379 elif currSat.voltage.value == "18V":
380 sec.setVoltageMode(switchParam._18V)
382 if currSat.tonemode.value == "band":
383 sec.setToneMode(switchParam.HILO)
384 elif currSat.tonemode.value == "on":
385 sec.setToneMode(switchParam.ON)
386 elif currSat.tonemode.value == "off":
387 sec.setToneMode(switchParam.OFF)
389 if not currSat.usals.value and x < 34:
390 sec.setRotorPosNum(currSat.rotorposition.value)
392 sec.setRotorPosNum(0) #USALS
394 def __init__(self, nimmgr):
395 self.NimManager = nimmgr
396 self.configuredSatellites = Set()
400 def __init__(self, slot, type, description, has_outputs = True, internally_connectable = None):
403 if type not in ["DVB-S", "DVB-C", "DVB-T", "DVB-S2", None]:
404 print "warning: unknown NIM type %s, not using." % type
408 self.description = description
409 self.has_outputs = has_outputs
410 self.internally_connectable = internally_connectable
412 def isCompatible(self, what):
415 "DVB-S": ["DVB-S", None],
416 "DVB-C": ["DVB-C", None],
417 "DVB-T": ["DVB-T", None],
418 "DVB-S2": ["DVB-S", "DVB-S2", None]
420 return what in compatible[self.type]
422 def connectableTo(self):
424 "DVB-S": ["DVB-S", "DVB-S2"],
427 "DVB-S2": ["DVB-S", "DVB-S2"]
429 return connectable[self.type]
431 def getSlotName(self):
432 # get a friendly description for a slot name.
433 # we name them "Tuner A/B/C/...", because that's what's usually written on the back
435 return _("Tuner ") + chr(ord('A') + self.slot)
437 slot_name = property(getSlotName)
440 return chr(ord('A') + self.slot)
442 def hasOutputs(self):
443 return self.has_outputs
445 def internallyConnectableTo(self):
446 return self.internally_connectable
448 slot_id = property(getSlotID)
450 def getFriendlyType(self):
459 friendly_type = property(getFriendlyType)
461 def getFriendlyFullDescription(self):
462 nim_text = self.slot_name + ": "
465 nim_text += _("(empty)")
467 nim_text += self.description + " (" + self.friendly_type + ")"
471 friendly_full_description = property(getFriendlyFullDescription)
472 config_mode = property(lambda self: config.Nims[self.slot].configMode.value)
473 config = property(lambda self: config.Nims[self.slot])
474 empty = property(lambda self: self.type is None)
477 def getConfiguredSats(self):
478 return self.sec.getConfiguredSats()
480 def getTransponders(self, pos):
481 if self.transponders.has_key(pos):
482 return self.transponders[pos]
486 def getTranspondersCable(self, nim):
487 nimConfig = config.Nims[nim]
488 if nimConfig.configMode.value != "nothing" and nimConfig.cable.scan_type.value == "provider":
489 return self.transponderscable[self.cablesList[nimConfig.cable.scan_provider.index][0]]
492 def getTranspondersTerrestrial(self, region):
493 return self.transpondersterrestrial[region]
495 def getCableDescription(self, nim):
496 return self.cablesList[config.Nims[nim].scan_provider.index][0]
498 def getCableFlags(self, nim):
499 return self.cablesList[config.Nims[nim].scan_provider.index][1]
501 def getTerrestrialDescription(self, nim):
502 return self.terrestrialsList[config.Nims[nim].terrestrial.index][0]
504 def getTerrestrialFlags(self, nim):
505 return self.terrestrialsList[config.Nims[nim].terrestrial.index][1]
507 def getSatDescription(self, pos):
508 return self.satellites[pos]
510 def readTransponders(self):
511 # read initial networks from file. we only read files which we are interested in,
512 # which means only these where a compatible tuner exists.
513 self.satellites = { }
514 self.transponders = { }
515 self.transponderscable = { }
516 self.transpondersterrestrial = { }
517 db = eDVBDB.getInstance()
518 if self.hasNimType("DVB-S"):
519 print "Reading satellites.xml"
520 db.readSatellites(self.satList, self.satellites, self.transponders)
521 # print "SATLIST", self.satList
522 # print "SATS", self.satellites
523 # print "TRANSPONDERS", self.transponders
525 if self.hasNimType("DVB-C"):
526 print "Reading cables.xml"
527 db.readCables(self.cablesList, self.transponderscable)
528 # print "CABLIST", self.cablesList
529 # print "TRANSPONDERS", self.transponders
531 if self.hasNimType("DVB-T"):
532 print "Reading terrestrial.xml"
533 db.readTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
534 # print "TERLIST", self.terrestrialsList
535 # print "TRANSPONDERS", self.transpondersterrestrial
537 def enumerateNIMs(self):
538 # enum available NIMs. This is currently very dreambox-centric and uses the /proc/bus/nim_sockets interface.
539 # the result will be stored into nim_slots.
540 # the content of /proc/bus/nim_sockets looks like:
543 # Name: BCM4501 DVB-S2 NIM (internal)
546 # Name: BCM4501 DVB-S2 NIM (internal)
549 # Name: Philips TU1216
552 # Name: Alps BSBE1 702A
555 # Type will be either "DVB-S", "DVB-S2", "DVB-T", "DVB-C" or None.
557 # nim_slots is an array which has exactly one entry for each slot, even for empty ones.
560 nimfile = tryOpen("/proc/bus/nim_sockets")
568 for line in nimfile.readlines():
571 if line.strip().startswith("NIM Socket"):
572 parts = line.strip().split(" ")
573 current_slot = int(parts[2][:-1])
574 entries[current_slot] = {}
575 elif line.strip().startswith("Type:"):
576 entries[current_slot]["type"] = str(line.strip()[6:])
577 elif line.strip().startswith("Name:"):
578 entries[current_slot]["name"] = str(line.strip()[6:])
579 elif line.strip().startswith("Has_Outputs:"):
580 input = str(line.strip()[len("Has_Outputs:") + 1:])
581 entries[current_slot]["has_outputs"] = (input == "yes")
582 elif line.strip().startswith("Internally_Connectable:"):
583 input = int(line.strip()[len("Internally_Connectable:") + 1:])
584 entries[current_slot]["internally_connectable"] = input
585 elif line.strip().startswith("empty"):
586 entries[current_slot]["type"] = None
587 entries[current_slot]["name"] = _("N/A")
590 for id, entry in entries.items():
591 if not (entry.has_key("name") and entry.has_key("type")):
592 entry["name"] = _("N/A")
594 if not (entry.has_key("has_outputs")):
595 entry["has_outputs"] = True
596 if not (entry.has_key("internally_connectable")):
597 entry["internally_connectable"] = None
598 self.nim_slots.append(NIM(slot = id, description = entry["name"], type = entry["type"], has_outputs = entry["has_outputs"], internally_connectable = entry["internally_connectable"]))
600 def hasNimType(self, chktype):
601 for slot in self.nim_slots:
602 if slot.isCompatible(chktype):
606 def getNimType(self, slotid):
607 return self.nim_slots[slotid].type
609 def getNimDescription(self, slotid):
610 return self.nim_slots[slotid].friendly_full_description
612 def getNimListOfType(self, type, exception = -1):
613 # returns a list of indexes for NIMs compatible to the given type, except for 'exception'
615 for x in self.nim_slots:
616 if x.isCompatible(type) and x.slot != exception:
623 self.terrestrialsList = []
625 self.readTransponders()
626 InitNimManager(self) #init config stuff
628 # get a list with the friendly full description
631 for slot in self.nim_slots:
632 list.append(slot.friendly_full_description)
635 def getSlotCount(self):
636 return len(self.nim_slots)
638 def hasOutputs(self, slotid):
639 return self.nim_slots[slotid].hasOutputs()
641 def canConnectTo(self, slotid):
643 if self.nim_slots[slotid].internallyConnectableTo() is not None:
644 slots.append(self.nim_slots[slotid].internallyConnectableTo())
645 for type in self.nim_slots[slotid].connectableTo():
646 for slot in self.getNimListOfType(type, exception = slotid):
647 if self.hasOutputs(slot):
649 # remove nims, that have a conntectedTo reference on
650 for testnim in slots[:]:
651 for nim in self.getNimListOfType("DVB-S", slotid):
652 nimConfig = self.getNimConfig(nim)
653 if nimConfig.content.items.has_key("configMode") and nimConfig.configMode.value == "loopthrough" and int(nimConfig.connectedTo.value) == testnim:
654 slots.remove(testnim)
660 def canEqualTo(self, slotid):
661 type = self.getNimType(slotid)
664 nimList = self.getNimListOfType(type, slotid)
665 for nim in nimList[:]:
666 mode = self.getNimConfig(nim)
667 if mode.configMode.value == "loopthrough" or mode.configMode.value == "satposdepends":
671 def canDependOn(self, slotid):
672 type = self.getNimType(slotid)
675 nimList = self.getNimListOfType(type, slotid)
677 for nim in nimList[:]:
678 mode = self.getNimConfig(nim)
679 nimHaveRotor = mode.configMode.value == "simple" and mode.diseqcMode.value == "positioner"
680 if not nimHaveRotor and mode.configMode.value == "advanced":
681 for x in range(3601, 3605):
682 lnb = int(mode.advanced.sat[x].lnb.value)
687 alreadyConnected = False
688 for testnim in nimList:
689 testmode = self.getNimConfig(testnim)
690 if testmode.configMode.value == "satposdepends" and int(testmode.connectedTo.value) == int(nim):
691 alreadyConnected = True
693 if not alreadyConnected:
694 positionerList.append(nim)
695 return positionerList
697 def getNimConfig(self, slotid):
698 return config.Nims[slotid]
700 def getSatName(self, pos):
701 for sat in self.satList:
706 def getSatList(self):
709 def getSatListForNim(self, slotid):
711 if self.nim_slots[slotid].isCompatible("DVB-S"):
712 nim = config.Nims[slotid]
713 #print "slotid:", slotid
715 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.index]
716 #print "diseqcA:", config.Nims[slotid].diseqcA.value
717 configMode = nim.configMode.value
719 if configMode == "equal":
720 slotid = int(nim.connectedTo.value)
721 nim = config.Nims[slotid]
722 configMode = nim.configMode.value
723 elif configMode == "loopthrough":
724 slotid = self.sec.getRoot(slotid, int(nim.connectedTo.value))
725 nim = config.Nims[slotid]
726 configMode = nim.configMode.value
728 if configMode == "simple":
729 dm = nim.diseqcMode.value
730 if dm in ["single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
731 list.append(self.satList[nim.diseqcA.index])
732 if dm in ["toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
733 list.append(self.satList[nim.diseqcB.index])
734 if dm == "diseqc_a_b_c_d":
735 list.append(self.satList[nim.diseqcC.index])
736 list.append(self.satList[nim.diseqcD.index])
737 if dm == "positioner":
738 for x in self.satList:
740 elif configMode == "advanced":
741 for x in range(3601, 3605):
742 if int(nim.advanced.sat[x].lnb.value) != 0:
743 for x in self.satList:
746 for x in self.satList:
747 if int(nim.advanced.sat[x[0]].lnb.value) != 0:
751 def getRotorSatListForNim(self, slotid):
753 if self.nim_slots[slotid].isCompatible("DVB-S"):
754 #print "slotid:", slotid
755 #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
756 #print "diseqcA:", config.Nims[slotid].diseqcA.value
757 configMode = config.Nims[slotid].configMode.value
758 if configMode == "simple":
759 if config.Nims[slotid].diseqcMode.value == "positioner":
760 for x in self.satList:
762 elif configMode == "advanced":
763 nim = config.Nims[slotid]
764 for x in range(3601, 3605):
765 if int(nim.advanced.sat[x].lnb.value) != 0:
766 for x in self.satList:
769 for x in self.satList:
770 lnbnum = int(nim.advanced.sat[x[0]].lnb.value)
772 lnb = nim.advanced.lnb[lnbnum]
773 if lnb.diseqcMode.value == "1_2":
778 config.sec = ConfigSubsection()
780 x = ConfigInteger(default=15, limits = (0, 9999))
781 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_CONT_TONE, configElement.value))
782 config.sec.delay_after_continuous_tone_change = x
784 x = ConfigInteger(default=10, limits = (0, 9999))
785 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_VOLTAGE_CHANGE, configElement.value))
786 config.sec.delay_after_final_voltage_change = x
788 x = ConfigInteger(default=120, limits = (0, 9999))
789 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_DISEQC_REPEATS, configElement.value))
790 config.sec.delay_between_diseqc_repeats = x
792 x = ConfigInteger(default=50, limits = (0, 9999))
793 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_LAST_DISEQC_CMD, configElement.value))
794 config.sec.delay_after_last_diseqc_command = x
796 x = ConfigInteger(default=50, limits = (0, 9999))
797 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value))
798 config.sec.delay_after_toneburst = x
800 x = ConfigInteger(default=20, limits = (0, 9999))
801 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS, configElement.value))
802 config.sec.delay_after_change_voltage_before_switch_command = x
804 x = ConfigInteger(default=200, limits = (0, 9999))
805 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS, configElement.value))
806 config.sec.delay_after_enable_voltage_before_switch_command = x
808 x = ConfigInteger(default=700, limits = (0, 9999))
809 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_SWITCH_AND_MOTOR_CMD, configElement.value))
810 config.sec.delay_between_switch_and_motor_command = x
812 x = ConfigInteger(default=500, limits = (0, 9999))
813 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MEASURE_IDLE_INPUTPOWER, configElement.value))
814 config.sec.delay_after_voltage_change_before_measure_idle_inputpower = x
816 x = ConfigInteger(default=750, limits = (0, 9999))
817 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_MOTOR_CMD, configElement.value))
818 config.sec.delay_after_enable_voltage_before_motor_command = x
820 x = ConfigInteger(default=500, limits = (0, 9999))
821 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_MOTOR_STOP_CMD, configElement.value))
822 config.sec.delay_after_motor_stop_command = x
824 x = ConfigInteger(default=500, limits = (0, 9999))
825 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MOTOR_CMD, configElement.value))
826 config.sec.delay_after_voltage_change_before_motor_command = x
828 x = ConfigInteger(default=70, limits = (0, 9999))
829 x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BEFORE_SEQUENCE_REPEAT, configElement.value))
830 config.sec.delay_before_sequence_repeat = x
832 x = ConfigInteger(default=360, limits = (0, 9999))
833 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_RUNNING_TIMEOUT, configElement.value))
834 config.sec.motor_running_timeout = x
836 x = ConfigInteger(default=1, limits = (0, 5))
837 x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_COMMAND_RETRIES, configElement.value))
838 config.sec.motor_command_retries = x
840 # TODO add support for satpos depending nims to advanced nim configuration
841 # so a second/third/fourth cable from a motorized lnb can used behind a
842 # diseqc 1.0 / diseqc 1.1 / toneburst switch
843 # the C(++) part should can handle this
844 # the configElement should be only visible when diseqc 1.2 is disabled
846 def InitNimManager(nimmgr):
850 config.Nims = ConfigSubList()
851 for x in range(len(nimmgr.nim_slots)):
852 config.Nims.append(ConfigSubsection())
854 for slot in nimmgr.nim_slots:
858 if slot.isCompatible("DVB-S"):
859 choices = { "nothing": _("nothing connected"),
860 "simple": _("simple"),
861 "advanced": _("advanced")}
862 if len(nimmgr.getNimListOfType(slot.type, exception = x)) > 0:
863 choices["equal"] = _("equal to")
864 choices["satposdepends"] = _("second cable of motorized LNB")
865 if len(nimmgr.canConnectTo(x)) > 0:
866 choices["loopthrough"] = _("loopthrough to")
867 nim.configMode = ConfigSelection(choices = choices, default = "nothing")
869 # for y in nimmgr.nim_slots:
871 # if not y.isCompatible("DVB-S"):
873 # nim.configMode.value = "simple"
874 # nim.configMode.save()
876 nim.diseqcMode = ConfigSelection(
878 ("single", _("Single")),
879 ("toneburst_a_b", _("Toneburst A/B")),
880 ("diseqc_a_b", _("DiSEqC A/B")),
881 ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")),
882 ("positioner", _("Positioner"))],
883 default = "diseqc_a_b")
886 for id in nimmgr.getNimListOfType("DVB-S"):
888 choices.append((str(id), nimmgr.getNimDescription(id)))
889 nim.connectedTo = ConfigSelection(choices = choices)
890 nim.diseqcA = getConfigSatlist(192, nimmgr.satList)
891 nim.diseqcB = getConfigSatlist(130, nimmgr.satList)
892 nim.diseqcC = ConfigSatlist(list = nimmgr.satList)
893 nim.diseqcD = ConfigSatlist(list = nimmgr.satList)
894 nim.positionerMode = ConfigSelection(
896 ("usals", _("USALS")),
897 ("manual", _("manual"))],
899 nim.longitude = ConfigFloat(default=[5,100], limits=[(0,359),(0,999)])
900 nim.longitudeOrientation = ConfigSelection(choices={"east": _("East"), "west": _("West")}, default = "east")
901 nim.latitude = ConfigFloat(default=[50,767], limits=[(0,359),(0,999)])
902 nim.latitudeOrientation = ConfigSelection(choices={"north": _("North"), "south": _("South")}, default="north")
903 nim.powerMeasurement = ConfigYesNo(default=True)
904 nim.powerThreshold = ConfigInteger(default=50, limits=(0, 100))
905 nim.turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch")) ], default = "fast")
906 btime = datetime(1970, 1, 1, 7, 0);
907 nim.fastTurningBegin = ConfigDateTime(default = mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 900)
908 etime = datetime(1970, 1, 1, 19, 0);
909 nim.fastTurningEnd = ConfigDateTime(default = mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 900)
912 nim.advanced = ConfigSubsection()
913 tmp = [(3601, _('All Satellites')+' 1', 1), (3602, _('All Satellites')+' 2', 1), (3603, _('All Satellites')+' 3', 1), (3604, _('All Satellites')+' 4', 1)]
914 nim.advanced.sats = getConfigSatlist(192,nimmgr.satList+tmp)
915 nim.advanced.sat = ConfigSubDict()
916 lnbs = [("0", "not available")]
917 for y in range(1, 33):
918 lnbs.append((str(y), "LNB " + str(y)))
920 for x in nimmgr.satList:
921 nim.advanced.sat[x[0]] = ConfigSubsection()
922 nim.advanced.sat[x[0]].voltage = ConfigSelection(choices={"polarization": _("Polarization"), "13V": _("13 V"), "18V": _("18 V")}, default = "polarization")
923 nim.advanced.sat[x[0]].tonemode = ConfigSelection(choices={"band": _("Band"), "on": _("On"), "off": _("Off")}, default = "band")
924 nim.advanced.sat[x[0]].usals = ConfigYesNo(default=True)
925 nim.advanced.sat[x[0]].rotorposition = ConfigInteger(default=1, limits=(1, 255))
926 nim.advanced.sat[x[0]].lnb = ConfigSelection(choices = lnbs)
928 for x in range(3601, 3605):
929 nim.advanced.sat[x] = ConfigSubsection()
930 nim.advanced.sat[x].voltage = ConfigSelection(choices={"polarization": _("Polarization"), "13V": _("13 V"), "18V": _("18 V")}, default = "polarization")
931 nim.advanced.sat[x].tonemode = ConfigSelection(choices={"band": _("Band"), "on": _("On"), "off": _("Off")}, default = "band")
932 nim.advanced.sat[x].usals = ConfigYesNo(default=True)
933 nim.advanced.sat[x].rotorposition = ConfigInteger(default=1, limits=(1, 255))
935 nim.advanced.sat[x].lnb = ConfigSelection(choices = [("0", "not available"), (str(lnbnum), "LNB %d"%(lnbnum))], default="0")
937 csw = [("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))]
938 for y in range(0, 16):
939 csw.append((str(0xF0|y), "Input " + str(y+1)))
941 ucsw = [("0", _("None"))]
942 for y in range(1, 17):
943 ucsw.append((str(y), "Input " + str(y)))
945 nim.advanced.lnb = ConfigSubList()
946 nim.advanced.lnb.append(ConfigNothing())
947 for x in range(1, 37):
948 nim.advanced.lnb.append(ConfigSubsection())
949 nim.advanced.lnb[x].lof = ConfigSelection(choices={"universal_lnb": _("Universal LNB"), "c_band": _("C-Band"), "user_defined": _("User defined")}, default="universal_lnb")
950 nim.advanced.lnb[x].lofl = ConfigInteger(default=9750, limits = (0, 99999))
951 nim.advanced.lnb[x].lofh = ConfigInteger(default=10600, limits = (0, 99999))
952 nim.advanced.lnb[x].threshold = ConfigInteger(default=11700, limits = (0, 99999))
953 # nim.advanced.lnb[x].output_12v = ConfigSelection(choices = [("0V", _("0 V")), ("12V", _("12 V"))], default="0V")
954 nim.advanced.lnb[x].increased_voltage = ConfigYesNo(default=False)
955 nim.advanced.lnb[x].toneburst = ConfigSelection(choices = [("none", _("None")), ("A", _("A")), ("B", _("B"))], default = "none")
957 nim.advanced.lnb[x].diseqcMode = ConfigSelection(choices = [("1_2", _("1.2"))], default = "1_2")
959 nim.advanced.lnb[x].diseqcMode = ConfigSelection(choices = [("none", _("None")), ("1_0", _("1.0")), ("1_1", _("1.1")), ("1_2", _("1.2"))], default = "none")
960 nim.advanced.lnb[x].commitedDiseqcCommand = ConfigSelection(choices = csw)
961 nim.advanced.lnb[x].fastDiseqc = ConfigYesNo(default=False)
962 nim.advanced.lnb[x].sequenceRepeat = ConfigYesNo(default=False)
963 nim.advanced.lnb[x].commandOrder1_0 = ConfigSelection(choices = [("ct", "committed, toneburst"), ("tc", "toneburst, committed")], default = "ct")
964 nim.advanced.lnb[x].commandOrder = ConfigSelection(choices = [
965 ("ct", "committed, toneburst"),
966 ("tc", "toneburst, committed"),
967 ("cut", "committed, uncommitted, toneburst"),
968 ("tcu", "toneburst, committed, uncommitted"),
969 ("uct", "uncommitted, committed, toneburst"),
970 ("tuc", "toneburst, uncommitted, commmitted")],
972 nim.advanced.lnb[x].uncommittedDiseqcCommand = ConfigSelection(choices = ucsw)
973 nim.advanced.lnb[x].diseqcRepeats = ConfigSelection(choices = [("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))], default = "none")
974 nim.advanced.lnb[x].longitude = ConfigFloat(default = [5,100], limits = [(0,359),(0,999)])
975 nim.advanced.lnb[x].longitudeOrientation = ConfigSelection(choices = [("east", _("East")), ("west", _("West"))], default = "east")
976 nim.advanced.lnb[x].latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)])
977 nim.advanced.lnb[x].latitudeOrientation = ConfigSelection(choices = [("north", _("North")), ("south", _("South"))], default = "north")
978 nim.advanced.lnb[x].powerMeasurement = ConfigYesNo(default=True)
979 nim.advanced.lnb[x].powerThreshold = ConfigInteger(default=hw.get_device_name() == "dm8000" and 15 or 50, limits=(0, 100))
980 nim.advanced.lnb[x].turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch"))], default = "fast")
981 btime = datetime(1970, 1, 1, 7, 0);
982 nim.advanced.lnb[x].fastTurningBegin = ConfigDateTime(default=mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 600)
983 etime = datetime(1970, 1, 1, 19, 0);
984 nim.advanced.lnb[x].fastTurningEnd = ConfigDateTime(default=mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 600)
985 elif slot.isCompatible("DVB-C"):
986 nim.configMode = ConfigSelection(
988 "enabled": _("enabled"),
989 "nothing": _("nothing connected"),
994 for x in nimmgr.cablesList:
995 list.append((str(n), x[0]))
997 nim.cable = ConfigSubsection()
998 possible_scan_types = [("bands", _("Frequency bands")), ("steps", _("Frequency steps"))]
1000 possible_scan_types.append(("provider", _("Provider")))
1001 nim.cable.scan_provider = ConfigSelection(default = "0", choices = list)
1002 nim.cable.scan_type = ConfigSelection(default = "bands", choices = possible_scan_types)
1003 nim.cable.scan_band_EU_VHF_I = ConfigYesNo(default = True)
1004 nim.cable.scan_band_EU_MID = ConfigYesNo(default = True)
1005 nim.cable.scan_band_EU_VHF_III = ConfigYesNo(default = True)
1006 nim.cable.scan_band_EU_UHF_IV = ConfigYesNo(default = True)
1007 nim.cable.scan_band_EU_UHF_V = ConfigYesNo(default = True)
1008 nim.cable.scan_band_EU_SUPER = ConfigYesNo(default = True)
1009 nim.cable.scan_band_EU_HYPER = ConfigYesNo(default = True)
1010 nim.cable.scan_band_US_LOW = ConfigYesNo(default = False)
1011 nim.cable.scan_band_US_MID = ConfigYesNo(default = False)
1012 nim.cable.scan_band_US_HIGH = ConfigYesNo(default = False)
1013 nim.cable.scan_band_US_SUPER = ConfigYesNo(default = False)
1014 nim.cable.scan_band_US_HYPER = ConfigYesNo(default = False)
1015 nim.cable.scan_frequency_steps = ConfigInteger(default = 1000, limits = (1000, 10000))
1016 nim.cable.scan_mod_qam16 = ConfigYesNo(default = False)
1017 nim.cable.scan_mod_qam32 = ConfigYesNo(default = False)
1018 nim.cable.scan_mod_qam64 = ConfigYesNo(default = True)
1019 nim.cable.scan_mod_qam128 = ConfigYesNo(default = False)
1020 nim.cable.scan_mod_qam256 = ConfigYesNo(default = True)
1021 nim.cable.scan_sr_6900 = ConfigYesNo(default = True)
1022 nim.cable.scan_sr_6875 = ConfigYesNo(default = True)
1023 nim.cable.scan_sr_ext1 = ConfigInteger(default = 0, limits = (0, 7230))
1024 nim.cable.scan_sr_ext2 = ConfigInteger(default = 0, limits = (0, 7230))
1025 elif slot.isCompatible("DVB-T"):
1026 nim.configMode = ConfigSelection(
1028 "enabled": _("enabled"),
1029 "nothing": _("nothing connected"),
1031 default = "enabled")
1034 for x in nimmgr.terrestrialsList:
1035 list.append((str(n), x[0]))
1037 nim.terrestrial = ConfigSelection(choices = list)
1038 nim.terrestrial_5V = ConfigOnOff()
1040 nim.configMode = ConfigSelection(choices = { "nothing": _("disabled") }, default="nothing");
1041 if slot.type is not None:
1042 print "pls add support for this frontend type!", slot.type
1045 nimmgr.sec = SecConfigure(nimmgr)
1047 nimmanager = NimManager()