ManualFancontrol : ADD ManualFancontrol Plugin
[vuplus_dvbapp] / lib / python / Plugins / SystemPlugins / ManualFancontrol / InstandbyOn.py
1 from Components.config import config, ConfigSubList, ConfigSubsection
2 import NavigationInstance
3 from enigma import iRecordableService
4 from Components.ConfigList import ConfigListScreen
5 from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigSelection, ConfigInteger, ConfigSlider
6
7 config.plugins.simplefancontrols = ConfigSubsection()
8 config.plugins.simplefancontrols.standbymode = ConfigSelection(default = "on", choices = [
9         ("off", _("off")), ("on", _("on"))])
10 config.plugins.simplefancontrols.recordingmode = ConfigSelection(default = "on", choices = [
11         ("off", _("no")), ("on", _("yes"))])
12 config.plugins.simplefancontrols.pwmvalue = ConfigSlider(default = 100, increment = 5, limits = (5, 255))
13
14 class instandbyOn:
15         def __init__(self):
16                 config.misc.standbyCounter.addNotifier(self.standbyBegin, initial_call = False)
17
18         def standbyBegin(self, configElement):
19                         print "<SimpleFancontrol> config.plugins.fancontrols.standbymode.value : ", config.plugins.simplefancontrols.standbymode.value
20                         if config.plugins.simplefancontrols.standbymode.value == "on":
21                                 from Screens.Standby import inStandby
22                                 inStandby.onClose.append(self.StandbyEnd)
23                                 NavigationInstance.instance.record_event.append(self.getRecordEvent)
24                                 recordings = NavigationInstance.instance.getRecordings()
25                                 if not recordings:
26                                         self.setPWM(0)
27
28         def StandbyEnd(self):
29                         print "<SimpleFancontrol> Standby End"
30                         NavigationInstance.instance.record_event.remove(self.getRecordEvent)
31                         if self.getPWM() == 0:
32                                 self.setPWM(config.plugins.simplefancontrols.pwmvalue.value)
33
34         def getRecordEvent(self, recservice, event):
35                         recordings = len(NavigationInstance.instance.getRecordings())
36                         print "<SimpleFancontrol> recordings : %d , event : %d" % (recordings,event)
37                         if event == iRecordableService.evEnd:
38                                 print "<SimpleFancontrol> getRecordEvent : evEnd"
39                                 if recordings == 0:
40                                         self.setPWM(0)
41                         elif event == iRecordableService.evStart:
42                                 print "<SimpleFancontrol> getRecordEvent : evStart"
43                                 if self.getPWM() == 0:
44                                         self.setPWM(config.plugins.simplefancontrols.pwmvalue.value)
45
46         def getPWM(self):
47                 f = open("/proc/stb/fp/fan_pwm", "r")
48                 value = int(f.readline().strip(), 16)
49                 f.close()
50                 print "<SimpleFancontrol> getPWM : %d "%value
51                 return value
52
53         def setPWM(self, value):
54                 print "<SimpleFancontrol> setPWM to : %d"%value
55                 f = open("/proc/stb/fp/fan_pwm", "w")
56                 f.write("%x" % value)
57                 f.close()
58
59 instandbyon = instandbyOn()
60