mirror of https://github.com/BOINC/boinc.git
parent
c3f30199ff
commit
636839ea03
|
@ -111,8 +111,11 @@ int CLIENT_STATE::init() {
|
|||
make_slot_dirs();
|
||||
|
||||
// Run the time tests and host information check if needed
|
||||
// TODO: break time tests and host information check into two
|
||||
// separate functions?
|
||||
|
||||
// Getting host info is very fast, so we can do it anytime
|
||||
clear_host_info(host_info);
|
||||
get_host_info(host_info); // this is platform dependent
|
||||
|
||||
if (gstate.run_time_tests()) {
|
||||
gstate.time_tests();
|
||||
}
|
||||
|
@ -141,8 +144,6 @@ int CLIENT_STATE::time_tests() {
|
|||
if (log_flags.measurement_debug) {
|
||||
printf("Getting general host information.\n");
|
||||
}
|
||||
clear_host_info(host_info);
|
||||
get_host_info(host_info); // this is platform dependent
|
||||
#if 0
|
||||
double fpop_test_secs = 2.0;
|
||||
double iop_test_secs = 2.0;
|
||||
|
@ -190,7 +191,7 @@ double CLIENT_STATE::allowed_disk_usage() {
|
|||
|
||||
// Calculate allowed disk usage based on % pref
|
||||
//
|
||||
percent_space = host_info.d_total*global_prefs.disk_max_used_pct/100.0;
|
||||
percent_space = host_info.d_total*global_prefs.disk_max_used_pct;
|
||||
|
||||
min_val = host_info.d_free - global_prefs.disk_min_free_gb*1e9;
|
||||
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
#include "client_types.h"
|
||||
#include "hostinfo.h"
|
||||
|
||||
double GetDiskFree();
|
||||
double GetDiskSize();
|
||||
|
||||
// Gets windows specific host information (not complete)
|
||||
//
|
||||
int get_host_info(HOST_INFO& host) {
|
||||
|
@ -139,6 +142,8 @@ int get_host_info(HOST_INFO& host) {
|
|||
}
|
||||
|
||||
memset(&host, 0, sizeof(host));
|
||||
host.d_total = GetDiskSize();
|
||||
host.d_free = GetDiskFree();
|
||||
|
||||
get_local_domain_name(host.domain_name);
|
||||
get_local_ip_addr_str(host.ip_addr);
|
||||
|
@ -148,4 +153,41 @@ int get_host_info(HOST_INFO& host) {
|
|||
|
||||
bool host_is_running_on_batteries() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////
|
||||
// GetDiskFree
|
||||
// arguments: void
|
||||
// returns: amount of free disk space in MB
|
||||
// function: calculates free disk space on current drive
|
||||
double GetDiskFree()
|
||||
{
|
||||
ULARGE_INTEGER TotalNumberOfFreeBytes;
|
||||
char path[256];
|
||||
char drive[256];
|
||||
GetCurrentDirectory(256, path);
|
||||
memcpy(drive, path, 3);
|
||||
drive[3] = 0;
|
||||
GetDiskFreeSpaceEx(drive, NULL, NULL, &TotalNumberOfFreeBytes);
|
||||
unsigned int MB = TotalNumberOfFreeBytes.QuadPart / (1024 * 1024);
|
||||
return (double)MB * 1024.0 * 1024.0;
|
||||
}
|
||||
|
||||
//////////
|
||||
// GetDiskSize
|
||||
// arguments: void
|
||||
// returns: total disk space in bytes
|
||||
// function: calculates total disk space on current drive
|
||||
double GetDiskSize()
|
||||
{
|
||||
ULARGE_INTEGER TotalNumberOfBytes;
|
||||
char path[256];
|
||||
char drive[256];
|
||||
GetCurrentDirectory(256, path);
|
||||
memcpy(drive, path, 3);
|
||||
drive[3] = 0;
|
||||
GetDiskFreeSpaceEx(drive, NULL, &TotalNumberOfBytes, NULL);
|
||||
unsigned int MB = TotalNumberOfBytes.QuadPart / (1024 * 1024);
|
||||
return (double)MB * 1024.0 * 1024.0;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,9 @@ char* column_titles[MAX_LIST_ID][MAX_COLS] = {
|
|||
{"Project", "File", "Progress", "Total", "Direction", NULL, NULL}
|
||||
};
|
||||
|
||||
double GetDiskSize();
|
||||
double GetDiskFree();
|
||||
|
||||
void show_message(char* message, char* priority) {
|
||||
if(g_myWnd) {
|
||||
g_myWnd->MessageUser(message, priority);
|
||||
|
@ -1110,7 +1113,7 @@ void CMainWindow::UpdateGUI(CLIENT_STATE* cs)
|
|||
int cpuhour = (int)(cur_cpu / (60 * 60));
|
||||
int cpumin = (int)(cur_cpu / 60) % 60;
|
||||
int cpusec = (int)(cur_cpu) % 60;
|
||||
buf.Format("%0.2dh%0.2dm%0.2ds", cpuhour, cpumin, cpusec);
|
||||
buf.Format("%0.2d:%0.2d:%0.2d", cpuhour, cpumin, cpusec);
|
||||
m_ResultListCtrl.SetItemText(i, 3, buf);
|
||||
|
||||
// progress
|
||||
|
@ -1128,7 +1131,7 @@ void CMainWindow::UpdateGUI(CLIENT_STATE* cs)
|
|||
cpuhour = (int)(tocomp / (60 * 60));
|
||||
cpumin = (int)(tocomp / 60) % 60;
|
||||
cpusec = (int)(tocomp) % 60;
|
||||
buf.Format("%0.2dh%0.2dm%0.2ds", cpuhour, cpumin, cpusec);
|
||||
buf.Format("%0.2d:%0.2d:%0.2d", cpuhour, cpumin, cpusec);
|
||||
}
|
||||
m_ResultListCtrl.SetItemText(i, 5, buf);
|
||||
|
||||
|
@ -1386,42 +1389,6 @@ void CMainWindow::LoadUserSettings()
|
|||
}
|
||||
}
|
||||
|
||||
//////////
|
||||
// CMainWindow::GetDiskSize
|
||||
// arguments: void
|
||||
// returns: total disk space in bytes
|
||||
// function: calculates total disk space on current drive
|
||||
double CMainWindow::GetDiskSize()
|
||||
{
|
||||
ULARGE_INTEGER TotalNumberOfBytes;
|
||||
char path[256];
|
||||
char drive[256];
|
||||
GetCurrentDirectory(256, path);
|
||||
memcpy(drive, path, 3);
|
||||
drive[3] = 0;
|
||||
GetDiskFreeSpaceEx(drive, NULL, &TotalNumberOfBytes, NULL);
|
||||
unsigned int MB = TotalNumberOfBytes.QuadPart / (1024 * 1024);
|
||||
return (double)MB * 1024.0 * 1024.0;
|
||||
}
|
||||
|
||||
//////////
|
||||
// CMainWindow::GetDiskFree
|
||||
// arguments: void
|
||||
// returns: amount of free disk space in MB
|
||||
// function: calculates free disk space on current drive
|
||||
double CMainWindow::GetDiskFree()
|
||||
{
|
||||
ULARGE_INTEGER TotalNumberOfFreeBytes;
|
||||
char path[256];
|
||||
char drive[256];
|
||||
GetCurrentDirectory(256, path);
|
||||
memcpy(drive, path, 3);
|
||||
drive[3] = 0;
|
||||
GetDiskFreeSpaceEx(drive, NULL, NULL, &TotalNumberOfFreeBytes);
|
||||
unsigned int MB = TotalNumberOfFreeBytes.QuadPart / (1024 * 1024);
|
||||
return (double)MB * 1024.0 * 1024.0;
|
||||
}
|
||||
|
||||
//////////
|
||||
// CMainWindow::GetUserIdleTime
|
||||
// arguments: void
|
||||
|
@ -1700,7 +1667,7 @@ int CMainWindow::OnCreate(LPCREATESTRUCT lpcs)
|
|||
m_UsagePieCtrl.AddPiece("Free not available for BOINC", RGB(192, 192, 192), 0, GetDiskSize() / (1024.0 * 1024.0 * 1024.0));
|
||||
m_UsagePieCtrl.AddPiece("Space used", RGB(0, 0, 255), 0, 0);
|
||||
m_UsagePieCtrl.AddPiece("Used by BOINC", RGB(255, 255, 0), 0, 0);
|
||||
m_UsagePieCtrl.AddPiece("Free available for BOINC", RGB(255, 128, 0), 0, 0);
|
||||
m_UsagePieCtrl.AddPiece("Space available to BOINC", RGB(255, 128, 0), 0, 0);
|
||||
|
||||
// create message edit control
|
||||
m_MessageEditCtrl.Create(ES_MULTILINE|ES_READONLY|WS_VSCROLL|WS_CHILD|WS_TABSTOP|WS_BORDER|WS_VISIBLE, CRect(0,0,0,0), this, MESSAGE_ID);
|
||||
|
|
|
@ -211,8 +211,6 @@ protected:
|
|||
void SetStatusIcon(DWORD);
|
||||
void SaveUserSettings();
|
||||
void LoadUserSettings();
|
||||
double GetDiskSize();
|
||||
double GetDiskFree();
|
||||
DWORD GetUserIdleTime();
|
||||
void Syncronize(CProgressListCtrl*, vector<void*>*);
|
||||
virtual void PostNcDestroy();
|
||||
|
|
Loading…
Reference in New Issue