Exemplo n.º 1
0
function updateAllStatus($s20Table)
{
    //
    // This function updates the power status of all S20 in $allAllS20Data.
    //
    // InitS20Data also fills the power status when it is called.
    // However, this function is more efficient when $s20Table
    // was already initialized and relevant available
    // and one just wants to update the power status of all S20s
    //
    // echo "Update all status <p>";
    foreach ($s20Table as $mac => $devData) {
        $s20Table[$mac]['st'] = checkStatus($mac, $s20Table);
    }
    updTableTimers($s20Table);
    return $s20Table;
}
Exemplo n.º 2
0
function updateAllStatus(&$s20Table)
{
    //
    // This function updates the power status of all S20 in $allAllS20Data.
    //
    // InitS20Data also fills the power status when it is called.
    // However, this function is more efficient if the $s20Table
    // was already initialized and one just wants to update the
    // power status of all S20s
    //
    foreach ($s20Table as $mac => $devData) {
        if (!array_key_exists('off', $s20Table[$mac])) {
            $s20Table[$mac]['st'] = checkStatus($mac, $s20Table);
        } else {
            $offTime = $s20Table[$mac]['off'];
            if ($offTime - time() > 300) {
                // if last time checked more than 5 minutes ago, try again
                $st = checkStatus($mac, $s20Table);
                if ($st >= 0) {
                    unset($s20Table[$mac]['off']);
                    $s20Table[$mac]['st'] = $st;
                }
            }
        }
    }
    updTableTimers($s20Table);
    writeDataFile($s20Table);
    return $s20Table;
}