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