working on move, edit mode and add remove service to context menu
[enigma2.git] / lib / python / Screens / ScanSetup.py
index 660440b..6bad9a5 100644 (file)
@@ -1,26 +1,50 @@
 from Screen import Screen
-from Components.ActionMap import ActionMap
+from ServiceScan import *
+from Components.config import *
+from Components.ActionMap import NumberActionMap
 from Components.ConfigList import ConfigList
 from Components.config import config
 from Components.config import getConfigListEntry
 from Components.NimManager import nimmanager
+from Components.Label import Label
 
 class ScanSetup(Screen):
     def __init__(self, session):
         Screen.__init__(self, session)
         
-        self["actions"] = ActionMap(["SetupActions"],
+        self.updateSatList()
+        self.createConfig()
+
+        
+        self["actions"] = NumberActionMap(["SetupActions"],
         {
-            "ok": self.keySave,
+            "ok": self.keyGo,
             "cancel": self.keyCancel,
             "left": self.keyLeft,
-            "right": self.keyRight
+            "right": self.keyRight,
+            "1": self.keyNumberGlobal,
+            "2": self.keyNumberGlobal,
+            "3": self.keyNumberGlobal,
+            "4": self.keyNumberGlobal,
+            "5": self.keyNumberGlobal,
+            "6": self.keyNumberGlobal,
+            "7": self.keyNumberGlobal,
+            "8": self.keyNumberGlobal,
+            "9": self.keyNumberGlobal,
+            "0": self.keyNumberGlobal
         }, -1)
-
+                
         self.list = []
         self["config"] = ConfigList(self.list)
         self.createSetup()
-        
+
+        self["introduction"] = Label("Press OK to start the scan")
+
+    def updateSatList(self):
+        self.satList = []
+        for slot in nimmanager.nimslots:
+            self.satList.append(nimmanager.getSatListForNim(slot.slotid))
+            
     def createSetup(self):
         self.list = []
         
@@ -53,22 +77,92 @@ class ScanSetup(Screen):
                 self.list.append(getConfigListEntry("Hierarchy mode", config.scan.ter.hierarchy))
 
         # single satellite scan
+        print config.scan.satselection
         if (config.scan.type.value == 1):
-            pass
+            self.updateSatList()
+            print config.scan.satselection[config.scan.nims.value]
+            self.list.append(getConfigListEntry("Satellite", config.scan.satselection[config.scan.nims.value]))
+            
         
         # multi sat scan
         if (config.scan.type.value == 2):
-            pass
+            # if (norotor)
+            tlist = []
+            SatList = nimmanager.getSatListForNim(config.scan.nims.value)
+
+            for x in SatList:
+                if self.Satexists(tlist, x[1]) == 0:
+                    tlist.append(x[1])
+                    sat = configElement_nonSave(x[1], configSelection, 0, ("Enable", "Disable"))
+                    self.list.append(getConfigListEntry(nimmanager.getSatDescription(x[1]), sat))
+            
+            # if (rotor):
+           # for sat in nimmanager.satList:
+            #    self.list.append(getConfigListEntry(sat[0], config.scan.scansat[sat[1]]))                
                 
         self["config"].list = self.list
         self["config"].l.setList(self.list)
         
+    def Satexists(self, tlist, pos):
+        for x in tlist:
+            if x == pos:
+                return 1
+        return 0    
+    
     def newConfig(self):
         print self["config"].getCurrent()
         if self["config"].getCurrent()[0] == "Type of scan":
             self.createSetup()
         if self["config"].getCurrent()[0] == "Tuner":
             self.createSetup()
+            
+    def createConfig(self):
+            config.scan = ConfigSubsection()
+            config.scan.sat = ConfigSubsection()
+            config.scan.cab = ConfigSubsection()
+            config.scan.ter = ConfigSubsection()        
+        
+            config.scan.type = configElement_nonSave("config.scan.type", configSelection, 0, ("Single transponder", "Single satellite", "Multisat"))
+            nimList = [ ]
+            for nim in nimmanager.nimList():
+                nimList.append(nim[0])
+            nimList.append("all")
+            config.scan.nims = configElement_nonSave("config.scan.nims", configSelection, 0, nimList)
+            
+            # sat
+            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.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.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.symbolrate = configElement_nonSave("config.scan.cab.symbolrate", configSequence, [6900], configsequencearg.get("INTEGER", (1, 30000)))
+            
+            # terrestial
+            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.feclow = configElement_nonSave("config.scan.ter.feclow", configSelection, 0, ("Auto", "1/2", "2/3", "3/4", "4/5", "5/6", "7/8", "8/9"))
+            config.scan.ter.modulation = configElement_nonSave("config.scan.ter.modulation", configSelection, 0, ("Auto", "16-QAM", "32-QAM", "64-QAM", "128-QAM", "256-QAM"))
+            config.scan.ter.transmission = configElement_nonSave("config.scan.ter.transmission", configSelection, 0, ("Auto", "2K", "8K"))
+            config.scan.ter.guard = configElement_nonSave("config.scan.ter.guard", configSelection, 0, ("Auto", "1/4", "1/8", "1/16", "1/32"))
+            config.scan.ter.hierarchy = configElement_nonSave("config.scan.ter.hierarchy", configSelection, 0, ("Auto", "1", "2", "4"))
+            
+            config.scan.scansat = {}
+            for sat in nimmanager.satList:
+                #print sat[1]
+                config.scan.scansat[sat[1]] = configElement_nonSave("config.scan.scansat[" + str(sat[1]) + "]", configSelection, 0, ("yes", "no"))
+                
+            config.scan.satselection = []
+            slotid = 0
+            for slot in nimmanager.nimslots:
+                config.scan.satselection.append(configElement_nonSave("config.scan.satselection[" + str(slot.slotid) + "]", configSatlist, 0, self.satList[slot.slotid]))
         
     def keyLeft(self):
         self["config"].handleKey(config.key["prevElement"])
@@ -78,12 +172,70 @@ class ScanSetup(Screen):
         self["config"].handleKey(config.key["nextElement"])
         self.newConfig()
 
-    def keySave(self):
+    def keyNumberGlobal(self, number):
+        print "You pressed number " + str(number)
+        if (self["config"].getCurrent()[1].parent.enabled == True):
+            self["config"].handleKey(config.key[str(number)])
+
+    def keyGo(self):
         for x in self["config"].list:
             x[1].save()
-        self.close()
+        self.session.openWithCallback(self.keyCancel, ServiceScan)        
+
+        #self.close()
 
     def keyCancel(self):
         for x in self["config"].list:
             x[1].cancel()
-        self.close()
\ No newline at end of file
+        self.close()
+
+class ScanSimple(Screen):
+
+       def keyOK(self):
+               print "start scan for sats:"
+               for x in self.list:
+                       if x[1].parent.value == 0:
+                               print "   " + str(x[1].parent.configPath)
+
+               self.session.openWithCallback(self.keyCancel, ServiceScan)        
+               
+       def keyCancel(self):
+               self.close()
+
+       def keyLeft(self):
+               self["config"].handleKey(config.key["prevElement"])
+
+       def keyRight(self):
+               self["config"].handleKey(config.key["nextElement"])
+
+       def Satexists(self, tlist, pos):
+               for x in tlist:
+                       if x == pos:
+                               return 1
+               return 0
+
+       def __init__(self, session):
+               Screen.__init__(self, session)
+
+               self["actions"] = ActionMap(["SetupActions"],
+               {
+                       "ok": self.keyOK,
+                       "cancel": self.keyCancel,
+                       "left": self.keyLeft,
+                       "right": self.keyRight,
+               }, -1)
+                
+               self.list = []
+               tlist = []
+               
+               SatList = nimmanager.getConfiguredSats()
+
+               for x in SatList:
+                       if self.Satexists(tlist, x) == 0:
+                               tlist.append(x)
+                               sat = configElement_nonSave(x, configSelection, 0, ("Enable", "Disable"))
+                               self.list.append(getConfigListEntry(nimmanager.getSatDescription(x), sat))
+
+               self["config"] = ConfigList(self.list)
+               self["header"] = Label("Automatic Scan")
+               self["footer"] = Label("Press OK to scan")