Subversion Repositories ALCASAR

Rev

Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
2770 rexy 1
<?php
2
/**
3
 * pitemp sensor class
4
 *
5
 * PHP version 5
6
 *
7
 * @category  PHP
8
 * @package   PSI_Sensor
9
 * @author    Marc Hillesheim <hawkeyexp@gmail.com>
10
 * @copyright 2012 phpSysInfo
11
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
12
 * @version   Release: 3.0
13
 * @link      http://phpsysinfo.sourceforge.net
14
 */
15
class PiTemp extends Sensors
16
{
17
    private function _temperature()
18
    {
19
        $temp = null;
20
        $temp_max = null;
21
        if (!CommonFunctions::rfts('/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/temp1_input', $temp, 1, 4096, false)) { // Not Banana Pi
22
            CommonFunctions::rfts('/sys/class/thermal/thermal_zone0/temp', $temp, 1);
23
            CommonFunctions::rfts('/sys/class/thermal/thermal_zone0/trip_point_0_temp', $temp_max, 1, 4096, PSI_DEBUG);
24
        }
25
        if (!is_null($temp) && (($temp = trim($temp)) != "")) {
26
            $dev = new SensorDevice();
27
            $dev->setName("CPU 1");
28
            $dev->setValue($temp / 1000);
29
            if (!is_null($temp_max) && (($temp_max = trim($temp_max)) != "") && ($temp_max > 0)) {
30
                $dev->setMax($temp_max / 1000);
31
            }
32
            $this->mbinfo->setMbTemp($dev);
33
        }
34
    }
35
 
36
    private function _voltage()
37
    {
38
        $volt = null;
39
        if (CommonFunctions::rfts('/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/ac/voltage_now', $volt, 1, 4096, false) && !is_null($volt) && (($volt = trim($volt)) != "")) { // Banana Pi
40
            $dev = new SensorDevice();
41
            $dev->setName("Voltage 1");
42
            $dev->setValue($volt / 1000000);
43
            $this->mbinfo->setMbVolt($dev);
44
        }
45
    }
46
 
47
    private function _current()
48
    {
49
        $current = null;
50
        if (CommonFunctions::rfts('/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/ac/current_now', $current, 1, 4096, false) && !is_null($current) && (($current = trim($current)) != "")) { // Banana Pi
51
            $dev = new SensorDevice();
52
            $dev->setName("Current 1");
53
            $dev->setValue($current / 1000000);
54
            $this->mbinfo->setMbCurrent($dev);
55
        }
56
    }
57
 
58
    public function build()
59
    {
60
        $this->_temperature();
61
        $this->_voltage();
62
        $this->_current();
63
    }
64
}