1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
<?php
/**
* Open Hardware Monitor sensor class, getting information from Open Hardware Monitor
*
* PHP version 5
*
* @category PHP
* @package PSI_Sensor
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
* @copyright 2014 phpSysInfo
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
* @version Release: 3.0
* @link http://phpsysinfo.sourceforge.net
*/
class OHM extends Sensors
{
/**
* holds the COM object that we pull all the WMI data from
*
* @var Object
*/
private $_buf = array();
/**
* fill the private content var
*/
public function __construct()
{
parent::__construct();
if ((PSI_OS == 'WINNT') || (defined('PSI_EMU_HOSTNAME') && !defined('PSI_EMU_PORT'))) {
$_wmi = WINNT::initWMI('root\OpenHardwareMonitor', true);
if ($_wmi) {
$tmpbuf = WINNT::getWMI($_wmi, 'Sensor', array('Parent', 'Name', 'SensorType', 'Value'));
if ($tmpbuf) foreach ($tmpbuf as $buffer) {
if (!isset($this->_buf[$buffer['SensorType']]) || !isset($this->_buf[$buffer['SensorType']][$buffer['Parent'].' '.$buffer['Name']])) { // avoid duplicates
$this->_buf[$buffer['SensorType']][$buffer['Parent'].' '.$buffer['Name']] = $buffer['Value'];
}
}
}
}
}
/**
* get temperature information
*
* @return void
*/
private function _temperature()
{
if (isset($this->_buf['Temperature'])) foreach ($this->_buf['Temperature'] as $name=>$value) {
$dev = new SensorDevice();
$dev->setName($name);
$dev->setValue($value);
$this->mbinfo->setMbTemp($dev);
}
}
/**
* get voltage information
*
* @return void
*/
private function _voltage()
{
if (isset($this->_buf['Voltage'])) foreach ($this->_buf['Voltage'] as $name=>$value) {
$dev = new SensorDevice();
$dev->setName($name);
$dev->setValue($value);
$this->mbinfo->setMbVolt($dev);
}
}
/**
* get fan information
*
* @return void
*/
private function _fans()
{
if (isset($this->_buf['Fan'])) foreach ($this->_buf['Fan'] as $name=>$value) {
$dev = new SensorDevice();
$dev->setName($name);
$dev->setValue($value);
$this->mbinfo->setMbFan($dev);
}
}
/**
* get power information
*
* @return void
*/
private function _power()
{
if (isset($this->_buf['Power'])) foreach ($this->_buf['Power'] as $name=>$value) {
$dev = new SensorDevice();
$dev->setName($name);
$dev->setValue($value);
$this->mbinfo->setMbPower($dev);
}
}
/**
* get the information
*
* @see PSI_Interface_Sensor::build()
*
* @return void
*/
public function build()
{
$this->_temperature();
$this->_voltage();
$this->_fans();
$this->_power();
}
}
|