display Satfinder, SatelliteEquipmentControl and PositionerSetup
[enigma2.git] / lib / python / Plugins / SystemPlugins / Satfinder / plugin.py
index 6325a82f10d215fcb34cd5b6d293940348d8146d..3cf48fb8797b4141e2a8ae180da893edf66227f0 100644 (file)
@@ -1,16 +1,17 @@
-from enigma import eTimer, eDVBSatelliteEquipmentControl, eDVBResourceManager, eDVBDiseqcCommand, eDVBResourceManagerPtr, iDVBChannelPtr, iDVBFrontendPtr, iDVBFrontend, eDVBFrontendParametersSatellite, eDVBFrontendParameters
+from enigma import eTimer, eDVBResourceManager,\
+       eDVBFrontendParametersSatellite, eDVBFrontendParameters
+
 from Screens.Screen import Screen
 from Screens.ScanSetup import ScanSetup
 from Screens.MessageBox import MessageBox
 from Plugins.Plugin import PluginDescriptor
 
 from Components.Label import Label
-from Components.ConfigList import ConfigList
 from Components.TunerInfo import TunerInfo
 from Components.ActionMap import ActionMap
 from Components.NimManager import nimmanager, getConfigSatlist
 from Components.MenuList import MenuList
-from Components.config import ConfigSelection, ConfigSatlist, getConfigListEntry
+from Components.config import ConfigSelection, getConfigListEntry
 
 class Tuner:
        def __init__(self, frontend):
@@ -56,12 +57,12 @@ class Satfinder(ScanSetup):
                </screen>"""
 
        def openFrontend(self):
-               res_mgr = eDVBResourceManagerPtr()
-               if eDVBResourceManager.getInstance(res_mgr) == 0:
-                       self.raw_channel = iDVBChannelPtr()
-                       if res_mgr.allocateRawChannel(self.raw_channel, self.feid) == 0:
-                               self.frontend = iDVBFrontendPtr()
-                               if self.raw_channel.getFrontend(self.frontend) == 0:
+               res_mgr = eDVBResourceManager.getInstance()
+               if res_mgr:
+                       self.raw_channel = res_mgr.allocateRawChannel(self.feid)
+                       if self.raw_channel:
+                               self.frontend = self.raw_channel.getFrontend()
+                               if self.frontend:
                                        return True
                                else:
                                        print "getFrontend failed"
@@ -71,13 +72,11 @@ class Satfinder(ScanSetup):
                        print "getResourceManager instance failed"
                return False
 
-       def getFrontend(self):
-               return self.frontend
-
        def __init__(self, session, feid):
                self.initcomplete = False
                self.feid = feid
                self.oldref = None
+               self.frontendStatus = { }
                
                if not self.openFrontend():
                        self.oldref = session.nav.getCurrentlyPlayingServiceReference()
@@ -88,8 +87,7 @@ class Satfinder(ScanSetup):
                                        del session.pip
                                        if not self.openFrontend():
                                                self.frontend = None # in normal case this should not happen
-                                               self.getFrontend = None
-               
+
                ScanSetup.__init__(self, session)
                self.tuner = Tuner(self.frontend)
                
@@ -97,24 +95,26 @@ class Satfinder(ScanSetup):
                self["agc"] = Label()
                self["ber"] = Label()
                self["lock"] = Label()
-               self["snr_percentage"] = TunerInfo(TunerInfo.SNR_PERCENTAGE, frontendfkt = self.getFrontend)
-               self["agc_percentage"] = TunerInfo(TunerInfo.AGC_PERCENTAGE, frontendfkt = self.getFrontend)
-               self["ber_value"] = TunerInfo(TunerInfo.BER_VALUE, frontendfkt = self.getFrontend)
-               self["snr_bar"] = TunerInfo(TunerInfo.SNR_BAR, frontendfkt = self.getFrontend)
-               self["agc_bar"] = TunerInfo(TunerInfo.AGC_BAR, frontendfkt = self.getFrontend)
-               self["ber_bar"] = TunerInfo(TunerInfo.BER_BAR, frontendfkt = self.getFrontend)
-               self["lock_state"] = TunerInfo(TunerInfo.LOCK_STATE, frontendfkt = self.getFrontend)
+               self["snr_percentage"] = TunerInfo(TunerInfo.SNR_PERCENTAGE, statusDict = self.frontendStatus)
+               self["agc_percentage"] = TunerInfo(TunerInfo.AGC_PERCENTAGE, statusDict = self.frontendStatus)
+               self["ber_value"] = TunerInfo(TunerInfo.BER_VALUE, statusDict = self.frontendStatus)
+               self["snr_bar"] = TunerInfo(TunerInfo.SNR_BAR, statusDict = self.frontendStatus)
+               self["agc_bar"] = TunerInfo(TunerInfo.AGC_BAR, statusDict = self.frontendStatus)
+               self["ber_bar"] = TunerInfo(TunerInfo.BER_BAR, statusDict = self.frontendStatus)
+               self["lock_state"] = TunerInfo(TunerInfo.LOCK_STATE, statusDict = self.frontendStatus)
                
                self["introduction"].setText("")
-               
+
                self.statusTimer = eTimer()
                self.statusTimer.timeout.get().append(self.updateStatus)
                self.statusTimer.start(50, False)
-               
                self.initcomplete = True
-               self.session = session
 
        def updateStatus(self):
+               if self.frontend:
+                       self.frontend.getFrontendStatus(self.frontendStatus)
+               else:
+                       self.frontendStatus.clear()
                self["snr_percentage"].update()
                self["agc_percentage"].update()
                self["ber_value"].update()
@@ -247,11 +247,11 @@ class NimSelection(Screen):
        def __init__(self, session):
                Screen.__init__(self, session)
 
-               nimlist = nimmanager.getNimListOfType(nimmanager.nimType["DVB-S"])
+               nimlist = nimmanager.getNimListOfType("DVB-S")
                nimMenuList = []
                for x in nimlist:
-                       nimMenuList.append((_("NIM ") + (["A", "B", "C", "D"][x]) + ": " + nimmanager.getNimName(x) + " (" + nimmanager.getNimTypeName(x) + ")", x))
-               
+                       nimMenuList.append((nimmanager.nim_slots[x].friendly_full_description, x))
+
                self["nimlist"] = MenuList(nimMenuList)
 
                self["actions"] = ActionMap(["OkCancelActions"],
@@ -261,11 +261,11 @@ class NimSelection(Screen):
                }, -1)
 
        def okbuttonClick(self):
-               selection = self["nimlist"].getCurrent()
-               self.session.open(Satfinder, selection[1])
+               selection = self["nimlist"].getCurrent()[1]
+               self.session.open(Satfinder, selection)
 
 def SatfinderMain(session, **kwargs):
-       nimList = nimmanager.getNimListOfType(nimmanager.nimType["DVB-S"])
+       nimList = nimmanager.getNimListOfType("DVB-S")
        if len(nimList) == 0:
                session.open(MessageBox, _("No satellite frontend found!!"), MessageBox.TYPE_ERROR)
        else:
@@ -284,4 +284,7 @@ def SatfinderStart(menuid):
                return []
 
 def Plugins(**kwargs):
-       return PluginDescriptor(name=_("Satfinder"), description="Helps setting up your dish", where = PluginDescriptor.WHERE_SETUP, fnc=SatfinderStart)
+       if (nimmanager.hasNimType("DVB-T")):
+               return PluginDescriptor(name=_("Satfinder"), description="Helps setting up your dish", where = PluginDescriptor.WHERE_SETUP, fnc=SatfinderStart)
+       else:
+               return []