diff --git a/api/boinc_api.cpp b/api/boinc_api.cpp index 6b58f1dfd2..6d8be85033 100644 --- a/api/boinc_api.cpp +++ b/api/boinc_api.cpp @@ -141,12 +141,10 @@ static volatile int interrupt_count = 0; static volatile int running_interrupt_count = 0; // number of timer interrupts while not suspended. // Used to compute elapsed time -static double fpops_per_cpu_sec = 0; -static double fpops_cumulative = 0; -static double intops_per_cpu_sec = 0; -static double intops_cumulative = 0; static int want_network = 0; static int have_network = 1; +static double bytes_sent = 0; +static double bytes_received = 0; bool g_sleep = false; // simulate unresponsive app by setting to true (debugging) static FUNC_PTR timer_callback = 0; @@ -336,21 +334,13 @@ static bool update_app_progress(double cpu_t, double cp_cpu_t) { sprintf(buf, "%e\n", fdone); strlcat(msg_buf, buf, MSG_CHANNEL_SIZE); } - if (fpops_per_cpu_sec) { - sprintf(buf, "%e\n", fpops_per_cpu_sec); - strlcat(msg_buf, buf, MSG_CHANNEL_SIZE); + if (bytes_sent) { + sprintf(buf, "%f\n", bytes_sent); + strcat(msg_buf, buf); } - if (fpops_cumulative) { - sprintf(buf, "%e\n", fpops_cumulative); - strlcat(msg_buf, buf, MSG_CHANNEL_SIZE); - } - if (intops_per_cpu_sec) { - sprintf(buf, "%e\n", intops_per_cpu_sec); - strlcat(msg_buf, buf, MSG_CHANNEL_SIZE); - } - if (intops_cumulative) { - sprintf(buf, "%e\n", intops_cumulative); - strlcat(msg_buf, buf, MSG_CHANNEL_SIZE); + if (bytes_received) { + sprintf(buf, "%f\n", bytes_received); + strcat(msg_buf, buf); } return app_client_shm->shm->app_status.send_msg(msg_buf); } @@ -684,6 +674,11 @@ void boinc_exit(int status) { #endif } +void boinc_network_usage(double sent, double received) { + bytes_sent = sent; + bytes_received = received; +} + int boinc_is_standalone() { if (standalone) return 1; return 0; @@ -754,8 +749,8 @@ int boinc_report_app_status_aux( double checkpoint_cpu_time, double _fraction_done, int other_pid, - double bytes_sent, - double bytes_received + double _bytes_sent, + double _bytes_received ) { char msg_buf[MSG_CHANNEL_SIZE], buf[256]; if (standalone) return 0; @@ -772,12 +767,12 @@ int boinc_report_app_status_aux( sprintf(buf, "%d\n", other_pid); strcat(msg_buf, buf); } - if (bytes_sent) { - sprintf(buf, "%f\n", bytes_sent); + if (_bytes_sent) { + sprintf(buf, "%f\n", _bytes_sent); strcat(msg_buf, buf); } - if (bytes_received) { - sprintf(buf, "%f\n", bytes_received); + if (_bytes_received) { + sprintf(buf, "%f\n", _bytes_received); strcat(msg_buf, buf); } if (app_client_shm->shm->app_status.send_msg(msg_buf)) { @@ -1433,20 +1428,6 @@ int boinc_upload_status(std::string& name) { return ERR_NOT_FOUND; } -void boinc_ops_per_cpu_sec(double fp, double i) { - fpops_per_cpu_sec = fp; - intops_per_cpu_sec = i; -} - -void boinc_ops_cumulative(double fp, double i) { - fpops_cumulative = fp; - intops_cumulative = i; -} - -void boinc_set_credit_claim(double credit) { - boinc_ops_cumulative(credit*8.64000e+11, 0); -} - void boinc_need_network() { want_network = 1; have_network = 0; diff --git a/api/boinc_api.h b/api/boinc_api.h index 50e8a8c940..a3f87a61e7 100644 --- a/api/boinc_api.h +++ b/api/boinc_api.h @@ -100,6 +100,7 @@ extern void boinc_end_critical_section(); extern void boinc_need_network(); extern int boinc_network_poll(); extern void boinc_network_done(); +extern void boinc_network_usage(double sent, double received); extern int boinc_is_standalone(void); extern void boinc_ops_per_cpu_sec(double fp, double integer); extern void boinc_ops_cumulative(double fp, double integer); diff --git a/checkin_notes b/checkin_notes index ca2a238f11..122ffebd0e 100644 --- a/checkin_notes +++ b/checkin_notes @@ -3958,3 +3958,18 @@ Rom 18 May 2012 AccountManagerInfoPage.cpp clientgui/ ProjectListCtrl.cpp, .h + +David 20 May 2012 + - API: add boinc_network_usage(); + lets an application report its network usage to BOINC, + and hence take it into account with monthly limits etc. + - API: get rid of deprecated boinc_ops_per_cpu_sec(), + boinc_ops_cumulative(), and + boinc_set_credit_claim(); + - admin web: update manage_apps.php; + add the ability to set homogeneous app version + + html/ops/ + manage_apps.php + api/ + boinc_api.cpp,h diff --git a/html/ops/manage_apps.php b/html/ops/manage_apps.php index 955e5cdc28..58d07621df 100644 --- a/html/ops/manage_apps.php +++ b/html/ops/manage_apps.php @@ -18,15 +18,13 @@ -/***********************************************************************\ - * Display and Manage BOINC Application Versions - * - * This page presents a form with information about application versions. - * Some of the fields can be changed. - * - * Eric Myers - 4 June 2006 - * @(#) $Id$ -\***********************************************************************/ +// Display and Manage BOINC Application Versions +// +// This page presents a form with information about application versions. +// Some of the fields can be changed. +// +// Eric Myers - 4 June 2006 +// @(#) $Id$ // TODO - code cleanup and use new DB interface @@ -36,217 +34,190 @@ db_init(); $commands = ""; -// Platform and application labels (are better than numbers) +// process form input for changes +// +function do_updates() { + $apps = BoincApp::enum(""); -$result = mysql_query("SELECT * FROM platform"); -$Nplatform = mysql_num_rows($result); -for($i=0;$i<$Nplatform;$i++){ - $item=mysql_fetch_object($result); - $id=$item->id; - $plat_off[$id]=$item->deprecated; - $platform[$id]=$item->user_friendly_name; - } -mysql_free_result($result); + foreach ($apps as $app) { + $id = $app->id; -/***************************************************\ - * Action: process form input for changes - \***************************************************/ - -if( !empty($_POST) ) { - - /* Changing properties of existing applications */ - - $result = mysql_query("SELECT * FROM app"); - $Nrow=mysql_num_rows($result); - - for($j=1;$j<=$Nrow;$j++){ // test/update each row in DB - $item=mysql_fetch_object($result); - $id=$item->id; - - /* Change deprecated status? */ - $field="deprecated_".$id; - $new_v= (post_str($field, true)=='on') ? 1 : 0; - $old_v=$item->deprecated; - if($new_v != $old_v ) { - $cmd = "UPDATE app SET deprecated=$new_v WHERE id=$id"; - $commands .= "

