Subversion Repositories ALCASAR

Rev

Rev 2976 | 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':
3037 rexy 37
            if (CommonFunctions::rftsdata('k8temp.tmp', $lines)) {
2770 rexy 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
        }
44
    }
45
 
46
    /**
47
     * get temperature information
48
     *
49
     * @return void
50
     */
51
    private function _temperature()
52
    {
53
        foreach ($this->_lines as $line) {
54
            if (preg_match('/(.*):\s*(\d*)/', $line, $data)) {
55
                if ($data[2] > 0) {
56
                    $dev = new SensorDevice();
57
                    $dev->setName($data[1]);
58
//                    $dev->setMax('70.0');
59
                    if ($data[2] < 250) {
60
                        $dev->setValue($data[2]);
61
                    }
62
                    $this->mbinfo->setMbTemp($dev);
63
                }
64
            }
65
        }
66
    }
67
 
68
    /**
69
     * get the information
70
     *
71
     * @see PSI_Interface_Sensor::build()
72
     *
3037 rexy 73
     * @return void
2770 rexy 74
     */
75
    public function build()
76
    {
77
        $this->_temperature();
78
    }
79
}