From b12a0b786cdd6f0650d3364aa191a1e2b46f535f Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 3 Nov 2006 17:08:49 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=11461 --- checkin_notes | 19 +++++++++++++++++++ client/gui_rpc_server_ops.C | 12 +++++++++--- clientgui/MainDocument.cpp | 26 ++++++------------------- clientgui/MainDocument.h | 13 +++++-------- clientgui/ViewResources.cpp | 38 ++++++++++++++++--------------------- lib/boinc_cmd.C | 6 +++--- lib/gui_rpc_client.h | 18 +++++++++++++++--- lib/gui_rpc_client_ops.C | 24 ++++++++++++++--------- lib/gui_rpc_client_print.C | 11 +++++++++++ 9 files changed, 99 insertions(+), 68 deletions(-) diff --git a/checkin_notes b/checkin_notes index 384005b075..c18f06529d 100755 --- a/checkin_notes +++ b/checkin_notes @@ -12112,3 +12112,22 @@ Charlie 3 Nov 2006 BOINCTaskBar.cpp sg_BoincSimpleGUI.cpp SkinManager.cpp, .h + +David 3 Nov 2006 + - GUI RPC: change RPC so it returns + the total and free disk space, as well as per-project usage. + This allows GUIs to display total/free disk for remote systems + - Manager: get total/free disk from RPC info, not WxWidgets calls + - Manager: change function names to make more sense + + client/ + gui_rpc_server_ops.C + clientgui/ + MainDocument.cpp,h + ViewResources.cpp + lib/ + boinc_cmd.C + gui_rpc_client.h + gui_rpc_client_ops.C + gui_rpc_client_print.C + diff --git a/client/gui_rpc_server_ops.C b/client/gui_rpc_server_ops.C index 5f187fb9be..75afd6b533 100644 --- a/client/gui_rpc_server_ops.C +++ b/client/gui_rpc_server_ops.C @@ -116,9 +116,15 @@ static void handle_get_project_status(MIOFILE& fout) { static void handle_get_disk_usage(MIOFILE& fout) { unsigned int i; - double size; + double size, d_total, d_free; - fout.printf("\n"); + fout.printf("\n"); + get_filesystem_info(d_total, d_free); + fout.printf( + "%f\n" + "%f\n", + d_total, d_free + ); for (i=0; imaster_url, size ); } - fout.printf("\n"); + fout.printf("\n"); } static PROJECT* get_project(char* buf, MIOFILE& fout) { diff --git a/clientgui/MainDocument.cpp b/clientgui/MainDocument.cpp index 0ba386387b..f4ef5c5a37 100644 --- a/clientgui/MainDocument.cpp +++ b/clientgui/MainDocument.cpp @@ -1002,17 +1002,17 @@ int CMainDocument::TransferAbort(int iIndex) { } -int CMainDocument::CachedResourceStatusUpdate() { +int CMainDocument::CachedDiskUsageUpdate() { int iRetVal = 0; if (IsConnected()) { - wxTimeSpan ts(wxDateTime::Now() - m_dtResourceStatusTimestamp); + wxTimeSpan ts(wxDateTime::Now() - m_dtDiskUsageTimestamp); if (ts.GetSeconds() > 0) { - m_dtResourceStatusTimestamp = wxDateTime::Now(); + m_dtDiskUsageTimestamp = wxDateTime::Now(); - iRetVal = rpc.get_disk_usage(resource_status); + iRetVal = rpc.get_disk_usage(disk_usage); if (iRetVal) { - wxLogTrace(wxT("Function Status"), wxT("CMainDocument::CachedResourceStatusUpdate - Get Disk Usage Failed '%d'"), iRetVal); + wxLogTrace(wxT("Function Status"), wxT("Get Disk Usage Failed '%d'"), iRetVal); ForceCacheUpdate(); } } @@ -1024,7 +1024,7 @@ int CMainDocument::CachedResourceStatusUpdate() { } -PROJECT* CMainDocument::resource(unsigned int i) { +PROJECT* CMainDocument::DiskUsageProject(unsigned int i) { PROJECT* pProject = NULL; // It is not safe to assume that the vector actually contains the data, @@ -1045,20 +1045,6 @@ PROJECT* CMainDocument::resource(unsigned int i) { return pProject; } - -int CMainDocument::GetResourceCount() { - int iCount = -1; - - CachedResourceStatusUpdate(); - CachedStateUpdate(); - - if (!resource_status.projects.empty()) - iCount = (int)resource_status.projects.size(); - - return iCount; -} - - int CMainDocument::CachedStatisticsStatusUpdate() { int iRetVal = 0; diff --git a/clientgui/MainDocument.h b/clientgui/MainDocument.h index 098848cae7..0a136a0e74 100644 --- a/clientgui/MainDocument.h +++ b/clientgui/MainDocument.h @@ -225,18 +225,15 @@ public: // - // Resources Tab + // Disk Tab // private: - int CachedResourceStatusUpdate(); - wxDateTime m_dtResourceStatusTimestamp; + int CachedDiskUsageUpdate(); + wxDateTime m_dtDiskUsageTimestamp; public: - PROJECTS resource_status; - PROJECT* resource(unsigned int); - - int GetResourceCount(); - + DISK_USAGE disk_usage; + PROJECT* DiskUsageProject(unsigned int); // // Statistics Tab diff --git a/clientgui/ViewResources.cpp b/clientgui/ViewResources.cpp index df7b53599c..d40a1c4745 100644 --- a/clientgui/ViewResources.cpp +++ b/clientgui/ViewResources.cpp @@ -166,15 +166,15 @@ void CViewResources::UpdateSelection() { wxInt32 CViewResources::FormatProjectName(wxInt32 item, wxString& strBuffer) const { CMainDocument* doc = wxGetApp().GetDocument(); - PROJECT* resource = wxGetApp().GetDocument()->resource(item); + PROJECT* project = doc->DiskUsageProject(item); PROJECT* state_project = NULL; std::string project_name; wxASSERT(doc); wxASSERT(wxDynamicCast(doc, CMainDocument)); - if (resource) { - state_project = doc->state.lookup_project(resource->master_url); + if (project) { + state_project = doc->state.lookup_project(project->master_url); if (state_project) { state_project->get_name(project_name); strBuffer = wxString(project_name.c_str(), wxConvUTF8); @@ -210,34 +210,29 @@ bool CViewResources::OnRestoreState(wxConfigBase* pConfig) { } void CViewResources::OnListRender( wxTimerEvent& WXUNUSED(event) ) { - CMainDocument* pDoc = wxGetApp().GetDocument(); + CMainDocument* pDoc = wxGetApp().GetDocument(); wxString diskspace; double boinctotal=0.0; wxASSERT(pDoc); - wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + wxASSERT(wxDynamicCast(pDoc, CMainDocument)); //clear former data m_pieCtrlBOINC->m_Series.Clear(); m_pieCtrlTotal->m_Series.Clear(); //get data for BOINC projects disk usage - if (pDoc->GetResourceCount() > 0) { - PROJECTS *proj=&(pDoc->resource_status); - wxASSERT(proj); - //update data for boinc projects pie chart - wxInt32 count=-1; - for (std::vector::const_iterator i=proj->projects.begin();i!=proj->projects.end(); ++i) { - ++count; + pDoc->CachedDiskUsageUpdate(); + pDoc->CachedStateUpdate(); + if (disk_usage.projects.size()>0) { + for (i=0; iDiskUsageProject(count); wxString projectname; - FormatProjectName(count,projectname); - FormatDiskSpace(count,diskspace); - PROJECT* resource = wxGetApp().GetDocument()->resource(count); - double usage = 0.0; - if (resource) { - usage = resource->disk_usage; - boinctotal += usage; - } + FormatProjectName(project, projectname); + FormatDiskSpace(project, diskspace); + double usage = project->disk_usage; + boinctotal += usage; wxPiePart part; part.SetLabel(projectname + wxT(" - ") + diskspace); part.SetValue(usage); @@ -245,8 +240,7 @@ void CViewResources::OnListRender( wxTimerEvent& WXUNUSED(event) ) { m_pieCtrlBOINC->m_Series.Add(part); } m_pieCtrlBOINC->Refresh(); - } - else { + } else { //paint an empty black pie wxPiePart part; part.SetLabel(_("not attached to any BOINC project - 0 bytes")); diff --git a/lib/boinc_cmd.C b/lib/boinc_cmd.C index b66c450fc2..023ffd7058 100644 --- a/lib/boinc_cmd.C +++ b/lib/boinc_cmd.C @@ -238,9 +238,9 @@ int main(int argc, char** argv) { retval = rpc.get_simple_gui_info(sgi); if (!retval) sgi.print(); } else if (!strcmp(cmd, "--get_disk_usage")) { - PROJECTS ps; - retval = rpc.get_disk_usage(ps); - if (!retval) ps.print(); + DISK_USAGE du; + retval = rpc.get_disk_usage(du); + if (!retval) du.print(); } else if (!strcmp(cmd, "--result")) { RESULT result; char* project_url = next_arg(argc, argv, i); diff --git a/lib/gui_rpc_client.h b/lib/gui_rpc_client.h index db5e2c3d0b..aede7b91e4 100644 --- a/lib/gui_rpc_client.h +++ b/lib/gui_rpc_client.h @@ -307,18 +307,30 @@ class PROJECTS { public: std::vector projects; - PROJECTS(); + PROJECTS(){} ~PROJECTS(); void print(); void clear(); }; +struct DISK_USAGE { + std::vector projects; + double d_total; + double d_free; + + DISK_USAGE(){} + ~DISK_USAGE(); + + void print(); + void clear(); +}; + class RESULTS { public: std::vector results; - RESULTS(); + RESULTS(){} ~RESULTS(); void print(); @@ -513,7 +525,7 @@ public: int get_simple_gui_info(CC_STATE&, RESULTS&); int get_project_status(CC_STATE&); int get_project_status(PROJECTS&); - int get_disk_usage(PROJECTS&); + int get_disk_usage(DISK_USAGE&); int show_graphics( const char* project, const char* result_name, int graphics_mode, DISPLAY_INFO& diff --git a/lib/gui_rpc_client_ops.C b/lib/gui_rpc_client_ops.C index 69fce1e79f..9843023259 100644 --- a/lib/gui_rpc_client_ops.C +++ b/lib/gui_rpc_client_ops.C @@ -699,10 +699,6 @@ RESULT* CC_STATE::lookup_result(PROJECT* project, string& str) { return 0; } -PROJECTS::PROJECTS() { - clear(); -} - PROJECTS::~PROJECTS() { clear(); } @@ -715,10 +711,18 @@ void PROJECTS::clear() { projects.clear(); } -RESULTS::RESULTS() { +DISK_USAGE::~DISK_USAGE() { clear(); } +void DISK_USAGE::clear() { + unsigned int i; + for (i=0; i\n"); if (!retval) { while (rpc.fin.fgets(buf, 256)) { - if (match_tag(buf, "")) break; + if (match_tag(buf, "")) break; else if (match_tag(buf, "")) { PROJECT* project = new PROJECT(); project->parse(rpc.fin); - p.projects.push_back(project); + du.projects.push_back(project); continue; } + else if (parse_double(buf, "", du.d_total)) continue; + else if (parse_double(buf, "", du.d_free)) continue; } } return retval; diff --git a/lib/gui_rpc_client_print.C b/lib/gui_rpc_client_print.C index ece103ab88..404e0abda7 100644 --- a/lib/gui_rpc_client_print.C +++ b/lib/gui_rpc_client_print.C @@ -221,6 +221,17 @@ void PROJECTS::print() { } } +void DISK_USAGE::print() { + unsigned int i; + printf("======== Disk usage ========\n"); + printf("total: %f\n", d_total); + printf("free: %f\n", d_free); + for (i=0; iprint(); + } +} + void RESULTS::print() { unsigned int i; printf("\n======== Results ========\n");