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 if (nimmanager.getNimType(self.nim.slotid) == nimmanager.nimType["DVB-S"]):
47 self.configMode = getConfigListEntry(_("Configuration Mode"), self.nimConfig.configMode)
48 self.list.append(self.configMode)
50 if currentConfigSelectionElement(self.nimConfig.configMode) == "simple": #simple setup
51 self.diseqcModeEntry = getConfigListEntry(_("DiSEqC Mode"), self.nimConfig.diseqcMode)
52 self.list.append(self.diseqcModeEntry)
53 if (0 <= self.nimConfig.diseqcMode.value < 4):
54 self.createSimpleSetup(self.list, self.nimConfig.diseqcMode.value)
55 if (self.nimConfig.diseqcMode.value == 4):
56 self.createPositionerSetup(self.list)
57 elif currentConfigSelectionElement(self.nimConfig.configMode) in ["loopthrough", "satposdepends", "nothing", "equal"]:
59 elif currentConfigSelectionElement(self.nimConfig.configMode) == "advanced": # advanced
61 self.advancedSatsEntry = getConfigListEntry(_("Satellite"), self.nimConfig.advanced.sats)
62 self.list.append(self.advancedSatsEntry)
63 currSat = self.nimConfig.advanced.sat[nimmanager.satList[self.nimConfig.advanced.sats.value][1]]
64 self.fillListWithAdvancedSatEntrys(currSat)
65 elif (nimmanager.getNimType(self.nim.slotid) == nimmanager.nimType["DVB-C"]):
66 self.list.append(getConfigListEntry(_("Cable provider"), self.nimConfig.cable))
67 elif (nimmanager.getNimType(self.nim.slotid) == nimmanager.nimType["DVB-T"]):
68 self.list.append(getConfigListEntry(_("Terrestrial provider"), self.nimConfig.terrestrial))
70 self["config"].list = self.list
71 self["config"].l.setList(self.list)
74 checkList = (self.configMode, self.diseqcModeEntry, self.advancedSatsEntry, self.advancedLnbsEntry, self.advancedDiseqcMode, self.advancedUsalsEntry, self.advancedLof, self.advancedPowerMeasurement)
76 if self["config"].getCurrent() == x:
80 self["config"].handleKey(config.key["prevElement"])
84 self["config"].handleKey(config.key["nextElement"])
87 def keyNumberGlobal(self, number):
88 print "You pressed number " + str(number)
89 if (self["config"].getCurrent()[1].parent.enabled == True):
90 self["config"].handleKey(config.key[str(number)])
93 for x in self["config"].list:
95 nimmanager.sec.update()
97 def fillListWithAdvancedSatEntrys(self, Sat):
98 currLnb = self.nimConfig.advanced.lnb[Sat.lnb.value]
100 self.list.append(getConfigListEntry(_("Voltage mode"), Sat.voltage))
101 self.list.append(getConfigListEntry(_("Tone mode"), Sat.tonemode))
102 if (currLnb != 0 and currentConfigSelectionElement(currLnb.diseqcMode) == "1_2"):
103 self.advancedUsalsEntry = getConfigListEntry(_("Use usals for this sat"), Sat.usals)
104 self.list.append(self.advancedUsalsEntry)
105 if (currentConfigSelectionElement(Sat.usals) == "no"):
106 self.list.append(getConfigListEntry(_("Stored position"), Sat.rotorposition))
109 self.advancedLnbsEntry = getConfigListEntry(_("LNB"), Sat.lnb)
110 self.list.append(self.advancedLnbsEntry)
112 self.advancedDiseqcMode = getConfigListEntry(_("DiSEqC mode"), currLnb.diseqcMode)
113 self.list.append(self.advancedDiseqcMode)
114 if currentConfigSelectionElement(currLnb.diseqcMode) != "none":
115 self.list.append(getConfigListEntry(_("Toneburst"), currLnb.toneburst))
116 self.list.append(getConfigListEntry(_("Committed DiSEqC command"), currLnb.commitedDiseqcCommand))
117 self.list.append(getConfigListEntry(_("Fast DiSEqC"), currLnb.fastDiseqc))
118 self.list.append(getConfigListEntry(_("Sequence repeat"), currLnb.sequenceRepeat))
119 if currentConfigSelectionElement(currLnb.diseqcMode) == "1_0":
120 self.list.append(getConfigListEntry(_("Command order"), currLnb.commandOrder1_0))
122 self.list.append(getConfigListEntry(_("Command order"), currLnb.commandOrder))
123 self.list.append(getConfigListEntry(_("Uncommitted DiSEqC command"), currLnb.uncommittedDiseqcCommand))
124 self.list.append(getConfigListEntry(_("DiSEqC repeats"), currLnb.diseqcRepeats))
125 if currentConfigSelectionElement(currLnb.diseqcMode) == "1_2":
126 self.list.append(getConfigListEntry(_("Longitude"), currLnb.longitude))
127 self.list.append(getConfigListEntry(" ", currLnb.longitudeOrientation))
128 self.list.append(getConfigListEntry(_("Latitude"), currLnb.latitude))
129 self.list.append(getConfigListEntry(" ", currLnb.latitudeOrientation))
130 self.advancedPowerMeasurement = getConfigListEntry("Use Power Measurement", currLnb.powerMeasurement)
131 self.list.append(self.advancedPowerMeasurement)
132 if currentConfigSelectionElement(currLnb.powerMeasurement) == "yes":
133 self.list.append(getConfigListEntry("Power Threshold in mA", currLnb.powerThreshold))
134 self.advancedLof = getConfigListEntry(_("LOF"), currLnb.lof)
135 self.list.append(self.advancedLof)
136 if currentConfigSelectionElement(currLnb.lof) == "user_defined":
137 self.list.append(getConfigListEntry(_("LOF/L"), currLnb.lofl))
138 self.list.append(getConfigListEntry(_("LOF/H"), currLnb.lofh))
139 self.list.append(getConfigListEntry(_("Threshold"), currLnb.threshold))
140 self.list.append(getConfigListEntry(_("12V Output"), currLnb.output_12v))
141 self.list.append(getConfigListEntry(_("Increased voltage"), currLnb.increased_voltage))
143 def fillAdvancedList(self):
145 self.configMode = getConfigListEntry(_("Configuration Mode"), self.nimConfig.configMode)
146 self.list.append(self.configMode)
147 self.advancedSatsEntry = getConfigListEntry(_("Satellite"), self.nimConfig.advanced.sats)
148 self.list.append(self.advancedSatsEntry)
149 for x in nimmanager.satList:
150 Sat = self.nimConfig.advanced.sat[x[1]]
151 self.fillListWithAdvancedSatEntrys(Sat)
152 self["config"].list = self.list
155 if currentConfigSelectionElement(config.Nims[self.nim.slotid].configMode) == "advanced":
156 self.fillAdvancedList()
161 for x in self["config"].list:
165 def __init__(self, session, slotid):
166 Screen.__init__(self, session)
168 self["actions"] = NumberActionMap(["SetupActions"],
171 "cancel": self.keyCancel,
172 "left": self.keyLeft,
173 "right": self.keyRight,
174 "1": self.keyNumberGlobal,
175 "2": self.keyNumberGlobal,
176 "3": self.keyNumberGlobal,
177 "4": self.keyNumberGlobal,
178 "5": self.keyNumberGlobal,
179 "6": self.keyNumberGlobal,
180 "7": self.keyNumberGlobal,
181 "8": self.keyNumberGlobal,
182 "9": self.keyNumberGlobal,
183 "0": self.keyNumberGlobal
186 self.nim = nimmanager.nimList()[slotid][1]
187 self.nimConfig = config.Nims[self.nim.slotid]
189 self["config"] = ConfigList(self.list)
192 class NimSelection(Screen):
193 def __init__(self, session):
194 Screen.__init__(self, session)
196 self["nimlist"] = MenuList(nimmanager.nimList())
198 self["actions"] = ActionMap(["OkCancelActions"],
200 "ok": self.okbuttonClick ,
204 def okbuttonClick(self):
205 selection = self["nimlist"].getCurrent()
206 if selection[1].nimType != -1: #unknown/empty
207 self.session.open(NimSetup, selection[1].slotid)