X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fpython%2FPlugins%2FSystemPlugins%2FManualFancontrol%2FInstandbyOn.py;h=b4af0ad84efc1ade4ceb29e02700416fa8380fa0;hp=b7eb5ae46bd5f13ec3215dd08a8bed707301686c;hb=ae49c64044d1a591af5d8a5f1bfa79d9f43e080b;hpb=783d38d689180a4d288e62779f78305ce16d68fe diff --git a/lib/python/Plugins/SystemPlugins/ManualFancontrol/InstandbyOn.py b/lib/python/Plugins/SystemPlugins/ManualFancontrol/InstandbyOn.py index b7eb5ae..b4af0ad 100755 --- a/lib/python/Plugins/SystemPlugins/ManualFancontrol/InstandbyOn.py +++ b/lib/python/Plugins/SystemPlugins/ManualFancontrol/InstandbyOn.py @@ -1,60 +1,146 @@ from Components.config import config, ConfigSubList, ConfigSubsection import NavigationInstance -from enigma import iRecordableService +from enigma import iRecordableService, eTimer, iPlayableService, eServiceCenter, iServiceInformation from Components.ConfigList import ConfigListScreen -from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigSelection, ConfigInteger, ConfigSlider +from Components.config import config, ConfigSubsection, ConfigSelection, ConfigSlider +from Components.Harddisk import harddiskmanager -config.plugins.simplefancontrols = ConfigSubsection() -config.plugins.simplefancontrols.standbymode = ConfigSelection(default = "on", choices = [ - ("off", _("off")), ("on", _("on"))]) -config.plugins.simplefancontrols.recordingmode = ConfigSelection(default = "on", choices = [ - ("off", _("no")), ("on", _("yes"))]) -config.plugins.simplefancontrols.pwmvalue = ConfigSlider(default = 100, increment = 5, limits = (5, 255)) +def getModel(): + file = open("/proc/stb/info/vumodel", "r") + modelname = file.readline().strip() + file.close() + return modelname + +config.plugins.manualfancontrols = ConfigSubsection() +config.plugins.manualfancontrols.standbymode = ConfigSelection(default = "yes", choices = [ + ("no", _("no")), ("yes", _("yes"))]) + +if getModel() == "ultimo": + config.plugins.manualfancontrols.pwmvalue = ConfigSlider(default = 100, increment = 5, limits = (0, 255)) +else: + config.plugins.manualfancontrols.pwmvalue = ConfigSlider(default = 10, increment = 5, limits = (0, 255)) + +config.plugins.manualfancontrols.checkperiod = ConfigSelection(default = "10", choices = [ + ("5", "5 " + _("seconds")), ("10", "10 " + _("seconds")), ("30", "30 " + _("seconds")), + ("60", "1 " + _("minute")), ("120", "2 " + _("minutes")), + ("300", "5 " + _("minutes")), ("600", "10 " + _("minutes"))]) + +instandbyOn_playingpvr = False class instandbyOn: def __init__(self): - config.misc.standbyCounter.addNotifier(self.standbyBegin, initial_call = False) + self.fanoffmode = 'OFF' + self.minimum_pwm = 5 + self.setPWM(config.plugins.manualfancontrols.pwmvalue.value) + self.checkStstusTimer = eTimer() + self.checkStstusTimer.callback.append(self.checkStstus) + if config.plugins.manualfancontrols.pwmvalue.value == 0: + self.fanoffmode = 'ON' + if self.check_fan_pwm(): + if self.fanoffmode == 'ON': + self.checkStatusLoopStart() + config.misc.standbyCounter.addNotifier(self.standbyBegin, initial_call = False) +# print "[ManualFancontrol] init : self.fanoffmode : ", self.fanoffmode +# print "[ManualFancontrol] init : config.plugins.manualfancontrols.pwmvalue.value : ", config.plugins.manualfancontrols.pwmvalue.value + + def checkStatusLoopStart(self): +# print "[ManualFancontrol] checkStatusLoopStart" + self.checkStstusTimer.start(int(config.plugins.manualfancontrols.checkperiod.value) * 1000) + + def checkStatusLoopStop(self): +# print "[ManualFancontrol] checkStatusLoopStop" + self.checkStstusTimer.stop() + + def checkStstus(self): + from Screens.Standby import inStandby + print "[ManualFancontrol] checkStstus, fanoffmode : %s, "%self.fanoffmode,"inStandby : ",inStandby and True or False + if self.fanoffmode is 'ON' : # pwmvalue is '0' + if self.isRecording() or self.isHDDActive(): + self.setPWM(self.minimum_pwm) + else: + self.setPWM(0) + elif inStandby : # standby mode but pwm > 0 + if self.isRecording() or self.isHDDActive(): + self.setPWM(config.plugins.manualfancontrols.pwmvalue.value) + else: + self.setPWM(0) + else: + pwm = self.getPWM() + if pwm is not None and pwm != config.plugins.manualfancontrols.pwmvalue.value : # normal mode + self.setPWM(config.plugins.manualfancontrols.pwmvalue.value) def standbyBegin(self, configElement): - print " config.plugins.fancontrols.standbymode.value : ", config.plugins.simplefancontrols.standbymode.value - if config.plugins.simplefancontrols.standbymode.value == "on": - from Screens.Standby import inStandby - inStandby.onClose.append(self.StandbyEnd) - NavigationInstance.instance.record_event.append(self.getRecordEvent) - recordings = NavigationInstance.instance.getRecordings() - if not recordings: - self.setPWM(0) +# print "[ManualFancontrol] Standby Begin" + if config.plugins.manualfancontrols.standbymode.value == "yes" and self.fanoffmode is "OFF": + from Screens.Standby import inStandby + inStandby.onClose.append(self.StandbyEnd) + self.addRecordEventCB() + self.checkStatusLoopStart() + self.checkStstus() def StandbyEnd(self): - print " Standby End" +# print "[ManualFancontrol] Standby End" + if self.fanoffmode is "OFF": + self.removeRecordEventCB() + self.checkStatusLoopStop() + self.checkStstus() + + def addRecordEventCB(self): +# print "[ManualFancontrol] addRecordEventCB" + if self.getRecordEvent not in NavigationInstance.instance.record_event: + NavigationInstance.instance.record_event.append(self.getRecordEvent) + + def removeRecordEventCB(self): +# print "[ManualFancontrol] removeRecordEventCB" + if self.getRecordEvent in NavigationInstance.instance.record_event: NavigationInstance.instance.record_event.remove(self.getRecordEvent) - if self.getPWM() == 0: - self.setPWM(config.plugins.simplefancontrols.pwmvalue.value) def getRecordEvent(self, recservice, event): - recordings = len(NavigationInstance.instance.getRecordings()) - print " recordings : %d , event : %d" % (recordings,event) - if event == iRecordableService.evEnd: - print " getRecordEvent : evEnd" - if recordings == 0: - self.setPWM(0) - elif event == iRecordableService.evStart: - print " getRecordEvent : evStart" - if self.getPWM() == 0: - self.setPWM(config.plugins.simplefancontrols.pwmvalue.value) + if event == iRecordableService.evEnd or event == iRecordableService.evStart: + self.checkStstus() + + def isRecording(self): + recordings = NavigationInstance.instance.getRecordings() + print " recordings : ",len(recordings) + if recordings : + return True + else: + return False + + def isHDDActive(self): # remake certainly + for hdd in harddiskmanager.HDDList(): + if not hdd[1].isSleeping(): + print " %s is not Sleeping"%hdd[0] + return True + print " All HDDs are Sleeping" + return False def getPWM(self): - f = open("/proc/stb/fp/fan_pwm", "r") - value = int(f.readline().strip(), 16) - f.close() - print " getPWM : %d "%value - return value + try: + f = open("/proc/stb/fp/fan_pwm", "r") + value = int(f.readline().strip(), 16) + f.close() + print "[ManualFancontrol] getPWM : %d "%value + return value + except: + print "[ManualFancontrol] /proc/stb/fp/fan_pwm is not exist" + return None def setPWM(self, value): - print " setPWM to : %d"%value - f = open("/proc/stb/fp/fan_pwm", "w") - f.write("%x" % value) - f.close() + try: + f = open("/proc/stb/fp/fan_pwm", "w") + f.write("%x" % value) + f.close() + print "[ManualFancontrol] setPWM to : %d"%value + except: + print "[ManualFancontrol] /proc/stb/fp/fan_pwm is not exist" + + def check_fan_pwm(self): + from os import access, F_OK + if access("/proc/stb/fp/fan_pwm", F_OK): + return True + else: + return False instandbyon = instandbyOn()