prepare calls for linked tuners
[enigma2.git] / lib / python / Components / NimManager.py
index 437c51dac3bc196ce27805d0d8b7c5ba7521d18c..31c09446a53f4c48171366474aa9b6c443297d2b 100644 (file)
@@ -253,6 +253,13 @@ class NimManager:
                        if (chktype == self.nimType[str(type)]):
                                return True
                return False
+       
+       def getNimListOfType(self, type, exception = -1):
+               list = []
+               for x in self.nimslots:
+                       if ((x.nimType == type) and (x.slotid != exception)):
+                               list.append(x.slotid)
+               return list
 
        def getConfigPrefix(self, slotid):
                return "config.Nim" + ("A","B","C","D")[slotid] + "."
@@ -314,8 +321,16 @@ class NimManager:
 
        #callbacks for c++ config
        def nimConfigModeChanged(self, slotid, mode):
-               #print "nimConfigModeChanged set to " + str(mode)
-               pass
+               if (mode != 1): # not linked
+                       print "Unlinking slot " + str(slotid)
+                       # TODO call c++ to unlink nim in slot slotid
+               if (mode == 1): # linked
+                       if (len(self.getNimListOfType(self.nimType["DVB-S"], slotid)) > 0):
+                               print "Linking slot " + str(slotid) + " to " + str(nimmgr.getConfigPrefix(slotid).value)
+                       # TODO call c++ to link nim in slot slotid with nim in slot nimmgr.getConfigPrefix(slotid).value
+       def nimLinkedToChanged(self, slotid, val):
+               print "Linking slot " + str(slotid) + " to " + str(val)
+               # TODO call c++ to link nim in slot slotid with nim in slot val
        def nimDiseqcModeChanged(self, slotid, mode):
                #print "nimDiseqcModeChanged set to " + str(mode)
                pass
@@ -333,7 +348,6 @@ class NimManager:
                #print "nimDiseqcD set to " + str(val)
                pass
 
-
 def InitNimManager(nimmgr):
        config.Nims = []
        for x in range(nimmgr.nimCount):
@@ -341,6 +355,8 @@ def InitNimManager(nimmgr):
                
        def nimConfigModeChanged(slotid, configElement):
                nimmgr.nimConfigModeChanged(slotid, configElement.value)
+       def nimLinkedToChanged(slotid, configElement):
+               nimmgr.nimLinkedToChanged(slotid, configElement.value)
        def nimDiseqcModeChanged(slotid, configElement):
                nimmgr.nimDiseqcModeChanged(slotid, configElement.value)
                
@@ -359,7 +375,7 @@ def InitNimManager(nimmgr):
                nim = config.Nims[x]
                
                if slot.nimType == nimmgr.nimType["DVB-S"]:
-                       nim.configMode = configElement(cname + "configMode", configSelection, 0, (_("Simple"), _("Advanced")));
+                       nim.configMode = configElement(cname + "configMode", configSelection, 0, (_("Simple"), _("Linked tuner"))) # _("Advanced")));
                        nim.diseqcMode = configElement(cname + "diseqcMode", configSelection, 2, (_("Single"), _("Toneburst A/B"), _("DiSEqC A/B"), _("DiSEqC A/B/C/D"), _("Positioner")));
                        nim.diseqcA = configElement(cname + "diseqcA", configSatlist, 192, nimmgr.satList);
                        nim.diseqcB = configElement(cname + "diseqcB", configSatlist, 130, nimmgr.satList);
@@ -368,6 +384,12 @@ def InitNimManager(nimmgr):
                        nim.longitude = configElement(cname + "longitude", configSequence, [0,0], configsequencearg.get("FLOAT", [(0,90),(0,999)]));
                        nim.latitude = configElement(cname + "latitude", configSequence, [0,0], configsequencearg.get("FLOAT", [(0,90),(0,999)]));
                        
+                       satNimList = nimmgr.getNimListOfType(nimmgr.nimType["DVB-S"], slot.slotid)
+                       satNimListNames = []
+                       for x in satNimList:
+                               satNimListNames.append(_("Slot ") + ("A", "B", "C", "D")[x] + ": " + nimmgr.getNimName(x))
+                       nim.linkedTo = configElement(cname + "linkedTo", configSelection, 0, satNimListNames);
+                       
                        #perhaps the instance of the slot is more useful?
                        nim.configMode.addNotifier(boundFunction(nimConfigModeChanged,x))
                        nim.diseqcMode.addNotifier(boundFunction(nimDiseqcModeChanged,x))
@@ -375,6 +397,7 @@ def InitNimManager(nimmgr):
                        nim.diseqcB.addNotifier(boundFunction(nimPortBChanged,x))
                        nim.diseqcC.addNotifier(boundFunction(nimPortCChanged,x))
                        nim.diseqcD.addNotifier(boundFunction(nimPortDChanged,x))
+                       nim.linkedTo.addNotifier(boundFunction(nimLinkedToChanged,x))
                elif slot.nimType == nimmgr.nimType["DVB-C"]:
                        nim.cable = configElement(cname + "cable", configSelection, 0, nimmgr.cablesList);
                elif slot.nimType == nimmgr.nimType["DVB-T"]: