2005-01-20 23:22:22 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
2004-07-13 13:54:09 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation;
|
|
|
|
// either version 2.1 of the License, or (at your option) any later version.
|
2004-07-13 13:54:09 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This software is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
2002-04-30 22:22:54 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// To view the GNU Lesser General Public License visit
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// or write to the Free Software Foundation, Inc.,
|
|
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2002-04-30 22:22:54 +00:00
|
|
|
|
|
|
|
#ifndef _PREFS_
|
|
|
|
#define _PREFS_
|
|
|
|
|
2004-07-13 13:54:09 +00:00
|
|
|
#include <cstdio>
|
2005-06-22 10:51:34 +00:00
|
|
|
#include "miofile.h"
|
2006-09-11 19:03:00 +00:00
|
|
|
#include "parse.h"
|
2002-06-21 06:52:47 +00:00
|
|
|
|
2002-09-26 05:57:10 +00:00
|
|
|
// Global preferences are edited and stored on BOINC servers.
|
2002-06-01 20:26:21 +00:00
|
|
|
// The native representation of preferences is XML.
|
|
|
|
// The client maintains the preferences (in XML form)
|
|
|
|
// and mod time in the state file and in memory.
|
|
|
|
// It includes these items in each scheduler request message.
|
|
|
|
// A scheduler reply message may contain a more recent set of preferences.
|
|
|
|
//
|
|
|
|
|
2006-11-02 20:38:47 +00:00
|
|
|
// A struct with one bool per GLOBAL_PREFS field
|
|
|
|
//
|
|
|
|
struct GLOBAL_PREFS_MASK {
|
|
|
|
bool run_on_batteries;
|
|
|
|
bool run_if_user_active;
|
|
|
|
bool start_hour; // 0..23; no restriction if start==end
|
|
|
|
bool end_hour;
|
|
|
|
bool net_start_hour; // 0..23; no restriction if start==end
|
|
|
|
bool net_end_hour;
|
|
|
|
bool leave_apps_in_memory;
|
|
|
|
bool confirm_before_connecting;
|
|
|
|
bool hangup_if_dialed;
|
|
|
|
bool dont_verify_images;
|
|
|
|
bool work_buf_min_days;
|
2007-03-28 21:30:45 +00:00
|
|
|
bool work_buf_additional_days;
|
2006-11-02 20:38:47 +00:00
|
|
|
bool max_cpus;
|
|
|
|
bool cpu_scheduling_period_minutes;
|
|
|
|
bool disk_interval;
|
|
|
|
bool disk_max_used_gb;
|
|
|
|
bool disk_max_used_pct;
|
|
|
|
bool disk_min_free_gb;
|
|
|
|
bool vm_max_used_frac;
|
|
|
|
bool ram_max_used_busy_frac;
|
|
|
|
bool ram_max_used_idle_frac;
|
|
|
|
bool idle_time_to_run;
|
|
|
|
bool max_bytes_sec_up;
|
|
|
|
bool max_bytes_sec_down;
|
|
|
|
bool cpu_usage_limit;
|
2006-11-07 00:17:01 +00:00
|
|
|
|
|
|
|
GLOBAL_PREFS_MASK();
|
|
|
|
void clear();
|
2006-11-24 21:50:58 +00:00
|
|
|
bool are_prefs_set();
|
2006-11-27 03:53:43 +00:00
|
|
|
bool are_simple_prefs_set();
|
2006-11-02 20:38:47 +00:00
|
|
|
};
|
|
|
|
|
2007-03-19 22:57:30 +00:00
|
|
|
#define PREFS_CPU 0
|
|
|
|
#define PREFS_NETWORK 1
|
|
|
|
|
2007-03-15 19:08:22 +00:00
|
|
|
struct TIME_PREFS {
|
2007-03-19 22:57:30 +00:00
|
|
|
double start_hour; // 0..24
|
|
|
|
// run always if start==end or start==0, end=24
|
|
|
|
// don't run at all if start=24, end=0
|
|
|
|
double end_hour;
|
|
|
|
double net_start_hour; // 0..24; no restriction if start==end
|
|
|
|
double net_end_hour;
|
2007-03-15 19:08:22 +00:00
|
|
|
|
|
|
|
void clear();
|
2007-03-19 22:57:30 +00:00
|
|
|
bool suspended(double hour, int which);
|
2007-03-15 19:08:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct DAY_PREFS {
|
|
|
|
bool present;
|
2007-03-19 22:57:30 +00:00
|
|
|
int day_of_week;
|
2007-03-15 19:08:22 +00:00
|
|
|
TIME_PREFS time_prefs;
|
|
|
|
|
|
|
|
int parse(XML_PARSER&);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WEEK_PREFS {
|
|
|
|
bool present; // at least one day is present
|
2007-03-19 22:57:30 +00:00
|
|
|
DAY_PREFS days[7]; // sun..sat
|
2007-03-15 19:08:22 +00:00
|
|
|
};
|
|
|
|
|
2002-06-21 06:52:47 +00:00
|
|
|
// The following structure is a parsed version of the prefs file
|
|
|
|
//
|
2002-09-29 00:32:11 +00:00
|
|
|
struct GLOBAL_PREFS {
|
2003-09-02 23:49:53 +00:00
|
|
|
int mod_time;
|
2003-02-21 01:38:16 +00:00
|
|
|
bool run_on_batteries;
|
|
|
|
bool run_if_user_active;
|
2004-08-06 23:17:59 +00:00
|
|
|
bool leave_apps_in_memory;
|
2002-06-01 20:26:21 +00:00
|
|
|
bool confirm_before_connecting;
|
2003-02-06 19:01:49 +00:00
|
|
|
bool hangup_if_dialed;
|
2005-04-06 19:41:31 +00:00
|
|
|
bool dont_verify_images;
|
2007-03-15 19:08:22 +00:00
|
|
|
TIME_PREFS time_prefs;
|
2003-02-26 00:47:57 +00:00
|
|
|
double work_buf_min_days;
|
2007-03-28 21:30:45 +00:00
|
|
|
double work_buf_additional_days;
|
2003-03-20 02:05:25 +00:00
|
|
|
int max_cpus;
|
2004-10-13 18:30:18 +00:00
|
|
|
double cpu_scheduling_period_minutes;
|
2003-03-20 02:05:25 +00:00
|
|
|
double disk_interval;
|
2002-06-01 20:26:21 +00:00
|
|
|
double disk_max_used_gb;
|
|
|
|
double disk_max_used_pct;
|
|
|
|
double disk_min_free_gb;
|
2006-10-02 23:42:38 +00:00
|
|
|
double vm_max_used_frac;
|
|
|
|
double ram_max_used_busy_frac;
|
|
|
|
double ram_max_used_idle_frac;
|
2002-11-19 22:57:05 +00:00
|
|
|
double idle_time_to_run;
|
2003-02-26 00:47:57 +00:00
|
|
|
double max_bytes_sec_up;
|
|
|
|
double max_bytes_sec_down;
|
2006-05-21 22:03:36 +00:00
|
|
|
double cpu_usage_limit;
|
2004-10-06 19:09:37 +00:00
|
|
|
char source_project[256];
|
|
|
|
char source_scheduler[256];
|
2006-10-06 18:52:50 +00:00
|
|
|
bool host_specific;
|
2007-03-15 19:08:22 +00:00
|
|
|
WEEK_PREFS week_prefs;
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2002-09-29 00:32:11 +00:00
|
|
|
GLOBAL_PREFS();
|
2004-10-17 02:18:59 +00:00
|
|
|
void defaults();
|
|
|
|
void clear_bools();
|
2006-11-14 10:12:24 +00:00
|
|
|
int parse(XML_PARSER&, const char* venue, bool& found_venue, GLOBAL_PREFS_MASK& mask);
|
|
|
|
int parse_override(XML_PARSER&, const char* venue, bool& found_venue, GLOBAL_PREFS_MASK& mask);
|
2005-02-16 23:17:43 +00:00
|
|
|
int parse_file(const char* filename, const char* venue, bool& found_venue);
|
2005-06-22 10:51:34 +00:00
|
|
|
int write(MIOFILE&);
|
2006-11-02 20:38:47 +00:00
|
|
|
int write_subset(MIOFILE&, GLOBAL_PREFS_MASK&);
|
2007-03-19 22:57:30 +00:00
|
|
|
bool suspended_time_of_day(int);
|
2002-04-30 22:22:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|