1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* K8Temp 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.k8temp.inc.php 661 2012-08-27 11:26:39Z namiltd $ |
13
|
|
|
* @link http://phpsysinfo.sourceforge.net |
14
|
|
|
*/ |
15
|
|
|
/** |
16
|
|
|
* getting information from k8temp |
17
|
|
|
* |
18
|
|
|
* @category PHP |
19
|
|
|
* @package PSI_Sensor |
20
|
|
|
* @author Michael Cramer <[email protected]> |
21
|
|
|
* @copyright 2009 phpSysInfo |
22
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
23
|
|
|
* @version Release: 3.0 |
24
|
|
|
* @link http://phpsysinfo.sourceforge.net |
25
|
|
|
*/ |
26
|
|
|
class K8Temp extends Sensors |
|
|
|
|
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* content to parse |
30
|
|
|
* |
31
|
|
|
* @var array |
32
|
|
|
*/ |
33
|
|
|
private $_lines = array(); |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* fill the private array |
37
|
|
|
*/ |
38
|
|
View Code Duplication |
public function __construct() |
|
|
|
|
39
|
|
|
{ |
40
|
|
|
parent::__construct(); |
41
|
|
|
switch (defined('PSI_SENSOR_K8TEMP_ACCESS')?strtolower(PSI_SENSOR_K8TEMP_ACCESS):'command') { |
42
|
|
|
case 'command': |
43
|
|
|
$lines = ""; |
44
|
|
|
CommonFunctions::executeProgram('k8temp', '', $lines); |
45
|
|
|
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY); |
46
|
|
|
break; |
47
|
|
|
case 'data': |
48
|
|
|
if (CommonFunctions::rfts(APP_ROOT.'/data/k8temp.txt', $lines)) { |
49
|
|
|
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY); |
50
|
|
|
} |
51
|
|
|
break; |
52
|
|
|
default: |
53
|
|
|
$this->error->addConfigError('__construct()', 'PSI_SENSOR_K8TEMP_ACCESS'); |
54
|
|
|
break; |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* get temperature information |
60
|
|
|
* |
61
|
|
|
* @return void |
62
|
|
|
*/ |
63
|
|
|
private function _temperature() |
64
|
|
|
{ |
65
|
|
|
foreach ($this->_lines as $line) { |
66
|
|
|
if (preg_match('/(.*):\s*(\d*)/', $line, $data)) { |
67
|
|
|
if ($data[2] > 0) { |
68
|
|
|
$dev = new SensorDevice(); |
69
|
|
|
$dev->setName($data[1]); |
70
|
|
|
// $dev->setMax('70.0'); |
|
|
|
|
71
|
|
|
if ($data[2] < 250) { |
72
|
|
|
$dev->setValue($data[2]); |
73
|
|
|
} |
74
|
|
|
$this->mbinfo->setMbTemp($dev); |
|
|
|
|
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* get the information |
82
|
|
|
* |
83
|
|
|
* @see PSI_Interface_Sensor::build() |
84
|
|
|
* |
85
|
|
|
* @return Void |
86
|
|
|
*/ |
87
|
|
|
public function build() |
88
|
|
|
{ |
89
|
|
|
$this->_temperature(); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
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.