From 636839ea03c696ad4b9034799b241bcb33db3a56 Mon Sep 17 00:00:00 2001 From: Eric Heien Date: Thu, 5 Dec 2002 22:50:21 +0000 Subject: [PATCH] bug fixes svn path=/trunk/boinc/; revision=690 --- client/client_state.C | 11 ++++----- client/win/hostinfo_win.cpp | 44 +++++++++++++++++++++++++++++++++++- client/win/wingui.cpp | 45 +++++-------------------------------- client/win/wingui.h | 2 -- 4 files changed, 55 insertions(+), 47 deletions(-) diff --git a/client/client_state.C b/client/client_state.C index 2b96e6a846..5b0ec0bb27 100644 --- a/client/client_state.C +++ b/client/client_state.C @@ -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; diff --git a/client/win/hostinfo_win.cpp b/client/win/hostinfo_win.cpp index 15d9aac745..2ee984b016 100755 --- a/client/win/hostinfo_win.cpp +++ b/client/win/hostinfo_win.cpp @@ -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; -} \ No newline at end of file +} + + +////////// +// 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; +} diff --git a/client/win/wingui.cpp b/client/win/wingui.cpp index 99078cb54d..3504ed3bf8 100755 --- a/client/win/wingui.cpp +++ b/client/win/wingui.cpp @@ -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); diff --git a/client/win/wingui.h b/client/win/wingui.h index 5cfea08e84..734dcac829 100755 --- a/client/win/wingui.h +++ b/client/win/wingui.h @@ -211,8 +211,6 @@ protected: void SetStatusIcon(DWORD); void SaveUserSettings(); void LoadUserSettings(); - double GetDiskSize(); - double GetDiskFree(); DWORD GetUserIdleTime(); void Syncronize(CProgressListCtrl*, vector*); virtual void PostNcDestroy();