1 from Components.config import config, ConfigSubList, ConfigSubsection
2 import NavigationInstance
3 from enigma import iRecordableService, eTimer, iPlayableService, eServiceCenter, iServiceInformation
4 from Components.ConfigList import ConfigListScreen
5 from Components.config import config, ConfigSubsection, ConfigSelection, ConfigSlider
6 from Components.Harddisk import harddiskmanager
8 config.plugins.manualfancontrols = ConfigSubsection()
9 config.plugins.manualfancontrols.standbymode = ConfigSelection(default = "yes", choices = [
10 ("no", _("no")), ("yes", _("yes"))])
11 config.plugins.manualfancontrols.pwmvalue = ConfigSlider(default = 10, increment = 5, limits = (0, 255))
12 config.plugins.manualfancontrols.checkperiod = ConfigSelection(default = "10", choices = [
13 ("5", "5 " + _("seconds")), ("10", "10 " + _("seconds")), ("30", "30 " + _("seconds")),
14 ("60", "1 " + _("minute")), ("120", "2 " + _("minutes")),
15 ("300", "5 " + _("minutes")), ("600", "10 " + _("minutes"))])
17 instandbyOn_playingpvr = False
21 self.fanoffmode = 'OFF'
23 self.setPWM(config.plugins.manualfancontrols.pwmvalue.value)
24 self.checkStstusTimer = eTimer()
25 self.checkStstusTimer.callback.append(self.checkStstus)
26 if config.plugins.manualfancontrols.pwmvalue.value == 0:
27 self.fanoffmode = 'ON'
28 if self.fanoffmode == 'ON':
29 self.checkStatusLoopStart()
31 config.misc.standbyCounter.addNotifier(self.standbyBegin, initial_call = False)
32 print "<ManualFancontrol> init : self.fanoffmode : ", self.fanoffmode
33 print "<ManualFancontrol> init : config.plugins.manualfancontrols.pwmvalue.value : ", config.plugins.manualfancontrols.pwmvalue.value
35 def checkStatusLoopStart(self):
36 print "<ManualFancontrol> checkStatusLoopStart"
37 self.checkStstusTimer.start(int(config.plugins.manualfancontrols.checkperiod.value) * 1000)
39 def checkStatusLoopStop(self):
40 print "<ManualFancontrol> checkStatusLoopStop"
41 self.checkStstusTimer.stop()
43 def checkStstus(self):
44 from Screens.Standby import inStandby
45 print "<ManualFancontrol> checkStstus, fanoffmode : %s, "%self.fanoffmode,"inStandby : ",inStandby and True or False
46 if self.fanoffmode is 'ON' : # pwmvalue is '0'
47 if self.isRecording() or self.isHDDActive():
48 self.setPWM(self.minimum_pwm)
51 elif inStandby : # standby mode but pwm > 0
52 if self.isRecording() or self.isHDDActive():
53 self.setPWM(config.plugins.manualfancontrols.pwmvalue.value)
56 elif self.getPWM() != config.plugins.manualfancontrols.pwmvalue.value : # normal mode
57 self.setPWM(config.plugins.manualfancontrols.pwmvalue.value)
59 def standbyBegin(self, configElement):
60 print "<ManualFancontrol> Standby Begin"
61 if config.plugins.manualfancontrols.standbymode.value == "yes" and self.fanoffmode is "OFF":
62 from Screens.Standby import inStandby
63 inStandby.onClose.append(self.StandbyEnd)
64 self.addRecordEventCB()
65 self.checkStatusLoopStart()
69 print "<ManualFancontrol> Standby End"
70 if self.fanoffmode is "OFF":
71 self.removeRecordEventCB()
72 self.checkStatusLoopStop()
75 def addRecordEventCB(self):
76 print "<ManualFancontrol> addRecordEventCB"
77 if self.getRecordEvent not in NavigationInstance.instance.record_event:
78 NavigationInstance.instance.record_event.append(self.getRecordEvent)
80 def removeRecordEventCB(self):
81 print "<ManualFancontrol> removeRecordEventCB"
82 if self.getRecordEvent in NavigationInstance.instance.record_event:
83 NavigationInstance.instance.record_event.remove(self.getRecordEvent)
85 def getRecordEvent(self, recservice, event):
86 if event == iRecordableService.evEnd or event == iRecordableService.evStart:
89 def isRecording(self):
90 recordings = NavigationInstance.instance.getRecordings()
91 print "<ManualFancontrol_> recordings : ",len(recordings)
97 def isHDDActive(self): # remake certainly
98 for hdd in harddiskmanager.HDDList():
99 if not hdd[1].isSleeping():
100 print "<ManualFancontrol_> %s is not Sleeping"%hdd[0]
102 print "<ManualFancontrol_> All HDDs are Sleeping"
106 f = open("/proc/stb/fp/fan_pwm", "r")
107 value = int(f.readline().strip(), 16)
109 print "<ManualFancontrol> getPWM : %d "%value
112 def setPWM(self, value):
113 print "<ManualFancontrol> setPWM to : %d"%value
114 f = open("/proc/stb/fp/fan_pwm", "w")
115 f.write("%x" % value)
118 instandbyon = instandbyOn()