added ci-selection / setup-menu screen
[enigma2.git] / lib / python / Screens / ScanSetup.py
1 from Screen import Screen
2 from Components.config import *
3 from Components.ActionMap import NumberActionMap
4 from Components.ConfigList import ConfigList
5 from Components.config import config
6 from Components.config import getConfigListEntry
7 from Components.NimManager import nimmanager
8 from Components.Label import Label
9
10 class ScanSetup(Screen):
11     def __init__(self, session):
12         Screen.__init__(self, session)
13         
14         self.updateSatList()
15         self.createConfig()
16
17         
18         self["actions"] = NumberActionMap(["SetupActions"],
19         {
20             "ok": self.keySave,
21             "cancel": self.keyCancel,
22             "left": self.keyLeft,
23             "right": self.keyRight,
24             "1": self.keyNumberGlobal,
25             "2": self.keyNumberGlobal,
26             "3": self.keyNumberGlobal,
27             "4": self.keyNumberGlobal,
28             "5": self.keyNumberGlobal,
29             "6": self.keyNumberGlobal,
30             "7": self.keyNumberGlobal,
31             "8": self.keyNumberGlobal,
32             "9": self.keyNumberGlobal,
33             "0": self.keyNumberGlobal
34         }, -1)
35                 
36         self.list = []
37         self["config"] = ConfigList(self.list)
38         self.createSetup()
39
40         self["introduction"] = Label("Press OK to start the scan")
41
42     def updateSatList(self):
43         self.satList = []
44         for slot in nimmanager.nimslots:
45             self.satList.append(nimmanager.getSatListForNim(slot.slotid))
46             
47     def createSetup(self):
48         self.list = []
49         
50         self.list.append(getConfigListEntry("Type of scan", config.scan.type))
51         self.list.append(getConfigListEntry("Tuner", config.scan.nims))
52         
53         # single transponder scan
54         if (config.scan.type.value == 0):
55             if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-S"]):
56                 self.list.append(getConfigListEntry("Frequency", config.scan.sat.frequency))
57                 self.list.append(getConfigListEntry("Inversion", config.scan.sat.inversion))
58                 self.list.append(getConfigListEntry("Symbolrate", config.scan.sat.symbolrate))
59                 self.list.append(getConfigListEntry("Polarity", config.scan.sat.polarzation))
60                 self.list.append(getConfigListEntry("FEC", config.scan.sat.fec))
61             if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-C"]):
62                 self.list.append(getConfigListEntry("Frequency", config.scan.cab.frequency))
63                 self.list.append(getConfigListEntry("Inversion", config.scan.cab.inversion))
64                 self.list.append(getConfigListEntry("Symbolrate", config.scan.cab.symbolrate))
65                 self.list.append(getConfigListEntry("Modulation", config.scan.cab.modulation))
66                 self.list.append(getConfigListEntry("FEC", config.scan.cab.fec))
67             if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-T"]):
68                 self.list.append(getConfigListEntry("Frequency", config.scan.ter.frequency))
69                 self.list.append(getConfigListEntry("Inversion", config.scan.ter.inversion))
70                 self.list.append(getConfigListEntry("Bandwidth", config.scan.ter.bandwidth))
71                 self.list.append(getConfigListEntry("Code rate high", config.scan.ter.fechigh))
72                 self.list.append(getConfigListEntry("Code rate low", config.scan.ter.feclow))
73                 self.list.append(getConfigListEntry("Modulation", config.scan.ter.modulation))
74                 self.list.append(getConfigListEntry("Transmission mode", config.scan.ter.transmission))
75                 self.list.append(getConfigListEntry("Guard interval mode", config.scan.ter.guard))
76                 self.list.append(getConfigListEntry("Hierarchy mode", config.scan.ter.hierarchy))
77
78         # single satellite scan
79         print config.scan.satselection
80         if (config.scan.type.value == 1):
81             self.updateSatList()
82             print config.scan.satselection[config.scan.nims.value]
83             self.list.append(getConfigListEntry("Satellite", config.scan.satselection[config.scan.nims.value]))
84             
85         
86         # multi sat scan
87         if (config.scan.type.value == 2):
88             for sat in nimmanager.satList:
89                 self.list.append(getConfigListEntry(sat[0], config.scan.scansat[sat[1]]))                
90                 
91         self["config"].list = self.list
92         self["config"].l.setList(self.list)
93         
94     def newConfig(self):
95         print self["config"].getCurrent()
96         if self["config"].getCurrent()[0] == "Type of scan":
97             self.createSetup()
98         if self["config"].getCurrent()[0] == "Tuner":
99             self.createSetup()
100             
101     def createConfig(self):
102             config.scan = ConfigSubsection()
103             config.scan.sat = ConfigSubsection()
104             config.scan.cab = ConfigSubsection()
105             config.scan.ter = ConfigSubsection()        
106         
107             config.scan.type = configElement_nonSave("config.scan.type", configSelection, 0, ("Single transponder", "Single satellite", "Multisat"))
108             nimList = [ ]
109             for nim in nimmanager.nimList():
110                 nimList.append(nim[0])
111             nimList.append("all")
112             config.scan.nims = configElement_nonSave("config.scan.nims", configSelection, 0, nimList)
113             
114             # sat
115             config.scan.sat.frequency = configElement_nonSave("config.scan.sat.frequency", configSequence, [12187], configsequencearg.get("INTEGER", (10000, 14000)))
116             config.scan.sat.inversion = configElement_nonSave("config.scan.sat.inversion", configSelection, 0, ("off", "on"))
117             config.scan.sat.symbolrate = configElement_nonSave("config.scan.sat.symbolrate", configSequence, [27500], configsequencearg.get("INTEGER", (1, 30000)))
118             config.scan.sat.polarzation = configElement_nonSave("config.scan.sat.polarzation", configSelection, 0, ("horizontal", "vertical"))
119             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"))
120         
121             # cable
122             config.scan.cab.frequency = configElement_nonSave("config.scan.cab.frequency", configSequence, [466], configsequencearg.get("INTEGER", (10000, 14000)))
123             config.scan.cab.inversion = configElement_nonSave("config.scan.cab.inversion", configSelection, 0, ("off", "on"))
124             config.scan.cab.modulation = configElement_nonSave("config.scan.cab.modulation", configSelection, 0, ("Auto", "16-QAM", "32-QAM", "64-QAM", "128-QAM", "256-QAM"))
125             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"))
126             config.scan.cab.symbolrate = configElement_nonSave("config.scan.cab.symbolrate", configSequence, [6900], configsequencearg.get("INTEGER", (1, 30000)))
127             
128             # terrestial
129             config.scan.ter.frequency = configElement_nonSave("config.scan.ter.frequency", configSequence, [466], configsequencearg.get("INTEGER", (10000, 14000)))
130             config.scan.ter.inversion = configElement_nonSave("config.scan.ter.inversion", configSelection, 0, ("off", "on"))
131             config.scan.ter.bandwidth = configElement_nonSave("config.scan.ter.bandwidth", configSelection, 0, ("Auto", "6 MHz", "7MHz", "8MHz"))
132             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"))
133             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"))
134             config.scan.ter.modulation = configElement_nonSave("config.scan.ter.modulation", configSelection, 0, ("Auto", "16-QAM", "32-QAM", "64-QAM", "128-QAM", "256-QAM"))
135             config.scan.ter.transmission = configElement_nonSave("config.scan.ter.transmission", configSelection, 0, ("Auto", "2K", "8K"))
136             config.scan.ter.guard = configElement_nonSave("config.scan.ter.guard", configSelection, 0, ("Auto", "1/4", "1/8", "1/16", "1/32"))
137             config.scan.ter.hierarchy = configElement_nonSave("config.scan.ter.hierarchy", configSelection, 0, ("Auto", "1", "2", "4"))
138             
139             config.scan.scansat = {}
140             for sat in nimmanager.satList:
141                 #print sat[1]
142                 config.scan.scansat[sat[1]] = configElement_nonSave("config.scan.scansat[" + str(sat[1]) + "]", configSelection, 0, ("yes", "no"))
143                 
144             config.scan.satselection = []
145             slotid = 0
146             for slot in nimmanager.nimslots:
147                 config.scan.satselection.append(configElement_nonSave("config.scan.satselection[" + str(slot.slotid) + "]", configSatlist, 0, self.satList[slot.slotid]))
148         
149     def keyLeft(self):
150         self["config"].handleKey(config.key["prevElement"])
151         self.newConfig()
152
153     def keyRight(self):
154         self["config"].handleKey(config.key["nextElement"])
155         self.newConfig()
156
157     def keyNumberGlobal(self, number):
158         print "You pressed number " + str(number)
159         if (self["config"].getCurrent()[1].parent.enabled == True):
160             self["config"].handleKey(config.key[str(number)])
161
162     def keySave(self):
163         for x in self["config"].list:
164             x[1].save()
165         self.close()
166
167     def keyCancel(self):
168         for x in self["config"].list:
169             x[1].cancel()
170         self.close()