some changes to the configSelection stuff
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Fri, 30 Dec 2005 14:09:37 +0000 (14:09 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Fri, 30 Dec 2005 14:09:37 +0000 (14:09 +0000)
lib/python/Components/NimManager.py
lib/python/Components/config.py
lib/python/Screens/Satconfig.py

index 3e9b04277ee6752978169f144dbadfe1c6a79b87..bf4bdc93982531c88bd1c17e3a326848c473335c 100644 (file)
@@ -4,6 +4,8 @@ from config import configElement
 from config import ConfigSubsection
 from config import ConfigSlider
 from config import configSelection
+from config import currentConfigSelectionElement
+from config import getConfigSelectionElement
 from config import configSequence
 from config import configsequencearg
 from config import configSatlist
@@ -83,26 +85,28 @@ 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 == 2:
+                               if currentConfigSelectionElement(nim.configMode) == "loopthrough":
                                        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
+                               elif currentConfigSelectionElement(nim.configMode) == "simple":         #simple config
+                                       if currentConfigSelectionElement(nim.diseqcMode) == "single":                   #single
                                                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
+                                       elif currentConfigSelectionElement(nim.diseqcMode) == "toneburst_a_b":          #Toneburst A/B
                                                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
+                                       elif currentConfigSelectionElement(nim.diseqcMode) == "diseqc_a_b":             #DiSEqC A/B
                                                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
+                                       elif currentConfigSelectionElement(nim.diseqcMode) == "diseqc_a_b_c_d":         #DiSEqC A/B/C/D
                                                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
+                                       elif currentConfigSelectionElement(nim.diseqcMode) == "positioner":             #Positioner
                                                self.addLNBSimple(slotid = x, diseqcmode = 3, longitude = float(str(nim.longitude.value[0]) + "." + str(nim.longitude.value[1])), loDirection = nim.longitudeOrientation.value - 2, latitude = float(str(nim.latitude.value[0]) + "." + str(nim.latitude.value[1])), laDirection = nim.latitudeOrientation.value)
                                        pass
+                               elif currentConfigSelectionElement(nim.configMode) == "nothing":
+                                       pass
                                else:                                                                                                                                   #advanced config
                                        print "FIXME add support for advanced config"
                
@@ -408,19 +412,19 @@ def InitNimManager(nimmgr):
                nim = config.Nims[x]
                
                if slot.nimType == nimmgr.nimType["DVB-S"]:
-                       nim.configMode = configElement(cname + "configMode", configSelection, 0, (("simple", _("Simple")), ("nothing", _("Nothing connected")), ("loopthrough", _("Loopthrough to Socket A")))) # "Advanced"));
+                       nim.configMode = configElement(cname + "configMode", configSelection, 0, (("simple", _("Simple")), ("nothing", _("Nothing connected")), ("loopthrough", _("Loopthrough to Socket A")), ("advanced", _("Advanced")))) # "Advanced"));
                        
                        #important - check if just the 2nd one is LT only and the first one is DVB-S
-                       if nim.configMode.value == 2: #linked
+                       if currentConfigSelectionElement(nim.configMode) == "loopthrough": #linked
                                if x == 0:                                                                              #first one can never be linked to anything
-                                       nim.configMode.value = 0                #reset to simple
+                                       nim.configMode.value = getConfigSelectionElement(nim.configMode, "simple")              #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.value = getConfigSelectionElement(nim.configMode, "simple")              #reset to simple
                                                                nim.configMode.save()
 
                        nim.diseqcMode = configElement(cname + "diseqcMode", configSelection, 2, (("single", _("Single")), ("toneburst_a_b", _("Toneburst A/B")), ("diseqc_a_b", _("DiSEqC A/B")), ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")), ("positioner", _("Positioner"))));
index 2b51d169ce5cbcff972229b375b1449d4a8be37a..25684fc186dcda69b112869e5ffd145f6db476d2 100644 (file)
@@ -48,7 +48,18 @@ class configFile:
 
                        fileHandle.write(wstr)
 
-               fileHandle.close()              
+               fileHandle.close()
+               
+def currentConfigSelectionElement(element):
+       return element.vals[element.value][0]
+
+def getConfigSelectionElement(element, value):
+       count = 0
+       for x in element.vals:
+               if x[0] == value:
+                       return count
+               count += 1
+       return -1
 
 class configSelection:
        def __init__(self, parent):
@@ -82,9 +93,6 @@ class configSelection:
                        returnValue = _(self.parent.vals[self.parent.value])
                else:
                        returnValue = _(self.parent.vals[self.parent.value][1])
-
-                       
-               print self.parent.vals[self.parent.value]
                
                return ("text", returnValue)
                
index 6c5608b5c15cc4b35c9787d90201e7f626e12bc4..f7550444b2490b20b055979c3733476189113536 100644 (file)
@@ -22,22 +22,23 @@ class NimSetup(Screen):
        
        def createPositionerSetup(self, nim, list):
                list.append(getConfigListEntry(_("Positioner mode"), config.Nims[nim.slotid].positionerMode))
-               if (config.Nims[nim.slotid].positionerMode.value == 0): # USALS
+               if (currentConfigSelectionElement(config.Nims[nim.slotid].positionerMode) == "usals"): # USALS
                        list.append(getConfigListEntry(_("Longitude"), config.Nims[nim.slotid].longitude))
                        list.append(getConfigListEntry("", config.Nims[nim.slotid].longitudeOrientation))
                        list.append(getConfigListEntry(_("Latitude"), config.Nims[nim.slotid].latitude))
                        list.append(getConfigListEntry("", config.Nims[nim.slotid].latitudeOrientation))
-               elif (config.Nims[nim.slotid].positionerMode.value == 1): # manual
+               elif (currentConfigSelectionElement(config.Nims[nim.slotid].positionerMode) == "manual"): # manual
                        pass
        
        def createSetup(self):
                self.list = [ ]
+               self.diseqcModeEntry = None
                
                if (nimmanager.getNimType(self.nim.slotid) == nimmanager.nimType["DVB-S"]):
                        self.configMode = getConfigListEntry(_("Configuration Mode"), config.Nims[self.nim.slotid].configMode)
                        self.list.append(self.configMode)
                        
-                       if config.Nims[self.nim.slotid].configMode.value == 0:                  #simple setup
+                       if currentConfigSelectionElement(config.Nims[self.nim.slotid].configMode) == "simple":                  #simple setup
                                self.diseqcModeEntry = getConfigListEntry(_("DiSEqC Mode"), config.Nims[self.nim.slotid].diseqcMode)
                                self.list.append(self.diseqcModeEntry)
                        
@@ -45,10 +46,10 @@ class NimSetup(Screen):
                                        self.createSimpleSetup(self.nim, self.list, config.Nims[self.nim.slotid].diseqcMode.value)
                                if (config.Nims[self.nim.slotid].diseqcMode.value == 4):
                                        self.createPositionerSetup(self.nim, self.list)
-                       elif config.Nims[self.nim.slotid].configMode.value == 1: # nothing
+                       elif currentConfigSelectionElement(config.Nims[self.nim.slotid].configMode) == "nothing": # nothing
                                #self.list.append(getConfigListEntry(_("Linked to"), config.Nims[self.nim.slotid].linkedTo))
                                pass
-                       elif config.Nims[self.nim.slotid].configMode.value == 2: # linked
+                       elif currentConfigSelectionElement(config.Nims[self.nim.slotid].configMode) == "loopthrough": # linked
                                pass
                
                elif (nimmanager.getNimType(self.nim.slotid) == nimmanager.nimType["DVB-C"]):
@@ -61,10 +62,10 @@ class NimSetup(Screen):
                self["config"].l.setList(self.list)
                
        def newConfig(self):    
-               if self["config"].getCurrent() == self.diseqcModeEntry:
-                       self.createSetup()
                if self["config"].getCurrent() == self.configMode:
                        self.createSetup()
+               if self["config"].getCurrent() == self.diseqcModeEntry:
+                       self.createSetup()
                
        def keyLeft(self):
                if self["config"].getCurrent() == self.configMode: