server_state <> 5) return "---"; switch($result->outcome) { case 1: return $string_to_show; //Success case 2: return "---"; //Couldn't send case 3: if ($result->exit_status <> -221) { return $string_to_show; //Client error } else return "---"; // Aborted by server case 4: return "---"; //No reply case 5: return "---"; //Didn't need case 6: return "---"; // Validate error case 7: return "---"; // client detached default: return $string_to_show; } } function result_granted_credit_string($result, $string_to_show) { if ($result->server_state <> 5) return "---"; switch($result->outcome) { case 1: //Success switch ($result->validate_state) { case 0: case 4: return "pending"; } return $string_to_show; case 2: return "---"; //Couldn't send case 3: return "---"; //Client error case 4: return "---"; //No reply case 5: return "---"; //Didn't need case 6: return "---"; //Validate error case 7: return "---"; // client detached default: return $string_to_show; } } function result_server_state_string($result) { switch($result->server_state) { case 1: return "Inactive"; case 2: return "Unsent"; case 4: return "In Progress"; case 5: return "Over"; } return "Unknown"; } function result_outcome_string($result) { switch($result->outcome) { case 1: return "Success"; case 2: return "Couldn't send"; case 3: if ($result->exit_status <> -221) { return "Client error"; } else return "Redundant result"; case 4: return "No reply"; case 5: return "Didn't need"; case 6: return "Validate error"; case 7: return "Client detached"; } return "Unknown"; } function result_client_state_string($result) { switch($result->client_state) { case 0: return "New"; case 1: return "Downloading"; case 2: return "Computing"; case 3: return "Compute error"; case 4: return "Uploading"; case 5: return "Done"; case 6: if ($result->exit_status <> -221) { return "Aborted by user"; } else return "Cancelled by server"; } } function validate_state_str($result) { switch($result->validate_state) { case 0: return "Initial"; case 1: return "Valid"; case 2: if ($result->exit_status <> -221) { return "Invalid"; } else return "Not necessary"; case 3: return "Workunit error - check skipped"; case 4: return "Checked, but no consensus yet"; case 5: return "Task was reported too late to validate"; } return "Unknown"; } function wu_error_mask_str($s) { $x = ""; if ($s & 1) { $x = $x."Couldn't send result "; $s -= 1; } if ($s & 2) { $x = $x."Too many error results "; $s -= 2; } if ($s & 4) { $x = $x."Too many success results "; $s -= 4; } if ($s & 8) { $x = $x."Too many total results "; $s -= 8; } if ($s & 16) { $x = $x."Cancelled "; $s -= 16; } if ($s) { $x = $x."Unrecognized Error: $s "; } if (strlen($x)) { } else { $x="
"; } return $x; } function result_table_start($show_wu_link, $show_host_link, $show_result_link) { start_table(); echo " "; if ($show_result_link) { echo "Task ID
click for details\n"; } if ($show_wu_link) { echo "Work unit ID
click for details\n"; } if ($show_host_link) { echo "Computer\n"; } echo " Sent Time reported
or deadline
explain Server state
explain Outcome
explain Client state
explain CPU time (sec) claimed credit granted credit "; } // was result invalid or timed out? // function bad_result($result) { if ($result->validate_state == 2) return true; if (!$result->received_time && ($result->report_deadline < time())) return true; return false; } function show_result_row( $result, $show_wu_link, $show_host_link, $show_result_link ) { $s = time_str($result->sent_time); // if result has been received, show the received time, // else show the reporting deadline in green if in the future // and in red if in the past. // if ($result->received_time) { $r = time_str($result->received_time); } else if ($result->report_deadline) { if ($result->report_deadline>time()) { $r = "" . time_str($result->report_deadline) . ""; } else { $r = "" . time_str($result->report_deadline) . ""; } } else { $r = "---"; } $ss = result_server_state_string($result); $out = result_outcome_string($result); $cl = result_client_state_string($result); $result_claimed_credit = format_credit($result->claimed_credit); $result_granted_credit = format_credit($result->granted_credit); $result_claimed_credit = result_claimed_credit_string($result, $result_claimed_credit); $result_granted_credit = result_granted_credit_string($result, $result_granted_credit); if (bad_result($result)) { echo ""; } else { echo ""; } if ($show_result_link) { echo "id\" title=\"Name: ".$result->name."\">$result->id\n"; } if ($show_wu_link) { echo "workunitid\">$result->workunitid\n"; } if ($show_host_link) { echo "", host_link($result->hostid), "\n"; } if ($result->server_state <> 5) { $cpu_time = "---"; } else { $cpu_time = number_format($result->cpu_time, 2); } echo " $s $r $ss $out $cl $cpu_time $result_claimed_credit $result_granted_credit "; } function version_string($version_num) { if (!$version_num) { return '---'; } else { return sprintf("%.2f", $version_num/100); } } function exit_status_string($result) { $x = $result->exit_status; if ($x == 0) { $y = parse_element($result->stderr_out, ""); if ($y) { $x = (int)$y; } } return sprintf("%d (0x%x)", $x, $x); } function show_result($result) { start_table(); row2("Task ID", $result->id); row2("Name", $result->name); row2("Workunit", "workunitid\">$result->workunitid"); row2("Created", time_str($result->create_time)); row2("Sent", time_str($result->sent_time)); row2("Received", time_str($result->received_time)); row2("Server state", result_server_state_string($result)); row2("Outcome", result_outcome_string($result)); row2("Client state", result_client_state_string($result)); row2("Exit status", exit_status_string($result)); row2("Computer ID", host_link($result->hostid)); row2("Report deadline", time_str($result->report_deadline)); row2("CPU time", $result->cpu_time); row2("stderr out", "
".htmlspecialchars($result->stderr_out)."
"); row2("Validate state", validate_state_str($result)); row2("Claimed credit", $result->claimed_credit); row2("Granted credit", $result->granted_credit); row2("application version", version_string($result->app_version_num)); end_table(); } function show_result_navigation( $clause, $number_of_results, $offset, $results_per_page ) { echo "
"; if ($offset >= $results_per_page) { $offset_p = $offset-$results_per_page; echo "Previous $results_per_page"; } if (($offset >= $results_per_page) && ($number_of_results > $results_per_page)) { echo " | "; } if ($number_of_results > $results_per_page) { $offset_n = $offset+$results_per_page; echo "Next $results_per_page

"; } else { echo "

"; } } ?>