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.fanoffmode == 'ON':
40 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)
67 elif self.getPWM() != config.plugins.manualfancontrols.pwmvalue.value : # normal mode
68 self.setPWM(config.plugins.manualfancontrols.pwmvalue.value)
70 def standbyBegin(self, configElement):
71 print "<ManualFancontrol> Standby Begin"
72 if config.plugins.manualfancontrols.standbymode.value == "yes" and self.fanoffmode is "OFF":
73 from Screens.Standby import inStandby
74 inStandby.onClose.append(self.StandbyEnd)
75 self.addRecordEventCB()
76 self.checkStatusLoopStart()
80 print "<ManualFancontrol> Standby End"
81 if self.fanoffmode is "OFF":
82 self.removeRecordEventCB()
83 self.checkStatusLoopStop()
86 def addRecordEventCB(self):
87 print "<ManualFancontrol> addRecordEventCB"
88 if self.getRecordEvent not in NavigationInstance.instance.record_event:
89 NavigationInstance.instance.record_event.append(self.getRecordEvent)
91 def removeRecordEventCB(self):
92 print "<ManualFancontrol> removeRecordEventCB"
93 if self.getRecordEvent in NavigationInstance.instance.record_event:
94 NavigationInstance.instance.record_event.remove(self.getRecordEvent)
96 def getRecordEvent(self, recservice, event):
97 if event == iRecordableService.evEnd or event == iRecordableService.evStart:
100 def isRecording(self):
101 recordings = NavigationInstance.instance.getRecordings()
102 print "<ManualFancontrol_> recordings : ",len(recordings)
108 def isHDDActive(self): # remake certainly
109 for hdd in harddiskmanager.HDDList():
110 if not hdd[1].isSleeping():
111 print "<ManualFancontrol_> %s is not Sleeping"%hdd[0]
113 print "<ManualFancontrol_> All HDDs are Sleeping"
117 f = open("/proc/stb/fp/fan_pwm", "r")
118 value = int(f.readline().strip(), 16)
120 print "<ManualFancontrol> getPWM : %d "%value
123 def setPWM(self, value):
124 print "<ManualFancontrol> setPWM to : %d"%value
125 f = open("/proc/stb/fp/fan_pwm", "w")
126 f.write("%x" % value)
129 instandbyon = instandbyOn()