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