Subversion Repositories ALCASAR

Rev

Rev 2770 | Rev 3037 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
2770 rexy 1
<?php
2
/**
3
 * K8Temp sensor class, getting information from k8temp
4
 *
5
 * PHP version 5
6
 *
7
 * @category  PHP
8
 * @package   PSI_Sensor
9
 * @author    Michael Cramer <BigMichi1@users.sourceforge.net>
10
 * @copyright 2009 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 K8Temp extends Sensors
16
{
17
    /**
18
     * content to parse
19
     *
20
     * @var array
21
     */
22
    private $_lines = array();
23
 
24
    /**
25
     * fill the private array
26
     */
27
    public function __construct()
28
    {
29
        parent::__construct();
2976 rexy 30
        if ((PSI_OS != 'WINNT') && !defined('PSI_EMU_HOSTNAME')) switch (defined('PSI_SENSOR_K8TEMP_ACCESS')?strtolower(PSI_SENSOR_K8TEMP_ACCESS):'command') {
2770 rexy 31
        case 'command':
32
            $lines = "";
33
            CommonFunctions::executeProgram('k8temp', '', $lines);
34
            $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
35
            break;
36
        case 'data':
37
            if (CommonFunctions::rfts(PSI_APP_ROOT.'/data/k8temp.txt', $lines)) {
38
                $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
39
            }
40
            break;
41
        default:
42
            $this->error->addConfigError('__construct()', '[sensor_k8temp] ACCESS');
43
            break;
44
        }
45
    }
46
 
47
    /**
48
     * get temperature information
49
     *
50
     * @return void
51
     */
52
    private function _temperature()
53
    {
54
        foreach ($this->_lines as $line) {
55
            if (preg_match('/(.*):\s*(\d*)/', $line, $data)) {
56
                if ($data[2] > 0) {
57
                    $dev = new SensorDevice();
58
                    $dev->setName($data[1]);
59
//                    $dev->setMax('70.0');
60
                    if ($data[2] < 250) {
61
                        $dev->setValue($data[2]);
62
                    }
63
                    $this->mbinfo->setMbTemp($dev);
64
                }
65
            }
66
        }
67
    }
68
 
69
    /**
70
     * get the information
71
     *
72
     * @see PSI_Interface_Sensor::build()
73
     *
74
     * @return Void
75
     */
76
    public function build()
77
    {
78
        $this->_temperature();
79
    }
80
}