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
9 file = open("/proc/stb/info/vumodel", "r")
10 modelname = file.readline().strip()
14 config.plugins.manualfancontrols = ConfigSubsection()
15 config.plugins.manualfancontrols.standbymode = ConfigSelection(default = "yes", choices = [
16 ("no", _("no")), ("yes", _("yes"))])
18 if getModel() == "ultimo":
19 config.plugins.manualfancontrols.pwmvalue = ConfigSlider(default = 100, increment = 5, limits = (0, 255))
21 config.plugins.manualfancontrols.pwmvalue = ConfigSlider(default = 10, increment = 5, limits = (0, 255))
23 config.plugins.manualfancontrols.checkperiod = ConfigSelection(default = "10", choices = [
24 ("5", "5 " + _("seconds")), ("10", "10 " + _("seconds")), ("30", "30 " + _("seconds")),
25 ("60", "1 " + _("minute")), ("120", "2 " + _("minutes")),
26 ("300", "5 " + _("minutes")), ("600", "10 " + _("minutes"))])
28 instandbyOn_playingpvr = False
32 self.fanoffmode = 'OFF'
34 self.setPWM(config.plugins.manualfancontrols.pwmvalue.value)
35 self.checkStstusTimer = eTimer()
36 self.checkStstusTimer.callback.append(self.checkStstus)
37 if config.plugins.manualfancontrols.pwmvalue.value == 0:
38 self.fanoffmode = 'ON'
39 if self.check_fan_pwm():
40 if self.fanoffmode == 'ON':
41 self.checkStatusLoopStart()
42 config.misc.standbyCounter.addNotifier(self.standbyBegin, initial_call = False)
43 # print "[ManualFancontrol] init : self.fanoffmode : ", self.fanoffmode
44 # print "[ManualFancontrol] init : config.plugins.manualfancontrols.pwmvalue.value : ", config.plugins.manualfancontrols.pwmvalue.value
46 def checkStatusLoopStart(self):
47 # print "[ManualFancontrol] checkStatusLoopStart"
48 self.checkStstusTimer.start(int(config.plugins.manualfancontrols.checkperiod.value) * 1000)
50 def checkStatusLoopStop(self):
51 # print "[ManualFancontrol] checkStatusLoopStop"
52 self.checkStstusTimer.stop()
54 def checkStstus(self):
55 from Screens.Standby import inStandby
56 print "[ManualFancontrol] checkStstus, fanoffmode : %s, "%self.fanoffmode,"inStandby : ",inStandby and True or False
57 if self.fanoffmode is 'ON' : # pwmvalue is '0'
58 if self.isRecording() or self.isHDDActive():
59 self.setPWM(self.minimum_pwm)
62 elif inStandby : # standby mode but pwm > 0
63 if self.isRecording() or self.isHDDActive():
64 self.setPWM(config.plugins.manualfancontrols.pwmvalue.value)
69 if pwm is not None and pwm != config.plugins.manualfancontrols.pwmvalue.value : # normal mode
70 self.setPWM(config.plugins.manualfancontrols.pwmvalue.value)
72 def standbyBegin(self, configElement):
73 # print "[ManualFancontrol] Standby Begin"
74 if config.plugins.manualfancontrols.standbymode.value == "yes" and self.fanoffmode is "OFF":
75 from Screens.Standby import inStandby
76 inStandby.onClose.append(self.StandbyEnd)
77 self.addRecordEventCB()
78 self.checkStatusLoopStart()
82 # print "[ManualFancontrol] Standby End"
83 if self.fanoffmode is "OFF":
84 self.removeRecordEventCB()
85 self.checkStatusLoopStop()
88 def addRecordEventCB(self):
89 # print "[ManualFancontrol] addRecordEventCB"
90 if self.getRecordEvent not in NavigationInstance.instance.record_event:
91 NavigationInstance.instance.record_event.append(self.getRecordEvent)
93 def removeRecordEventCB(self):
94 # print "[ManualFancontrol] removeRecordEventCB"
95 if self.getRecordEvent in NavigationInstance.instance.record_event:
96 NavigationInstance.instance.record_event.remove(self.getRecordEvent)
98 def getRecordEvent(self, recservice, event):
99 if event == iRecordableService.evEnd or event == iRecordableService.evStart:
102 def isRecording(self):
103 recordings = NavigationInstance.instance.getRecordings()
104 print "<ManualFancontrol_> recordings : ",len(recordings)
110 def isHDDActive(self): # remake certainly
111 for hdd in harddiskmanager.HDDList():
112 if not hdd[1].isSleeping():
113 print "<ManualFancontrol_> %s is not Sleeping"%hdd[0]
115 print "<ManualFancontrol_> All HDDs are Sleeping"
120 f = open("/proc/stb/fp/fan_pwm", "r")
121 value = int(f.readline().strip(), 16)
123 print "[ManualFancontrol] getPWM : %d "%value
126 print "[ManualFancontrol] /proc/stb/fp/fan_pwm is not exist"
129 def setPWM(self, value):
131 f = open("/proc/stb/fp/fan_pwm", "w")
132 f.write("%x" % value)
134 print "[ManualFancontrol] setPWM to : %d"%value
136 print "[ManualFancontrol] /proc/stb/fp/fan_pwm is not exist"
138 def check_fan_pwm(self):
139 from os import access, F_OK
140 if access("/proc/stb/fp/fan_pwm", F_OK):
145 instandbyon = instandbyOn()