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