$cmd
\n"; - mysql_query($cmd); + // Change deprecated status? + // + $field = "deprecated_".$id; + $new_v = (post_str($field, true)=='on') ? 1 : 0; + $old_v = $app->deprecated; + if ($new_v != $old_v ) { + $app->update("deprecated=$new_v"); } - /* Minimum version limit */ - $field="min_version_".$id; - $new_v= $_POST[$field] + 0; - $old_v=$item->min_version; - if( $new_v != $old_v ) { - $cmd = "UPDATE app SET min_version=$new_v WHERE id=$id"; - $commands .= "

$cmd
\n"; - mysql_query($cmd); + $field = "weight_".$id; + $new_v = $_POST[$field] + 0; + $old_v = $app->weight; + if ($new_v != $old_v ) { + $app->update("weight=$new_v"); } - - $field="weight_".$id; - $new_v= $_POST[$field] + 0; - $old_v=$item->weight; - if( $new_v != $old_v ) { - $cmd = "UPDATE app SET weight=$new_v WHERE id=$id"; - $commands .= "

$cmd
\n"; - mysql_query($cmd); + $field = "homogeneous_redundancy_".$id; + $new_v = $_POST[$field]; + $old_v = $app->homogeneous_redundancy; + if ($new_v != $old_v ) { + $app->update("homogeneous_redundancy=$new_v"); } - /* Homogendous redundancy restriction (same platform for all WU's) */ - $field="homogeneous_redundancy_".$id; - $new_v= $_POST[$field]; - $old_v=$item->homogeneous_redundancy; - if( $new_v != $old_v ) { - $cmd = "UPDATE app SET homogeneous_redundancy=$new_v WHERE id=$id"; - $commands .= "

$cmd
\n"; - mysql_query($cmd); + $field = "homogeneous_app_version".$id; + $new_v = (post_str($field, true)=='on') ? 1 : 0; + $old_v = $app->homogeneous_app_version; + if ($new_v != $old_v ) { + $app->update("homogeneous_app_version=$new_v"); } } - /* Adding a new application */ + // Adding a new application - if(post_str('add_app', true)) { - $name= mysql_real_escape_string($_POST['add_name']); - $user_friendly_name=mysql_real_escape_string($_POST['add_user_friendly_name']); - if( empty($name) || empty($user_friendly_name) ) { + if (post_str('add_app', true)) { + $name = mysql_real_escape_string($_POST['add_name']); + $user_friendly_name = mysql_real_escape_string($_POST['add_user_friendly_name']); + if (empty($name) || empty($user_friendly_name) ) { $commands .= "

- To add a new application please supply both a brief name and a - longer 'user-friendly' name.

\n"; - } - else { - $now=time(); + To add a new application please supply both a brief name and a + longer 'user-friendly' name.

