add single satellite scan to userinterface
[enigma2.git] / lib / python / Screens / ScanSetup.py
1 from Screen import Screen
2 from Components.ActionMap import ActionMap
3 from Components.ConfigList import ConfigList
4 from Components.config import config
5 from Components.config import getConfigListEntry
6 from Components.NimManager import nimmanager
7 from Components.Label import Label
8 from Components.ScanSetup import InitScanSetup
9
10 class ScanSetup(Screen):
11     def __init__(self, session):
12         Screen.__init__(self, session)
13         
14         self["actions"] = ActionMap(["SetupActions"],
15         {
16             "ok": self.keySave,
17             "cancel": self.keyCancel,
18             "left": self.keyLeft,
19             "right": self.keyRight
20         }, -1)
21
22         self.list = []
23         self["config"] = ConfigList(self.list)
24         self.createSetup()
25
26         self["introduction"] = Label("Press OK to start the scan")
27         
28     def createSetup(self):
29         #InitScanSetup()
30         self.list = []
31         
32         self.list.append(getConfigListEntry("Type of scan", config.scan.type))
33         self.list.append(getConfigListEntry("Tuner", config.scan.nims))
34         
35         # single transponder scan
36         if (config.scan.type.value == 0):
37             if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-S"]):
38                 self.list.append(getConfigListEntry("Frequency", config.scan.sat.frequency))
39                 self.list.append(getConfigListEntry("Inversion", config.scan.sat.inversion))
40                 self.list.append(getConfigListEntry("Symbolrate", config.scan.sat.symbolrate))
41                 self.list.append(getConfigListEntry("Polarity", config.scan.sat.polarzation))
42                 self.list.append(getConfigListEntry("FEC", config.scan.sat.fec))
43             if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-C"]):
44                 self.list.append(getConfigListEntry("Frequency", config.scan.cab.frequency))
45                 self.list.append(getConfigListEntry("Inversion", config.scan.cab.inversion))
46                 self.list.append(getConfigListEntry("Symbolrate", config.scan.cab.symbolrate))
47                 self.list.append(getConfigListEntry("Modulation", config.scan.cab.modulation))
48                 self.list.append(getConfigListEntry("FEC", config.scan.cab.fec))
49             if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-T"]):
50                 self.list.append(getConfigListEntry("Frequency", config.scan.ter.frequency))
51                 self.list.append(getConfigListEntry("Inversion", config.scan.ter.inversion))
52                 self.list.append(getConfigListEntry("Bandwidth", config.scan.ter.bandwidth))
53                 self.list.append(getConfigListEntry("Code rate high", config.scan.ter.fechigh))
54                 self.list.append(getConfigListEntry("Code rate low", config.scan.ter.feclow))
55                 self.list.append(getConfigListEntry("Modulation", config.scan.ter.modulation))
56                 self.list.append(getConfigListEntry("Transmission mode", config.scan.ter.transmission))
57                 self.list.append(getConfigListEntry("Guard interval mode", config.scan.ter.guard))
58                 self.list.append(getConfigListEntry("Hierarchy mode", config.scan.ter.hierarchy))
59
60         # single satellite scan
61         print "NIM: ", config.scan.nims.value
62         print config.scan.satselection
63         if (config.scan.type.value == 1):
64             print config.scan.satselection[config.scan.nims.value]
65             self.list.append(getConfigListEntry("Satellite", config.scan.satselection[config.scan.nims.value]))
66             
67         
68         # multi sat scan
69         if (config.scan.type.value == 2):
70             for sat in nimmanager.satList:
71                 self.list.append(getConfigListEntry(sat[0], config.scan.scansat[sat[1]]))                
72                 
73         self["config"].list = self.list
74         self["config"].l.setList(self.list)
75         
76     def newConfig(self):
77         print self["config"].getCurrent()
78         if self["config"].getCurrent()[0] == "Type of scan":
79             self.createSetup()
80         if self["config"].getCurrent()[0] == "Tuner":
81             self.createSetup()
82         
83     def keyLeft(self):
84         self["config"].handleKey(config.key["prevElement"])
85         self.newConfig()
86
87     def keyRight(self):
88         self["config"].handleKey(config.key["nextElement"])
89         self.newConfig()
90
91     def keySave(self):
92         for x in self["config"].list:
93             x[1].save()
94         self.close()
95
96     def keyCancel(self):
97         for x in self["config"].list:
98             x[1].cancel()
99         self.close()