|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* MBM5 sensor class |
|
4
|
|
|
* |
|
5
|
|
|
* PHP version 5 |
|
6
|
|
|
* |
|
7
|
|
|
* @category PHP |
|
8
|
|
|
* @package PSI_Sensor |
|
9
|
|
|
* @author Michael Cramer <[email protected]> |
|
10
|
|
|
* @copyright 2009 phpSysInfo |
|
11
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
|
12
|
|
|
* @version SVN: $Id: class.mbm5.inc.php 661 2012-08-27 11:26:39Z namiltd $ |
|
13
|
|
|
* @link http://phpsysinfo.sourceforge.net |
|
14
|
|
|
*/ |
|
15
|
|
|
/** |
|
16
|
|
|
* getting information from Motherboard Monitor 5 |
|
17
|
|
|
* information retrival through csv file |
|
18
|
|
|
* |
|
19
|
|
|
* @category PHP |
|
20
|
|
|
* @package PSI_Sensor |
|
21
|
|
|
* @author Michael Cramer <[email protected]> |
|
22
|
|
|
* @copyright 2009 phpSysInfo |
|
23
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
|
24
|
|
|
* @version Release: 3.0 |
|
25
|
|
|
* @link http://phpsysinfo.sourceforge.net |
|
26
|
|
|
*/ |
|
27
|
|
|
class MBM5 extends Sensors |
|
|
|
|
|
|
28
|
|
|
{ |
|
29
|
|
|
/** |
|
30
|
|
|
* array with the names of the labels |
|
31
|
|
|
* |
|
32
|
|
|
* @var array |
|
33
|
|
|
*/ |
|
34
|
|
|
private $_buf_label = array(); |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* array withe the values |
|
38
|
|
|
* |
|
39
|
|
|
* @var array |
|
40
|
|
|
*/ |
|
41
|
|
|
private $_buf_value = array(); |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* read the MBM5.csv file and fill the private arrays |
|
45
|
|
|
*/ |
|
46
|
|
|
public function __construct() |
|
47
|
|
|
{ |
|
48
|
|
|
parent::__construct(); |
|
49
|
|
|
$delim = "/;/"; |
|
50
|
|
|
CommonFunctions::rfts(APP_ROOT."/data/MBM5.csv", $buffer); |
|
51
|
|
|
if (strpos($buffer, ";") === false) { |
|
52
|
|
|
$delim = "/,/"; |
|
53
|
|
|
} |
|
54
|
|
|
$buffer = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY); |
|
55
|
|
|
$this->_buf_label = preg_split($delim, substr($buffer[0], 0, -2), -1, PREG_SPLIT_NO_EMPTY); |
|
56
|
|
|
$this->_buf_value = preg_split($delim, substr($buffer[1], 0, -2), -1, PREG_SPLIT_NO_EMPTY); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* get temperature information |
|
61
|
|
|
* |
|
62
|
|
|
* @return void |
|
63
|
|
|
*/ |
|
64
|
|
View Code Duplication |
private function _temperature() |
|
|
|
|
|
|
65
|
|
|
{ |
|
66
|
|
|
for ($intPosi = 3; $intPosi < 6; $intPosi++) { |
|
67
|
|
|
if ($this->_buf_value[$intPosi] == 0) { |
|
68
|
|
|
continue; |
|
69
|
|
|
} |
|
70
|
|
|
preg_match("/([0-9\.])*/", str_replace(",", ".", $this->_buf_value[$intPosi]), $hits); |
|
71
|
|
|
$dev = new SensorDevice(); |
|
72
|
|
|
$dev->setName($this->_buf_label[$intPosi]); |
|
73
|
|
|
$dev->setValue($hits[0]); |
|
74
|
|
|
// $dev->setMax(70); |
|
|
|
|
|
|
75
|
|
|
$this->mbinfo->setMbTemp($dev); |
|
|
|
|
|
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* get fan information |
|
81
|
|
|
* |
|
82
|
|
|
* @return void |
|
83
|
|
|
*/ |
|
84
|
|
View Code Duplication |
private function _fans() |
|
|
|
|
|
|
85
|
|
|
{ |
|
86
|
|
|
for ($intPosi = 13; $intPosi < 16; $intPosi++) { |
|
87
|
|
|
if (!isset($this->_buf_value[$intPosi])) { |
|
88
|
|
|
continue; |
|
89
|
|
|
} |
|
90
|
|
|
preg_match("/([0-9\.])*/", str_replace(",", ".", $this->_buf_value[$intPosi]), $hits); |
|
91
|
|
|
$dev = new SensorDevice(); |
|
92
|
|
|
$dev->setName($this->_buf_label[$intPosi]); |
|
93
|
|
|
$dev->setValue($hits[0]); |
|
94
|
|
|
// $dev->setMin(3000); |
|
|
|
|
|
|
95
|
|
|
$this->mbinfo->setMbFan($dev); |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* get voltage information |
|
101
|
|
|
* |
|
102
|
|
|
* @return void |
|
103
|
|
|
*/ |
|
104
|
|
View Code Duplication |
private function _voltage() |
|
|
|
|
|
|
105
|
|
|
{ |
|
106
|
|
|
for ($intPosi = 6; $intPosi < 13; $intPosi++) { |
|
107
|
|
|
if ($this->_buf_value[$intPosi] == 0) { |
|
108
|
|
|
continue; |
|
109
|
|
|
} |
|
110
|
|
|
preg_match("/([0-9\.])*/", str_replace(",", ".", $this->_buf_value[$intPosi]), $hits); |
|
111
|
|
|
$dev = new SensorDevice(); |
|
112
|
|
|
$dev->setName($this->_buf_label[$intPosi]); |
|
113
|
|
|
$dev->setValue($hits[0]); |
|
114
|
|
|
$this->mbinfo->setMbVolt($dev); |
|
|
|
|
|
|
115
|
|
|
} |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* get the information |
|
120
|
|
|
* |
|
121
|
|
|
* @see PSI_Interface_Sensor::build() |
|
122
|
|
|
* |
|
123
|
|
|
* @return Void |
|
124
|
|
|
*/ |
|
125
|
|
|
public function build() |
|
126
|
|
|
{ |
|
127
|
|
|
$this->_fans(); |
|
128
|
|
|
$this->_temperature(); |
|
129
|
|
|
$this->_voltage(); |
|
130
|
|
|
} |
|
131
|
|
|
} |
|
132
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.