mirror of https://github.com/BOINC/boinc.git
parent
9276415e06
commit
5e26d53f33
|
@ -10285,3 +10285,18 @@ David 10 Aug 2005
|
|||
bbcode.php
|
||||
sched/
|
||||
db_purge.C
|
||||
|
||||
David 10 Aug 2005
|
||||
- changed logic of some daily-stats-related code
|
||||
in attempt to fix crash on VC 8
|
||||
- rename STATISTIC to DAILY_STATS
|
||||
|
||||
client/
|
||||
client_types.C,h
|
||||
cs_account.C
|
||||
scheduler_op.C
|
||||
clientgui/
|
||||
ViewStatistics.cpp
|
||||
lib/
|
||||
gui_rpc_client.h
|
||||
gui_rpc_client_ops.C
|
||||
|
|
|
@ -331,7 +331,7 @@ int PROJECT::write_statistics(MIOFILE& out, bool /*gui_rpc*/) {
|
|||
master_url
|
||||
);
|
||||
|
||||
for (std::vector<STATISTIC>::iterator i=statistics.begin();
|
||||
for (std::vector<DAILY_STATS>::iterator i=statistics.begin();
|
||||
i!=statistics.end(); ++i
|
||||
) {
|
||||
out.printf(
|
||||
|
|
|
@ -132,12 +132,16 @@ struct FILE_REF {
|
|||
|
||||
// statistics at a specific day
|
||||
//
|
||||
struct STATISTIC {
|
||||
struct DAILY_STATS {
|
||||
double user_total_credit;
|
||||
double user_expavg_credit;
|
||||
double host_total_credit;
|
||||
double host_expavg_credit;
|
||||
double day;
|
||||
|
||||
void clear();
|
||||
DAILY_STATS() {clear();}
|
||||
int parse(FILE*);
|
||||
};
|
||||
|
||||
// reasons for attach failure
|
||||
|
@ -316,7 +320,7 @@ public:
|
|||
bool waiting_until_min_rpc_time();
|
||||
|
||||
// statistic of the last x days
|
||||
std::vector<STATISTIC> statistics;
|
||||
std::vector<DAILY_STATS> statistics;
|
||||
int parse_statistics(MIOFILE&);
|
||||
int parse_statistics(FILE*);
|
||||
int write_statistics(MIOFILE&, bool gui_rpc=false);
|
||||
|
|
|
@ -222,31 +222,40 @@ int CLIENT_STATE::parse_account_files() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void DAILY_STATS::clear() {
|
||||
memset(this, 0, sizeof(DAILY_STATS));
|
||||
}
|
||||
|
||||
int DAILY_STATS::parse(FILE* in) {
|
||||
char buf[256];
|
||||
clear();
|
||||
while (fgets(buf, 256, in)) {
|
||||
if (match_tag(buf, "</daily_statistics>")) return 0;
|
||||
else if (parse_double(buf, "<day>", day)) continue;
|
||||
else if (parse_double(buf, "<user_total_credit>", user_total_credit)) continue;
|
||||
else if (parse_double(buf, "<user_expavg_credit>", user_expavg_credit)) continue;
|
||||
else if (parse_double(buf, "<host_total_credit>", host_total_credit)) continue;
|
||||
else if (parse_double(buf, "<host_expavg_credit>", host_expavg_credit)) continue;
|
||||
}
|
||||
return ERR_XML_PARSE;
|
||||
}
|
||||
|
||||
// parse an statistics_*.xml file
|
||||
//
|
||||
int PROJECT::parse_statistics(FILE* in) {
|
||||
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_STATE);
|
||||
|
||||
bool open_daily_statistics=false;
|
||||
int retval;
|
||||
char buf[256];
|
||||
|
||||
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_STATE);
|
||||
|
||||
while (fgets(buf, 256, in)) {
|
||||
if (match_tag(buf, "</project_statistics>")) return 0;
|
||||
else if (match_tag(buf, "<project_statistics>")) continue;
|
||||
else if (match_tag(buf, "<daily_statistics>")) {
|
||||
if (open_daily_statistics) break;
|
||||
open_daily_statistics=true;
|
||||
statistics.push_back(STATISTIC());
|
||||
continue;
|
||||
}
|
||||
else if (parse_double(buf, "<day>", statistics.back().day)) continue;
|
||||
else if (parse_double(buf, "<user_total_credit>", statistics.back().user_total_credit)) continue;
|
||||
else if (parse_double(buf, "<user_expavg_credit>", statistics.back().user_expavg_credit)) continue;
|
||||
else if (parse_double(buf, "<host_total_credit>", statistics.back().host_total_credit)) continue;
|
||||
else if (parse_double(buf, "<host_expavg_credit>", statistics.back().host_expavg_credit)) continue;
|
||||
else if (match_tag(buf, "</daily_statistics>")) {
|
||||
if (!open_daily_statistics) break;
|
||||
open_daily_statistics=false;
|
||||
DAILY_STATS daily_stats;
|
||||
retval = daily_stats.parse(in);
|
||||
if (retval) return retval;
|
||||
statistics.push_back(daily_stats);
|
||||
continue;
|
||||
}
|
||||
else if (parse_str(buf, "<master_url>", master_url, sizeof(master_url))) {
|
||||
|
@ -283,7 +292,7 @@ int CLIENT_STATE::parse_statistics_files() {
|
|||
"Project for statistic file %s not found - ignoring", name.c_str()
|
||||
);
|
||||
} else {
|
||||
for (std::vector<STATISTIC>::const_iterator i=temp->statistics.begin();
|
||||
for (std::vector<DAILY_STATS>::const_iterator i=temp->statistics.begin();
|
||||
i!=temp->statistics.end(); ++i
|
||||
) {
|
||||
project->statistics.push_back(*i);
|
||||
|
@ -309,7 +318,7 @@ int PROJECT::write_statistics_file() {
|
|||
master_url
|
||||
);
|
||||
|
||||
for (std::vector<STATISTIC>::iterator i=statistics.begin();
|
||||
for (std::vector<DAILY_STATS>::iterator i=statistics.begin();
|
||||
i!=statistics.end(); ++i
|
||||
) {
|
||||
fprintf(f,
|
||||
|
|
|
@ -573,19 +573,21 @@ int SCHEDULER_REPLY::parse(FILE* in, PROJECT* project) {
|
|||
|
||||
// check if vector is empty or we have a new day
|
||||
if (project->statistics.empty() || project->statistics.back().day!=dday()) {
|
||||
|
||||
// check if max. number of statistics already saved
|
||||
while (project->statistics.size()>30) {
|
||||
project->statistics.erase(project->statistics.begin());
|
||||
}
|
||||
|
||||
project->statistics.push_back(STATISTIC());
|
||||
DAILY_STATS nds;
|
||||
project->statistics.push_back(nds);
|
||||
}
|
||||
|
||||
project->statistics.back().day=dday();
|
||||
project->statistics.back().user_total_credit=project->user_total_credit;
|
||||
project->statistics.back().user_expavg_credit=project->user_expavg_credit;
|
||||
project->statistics.back().host_total_credit=project->host_total_credit;
|
||||
project->statistics.back().host_expavg_credit=project->host_expavg_credit;
|
||||
DAILY_STATS& ds = project->statistics.back();
|
||||
ds.day=dday();
|
||||
ds.user_total_credit=project->user_total_credit;
|
||||
ds.user_expavg_credit=project->user_expavg_credit;
|
||||
ds.host_total_credit=project->host_total_credit;
|
||||
ds.host_expavg_credit=project->host_expavg_credit;
|
||||
|
||||
project->write_statistics_file();
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ void CPaintStatistics::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
|||
|
||||
//Find minimum/maximum value
|
||||
double min_val=10e32, max_val=0;
|
||||
for (std::vector<STATISTIC>::const_iterator j=(*i)->statistics.begin();
|
||||
for (std::vector<DAILY_STATS>::const_iterator j=(*i)->statistics.begin();
|
||||
j!=(*i)->statistics.end();++j)
|
||||
{
|
||||
if (m_SelectedStatistic==0) {
|
||||
|
@ -207,7 +207,7 @@ void CPaintStatistics::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
|||
|
||||
//Draw day numbers and lines marking the days
|
||||
wxCoord xpos=rectangle_x_start;
|
||||
for (std::vector<STATISTIC>::const_iterator j=(*i)->statistics.begin(); j!=(*i)->statistics.end(); ++j) {
|
||||
for (std::vector<DAILY_STATS>::const_iterator j=(*i)->statistics.begin(); j!=(*i)->statistics.end(); ++j) {
|
||||
double day=dday()-j->day;
|
||||
day=day/(60*60*24);
|
||||
dc.SetPen(wxPen(wxColour (0 , 0 , 0) , 1 , wxSOLID));
|
||||
|
@ -230,7 +230,7 @@ void CPaintStatistics::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
|||
|
||||
wxCoord last_x=rectangle_x_start, last_y=0, xpos=rectangle_x_start, ypos=0;
|
||||
|
||||
for (std::vector<STATISTIC>::const_iterator j=(*i)->statistics.begin(); j!=(*i)->statistics.end(); ++j) {
|
||||
for (std::vector<DAILY_STATS>::const_iterator j=(*i)->statistics.begin(); j!=(*i)->statistics.end(); ++j) {
|
||||
|
||||
ypos=rectangle_y_end - 1 - (yscale * (j->user_total_credit-min_val));
|
||||
if (m_SelectedStatistic==0) {
|
||||
|
|
|
@ -102,12 +102,14 @@ struct GUI_URL {
|
|||
|
||||
// statistics at a specific day
|
||||
//
|
||||
struct STATISTIC {
|
||||
struct DAILY_STATS {
|
||||
double user_total_credit;
|
||||
double user_expavg_credit;
|
||||
double host_total_credit;
|
||||
double host_expavg_credit;
|
||||
double day;
|
||||
|
||||
int parse(MIOFILE&);
|
||||
};
|
||||
|
||||
|
||||
|
@ -145,7 +147,7 @@ public:
|
|||
void get_name(std::string&);
|
||||
|
||||
// statistic of the last x days
|
||||
std::vector<STATISTIC> statistics;
|
||||
std::vector<DAILY_STATS> statistics;
|
||||
};
|
||||
|
||||
class APP {
|
||||
|
|
|
@ -1002,6 +1002,19 @@ int RPC_CLIENT::get_disk_usage(PROJECTS& p) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int DAILY_STATS::parse(MIOFILE& in) {
|
||||
char buf[256];
|
||||
while (in.fgets(buf, 256)) {
|
||||
if (match_tag(buf, "</daily_statistics>")) return 0;
|
||||
else if (parse_double(buf, "<day>", day)) continue;
|
||||
else if (parse_double(buf, "<user_total_credit>", user_total_credit)) continue;
|
||||
else if (parse_double(buf, "<user_expavg_credit>", user_expavg_credit)) continue;
|
||||
else if (parse_double(buf, "<host_total_credit>", host_total_credit)) continue;
|
||||
else if (parse_double(buf, "<host_expavg_credit>", host_expavg_credit)) continue;
|
||||
}
|
||||
return ERR_XML_PARSE;
|
||||
}
|
||||
|
||||
int RPC_CLIENT::get_statistics(PROJECTS& p) {
|
||||
char buf[256];
|
||||
RPC rpc(this);
|
||||
|
@ -1022,16 +1035,10 @@ int RPC_CLIENT::get_statistics(PROJECTS& p) {
|
|||
if (match_tag(buf, "</project_statistics>")) break;
|
||||
else if (parse_str(buf, "<master_url>", p.projects.back()->master_url)) continue;
|
||||
else if (match_tag(buf, "<daily_statistics>")) {
|
||||
p.projects.back()->statistics.push_back(STATISTIC());
|
||||
|
||||
while (rpc.fin.fgets(buf, 256)) {
|
||||
if (match_tag(buf, "</daily_statistics>")) break;
|
||||
else if (parse_double(buf, "<day>", p.projects.back()->statistics.back().day)) continue;
|
||||
else if (parse_double(buf, "<user_total_credit>", p.projects.back()->statistics.back().user_total_credit)) continue;
|
||||
else if (parse_double(buf, "<user_expavg_credit>", p.projects.back()->statistics.back().user_expavg_credit)) continue;
|
||||
else if (parse_double(buf, "<host_total_credit>", p.projects.back()->statistics.back().host_total_credit)) continue;
|
||||
else if (parse_double(buf, "<host_expavg_credit>", p.projects.back()->statistics.back().host_expavg_credit)) continue;
|
||||
}
|
||||
DAILY_STATS ds;
|
||||
retval = ds.parse(rpc.fin);
|
||||
if (retval) return retval;
|
||||
p.projects.back()->statistics.push_back(ds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue