1 from Screen import Screen
2 from Components.ActionMap import NumberActionMap
3 from Components.ActionMap import ActionMap
4 from Components.ConfigList import ConfigList
5 from Components.config import *
6 from Components.MenuList import MenuList
7 from Components.NimManager import nimmanager
8 from Components.config import getConfigListEntry
10 class NimSetup(Screen):
11 def createSimpleSetup(self, nim, list, mode):
12 if mode == 0: #single Sat
13 list.append(getConfigListEntry(_("Satellite"), config.Nims[nim.slotid].diseqcA))
15 list.append(getConfigListEntry(_("Port A"), config.Nims[nim.slotid].diseqcA))
17 if mode >= 1: # > 1 Sats
18 list.append(getConfigListEntry(_("Port B"), config.Nims[nim.slotid].diseqcB))
19 if mode >= 3: # > 2 Sats
20 list.append(getConfigListEntry(_("Port C"), config.Nims[nim.slotid].diseqcC))
21 list.append(getConfigListEntry(_("Port D"), config.Nims[nim.slotid].diseqcD))
23 def createPositionerSetup(self, nim, list):
24 list.append(getConfigListEntry(_("Positioner mode"), config.Nims[nim.slotid].positionerMode))
25 if (currentConfigSelectionElement(config.Nims[nim.slotid].positionerMode) == "usals"): # USALS
26 list.append(getConfigListEntry(_("Longitude"), config.Nims[nim.slotid].longitude))
27 list.append(getConfigListEntry("", config.Nims[nim.slotid].longitudeOrientation))
28 list.append(getConfigListEntry(_("Latitude"), config.Nims[nim.slotid].latitude))
29 list.append(getConfigListEntry("", config.Nims[nim.slotid].latitudeOrientation))
30 elif (currentConfigSelectionElement(config.Nims[nim.slotid].positionerMode) == "manual"): # manual
33 def createSetup(self):
35 self.diseqcModeEntry = None
37 if (nimmanager.getNimType(self.nim.slotid) == nimmanager.nimType["DVB-S"]):
38 self.configMode = getConfigListEntry(_("Configuration Mode"), config.Nims[self.nim.slotid].configMode)
39 self.list.append(self.configMode)
41 if currentConfigSelectionElement(config.Nims[self.nim.slotid].configMode) == "simple": #simple setup
42 self.diseqcModeEntry = getConfigListEntry(_("DiSEqC Mode"), config.Nims[self.nim.slotid].diseqcMode)
43 self.list.append(self.diseqcModeEntry)
45 if (0 <= config.Nims[self.nim.slotid].diseqcMode.value < 4):
46 self.createSimpleSetup(self.nim, self.list, config.Nims[self.nim.slotid].diseqcMode.value)
47 if (config.Nims[self.nim.slotid].diseqcMode.value == 4):
48 self.createPositionerSetup(self.nim, self.list)
49 elif currentConfigSelectionElement(config.Nims[self.nim.slotid].configMode) == "nothing": # nothing
50 #self.list.append(getConfigListEntry(_("Linked to"), config.Nims[self.nim.slotid].linkedTo))
52 elif currentConfigSelectionElement(config.Nims[self.nim.slotid].configMode) == "loopthrough": # linked
55 elif (nimmanager.getNimType(self.nim.slotid) == nimmanager.nimType["DVB-C"]):
56 self.list.append(getConfigListEntry(_("Cable provider"), config.Nims[self.nim.slotid].cable))
57 elif (nimmanager.getNimType(self.nim.slotid) == nimmanager.nimType["DVB-T"]):
58 self.list.append(getConfigListEntry(_("Terrestrial provider"), config.Nims[self.nim.slotid].terrestrial))
61 self["config"].list = self.list
62 self["config"].l.setList(self.list)
65 if self["config"].getCurrent() == self.configMode:
67 if self["config"].getCurrent() == self.diseqcModeEntry:
71 if self["config"].getCurrent() == self.configMode:
72 if self.nim.slotid == 0:
74 self["config"].handleKey(config.key["prevElement"])
78 #forbid to enable advanced mode until its ready
79 #perhaps its better to use an own element here
80 #this suckz .. how enable advanced config?
81 if self["config"].getCurrent() == self.configMode:
82 if self.nim.slotid == 0:
85 self["config"].handleKey(config.key["nextElement"])
88 def keyNumberGlobal(self, number):
89 print "You pressed number " + str(number)
90 if (self["config"].getCurrent()[1].parent.enabled == True):
91 self["config"].handleKey(config.key[str(number)])
94 for x in self["config"].list:
96 nimmanager.sec.update()
103 for x in self["config"].list:
107 def __init__(self, session, slotid):
108 Screen.__init__(self, session)
110 self.nim = nimmanager.nimList()[slotid][1]
112 self["actions"] = NumberActionMap(["SetupActions"],
115 "cancel": self.keyCancel,
116 "left": self.keyLeft,
117 "right": self.keyRight,
118 "1": self.keyNumberGlobal,
119 "2": self.keyNumberGlobal,
120 "3": self.keyNumberGlobal,
121 "4": self.keyNumberGlobal,
122 "5": self.keyNumberGlobal,
123 "6": self.keyNumberGlobal,
124 "7": self.keyNumberGlobal,
125 "8": self.keyNumberGlobal,
126 "9": self.keyNumberGlobal,
127 "0": self.keyNumberGlobal
131 self["config"] = ConfigList(self.list)
135 class NimSelection(Screen):
136 def __init__(self, session):
137 Screen.__init__(self, session)
139 self["nimlist"] = MenuList(nimmanager.nimList())
141 self["actions"] = ActionMap(["OkCancelActions"],
143 "ok": self.okbuttonClick ,
147 def okbuttonClick(self):
148 selection = self["nimlist"].getCurrent()
149 if selection[1].nimType != -1: #unknown/empty
150 self.session.open(NimSetup, selection[1].slotid)