prepare better configSequence
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Wed, 12 Oct 2005 22:22:50 +0000 (22:22 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Wed, 12 Oct 2005 22:22:50 +0000 (22:22 +0000)
lib/python/Components/Network.py
lib/python/Components/NimManager.py
lib/python/Components/ScanSetup.py
lib/python/Components/config.py

index cd82081b774b8c741f01c84f5e8a0dea16327791..60c98ea37fcf81045505c8a01bbf8b1b8c98806d 100644 (file)
@@ -132,11 +132,11 @@ def InitNetwork():
                
        config.network = ConfigSubsection()
        config.network.dhcp = configElement_nonSave("config.network.dhcp", configSelection, 1, ("no", "yes"))
                
        config.network = ConfigSubsection()
        config.network.dhcp = configElement_nonSave("config.network.dhcp", configSelection, 1, ("no", "yes"))
-       config.network.ip = configElement_nonSave("config.network.ip", configSequence, ip, (("."), (1,255)))
-       config.network.netmask = configElement_nonSave("config.network.netmask", configSequence, [255,255,255,0], (("."), (1,255)))
-       config.network.gateway = configElement_nonSave("config.network.gateway", configSequence, [192,168,1,3], (("."), (1,255)))
-       config.network.dns = configElement_nonSave("config.network.dns", configSequence, [192,168,1,3], (("."), (1,255)))
-       config.network.mac = configElement_nonSave("config.network.mac", configSequence, [00,11,22,33,44,55], ((":"), (1,255)))
+       config.network.ip = configElement_nonSave("config.network.ip", configSequence, ip, configsequencearg.get("IP"))
+       config.network.netmask = configElement_nonSave("config.network.netmask", configSequence, [255,255,255,0], configsequencearg.get("IP"))
+       config.network.gateway = configElement_nonSave("config.network.gateway", configSequence, [192,168,1,3], configsequencearg.get("IP"))
+       config.network.dns = configElement_nonSave("config.network.dns", configSequence, [192,168,1,3], configsequencearg.get("IP"))
+       config.network.mac = configElement_nonSave("config.network.mac", configSequence, [00,11,22,33,44,55], configsequencearg.get("MAC"))
 
        iNetwork.loadNetworkConfig()
        
 
        iNetwork.loadNetworkConfig()
        
index bbce2d503f4e80e786797bf9d621afccfab3cee0..01ef4bf4fb337e5c84880880fce87d6e97b7d785 100644 (file)
@@ -5,8 +5,10 @@ from config import ConfigSubsection
 from config import ConfigSlider
 from config import configSelection
 from config import configSequence
 from config import ConfigSlider
 from config import configSelection
 from config import configSequence
+from config import configsequencearg
 from config import configSatlist
 
 from config import configSatlist
 
+
 import xml.dom.minidom
 from xml.dom import EMPTY_NAMESPACE
 from skin import elementsWithTag
 import xml.dom.minidom
 from xml.dom import EMPTY_NAMESPACE
 from skin import elementsWithTag
@@ -161,8 +163,8 @@ def InitNimManager(nimmgr):
                        config.Nims[x].diseqcB = configElement(cname + "diseqcB",configSatlist, 130, nimmgr.satList);
                        config.Nims[x].diseqcC = configElement(cname + "diseqcC",configSatlist, 0, nimmgr.satList);
                        config.Nims[x].diseqcD = configElement(cname + "diseqcD",configSatlist, 0, nimmgr.satList);
                        config.Nims[x].diseqcB = configElement(cname + "diseqcB",configSatlist, 130, nimmgr.satList);
                        config.Nims[x].diseqcC = configElement(cname + "diseqcC",configSatlist, 0, nimmgr.satList);
                        config.Nims[x].diseqcD = configElement(cname + "diseqcD",configSatlist, 0, nimmgr.satList);
-                       config.Nims[x].longitude = configElement(cname + "longitude",configSequence, [0,0], (("."), (1,999)));
-                       config.Nims[x].latitude = configElement(cname + "latitude",configSequence, [0,0], (("."), (1,999)));
+                       config.Nims[x].longitude = configElement(cname + "longitude",configSequence, [0,0], configsequencearg.get("FLOAT", [(1,90),(1,999)]));
+                       config.Nims[x].latitude = configElement(cname + "latitude",configSequence, [0,0], configsequencearg.get("FLOAT", [(1,90),(1,999)]));
                        
                        #perhaps the instance of the slot is more useful?
                        config.Nims[x].configMode.addNotifier(boundFunction(nimConfigModeChanged,x))
                        
                        #perhaps the instance of the slot is more useful?
                        config.Nims[x].configMode.addNotifier(boundFunction(nimConfigModeChanged,x))
index 6cdefe43957af9746d44359e6244d3a8c9bd4e08..95e476718a43ccfc4b2a014d269630f6ec5f34d9 100644 (file)
@@ -1,8 +1,4 @@
-from config import config
-from config import ConfigSubsection
-from config import configElement_nonSave
-from config import configSelection
-from config import configSequence
+from config import *
 from Components.NimManager import nimmanager
 
 def InitScanSetup():
 from Components.NimManager import nimmanager
 
 def InitScanSetup():
@@ -18,21 +14,21 @@ def InitScanSetup():
     config.scan.nims = configElement_nonSave("config.scan.nims", configSelection, 0, nimList)
     
     # sat
     config.scan.nims = configElement_nonSave("config.scan.nims", configSelection, 0, nimList)
     
     # sat
-    config.scan.sat.frequency = configElement_nonSave("config.scan.sat.frequency", configSequence, [12187], (("."), (10000,14000)))
+    config.scan.sat.frequency = configElement_nonSave("config.scan.sat.frequency", configSequence, [12187], configsequencearg.get("INTEGER", (10000, 14000)))
     config.scan.sat.inversion = configElement_nonSave("config.scan.sat.inversion", configSelection, 0, ("off", "on"))
     config.scan.sat.inversion = configElement_nonSave("config.scan.sat.inversion", configSelection, 0, ("off", "on"))
-    config.scan.sat.symbolrate = configElement_nonSave("config.scan.sat.symbolrate", configSequence, [27500], (("."), (1,30000)))
+    config.scan.sat.symbolrate = configElement_nonSave("config.scan.sat.symbolrate", configSequence, [27500], configsequencearg.get("INTEGER", (1, 30000)))
     config.scan.sat.polarzation = configElement_nonSave("config.scan.sat.polarzation", configSelection, 0, ("horizontal", "vertical"))
     config.scan.sat.fec = configElement_nonSave("config.scan.sat.fec", configSelection, 0, ("Auto", "1/2", "2/3", "3/4", "4/5", "5/6", "7/8", "8/9"))
 
     # cable
     config.scan.sat.polarzation = configElement_nonSave("config.scan.sat.polarzation", configSelection, 0, ("horizontal", "vertical"))
     config.scan.sat.fec = configElement_nonSave("config.scan.sat.fec", configSelection, 0, ("Auto", "1/2", "2/3", "3/4", "4/5", "5/6", "7/8", "8/9"))
 
     # cable
-    config.scan.cab.frequency = configElement_nonSave("config.scan.cab.frequency", configSequence, [466], (("."), (10000,14000)))
+    config.scan.cab.frequency = configElement_nonSave("config.scan.cab.frequency", configSequence, [466], configsequencearg.get("INTEGER", (10000, 14000)))
     config.scan.cab.inversion = configElement_nonSave("config.scan.cab.inversion", configSelection, 0, ("off", "on"))
     config.scan.cab.modulation = configElement_nonSave("config.scan.cab.modulation", configSelection, 0, ("Auto", "16-QAM", "32-QAM", "64-QAM", "128-QAM", "256-QAM"))
     config.scan.cab.fec = configElement_nonSave("config.scan.cab.fec", configSelection, 0, ("Auto", "1/2", "2/3", "3/4", "4/5", "5/6", "7/8", "8/9"))
     config.scan.cab.inversion = configElement_nonSave("config.scan.cab.inversion", configSelection, 0, ("off", "on"))
     config.scan.cab.modulation = configElement_nonSave("config.scan.cab.modulation", configSelection, 0, ("Auto", "16-QAM", "32-QAM", "64-QAM", "128-QAM", "256-QAM"))
     config.scan.cab.fec = configElement_nonSave("config.scan.cab.fec", configSelection, 0, ("Auto", "1/2", "2/3", "3/4", "4/5", "5/6", "7/8", "8/9"))
-    config.scan.cab.symbolrate = configElement_nonSave("config.scan.cab.symbolrate", configSequence, [6900], (("."), (1,30000)))
+    config.scan.cab.symbolrate = configElement_nonSave("config.scan.cab.symbolrate", configSequence, [6900], configsequencearg.get("INTEGER", (1, 30000)))
     
     # terrestial
     
     # terrestial
-    config.scan.ter.frequency = configElement_nonSave("config.scan.ter.frequency", configSequence, [466], (("."), (10000,14000)))
+    config.scan.ter.frequency = configElement_nonSave("config.scan.ter.frequency", configSequence, [466], configsequencearg.get("INTEGER", (10000, 14000)))
     config.scan.ter.inversion = configElement_nonSave("config.scan.ter.inversion", configSelection, 0, ("off", "on"))
     config.scan.ter.bandwidth = configElement_nonSave("config.scan.ter.bandwidth", configSelection, 0, ("Auto", "6 MHz", "7MHz", "8MHz"))
     config.scan.ter.fechigh = configElement_nonSave("config.scan.ter.fechigh", configSelection, 0, ("Auto", "1/2", "2/3", "3/4", "4/5", "5/6", "7/8", "8/9"))
     config.scan.ter.inversion = configElement_nonSave("config.scan.ter.inversion", configSelection, 0, ("off", "on"))
     config.scan.ter.bandwidth = configElement_nonSave("config.scan.ter.bandwidth", configSelection, 0, ("Auto", "6 MHz", "7MHz", "8MHz"))
     config.scan.ter.fechigh = configElement_nonSave("config.scan.ter.fechigh", configSelection, 0, ("Auto", "1/2", "2/3", "3/4", "4/5", "5/6", "7/8", "8/9"))
index 5a92f076834f8439ab97d241f224ace4f0ae7ed8..93479b664a1001413a8514c2b9586dc59848db7a 100644 (file)
@@ -111,14 +111,33 @@ class configSatlist:
                self.checkValues()
                #fixme
                return ("text", str(self.parent.vals[self.parent.value][0]))
                self.checkValues()
                #fixme
                return ("text", str(self.parent.vals[self.parent.value][0]))
+
+class configSequenceArg:
+       def get(self, type, args = ()):
+               # configsequencearg.get ("IP")
+               if (type == "IP"):
+                       return (("."), [(1,255),(1,255),(1,255),(1,255)])
+               # configsequencearg.get ("MAC")
+               if (type == "MAC"):
+                       return ((":"), [(1,255),(1,255),(1,255),(1,255),(1,255),(1,255)])
+               # configsequencearg.get("INTEGER", (min, max)) => x with min <= x <= max
+               if (type == "INTEGER"):
+                       return ((":"), [args])
+               # configsequencearg.get("FLOAT", [(min,max),(min1,max1)]) => x.y with min <= x <= max and min1 <= y <= max1
+               if (type == "FLOAT"):
+                       return (("."), args)
+
+configsequencearg = configSequenceArg()
                
 class configSequence:
        def __init__(self, parent):
                self.parent = parent
                self.markedPos = 0
                
 class configSequence:
        def __init__(self, parent):
                self.parent = parent
                self.markedPos = 0
-               
+               self.seperator = self.parent.vals[0]
+               self.valueBounds = self.parent.vals[1]
+
        def checkValues(self):
        def checkValues(self):
-               maxPos = len(self.parent.value) * len(self.parent.vals[1]) + len(self.parent.value)
+               maxPos = len(self.parent.value) * len(self.valueBounds) + len(self.parent.value)
                        
                if self.markedPos >= maxPos:
                        self.markedPos = maxPos - 1
                        
                if self.markedPos >= maxPos:
                        self.markedPos = maxPos - 1
@@ -142,7 +161,7 @@ class configSequence:
                if key >= config.key["0"] and key <= config.key["9"]:
                        number = 9 - config.key["9"] + key
                        # length of numberblock
                if key >= config.key["0"] and key <= config.key["9"]:
                        number = 9 - config.key["9"] + key
                        # length of numberblock
-                       numberLen = len(str(self.parent.vals[1][1]))
+                       numberLen = len(str(self.valueBounds[0][1]))
                        # position in the block
                        posinblock = self.markedPos % numberLen
                        # blocknumber
                        # position in the block
                        posinblock = self.markedPos % numberLen
                        # blocknumber
@@ -171,16 +190,16 @@ class configSequence:
                print "Positon: " + str(mPos)
                for i in self.parent.value:
                        if len(value):  #fixme no heading separator possible
                print "Positon: " + str(mPos)
                for i in self.parent.value:
                        if len(value):  #fixme no heading separator possible
-                               value += self.parent.vals[0]
+                               value += self.seperator
                                if mPos >= len(value) - 1:
                                        mPos += 1
                                
                                if mPos >= len(value) - 1:
                                        mPos += 1
                                
-                       #diff =         self.parent.vals[1] - len(str(i))
+                       #diff =         self.valueBounds - len(str(i))
                        #if diff > 0:
                                ## if this helps?!
                                #value += " " * diff
                        #if diff > 0:
                                ## if this helps?!
                                #value += " " * diff
-                       print (("%0" + str(len(str(self.parent.vals[1][1]))) + "d") % i)
-                       value += ("%0" + str(len(str(self.parent.vals[1][1]))) + "d") % i
+                       print (("%0" + str(len(str(self.valueBounds[0][1]))) + "d") % i)
+                       value += ("%0" + str(len(str(self.valueBounds[0][1]))) + "d") % i
 
                        # only mark cursor when we are selected
                        # (this code is heavily ink optimized!)
 
                        # only mark cursor when we are selected
                        # (this code is heavily ink optimized!)