Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 2769 → Rev 2770

/web/acc/phpsysinfo/includes/mb/class.mbm5.inc.php
1,79 → 1,119
<?php
//
// phpSysInfo - A PHP System Information Script
// http://phpsysinfo.sourceforge.net/
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// $Id: class.mbm5.inc.php,v 1.7 2007/02/18 19:11:31 bigmichi1 Exp $
<?php
/**
* MBM5 sensor class, getting information from Motherboard Monitor 5 information retrival through csv file
*
* PHP version 5
*
* @category PHP
* @package PSI_Sensor
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
* @copyright 2009 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 MBM5 extends Sensors
{
/**
* array with the names of the labels
*
* @var array
*/
private $_buf_label = array();
 
class mbinfo {
var $buf_label;
var $buf_value;
/**
* array withe the values
*
* @var array
*/
private $_buf_value = array();
 
function mbinfo() {
$buffer = rfts( APP_ROOT . "/data/MBM5.csv" );
if( strpos( $buffer, ";") === false ) {
$delim = ",";
} else {
$delim = ";";
}
$buffer = explode( "\n", $buffer );
$this->buf_label = explode( $delim, $buffer[0] );
$this->buf_value = explode( $delim, $buffer[1] );
}
function temperature() {
$results = array();
$intCount = 0;
for( $intPosi = 3; $intPosi < 6; $intPosi++ ) {
$results[$intCount]['label'] = $this->buf_label[$intPosi];
$results[$intCount]['value'] = $this->buf_value[$intPosi];
$results[$intCount]['limit'] = '70.0';
$intCount++;
}
return $results;
}
function fans() {
$results = array();
$intCount = 0;
for( $intPosi = 13; $intPosi < 16; $intPosi++ ) {
$results[$intCount]['label'] = $this->buf_label[$intPosi];
$results[$intCount]['value'] = $this->buf_value[$intPosi];
$results[$intCount]['min'] = '3000';
$intCount++;
}
return $results;
}
function voltage() {
$results = array();
$intCount = 0;
for( $intPosi = 6; $intPosi < 13; $intPosi++ ) {
$results[$intCount]['label'] = $this->buf_label[$intPosi];
$results[$intCount]['value'] = $this->buf_value[$intPosi];
$results[$intCount]['min'] = '0.00';
$results[$intCount]['max'] = '0.00';
$intCount++;
}
return $results;
}
}
/**
* read the MBM5.csv file and fill the private arrays
*/
public function __construct()
{
parent::__construct();
$delim = "/;/";
CommonFunctions::rfts(PSI_APP_ROOT."/data/MBM5.csv", $buffer);
if (strpos($buffer, ";") === false) {
$delim = "/,/";
}
$buffer = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
$this->_buf_label = preg_split($delim, substr($buffer[0], 0, -2), -1, PREG_SPLIT_NO_EMPTY);
$this->_buf_value = preg_split($delim, substr($buffer[1], 0, -2), -1, PREG_SPLIT_NO_EMPTY);
}
 
?>
/**
* get temperature information
*
* @return void
*/
private function _temperature()
{
for ($intPosi = 3; $intPosi < 6; $intPosi++) {
if ($this->_buf_value[$intPosi] == 0) {
continue;
}
preg_match("/([0-9\.])*/", str_replace(",", ".", $this->_buf_value[$intPosi]), $hits);
$dev = new SensorDevice();
$dev->setName($this->_buf_label[$intPosi]);
$dev->setValue($hits[0]);
// $dev->setMax(70);
$this->mbinfo->setMbTemp($dev);
}
}
 
/**
* get fan information
*
* @return void
*/
private function _fans()
{
for ($intPosi = 13; $intPosi < 16; $intPosi++) {
if (!isset($this->_buf_value[$intPosi])) {
continue;
}
preg_match("/([0-9\.])*/", str_replace(",", ".", $this->_buf_value[$intPosi]), $hits);
$dev = new SensorDevice();
$dev->setName($this->_buf_label[$intPosi]);
$dev->setValue($hits[0]);
// $dev->setMin(3000);
$this->mbinfo->setMbFan($dev);
}
}
 
/**
* get voltage information
*
* @return void
*/
private function _voltage()
{
for ($intPosi = 6; $intPosi < 13; $intPosi++) {
if ($this->_buf_value[$intPosi] == 0) {
continue;
}
preg_match("/([0-9\.])*/", str_replace(",", ".", $this->_buf_value[$intPosi]), $hits);
$dev = new SensorDevice();
$dev->setName($this->_buf_label[$intPosi]);
$dev->setValue($hits[0]);
$this->mbinfo->setMbVolt($dev);
}
}
 
/**
* get the information
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
*/
public function build()
{
$this->_fans();
$this->_temperature();
$this->_voltage();
}
}