Skip to content

Commit

Permalink
Merge branch 'dpa_niu_prefs' of https://github.com/BOINC/boinc into d…
Browse files Browse the repository at this point in the history
…pa_niu_prefs
  • Loading branch information
davidpanderson committed Sep 1, 2022
2 parents ca48a69 + 9ee282f commit e5367f8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
22 changes: 18 additions & 4 deletions html/inc/prefs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,21 @@ $not_in_use_prefs = [
tra("Keep some CPUs free for other applications. Example: 75% means use 6 cores on an 8-core CPU."),
"niu_max_ncpus_pct",
// xgettext:no-php-format
new NUM_SPEC(tra("% of the CPUs"), 1, 100, 100)
new NUM_SPEC(tra("% of the CPUs"), 1, 100, 0)
),
new PREF_NUM(
tra("Use at most") ."<br><font size=-2>Requires BOINC 7.20.3+</font>",
// xgettext:no-php-format
tra("Suspend/resume computing every few seconds to reduce CPU temperature and energy usage. Example: 75% means compute for 3 seconds, wait for 1 second, and repeat."),
"niu_cpu_usage_limit",
// xgettext:no-php-format
new NUM_SPEC(tra("% of CPU time"), 1, 100, 100)
new NUM_SPEC(tra("% of CPU time"), 1, 100, 0)
),
new PREF_OPT_NUM(
tra("Suspend when non-BOINC CPU usage is above")."<br><font size=-2>Requires BOINC 7.20.3+</font>",
tra("Suspend computing when your computer is busy running other programs."),
"niu_suspend_cpu_usage",
new NUM_SPEC("%", 0, 100, 25)
new NUM_SPEC("%", 0, 100, 0)
),
new PREF_NUM(
tra("Use at most"),
Expand Down Expand Up @@ -422,9 +422,22 @@ function default_prefs_global() {
return $p;
}

// parse prefs from XML to a struct
// if not-in-use prefs undefined, copy from in-use
//
function set_niu_prefs($prefs) {
if (!$prefs->niu_max_ncpus_pct) {
$prefs->niu_max_ncpus_pct = $prefs->max_ncpus_pct;
}
if (!$prefs->niu_cpu_usage_limit) {
$prefs->niu_cpu_usage_limit = $prefs->cpu_usage_limit;
}
if (!$prefs->niu_suspend_cpu_usage) {
$prefs->niu_suspend_cpu_usage = $prefs->suspend_cpu_usage;
}
}

// parse prefs from XML to a struct
//
function prefs_parse_global($prefs_xml) {
global $parse_result;
$parse_result = default_prefs_global();
Expand All @@ -433,6 +446,7 @@ function prefs_parse_global($prefs_xml) {
xml_set_element_handler($xml_parser, "element_start_global", "element_end_global");
xml_set_character_data_handler($xml_parser, "char_handler");
xml_parse($xml_parser, $prefs_xml, 1);
set_niu_prefs($parse_result);
return $parse_result;
}

Expand Down
1 change: 1 addition & 0 deletions html/user/add_venue.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@

if ($subset == "global") {
$prefs = default_prefs_global();
set_niu_prefs($prefs);
} else {
$prefs = default_prefs_project();
}
Expand Down

0 comments on commit e5367f8

Please sign in to comment.