png cleanup by nemesis, source changes.
[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, eDVBDB
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                         if slot.type is not None:
109                                 used_nim_slots.append((slot.slot, slot.description, slot.config.configMode.value != "nothing" and True or False))
110                 eDVBResourceManager.getInstance().setFrontendSlotInformations(used_nim_slots)
111
112                 for slot in nim_slots:
113                         x = slot.slot
114                         nim = slot.config
115                         if slot.isCompatible("DVB-S"):
116                                 # save what nim we link to/are equal to/satposdepends to.
117                                 # this is stored in the *value* (not index!) of the config list
118                                 if nim.configMode.value == "equal":
119                                         self.equal[int(nim.equalTo.value)]=x
120                                 elif nim.configMode.value == "loopthrough":
121                                         self.linkNIMs(sec, x, int(nim.linkedTo.value))
122                                         self.linked[int(nim.linkedTo.value)]=x
123                                 elif nim.configMode.value == "satposdepends":
124                                         self.setSatposDepends(sec, x, int(nim.satposDependsTo.value))
125                                         self.satposdepends[int(nim.satposDependsTo.value)]=x
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 #                               tflags = int(attrs.get('flags', '0'))
429 #                               self.satellites[tpos] = tname
430 #                               self.satList.append( (tpos, tname, tflags) )
431 #                               self.parsedSat = int(tpos)
432 #                       elif (name == "transponder"):
433 #                               modulation = int(attrs.get('modulation',"1")) # QPSK default
434 #                               system = int(attrs.get('system',"0")) # DVB-S default
435 #                               freq = int(attrs.get('frequency',""))
436 #                               sr = int(attrs.get('symbol_rate',""))
437 #                               pol = int(attrs.get('polarization',""))
438 #                               fec = int(attrs.get('fec_inner',"0")) # AUTO default
439 #                               if self.parsedSat in self.transponders:
440 #                                       pass
441 #                               else:
442 #                                       self.transponders[self.parsedSat] = [ ]
443 #
444 #                               self.transponders[self.parsedSat].append((0, freq, sr, pol, fec, system, modulation))
445
446 #       class parseCables(ContentHandler):
447 #               def __init__(self, cablesList, transponders):
448 #                       self.isPointsElement, self.isReboundsElement = 0, 0
449 #                       self.cablesList = cablesList
450 #                       for x in self.cablesList:
451 #                               self.cablesList.remove(x)
452 #                       self.transponders = transponders
453 #       
454 #               def startElement(self, name, attrs):
455 #                       if (name == "cable"):
456 #                               #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
457 #                               tname = attrs.get('name',"").encode("UTF-8")
458 #                               tflags = int(attrs.get('flags', '0'))
459 #                               self.cablesList.append((tname, tflags))
460 #                               self.parsedCab = tname
461 #                       elif (name == "transponder"):
462 #                               freq = int(attrs.get('frequency',""))
463 #                               while freq > 999999:
464 #                                       freq /= 10
465 #                               sr = int(attrs.get('symbol_rate',"0"))
466 #                               mod = int(attrs.get('modulation',"3")) # QAM64 default
467 #                               fec = int(attrs.get('fec_inner',"0")) # AUTO default
468 #                               if self.parsedCab in self.transponders:
469 #                                       pass
470 #                               else:
471 #                                       self.transponders[self.parsedCab] = [ ]
472 #                               self.transponders[self.parsedCab].append((1, freq, sr, mod, fec))
473 #
474 #       class parseTerrestrials(ContentHandler):
475 #               def __init__(self, terrestrialsList, transponders):
476 #                       self.isPointsElement, self.isReboundsElement = 0, 0
477 #                       self.terrestrialsList = terrestrialsList
478 #                       self.transponders = transponders
479 #       
480 #               def startElement(self, name, attrs):
481 #                       if (name == "terrestrial"):
482 #                               #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
483 #                               tname = attrs.get('name',"").encode("UTF-8")
484 #                               tflags = int(attrs.get('flags', '0'))
485 #                               self.terrestrialsList.append((tname, tflags))
486 #                               self.parsedTer = str(tname)
487 #                       elif (name == "transponder"):
488 #                               # TODO finish this!
489 #                               freq = int(attrs.get('centre_frequency',""))
490 #                               bw = int(attrs.get('bandwidth',"3")) # AUTO
491 #                               const = int(attrs.get('constellation',"1")) # AUTO
492 #                               crh = int(attrs.get('code_rate_hp',"5")) # AUTO
493 #                               if crh > 5: # our terrestrial.xml is buggy... 6 for AUTO
494 #                                       crh = 5
495 #                               crl = int(attrs.get('code_rate_lp',"5")) # AUTO
496 #                               if crl > 5: # our terrestrial.xml is buggy... 6 for AUTO
497 #                                       crl = 5
498 #                               guard = int(attrs.get('guard_interval',"4")) # AUTO
499 #                               transm = int(attrs.get('transmission_mode',"2")) # AUTO
500 #                               hierarchy = int(attrs.get('hierarchy_information',"4")) # AUTO
501 #                               inv = int(attrs.get('inversion',"2")) # AUTO
502 #                               if self.parsedTer in self.transponders:
503 #                                       pass
504 #                               else:
505 #                                       self.transponders[self.parsedTer] = [ ]
506 #
507 #                               self.transponders[self.parsedTer].append((2, freq, bw, const, crh, crl, guard, transm, hierarchy, inv))
508
509         def getTransponders(self, pos):
510                 if self.transponders.has_key(pos):
511                         return self.transponders[pos]
512                 else:
513                         return []
514
515         def getTranspondersCable(self, nim):
516                 nimConfig = config.Nims[nim]
517                 if nimConfig.configMode.value != "nothing" and nimConfig.cable.scan_type.value == "provider":
518                         return self.transponderscable[self.cablesList[nimConfig.cable.scan_provider.index][0]]
519                 return [ ]
520
521         def getTranspondersTerrestrial(self, region):
522                 return self.transpondersterrestrial[region]
523         
524         def getCableDescription(self, nim):
525                 return self.cablesList[config.Nims[nim].scan_provider.index][0]
526
527         def getCableFlags(self, nim):
528                 return self.cablesList[config.Nims[nim].scan_provider.index][1]
529
530         def getTerrestrialDescription(self, nim):
531                 return self.terrestrialsList[config.Nims[nim].terrestrial.index][0]
532
533         def getTerrestrialFlags(self, nim):
534                 return self.terrestrialsList[config.Nims[nim].terrestrial.index][1]
535
536         def getConfiguredSats(self):
537                 return self.sec.getSatList()
538
539         def getSatDescription(self, pos):
540                 return self.satellites[pos]
541
542         def readTransponders(self):
543                 # read initial networks from file. we only read files which we are interested in,
544                 # which means only these where a compatible tuner exists.
545                 self.satellites = { }
546                 self.transponders = { }
547                 self.transponderscable = { }
548                 self.transpondersterrestrial = { }
549                 db = eDVBDB.getInstance()
550
551 #               parser = make_parser()
552                 if self.hasNimType("DVB-S"):
553                         print "Reading satellites.xml"
554 #                       satHandler = self.parseSats(self.satList, self.satellites, self.transponders)
555 #                       parser.setContentHandler(satHandler)
556 #                       parser.parse('/etc/tuxbox/satellites.xml')
557                         db.readSatellites(self.satList, self.satellites, self.transponders)
558 #                       print "SATLIST", self.satList
559 #                       print "SATS", self.satellites
560 #                       print "TRANSPONDERS", self.transponders
561
562                 if self.hasNimType("DVB-C"):
563                         print "Reading cables.xml"
564 #                       cabHandler = self.parseCables(self.cablesList, self.transponderscable)
565 #                       parser.setContentHandler(cabHandler)
566 #                       parser.parse('/etc/tuxbox/cables.xml')
567                         db.readCables(self.cablesList, self.transponderscable)
568 #                       print "CABLIST", self.cablesList
569 #                       print "TRANSPONDERS", self.transponders
570
571                 if self.hasNimType("DVB-T"):
572                         print "Reading terrestrial.xml"
573 #                       terHandler = self.parseTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
574 #                       parser.setContentHandler(terHandler)
575 #                       parser.parse('/etc/tuxbox/terrestrial.xml')
576                         db.readTerrestrials(self.terrestrialsList, self.transpondersterrestrial)
577 #                       print "TERLIST", self.terrestrialsList
578 #                       print "TRANSPONDERS", self.transpondersterrestrial
579
580         def enumerateNIMs(self):
581                 # enum available NIMs. This is currently very dreambox-centric and uses the /proc/bus/nim_sockets interface.
582                 # the result will be stored into nim_slots.
583                 # the content of /proc/bus/nim_sockets looks like:
584                 # NIM Socket 0:
585                 #          Type: DVB-S
586                 #          Name: BCM4501 DVB-S2 NIM (internal)
587                 # NIM Socket 1:
588                 #          Type: DVB-S
589                 #          Name: BCM4501 DVB-S2 NIM (internal)
590                 # NIM Socket 2:
591                 #          Type: DVB-T
592                 #          Name: Philips TU1216
593                 # NIM Socket 3:
594                 #          Type: DVB-S
595                 #          Name: Alps BSBE1 702A
596                 
597                 #
598                 # Type will be either "DVB-S", "DVB-S2", "DVB-T", "DVB-C" or None.
599
600                 # nim_slots is an array which has exactly one entry for each slot, even for empty ones.
601                 self.nim_slots = [ ]
602
603                 nimfile = tryOpen("/proc/bus/nim_sockets")
604
605                 if nimfile is None:
606                         return
607
608                 current_slot = None
609
610                 entries = {}
611                 for line in nimfile.readlines():
612                         if line == "":
613                                 break
614                         if line.strip().startswith("NIM Socket"):
615                                 parts = line.strip().split(" ")
616                                 current_slot = int(parts[2][:-1])
617                                 entries[current_slot] = {}
618                         elif line.strip().startswith("Type:"):
619                                 entries[current_slot]["type"] = str(line.strip()[6:])
620                         elif line.strip().startswith("Name:"):
621                                 entries[current_slot]["name"] = str(line.strip()[6:])
622                         elif line.strip().startswith("empty"):
623                                 entries[current_slot]["type"] = None
624                                 entries[current_slot]["name"] = _("N/A")
625                 nimfile.close()
626                 
627                 for id, entry in entries.items():
628                         if not (entry.has_key("name") and entry.has_key("type")):
629                                 entry["name"] =  _("N/A")
630                                 entry["type"] = None
631                         self.nim_slots.append(NIM(slot = id, description = entry["name"], type = entry["type"]))
632
633         def hasNimType(self, chktype):
634                 for slot in self.nim_slots:
635                         if slot.isCompatible(chktype):
636                                 return True
637                 return False
638
639         def getNimListOfType(self, type, exception = -1):
640                 # returns a list of indexes for NIMs compatible to the given type, except for 'exception'
641                 list = []
642                 for x in self.nim_slots:
643                         if x.isCompatible(type) and x.slot != exception:
644                                 list.append(x.slot)
645                 return list
646
647         def __init__(self):
648                 self.satList = [ ]
649                 self.cablesList = []
650                 self.terrestrialsList = []
651                 self.enumerateNIMs()
652                 self.readTransponders()
653                 InitNimManager(self)    #init config stuff
654
655         # get a list with the friendly full description
656         def nimList(self):
657                 list = [ ]
658                 for slot in self.nim_slots:
659                         list.append(slot.friendly_full_description)
660                 return list
661
662         def getSatList(self):
663                 return self.satList
664
665         def getSatListForNim(self, slotid):
666                 list = []
667                 if self.nim_slots[slotid].isCompatible("DVB-S"):
668                         #print "slotid:", slotid
669
670                         #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.index]
671                         #print "diseqcA:", config.Nims[slotid].diseqcA.value
672                         configMode = config.Nims[slotid].configMode.value
673
674                         if configMode == "equal":
675                                 slotid=0 #FIXME add handling for more than two tuners !!!
676                                 configMode = config.Nims[slotid].configMode.value
677
678                         if configMode == "simple":
679                                 dm = config.Nims[slotid].diseqcMode.value
680                                 if dm in ["single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
681                                         list.append(self.satList[config.Nims[slotid].diseqcA.index])
682                                 if dm in ["toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
683                                         list.append(self.satList[config.Nims[slotid].diseqcB.index])
684                                 if dm == "diseqc_a_b_c_d":
685                                         list.append(self.satList[config.Nims[slotid].diseqcC.index])
686                                         list.append(self.satList[config.Nims[slotid].diseqcD.index])
687                                 if dm == "positioner":
688                                         for x in self.satList:
689                                                 list.append(x)
690                         elif configMode == "advanced":
691                                 for x in self.satList:
692                                         if int(config.Nims[slotid].advanced.sat[x[0]].lnb.value) != 0:
693                                                 list.append(x)
694                 
695                 return list
696
697         def getRotorSatListForNim(self, slotid):
698                 list = []
699                 if self.nim_slots[slotid].isCompatible("DVB-S"):
700                         #print "slotid:", slotid
701
702                         #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
703                         #print "diseqcA:", config.Nims[slotid].diseqcA.value
704                         configMode = config.Nims[slotid].configMode.value
705                         if configMode == "simple":
706                                 if config.Nims[slotid].diseqcMode.value == "positioner":
707                                         for x in self.satList:
708                                                 list.append(x)
709                         elif configMode == "advanced":
710                                 for x in self.satList:
711                                         nim = config.Nims[slotid]
712                                         lnbnum = int(nim.advanced.sat[x[0]].lnb.value)
713                                         if lnbnum != 0:
714                                                 lnb = nim.advanced.lnb[lnbnum]
715                                                 if lnb.diseqcMode.value == "1_2":
716                                                         list.append(x)
717                 return list
718
719 def InitSecParams():
720         config.sec = ConfigSubsection()
721
722         x = ConfigInteger(default=15, limits = (0, 9999))
723         x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_CONT_TONE, configElement.value))
724         config.sec.delay_after_continuous_tone_change = x
725
726         x = ConfigInteger(default=10, limits = (0, 9999))
727         x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_VOLTAGE_CHANGE, configElement.value))
728         config.sec.delay_after_final_voltage_change = x
729
730         x = ConfigInteger(default=120, limits = (0, 9999))
731         x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_DISEQC_REPEATS, configElement.value))
732         config.sec.delay_between_diseqc_repeats = x
733
734         x = ConfigInteger(default=50, limits = (0, 9999))
735         x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_LAST_DISEQC_CMD, configElement.value))
736         config.sec.delay_after_last_diseqc_command = x
737
738         x = ConfigInteger(default=50, limits = (0, 9999))
739         x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value))
740         config.sec.delay_after_toneburst = x
741
742         x = ConfigInteger(default=200, limits = (0, 9999))
743         x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS, configElement.value))
744         config.sec.delay_after_enable_voltage_before_switch_command = x
745
746         x = ConfigInteger(default=700, limits = (0, 9999))
747         x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_BETWEEN_SWITCH_AND_MOTOR_CMD, configElement.value))
748         config.sec.delay_between_switch_and_motor_command = x
749
750         x = ConfigInteger(default=150, limits = (0, 9999))
751         x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MEASURE_IDLE_INPUTPOWER, configElement.value))
752         config.sec.delay_after_voltage_change_before_measure_idle_inputpower = x
753
754         x = ConfigInteger(default=750, limits = (0, 9999))
755         x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_MOTOR_CMD, configElement.value))
756         config.sec.delay_after_enable_voltage_before_motor_command = x
757
758         x = ConfigInteger(default=150, limits = (0, 9999))
759         x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_MOTOR_STOP_CMD, configElement.value))
760         config.sec.delay_after_motor_stop_command = x
761
762         x = ConfigInteger(default=150, limits = (0, 9999))
763         x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MOTOR_CMD, configElement.value))
764         config.sec.delay_after_voltage_change_before_motor_command = x
765
766         x = ConfigInteger(default=120, limits = (0, 9999))
767         x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_RUNNING_TIMEOUT, configElement.value))
768         config.sec.motor_running_timeout = x
769
770         x = ConfigInteger(default=1, limits = (0, 5))
771         x.addNotifier(lambda configElement: secClass.setParam(secClass.MOTOR_COMMAND_RETRIES, configElement.value))
772         config.sec.motor_command_retries = x
773
774         x = ConfigInteger(default=20, limits = (0, 9999))
775         x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS, configElement.value))
776         config.sec.delay_after_change_voltage_before_switch_command = x
777
778 # TODO add support for satpos depending nims to advanced nim configuration
779 # so a second/third/fourth cable from a motorized lnb can used behind a
780 # diseqc 1.0 / diseqc 1.1 / toneburst switch
781 # the C(++) part should can handle this
782 # the configElement should be only visible when diseqc 1.2 is disabled
783
784 def InitNimManager(nimmgr):
785         InitSecParams()
786
787         config.Nims = ConfigSubList()
788         for x in range(len(nimmgr.nim_slots)):
789                 config.Nims.append(ConfigSubsection())
790
791         for slot in nimmgr.nim_slots:
792                 x = slot.slot
793                 nim = config.Nims[x]
794                 
795                 # HACK: currently, we can only looptrough to socket A
796
797                 if slot.isCompatible("DVB-S"):
798                         if slot.slot == 0:
799                                 nim.configMode = ConfigSelection(
800                                         choices = {
801                                                 "simple": _("simple"),
802                                                 "advanced": _("advanced"),
803                                                 "nothing": _("nothing connected"),
804                                                 },
805                                         default = "simple")
806                         else:
807                                 nim.configMode = ConfigSelection(
808                                         choices = {
809                                                 "equal": _("equal to Socket A"),
810                                                 "loopthrough": _("loopthrough to socket A"),
811                                                 "nothing": _("nothing connected"),
812                                                 "satposdepends": _("second cable of motorized LNB"),
813                                                 "simple": _("simple"),
814                                                 "advanced": _("advanced")},
815                                         default = "loopthrough")
816
817                         #important - check if just the 2nd one is LT only and the first one is DVB-S
818                         # CHECKME: is this logic correct for >2 slots?
819                         if nim.configMode.value in ["loopthrough", "satposdepends", "equal"]:
820                                 if x == 0: # first one can never be linked to anything
821                                         # reset to simple
822                                         nim.configMode.value = "simple"
823                                         nim.configMode.save()
824                                 else:
825                                         #FIXME: make it better
826                                         for y in nimmgr.nim_slots:
827                                                 if y.slot == 0:
828                                                         if not y.isCompatible("DVB-S"):
829                                                                 # reset to simple
830                                                                 nim.configMode.value = "simple"
831                                                                 nim.configMode.save()
832
833                         nim.diseqcMode = ConfigSelection(
834                                 choices = [
835                                         ("single", _("Single")),
836                                         ("toneburst_a_b", _("Toneburst A/B")),
837                                         ("diseqc_a_b", _("DiSEqC A/B")),
838                                         ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")),
839                                         ("positioner", _("Positioner"))],
840                                 default = "diseqc_a_b")
841
842                         nim.diseqcA = getConfigSatlist(192, nimmgr.satList)
843                         nim.diseqcB = getConfigSatlist(130, nimmgr.satList)
844                         nim.diseqcC = ConfigSatlist(list = nimmgr.satList)
845                         nim.diseqcD = ConfigSatlist(list = nimmgr.satList)
846                         nim.positionerMode = ConfigSelection(
847                                 choices = [
848                                         ("usals", _("USALS")),
849                                         ("manual", _("manual"))],
850                                 default = "usals")
851                         nim.longitude = ConfigFloat(default=[5,100], limits=[(0,359),(0,999)])
852                         nim.longitudeOrientation = ConfigSelection(choices={"east": _("East"), "west": _("West")}, default = "east")
853                         nim.latitude = ConfigFloat(default=[50,767], limits=[(0,359),(0,999)])
854                         nim.latitudeOrientation = ConfigSelection(choices={"north": _("North"), "south": _("South")}, default="north")
855                         nim.powerMeasurement = ConfigYesNo(default=True)
856                         nim.powerThreshold = ConfigInteger(default=50, limits=(0, 100))
857                         nim.turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch")) ], default = "fast")
858                         btime = datetime(1970, 1, 1, 7, 0);
859                         nim.fastTurningBegin = ConfigDateTime(default = mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 900)
860                         etime = datetime(1970, 1, 1, 19, 0);
861                         nim.fastTurningEnd = ConfigDateTime(default = mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 900)
862                         # get other frontends of the same type
863
864                         satNimList = nimmgr.getNimListOfType("DVB-S", slot.slot)
865                         satNimListNames = {}
866
867                         for x in satNimList:
868                                 n = nimmgr.nim_slots[x]
869                                 satNimListNames["%d" % n.slot] = n.friendly_full_description
870
871                         if len(satNimListNames):
872                                 nim.equalTo = ConfigSelection(choices = satNimListNames)
873                                 nim.linkedTo = ConfigSelection(choices = satNimListNames)
874                                 nim.satposDependsTo = ConfigSelection(choices = satNimListNames)
875
876                         # advanced config:
877                         nim.advanced = ConfigSubsection()
878                         nim.advanced.sats = getConfigSatlist(192,nimmgr.satList)
879                         nim.advanced.sat = ConfigSubDict()
880                         lnbs = [("0", "not available")]
881                         for y in range(1, 33):
882                                 lnbs.append((str(y), "LNB " + str(y)))
883
884                         for x in nimmgr.satList:
885                                 nim.advanced.sat[x[0]] = ConfigSubsection()
886                                 nim.advanced.sat[x[0]].voltage = ConfigSelection(choices={"polarization": _("Polarization"), "13V": _("13 V"), "18V": _("18 V")}, default = "polarization")
887                                 nim.advanced.sat[x[0]].tonemode = ConfigSelection(choices={"band": _("Band"), "on": _("On"), "off": _("Off")}, default = "band")
888                                 nim.advanced.sat[x[0]].usals = ConfigYesNo(default=True)
889                                 nim.advanced.sat[x[0]].rotorposition = ConfigInteger(default=1, limits=(1, 255))
890                                 nim.advanced.sat[x[0]].lnb = ConfigSelection(choices = lnbs)
891
892                         csw = [("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))]
893                         for y in range(0, 16):
894                                 csw.append((str(0xF0|y), "Input " + str(y+1)))
895
896                         ucsw = [("0", _("None"))]
897                         for y in range(1, 17):
898                                 ucsw.append((str(y), "Input " + str(y)))
899
900                         nim.advanced.lnb = ConfigSubList()
901                         nim.advanced.lnb.append(ConfigNothing())
902                         for x in range(1, 33):
903                                 nim.advanced.lnb.append(ConfigSubsection())
904                                 nim.advanced.lnb[x].lof = ConfigSelection(choices={"universal_lnb": _("Universal LNB"), "c_band": _("C-Band"), "user_defined": _("User defined")}, default="universal_lnb")
905                                 nim.advanced.lnb[x].lofl = ConfigInteger(default=9750, limits = (0, 99999))
906                                 nim.advanced.lnb[x].lofh = ConfigInteger(default=10600, limits = (0, 99999))
907                                 nim.advanced.lnb[x].threshold = ConfigInteger(default=11700, limits = (0, 99999))
908 #                               nim.advanced.lnb[x].output_12v = ConfigSelection(choices = [("0V", _("0 V")), ("12V", _("12 V"))], default="0V")
909                                 nim.advanced.lnb[x].increased_voltage = ConfigYesNo(default=False)
910                                 nim.advanced.lnb[x].toneburst = ConfigSelection(choices = [("none", _("None")), ("A", _("A")), ("B", _("B"))], default = "none")
911                                 nim.advanced.lnb[x].diseqcMode = ConfigSelection(choices = [("none", _("None")), ("1_0", _("1.0")), ("1_1", _("1.1")), ("1_2", _("1.2"))], default = "none")
912                                 nim.advanced.lnb[x].commitedDiseqcCommand = ConfigSelection(choices = csw)
913                                 nim.advanced.lnb[x].fastDiseqc = ConfigYesNo(default=False)
914                                 nim.advanced.lnb[x].sequenceRepeat = ConfigYesNo(default=False)
915                                 nim.advanced.lnb[x].commandOrder1_0 = ConfigSelection(choices = [("ct", "committed, toneburst"), ("tc", "toneburst, committed")], default = "ct")
916                                 nim.advanced.lnb[x].commandOrder = ConfigSelection(choices = [
917                                                 ("ct", "committed, toneburst"),
918                                                 ("tc", "toneburst, committed"),
919                                                 ("cut", "committed, uncommitted, toneburst"),
920                                                 ("tcu", "toneburst, committed, uncommitted"),
921                                                 ("uct", "uncommitted, committed, toneburst"),
922                                                 ("tuc", "toneburst, uncommitted, commmitted")],
923                                                 default="ct")
924                                 nim.advanced.lnb[x].uncommittedDiseqcCommand = ConfigSelection(choices = ucsw)
925                                 nim.advanced.lnb[x].diseqcRepeats = ConfigSelection(choices = [("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))], default = "none")
926                                 nim.advanced.lnb[x].longitude = ConfigFloat(default = [5,100], limits = [(0,359),(0,999)])
927                                 nim.advanced.lnb[x].longitudeOrientation = ConfigSelection(choices = [("east", _("East")), ("west", _("West"))], default = "east")
928                                 nim.advanced.lnb[x].latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)])
929                                 nim.advanced.lnb[x].latitudeOrientation = ConfigSelection(choices = [("north", _("North")), ("south", _("South"))], default = "north")
930                                 nim.advanced.lnb[x].powerMeasurement = ConfigYesNo(default=True)
931                                 nim.advanced.lnb[x].powerThreshold = ConfigInteger(default=50, limits=(0, 100))
932                                 nim.advanced.lnb[x].turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch"))], default = "fast")
933                                 btime = datetime(1970, 1, 1, 7, 0);
934                                 nim.advanced.lnb[x].fastTurningBegin = ConfigDateTime(default=mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 600)
935                                 etime = datetime(1970, 1, 1, 19, 0);
936                                 nim.advanced.lnb[x].fastTurningEnd = ConfigDateTime(default=mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 600)
937                 elif slot.isCompatible("DVB-C"):
938                         nim.configMode = ConfigSelection(
939                                 choices = {
940                                         "enabled": _("enabled"),
941                                         "nothing": _("nothing connected"),
942                                         },
943                                 default = "enabled")
944                         list = [ ]
945                         n = 0
946                         for x in nimmgr.cablesList:
947                                 list.append((str(n), x[0]))
948                                 n += 1
949                         nim.cable = ConfigSubsection()
950                         possible_scan_types = [("bands", _("Frequency bands")), ("steps", _("Frequency steps"))]
951                         if n:
952                                 possible_scan_types.append(("provider", _("Provider")))
953                         nim.cable.scan_type = ConfigSelection(default = "bands", choices = possible_scan_types)
954                         nim.cable.scan_provider = ConfigSelection(default = "0", choices = list)
955                         nim.cable.scan_band_EU_VHF_I = ConfigYesNo(default = True)
956                         nim.cable.scan_band_EU_MID = ConfigYesNo(default = True)
957                         nim.cable.scan_band_EU_VHF_III = ConfigYesNo(default = True)
958                         nim.cable.scan_band_EU_UHF_IV = ConfigYesNo(default = True)
959                         nim.cable.scan_band_EU_UHF_V = ConfigYesNo(default = True)
960                         nim.cable.scan_band_EU_SUPER = ConfigYesNo(default = True)
961                         nim.cable.scan_band_EU_HYPER = ConfigYesNo(default = True)
962                         nim.cable.scan_band_US_LOW = ConfigYesNo(default = False)
963                         nim.cable.scan_band_US_MID = ConfigYesNo(default = False)
964                         nim.cable.scan_band_US_HIGH = ConfigYesNo(default = False)
965                         nim.cable.scan_band_US_SUPER = ConfigYesNo(default = False)
966                         nim.cable.scan_band_US_HYPER = ConfigYesNo(default = False)
967                         nim.cable.scan_frequency_steps = ConfigInteger(default = 1000, limits = (1000, 10000))
968                         nim.cable.scan_mod_qam16 = ConfigYesNo(default = False)
969                         nim.cable.scan_mod_qam32 = ConfigYesNo(default = False)
970                         nim.cable.scan_mod_qam64 = ConfigYesNo(default = True)
971                         nim.cable.scan_mod_qam128 = ConfigYesNo(default = False)
972                         nim.cable.scan_mod_qam256 = ConfigYesNo(default = True)
973                         nim.cable.scan_sr_6900 = ConfigYesNo(default = True)
974                         nim.cable.scan_sr_6875 = ConfigYesNo(default = True)
975                         nim.cable.scan_sr_ext1 = ConfigInteger(default = 0, limits = (0, 7230))
976                         nim.cable.scan_sr_ext2 = ConfigInteger(default = 0, limits = (0, 7230))
977                 elif slot.isCompatible("DVB-T"):
978                         nim.configMode = ConfigSelection(
979                                 choices = {
980                                         "enabled": _("enabled"),
981                                         "nothing": _("nothing connected"),
982                                         },
983                                 default = "enabled")
984                         list = []
985                         n = 0
986                         for x in nimmgr.terrestrialsList:
987                                 list.append((str(n), x[0]))
988                                 n += 1
989                         nim.terrestrial = ConfigSelection(choices = list)
990                         nim.terrestrial_5V = ConfigOnOff()
991                 else:
992                         nim.configMode = ConfigSelection(choices = { "nothing": _("disabled") }, default="nothing");
993                         print "pls add support for this frontend type!"         
994 #                       assert False
995
996         nimmgr.sec = SecConfigure(nimmgr)
997
998 nimmanager = NimManager()