1 from Screen import Screen
2 from Components.ActionMap import ActionMap
3 from Components.ConfigList import ConfigListScreen
4 from Components.MenuList import MenuList
5 from Components.NimManager import nimmanager
6 from Components.config import getConfigListEntry, config, ConfigNothing
8 from time import mktime, localtime
9 from datetime import datetime
11 class NimSetup(Screen, ConfigListScreen):
12 def createSimpleSetup(self, list, mode):
14 list.append(getConfigListEntry(_("Satellite"), self.nimConfig.diseqcA))
16 list.append(getConfigListEntry(_("Port A"), self.nimConfig.diseqcA))
18 if mode in ["toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
19 list.append(getConfigListEntry(_("Port B"), self.nimConfig.diseqcB))
20 if mode == "diseqc_a_b_c_d":
21 list.append(getConfigListEntry(_("Port C"), self.nimConfig.diseqcC))
22 list.append(getConfigListEntry(_("Port D"), self.nimConfig.diseqcD))
24 def createPositionerSetup(self, list):
26 list.append(getConfigListEntry(_("Longitude"), nim.longitude))
27 list.append(getConfigListEntry(" ", nim.longitudeOrientation))
28 list.append(getConfigListEntry(_("Latitude"), nim.latitude))
29 list.append(getConfigListEntry(" ", nim.latitudeOrientation))
31 self.advancedPowerMeasurement = getConfigListEntry(_("Use Power Measurement"), nim.powerMeasurement)
32 list.append(self.advancedPowerMeasurement)
33 if nim.powerMeasurement.value:
34 list.append(getConfigListEntry(_("Power threshold in mA"), nim.powerThreshold))
35 self.turningSpeed = getConfigListEntry(_("Rotor turning speed"), nim.turningSpeed)
36 list.append(self.turningSpeed)
37 if nim.turningSpeed.value == "fast epoch":
38 self.turnFastEpochBegin = getConfigListEntry(_("Begin time"), nim.fastTurningBegin)
39 self.turnFastEpochEnd = getConfigListEntry(_("End time"), nim.fastTurningEnd)
40 list.append(self.turnFastEpochBegin)
41 list.append(self.turnFastEpochEnd)
43 def createSetup(self):
44 print "Creating setup"
47 self.configMode = None
48 self.diseqcModeEntry = None
49 self.advancedSatsEntry = None
50 self.advancedLnbsEntry = None
51 self.advancedDiseqcMode = None
52 self.advancedUsalsEntry = None
53 self.advancedLof = None
54 self.advancedPowerMeasurement = None
55 self.turningSpeed = None
56 self.turnFastEpochBegin = None
57 self.turnFastEpochEnd = None
59 self.cableScanType = None
61 if self.nim.isCompatible("DVB-S"):
62 self.configMode = getConfigListEntry(_("Configuration Mode"), self.nimConfig.configMode)
63 self.list.append(self.configMode)
65 if self.nimConfig.configMode.value == "simple": #simple setup
66 self.diseqcModeEntry = getConfigListEntry(_("DiSEqC Mode"), self.nimConfig.diseqcMode)
67 self.list.append(self.diseqcModeEntry)
68 if self.nimConfig.diseqcMode.value in ["single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
69 self.createSimpleSetup(self.list, self.nimConfig.diseqcMode.value)
70 if self.nimConfig.diseqcMode.value == "positioner":
71 self.createPositionerSetup(self.list)
72 elif self.nimConfig.configMode.value in ["loopthrough", "satposdepends", "nothing", "equal"]:
74 elif self.nimConfig.configMode.value == "advanced": # advanced
76 self.advancedSatsEntry = getConfigListEntry(_("Satellite"), self.nimConfig.advanced.sats)
77 self.list.append(self.advancedSatsEntry)
78 cur_orb_pos = self.nimConfig.advanced.sats.orbital_position
79 satlist = self.nimConfig.advanced.sat.keys()
80 if cur_orb_pos not in satlist:
81 cur_orb_pos = satlist[0]
82 currSat = self.nimConfig.advanced.sat[cur_orb_pos]
83 self.fillListWithAdvancedSatEntrys(currSat)
84 self.have_advanced = True
85 elif self.nim.isCompatible("DVB-C"):
86 self.configMode = getConfigListEntry(_("Configuration Mode"), self.nimConfig.configMode)
87 self.list.append(self.configMode)
88 if self.nimConfig.configMode.value == "enabled":
89 self.cableScanType=getConfigListEntry(_("Used service scan type"), self.nimConfig.cable.scan_type)
90 self.list.append(self.cableScanType)
91 if self.nimConfig.cable.scan_type.value == "provider":
92 self.list.append(getConfigListEntry(_("Provider to scan"), self.nimConfig.cable.scan_provider))
94 if self.nimConfig.cable.scan_type.value == "bands":
95 self.list.append(getConfigListEntry(_("Scan band EU VHF I"), self.nimConfig.cable.scan_band_EU_VHF_I))
96 self.list.append(getConfigListEntry(_("Scan band EU MID"), self.nimConfig.cable.scan_band_EU_MID))
97 self.list.append(getConfigListEntry(_("Scan band EU VHF III"), self.nimConfig.cable.scan_band_EU_VHF_III))
98 self.list.append(getConfigListEntry(_("Scan band EU UHF IV"), self.nimConfig.cable.scan_band_EU_UHF_IV))
99 self.list.append(getConfigListEntry(_("Scan band EU UHF V"), self.nimConfig.cable.scan_band_EU_UHF_V))
100 self.list.append(getConfigListEntry(_("Scan band EU SUPER"), self.nimConfig.cable.scan_band_EU_SUPER))
101 self.list.append(getConfigListEntry(_("Scan band EU HYPER"), self.nimConfig.cable.scan_band_EU_HYPER))
102 self.list.append(getConfigListEntry(_("Scan band US LOW"), self.nimConfig.cable.scan_band_US_LOW))
103 self.list.append(getConfigListEntry(_("Scan band US MID"), self.nimConfig.cable.scan_band_US_MID))
104 self.list.append(getConfigListEntry(_("Scan band US HIGH"), self.nimConfig.cable.scan_band_US_HIGH))
105 self.list.append(getConfigListEntry(_("Scan band US SUPER"), self.nimConfig.cable.scan_band_US_SUPER))
106 self.list.append(getConfigListEntry(_("Scan band US HYPER"), self.nimConfig.cable.scan_band_US_HYPER))
107 elif self.nimConfig.cable.scan_type.value == "steps":
108 self.list.append(getConfigListEntry(_("Frequency scan step size(khz)"), self.nimConfig.cable.scan_frequency_steps))
109 self.list.append(getConfigListEntry(_("Scan QAM16"), self.nimConfig.cable.scan_mod_qam16))
110 self.list.append(getConfigListEntry(_("Scan QAM32"), self.nimConfig.cable.scan_mod_qam32))
111 self.list.append(getConfigListEntry(_("Scan QAM64"), self.nimConfig.cable.scan_mod_qam64))
112 self.list.append(getConfigListEntry(_("Scan QAM128"), self.nimConfig.cable.scan_mod_qam128))
113 self.list.append(getConfigListEntry(_("Scan QAM256"), self.nimConfig.cable.scan_mod_qam256))
114 self.list.append(getConfigListEntry(_("Scan SR6900"), self.nimConfig.cable.scan_sr_6900))
115 self.list.append(getConfigListEntry(_("Scan SR6875"), self.nimConfig.cable.scan_sr_6875))
116 self.list.append(getConfigListEntry(_("Scan additional SR"), self.nimConfig.cable.scan_sr_ext1))
117 self.list.append(getConfigListEntry(_("Scan additional SR"), self.nimConfig.cable.scan_sr_ext2))
118 self.have_advanced = False
119 elif self.nim.isCompatible("DVB-T"):
120 self.configMode = getConfigListEntry(_("Configuration Mode"), self.nimConfig.configMode)
121 self.list.append(self.configMode)
122 self.have_advanced = False
123 if self.nimConfig.configMode.value == "enabled":
124 self.list.append(getConfigListEntry(_("Terrestrial provider"), self.nimConfig.terrestrial))
125 self.list.append(getConfigListEntry(_("Enable 5V for active antenna"), self.nimConfig.terrestrial_5V))
127 self.have_advanced = False
128 self["config"].list = self.list
129 self["config"].l.setList(self.list)
132 checkList = (self.configMode, self.diseqcModeEntry, self.advancedSatsEntry, \
133 self.advancedLnbsEntry, self.advancedDiseqcMode, self.advancedUsalsEntry, \
134 self.advancedLof, self.advancedPowerMeasurement, self.turningSpeed, self.cableScanType)
136 if self["config"].getCurrent() == x:
140 if self.have_advanced and self.nim.config_mode == "advanced":
141 self.fillAdvancedList()
143 if x in [self.turnFastEpochBegin, self.turnFastEpochEnd]:
144 # workaround for storing only hour*3600+min*60 value in configfile
145 # not really needed.. just for cosmetics..
146 tm = localtime(x[1].value)
147 dt = datetime(1970, 1, 1, tm.tm_hour, tm.tm_min)
148 x[1].value = int(mktime(dt.timetuple()))
150 nimmanager.sec.update()
152 def fillListWithAdvancedSatEntrys(self, Sat):
153 currLnb = self.nimConfig.advanced.lnb[int(Sat.lnb.value)]
155 if isinstance(currLnb, ConfigNothing):
158 self.list.append(getConfigListEntry(_("Voltage mode"), Sat.voltage))
159 self.list.append(getConfigListEntry(_("Tone mode"), Sat.tonemode))
160 if currLnb and currLnb.diseqcMode.value == "1_2":
161 self.advancedUsalsEntry = getConfigListEntry(_("Use usals for this sat"), Sat.usals)
162 self.list.append(self.advancedUsalsEntry)
163 if not Sat.usals.value:
164 self.list.append(getConfigListEntry(_("Stored position"), Sat.rotorposition))
167 self.advancedLnbsEntry = getConfigListEntry(_("LNB"), Sat.lnb)
168 self.list.append(self.advancedLnbsEntry)
170 self.advancedDiseqcMode = getConfigListEntry(_("DiSEqC mode"), currLnb.diseqcMode)
171 self.list.append(self.advancedDiseqcMode)
172 if currLnb.diseqcMode.value != "none":
173 self.list.append(getConfigListEntry(_("Toneburst"), currLnb.toneburst))
174 self.list.append(getConfigListEntry(_("Committed DiSEqC command"), currLnb.commitedDiseqcCommand))
175 self.list.append(getConfigListEntry(_("Fast DiSEqC"), currLnb.fastDiseqc))
176 self.list.append(getConfigListEntry(_("Sequence repeat"), currLnb.sequenceRepeat))
177 if currLnb.diseqcMode.value == "1_0":
178 self.list.append(getConfigListEntry(_("Command order"), currLnb.commandOrder1_0))
180 self.list.append(getConfigListEntry(_("Command order"), currLnb.commandOrder))
181 self.list.append(getConfigListEntry(_("Uncommitted DiSEqC command"), currLnb.uncommittedDiseqcCommand))
182 self.list.append(getConfigListEntry(_("DiSEqC repeats"), currLnb.diseqcRepeats))
183 if currLnb.diseqcMode.value == "1_2":
184 self.list.append(getConfigListEntry(_("Longitude"), currLnb.longitude))
185 self.list.append(getConfigListEntry(" ", currLnb.longitudeOrientation))
186 self.list.append(getConfigListEntry(_("Latitude"), currLnb.latitude))
187 self.list.append(getConfigListEntry(" ", currLnb.latitudeOrientation))
188 self.advancedPowerMeasurement = getConfigListEntry(_("Use Power Measurement"), currLnb.powerMeasurement)
189 self.list.append(self.advancedPowerMeasurement)
190 if currLnb.powerMeasurement.value:
191 self.list.append(getConfigListEntry(_("Power threshold in mA"), currLnb.powerThreshold))
192 self.turningSpeed = getConfigListEntry(_("Rotor turning speed"), currLnb.turningSpeed)
193 self.list.append(self.turningSpeed)
194 if currLnb.turningSpeed.value == "fast epoch":
195 self.turnFastEpochBegin = getConfigListEntry(_("Begin time"), currLnb.fastTurningBegin)
196 self.turnFastEpochEnd = getConfigListEntry(_("End time"), currLnb.fastTurningEnd)
197 self.list.append(self.turnFastEpochBegin)
198 self.list.append(self.turnFastEpochEnd)
199 self.advancedLof = getConfigListEntry(_("LOF"), currLnb.lof)
200 self.list.append(self.advancedLof)
201 if currLnb.lof.value == "user_defined":
202 self.list.append(getConfigListEntry(_("LOF/L"), currLnb.lofl))
203 self.list.append(getConfigListEntry(_("LOF/H"), currLnb.lofh))
204 self.list.append(getConfigListEntry(_("Threshold"), currLnb.threshold))
205 # self.list.append(getConfigListEntry(_("12V Output"), currLnb.output_12v))
206 self.list.append(getConfigListEntry(_("Increased voltage"), currLnb.increased_voltage))
208 def fillAdvancedList(self):
210 self.configMode = getConfigListEntry(_("Configuration Mode"), self.nimConfig.configMode)
211 self.list.append(self.configMode)
212 self.advancedSatsEntry = getConfigListEntry(_("Satellite"), self.nimConfig.advanced.sats)
213 self.list.append(self.advancedSatsEntry)
214 for x in nimmanager.satList:
215 Sat = self.nimConfig.advanced.sat[x[0]]
216 self.fillListWithAdvancedSatEntrys(Sat)
217 self["config"].list = self.list
223 def __init__(self, session, slotid):
224 Screen.__init__(self, session)
227 ConfigListScreen.__init__(self, self.list)
229 self["actions"] = ActionMap(["SetupActions"],
232 "cancel": self.keyCancel,
235 self.nim = nimmanager.nim_slots[slotid]
236 self.nimConfig = self.nim.config
240 ConfigListScreen.keyLeft(self)
244 ConfigListScreen.keyRight(self)
247 class NimSelection(Screen):
248 def __init__(self, session):
249 Screen.__init__(self, session)
252 for x in nimmanager.nim_slots:
253 menu.append((x.friendly_full_description, x))
255 self["nimlist"] = MenuList(menu)
257 self["actions"] = ActionMap(["OkCancelActions"],
259 "ok": self.okbuttonClick ,
263 def okbuttonClick(self):
264 nim = self["nimlist"].getCurrent()
266 if nim is not None and not nim.empty:
267 self.session.open(NimSetup, nim.slot)