hide progressbar when event is not valid
[enigma2.git] / lib / python / Components / NimManager.py
1 from config import config, ConfigSubsection, ConfigSelection, ConfigFloat, ConfigSatlist, ConfigYesNo, ConfigInteger, ConfigSubList, ConfigNothing, ConfigSubDict, ConfigOnOff, ConfigDateTime
2
3 from enigma import eDVBSatelliteEquipmentControl as secClass, \
4         eDVBSatelliteLNBParameters as lnbParam, \
5         eDVBSatelliteDiseqcParameters as diseqcParam, \
6         eDVBSatelliteSwitchParameters as switchParam, \
7         eDVBSatelliteRotorParameters as rotorParam, \
8         eDVBResourceManager
9
10 from xml.sax import make_parser
11 from xml.sax.handler import ContentHandler
12
13 from time import localtime, mktime
14 from datetime import datetime
15
16 def getConfigSatlist(orbpos, satlist):
17         default_orbpos = None
18         for x in satlist:
19                 if x[0] == orbpos:
20                         default_orbpos = orbpos
21                         break
22         return ConfigSatlist(satlist, default_orbpos)
23
24 def tryOpen(filename):
25         try:
26                 procFile = open(filename)
27         except IOError:
28                 return None
29         return procFile
30
31 class SecConfigure:
32         def addLNBSimple(self, sec, slotid, diseqcmode, toneburstmode = diseqcParam.NO, diseqcpos = diseqcParam.SENDNO, orbpos = 0, longitude = 0, latitude = 0, loDirection = 0, laDirection = 0, turningSpeed = rotorParam.FAST):
33                 #simple defaults
34                 sec.addLNB()
35                 tunermask = 1 << slotid
36                 if self.equal.has_key(slotid):
37                         tunermask |= (1 << self.equal[slotid])
38                 elif self.linked.has_key(slotid):
39                         tunermask |= (1 << self.linked[slotid])
40                 sec.setLNBLOFL(9750000)
41                 sec.setLNBLOFH(10600000)
42                 sec.setLNBThreshold(11700000)
43                 sec.setLNBIncreasedVoltage(lnbParam.OFF)
44                 sec.setRepeats(0)
45                 sec.setFastDiSEqC(0)
46                 sec.setSeqRepeat(0)
47                 sec.setVoltageMode(switchParam.HV)
48                 sec.setToneMode(switchParam.HILO)
49                 sec.setCommandOrder(0)
50
51                 #user values
52                 sec.setDiSEqCMode(diseqcmode)
53                 sec.setToneburst(toneburstmode)
54                 sec.setCommittedCommand(diseqcpos)
55                 sec.setUncommittedCommand(0) # SENDNO
56                 #print "set orbpos to:" + str(orbpos)
57
58                 if 0 <= diseqcmode < 3:
59                         sec.addSatellite(orbpos)
60                         self.satList.append(orbpos)
61                 elif (diseqcmode == 3): # diseqc 1.2
62                         if self.satposdepends.has_key(slotid):
63                                 tunermask |= (1 << self.satposdepends[slotid])
64                         sec.setLatitude(latitude)
65                         sec.setLaDirection(laDirection)
66                         sec.setLongitude(longitude)
67                         sec.setLoDirection(loDirection)
68                         sec.setUseInputpower(True)
69                         sec.setInputpowerDelta(50)
70                         sec.setRotorTurningSpeed(turningSpeed)
71
72                         for x in self.NimManager.satList:
73                                 print "Add sat " + str(x[0])
74                                 sec.addSatellite(int(x[0]))
75                                 sec.setVoltageMode(0)
76                                 sec.setToneMode(0)
77                                 sec.setRotorPosNum(0) # USALS
78                                 self.satList.append(int(x[0]))
79
80                 sec.setLNBSlotMask(tunermask)
81
82         def setSatposDepends(self, sec, nim1, nim2):
83                 print "tuner", nim1, "depends on satpos of", nim2
84                 sec.setTunerDepends(nim1, nim2)
85
86         def linkNIMs(self, sec, nim1, nim2):
87                 print "link tuner", nim1, "to tuner", nim2
88                 sec.setTunerLinked(nim1, nim2)
89
90         def getSatList(self):
91                 return self.satList
92
93         def update(self):
94                 sec = secClass.getInstance()
95                 sec.clear() ## this do unlinking NIMs too !!
96                 print "sec config cleared"
97                 self.satList = []
98
99                 self.linked = { }
100                 self.satposdepends = { }
101                 self.equal = { }
102
103                 nim_slots = self.NimManager.nim_slots
104
105                 used_nim_slots = [ ]
106
107                 for slot in nim_slots:
108                         x = slot.slot
109                         nim = slot.config
110                         if slot.isCompatible("DVB-S"):
111                                 # save what nim we link to/are equal to/satposdepends to.
112                                 # this is stored in the *value* (not index!) of the config list
113                                 if nim.configMode.value == "equal":
114                                         self.equal[int(nim.equalTo.value)]=x
115                                 elif nim.configMode.value == "loopthrough":
116                                         self.linkNIMs(sec, x, int(nim.linkedTo.value))
117                                         self.linked[int(nim.linkedTo.value)]=x
118                                 elif nim.configMode.value == "satposdepends":
119                                         self.setSatposDepends(sec, x, int(nim.satposDependsTo.value))
120                                         self.satposdepends[int(nim.satposDependsTo.value)]=x
121
122                         if slot.type is not None:
123                                 used_nim_slots.append((slot.slot, slot.description, nim.configMode.value != "nothing" and True or False))
124
125                 eDVBResourceManager.getInstance().setFrontendSlotInformations(used_nim_slots)
126
127                 for slot in nim_slots:
128                         x = slot.slot
129                         nim = slot.config
130                         if slot.isCompatible("DVB-S"):
131                                 print "slot: " + str(x) + " configmode: " + str(nim.configMode.value)
132                                 print "diseqcmode: ", nim.configMode.value
133                                 if nim.configMode.value in [ "loopthrough", "satposdepends", "nothing" ]:
134                                         pass
135                                 else:
136                                         sec.setSlotNotLinked(x)
137                                         if nim.configMode.value == "equal":
138                                                 pass
139                                         elif nim.configMode.value == "simple":          #simple config
140                                                 if nim.diseqcMode.value == "single":                    #single
141                                                         self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.NONE, diseqcpos = diseqcParam.SENDNO)
142                                                 elif nim.diseqcMode.value == "toneburst_a_b":           #Toneburst A/B
143                                                         self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.A, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO)
144                                                         self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.B, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO)
145                                                 elif nim.diseqcMode.value == "diseqc_a_b":              #DiSEqC A/B
146                                                         self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA)
147                                                         self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB)
148                                                 elif nim.diseqcMode.value == "diseqc_a_b_c_d":          #DiSEqC A/B/C/D
149                                                         self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA)
150                                                         self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB)
151                                                         self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcC.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BA)
152                                                         self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcD.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BB)
153                                                 elif nim.diseqcMode.value == "positioner":              #Positioner
154                                                         if nim.latitudeOrientation.value == "north":
155                                                                 laValue = rotorParam.NORTH
156                                                         else:
157                                                                 laValue = rotorParam.SOUTH
158                                                         if nim.longitudeOrientation.value == "east":
159                                                                 loValue = rotorParam.EAST
160                                                         else:
161                                                                 loValue = rotorParam.WEST
162                                                         turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
163                                                         if turn_speed_dict.has_key(nim.turningSpeed.value):
164                                                                 turning_speed = turn_speed_dict[nim.turningSpeed.value]
165                                                         else:
166                                                                 beg_time = localtime(nim.fastTurningBegin.value)
167                                                                 end_time = localtime(nim.fastTurningEnd.value)
168                                                                 turning_speed = ((beg_time.tm_hour+1) * 60 + beg_time.tm_min + 1) << 16
169                                                                 turning_speed |= (end_time.tm_hour+1) * 60 + end_time.tm_min + 1
170                                                         self.addLNBSimple(sec, slotid = x, diseqcmode = 3,
171                                                                 longitude = nim.longitude.float,
172                                                                 loDirection = loValue,
173                                                                 latitude = nim.latitude.float,
174                                                                 laDirection = laValue,
175                                                                 turningSpeed = turning_speed)
176                                         elif nim.configMode.value == "advanced": #advanced config
177                                                 self.updateAdvanced(sec, x)
178                 print "sec config completed"
179
180         def updateAdvanced(self, sec, slotid):
181                 lnbSat = {}
182                 for x in range(1,33):
183                         lnbSat[x] = []
184                 for x in self.NimManager.satList:
185                         lnb = int(config.Nims[slotid].advanced.sat[x[0]].lnb.value)
186                         if lnb != 0:
187                                 print "add", x[0], "to", lnb
188                                 lnbSat[lnb].append(x[0])
189                 for x in range(1,33):
190                         if len(lnbSat[x]) > 0:
191                                 currLnb = config.Nims[slotid].advanced.lnb[x]
192                                 sec.addLNB()
193
194                                 tunermask = 1 << slotid
195                                 if self.equal.has_key(slotid):
196                                         tunermask |= (1 << self.equal[slotid])
197                                 elif self.linked.has_key(slotid):
198                                         tunermask |= (1 << self.linked[slotid])
199
200                                 if currLnb.lof.value == "universal_lnb":
201                                         sec.setLNBLOFL(9750000)
202                                         sec.setLNBLOFH(10600000)
203                                         sec.setLNBThreshold(11700000)
204                                 elif currLnb.lof.value == "c_band":
205                                         sec.setLNBLOFL(5150000)
206                                         sec.setLNBLOFH(5150000)
207                                         sec.setLNBThreshold(5150000)
208                                 elif currLnb.lof.value == "user_defined":
209                                         sec.setLNBLOFL(currLnb.lofl.value * 1000)
210                                         sec.setLNBLOFH(currLnb.lofh.value * 1000)
211                                         sec.setLNBThreshold(currLnb.threshold.value * 1000)
212
213 #                               if currLnb.output_12v.value == "0V":
214 #                                       pass # nyi in drivers
215 #                               elif currLnb.output_12v.value == "12V":
216 #                                       pass # nyi in drivers
217
218                                 if currLnb.increased_voltage.value:
219                                         sec.setLNBIncreasedVoltage(lnbParam.ON)
220                                 else:
221                                         sec.setLNBIncreasedVoltage(lnbParam.OFF)
222
223                                 dm = currLnb.diseqcMode.value
224                                 if dm == "none":
225                                         sec.setDiSEqCMode(diseqcParam.NONE)
226                                 elif dm == "1_0":
227                                         sec.setDiSEqCMode(diseqcParam.V1_0)
228                                 elif dm == "1_1":
229                                         sec.setDiSEqCMode(diseqcParam.V1_1)
230                                 elif dm == "1_2":
231                                         sec.setDiSEqCMode(diseqcParam.V1_2)
232
233                                         if self.satposdepends.has_key(slotid):  # only useable with rotors
234                                                 tunermask |= (1 << self.satposdepends[slotid])
235
236                                 if dm != "none":
237                                         if currLnb.toneburst.value == "none":
238                                                 sec.setToneburst(diseqcParam.NO)
239                                         elif currLnb.toneburst.value == "A":
240                                                 sec.setToneburst(diseqcParam.A)
241                                         elif currLnb.toneburst.value == "B":
242                                                 sec.setToneburst(diseqcParam.B)
243
244                                         # Committed Diseqc Command
245                                         cdc = currLnb.commitedDiseqcCommand.value
246
247                                         c = { "none": diseqcParam.SENDNO,
248                                                 "AA": diseqcParam.AA,
249                                                 "AB": diseqcParam.AB,
250                                                 "BA": diseqcParam.BA,
251                                                 "BB": diseqcParam.BB }
252
253                                         if c.has_key(cdc):
254                                                 sec.setCommittedCommand(c[cdc])
255                                         else:
256                                                 sec.setCommittedCommand(long(cdc))
257
258                                         sec.setFastDiSEqC(currLnb.fastDiseqc.value)
259
260                                         sec.setSeqRepeat(currLnb.sequenceRepeat.value)
261
262                                         if currLnb.diseqcMode.value == "1_0":
263                                                 currCO = currLnb.commandOrder1_0.value
264                                         else:
265                                                 currCO = currLnb.commandOrder.value
266
267                                                 udc = int(currLnb.uncommittedDiseqcCommand.value)
268                                                 if udc > 0:
269                                                         sec.setUncommittedCommand(0xF0|(udc-1))
270                                                 else:
271                                                         sec.setUncommittedCommand(0) # SENDNO
272
273                                                 sec.setRepeats({"none": 0, "one": 1, "two": 2, "three": 3}[currLnb.diseqcRepeats.value])
274
275                                         setCommandOrder = False
276
277                                         # 0 "committed, toneburst",
278                                         # 1 "toneburst, committed",
279                                         # 2 "committed, uncommitted, toneburst",
280                                         # 3 "toneburst, committed, uncommitted",
281                                         # 4 "uncommitted, committed, toneburst"
282                                         # 5 "toneburst, uncommitted, commmitted"
283                                         order_map = {"ct": 0, "tc": 1, "cut": 2, "tcu": 3, "uct": 4, "tuc": 5}
284                                         sec.setCommandOrder(order_map[currCO])
285
286                                 if dm == "1_2":
287                                         latitude = currLnb.latitude.float
288                                         sec.setLatitude(latitude)
289                                         longitude = currLnb.longitude.float
290                                         sec.setLongitude(longitude)
291                                         if currLnb.latitudeOrientation.value == "north":
292                                                 sec.setLaDirection(rotorParam.NORTH)
293                                         else:
294                                                 sec.setLaDirection(rotorParam.SOUTH)
295                                         if currLnb.longitudeOrientation.value == "east":
296                                                 sec.setLoDirection(rotorParam.EAST)
297                                         else:
298                                                 sec.setLoDirection(rotorParam.WEST)
299
300                                 if currLnb.powerMeasurement.value:
301                                         sec.setUseInputpower(True)
302                                         sec.setInputpowerDelta(currLnb.powerThreshold.value)
303                                         turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW }
304                                         if turn_speed_dict.has_key(currLnb.turningSpeed.value):
305                                                 turning_speed = turn_speed_dict[currLnb.turningSpeed.value]
306                                         else:
307                                                 beg_time = localtime(currLnb.fastTurningBegin.value)
308                                                 end_time = localtime(currLnb.fastTurningEnd.value)
309                                                 turning_speed = ((beg_time.tm_hour + 1) * 60 + beg_time.tm_min + 1) << 16
310                                                 turning_speed |= (end_time.tm_hour + 1) * 60 + end_time.tm_min + 1
311                                         sec.setRotorTurningSpeed(turning_speed)
312                                 else:
313                                         sec.setUseInputpower(False)
314
315                                 sec.setLNBSlotMask(tunermask)
316
317                                 # finally add the orbital positions
318                                 for y in lnbSat[x]:
319                                         sec.addSatellite(y)
320                                         currSat = config.Nims[slotid].advanced.sat[y]
321
322                                         if currSat.voltage.value == "polarization":
323                                                 sec.setVoltageMode(switchParam.HV)
324                                         elif currSat.voltage.value == "13V":
325                                                 sec.setVoltageMode(switchParam._14V)
326                                         elif currSat.voltage.value == "18V":
327                                                 sec.setVoltageMode(switchParam._18V)
328                                                 
329                                         if currSat.tonemode == "band":
330                                                 sec.setToneMode(switchParam.HILO)
331                                         elif currSat.tonemode == "on":
332                                                 sec.setToneMode(switchParam.ON)
333                                         elif currSat.tonemode == "off":
334                                                 sec.setToneMode(switchParam.OFF)
335                                                 
336                                         if not currSat.usals.value:
337                                                 sec.setRotorPosNum(currSat.rotorposition.value)
338                                         else:
339                                                 sec.setRotorPosNum(0) #USALS
340
341         def __init__(self, nimmgr):
342                 self.NimManager = nimmgr
343                 self.update()
344
345 class NIM(object):
346         def __init__(self, slot, type, description):
347                 self.slot = slot
348
349                 if type not in ["DVB-S", "DVB-C", "DVB-T", "DVB-S2", None]:
350                         print "warning: unknown NIM type %s, not using." % type
351                         type = None
352
353                 self.type = type
354                 self.description = description
355
356         def isCompatible(self, what):
357                 compatible = {
358                                 None: [None],
359                                 "DVB-S": ["DVB-S", None],
360                                 "DVB-C": ["DVB-C", None],
361                                 "DVB-T": ["DVB-T", None],
362                                 "DVB-S2": ["DVB-S", "DVB-S2", None]
363                         }
364                 return what in compatible[self.type]
365
366         def getSlotName(self):
367                 # get a friendly description for a slot name.
368                 # we name them "Tuner A/B/C/...", because that's what's usually written on the back
369                 # of the device.
370                 return _("Tuner ") + chr(ord('A') + self.slot)
371
372         slot_name = property(getSlotName)
373
374         def getSlotID(self):
375                 return chr(ord('A') + self.slot)
376
377         slot_id = property(getSlotID)
378
379         def getFriendlyType(self):
380                 return {
381                         "DVB-S": "DVB-S", 
382                         "DVB-T": "DVB-T",
383                         "DVB-S2": "DVB-S2",
384                         "DVB-C": "DVB-C",
385                         None: _("empty")
386                         }[self.type]
387
388         friendly_type = property(getFriendlyType)
389
390         def getFriendlyFullDescription(self):
391                 nim_text = self.slot_name + ": "
392                         
393                 if self.empty:
394                         nim_text += _("(empty)")
395                 else:
396                         nim_text += self.description + " (" + self.friendly_type + ")"
397                 
398                 return nim_text
399
400         friendly_full_description = property(getFriendlyFullDescription)
401         config_mode = property(lambda self: config.Nims[self.slot].configMode.value)
402         config = property(lambda self: config.Nims[self.slot])
403         empty = property(lambda self: self.type is None)
404
405 class NimManager:
406         class parseSats(ContentHandler):
407                 def __init__(self, satList, satellites, transponders):
408                         self.isPointsElement, self.isReboundsElement = 0, 0
409                         self.satList = satList
410                         self.satellites = satellites
411                         self.transponders = transponders
412         
413                 def startElement(self, name, attrs):
414                         if (name == "sat"):
415                                 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
416                                 tpos = int(attrs.get('position',""))
417                                 if tpos < 0:
418                                         tpos = 3600 + tpos
419                                 tname = attrs.get('name',"").encode("UTF-8")
420                                 self.satellites[tpos] = tname
421                                 self.satList.append( (tpos, tname) )
422                                 self.parsedSat = int(tpos)
423                         elif (name == "transponder"):
424                                 modulation = int(attrs.get('modulation',"1")) # QPSK default
425                                 system = int(attrs.get('system',"0")) # DVB-S default
426                                 freq = int(attrs.get('frequency',""))
427                                 sr = int(attrs.get('symbol_rate',""))
428                                 pol = int(attrs.get('polarization',""))
429                                 fec = int(attrs.get('fec_inner',"0")) # AUTO default
430                                 if self.parsedSat in self.transponders:
431                                         pass
432                                 else:
433                                         self.transponders[self.parsedSat] = [ ]
434
435                                 self.transponders[self.parsedSat].append((0, freq, sr, pol, fec, system, modulation))
436
437         class parseCables(ContentHandler):
438                 def __init__(self, cablesList, transponders):
439                         self.isPointsElement, self.isReboundsElement = 0, 0
440                         self.cablesList = cablesList
441                         for x in self.cablesList:
442                                 self.cablesList.remove(x)
443                         self.transponders = transponders
444         
445                 def startElement(self, name, attrs):
446                         if (name == "cable"):
447                                 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
448                                 tname = attrs.get('name',"").encode("UTF-8")
449                                 tflags = int(attrs.get('flags',"0"))
450                                 self.cablesList.append((tname, tflags))
451                                 self.parsedCab = tname
452                         elif (name == "transponder"):
453                                 freq = int(attrs.get('frequency',""))
454                                 while freq > 999999:
455                                         freq /= 10
456                                 sr = int(attrs.get('symbol_rate',"0"))
457                                 mod = int(attrs.get('modulation',"3")) # QAM64 default
458                                 fec = int(attrs.get('fec_inner',"0")) # AUTO default
459                                 if self.parsedCab in self.transponders:
460                                         pass
461                                 else:
462                                         self.transponders[self.parsedCab] = [ ]
463                                 self.transponders[self.parsedCab].append((1, freq, sr, mod, fec))
464
465         class parseTerrestrials(ContentHandler):
466                 def __init__(self, terrestrialsList, transponders):
467                         self.isPointsElement, self.isReboundsElement = 0, 0
468                         self.terrestrialsList = terrestrialsList
469                         self.transponders = transponders
470         
471                 def startElement(self, name, attrs):
472                         if (name == "terrestrial"):
473                                 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
474                                 tname = attrs.get('name',"").encode("UTF-8")
475                                 tflags = attrs.get('flags',"")
476                                 self.terrestrialsList.append((tname, tflags))
477                                 self.parsedTer = str(tname)
478                         elif (name == "transponder"):
479                                 # TODO finish this!
480                                 freq = int(attrs.get('centre_frequency',""))
481                                 bw = int(attrs.get('bandwidth',"3")) # AUTO
482                                 const = int(attrs.get('constellation',"1")) # AUTO
483                                 crh = int(attrs.get('code_rate_hp',"5")) # AUTO
484                                 if crh > 5: # our terrestrial.xml is buggy... 6 for AUTO
485                                         crh = 5
486                                 crl = int(attrs.get('code_rate_lp',"5")) # AUTO
487                                 if crl > 5: # our terrestrial.xml is buggy... 6 for AUTO
488                                         crl = 5
489                                 guard = int(attrs.get('guard_interval',"4")) # AUTO
490                                 transm = int(attrs.get('transmission_mode',"2")) # AUTO
491                                 hierarchy = int(attrs.get('hierarchy_information',"4")) # AUTO
492                                 inv = int(attrs.get('inversion',"2")) # AUTO
493                                 if self.parsedTer in self.transponders:
494                                         pass
495                                 else:
496                                         self.transponders[self.parsedTer] = [ ]
497
498                                 self.transponders[self.parsedTer].append((2, freq, bw, const, crh, crl, guard, transm, hierarchy, inv))
499
500         def getTransponders(self, pos):
501                 if self.transponders.has_key(pos):
502                         return self.transponders[pos]
503                 else:
504                         return []
505
506         def getTranspondersCable(self, nim):
507                 nimConfig = config.Nims[nim]
508                 if nimConfig.configMode.value != "nothing" and nimConfig.cable.scan_type.value == "provider":
509                         return self.transponderscable[self.cablesList[nimConfig.cable.scan_provider.index][0]]
510                 return [ ]
511
512         def getTranspondersTerrestrial(self, region):
513                 return self.transpondersterrestrial[region]
514         
515         def getCableDescription(self, nim):
516                 return self.cablesList[config.Nims[nim].scan_provider.index][0]
517
518         def getCableFlags(self, nim):
519                 return self.cablesList[config.Nims[nim].scan_provider.index][1]
520
521         def getTerrestrialDescription(self, nim):
522                 return self.terrestrialsList[config.Nims[nim].terrestrial.index][0]
523
524         def getTerrestrialFlags(self, nim):
525                 return self.terrestrialsList[config.Nims[nim].terrestrial.index][1]
526
527         def getConfiguredSats(self):
528                 return self.sec.getSatList()
529
530         def getSatDescription(self, pos):
531                 return self.satellites[pos]
532
533         def readSatsfromFile(self):
534                 # read initial networks from file. we only read files which we are interested in,
535                 # which means only these where a compatible tuner exists.
536                 self.satellites = { }
537                 self.transponders = { }
538                 self.transponderscable = { }
539                 self.transpondersterrestrial = { }              
540
541                 parser = make_parser()
542                 
543                 if self.hasNimType("DVB-S"):
544                         print "Reading satellites.xml"
545                         satHandler = self.parseSats(self.satList, self.satellites, self.transponders)
546                         parser.setContentHandler(satHandler)
547                         parser.parse('/etc/tuxbox/satellites.xml')
548
549                 if self.hasNimType("DVB-C"):
550                         print "Reading cables.xml"
551                         cabHandler = self.parseCables(self.cablesList, self.transponderscable)
552                         parser.setContentHandler(cabHandler)
553                         parser.parse('/etc/tuxbox/cables.xml')
554
555                 if self.hasNimType("DVB-T"):
556                         print "Reading terrestrial.xml"
557                         terHandler = self.parseTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
558                         parser.setContentHandler(terHandler)
559                         parser.parse('/etc/tuxbox/terrestrial.xml')
560
561         def enumerateNIMs(self):
562                 # enum available NIMs. This is currently very dreambox-centric and uses the /proc/bus/nim_sockets interface.
563                 # the result will be stored into nim_slots.
564                 # the content of /proc/bus/nim_sockets looks like:
565                 # NIM Socket 0:
566                 #          Type: DVB-S
567                 #          Name: BCM4501 DVB-S2 NIM (internal)
568                 # NIM Socket 1:
569                 #          Type: DVB-S
570                 #          Name: BCM4501 DVB-S2 NIM (internal)
571                 # NIM Socket 2:
572                 #          Type: DVB-T
573                 #          Name: Philips TU1216
574                 # NIM Socket 3:
575                 #          Type: DVB-S
576                 #          Name: Alps BSBE1 702A
577                 
578                 #
579                 # Type will be either "DVB-S", "DVB-S2", "DVB-T", "DVB-C" or None.
580
581                 nimfile = tryOpen("/proc/bus/nim_sockets")
582
583                 if nimfile is None:
584                         return
585
586                 current_slot = None
587
588                 entries = {}
589                 for line in nimfile.readlines():
590                         if line == "":
591                                 break
592                         if line.strip().startswith("NIM Socket"):
593                                 parts = line.strip().split(" ")
594                                 current_slot = int(parts[2][:-1])
595                                 entries[current_slot] = {}
596                         elif line.strip().startswith("Type:"):
597                                 entries[current_slot]["type"] = str(line.strip()[6:])
598                         elif line.strip().startswith("Name:"):
599                                 entries[current_slot]["name"] = str(line.strip()[6:])
600                         elif line.strip().startswith("empty"):
601                                 entries[current_slot]["type"] = None
602                                 entries[current_slot]["name"] = _("N/A")
603                 nimfile.close()
604                 
605                 # nim_slots is an array which has exactly one entry for each slot, even for empty ones.
606                 self.nim_slots = [ ]
607
608                 for id, entry in entries.items():
609                         if not (entry.has_key("name") and entry.has_key("type")):
610                                 entry["name"] =  _("N/A")
611                                 entry["type"] = None
612                         self.nim_slots.append(NIM(slot = id, description = entry["name"], type = entry["type"]))
613
614         def hasNimType(self, chktype):
615                 for slot in self.nim_slots:
616                         if slot.isCompatible(chktype):
617                                 return True
618                 return False
619
620         def getNimListOfType(self, type, exception = -1):
621                 # returns a list of indexes for NIMs compatible to the given type, except for 'exception'
622                 list = []
623                 for x in self.nim_slots:
624                         if x.isCompatible(type) and x.slot != exception:
625                                 list.append(x.slot)
626                 return list
627
628         def __init__(self):
629                 self.satList = [ ]
630                 self.cablesList = []
631                 self.terrestrialsList = []
632                 self.enumerateNIMs()
633                 self.readSatsfromFile()
634
635                 InitNimManager(self)    #init config stuff
636
637         # get a list with the friendly full description
638         def nimList(self):
639                 list = [ ]
640                 for slot in self.nim_slots:
641                         list.append(slot.friendly_full_description)
642                 return list
643
644         def getSatList(self):
645                 return self.satList
646
647         def getSatListForNim(self, slotid):
648                 list = []
649                 if self.nim_slots[slotid].isCompatible("DVB-S"):
650                         #print "slotid:", slotid
651
652                         #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.index]
653                         #print "diseqcA:", config.Nims[slotid].diseqcA.value
654                         configMode = config.Nims[slotid].configMode.value
655
656                         if configMode == "equal":
657                                 slotid=0 #FIXME add handling for more than two tuners !!!
658                                 configMode = config.Nims[slotid].configMode.value
659
660                         if configMode == "simple":
661                                 dm = config.Nims[slotid].diseqcMode.value
662                                 if dm in ["single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
663                                         list.append(self.satList[config.Nims[slotid].diseqcA.index])
664                                 if dm in ["toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
665                                         list.append(self.satList[config.Nims[slotid].diseqcB.index])
666                                 if dm == "diseqc_a_b_c_d":
667                                         list.append(self.satList[config.Nims[slotid].diseqcC.index])
668                                         list.append(self.satList[config.Nims[slotid].diseqcD.index])
669                                 if dm == "positioner":
670                                         for x in self.satList:
671                                                 list.append(x)
672                         elif configMode == "advanced":
673                                 for x in self.satList:
674                                         if int(config.Nims[slotid].advanced.sat[x[0]].lnb.value) != 0:
675                                                 list.append(x)
676                 
677                 return list
678
679         def getRotorSatListForNim(self, slotid):
680                 list = []
681                 if self.nim_slots[slotid].isCompatible("DVB-S"):
682                         #print "slotid:", slotid
683
684                         #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
685                         #print "diseqcA:", config.Nims[slotid].diseqcA.value
686                         configMode = config.Nims[slotid].configMode.value
687                         if configMode == "simple":
688                                 if config.Nims[slotid].diseqcMode.value == "positioner":
689                                         for x in self.satList:
690                                                 list.append(x)
691                         elif configMode == "advanced":
692                                 for x in self.satList:
693                                         nim = config.Nims[slotid]
694                                         lnbnum = int(nim.advanced.sat[x[0]].lnb.value)
695                                         if lnbnum != 0:
696                                                 lnb = nim.advanced.lnb[lnbnum]
697                                                 if lnb.diseqcMode.value == "1_2":
698                                                         list.append(x)
699                 return list
700
701 def InitSecParams():
702         config.sec = ConfigSubsection()
703
704         x = ConfigInteger(default=15, limits = (0, 9999))
705         x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_CONT_TONE, configElement.value))
706         config.sec.delay_after_continuous_tone_change = x
707
708         x = ConfigInteger(default=10, limits = (0, 9999))
709         x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_VOLTAGE_CHANGE, configElement.value))
710         config.sec.delay_after_final_voltage_change = x
711
712         x = ConfigInteger(default=120, limits = (0, 9999))
713         x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_DISEQC_REPEATS, configElement.value))
714         config.sec.delay_between_diseqc_repeats = x
715
716         x = ConfigInteger(default=50, limits = (0, 9999))
717         x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_LAST_DISEQC_CMD, configElement.value))
718         config.sec.delay_after_last_diseqc_command = x
719
720         x = ConfigInteger(default=50, limits = (0, 9999))
721         x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value))
722         config.sec.delay_after_toneburst = x
723
724         x = ConfigInteger(default=200, limits = (0, 9999))
725         x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS, configElement.value))
726         config.sec.delay_after_enable_voltage_before_switch_command = x
727
728         x = ConfigInteger(default=700, limits = (0, 9999))
729         x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_SWITCH_AND_MOTOR_CMD, configElement.value))
730         config.sec.delay_between_switch_and_motor_command = x
731
732         x = ConfigInteger(default=150, limits = (0, 9999))
733         x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MEASURE_IDLE_INPUTPOWER, configElement.value))
734         config.sec.delay_after_voltage_change_before_measure_idle_inputpower = x
735
736         x = ConfigInteger(default=750, limits = (0, 9999))
737         x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_MOTOR_CMD, configElement.value))
738         config.sec.delay_after_enable_voltage_before_motor_command = x
739
740         x = ConfigInteger(default=150, limits = (0, 9999))
741         x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_MOTOR_STOP_CMD, configElement.value))
742         config.sec.delay_after_motor_stop_command = x
743
744         x = ConfigInteger(default=150, limits = (0, 9999))
745         x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MOTOR_CMD, configElement.value))
746         config.sec.delay_after_voltage_change_before_motor_command = x
747
748         x = ConfigInteger(default=120, limits = (0, 9999))
749         x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_RUNNING_TIMEOUT, configElement.value))
750         config.sec.motor_running_timeout = x
751
752         x = ConfigInteger(default=1, limits = (0, 5))
753         x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_COMMAND_RETRIES, configElement.value))
754         config.sec.motor_command_retries = x
755
756         x = ConfigInteger(default=20, limits = (0, 9999))
757         x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS, configElement.value))
758         config.sec.delay_after_change_voltage_before_switch_command = x
759
760 # TODO add support for satpos depending nims to advanced nim configuration
761 # so a second/third/fourth cable from a motorized lnb can used behind a
762 # diseqc 1.0 / diseqc 1.1 / toneburst switch
763 # the C(++) part should can handle this
764 # the configElement should be only visible when diseqc 1.2 is disabled
765
766 def InitNimManager(nimmgr):
767         InitSecParams()
768
769         config.Nims = ConfigSubList()
770         for x in range(len(nimmgr.nim_slots)):
771                 config.Nims.append(ConfigSubsection())
772
773         for slot in nimmgr.nim_slots:
774                 x = slot.slot
775                 nim = config.Nims[x]
776                 
777                 # HACK: currently, we can only looptrough to socket A
778
779                 if slot.isCompatible("DVB-S"):
780                         if slot.slot == 0:
781                                 nim.configMode = ConfigSelection(
782                                         choices = {
783                                                 "simple": _("simple"),
784                                                 "advanced": _("advanced"),
785                                                 "nothing": _("nothing connected"),
786                                                 },
787                                         default = "simple")
788                         else:
789                                 nim.configMode = ConfigSelection(
790                                         choices = {
791                                                 "equal": _("equal to Socket A"),
792                                                 "loopthrough": _("loopthrough to socket A"),
793                                                 "nothing": _("nothing connected"),
794                                                 "satposdepends": _("second cable of motorized LNB"),
795                                                 "simple": _("simple"),
796                                                 "advanced": _("advanced")},
797                                         default = "loopthrough")
798
799                         #important - check if just the 2nd one is LT only and the first one is DVB-S
800                         # CHECKME: is this logic correct for >2 slots?
801                         if nim.configMode.value in ["loopthrough", "satposdepends", "equal"]:
802                                 if x == 0: # first one can never be linked to anything
803                                         # reset to simple
804                                         nim.configMode.value = "simple"
805                                         nim.configMode.save()
806                                 else:
807                                         #FIXME: make it better
808                                         for y in nimmgr.nim_slots:
809                                                 if y.slot == 0:
810                                                         if not y.isCompatible("DVB-S"):
811                                                                 # reset to simple
812                                                                 nim.configMode.value = "simple"
813                                                                 nim.configMode.save()
814
815                         nim.diseqcMode = ConfigSelection(
816                                 choices = [
817                                         ("single", _("Single")),
818                                         ("toneburst_a_b", _("Toneburst A/B")),
819                                         ("diseqc_a_b", _("DiSEqC A/B")),
820                                         ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")),
821                                         ("positioner", _("Positioner"))],
822                                 default = "diseqc_a_b")
823
824                         nim.diseqcA = getConfigSatlist(192, nimmgr.satList)
825                         nim.diseqcB = getConfigSatlist(130, nimmgr.satList)
826                         nim.diseqcC = ConfigSatlist(list = nimmgr.satList)
827                         nim.diseqcD = ConfigSatlist(list = nimmgr.satList)
828                         nim.positionerMode = ConfigSelection(
829                                 choices = [
830                                         ("usals", _("USALS")),
831                                         ("manual", _("manual"))],
832                                 default = "usals")
833                         nim.longitude = ConfigFloat(default=[5,100], limits=[(0,359),(0,999)])
834                         nim.longitudeOrientation = ConfigSelection(choices={"east": _("East"), "west": _("West")}, default = "east")
835                         nim.latitude = ConfigFloat(default=[50,767], limits=[(0,359),(0,999)])
836                         nim.latitudeOrientation = ConfigSelection(choices={"north": _("North"), "south": _("South")}, default="north")
837                         nim.turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch")) ], default = "fast")
838                         btime = datetime(1970, 1, 1, 7, 0);
839                         nim.fastTurningBegin = ConfigDateTime(default = mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 900)
840                         etime = datetime(1970, 1, 1, 19, 0);
841                         nim.fastTurningEnd = ConfigDateTime(default = mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 900)
842                         # get other frontends of the same type
843
844                         satNimList = nimmgr.getNimListOfType("DVB-S", slot.slot)
845                         satNimListNames = {}
846
847                         for x in satNimList:
848                                 n = nimmgr.nim_slots[x]
849                                 satNimListNames["%d" % n.slot] = n.friendly_full_description
850
851                         if len(satNimListNames):
852                                 nim.equalTo = ConfigSelection(choices = satNimListNames)
853                                 nim.linkedTo = ConfigSelection(choices = satNimListNames)
854                                 nim.satposDependsTo = ConfigSelection(choices = satNimListNames)
855
856                         # advanced config:
857                         nim.advanced = ConfigSubsection()
858                         nim.advanced.sats = getConfigSatlist(192,nimmgr.satList)
859                         nim.advanced.sat = ConfigSubDict()
860                         lnbs = [("0", "not available")]
861                         for y in range(1, 33):
862                                 lnbs.append((str(y), "LNB " + str(y)))
863
864                         for x in nimmgr.satList:
865                                 nim.advanced.sat[x[0]] = ConfigSubsection()
866                                 nim.advanced.sat[x[0]].voltage = ConfigSelection(choices={"polarization": _("Polarization"), "13V": _("13 V"), "18V": _("18 V")}, default = "polarization")
867                                 nim.advanced.sat[x[0]].tonemode = ConfigSelection(choices={"band": _("Band"), "on": _("On"), "off": _("Off")}, default = "band")
868                                 nim.advanced.sat[x[0]].usals = ConfigYesNo(default=True)
869                                 nim.advanced.sat[x[0]].rotorposition = ConfigInteger(default=1, limits=(1, 255))
870                                 nim.advanced.sat[x[0]].lnb = ConfigSelection(choices = lnbs)
871
872                         csw = [("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))]
873                         for y in range(0, 16):
874                                 csw.append((str(0xF0|y), "Input " + str(y+1)))
875
876                         ucsw = [("0", _("None"))]
877                         for y in range(1, 17):
878                                 ucsw.append((str(y), "Input " + str(y)))
879
880                         nim.advanced.lnb = ConfigSubList()
881                         nim.advanced.lnb.append(ConfigNothing())
882                         for x in range(1, 33):
883                                 nim.advanced.lnb.append(ConfigSubsection())
884                                 nim.advanced.lnb[x].lof = ConfigSelection(choices={"universal_lnb": _("Universal LNB"), "c_band": _("C-Band"), "user_defined": _("User defined")}, default="universal_lnb")
885                                 nim.advanced.lnb[x].lofl = ConfigInteger(default=9750, limits = (0, 99999))
886                                 nim.advanced.lnb[x].lofh = ConfigInteger(default=10600, limits = (0, 99999))
887                                 nim.advanced.lnb[x].threshold = ConfigInteger(default=11700, limits = (0, 99999))
888 #                               nim.advanced.lnb[x].output_12v = ConfigSelection(choices = [("0V", _("0 V")), ("12V", _("12 V"))], default="0V")
889                                 nim.advanced.lnb[x].increased_voltage = ConfigYesNo(default=False)
890                                 nim.advanced.lnb[x].toneburst = ConfigSelection(choices = [("none", _("None")), ("A", _("A")), ("B", _("B"))], default = "none")
891                                 nim.advanced.lnb[x].diseqcMode = ConfigSelection(choices = [("none", _("None")), ("1_0", _("1.0")), ("1_1", _("1.1")), ("1_2", _("1.2"))], default = "none")
892                                 nim.advanced.lnb[x].commitedDiseqcCommand = ConfigSelection(choices = csw)
893                                 nim.advanced.lnb[x].fastDiseqc = ConfigYesNo(default=False)
894                                 nim.advanced.lnb[x].sequenceRepeat = ConfigYesNo(default=False)
895                                 nim.advanced.lnb[x].commandOrder1_0 = ConfigSelection(choices = [("ct", "committed, toneburst"), ("tc", "toneburst, committed")], default = "ct")
896                                 nim.advanced.lnb[x].commandOrder = ConfigSelection(choices = [
897                                                 ("ct", "committed, toneburst"),
898                                                 ("tc", "toneburst, committed"),
899                                                 ("cut", "committed, uncommitted, toneburst"),
900                                                 ("tcu", "toneburst, committed, uncommitted"),
901                                                 ("uct", "uncommitted, committed, toneburst"),
902                                                 ("tuc", "toneburst, uncommitted, commmitted")],
903                                                 default="ct")
904                                 nim.advanced.lnb[x].uncommittedDiseqcCommand = ConfigSelection(choices = ucsw)
905                                 nim.advanced.lnb[x].diseqcRepeats = ConfigSelection(choices = [("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))], default = "none")
906                                 nim.advanced.lnb[x].longitude = ConfigFloat(default = [5,100], limits = [(0,359),(0,999)])
907                                 nim.advanced.lnb[x].longitudeOrientation = ConfigSelection(choices = [("east", _("East")), ("west", _("West"))], default = "east")
908                                 nim.advanced.lnb[x].latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)])
909                                 nim.advanced.lnb[x].latitudeOrientation = ConfigSelection(choices = [("north", _("North")), ("south", _("South"))], default = "north")
910                                 nim.advanced.lnb[x].powerMeasurement = ConfigYesNo(default=True)
911                                 nim.advanced.lnb[x].powerThreshold = ConfigInteger(default=50, limits=(0, 100))
912                                 nim.advanced.lnb[x].turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch"))], default = "fast")
913                                 btime = datetime(1970, 1, 1, 7, 0);
914                                 nim.advanced.lnb[x].fastTurningBegin = ConfigDateTime(default=mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 600)
915                                 etime = datetime(1970, 1, 1, 19, 0);
916                                 nim.advanced.lnb[x].fastTurningEnd = ConfigDateTime(default=mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 600)
917                 elif slot.isCompatible("DVB-C"):
918                         nim.configMode = ConfigSelection(
919                                 choices = {
920                                         "enabled": _("enabled"),
921                                         "nothing": _("nothing connected"),
922                                         },
923                                 default = "enabled")
924                         list = [ ]
925                         n = 0
926                         for x in nimmgr.cablesList:
927                                 list.append((str(n), x[0]))
928                                 n += 1
929                         nim.cable = ConfigSubsection()
930                         possible_scan_types = [("bands", _("Frequency bands")), ("steps", _("Frequency steps"))]
931                         if n:
932                                 possible_scan_types.append(("provider", _("Provider")))
933                         nim.cable.scan_type = ConfigSelection(default = "bands", choices = possible_scan_types)
934                         nim.cable.scan_provider = ConfigSelection(default = "0", choices = list)
935                         nim.cable.scan_band_EU_VHF_I = ConfigYesNo(default = True)
936                         nim.cable.scan_band_EU_MID = ConfigYesNo(default = True)
937                         nim.cable.scan_band_EU_VHF_III = ConfigYesNo(default = True)
938                         nim.cable.scan_band_EU_UHF_IV = ConfigYesNo(default = True)
939                         nim.cable.scan_band_EU_UHF_V = ConfigYesNo(default = True)
940                         nim.cable.scan_band_EU_SUPER = ConfigYesNo(default = True)
941                         nim.cable.scan_band_EU_HYPER = ConfigYesNo(default = True)
942                         nim.cable.scan_band_US_LOW = ConfigYesNo(default = False)
943                         nim.cable.scan_band_US_MID = ConfigYesNo(default = False)
944                         nim.cable.scan_band_US_HIGH = ConfigYesNo(default = False)
945                         nim.cable.scan_band_US_SUPER = ConfigYesNo(default = False)
946                         nim.cable.scan_band_US_HYPER = ConfigYesNo(default = False)
947                         nim.cable.scan_frequency_steps = ConfigInteger(default = 1000, limits = (1000, 10000))
948                         nim.cable.scan_mod_qam16 = ConfigYesNo(default = False)
949                         nim.cable.scan_mod_qam32 = ConfigYesNo(default = False)
950                         nim.cable.scan_mod_qam64 = ConfigYesNo(default = True)
951                         nim.cable.scan_mod_qam128 = ConfigYesNo(default = False)
952                         nim.cable.scan_mod_qam256 = ConfigYesNo(default = True)
953                         nim.cable.scan_sr_6900 = ConfigYesNo(default = True)
954                         nim.cable.scan_sr_6875 = ConfigYesNo(default = True)
955                         nim.cable.scan_sr_ext1 = ConfigInteger(default = 0, limits = (0, 7230))
956                         nim.cable.scan_sr_ext2 = ConfigInteger(default = 0, limits = (0, 7230))
957                 elif slot.isCompatible("DVB-T"):
958                         nim.configMode = ConfigSelection(
959                                 choices = {
960                                         "enabled": _("enabled"),
961                                         "nothing": _("nothing connected"),
962                                         },
963                                 default = "enabled")
964                         list = []
965                         n = 0
966                         for x in nimmgr.terrestrialsList:
967                                 list.append((str(n), x[0]))
968                                 n += 1
969                         nim.terrestrial = ConfigSelection(choices = list)
970                         nim.terrestrial_5V = ConfigOnOff()
971                 else:
972                         nim.configMode = ConfigSelection(choices = { "nothing": _("disabled") }, default="nothing");
973                         print "pls add support for this frontend type!"         
974 #                       assert False
975
976         nimmgr.sec = SecConfigure(nimmgr)
977
978 nimmanager = NimManager()