Subversion Repositories ALCASAR

Rev

Rev 3037 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log

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