Skip to content

Commit c01f23e

Browse files
committed
Add estimated completion date
1 parent fb69ef6 commit c01f23e

File tree

2 files changed

+79
-35
lines changed

2 files changed

+79
-35
lines changed

clientgui/ViewWork.cpp

Lines changed: 75 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@
4949
#define COLUMN_STATUS 2
5050
#define COLUMN_CPUTIME 3
5151
#define COLUMN_TOCOMPLETION 4
52-
#define COLUMN_ESTIMATEDCOMPLETION 5
53-
#define COLUMN_DEADLINEDIFF 6
54-
#define COLUMN_REPORTDEADLINE 7
55-
#define COLUMN_APPLICATION 8
56-
#define COLUMN_NAME 9
52+
#define COLUMN_REPORTDEADLINE 5
53+
#define COLUMN_APPLICATION 6
54+
#define COLUMN_NAME 7
55+
#define COLUMN_ESTIMATEDCOMPLETION 8
56+
//#define COLUMN_DEADLINEDIFF 9
5757

5858

5959
// DefaultShownColumns is an array containing the
@@ -198,9 +198,9 @@ static bool CompareViewWorkItems(int iRowIndex1, int iRowIndex2) {
198198
result = 1;
199199
}
200200
break;
201-
case COLUMN_DEADLINEDIFF:
201+
//case COLUMN_DEADLINEDIFF:
202202
// SOMETHING GOES IN HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
203-
break;
203+
// break;
204204
}
205205

206206
// Always return FALSE for equality (result == 0)
@@ -282,10 +282,11 @@ CViewWork::CViewWork(wxNotebook* pNotebook) :
282282
m_aStdColNameOrder->Insert(_("Status"), COLUMN_STATUS);
283283
m_aStdColNameOrder->Insert(_("Elapsed"), COLUMN_CPUTIME);
284284
m_aStdColNameOrder->Insert(_("Remaining (estimated)"), COLUMN_TOCOMPLETION);
285-
m_aStdColNameOrder->Insert(_("Estimated Completion"), COLUMN_ESTIMATEDCOMPLETION);
286285
m_aStdColNameOrder->Insert(_("Deadline"), COLUMN_REPORTDEADLINE);
287286
m_aStdColNameOrder->Insert(_("Application"), COLUMN_APPLICATION);
288287
m_aStdColNameOrder->Insert(_("Name"), COLUMN_NAME);
288+
m_aStdColNameOrder->Insert(_("Estimated Completion"), COLUMN_ESTIMATEDCOMPLETION);
289+
//m_aStdColNameOrder->Insert(_("Completion Before Deadline"), COLUMN_DEADLINEDIFF);
289290

290291
// m_iStdColWidthOrder is an array of the width for each column.
291292
// Entries must be in order of ascending Column ID. We initialize
@@ -299,10 +300,11 @@ CViewWork::CViewWork(wxNotebook* pNotebook) :
299300
m_iStdColWidthOrder.Insert(135, COLUMN_STATUS);
300301
m_iStdColWidthOrder.Insert(80, COLUMN_CPUTIME);
301302
m_iStdColWidthOrder.Insert(100, COLUMN_TOCOMPLETION);
302-
m_iStdColWidthOrder.Insert(150, COLUMN_ESTIMATEDCOMPLETION);
303303
m_iStdColWidthOrder.Insert(150, COLUMN_REPORTDEADLINE);
304304
m_iStdColWidthOrder.Insert(95, COLUMN_APPLICATION);
305305
m_iStdColWidthOrder.Insert(285, COLUMN_NAME);
306+
m_iStdColWidthOrder.Insert(150, COLUMN_ESTIMATEDCOMPLETION);
307+
//m_iStdColWidthOrder.Insert(150, COLUMN_DEADLINEDIFF);
306308

307309
wxASSERT(m_iStdColWidthOrder.size() == m_aStdColNameOrder->size());
308310

