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
10 class NimSetup(Screen):
11 def createSimpleSetup(self, list, mode):
12 if mode == 0: #single Sat
13 list.append(getConfigListEntry(_("Satellite"), self.nimConfig.diseqcA))
15 list.append(getConfigListEntry(_("Port A"), self.nimConfig.diseqcA))
17 if mode >= 1: # > 1 Sats
18 list.append(getConfigListEntry(_("Port B"), self.nimConfig.diseqcB))
19 if mode >= 3: # > 2 Sats
20 list.append(getConfigListEntry(_("Port C"), self.nimConfig.diseqcC))
21 list.append(getConfigListEntry(_("Port D"), self.nimConfig.diseqcD))
23 def createPositionerSetup(self, list):
24 # list.append(getConfigListEntry(_("Positioner mode"), self.nimConfig.positionerMode))
25 # if (currentConfigSelectionElement(self.nimConfig.positionerMode) == "usals"): # USALS
26 list.append(getConfigListEntry(_("Longitude"), self.nimConfig.longitude))
27 list.append(getConfigListEntry(" ", self.nimConfig.longitudeOrientation))
28 list.append(getConfigListEntry(_("Latitude"), self.nimConfig.latitude))
29 list.append(getConfigListEntry(" ", self.nimConfig.latitudeOrientation))
30 # elif (currentConfigSelectionElement(self.nimConfig.positionerMode) == "manual"): # manual
33 def createSetup(self):
34 print "Creating setup"
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
46 self.nim_type = nimmanager.getNimType(self.nim.slotid)
48 if self.nim_type == nimmanager.nimType["DVB-S"]:
49 self.configMode = getConfigListEntry(_("Configuration Mode"), self.nimConfig.configMode)
50 self.list.append(self.configMode)
52 if currentConfigSelectionElement(self.nimConfig.configMode) == "simple": #simple setup
53 self.diseqcModeEntry = getConfigListEntry(_("DiSEqC Mode"), self.nimConfig.diseqcMode)
54 self.list.append(self.diseqcModeEntry)
55 if (0 <= self.nimConfig.diseqcMode.value < 4):
56 self.createSimpleSetup(self.list, self.nimConfig.diseqcMode.value)
57 if (self.nimConfig.diseqcMode.value == 4):
58 self.createPositionerSetup(self.list)
59 elif currentConfigSelectionElement(self.nimConfig.configMode) in ["loopthrough", "satposdepends", "nothing", "equal"]:
61 elif currentConfigSelectionElement(self.nimConfig.configMode) == "advanced": # advanced
63 self.advancedSatsEntry = getConfigListEntry(_("Satellite"), self.nimConfig.advanced.sats)
64 self.list.append(self.advancedSatsEntry)
65 currSat = self.nimConfig.advanced.sat[nimmanager.satList[self.nimConfig.advanced.sats.value][1]]
66 self.fillListWithAdvancedSatEntrys(currSat)
67 self.have_advanced = True
68 elif self.nim_type == nimmanager.nimType["DVB-C"]:
69 self.list.append(getConfigListEntry(_("Cable provider"), self.nimConfig.cable))
70 self.have_advanced = False
71 elif self.nim_type == nimmanager.nimType["DVB-T"]:
72 self.have_advanced = False
73 self.list.append(getConfigListEntry(_("Terrestrial provider"), self.nimConfig.terrestrial))
75 self.have_advanced = False
77 self["config"].list = self.list
78 self["config"].l.setList(self.list)
81 checkList = (self.configMode, self.diseqcModeEntry, self.advancedSatsEntry, self.advancedLnbsEntry, self.advancedDiseqcMode, self.advancedUsalsEntry, self.advancedLof, self.advancedPowerMeasurement)
83 if self["config"].getCurrent() == x:
87 self["config"].handleKey(config.key["prevElement"])
91 self["config"].handleKey(config.key["nextElement"])
94 def keyNumberGlobal(self, number):
95 print "You pressed number " + str(number)
96 if (self["config"].getCurrent()[1].parent.enabled == True):
97 self["config"].handleKey(config.key[str(number)])
100 if self.have_advanced and currentConfigSelectionElement(config.Nims[self.nim.slotid].configMode) == "advanced":
101 self.fillAdvancedList()
102 for x in self["config"].list:
104 nimmanager.sec.update()
106 def fillListWithAdvancedSatEntrys(self, Sat):
107 currLnb = self.nimConfig.advanced.lnb[Sat.lnb.value]
109 self.list.append(getConfigListEntry(_("Voltage mode"), Sat.voltage))
110 self.list.append(getConfigListEntry(_("Tone mode"), Sat.tonemode))
111 if (currLnb != 0 and currentConfigSelectionElement(currLnb.diseqcMode) == "1_2"):
112 self.advancedUsalsEntry = getConfigListEntry(_("Use usals for this sat"), Sat.usals)
113 self.list.append(self.advancedUsalsEntry)
114 if (currentConfigSelectionElement(Sat.usals) == "no"):
115 self.list.append(getConfigListEntry(_("Stored position"), Sat.rotorposition))
118 self.advancedLnbsEntry = getConfigListEntry(_("LNB"), Sat.lnb)
119 self.list.append(self.advancedLnbsEntry)
121 self.advancedDiseqcMode = getConfigListEntry(_("DiSEqC mode"), currLnb.diseqcMode)
122 self.list.append(self.advancedDiseqcMode)
123 if currentConfigSelectionElement(currLnb.diseqcMode) != "none":
124 self.list.append(getConfigListEntry(_("Toneburst"), currLnb.toneburst))
125 self.list.append(getConfigListEntry(_("Committed DiSEqC command"), currLnb.commitedDiseqcCommand))
126 self.list.append(getConfigListEntry(_("Fast DiSEqC"), currLnb.fastDiseqc))
127 self.list.append(getConfigListEntry(_("Sequence repeat"), currLnb.sequenceRepeat))
128 if currentConfigSelectionElement(currLnb.diseqcMode) == "1_0":
129 self.list.append(getConfigListEntry(_("Command order"), currLnb.commandOrder1_0))
131 self.list.append(getConfigListEntry(_("Command order"), currLnb.commandOrder))
132 self.list.append(getConfigListEntry(_("Uncommitted DiSEqC command"), currLnb.uncommittedDiseqcCommand))
133 self.list.append(getConfigListEntry(_("DiSEqC repeats"), currLnb.diseqcRepeats))
134 if currentConfigSelectionElement(currLnb.diseqcMode) == "1_2":
135 self.list.append(getConfigListEntry(_("Longitude"), currLnb.longitude))
136 self.list.append(getConfigListEntry(" ", currLnb.longitudeOrientation))
137 self.list.append(getConfigListEntry(_("Latitude"), currLnb.latitude))
138 self.list.append(getConfigListEntry(" ", currLnb.latitudeOrientation))
139 self.advancedPowerMeasurement = getConfigListEntry("Use Power Measurement", currLnb.powerMeasurement)
140 self.list.append(self.advancedPowerMeasurement)
141 if currentConfigSelectionElement(currLnb.powerMeasurement) == "yes":
142 self.list.append(getConfigListEntry("Power Threshold in mA", currLnb.powerThreshold))
143 self.advancedLof = getConfigListEntry(_("LOF"), currLnb.lof)
144 self.list.append(self.advancedLof)
145 if currentConfigSelectionElement(currLnb.lof) == "user_defined":
146 self.list.append(getConfigListEntry(_("LOF/L"), currLnb.lofl))
147 self.list.append(getConfigListEntry(_("LOF/H"), currLnb.lofh))
148 self.list.append(getConfigListEntry(_("Threshold"), currLnb.threshold))
149 self.list.append(getConfigListEntry(_("12V Output"), currLnb.output_12v))
150 self.list.append(getConfigListEntry(_("Increased voltage"), currLnb.increased_voltage))
152 def fillAdvancedList(self):
154 self.configMode = getConfigListEntry(_("Configuration Mode"), self.nimConfig.configMode)
155 self.list.append(self.configMode)
156 self.advancedSatsEntry = getConfigListEntry(_("Satellite"), self.nimConfig.advanced.sats)
157 self.list.append(self.advancedSatsEntry)
158 for x in nimmanager.satList:
159 Sat = self.nimConfig.advanced.sat[x[1]]
160 self.fillListWithAdvancedSatEntrys(Sat)
161 self["config"].list = self.list
168 for x in self["config"].list:
172 def __init__(self, session, slotid):
173 Screen.__init__(self, session)
175 self["actions"] = NumberActionMap(["SetupActions"],
178 "cancel": self.keyCancel,
179 "left": self.keyLeft,
180 "right": self.keyRight,
181 "1": self.keyNumberGlobal,
182 "2": self.keyNumberGlobal,
183 "3": self.keyNumberGlobal,
184 "4": self.keyNumberGlobal,
185 "5": self.keyNumberGlobal,
186 "6": self.keyNumberGlobal,
187 "7": self.keyNumberGlobal,
188 "8": self.keyNumberGlobal,
189 "9": self.keyNumberGlobal,
190 "0": self.keyNumberGlobal
193 self.nim = nimmanager.nimList()[slotid][1]
194 self.nimConfig = config.Nims[self.nim.slotid]
196 self["config"] = ConfigList(self.list)
199 class NimSelection(Screen):
200 def __init__(self, session):
201 Screen.__init__(self, session)
203 self["nimlist"] = MenuList(nimmanager.nimList())
205 self["actions"] = ActionMap(["OkCancelActions"],
207 "ok": self.okbuttonClick ,
211 def okbuttonClick(self):
212 selection = self["nimlist"].getCurrent()
213 if selection[1].nimType != -1: #unknown/empty
214 self.session.open(NimSetup, selection[1].slotid)