2024-09-07 20:53:46 +10:00
|
|
|
<?php
|
|
|
|
/**
|
2025-05-14 16:14:01 +01:00
|
|
|
* K8Temp sensor class, getting information from k8temp
|
2024-09-07 20:53:46 +10:00
|
|
|
*
|
|
|
|
* PHP version 5
|
|
|
|
*
|
|
|
|
* @category PHP
|
|
|
|
* @package PSI_Sensor
|
|
|
|
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
|
|
|
* @copyright 2009 phpSysInfo
|
2025-05-14 16:14:01 +01:00
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
2024-09-07 20:53:46 +10:00
|
|
|
* @version Release: 3.0
|
|
|
|
* @link http://phpsysinfo.sourceforge.net
|
|
|
|
*/
|
|
|
|
class K8Temp extends Sensors
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* content to parse
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
private $_lines = array();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fill the private array
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
2025-05-14 16:14:01 +01:00
|
|
|
if ((PSI_OS != 'WINNT') && (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT'))) switch (defined('PSI_SENSOR_K8TEMP_ACCESS')?strtolower(PSI_SENSOR_K8TEMP_ACCESS):'command') {
|
2024-09-07 20:53:46 +10:00
|
|
|
case 'command':
|
|
|
|
$lines = "";
|
|
|
|
CommonFunctions::executeProgram('k8temp', '', $lines);
|
|
|
|
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
|
|
|
break;
|
2025-05-14 16:14:01 +01:00
|
|
|
case 'data':
|
|
|
|
if (!defined('PSI_EMU_PORT') && CommonFunctions::rftsdata('k8temp.tmp', $lines)) {
|
2024-09-07 20:53:46 +10:00
|
|
|
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2025-05-14 16:14:01 +01:00
|
|
|
$this->error->addConfigError('__construct()', '[sensor_k8temp] ACCESS');
|
2024-09-07 20:53:46 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get temperature information
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
private function _temperature()
|
|
|
|
{
|
|
|
|
foreach ($this->_lines as $line) {
|
|
|
|
if (preg_match('/(.*):\s*(\d*)/', $line, $data)) {
|
|
|
|
if ($data[2] > 0) {
|
|
|
|
$dev = new SensorDevice();
|
|
|
|
$dev->setName($data[1]);
|
2025-05-14 16:14:01 +01:00
|
|
|
// $dev->setMax('70.0');
|
2024-09-07 20:53:46 +10:00
|
|
|
if ($data[2] < 250) {
|
|
|
|
$dev->setValue($data[2]);
|
|
|
|
}
|
|
|
|
$this->mbinfo->setMbTemp($dev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get the information
|
|
|
|
*
|
|
|
|
* @see PSI_Interface_Sensor::build()
|
|
|
|
*
|
2025-05-14 16:14:01 +01:00
|
|
|
* @return void
|
2024-09-07 20:53:46 +10:00
|
|
|
*/
|
|
|
|
public function build()
|
|
|
|
{
|
|
|
|
$this->_temperature();
|
|
|
|
}
|
|
|
|
}
|