change parameters of diseqc-config to prepare the addition of positioners
[enigma2.git] / lib / python / Components / NimManager.py
index 5a18a454fa8715cec5448e2878e805b76e8bb959..22f49db72ff9857b730362e78d9fa7b8e091e5ec 100644 (file)
@@ -28,7 +28,7 @@ def tryOpen(filename):
        return procFile
 
 class SecConfigure:
-       def addLNBSimple(self, slotid, orbpos, toneburstmode, diseqcmode, diseqcpos):
+       def addLNBSimple(self, slotid, diseqcmode, toneburstmode = 0, diseqcpos = 0, orbpos = 0, longitude = 0, latitude = 0, loDirection = 0, laDirection = 0, satList = None):
                #simple defaults
                sec = eDVBSatelliteEquipmentControl.getInstance()
                sec.addLNB()
@@ -50,11 +50,15 @@ class SecConfigure:
                sec.addSatellite(orbpos)
                self.satList.append(orbpos)
 
+       def linkNIMs(self, nim1, nim2):
+               eDVBSatelliteEquipmentControl.getInstance().setTunerLinked(nim1, nim2)
+               
        def getSatList(self):
                return self.satList
 
        def update(self):
                eDVBSatelliteEquipmentControl.getInstance().clear()
+               
                self.satList = []
 
                for slot in self.NimManager.nimslots:
@@ -62,20 +66,23 @@ class SecConfigure:
                        nim = config.Nims[x]
                        if slot.nimType == self.NimManager.nimType["DVB-S"]:
                                print "slot: " + str(x) + " configmode: " + str(nim.configMode.value)
+                               if nim.configMode.value == 1:
+                                       self.linkNIMs(x, nim.linkedTo.value)
+                                       nim = config.Nims[nim.linkedTo.value]
                                if nim.configMode.value == 0:           #simple config
                                        if nim.diseqcMode.value == 0:                   #single
-                                               self.addLNBSimple(x, int(nim.diseqcA.vals[nim.diseqcA.value][1]), 0, 0, 4)
+                                               self.addLNBSimple(slotid = x, orbpos = int(nim.diseqcA.vals[nim.diseqcA.value][1]), toneburstmode = 0, diseqcmode = 0, diseqcpos = 4)
                                        elif nim.diseqcMode.value == 1:         #Toneburst A/B
-                                               self.addLNBSimple(x, int(nim.diseqcA.vals[nim.diseqcA.value][1]), 1, 0, 4)
-                                               self.addLNBSimple(x, int(nim.diseqcB.vals[nim.diseqcB.value][1]), 1, 0, 4)
+                                               self.addLNBSimple(slotid = x, orbpos = int(nim.diseqcA.vals[nim.diseqcA.value][1]), toneburstmode = 1, diseqcmode = 0, diseqcpos = 4)
+                                               self.addLNBSimple(slotid = x, orbpos = int(nim.diseqcB.vals[nim.diseqcB.value][1]), toneburstmode = 1, diseqcmode = 0, diseqcpos = 4)
                                        elif nim.diseqcMode.value == 2:         #DiSEqC A/B
-                                               self.addLNBSimple(x, int(nim.diseqcA.vals[nim.diseqcA.value][1]), 0, 1, 0)
-                                               self.addLNBSimple(x, int(nim.diseqcB.vals[nim.diseqcB.value][1]), 0, 1, 1)
+                                               self.addLNBSimple(slotid = x, orbpos = int(nim.diseqcA.vals[nim.diseqcA.value][1]), toneburstmode = 0, diseqcmode = 1, diseqcpos = 0)
+                                               self.addLNBSimple(slotid = x, orbpos = int(nim.diseqcB.vals[nim.diseqcB.value][1]), toneburstmode = 0, diseqcmode = 1, diseqcpos = 1)
                                        elif nim.diseqcMode.value == 3:         #DiSEqC A/B/C/D
-                                               self.addLNBSimple(x, int(nim.diseqcA.vals[nim.diseqcA.value][1]), 0, 1, 0)
-                                               self.addLNBSimple(x, int(nim.diseqcB.vals[nim.diseqcB.value][1]), 0, 1, 1)
-                                               self.addLNBSimple(x, int(nim.diseqcC.vals[nim.diseqcC.value][1]), 0, 1, 2)
-                                               self.addLNBSimple(x, int(nim.diseqcD.vals[nim.diseqcD.value][1]), 0, 1, 3)
+                                               self.addLNBSimple(slotid = x, orbpos = int(nim.diseqcA.vals[nim.diseqcA.value][1]), toneburstmode = 0, diseqcmode = 1, diseqcpos = 0)
+                                               self.addLNBSimple(slotid = x, orbpos = int(nim.diseqcB.vals[nim.diseqcB.value][1]), toneburstmode = 0, diseqcmode = 1, diseqcpos = 1)
+                                               self.addLNBSimple(slotid = x, orbpos = int(nim.diseqcC.vals[nim.diseqcC.value][1]), toneburstmode = 0, diseqcmode = 1, diseqcpos = 2)
+                                               self.addLNBSimple(slotid = x, orbpos = int(nim.diseqcD.vals[nim.diseqcD.value][1]), toneburstmode = 0, diseqcmode = 1, diseqcpos = 3)
                                        elif nim.diseqcMode.value == 4:         #Positioner
                                                print "FIXME: positioner suppport"
                                        pass
@@ -237,11 +244,13 @@ class NimManager:
                                self.nimTypes[lastsocket] = "empty/unknown"
 
                nimfile.close()
-               
 
        def getNimType(self, slotID):
-               return self.nimType[self.nimTypes[slotID]]
-
+               if slotID >= self.nimCount:
+                       return "empty/unknown"
+               else:   
+                       return self.nimType[self.nimTypes[slotID]]
+                       
        def getNimName(self, slotID):
                return self.nimNames[slotID]
 
@@ -325,12 +334,14 @@ class NimManager:
                        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)
+                       pass
+                       #FIXME!!!
+                       #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
@@ -375,8 +386,22 @@ def InitNimManager(nimmgr):
                nim = config.Nims[x]
                
                if slot.nimType == nimmgr.nimType["DVB-S"]:
-                       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.configMode = configElement(cname + "configMode", configSelection, 0, (_("Simple"), _("Loopthrough to Socket A"))) # "Advanced"));
+                       
+                       #important - check if just the 2nd one is LT only and the first one is DVB-S
+                       if nim.configMode.value == 1: #linked
+                               if x == 0:                                                                              #first one can never be linked to anything
+                                       nim.configMode.value = 0                #reset to simple
+                                       nim.configMode.save()
+                               else:
+                                       #FIXME: make it better
+                                       for y in nimmgr.nimslots:
+                                               if y.slotid == 0:
+                                                       if y.nimType != nimmgr.nimType["DVB-S"]:
+                                                               nim.configMode.value = 0                #reset to simple
+                                                               nim.configMode.save()
+
+                       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);
                        nim.diseqcC = configElement(cname + "diseqcC", configSatlist, 0, nimmgr.satList);