add 'weight' for menu entries (including plugins), so they can be sorted, patch by...
[enigma2.git] / lib / python / Plugins / SystemPlugins / PositionerSetup / plugin.py
index 10fa02d3f09f3433a8aa0683f00319c6ddd0d0da..fccd2625b6d024ceb922d3e3f66c2fb90679878a 100644 (file)
@@ -1,5 +1,6 @@
 from enigma import eTimer, eDVBSatelliteEquipmentControl, eDVBResourceManager, \
-       eDVBDiseqcCommand, eDVBFrontendParametersSatellite, eDVBFrontendParameters
+       eDVBDiseqcCommand, eDVBFrontendParametersSatellite, eDVBFrontendParameters,\
+       iDVBFrontend
 
 from Screens.Screen import Screen
 from Screens.ScanSetup import ScanSetup
@@ -60,8 +61,9 @@ class PositionerSetup(Screen):
                                        del session.pip
                                        if not self.openFrontend():
                                                self.frontend = None # in normal case this should not happen
-                                               self.getFrontend = None
-               
+
+               self.frontendStatus = { }
+
                self.diseqc = Diseqc(self.frontend)
                self.tuner = Tuner(self.frontend)
                self.tuner.tune((0,0,0,0,0,0))
@@ -88,13 +90,13 @@ class PositionerSetup(Screen):
                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["frequency"] = Label()
                self["symbolrate"] = Label()
@@ -138,9 +140,6 @@ class PositionerSetup(Screen):
                else:
                        self.restartPrevService(False)
 
-       def getFrontend(self):
-               return self.frontend
-
        def openFrontend(self):
                res_mgr = eDVBResourceManager.getInstance()
                if res_mgr:
@@ -323,6 +322,8 @@ class PositionerSetup(Screen):
                self.tuner.retune()
 
        def updateStatus(self):
+               if self.frontend:
+                       self.frontend.getFrontendStatus(self.frontendStatus)
                self["snr_percentage"].update()
                self["agc_percentage"].update()
                self["ber_value"].update()
@@ -331,10 +332,10 @@ class PositionerSetup(Screen):
                self["ber_bar"].update()
                self["lock_state"].update()
                transponderdata = self.tuner.getTransponderData()
-               self["frequency_value"].setText(str(transponderdata["frequency"]))
-               self["symbolrate_value"].setText(str(transponderdata["symbol_rate"]))
-               self["fec_value"].setText(str(transponderdata["fec_inner"]))
-               if transponderdata["tuner_locked"] == 1 and self.isMoving and self.stopOnLock:
+               self["frequency_value"].setText(str(transponderdata.get("frequency")))
+               self["symbolrate_value"].setText(str(transponderdata.get("symbol_rate")))
+               self["fec_value"].setText(str(transponderdata.get("fec_inner")))
+               if self.frontendStatus.get("tuner_locked", 0) == 1 and self.isMoving and self.stopOnLock:
                        self.diseqccommand("stop")
                        self.isMoving = False
                        self.stopOnLock = False
@@ -373,6 +374,8 @@ class Diseqc:
                        print "diseqc command:",
                        print string
                        cmd.setCommandString(string)
+                       self.frontend.setTone(iDVBFrontend.toneOff)
+                       sleep(0.015) # wait 15msec after disable tone
                        self.frontend.sendDiseqc(cmd)
                        if string == 'e03160': #positioner stop
                                sleep(0.05)
@@ -404,9 +407,10 @@ class Tuner:
                        self.frontend.tune(self.lastparm)
 
        def getTransponderData(self):
+               ret = { }
                if self.frontend:
-                       return self.frontend.readTransponderData(True)
-               return None
+                       self.frontend.getTransponderData(ret, True)
+               return ret
 
 tuning = None
 
@@ -528,7 +532,8 @@ class NimSelection(Screen):
                nimlist = nimmanager.getNimListOfType(nimmanager.nimType["DVB-S"])
                nimMenuList = []
                for x in nimlist:
-                       nimMenuList.append((_("NIM ") + (["A", "B", "C", "D"][x]) + ": " + nimmanager.getNimName(x) + " (" + nimmanager.getNimTypeName(x) + ")", x))
+                       n = nimmanager.nim_slots[x]
+                       nimMenuList.append((n.friendly_full_name, x))
                
                self["nimlist"] = MenuList(nimMenuList)
 
@@ -543,7 +548,7 @@ class NimSelection(Screen):
                self.session.open(PositionerSetup, selection[1])
 
 def PositionerMain(session, **kwargs):
-       nimList = nimmanager.getNimListOfType(nimmanager.nimType["DVB-S"])
+       nimList = nimmanager.getNimListOfType("DVB-S")
        if len(nimList) == 0:
                session.open(MessageBox, _("No positioner capable frontend found."), MessageBox.TYPE_ERROR)
        else:
@@ -562,11 +567,14 @@ def PositionerMain(session, **kwargs):
                        else:
                                session.open(MessageBox, _("No tuner is configured for use with a diseqc positioner!"), MessageBox.TYPE_ERROR)
 
-def PositionerSetupStart(menuid):
+def PositionerSetupStart(menuid, **kwargs):
        if menuid == "scan":
-               return [(_("Positioner setup"), PositionerMain)]
+               return [(_("Positioner setup"), PositionerMain, "positioner_setup", None)]
        else:
                return []
 
 def Plugins(**kwargs):
-       return PluginDescriptor(name=_("Positioner setup"), description="Setup your positioner", where = PluginDescriptor.WHERE_SETUP, fnc=PositionerSetupStart)
+       if (nimmanager.hasNimType("DVB-S")):
+               return PluginDescriptor(name=_("Positioner setup"), description="Setup your positioner", where = PluginDescriptor.WHERE_MENU, fnc=PositionerSetupStart)
+       else:
+               return []