Added converter for display orbital position for motorized tuner. Idea and partialy...
authorims <ims21@users.sourceforge.net>
Mon, 23 Mar 2015 18:21:59 +0000 (19:21 +0100)
committerlittlesat <littlesat99@yahoo.com>
Mon, 23 Mar 2015 19:21:51 +0000 (20:21 +0100)
Signed-off-by: littlesat <littlesat99@yahoo.com>

lib/python/Components/Converter/Makefile.am
lib/python/Components/Converter/RotorPosition.py [new file with mode: 0644]

index fd976fa..b9329d9 100644 (file)
@@ -7,4 +7,5 @@ install_PYTHON = \
        StaticMultiList.py ServiceTime.py MovieInfo.py MenuEntryCompare.py StringListSelection.py \
        ServiceOrbitalPosition.py CryptoInfo.py TextCase.py \
        ValueBitTest.py TunerInfo.py ConfigEntryTest.py TemplatedMultiContent.py ProgressToText.py \
-       Combine.py SensorToText.py ValueToPixmap.py PliExtraInfo.py genre.py TransponderInfo.py
+       Combine.py SensorToText.py ValueToPixmap.py PliExtraInfo.py genre.py TransponderInfo.py \
+       RotorPosition.py
diff --git a/lib/python/Components/Converter/RotorPosition.py b/lib/python/Components/Converter/RotorPosition.py
new file mode 100644 (file)
index 0000000..21ee3a1
--- /dev/null
@@ -0,0 +1,59 @@
+# -*- coding: utf-8 -*-
+from Converter import Converter
+from Components.Element import cached
+from Components.config import config
+from Tools.Transponder import orbpos
+from Components.NimManager import nimmanager
+from enigma import eDVBSatelliteEquipmentControl
+
+class RotorPosition(Converter, object):
+       DEFAULT = 0
+       WITH_TEXT = 1
+       TUNER_NAME = 2
+
+       def __init__(self, type):
+               Converter.__init__(self, type)
+               if type == "WithText":
+                       self.type = self.WITH_TEXT
+               if type == "TunerName":
+                       self.type = self.TUNER_NAME
+               else:
+                       self.type = self.DEFAULT
+
+       @cached
+       def getText(self):
+               (rotor, tuner) = self.isMotorizedTuner()
+               if rotor:
+                       self.actualizeCfgLastRotorPosition()
+                       if self.type == self.WITH_TEXT:
+                               return _("Rotor: ") + orbpos(config.misc.lastrotorposition.value)
+                       if self.type == self.TUNER_NAME:
+                               active_tuner = self.getActiveTuner()
+                               if tuner != active_tuner:
+                                       return _("%s:%s") % (chr(ord("A")+tuner), orbpos(config.misc.lastrotorposition.value))
+                               return ""
+                       return orbpos(config.misc.lastrotorposition.value)
+               return ""
+
+       text = property(getText)
+
+       def isMotorizedTuner(self):
+               for x in nimmanager.nim_slots:
+                       for sat in nimmanager.getRotorSatListForNim(x.slot):
+                               if sat[0]:
+                                       return (True, x.slot)
+               return (False, None)
+
+       def actualizeCfgLastRotorPosition(self):
+               if eDVBSatelliteEquipmentControl.getInstance().isRotorMoving():
+                       config.misc.lastrotorposition.value = eDVBSatelliteEquipmentControl.getInstance().getTargetOrbitalPosition()
+                       config.misc.lastrotorposition.save()
+
+       def getActiveTuner(self):
+               if not eDVBSatelliteEquipmentControl.getInstance().isRotorMoving():
+                       service = self.source.service
+                       feinfo = service and service.frontendInfo()
+                       tuner = feinfo and feinfo.getFrontendData()
+                       if tuner:
+                               return tuner.get("tuner_number")
+               return ""
\ No newline at end of file