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