+ "; + } else { + $now = time(); $cmd = "INSERT INTO app (name,user_friendly_name,create_time) ". "VALUES ('$name', '$user_friendly_name',$now)"; $commands .= "

$cmd
\n"; mysql_query($cmd); } } - }//$_POST - - -/***************************************************\ - * Display the DB contents in a form - \***************************************************/ - -admin_page_head("Manage Applications"); - -if (strlen($commands)) { - echo "The following updates were done: $commands -

- You must stop and restart the project - for these changes to take effect. -"; } -$self=$_SERVER['PHP_SELF']; -echo "

\n"; +function show_form($updated) { + admin_page_head("Manage Applications"); - -start_table(); -echo "ID # - Name and description
Click for details - Created - minimum app version for HR - weight - homogeneous redundancy type (0=none) - deprecated? - \n"; - -$total_weight = mysql_query('SELECT SUM(weight) AS total_weight FROM app WHERE deprecated=0'); -$total_weight = mysql_fetch_assoc($total_weight); -$total_weight = $total_weight['total_weight']; - -$q="SELECT * FROM app ORDER BY id"; -$result = mysql_query($q); -$Nrow=mysql_num_rows($result); -for ($j=1; $j<=$Nrow; $j++){ - $item = mysql_fetch_object($result); - $id = $item->id; - - // grey-out deprecated versions - $f1=$f2=''; - if($item->deprecated==1) { - $f1=""; - $f2=""; + if ($updated) { + echo "Updates were done. +

+ You must stop and restart the project + for these changes to take effect. + "; } - echo " "; - echo " $f1 $id $f2\n"; - $name=$item->name; - $full_name=$item->user_friendly_name; - echo " $f1$name
$full_name $f2\n"; - - $time=$item->create_time; - echo " $f1 " .date_str($time)."$f2\n"; - - $field="min_version_".$id; - $v=$item->min_version; - echo " - \n"; - - $field="weight_".$id; - $v=$item->weight; - echo " - \n"; - - $field="homogeneous_redundancy_".$id; - $v = $item->homogeneous_redundancy; - echo " - + $self=$_SERVER['PHP_SELF']; + echo " +

Edit applications

+ "; - $field="deprecated_".$id; - $v=''; - if($item->deprecated) $v=' CHECKED '; - echo " - \n"; + start_table(); + table_header( + "ID", + "Name and description
Click for details", + "Created", + "weight
details", + "homogeneous redundancy type
details", + "homogeneous app version?
details", + "deprecated?" + ); - echo " "; - } -mysql_free_result($result); + $total_weight = mysql_query('SELECT SUM(weight) AS total_weight FROM app WHERE deprecated=0'); + $total_weight = mysql_fetch_assoc($total_weight); + $total_weight = $total_weight['total_weight']; -echo " - - - \n"; + $q="SELECT * FROM app ORDER BY id"; + $result = mysql_query($q); + $Nrow=mysql_num_rows($result); + for ($j=1; $j<=$Nrow; $j++){ + $item = mysql_fetch_object($result); + $id = $item->id; -end_table(); + // grey-out deprecated versions + $f1=$f2=''; + if($item->deprecated==1) { + $f1 = ""; + $f2 = ""; + } + echo " "; + echo " $f1 $id $f2\n"; + + $name = $item->name; + $full_name = $item->user_friendly_name; + echo " $f1$name
$full_name $f2\n"; + + $time = $item->create_time; + echo " $f1 " .date_str($time)."$f2\n"; + + $field = "weight_".$id; + $v = $item->weight; + echo " + \n"; + + $field = "homogeneous_redundancy_".$id; + $v = $item->homogeneous_redundancy; + echo " + + "; + + $field = "homogeneous_app_version_".$id; + $v = ''; + if ($item->homogeneous_app_version) $v=' CHECKED '; + echo " + + "; + + $field = "deprecated_".$id; + $v = ''; + if ($item->deprecated) $v = ' CHECKED '; + echo " + + "; + + echo " "; + } + mysql_free_result($result); + echo ""; + + end_table(); -/** - * Entry form to create a new application - */ + // Entry form to create a new application + // -echo"

-

Add an Application

- To add an application to the project enter the short name and description - ('user friendly name') below. You can then control the version limits and - turn on homogeneous redundancy (if desired) when the application appears - in the table above. -

\n"; + echo"

+

Add an application

+ To add an application enter the short name and description + ('user friendly name') below. You can then edit the + application when it appears in the table above. +

\n"; -start_table("align='center' "); + start_table("align='center' "); -echo "Name - Description -   - \n"; + echo "Name + Description +   + \n"; -echo " - - - - - \n"; + echo " + + + + + \n"; -end_table(); + end_table(); + echo "

\n"; + admin_page_tail(); +} -echo "

\n"; - -admin_page_tail(); +if( !empty($_POST) ) { + do_updates(); + show_form(true); +} else { + show_form(false); +} //Generated automatically - do not edit $cvs_version_tracker[]="\$Id$";