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