From 2db3e8afead0a9ee14871c8436691755be22a5ca Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Thu, 6 Nov 2008 00:17:52 +0100 Subject: Patch by Anders Holst: * ConfigElement.addNotifier takes a new optional argument immediate_feedback (which is True by default). If True the notifier is called whenever an editing key is pressed in the element. When False, the notifier is only called when editing is finished, i.e the element is deselected or the dialog closed. * ConfigSet is updated in accordance with Teros suggestion so that it behaves like the others and feedback can be given immediately. * All ConfigElements are modified to check whether they have changed since last selected (by a new variable last_value). * UsageConfig.py is updated to use immediate_feedback=False in the case of validating the speeds. (The only case so far where this setting is needed, but with the possibility more uses may follow.) --- lib/python/Components/UsageConfig.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/python/Components/UsageConfig.py') diff --git a/lib/python/Components/UsageConfig.py b/lib/python/Components/UsageConfig.py index 6ed87840..2ea91aeb 100644 --- a/lib/python/Components/UsageConfig.py +++ b/lib/python/Components/UsageConfig.py @@ -89,8 +89,8 @@ def InitUsageConfig(): config.seek.speeds_backward = ConfigSet(default=[8, 16, 32, 64, 128], choices=[1, 2, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128]) config.seek.speeds_slowmotion = ConfigSet(default=[2, 4, 8], choices=[2, 4, 6, 8, 12, 16, 25]) - config.seek.enter_forward = ConfigSelection(default = "2", choices = ["2"]) - config.seek.enter_backward = ConfigSelection(default = "2", choices = ["2"]) + config.seek.enter_forward = ConfigSelection(default = "2", choices = ["2", "4", "6", "8", "12", "16", "24", "32", "48", "64", "96", "128"]) + config.seek.enter_backward = ConfigSelection(default = "1", choices = ["1", "2", "4", "6", "8", "12", "16", "24", "32", "48", "64", "96", "128"]) config.seek.stepwise_minspeed = ConfigSelection(default = "16", choices = ["Never", "2", "4", "6", "8", "12", "16", "24", "32", "48", "64", "96", "128"]) config.seek.stepwise_repeat = ConfigSelection(default = "3", choices = ["2", "3", "4", "5", "6"]) @@ -104,14 +104,14 @@ def InitUsageConfig(): configElement.value = [2] updateChoices(config.seek.enter_forward, configElement.value) - config.seek.speeds_forward.addNotifier(updateEnterForward) + config.seek.speeds_forward.addNotifier(updateEnterForward, immediate_feedback = False) def updateEnterBackward(configElement): if not configElement.value: configElement.value = [2] updateChoices(config.seek.enter_backward, configElement.value) - config.seek.speeds_backward.addNotifier(updateEnterBackward) + config.seek.speeds_backward.addNotifier(updateEnterBackward, immediate_feedback = False) def updateChoices(sel, choices): if choices: -- cgit v1.2.3 From fdc322a811049c371bd7dbdb75192534cebd36c8 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Tue, 27 Jan 2009 18:57:33 +0100 Subject: don't rely on hdd standby timer, but manage own idle timer. --- lib/python/Components/Harddisk.py | 64 +++++++++++++++++++++++++++++++++++- lib/python/Components/UsageConfig.py | 14 ++++---- 2 files changed, 70 insertions(+), 8 deletions(-) (limited to 'lib/python/Components/UsageConfig.py') diff --git a/lib/python/Components/Harddisk.py b/lib/python/Components/Harddisk.py index ad7f28de..1fc629a0 100644 --- a/lib/python/Components/Harddisk.py +++ b/lib/python/Components/Harddisk.py @@ -2,7 +2,8 @@ from os import system, listdir, statvfs, popen, makedirs, readlink, stat, major, from Tools.Directories import SCOPE_HDD, resolveFilename from Tools.CList import CList from SystemInfo import SystemInfo -import string +import string, time +from Components.Console import Console def tryOpen(filename): try: @@ -18,6 +19,8 @@ class Harddisk: tmp = procfile.readline().split(':') s_major = int(tmp[0]) s_minor = int(tmp[1]) + self.max_idle_time = 0 + self.idle_running = False for disc in listdir("/dev/discs"): path = readlink('/dev/discs/'+disc) devidex = '/dev/discs/'+disc+'/' @@ -28,6 +31,7 @@ class Harddisk: self.devidex = devidex self.devidex2 = devidex2 print "new Harddisk", device, '->', self.devidex, '->', self.devidex2 + self.startIdle() break def __lt__(self, ob): @@ -213,6 +217,64 @@ class Harddisk: def getDeviceName(self): return self.getDeviceDir() + "disc" + # the HDD idle poll daemon. + # as some harddrives have a buggy standby timer, we are doing this by hand here. + # first, we disable the hardware timer. then, we check every now and then if + # any access has been made to the disc. If there has been no access over a specifed time, + # we set the hdd into standby. + def readStats(self): + l = open("/sys/block/%s/stat" % self.device).read() + nr_read = int(l[:8].strip()) + nr_write = int(l[4*9:4*9+8].strip()) + return nr_read, nr_write + + def startIdle(self): + self.last_access = time.time() + self.last_stat = 0 + self.is_sleeping = False + from enigma import eTimer + + # disable HDD standby timer + Console().ePopen(("hdparm", "hdparm", "-S0", (self.devidex + "disc"))) + self.timer = eTimer() + self.timer.callback.append(self.runIdle) + self.idle_running = True + self.setIdleTime(self.max_idle_time) # kick the idle polling loop + + def runIdle(self): + if not self.max_idle_time: + return + t = time.time() + + idle_time = t - self.last_access + + l = sum(self.readStats()) + + if l != self.last_stat: # access + self.last_stat = l + self.last_access = t + self.idle_time = 0 + self.is_sleeping = False + + #print "[IDLE]", idle_time, self.max_idle_time, self.is_sleeping + if idle_time >= self.max_idle_time and not self.is_sleeping: + self.setSleep() + self.is_sleeping = True + + def setSleep(self): + Console().ePopen(("hdparm", "hdparm", "-y", (self.devidex + "disc"))) + + def setIdleTime(self, idle): + self.max_idle_time = idle + if self.idle_running: + if not idle: + self.timer.stop() + else: + self.timer.start(idle * 250, False) # poll 4 times per period. + + def isSleeping(self): + return self.is_sleeping + class Partition: def __init__(self, mountpoint, device = None, description = "", force_mounted = False): self.mountpoint = mountpoint diff --git a/lib/python/Components/UsageConfig.py b/lib/python/Components/UsageConfig.py index 2ea91aeb..21e057f2 100644 --- a/lib/python/Components/UsageConfig.py +++ b/lib/python/Components/UsageConfig.py @@ -17,12 +17,12 @@ def InitUsageConfig(): config.usage.show_infobar_on_zap = ConfigYesNo(default = True) config.usage.show_infobar_on_skip = ConfigYesNo(default = True) config.usage.show_infobar_on_event_change = ConfigYesNo(default = True) - config.usage.hdd_standby = ConfigSelection(default = "120", choices = [ - ("0", _("no standby")), ("2", "10 " + _("seconds")), ("6", "30 " + _("seconds")), - ("12", "1 " + _("minute")), ("24", "2 " + _("minutes")), - ("60", "5 " + _("minutes")), ("120", "10 " + _("minutes")), ("240", "20 " + _("minutes")), - ("241", "30 " + _("minutes")), ("242", "1 " + _("hour")), ("244", "2 " + _("hours")), - ("248", "4 " + _("hours")) ]) + config.usage.hdd_standby = ConfigSelection(default = "600", choices = [ + ("0", _("no standby")), ("10", "10 " + _("seconds")), ("30", "30 " + _("seconds")), + ("60", "1 " + _("minute")), ("120", "2 " + _("minutes")), + ("300", "5 " + _("minutes")), ("600", "10 " + _("minutes")), ("1200", "20 " + _("minutes")), + ("1800", "30 " + _("minutes")), ("3600", "1 " + _("hour")), ("7200", "2 " + _("hours")), + ("14400", "4 " + _("hours")) ]) config.usage.output_12V = ConfigSelection(default = "do not change", choices = [ ("do not change", _("do not change")), ("off", _("off")), ("on", _("on")) ]) @@ -66,7 +66,7 @@ def InitUsageConfig(): def setHDDStandby(configElement): for hdd in harddiskmanager.HDDList(): - os.system("hdparm -S%s %s" % (configElement.value, hdd[1].getDeviceName())) + hdd[1].setIdleTime(int(configElement.value)) config.usage.hdd_standby.addNotifier(setHDDStandby) def set12VOutput(configElement): -- cgit v1.2.3