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