1
0

a lot of debug

This commit is contained in:
2022-04-23 02:00:52 +02:00
parent f8fc3f63ec
commit d1f1065e44
21 changed files with 544 additions and 217 deletions

View File

@@ -8,7 +8,7 @@ function checkEvents()
{
global $logLevel, $events;
$oldLevel = $logLevel;
$logLevel = DEBUG;
//$logLevel = DEBUG;
$exception = false;
if ($events === null)
{
@@ -68,10 +68,12 @@ function checkEvents()
}
}
//print_r($events);
$logLevel = $oldLevel;
//$logLevel = $oldLevel;
}
function setOneshotEvent(&$deviceObject, $datetime, $property, $value, $replace=false, $method=null)
// datetime format : "yyyy-mm-dd hh:mm:ss"
function setOneshotEvent(device &$deviceObject, string $datetime, $property, $value, $replace=false, $method=null)
{
global $events;
$events[] = new event;
@@ -85,18 +87,20 @@ function setOneshotEvent(&$deviceObject, $datetime, $property, $value, $replace=
if ($method !==null) $events[$key]->method =$method;
}
function setRecurrentEvent(&$deviceObject, $property, $value, $startDatetime, $stopDatetime, $hours, $minutes, $seconds, $days, $weeks, $months, $years, $method = null)
// startDatetime and stopDatetime format : "yyyy-mm-dd hh:mm:ss"
function setRecurrentEvent(device &$deviceObject, string $property, $value, string $startDatetime, string $stopDatetime, int $hours, int $minutes, int $seconds, int $days, int $weeks, int $months, int $years, int $method = null)
{
global $events;
$string = "P";
if (!empty($years)) $string .= $days . "Y";
if (!empty($months)) $string .= $days . "M";
if (!empty($years)) $string .= $years . "Y";
if (!empty($months)) $string .= $months . "M";
if (!empty($week)) $string .= $week . "W";
if (!empty($days)) $string .= $days . "D";
$string .= "T";
if (!empty($hours)) $string .= $days . "H";
if (!empty($months)) $string .= $days . "M";
if (!empty($seconds)) $string .= $days . "S";
if (!empty($hours)) $string .= $hours . "H";
if (!empty($months)) $string .= $months . "M";
if (!empty($seconds)) $string .= $seconds . "S";
$event = new event;
@@ -117,7 +121,7 @@ function setRecurrentEvent(&$deviceObject, $property, $value, $startDatetime, $s
if ($method !== null) $event->method = $method;
}
function setDelay(&$deviceObject, $delay, $unit, $property, $value, $replace=false, $method = null)
function setDelay(device &$deviceObject, float $delay, string $unit, string $property, $value, bool $replace=false, int $method = null)
{
global $events, $logLevel;
$oldLevel = $logLevel;
@@ -160,7 +164,7 @@ function setDelay(&$deviceObject, $delay, $unit, $property, $value, $replace=fal
if ($replace)
{
$eventKey = searchEvent($deviceObject, $property, $value);
if ($eventKey !== false) deleteEvent($events[$eventKey]);
if ($eventKey !== false) deleteEvent($eventKey);
}
//$dt = $datetime->format("Y-m-d\TH:i:s\Z");
$events[] = new event;
@@ -177,7 +181,7 @@ function setDelay(&$deviceObject, $delay, $unit, $property, $value, $replace=fal
$logLevel = $oldLevel;
}
function removeEvent($deviceObject, $property , $value, $method = null)
function removeEvent(device $deviceObject, string $property , $value, int $method = null)
{
global $events;
$eventKey = searchEvent($deviceObject, $property , $value);
@@ -188,7 +192,7 @@ function removeEvent($deviceObject, $property , $value, $method = null)
}
}
function searchEvent($deviceObject, $property , $value)
function searchEvent(device $deviceObject, string $property , $value)
{
global $events;
logger(DEBUG, sprintf(_("searching event for device %s, property %s and value %s"), $deviceObject->friendlyName, $property, bool2string($value)), __FILE__ . ":" . __LINE__);
@@ -205,7 +209,7 @@ function searchEvent($deviceObject, $property , $value)
}
// warning delete event does not manage method of the device (IDLE, )
function deleteEvent($eventKey)
function deleteEvent(int $eventKey)
{
global $events;
if ($eventKey !== false)