Subversion Repositories ALCASAR

Rev

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

Rev 325 Rev 2770
1
<?php 
1
<?php
2
//
2
/**
3
// phpSysInfo - A PHP System Information Script
3
 * MBM5 sensor class, getting information from Motherboard Monitor 5 information retrival through csv file
-
 
4
 *
4
// http://phpsysinfo.sourceforge.net/
5
 * PHP version 5
5
//
6
 *
-
 
7
 * @category  PHP
6
// This program is free software; you can redistribute it and/or
8
 * @package   PSI_Sensor
7
// modify it under the terms of the GNU General Public License
9
 * @author    Michael Cramer <BigMichi1@users.sourceforge.net>
-
 
10
 * @copyright 2009 phpSysInfo
8
// as published by the Free Software Foundation; either version 2
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
9
// of the License, or (at your option) any later version.
13
 * @link      http://phpsysinfo.sourceforge.net
10
//
14
 */
11
// This program is distributed in the hope that it will be useful,
-
 
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-
 
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-
 
14
// GNU General Public License for more details.
15
class MBM5 extends Sensors
15
//
16
{
-
 
17
    /**
16
// You should have received a copy of the GNU General Public License
18
     * array with the names of the labels
-
 
19
     *
17
// along with this program; if not, write to the Free Software
20
     * @var array
18
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-
 
19
//
21
     */
20
// $Id: class.mbm5.inc.php,v 1.7 2007/02/18 19:11:31 bigmichi1 Exp $
22
    private $_buf_label = array();
21
 
23
 
-
 
24
    /**
-
 
25
     * array withe the values
22
class mbinfo {
26
     *
23
	var $buf_label;
27
     * @var array
-
 
28
     */
24
	var $buf_value;
29
    private $_buf_value = array();
25
 
30
 
-
 
31
    /**
-
 
32
     * read the MBM5.csv file and fill the private arrays
-
 
33
     */
26
	function mbinfo() {
34
    public function __construct()
-
 
35
    {
-
 
36
        parent::__construct();
-
 
37
        $delim = "/;/";
27
		$buffer = rfts( APP_ROOT . "/data/MBM5.csv" );
38
        CommonFunctions::rfts(PSI_APP_ROOT."/data/MBM5.csv", $buffer);
28
		if( strpos( $buffer, ";") === false ) {
39
        if (strpos($buffer, ";") === false) {
29
			$delim = ",";
40
            $delim = "/,/";
30
		} else {
41
        }
31
			$delim = ";";
-
 
32
		}
-
 
33
		$buffer = explode( "\n", $buffer );
42
        $buffer = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
34
		$this->buf_label = explode( $delim, $buffer[0] );
43
        $this->_buf_label = preg_split($delim, substr($buffer[0], 0, -2), -1, PREG_SPLIT_NO_EMPTY);
35
		$this->buf_value = explode( $delim, $buffer[1] );
44
        $this->_buf_value = preg_split($delim, substr($buffer[1], 0, -2), -1, PREG_SPLIT_NO_EMPTY);
36
	}
45
    }
37
	
46
 
-
 
47
    /**
38
	function temperature() {
48
     * get temperature information
-
 
49
     *
39
		$results = array();
50
     * @return void
40
		$intCount = 0;
51
     */
-
 
52
    private function _temperature()
41
		
53
    {
42
		for( $intPosi = 3; $intPosi < 6; $intPosi++ ) { 
54
        for ($intPosi = 3; $intPosi < 6; $intPosi++) {
43
			$results[$intCount]['label'] = $this->buf_label[$intPosi];
55
            if ($this->_buf_value[$intPosi] == 0) {
-
 
56
                continue;
-
 
57
            }
-
 
58
            preg_match("/([0-9\.])*/", str_replace(",", ".", $this->_buf_value[$intPosi]), $hits);
-
 
59
            $dev = new SensorDevice();
44
			$results[$intCount]['value'] = $this->buf_value[$intPosi];
60
            $dev->setName($this->_buf_label[$intPosi]);
45
			$results[$intCount]['limit'] = '70.0';
61
            $dev->setValue($hits[0]);
46
			$intCount++;
62
//            $dev->setMax(70);
-
 
63
            $this->mbinfo->setMbTemp($dev);
47
		}
64
        }
48
		return $results;
-
 
49
	} 
65
    }
50
	
66
 
-
 
67
    /**
51
	function fans() {
68
     * get fan information
-
 
69
     *
52
		$results = array();
70
     * @return void
-
 
71
     */
53
		$intCount = 0;
72
    private function _fans()
54
		
73
    {
55
		for( $intPosi = 13; $intPosi < 16; $intPosi++ ) {
74
        for ($intPosi = 13; $intPosi < 16; $intPosi++) {
56
			$results[$intCount]['label'] = $this->buf_label[$intPosi];
75
            if (!isset($this->_buf_value[$intPosi])) {
-
 
76
                continue;
-
 
77
            }
-
 
78
            preg_match("/([0-9\.])*/", str_replace(",", ".", $this->_buf_value[$intPosi]), $hits);
-
 
79
            $dev = new SensorDevice();
57
			$results[$intCount]['value'] = $this->buf_value[$intPosi];
80
            $dev->setName($this->_buf_label[$intPosi]);
-
 
81
            $dev->setValue($hits[0]);
58
			$results[$intCount]['min'] = '3000';
82
//            $dev->setMin(3000);
59
			$intCount++;
83
            $this->mbinfo->setMbFan($dev);
60
		}
84
        }
61
		return $results;
-
 
62
	} 
85
    }
63
	
86
 
-
 
87
    /**
64
	function voltage() {
88
     * get voltage information
-
 
89
     *
65
		$results = array();
90
     * @return void
-
 
91
     */
66
		$intCount = 0;
92
    private function _voltage()
67
		
93
    {
68
		for( $intPosi = 6; $intPosi < 13; $intPosi++ ) {
94
        for ($intPosi = 6; $intPosi < 13; $intPosi++) {
69
			$results[$intCount]['label'] = $this->buf_label[$intPosi];
-
 
70
			$results[$intCount]['value'] = $this->buf_value[$intPosi];
95
            if ($this->_buf_value[$intPosi] == 0) {
71
			$results[$intCount]['min'] = '0.00';
96
                continue;
72
			$results[$intCount]['max'] = '0.00';
-
 
73
			$intCount++;
-
 
74
		}
97
            }
-
 
98
            preg_match("/([0-9\.])*/", str_replace(",", ".", $this->_buf_value[$intPosi]), $hits);
-
 
99
            $dev = new SensorDevice();
-
 
100
            $dev->setName($this->_buf_label[$intPosi]);
75
		return $results;
101
            $dev->setValue($hits[0]);
-
 
102
            $this->mbinfo->setMbVolt($dev);
76
	} 
103
        }
77
} 
104
    }
78
 
105
 
-
 
106
    /**
-
 
107
     * get the information
-
 
108
     *
-
 
109
     * @see PSI_Interface_Sensor::build()
-
 
110
     *
-
 
111
     * @return Void
-
 
112
     */
-
 
113
    public function build()
-
 
114
    {
-
 
115
        $this->_fans();
-
 
116
        $this->_temperature();
-
 
117
        $this->_voltage();
-
 
118
    }
79
?>
119
}
80
 
120