Subversion Repositories ALCASAR

Rev

Rev 2976 | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
2770 rexy 1
<?php
2
/**
3
 * MBM5 sensor class, getting information from Motherboard Monitor 5 information retrival through csv file
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 MBM5 extends Sensors
16
{
17
    /**
18
     * array with the names of the labels
19
     *
20
     * @var array
21
     */
22
    private $_buf_label = array();
325 richard 23
 
2770 rexy 24
    /**
25
     * array withe the values
26
     *
27
     * @var array
28
     */
29
    private $_buf_value = array();
325 richard 30
 
2770 rexy 31
    /**
32
     * read the MBM5.csv file and fill the private arrays
33
     */
34
    public function __construct()
35
    {
36
        parent::__construct();
2976 rexy 37
        if ((PSI_OS == 'WINNT') && !defined('PSI_EMU_HOSTNAME')) {
38
            $delim = "/;/";
3037 rexy 39
            CommonFunctions::rftsdata("MBM5.csv", $buffer);
2976 rexy 40
            if (strpos($buffer, ";") === false) {
41
                $delim = "/,/";
42
            }
43
            $buffer = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
44
            $this->_buf_label = preg_split($delim, substr($buffer[0], 0, -2), -1, PREG_SPLIT_NO_EMPTY);
45
            $this->_buf_value = preg_split($delim, substr($buffer[1], 0, -2), -1, PREG_SPLIT_NO_EMPTY);
2770 rexy 46
        }
47
    }
325 richard 48
 
2770 rexy 49
    /**
50
     * get temperature information
51
     *
52
     * @return void
53
     */
54
    private function _temperature()
55
    {
56
        for ($intPosi = 3; $intPosi < 6; $intPosi++) {
57
            if ($this->_buf_value[$intPosi] == 0) {
58
                continue;
59
            }
60
            preg_match("/([0-9\.])*/", str_replace(",", ".", $this->_buf_value[$intPosi]), $hits);
61
            $dev = new SensorDevice();
62
            $dev->setName($this->_buf_label[$intPosi]);
63
            $dev->setValue($hits[0]);
64
//            $dev->setMax(70);
65
            $this->mbinfo->setMbTemp($dev);
66
        }
67
    }
68
 
69
    /**
70
     * get fan information
71
     *
72
     * @return void
73
     */
74
    private function _fans()
75
    {
76
        for ($intPosi = 13; $intPosi < 16; $intPosi++) {
77
            if (!isset($this->_buf_value[$intPosi])) {
78
                continue;
79
            }
80
            preg_match("/([0-9\.])*/", str_replace(",", ".", $this->_buf_value[$intPosi]), $hits);
81
            $dev = new SensorDevice();
82
            $dev->setName($this->_buf_label[$intPosi]);
83
            $dev->setValue($hits[0]);
84
//            $dev->setMin(3000);
85
            $this->mbinfo->setMbFan($dev);
86
        }
87
    }
88
 
89
    /**
90
     * get voltage information
91
     *
92
     * @return void
93
     */
94
    private function _voltage()
95
    {
96
        for ($intPosi = 6; $intPosi < 13; $intPosi++) {
97
            if ($this->_buf_value[$intPosi] == 0) {
98
                continue;
99
            }
100
            preg_match("/([0-9\.])*/", str_replace(",", ".", $this->_buf_value[$intPosi]), $hits);
101
            $dev = new SensorDevice();
102
            $dev->setName($this->_buf_label[$intPosi]);
103
            $dev->setValue($hits[0]);
104
            $this->mbinfo->setMbVolt($dev);
105
        }
106
    }
107
 
108
    /**
109
     * get the information
110
     *
111
     * @see PSI_Interface_Sensor::build()
112
     *
3037 rexy 113
     * @return void
2770 rexy 114
     */
115
    public function build()
116
    {
117
        $this->_fans();
118
        $this->_temperature();
119
        $this->_voltage();
120
    }
121
}