1
0

debuggage

This commit is contained in:
2022-01-23 09:46:06 +01:00
parent 10f2a1087a
commit fc4eaf2238
14 changed files with 294 additions and 157 deletions

View File

@ -3,7 +3,7 @@ logger(DEBUG,"Including db.php");
class db extends mysqli
{
public $mysqlServer = "localhost"; // "127.0.0.1";
public $mysqlServer = "127.0.0.1"; // Your production server
public $username = "moha";
public $passwd = "MysqlMoha";
public $database = "moha";
@ -11,10 +11,21 @@ class db extends mysqli
function __construct()
{
if ($this->connect($this->mysqlServer, $this->username, $this->passwd, $this->database) === false)
global $testMode;
$flagError = false;
if ($testMode)
{
logger(ERROR,"Connection to sql server error :" . $this->connect_error);
return 2;
$this->mysqlServer = "192.168.1.253"; // Your test server
}
while ($this->connect($this->mysqlServer, $this->username, $this->passwd, $this->database) === false)
{
logger(ERROR,_("Connection to sql server error :") . $this->connect_error);
sleep(5);
$flagError = true;
}
if ($flagError === true)
{
logger(ERROR, _("Connection to sql server ready"));
}
$result = new mysqli_result($this);
}
@ -38,14 +49,19 @@ class db extends mysqli
if (is_numeric($value) and !empty($properties2log[$propertyTree]))
{
// calculate a min/max value for storing data
$var = $properties2log[$propertyTree];
if (!is_numeric($var))
if (is_callable($var))
{
$minMax = (float)$value * (float)$var / 100;
}else
{
$minMax = $var;
$var = $var($value);
}
//if (!is_numeric($var))
//{
$minMax = (float)$value + $var;
//}else
//{
// $minMax = $var;
//}
echo "minMax = " .$minMax . EOL;
//echo "oldValue = " . $oldValue . EOL;
//echo "Value = " . $value . EOL;

View File

@ -11,6 +11,10 @@ class hook
{
logger(DEBUG, _("Initializing hook: ") . $this->hookName);
$this->installHooks();
if (method_exists($this, "init"))
{
$this->init();
}
}
function installHooks()

View File

@ -32,11 +32,11 @@ class device
public $functions;
public $payload;
public $availability;
public $toConfirm;
private function __construct()
{
$this->availability = array("value" => null, "functions" => array());
var_dump($this->availability);
}
public function set($method=0) //, $event = null)