Exemplo n.º 1
0
function timerSettings(&$s20Table, $mac, $actionValue)
{
    //
    // Implements  the actions selected in the web timer page.
    //
    $actionType = $_POST['actionType'];
    if ($actionValue == "clearSwitchOff" || $actionValue == "clearCountdown") {
        $h = $m = $s = 0;
        $act = $s20Table[$mac]['st'];
    } else {
        $action = $_POST['action'];
        $h = $_POST['hours'];
        $m = $_POST['minutes'];
        $s = $_POST['seconds'];
        $act = $action == "on" ? 1 : 0;
    }
    $sec = $h * 3600 + $m * 60 + $s;
    if ($actionValue == "clearCountdown" || $actionValue == "setCountdown" && $actionType == "now") {
        //
        // Update regular countdown timer
        //
        // Set
        setTimer($mac, $h, $m, $s, $act, $s20Table);
        // Confirm
        $s20Table[$mac]['timerVal'] = checkTimerSec($mac, $s20Table, $action);
        $s20Table[$mac]['timerAction'] = $action;
        if ($s20Table[$mac]['timerVal'] != $sec || $s20Table[$mac]['timerAction'] != $act) {
            error_log("Unexpected inconsistency in timerSettings function: " . $mac . " Set=(" . $sec . "," . $act . ") Res=(" . $s20Table[$mac]['timerVal'] . "," . $s20Table[$mac]['timerAction'] . ")\n");
            return 1;
        }
    } else {
        //
        // Update automatic switch off after on timer
        //
        if (setSwitchOffTimer($mac, $sec, $s20Table) != $sec) {
            error_log("Set switch off unsuccessfull in timersettings (wrote " . $sec . " something else read...");
            return 1;
        }
    }
    return 0;
}
Exemplo n.º 2
0
function timerSettings(&$s20Table, $actionValue)
{
    //
    // Implements  the actions selected in the web timer page.
    //
    $actionType = $_POST['actionType'];
    $name = $_POST['name'];
    $mac = getMacFromName($name, $s20Table);
    if ($actionValue == "clearSwitchOff" || $actionValue == "clearCountdown") {
        $h = $m = $s = 0;
        $act = $s20Table[$mac]['st'];
    } else {
        $action = $_POST['action'];
        $h = $_POST['hours'];
        $m = $_POST['minutes'];
        $s = $_POST['seconds'];
        $act = $action == "on" ? 1 : 0;
    }
    $sec = $h * 3600 + $m * 60 + $s;
    if ($actionValue == "clearCountdown" || $actionValue == "setCountdown" && $actionType == "now") {
        //
        // Update regular countdown timer
        //
        // Set
        setTimer($mac, $h, $m, $s, $act, $s20Table);
        // Confirm
        $s20Table[$mac]['timerVal'] = checkTimerSec($mac, $s20Table, $action);
        $s20Table[$mac]['timerAction'] = $action;
        if ($s20Table[$mac]['timerVal'] != $sec || $s20Table[$mac]['timerAction'] != $act) {
            return 1;
        }
    } else {
        //
        // Update automatic switch off after on timer
        //
        if (setSwitchOffTimer($mac, $sec, $s20Table) != $sec) {
            return 1;
        }
    }
    return 0;
}
Exemplo n.º 3
0
function updTableTimers(&$s20Table)
{
    //
    // Update the values of count down timers in table $s20Table
    //
    // echo "Update table timers <p>";
    $justTest = 0;
    foreach ($s20Table as $mac => $devData) {
        // Check && update count down timers
        $s20Table[$mac]['timerVal'] = checkTimerSec($mac, $s20Table, $action);
        $s20Table[$mac]['timerAction'] = $action;
        // Check && update switch off after on timer
        updNameAndTimerAfterOnDevice($mac, $s20Table);
    }
}
Exemplo n.º 4
0
function updTableTimers(&$s20Table)
{
    //
    // Update the values of count down timers in table $s20Table
    //
    $justTest = 0;
    foreach ($s20Table as $mac => $devData) {
        // Check && update count down timers
        if (!array_key_exists('off', $s20Table[$mac])) {
            $s20Table[$mac]['timerVal'] = checkTimerSec($mac, $s20Table, $action);
            $s20Table[$mac]['timerAction'] = $action;
            // Check && update switch off after on timer
            updNameAndTimerAfterOnDevice($mac, $s20Table);
            getAndParseTimerTable($mac, $s20Table);
        }
    }
}