Subversion Repositories ALCASAR

Rev

Rev 2770 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

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