fix comments
[enigma2.git] / lib / python / Screens / ScanSetup.py
index ad45316b90ad9266a93233d880e91b16f67793d3..97e9dbec41752055c7b6994c3e28c08e8a36b0cd 100644 (file)
@@ -1,4 +1,5 @@
 from Screen import Screen
 from Screen import Screen
+from ServiceScan import *
 from Components.config import *
 from Components.ActionMap import NumberActionMap
 from Components.ConfigList import ConfigList
 from Components.config import *
 from Components.ActionMap import NumberActionMap
 from Components.ConfigList import ConfigList
@@ -6,7 +7,24 @@ from Components.config import config
 from Components.config import getConfigListEntry
 from Components.NimManager import nimmanager
 from Components.Label import Label
 from Components.config import getConfigListEntry
 from Components.NimManager import nimmanager
 from Components.Label import Label
+from enigma import eDVBFrontendParametersSatellite
 
 
+def getInitialTransponderList(tlist, pos):
+       list = nimmanager.getTransponders(pos)
+       
+       for x in list:
+               if x[0] == 0:           #SAT
+                       parm = eDVBFrontendParametersSatellite()
+                       parm.frequency = x[1]
+                       parm.symbol_rate = x[2]
+                       parm.polarisation = x[3] # eDVBFrontendParametersSatellite.Polarisation.Verti      
+                       #parm.fec = x[4]                        # eDVBFrontendParametersSatellite.FEC.f3_4;
+                       parm.fec = 6                                    # AUTO
+                       #parm.inversion = 1     #eDVBFrontendParametersSatellite.Inversion.Off;
+                       parm.inversion = 2              #AUTO
+                       parm.orbital_position = pos
+                       tlist.append(parm)
+               
 class ScanSetup(Screen):
     def __init__(self, session):
         Screen.__init__(self, session)
 class ScanSetup(Screen):
     def __init__(self, session):
         Screen.__init__(self, session)
@@ -17,7 +35,7 @@ class ScanSetup(Screen):
         
         self["actions"] = NumberActionMap(["SetupActions"],
         {
         
         self["actions"] = NumberActionMap(["SetupActions"],
         {
-            "ok": self.keySave,
+            "ok": self.keyGo,
             "cancel": self.keyCancel,
             "left": self.keyLeft,
             "right": self.keyRight,
             "cancel": self.keyCancel,
             "left": self.keyLeft,
             "right": self.keyRight,
@@ -85,12 +103,29 @@ class ScanSetup(Screen):
         
         # multi sat scan
         if (config.scan.type.value == 2):
         
         # multi sat scan
         if (config.scan.type.value == 2):
-            for sat in nimmanager.satList:
-                self.list.append(getConfigListEntry(sat[0], config.scan.scansat[sat[1]]))                
+            # 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)
         
                 
         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":
     def newConfig(self):
         print self["config"].getCurrent()
         if self["config"].getCurrent()[0] == "Type of scan":
@@ -159,12 +194,68 @@ class ScanSetup(Screen):
         if (self["config"].getCurrent()[1].parent.enabled == True):
             self["config"].handleKey(config.key[str(number)])
 
         if (self["config"].getCurrent()[1].parent.enabled == True):
             self["config"].handleKey(config.key[str(number)])
 
-    def keySave(self):
+    def keyGo(self):
         for x in self["config"].list:
             x[1].save()
         for x in self["config"].list:
             x[1].save()
-        self.close()
+                               #tlist = [ ]            
+        self.session.openWithCallback(self.keyCancel, ServiceScan, [ ])        
+
+        #self.close()
 
     def keyCancel(self):
         for x in self["config"].list:
             x[1].cancel()
 
     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:"
+               tlist = [ ]
+               for x in self.list:
+                       if x[1].parent.value == 0:
+                               print "   " + str(x[1].parent.configPath)
+                               getInitialTransponderList(tlist, x[1].parent.configPath)
+                               
+               self.session.openWithCallback(self.keyCancel, ServiceScan, tlist)        
+               
+       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")