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))
22 def createPositionerSetup(self, nim, list):
23 list.append(getConfigListEntry("Longitude", config.Nims[nim.slotid].longitude))
24 list.append(getConfigListEntry("Latitude", config.Nims[nim.slotid].latitude))
27 def createSetup(self):
30 self.list.append(getConfigListEntry("Configmode", config.Nims[self.nim.slotid].configMode))
32 if config.Nims[self.nim.slotid].configMode.value == 0: #simple setup
33 self.list.append(getConfigListEntry("Diseqcmode", config.Nims[self.nim.slotid].diseqcMode))
35 if (0 <= config.Nims[self.nim.slotid].diseqcMode.value < 4):
36 self.createSimpleSetup(self.nim, self.list, config.Nims[self.nim.slotid].diseqcMode.value)
37 if (config.Nims[self.nim.slotid].diseqcMode.value == 4):
38 self.createPositionerSetup(self.nim, self.list)
40 print "FIXME: implement advanced mode"
42 self["config"].list = self.list
43 self["config"].l.setList(self.list)
46 if self["config"].getCurrent()[0] == "Diseqcmode":
48 if self["config"].getCurrent()[0] == "Configmode":
52 self["config"].handleKey(config.key["prevElement"])
56 #forbid to enable advanced mode until its ready
57 if self["config"].getCurrent()[0] != "Configmode":
58 self["config"].handleKey(config.key["nextElement"])
61 def keyNumberGlobal(self, number):
62 print "You pressed number " + str(number)
63 if (self["config"].getCurrent()[1].parent.enabled == True):
64 self["config"].handleKey(config.key[str(number)])
67 for x in self["config"].list:
69 nimmanager.sec.update()
73 for x in self["config"].list:
77 def __init__(self, session, nim):
78 Screen.__init__(self, session)
81 self["actions"] = NumberActionMap(["SetupActions"],
84 "cancel": self.keyCancel,
86 "right": self.keyRight,
87 "1": self.keyNumberGlobal,
88 "2": self.keyNumberGlobal,
89 "3": self.keyNumberGlobal,
90 "4": self.keyNumberGlobal,
91 "5": self.keyNumberGlobal,
92 "6": self.keyNumberGlobal,
93 "7": self.keyNumberGlobal,
94 "8": self.keyNumberGlobal,
95 "9": self.keyNumberGlobal,
96 "0": self.keyNumberGlobal
100 self["config"] = ConfigList(self.list)
104 class NimSelection(Screen):
105 def __init__(self, session):
106 Screen.__init__(self, session)
108 self["nimlist"] = MenuList(nimmanager.nimList())
110 self["actions"] = ActionMap(["OkCancelActions"],
112 "ok": self.okbuttonClick ,
116 def okbuttonClick(self):
117 selection = self["nimlist"].getCurrent()
118 if selection[1].nimType != -1: #unknown/empty
119 self.session.open(NimSetup, selection[1])