@@ -357,10 +359,10 @@ void CViewWork::AppendColumn(int columnID){
357359
m_pListPane->AppendColumn((*m_aStdColNameOrder)[COLUMN_ESTIMATEDCOMPLETION],
358360
wxLIST_FORMAT_LEFT, m_iStdColWidthOrder[COLUMN_ESTIMATEDCOMPLETION]);
359361
break;
360-
case COLUMN_DEADLINEDIFF:
362+
/* case COLUMN_DEADLINEDIFF:
361363
m_pListPane->AppendColumn((*m_aStdColNameOrder)[COLUMN_DEADLINEDIFF],
362364
wxLIST_FORMAT_LEFT, m_iStdColWidthOrder[COLUMN_DEADLINEDIFF]);
363-
break;
365+
break; */
364366
}
365367
}
366368

@@ -783,30 +785,14 @@ wxString CViewWork::OnListGetItemText(long item, long column) const {
783785
strBuffer = work->m_strStatus;
784786
break;
785787
case COLUMN_ESTIMATEDCOMPLETION:
786-
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
787-
// Need to fix the following:
788-
// - replace "running"
789-
// - See how strBuffer should be addressed? Why is this not refereshing properly?
790-
if ((work->m_fCPUTime > 0) && (work->m_strStatus.Contains("Running"))) {
791-
wxDateTime now = wxDateTime::Now();
792-
wxTimeSpan time_to_completion = convert_to_timespan(work->m_fTimeToCompletion);
793-
wxDateTime estimated_completion = now.Add(time_to_completion);
794-
FormatDateTime(estimated_completion.GetTicks(), strBuffer);
795-
// Only display the Estimated Completion time if the task has
796-
// been started and is currently running.
797-
} else {
798-
strBuffer = FormatTime(0);
799-
// If the task has not started (CPUTime <= 0) or is not currently
800-
// running, pass 0 to FormatTime to display "---" as the Estimated
801-
// Completion time
802-
}
788+
strBuffer = work->m_strEstimatedCompletion;
803789
break;
804-
case COLUMN_DEADLINEDIFF:
790+
// case COLUMN_DEADLINEDIFF:
805791
// Fill out something here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
806-
break;
792+
// break;
807793
}
808794
}
809-
795+
810796
return strBuffer;
811797
}
812798

