66 lines
1.1 KiB
PHP
66 lines
1.1 KiB
PHP
<?php
|
|
logger(DEBUG, _("Including utils.php"), __FILE__ . ":" . __LINE__);
|
|
|
|
function bool2string($var)
|
|
{
|
|
if ($var === false)
|
|
{
|
|
return "false";
|
|
}elseif($var === true)
|
|
{
|
|
return "true";
|
|
}else
|
|
{
|
|
return $var;
|
|
}
|
|
}
|
|
|
|
function now()
|
|
{
|
|
$now = new datetime();
|
|
return $now;
|
|
}
|
|
|
|
function farenheit2celsius($value)
|
|
{
|
|
return round((((float)$value - 32) / 1.8),2);
|
|
}
|
|
|
|
function mph2kmh($value)
|
|
{
|
|
return round(((float)$value * 1.60934),2);
|
|
}
|
|
|
|
function millibars($value)
|
|
{
|
|
return round(((float)$value * 33.86),2);
|
|
}
|
|
|
|
function mktopic($device)
|
|
{
|
|
return $device->topic . "/" . $device->friendlyName;
|
|
}
|
|
|
|
function getValue($fn, $property)
|
|
{
|
|
global $indexDevices;
|
|
return $indexDevices[$fn]->$property["value"];
|
|
}
|
|
|
|
function setValue($fn, $property, $value)
|
|
{
|
|
global $indexDevices;
|
|
$indexDevices(RDC_SALON_MVMT2)->occupancy["value"] = $value;
|
|
}
|
|
|
|
logger(DEBUG, _("signal handling"), __FILE__ . ":" . __LINE__, false);
|
|
//signal handling
|
|
function signalHandler($signal)
|
|
{
|
|
endMoha();
|
|
}
|
|
pcntl_signal(SIGTERM, 'signalHandler');// Termination ('kill' was called)
|
|
pcntl_signal(SIGHUP, 'signalHandler'); // Terminal log-out
|
|
pcntl_signal(SIGINT, 'signalHandler');
|
|
?>
|