dont show toneburst(MiniDiSEqC) setting when no diseqc is used
[enigma2.git] / lib / python / Screens / Satconfig.py
1 from Screen import Screen
2 from Components.ActionMap import NumberActionMap
3 from Components.ActionMap import ActionMap
4 from Components.ConfigList import ConfigList
5 from Components.config import *
6 from Components.MenuList import MenuList
7 from Components.NimManager import nimmanager
8 from Components.config import getConfigListEntry
9
10 class NimSetup(Screen):
11         def createSimpleSetup(self, nim, list, mode):
12                 if mode == 0:                   #single Sat
13                         list.append(getConfigListEntry(_("Satellite"), config.Nims[nim.slotid].diseqcA))
14                 else:                                                   # > 1 Sats
15                         list.append(getConfigListEntry(_("Port A"), config.Nims[nim.slotid].diseqcA))
16
17                 if mode >= 1:                   # > 1 Sats
18                         list.append(getConfigListEntry(_("Port B"), config.Nims[nim.slotid].diseqcB))
19                         if mode >= 3:           # > 2 Sats
20                                 list.append(getConfigListEntry(_("Port C"), config.Nims[nim.slotid].diseqcC))
21                                 list.append(getConfigListEntry(_("Port D"), config.Nims[nim.slotid].diseqcD))
22         
23         def createPositionerSetup(self, nim, list):
24                 list.append(getConfigListEntry(_("Positioner mode"), config.Nims[nim.slotid].positionerMode))
25                 if (currentConfigSelectionElement(config.Nims[nim.slotid].positionerMode) == "usals"): # USALS
26                         list.append(getConfigListEntry(_("Longitude"), config.Nims[nim.slotid].longitude))
27                         list.append(getConfigListEntry("", config.Nims[nim.slotid].longitudeOrientation))
28                         list.append(getConfigListEntry(_("Latitude"), config.Nims[nim.slotid].latitude))
29                         list.append(getConfigListEntry("", config.Nims[nim.slotid].latitudeOrientation))
30                 elif (currentConfigSelectionElement(config.Nims[nim.slotid].positionerMode) == "manual"): # manual
31                         pass
32         
33         def createSetup(self):
34                 print "Creating setup"
35                 self.list = [ ]
36
37                 self.configMode = None
38                 self.diseqcModeEntry = None
39                 self.advancedSatsEntry = None
40                 self.advancedLnbsEntry = None
41                 self.advancedDiseqcMode = None
42                 self.advancedUsalsEntry = None
43                 self.advancedLof = None
44                 self.advancedPowerMeasurement = None
45
46                 if (nimmanager.getNimType(self.nim.slotid) == nimmanager.nimType["DVB-S"]):
47                         self.configMode = getConfigListEntry(_("Configuration Mode"), config.Nims[self.nim.slotid].configMode)
48                         self.list.append(self.configMode)
49                         
50                         if currentConfigSelectionElement(config.Nims[self.nim.slotid].configMode) == "simple":                  #simple setup
51                                 self.diseqcModeEntry = getConfigListEntry(_("DiSEqC Mode"), config.Nims[self.nim.slotid].diseqcMode)
52                                 self.list.append(self.diseqcModeEntry)
53                         
54                                 if (0 <= config.Nims[self.nim.slotid].diseqcMode.value < 4):
55                                         self.createSimpleSetup(self.nim, self.list, config.Nims[self.nim.slotid].diseqcMode.value)
56                                 if (config.Nims[self.nim.slotid].diseqcMode.value == 4):
57                                         self.createPositionerSetup(self.nim, self.list)
58                         elif currentConfigSelectionElement(config.Nims[self.nim.slotid].configMode) == "nothing": # nothing
59                                 #self.list.append(getConfigListEntry(_("Linked to"), config.Nims[self.nim.slotid].linkedTo))
60                                 pass
61                         elif currentConfigSelectionElement(config.Nims[self.nim.slotid].configMode) == "loopthrough": # linked
62                                 pass
63                         elif currentConfigSelectionElement(config.Nims[self.nim.slotid].configMode) == "advanced": # advanced
64                                 # SATs
65                                 self.advancedSatsEntry = getConfigListEntry(_("Satellite"), config.Nims[self.nim.slotid].advanced.sats)
66                                 self.list.append(self.advancedSatsEntry)
67                                 currSat = config.Nims[self.nim.slotid].advanced.sat[nimmanager.satList[config.Nims[self.nim.slotid].advanced.sats.value][1]]
68                                 currLnb = config.Nims[self.nim.slotid].advanced.lnb[currSat.lnb.value]
69                                 
70                                 self.list.append(getConfigListEntry(_("Voltage mode"), currSat.voltage))
71                                 self.list.append(getConfigListEntry(_("Tone mode"), currSat.tonemode))
72                                 if (currLnb != 0 and currentConfigSelectionElement(currLnb.diseqcMode) == "1_2"):
73                                         self.advancedUsalsEntry = getConfigListEntry(_("Use usals for this sat"), currSat.usals)
74                                         self.list.append(self.advancedUsalsEntry)
75                                         if (currentConfigSelectionElement(currSat.usals) == "no"):
76                                                 self.list.append(getConfigListEntry(_("Stored position"), currSat.rotorposition))
77                                 
78                                 # LNBs
79                                 self.advancedLnbsEntry = getConfigListEntry(_("LNB"), currSat.lnb)
80                                 self.list.append(self.advancedLnbsEntry)
81                                 if currLnb != 0:
82                                         self.advancedDiseqcMode = getConfigListEntry(_("DiSEqC mode"), currLnb.diseqcMode)
83                                         self.list.append(self.advancedDiseqcMode)
84                                         if currentConfigSelectionElement(currLnb.diseqcMode) != "none":
85                                                 self.list.append(getConfigListEntry(_("Toneburst"), currLnb.toneburst))
86                                                 self.list.append(getConfigListEntry(_("Committed DiSEqC command"), currLnb.commitedDiseqcCommand))
87                                                 self.list.append(getConfigListEntry(_("Fast DiSEqC"), currLnb.fastDiseqc))
88                                                 self.list.append(getConfigListEntry(_("Sequence repeat"), currLnb.sequenceRepeat))
89                                                 if currentConfigSelectionElement(currLnb.diseqcMode) == "1_0":
90                                                         self.list.append(getConfigListEntry(_("Command order"), currLnb.commandOrder1_0))
91                                                 else:
92                                                         self.list.append(getConfigListEntry(_("Command order"), currLnb.commandOrder))
93                                                         self.list.append(getConfigListEntry(_("Uncommitted DiSEqC command"), currLnb.uncommittedDiseqcCommand))
94                                                         self.list.append(getConfigListEntry(_("DiSEqC repeats"), currLnb.diseqcRepeats))
95                                                 if currentConfigSelectionElement(currLnb.diseqcMode) == "1_2":
96                                                         self.list.append(getConfigListEntry(_("Longitude"), currLnb.longitude))
97                                                         self.list.append(getConfigListEntry("", currLnb.longitudeOrientation))
98                                                         self.list.append(getConfigListEntry(_("Latitude"), currLnb.latitude))
99                                                         self.list.append(getConfigListEntry("", currLnb.latitudeOrientation))
100                                                         self.advancedPowerMeasurement = getConfigListEntry("Use Power Measurement", currLnb.powerMeasurement)
101                                                         self.list.append(self.advancedPowerMeasurement)
102                                                         if currentConfigSelectionElement(currLnb.powerMeasurement) == "yes":
103                                                                 self.list.append(getConfigListEntry("Power Threshold in mA", currLnb.powerThreshold))
104                                         self.advancedLof = getConfigListEntry(_("LOF"), currLnb.lof)
105                                         self.list.append(self.advancedLof)
106                                         if currentConfigSelectionElement(currLnb.lof) == "user_defined":
107                                                 self.list.append(getConfigListEntry(_("LOF/L"), currLnb.lofl))
108                                                 self.list.append(getConfigListEntry(_("LOF/H"), currLnb.lofh))
109                                                 self.list.append(getConfigListEntry(_("Threshold"), currLnb.threshold))
110                                         self.list.append(getConfigListEntry(_("12V Output"), currLnb.output_12v))
111                                         self.list.append(getConfigListEntry(_("Increased voltage"), currLnb.increased_voltage))
112                 elif (nimmanager.getNimType(self.nim.slotid) == nimmanager.nimType["DVB-C"]):
113                         self.list.append(getConfigListEntry(_("Cable provider"), config.Nims[self.nim.slotid].cable))
114                 elif (nimmanager.getNimType(self.nim.slotid) == nimmanager.nimType["DVB-T"]):
115                         self.list.append(getConfigListEntry(_("Terrestrial provider"), config.Nims[self.nim.slotid].terrestrial))
116
117
118                 self["config"].list = self.list
119                 self["config"].l.setList(self.list)
120                 
121         def newConfig(self):
122                 checkList = (self.configMode, self.diseqcModeEntry, self.advancedSatsEntry, self.advancedLnbsEntry, self.advancedDiseqcMode, self.advancedUsalsEntry, self.advancedLof, self.advancedPowerMeasurement)
123                 for x in checkList:
124                         if self["config"].getCurrent() == x:
125                                 self.createSetup()                      
126         def keyLeft(self):
127                 self["config"].handleKey(config.key["prevElement"])
128                 self.newConfig()
129
130         def keyRight(self):
131                 self["config"].handleKey(config.key["nextElement"])
132                 self.newConfig()
133
134         def keyNumberGlobal(self, number):
135                 print "You pressed number " + str(number)
136                 if (self["config"].getCurrent()[1].parent.enabled == True):
137                         self["config"].handleKey(config.key[str(number)])
138
139         def run(self):
140                 for x in self["config"].list:
141                         x[1].save()
142                 nimmanager.sec.update() 
143
144         def keySave(self):
145                 self.run()
146                 self.close()
147
148         def keyCancel(self):
149                 for x in self["config"].list:
150                         x[1].cancel()
151                 self.close()
152
153         def __init__(self, session, slotid):
154                 Screen.__init__(self, session)
155                 
156                 self.nim = nimmanager.nimList()[slotid][1]
157                 
158                 self["actions"] = NumberActionMap(["SetupActions"],
159                 {
160                         "ok": self.keySave,
161                         "cancel": self.keyCancel,
162                         "left": self.keyLeft,
163                         "right": self.keyRight,
164                         "1": self.keyNumberGlobal,
165                         "2": self.keyNumberGlobal,
166                         "3": self.keyNumberGlobal,
167                         "4": self.keyNumberGlobal,
168                         "5": self.keyNumberGlobal,
169                         "6": self.keyNumberGlobal,
170                         "7": self.keyNumberGlobal,
171                         "8": self.keyNumberGlobal,
172                         "9": self.keyNumberGlobal,
173                         "0": self.keyNumberGlobal
174                 }, -1)
175
176                 self.list = [ ]
177                 self["config"] = ConfigList(self.list)
178                 
179                 self.createSetup()
180
181 class NimSelection(Screen):
182         def __init__(self, session):
183                 Screen.__init__(self, session)
184
185                 self["nimlist"] = MenuList(nimmanager.nimList())
186
187                 self["actions"] = ActionMap(["OkCancelActions"],
188                 {
189                         "ok": self.okbuttonClick ,
190                         "cancel": self.close
191                 }, -1)
192
193         def okbuttonClick(self):
194                 selection = self["nimlist"].getCurrent()
195                 if selection[1].nimType != -1:  #unknown/empty
196                         self.session.open(NimSetup, selection[1].slotid)
197