1 from Components.FanControl import fancontrol
4 # (type, name, unit, directory)
6 # (type, name, unit, fanid)
10 # (type, name, unit, sensor_specific_dict/list)
11 self.sensors_list = []
14 def getSensorsCount(self, type = None):
16 return len(self.sensors_list)
18 for sensor in self.sensors_list:
23 # returns a list of sensorids of type "type"
24 def getSensorsList(self, type = None):
26 return range(len(self.sensors_list))
28 for sensorid in range(len(self.sensors_list)):
29 if self.sensors_list[sensorid][0] == type:
34 def getSensorType(self, sensorid):
35 return self.sensors_list[sensorid][0]
37 def getSensorName(self, sensorid):
38 return self.sensors_list[sensorid][1]
40 def getSensorValue(self, sensorid):
42 sensor = self.sensors_list[sensorid]
43 if sensor[0] == self.TYPE_TEMPERATURE:
44 f = open("%s/value" % sensor[3], "r")
45 value = int(f.readline().strip())
47 elif sensor[0] == self.TYPE_FAN_RPM:
48 value = fancontrol.getFanSpeed(sensor[3])
51 def getSensorUnit(self, sensorid):
52 return self.sensors_list[sensorid][2]
56 if os.path.exists("/proc/stb/sensors"):
57 for dirname in os.listdir("/proc/stb/sensors"):
58 if dirname.find("temp", 0, 4) == 0:
59 f = open("/proc/stb/sensors/%s/name" % dirname, "r")
60 name = f.readline().strip()
63 f = open("/proc/stb/sensors/%s/unit" % dirname, "r")
64 unit = f.readline().strip()
67 self.sensors_list.append((self.TYPE_TEMPERATURE, name, unit, "/proc/stb/sensors/%s" % dirname))
68 for fanid in range(fancontrol.getFanCount()):
69 if fancontrol.hasRPMSensor(fanid):
70 self.sensors_list.append((self.TYPE_FAN_RPM, _("Fan %d") % (fanid + 1), "rpm", fanid))