def linkNIMs(self, sec, nim1, nim2):
print "link tuner", nim1, "to tuner", nim2
- if nim2 == (nim1 - 1):
- self.linkInternally(nim1)
+# if nim2 == (nim1 - 1):
+# self.linkInternally(nim1)
+#
+# for internally connect tuner A to B
+ self.linkInternally(nim1)
sec.setTunerLinked(nim1, nim2)
def getRoot(self, slotid, connto):
for slot in nim_slots:
if slot.type is not None:
- used_nim_slots.append((slot.slot, slot.description, slot.config.configMode.value != "nothing" and True or False, slot.isCompatible("DVB-S2"), slot.frontend_id is None and -1 or slot.frontend_id))
+ used_nim_slots.append((slot.slot, slot.description, slot.config.configMode.value != "nothing" and True or False, slot.isCompatible("DVB-S2"), slot.isCompatible("DVB-T2"), slot.frontend_id is None and -1 or slot.frontend_id))
eDVBResourceManager.getInstance().setFrontendSlotInformations(used_nim_slots)
for slot in nim_slots:
def __init__(self, slot, type, description, has_outputs = True, internally_connectable = None, multi_type = {}, frontend_id = None, i2c = None, is_empty = False):
self.slot = slot
- if type not in ("DVB-S", "DVB-C", "DVB-T", "DVB-S2", None):
+ if type not in ("DVB-S", "DVB-C", "DVB-T", "DVB-S2", "DVB-T2", None):
print "warning: unknown NIM type %s, not using." % type
type = None
self.i2c = i2c
self.frontend_id = frontend_id
self.__is_empty = is_empty
-
- def isCompatible(self, what):
- if not self.isSupported():
- return False
- compatible = {
+ self.compatible = {
None: (None,),
"DVB-S": ("DVB-S", None),
"DVB-C": ("DVB-C", None),
"DVB-T": ("DVB-T", None),
- "DVB-S2": ("DVB-S", "DVB-S2", None)
+ "DVB-S2": ("DVB-S", "DVB-S2", None),
+ "DVB-T2": ("DVB-T", "DVB-T2", None)
}
- return what in compatible[self.type]
-
+
def getType(self):
+ try:
+ if self.isMultiType():
+ return self.multi_type[self.config.multiType.value]
+ except:
+ pass
return self.type
+
+ def isCompatible(self, what):
+ if not self.isSupported():
+ return False
+ return what in self.compatible[self.getType()]
+
+ def canBeCompatible(self, what):
+ if self.isCompatible(what):
+ return True
+ for type in self.getMultiTypeList().values():
+ if what in self.compatible[type]:
+ return True
+ return False
def connectableTo(self):
connectable = {
"DVB-S": ("DVB-S", "DVB-S2"),
"DVB-C": ("DVB-C",),
"DVB-T": ("DVB-T",),
- "DVB-S2": ("DVB-S", "DVB-S2")
+ "DVB-S2": ("DVB-S", "DVB-S2"),
+ "DVB-T2": ("DVB-T", "DVB-T2",)
}
- return connectable[self.type]
+ return connectable[self.getType()]
def getSlotName(self):
# get a friendly description for a slot name.
return {
"DVB-S": "DVB-S",
"DVB-T": "DVB-T",
- "DVB-S2": "DVB-S2",
"DVB-C": "DVB-C",
+ "DVB-S2": "DVB-S2",
+ "DVB-T2": "DVB-T2",
None: _("empty")
- }[self.type]
+ }[self.getType()]
friendly_type = property(getFriendlyType)
friendly_full_description = property(getFriendlyFullDescription)
config_mode = property(lambda self: config.Nims[self.slot].configMode.value)
config = property(lambda self: config.Nims[self.slot])
- empty = property(lambda self: self.type is None)
+ empty = property(lambda self: self.getType() is None)
class NimManager:
def getConfiguredSats(self):
entry["frontend_device"] = entry["internally_connectable"] = None
if not (entry.has_key("multi_type")):
entry["multi_type"] = {}
+
+ # get MultiType from DTV_ENUM_DELSYS
+ if entry["frontend_device"] is not None:
+ types = [type for type in ["DVB-C", "DVB-T2", "DVB-T", "DVB-S2", "DVB-S", "ATSC"] if eDVBResourceManager.getInstance().frontendIsCompatible(entry["frontend_device"], type)]
+ if "DVB-T2" in types and "DVB-T" in types:
+ # DVB-T2 implies DVB-T support
+ types.remove("DVB-T")
+ if "DVB-S2" in types and "DVB-S" in types:
+ # DVB-S2 implies DVB-S support
+ types.remove("DVB-S")
+ if len(types) > 1:
+ entry["multi_type"] = {}
+ for type in types:
+ entry["multi_type"][str(types.index(type))] = type
+
self.nim_slots.append(NIM(slot = id, description = entry["name"], type = entry["type"], has_outputs = entry["has_outputs"], internally_connectable = entry["internally_connectable"], multi_type = entry["multi_type"], frontend_id = entry["frontend_device"], i2c = entry["i2c"], is_empty = entry["isempty"]))
def hasNimType(self, chktype):
for slot in self.nim_slots:
- if slot.isCompatible(chktype):
+ if slot.canBeCompatible(chktype):
return True
- for type in slot.getMultiTypeList().values():
- if chktype == type:
- return True
return False
def getNimType(self, slotid):
- return self.nim_slots[slotid].type
+ return self.nim_slots[slotid].getType()
def getNimDescription(self, slotid):
return self.nim_slots[slotid].friendly_full_description
type = self.getNimType(slotid)
if type == "DVB-S2":
type = "DVB-S"
+ elif type == "DVB-T2":
+ type = "DVB-T"
nimList = self.getNimListOfType(type, slotid)
for nim in nimList[:]:
mode = self.getNimConfig(nim)
type = self.getNimType(slotid)
if type == "DVB-S2":
type = "DVB-S"
+ elif type == "DVB-T2":
+ type = "DVB-T"
nimList = self.getNimListOfType(type, slotid)
positionerList = []
for nim in nimList[:]:
if nimmgr.nim_slots[slot_id].description == 'Alps BSBE2':
open("/proc/stb/frontend/%d/tone_amplitude" %(fe_id), "w").write(configElement.value)
- def tunerTypeChanged(nimmgr, configElement):
- fe_id = configElement.fe_id
-
- cur_type = int(open("/proc/stb/frontend/%d/mode" % (fe_id), "r").read())
- if cur_type != int(configElement.value):
- print "tunerTypeChanged feid %d from %d to mode %d" % (fe_id, cur_type, int(configElement.value))
-
- try:
- oldvalue = open("/sys/module/dvb_core/parameters/dvb_shutdown_timeout", "r").readline()
- open("/sys/module/dvb_core/parameters/dvb_shutdown_timeout", "w").write("0")
- except:
- print "[info] no /sys/module/dvb_core/parameters/dvb_shutdown_timeout available"
-
- frontend = eDVBResourceManager.getInstance().allocateRawChannel(fe_id).getFrontend()
- frontend.closeFrontend()
- open("/proc/stb/frontend/%d/mode" % (fe_id), "w").write(configElement.value)
- frontend.reopenFrontend()
- try:
- open("/sys/module/dvb_core/parameters/dvb_shutdown_timeout", "w").write(oldvalue)
- except:
- print "[info] no /sys/module/dvb_core/parameters/dvb_shutdown_timeout available"
- nimmgr.enumerateNIMs()
- else:
- print "tuner type is already already %d" %cur_type
-
- empty_slots = 0
- for slot in nimmgr.nim_slots:
- x = slot.slot
- nim = config.Nims[x]
- addMultiType = False
+ def createSatConfig(nim, x, empty_slots):
+ print "[Nimmanager] slot %d create config satellite.." % slot.slot
try:
- nim.multiType
+ nim.toneAmplitude
except:
- addMultiType = True
- if slot.isMultiType() and addMultiType:
- typeList = []
- for id in slot.getMultiTypeList().keys():
- type = slot.getMultiTypeList()[id]
- typeList.append((id, type))
- nim.multiType = ConfigSelection(typeList, "0")
-
- nim.multiType.fe_id = x - empty_slots
- nim.multiType.addNotifier(boundFunction(tunerTypeChanged, nimmgr))
-
- empty_slots = 0
- for slot in nimmgr.nim_slots:
- x = slot.slot
- nim = config.Nims[x]
-
- if slot.isCompatible("DVB-S"):
nim.toneAmplitude = ConfigSelection([("11", "340mV"), ("10", "360mV"), ("9", "600mV"), ("8", "700mV"), ("7", "800mV"), ("6", "900mV"), ("5", "1100mV")], "7")
nim.toneAmplitude.fe_id = x - empty_slots
nim.toneAmplitude.slot_id = x
nim.fastTurningBegin = ConfigDateTime(default = mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 900)
etime = datetime(1970, 1, 1, 19, 0);
nim.fastTurningEnd = ConfigDateTime(default = mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 900)
- config_mode_choices = [ ("nothing", _("nothing connected")),
- ("simple", _("simple")), ("advanced", _("advanced"))]
- if len(nimmgr.getNimListOfType(slot.type, exception = x)) > 0:
- config_mode_choices.append(("equal", _("equal to")))
- config_mode_choices.append(("satposdepends", _("second cable of motorized LNB")))
- if len(nimmgr.canConnectTo(x)) > 0:
- config_mode_choices.append(("loopthrough", _("loopthrough to")))
- nim.advanced = ConfigNothing()
- tmp = ConfigSelection(config_mode_choices, "nothing")
- tmp.slot_id = x
- tmp.addNotifier(configModeChanged, initial_call = False)
- nim.configMode = tmp
- elif slot.isCompatible("DVB-C"):
- nim.configMode = ConfigSelection(
- choices = {
- "enabled": _("enabled"),
- "nothing": _("nothing connected"),
- },
- default = "enabled")
+
+ def createCableConfig(nim, x):
+ print "[Nimmanager] slot %d create config cable.." % slot.slot
+ try:
+ nim.cable
+ except:
list = [ ]
n = 0
for x in nimmgr.cablesList:
nim.cable.scan_sr_6875 = ConfigYesNo(default = True)
nim.cable.scan_sr_ext1 = ConfigInteger(default = 0, limits = (0, 7230))
nim.cable.scan_sr_ext2 = ConfigInteger(default = 0, limits = (0, 7230))
- elif slot.isCompatible("DVB-T"):
- nim.configMode = ConfigSelection(
- choices = {
- "enabled": _("enabled"),
- "nothing": _("nothing connected"),
- },
- default = "enabled")
+
+ def createTerrestrialConfig(nim, x):
+ print "[Nimmanager] slot %d create config terrestrial.." % slot.slot
+ try:
+ nim.terrestrial
+ except:
list = []
n = 0
for x in nimmgr.terrestrialsList:
n += 1
nim.terrestrial = ConfigSelection(choices = list)
nim.terrestrial_5V = ConfigOnOff()
+
+ def tunerTypeChanged(nimmgr, configElement):
+ fe_id = configElement.fe_id
+ eDVBResourceManager.getInstance().setFrontendType(nimmgr.nim_slots[fe_id].frontend_id, nimmgr.nim_slots[fe_id].getType())
+ import os
+ if os.path.exists("/proc/stb/frontend/%d/mode" % fe_id):
+ cur_type = int(open("/proc/stb/frontend/%d/mode" % (fe_id), "r").read())
+ if cur_type == int(configElement.value):
+ print "tuner type is already already %d" %cur_type
+ return
+ print "tunerTypeChanged feid %d from %d to mode %d" % (fe_id, cur_type, int(configElement.value))
+
+ print "tunerTypeChanged feid %d, mode %d" % (fe_id, int(configElement.value))
+
+ try:
+ oldvalue = open("/sys/module/dvb_core/parameters/dvb_shutdown_timeout", "r").readline()
+ open("/sys/module/dvb_core/parameters/dvb_shutdown_timeout", "w").write("0")
+ except:
+ print "[info] no /sys/module/dvb_core/parameters/dvb_shutdown_timeout available"
+
+ frontend = eDVBResourceManager.getInstance().allocateRawChannel(fe_id).getFrontend()
+ frontend.closeFrontend()
+
+ if os.path.exists("/proc/stb/frontend/%d/mode" % fe_id):
+ open("/proc/stb/frontend/%d/mode" % (fe_id), "w").write(configElement.value)
+
+ frontend.reopenFrontend()
+ try:
+ open("/sys/module/dvb_core/parameters/dvb_shutdown_timeout", "w").write(oldvalue)
+ except:
+ print "[info] no /sys/module/dvb_core/parameters/dvb_shutdown_timeout available"
+ nimmgr.enumerateNIMs()
+
+ empty_slots = 0
+ for slot in nimmgr.nim_slots:
+ print "[InitNimManager] check multi type slot %d" % slot.slot
+ x = slot.slot
+ nim = config.Nims[x]
+ addMultiType = False
+ try:
+ nim.multiType
+ except:
+ addMultiType = True
+ if slot.isMultiType() and addMultiType:
+ print "[InitNimManager] slot %d is multi type : " % slot.slot, slot.getMultiTypeList()
+ typeList = []
+ for id in slot.getMultiTypeList().keys():
+ type = slot.getMultiTypeList()[id]
+ typeList.append((id, type))
+ nim.multiType = ConfigSelection(typeList, "0")
+ nim.multiType.fe_id = x - empty_slots
+ nim.multiType.addNotifier(boundFunction(tunerTypeChanged, nimmgr))
+
+ empty_slots = 0
+ for slot in nimmgr.nim_slots:
+ x = slot.slot
+ nim = config.Nims[x]
+
+ if slot.isCompatible("DVB-S"):
+ createSatConfig(nim, x, empty_slots)
+ config_mode_choices = [ ("nothing", _("nothing connected")),
+ ("simple", _("simple")), ("advanced", _("advanced"))]
+ if len(nimmgr.getNimListOfType(slot.getType(), exception = x)) > 0:
+ config_mode_choices.append(("equal", _("equal to")))
+ config_mode_choices.append(("satposdepends", _("second cable of motorized LNB")))
+ if len(nimmgr.canConnectTo(x)) > 0:
+ config_mode_choices.append(("loopthrough", _("loopthrough to")))
+ nim.advanced = ConfigNothing()
+ tmp = ConfigSelection(config_mode_choices, "nothing")
+ tmp.slot_id = x
+ tmp.addNotifier(configModeChanged, initial_call = False)
+ nim.configMode = tmp
+ elif slot.isCompatible("DVB-C"):
+ nim.configMode = ConfigSelection(
+ choices = {
+ "enabled": _("enabled"),
+ "nothing": _("nothing connected"),
+ },
+ default = "enabled")
+ createCableConfig(nim, x)
+ elif slot.isCompatible("DVB-T"):
+ nim.configMode = ConfigSelection(
+ choices = {
+ "enabled": _("enabled"),
+ "nothing": _("nothing connected"),
+ },
+ default = "enabled")
+ createTerrestrialConfig(nim, x)
else:
+ print "[Nimmanager] slot %d create config nothing.." % slot.slot
empty_slots += 1
nim.configMode = ConfigSelection(choices = { "nothing": _("disabled") }, default="nothing");
- if slot.type is not None:
- print "pls add support for this frontend type!", slot.type
+ if slot.getType() is not None:
+ print "pls add support for this frontend type!", slot.getType()
# assert False
nimmgr.sec = SecConfigure(nimmgr)