*** empty log message ***

svn path=/trunk/boinc/; revision=11461
This commit is contained in:
David Anderson 2006-11-03 17:08:49 +00:00
parent 132d8c7d0b
commit b12a0b786c
9 changed files with 99 additions and 68 deletions

View File

@ -12112,3 +12112,22 @@ Charlie 3 Nov 2006
BOINCTaskBar.cpp
sg_BoincSimpleGUI.cpp
SkinManager.cpp, .h
David 3 Nov 2006
- GUI RPC: change <get_disk_usage> 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

View File

@ -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("<projects>\n");
fout.printf("<disk_usage_summary>\n");
get_filesystem_info(d_total, d_free);
fout.printf(
"<d_total>%f</d_total>\n"
"<d_free>%f</d_free>\n",
d_total, d_free
);
for (i=0; i<gstate.projects.size(); i++) {
PROJECT* p = gstate.projects[i];
gstate.project_disk_usage(p, size);
@ -130,7 +136,7 @@ static void handle_get_disk_usage(MIOFILE& fout) {
p->master_url, size
);
}
fout.printf("</projects>\n");
fout.printf("</disk_usage_summary>\n");
}
static PROJECT* get_project(char* buf, MIOFILE& fout) {

View File

@ -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;

View File

@ -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

View File

@ -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<PROJECT*>::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; i<disk_usage.projects.size(); i++) {
//update data for boinc projects pie chart
PROJECT* project = pDoc->DiskUsageProject(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"));

View File

@ -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);

View File

@ -307,18 +307,30 @@ class PROJECTS {
public:
std::vector<PROJECT*> projects;
PROJECTS();
PROJECTS(){}
~PROJECTS();
void print();
void clear();
};
struct DISK_USAGE {
std::vector<PROJECT*> projects;
double d_total;
double d_free;
DISK_USAGE(){}
~DISK_USAGE();
void print();
void clear();
};
class RESULTS {
public:
std::vector<RESULT*> 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&

View File

@ -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<projects.size(); i++) {
delete projects[i];
}
projects.clear();
}
RESULTS::~RESULTS() {
clear();
}
@ -1291,24 +1295,26 @@ int RPC_CLIENT::get_project_status(CC_STATE& state) {
return retval;
}
int RPC_CLIENT::get_disk_usage(PROJECTS& p) {
int RPC_CLIENT::get_disk_usage(DISK_USAGE& du) {
int retval;
SET_LOCALE sl;
char buf[256];
RPC rpc(this);
p.clear();
du.clear();
retval = rpc.do_rpc("<get_disk_usage/>\n");
if (!retval) {
while (rpc.fin.fgets(buf, 256)) {
if (match_tag(buf, "</projects>")) break;
if (match_tag(buf, "</disk_usage_summary>")) break;
else if (match_tag(buf, "<project>")) {
PROJECT* project = new PROJECT();
project->parse(rpc.fin);
p.projects.push_back(project);
du.projects.push_back(project);
continue;
}
else if (parse_double(buf, "<d_total>", du.d_total)) continue;
else if (parse_double(buf, "<d_free>", du.d_free)) continue;
}
}
return retval;

View File

@ -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; i<projects.size(); i++) {
printf("%d) -----------\n", i+1);
projects[i]->print();
}
}
void RESULTS::print() {
unsigned int i;
printf("\n======== Results ========\n");