@@ -1054,7 +1040,7 @@ void CViewWork::UpdateSelection() {
10541040
bool CViewWork::SynchronizeCacheItem(wxInt32 iRowIndex, wxInt32 iColumnIndex) {
10551041
wxString strDocumentText = wxEmptyString;
10561042
wxString strDocumentText2 = wxEmptyString;
1057-
double x = 0.0;
1043+
double x = 0.0;
10581044
time_t tDocumentTime = (time_t)0;
10591045
CWork* work;
10601046

@@ -1063,9 +1049,9 @@ bool CViewWork::SynchronizeCacheItem(wxInt32 iRowIndex, wxInt32 iColumnIndex) {
10631049
if (GetWorkCacheAtIndex(work, m_iSortedIndexes[iRowIndex])) {
10641050
return false;
10651051
}
1066-
1052+
10671053
if (iColumnIndex < 0) return false;
1068-
1054+
10691055
switch (m_iColumnIndexToColumnID[iColumnIndex]) {
10701056
case COLUMN_PROJECT:
10711057
GetDocProjectName(m_iSortedIndexes[iRowIndex], strDocumentText);
@@ -1122,6 +1108,26 @@ bool CViewWork::SynchronizeCacheItem(wxInt32 iRowIndex, wxInt32 iColumnIndex) {
11221108
return true;
11231109
}
11241110
break;
1111+
case COLUMN_ESTIMATEDCOMPLETION:
1112+
// TODO: NEED TO ADD A WAY TO DISPLAY '---' if the date is the original date.
1113+
// Also todo: Let's change all time_t pointers from 'time' to something else, like 'pt'.
1114+
// Function to pass 0 (to read '---' is: strBuffer = FormatTime(0)
1115+
// TODO: Figure out logic to be most efficient for this case.
1116+
// - what happens if time returned in 0 (because task is not active)
1117+
// - what happens if no change in time
1118+
// -what happens if there is a change in time.
1119+
GetDocEstCompletionDate(m_iSortedIndexes[iRowIndex], tDocumentTime);
1120+
if (tDocumentTime != work->m_tEstimatedCompletion) {
1121+
work->m_tEstimatedCompletion = tDocumentTime;
1122+
if (work->m_tEstimatedCompletion = 0) {
1123+
work->m_strEstimatedCompletion << 0;
1124+
}
1125+
else {
1126+
FormatDateTime(tDocumentTime, work->m_strEstimatedCompletion);
1127+
}
1128+
return true;
1129+
}
1130+
break;
11251131
case COLUMN_STATUS:
11261132
int i = m_iSortedIndexes[iRowIndex];
11271133
RESULT* result = wxGetApp().GetDocument()->result(i);
@@ -1283,6 +1289,41 @@ void CViewWork::GetDocReportDeadline(wxInt32 item, time_t& time) const {
12831289
}
12841290
}
12851291

1292+
// Calculates the estimated date and time a task will be completed.
1293+
// This is only calculated for active tasks. If a task is not active,
1294+
// time pt will remain at zero. The intent is for the command calling this
1295+
// function to use that value to display '---', not the epoch time.
1296+
//
1297+
void CViewWork::GetDocEstCompletionDate(wxInt32 item, time_t& pt) const {
1298+
RESULT* result = wxGetApp().GetDocument()->result(item);
1299+
pt = 0;
1300+
if (result->active_task_state == 1) {
1301+
time_t ttime = time(0);
1302+
pt = ttime;
1303+
pt += (time_t)result->estimated_cpu_time_remaining;
1304+
}
1305+
1306+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1307+
// Figure out what "strBuffer" needs to be down below.
1308+
// double check what passing variables need to be.
1309+
// Add function to header
1310+
/* RESULT* result = wxGetApp().GetDocument()->result(m_iSortedIndexes[item]);
1311+
if ((work->m_fCPUTime > 0) && (result->active_task_state == 1)) {
1312+
wxDateTime now = wxDateTime::Now();
1313+
wxTimeSpan time_to_completion = convert_to_timespan(work->m_fTimeToCompletion);
1314+
wxDateTime estimated_completion = now.Add(time_to_completion);
1315+
FormatDateTime(estimated_completion.GetTicks(), strBuffer);
1316+
// Only display the Estimated Completion time if the task has
1317+
// been started and is currently running.
1318+
}
1319+
else {
1320+
strBuffer = FormatTime(0);
1321+
// If the task has not started (CPUTime <= 0) or is not currently
1322+
// running, pass 0 to FormatTime to display "---" as the Estimated
1323+
// Completion time
1324+
}*/
1325+
}
1326+
12861327

12871328
wxInt32 CViewWork::FormatDateTime(time_t datetime, wxString& strBuffer) const {
12881329
#ifdef __WXMAC__

clientgui/ViewWork.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file is part of BOINC.
22
// http://boinc.berkeley.edu
3-
// Copyright (C) 2008 University of California
3+
// Copyright (C) 2022 University of California
44
//
55
// BOINC is free software; you can redistribute it and/or modify it
66
// under the terms of the GNU Lesser General Public License
@@ -39,12 +39,14 @@ class CWork : public wxObject
3939
double m_fProgress;
4040
double m_fTimeToCompletion;
4141
time_t m_tReportDeadline;
42+
time_t m_tEstimatedCompletion;
4243
wxString m_strStatus;
4344
wxString m_strProjectURL; // Used internally, not displayed
4445
wxString m_strCPUTime;
4546
wxString m_strProgress;
4647
wxString m_strTimeToCompletion;
4748
wxString m_strReportDeadline;
49+
wxString m_strEstimatedCompletion;
4850
};
4951

5052

@@ -107,6 +109,7 @@ class CViewWork : public CBOINCBaseView
107109
wxInt32 FormatProgress( double fBuffer, wxString& strBuffer ) const;
108110
void GetDocTimeToCompletion(wxInt32 item, double& fBuffer) const;
109111
void GetDocReportDeadline(wxInt32 item, time_t& time) const;
112+
void GetDocEstCompletionDate(wxInt32 item, time_t& time) const;
110113
wxInt32 FormatDateTime( time_t datetime, wxString& strBuffer ) const;
111114
wxInt32 FormatStatus( wxInt32 item, wxString& strBuffer ) const;
112115
void GetDocProjectURL(wxInt32 item, wxString& strBuffer) const;

0 commit comments

Comments
 (0)