From 497cdf03ef35886b452d366899988d041a7a533c Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Tue, 4 Apr 2006 11:02:10 +0000 Subject: [PATCH] some work on the positioner setup plugin --- lib/python/Components/TunerInfo.py | 13 +- .../SystemPlugins/PositionerSetup/plugin.py | 130 +++++++++++++++--- 2 files changed, 120 insertions(+), 23 deletions(-) diff --git a/lib/python/Components/TunerInfo.py b/lib/python/Components/TunerInfo.py index e22ce468..f39babf2 100644 --- a/lib/python/Components/TunerInfo.py +++ b/lib/python/Components/TunerInfo.py @@ -11,6 +11,8 @@ class TunerInfo(GUIComponent): SNR_BAR = 3 AGC_BAR = 4 BER_BAR = 5 + LOCK_STATE = 6 + SYNC_STATE = 7 def __init__(self, type, servicefkt): GUIComponent.__init__(self) self.instance = None @@ -50,6 +52,8 @@ class TunerInfo(GUIComponent): value = feinfo.getFrontendInfo(iFrontendStatusInformation.signalQuality) * 100 / 65536 elif self.type == self.BER_VALUE or self.type == self.BER_BAR: value = feinfo.getFrontendInfo(iFrontendStatusInformation.bitErrorRate) + elif self.type == self.LOCK_STATE: + value = feinfo.getFrontendInfo(iFrontendStatusInformation.LockState) if self.type == self.SNR_PERCENTAGE or self.type == self.AGC_PERCENTAGE: self.setText("%d%%" % (value)) @@ -59,9 +63,14 @@ class TunerInfo(GUIComponent): self.setValue(value) elif self.type == self.BER_BAR: self.setValue(self.calc(value)) - + elif self.type == self.LOCK_STATE: + if value == 1: + self.setText(_("locked")) + else: + self.setText(_("not locked")) + def createWidget(self, parent): - if self.SNR_PERCENTAGE <= self.type <= self.BER_VALUE: + if self.SNR_PERCENTAGE <= self.type <= self.BER_VALUE or self.type == self.LOCK_STATE: return eLabel(parent) elif self.SNR_BAR <= self.type <= self.BER_BAR: self.g = eSlider(parent) diff --git a/lib/python/Plugins/SystemPlugins/PositionerSetup/plugin.py b/lib/python/Plugins/SystemPlugins/PositionerSetup/plugin.py index 579f6c99..067ef9ea 100644 --- a/lib/python/Plugins/SystemPlugins/PositionerSetup/plugin.py +++ b/lib/python/Plugins/SystemPlugins/PositionerSetup/plugin.py @@ -1,21 +1,35 @@ -from enigma import eTimer, eDVBSatelliteEquipmentControl +from enigma import eTimer, eDVBSatelliteEquipmentControl, eDVBResourceManager, eDVBDiseqcCommand, eDVBResourceManagerPtr, iDVBChannelPtr from Screens.Screen import Screen 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.config import config, ConfigSubsection, configElement_nonSave, configNothing, getConfigListEntry, configSelection class PositionerSetup(Screen): skin = """ - - - - - - + + + + + + + + + + + + + + + + + + + """ def __init__(self, session): self.skin = PositionerSetup.skin @@ -23,6 +37,8 @@ class PositionerSetup(Screen): self.createConfig() + self.isMoving = False + self.status = Label("") self["status"] = self.status @@ -34,11 +50,25 @@ class PositionerSetup(Screen): self["yellow"] = self.yellow self.blue = Label("") self["blue"] = self.blue + + self.feid = 0 self.list = [] self["list"] = ConfigList(self.list) self.createSetup() - + + self["snr"] = Label() + self["agc"] = Label() + self["ber"] = Label() + self["lock"] = Label() + self["snr_percentage"] = TunerInfo(TunerInfo.SNR_PERCENTAGE, self.session.nav.getCurrentService) + self["agc_percentage"] = TunerInfo(TunerInfo.AGC_PERCENTAGE, self.session.nav.getCurrentService) + self["ber_value"] = TunerInfo(TunerInfo.BER_VALUE, self.session.nav.getCurrentService) + self["snr_bar"] = TunerInfo(TunerInfo.SNR_BAR, self.session.nav.getCurrentService) + self["agc_bar"] = TunerInfo(TunerInfo.AGC_BAR, self.session.nav.getCurrentService) + self["ber_bar"] = TunerInfo(TunerInfo.BER_BAR, self.session.nav.getCurrentService) + self["lock_state"] = TunerInfo(TunerInfo.LOCK_STATE, self.session.nav.getCurrentService) + self["actions"] = ActionMap(["DirectionActions", "OkCancelActions", "ColorActions"], { "ok": self.go, @@ -53,19 +83,21 @@ class PositionerSetup(Screen): "blue": self.blueKey, }, -1) - self.updateColors("move") + self.updateColors("tune") self.statusTimer = eTimer() self.statusTimer.timeout.get().append(self.updateStatus) - self.statusTimer.start(500, False) + self.statusTimer.start(200, False) def createConfig(self): config.positioner = ConfigSubsection() + config.positioner.tune = configElement_nonSave("tune", configNothing, 0, None) config.positioner.move = configElement_nonSave("move", configNothing, 0, None) config.positioner.limits = configElement_nonSave("limits", configNothing, 0, None) config.positioner.storage = configElement_nonSave("storage", configSelection, 0, ("1", "2", "3")) def createSetup(self): + self.list.append(getConfigListEntry(_("Tune"), config.positioner.tune)) self.list.append(getConfigListEntry(_("Positioner movement"), config.positioner.move)) self.list.append(getConfigListEntry(_("Set limits"), config.positioner.limits)) self.list.append(getConfigListEntry(_("Positioner storage"), config.positioner.storage)) @@ -75,13 +107,16 @@ class PositionerSetup(Screen): def go(self): pass + def getCurrentConfigPath(self): + return self["list"].getCurrent()[1].parent.configPath + def up(self): self["list"].instance.moveSelection(self["list"].instance.moveUp) - self.updateColors(self["list"].getCurrent()[1].parent.configPath) + self.updateColors(self.getCurrentConfigPath()) def down(self): self["list"].instance.moveSelection(self["list"].instance.moveDown) - self.updateColors(self["list"].getCurrent()[1].parent.configPath) + self.updateColors(self.getCurrentConfigPath()) def left(self): self["list"].handleKey(config.key["prevElement"]) @@ -90,11 +125,22 @@ class PositionerSetup(Screen): self["list"].handleKey(config.key["nextElement"]) def updateColors(self, entry): - if entry == "move": - self.red.setText(_("Move east")) - self.green.setText(_("Step east")) - self.yellow.setText(_("Step west")) - self.blue.setText(_("Move west")) + if entry == "tune": + self.red.setText("tune manually") + self.green.setText("predefined transponder") + self.yellow.setText("") + self.blue.setText("") + elif entry == "move": + if self.isMoving: + self.red.setText(_("Stop")) + self.green.setText(_("Stop")) + self.yellow.setText(_("Stop")) + self.blue.setText(_("Stop")) + else: + self.red.setText(_("Move east")) + self.green.setText(_("Step east")) + self.yellow.setText(_("Step west")) + self.blue.setText(_("Move west")) elif entry == "limits": self.red.setText(_("Limits off")) self.green.setText(_("Limit east")) @@ -112,22 +158,64 @@ class PositionerSetup(Screen): self.blue.setText("") def redKey(self): - print "red" + entry = self.getCurrentConfigPath() + if entry == "move": + print "moving east" + self.diseqc() def greenKey(self): - pass + entry = self.getCurrentConfigPath() + if entry == "move": + print "stepping east" def yellowKey(self): - pass + entry = self.getCurrentConfigPath() + if entry == "move": + print "stepping east" def blueKey(self): - pass + entry = self.getCurrentConfigPath() + if entry == "move": + print "moving west" + if self.isMoving: + self.diseqc("stop") + else: + self.diseqc("moveWest") + print "stepping west" + + def diseqc(self, what): + res_mgr = eDVBResourceManagerPtr() + eDVBResourceManager.getInstance(res_mgr) + raw_channel = iDVBChannelPtr() + res_mgr.allocateRawChannel(raw_channel, self.feid) + frontend = raw_channel.getFrontend() + cmd = eDVBDiseqcCommand + if what == "moveWest": + cmd.setCommandString('\xe1\x31\x69\x40') + elif what == "moveEast": + cmd.setCommandString('\xe1\x31\x68\x40') + else: + cmd.setCommandString('\xe0\x31\x60') #positioner stop + frontend.sendDiseqc(cmd) def updateStatus(self): if eDVBSatelliteEquipmentControl.getInstance().isRotorMoving(): + if not self.isMoving: + self.isMoving = True + self.updateColors(self.getCurrentConfigPath()) self.status.setText("moving...") else: + if self.isMoving: + self.isMoving = False + self.updateColors(self.getCurrentConfigPath()) self.status.setText("not moving") + + self["snr_percentage"].update() + self["agc_percentage"].update() + self["ber_value"].update() + self["snr_bar"].update() + self["agc_bar"].update() + self["ber_bar"].update() def PositionerMain(session, **kwargs): session.open(PositionerSetup) -- 2.30.2