replaced satconfig by nimselection
[enigma2.git] / lib / python / Components / NimManager.py
1 from config import config       #global config instance
2
3 from config import configElement
4 from config import ConfigSubsection
5 from config import ConfigSlider
6 from config import configSelection
7
8 class nimSlot:
9         def __init__(self, slotid, nimtype, name):
10                 self.slotid = slotid
11                 self.nimType = nimtype
12                 self.name = name
13
14 class NimManager:
15         def getNimType(self, slotID):
16                 #FIXME get it from /proc
17                 if slotID == 0:
18                         return self.nimType["DVB-S"]
19                 else:
20                         return self.nimType["empty/unknown"]
21
22         def getNimName(self, slotID):
23                 #FIXME get it from /proc
24                 return "Alps BSBE1"
25
26         def getNimSocketCount(self):
27                 #FIXME get it from /proc
28                 return 2
29
30         def getConfigPrefix(self, slotid):
31                 return "config.Nim" + ("A","B","C","D")[slotid] + "."
32                         
33         def __init__(self):
34                 #use as enum
35                 self.nimType = {                "empty/unknown": -1,
36                                                                                                 "DVB-S": 0,
37                                                                                                 "DVB-C": 1,
38                                                                                                 "DVB-T": 2}
39                                                                                                 
40                 self.nimCount = self.getNimSocketCount()
41
42                 self.nimslots = [ ]
43                 x = 0
44                 while x < self.nimCount:
45                         tType = self.getNimType(x)
46                         tName = self.getNimName(x)
47                         tNim = nimSlot(x, tType, tName)
48                         self.nimslots.append(tNim)
49                         x += 1
50                 
51                 InitNimManager(self)    #init config stuff
52
53         def nimList(self):
54                 list = [ ]
55                 for slot in self.nimslots:
56                         nimText = "Socket " + ("A", "B", "C", "D")[slot.slotid] + ": "
57                         if slot.nimType == -1:
58                                 nimText += "empty/unknown"
59                         else:
60                                 nimText += slot.name + " ("     
61                                 nimText += ("DVB-S", "DVB-C", "DVB-T")[slot.nimType] + ")"
62                         list.append((nimText, slot))
63                 return list
64
65 def InitNimManager(nimmgr):
66         config.Nims = [ConfigSubsection()] * nimmgr.nimCount
67
68         for slot in nimmgr.nimslots:
69                 x = slot.slotid
70                 cname = nimmgr.getConfigPrefix(x)
71                 
72                 if slot.nimType == nimmgr.nimType["DVB-S"]:
73                         config.Nims[x].configMode = configElement(cname + "configMode",configSelection, 0, ("Simple", "Advanced"));
74                         config.Nims[x].diseqcMode = configElement(cname + "diseqcMode",configSelection, 0, ("Single", "Toneburst A/B", "DiSEqC A/B"));
75                         config.Nims[x].diseqcMode = configElement(cname + "toneburstA",configSelection, 0, ("Astra", "Hotbird"));
76                         config.Nims[x].diseqcMode = configElement(cname + "toneburstB",configSelection, 0, ("Astra", "Hotbird"));
77                         config.Nims[x].diseqcMode = configElement(cname + "diseqcA",configSelection, 0, ("Astra", "Hotbird"));
78                         config.Nims[x].diseqcMode = configElement(cname + "diseqcB",configSelection, 0, ("Astra", "Hotbird"));
79                         config.Nims[x].diseqcMode = configElement(cname + "diseqcC",configSelection, 0, ("Astra", "Hotbird"));
80                         config.Nims[x].diseqcMode = configElement(cname + "diseqcD",configSelection, 0, ("Astra", "Hotbird"));
81                 else:
82                         print "pls add support for this frontend type!"         
83
84         #def nimConfig
85
86   #def inputDevicesRepeatChanged(configElement):
87   #  iDevices.setRepeat(configElement.value);
88
89   #def inputDevicesDelayChanged(configElement):
90   #  iDevices.setDelay(configElement.value);
91
92   # this will call the "setup-val" initial
93   #config.inputDevices.repeat.addNotifier(inputDevicesRepeatChanged);
94   #config.inputDevices.delay.addNotifier(inputDevicesDelayChanged);
95
96 nimmanager = NimManager()