diff --git a/checkin_notes b/checkin_notes index 6f31330953..a9c6961f6d 100755 --- a/checkin_notes +++ b/checkin_notes @@ -27522,7 +27522,7 @@ David 21 April 2005 MainDocument.cpp,h ViewProjects.cpp -Rom 20 April 2005 +Rom 21 April 2005 - Code Cleanup clientgui/ @@ -27535,3 +27535,21 @@ Rom 20 April 2005 ViewStatistics.cpp, .h ViewTransfers.cpp, .h ViewWork.cpp, .h + +David 21 April 2005 + - CPU scheduler: don't run projects or results suspended via GUI, + even in earliest-deadline-first mode + - fix button logic for projects + - set buttons in work tab based on selection + - include graphics_mode_acked in GUI RPC description RESULT. + Could indicate whether app has window open (but doesn't yet). + + client/ + app.C + cs_apps.C + clientgui/ + MainDocument.cpp,h + ViewProjects.cpp,h + ViewWork.cpp, h + lib/ + gui_rpc_client.h diff --git a/client/app.C b/client/app.C index ee1ca1eed8..ef47829ee3 100644 --- a/client/app.C +++ b/client/app.C @@ -352,9 +352,7 @@ int ACTIVE_TASK::write(MIOFILE& fout) { " %f\n" " %f\n" " %f\n" - " %f\n" - "%s" - "\n", + " %f\n", result->project->master_url, result->name, task_state, @@ -365,9 +363,16 @@ int ACTIVE_TASK::write(MIOFILE& fout) { fraction_done, current_cpu_time, vm_bytes, - rss_bytes, - supports_graphics()?" \n":"" + rss_bytes ); + if (supports_graphics()) { + fout.printf( + " \n" + " %d\n", + graphics_mode_acked + ); + } + fout.printf("\n"); return 0; } diff --git a/client/cs_apps.C b/client/cs_apps.C index 504c36722a..61f86c53d0 100644 --- a/client/cs_apps.C +++ b/client/cs_apps.C @@ -347,6 +347,7 @@ bool CLIENT_STATE::schedule_largest_debt_project(double expected_pay_off) { best_project->next_runnable_result = 0; return true; } + // Schedule the active task with the earliest deadline // Return true iff a task was scheduled. // @@ -360,6 +361,8 @@ bool CLIENT_STATE::schedule_earliest_deadline_result(double expected_pay_off) { for (i=0; i < results.size(); ++i) { RESULT *r = results[i]; if (r->state != RESULT_FILES_DOWNLOADED) continue; + if (r->suspended_via_gui) continue; + if (r->project->suspended_via_gui) continue; if (r->project->non_cpu_intensive) continue; if (r->already_selected) continue; if (first || r->report_deadline < earliest_deadline) { diff --git a/clientgui/MainDocument.cpp b/clientgui/MainDocument.cpp index 80dd98a21c..011e2d3836 100644 --- a/clientgui/MainDocument.cpp +++ b/clientgui/MainDocument.cpp @@ -1063,6 +1063,10 @@ PROJECT* CMainDocument::project(int i) { return project_status.projects[i]; } +RESULT* CMainDocument::result(int i) { + return results.results[i]; +} + int CMainDocument::CachedResultsStatusUpdate() { int iRetVal = 0; diff --git a/clientgui/MainDocument.h b/clientgui/MainDocument.h index 465cc26e86..ce04381ba4 100644 --- a/clientgui/MainDocument.h +++ b/clientgui/MainDocument.h @@ -164,6 +164,7 @@ private: public: PROJECT* project(int); + RESULT* result(int); int GetProjectCount(); int GetProjectProjectName(int iIndex, wxString& strBuffer); int GetProjectProjectURL(int iIndex, wxString& strBuffer); diff --git a/clientgui/ViewProjects.cpp b/clientgui/ViewProjects.cpp index a18800cd87..017f69384e 100644 --- a/clientgui/ViewProjects.cpp +++ b/clientgui/ViewProjects.cpp @@ -77,9 +77,7 @@ IMPLEMENT_DYNAMIC_CLASS(CViewProjects, CBOINCBaseView) BEGIN_EVENT_TABLE (CViewProjects, CBOINCBaseView) EVT_BUTTON(ID_TASK_PROJECT_UPDATE, CViewProjects::OnProjectUpdate) EVT_BUTTON(ID_TASK_PROJECT_SUSPEND, CViewProjects::OnProjectSuspend) - EVT_BUTTON(ID_TASK_PROJECT_RESUME, CViewProjects::OnProjectResume) EVT_BUTTON(ID_TASK_PROJECT_NONEWWORK, CViewProjects::OnProjectNoNewWork) - EVT_BUTTON(ID_TASK_PROJECT_ALLOWNEWWORK, CViewProjects::OnProjectAllowNewWork) EVT_BUTTON(ID_TASK_PROJECT_RESET, CViewProjects::OnProjectReset) EVT_BUTTON(ID_TASK_PROJECT_DETACH, CViewProjects::OnProjectDetach) EVT_BUTTON(ID_TASK_PROJECT_ATTACH, CViewProjects::OnProjectAttach) @@ -108,15 +106,15 @@ CViewProjects::CViewProjects(wxNotebook* pNotebook) : m_TaskGroups.push_back( pGroup ); pItem = new CTaskItem( - _("Update project"), - _("Report all completed work and refresh " - "your credit and preferences for this project."), + _("Update"), + _("Report all completed work, get latest credit, " + "get latest preferences, and possibly get more work."), ID_TASK_PROJECT_UPDATE ); pGroup->m_Tasks.push_back( pItem ); pItem = new CTaskItem( - _("Suspend project"), + _("Suspend"), _("Stop work for this project " "(you can resume later)."), ID_TASK_PROJECT_SUSPEND @@ -144,7 +142,7 @@ CViewProjects::CViewProjects(wxNotebook* pNotebook) : pGroup->m_Tasks.push_back( pItem ); pItem = new CTaskItem( - _("Detach from project"), + _("Detach"), _("Detach this computer from this project. " "Work in progress will be lost. " "You can update the project first to report " @@ -192,6 +190,8 @@ CViewProjects::CViewProjects(wxNotebook* pNotebook) : m_pListPane->InsertColumn(COLUMN_AVGCREDIT, _("Avg. credit"), wxLIST_FORMAT_RIGHT, 80); m_pListPane->InsertColumn(COLUMN_RESOURCESHARE, _("Resource share"), wxLIST_FORMAT_CENTRE, 85); m_pListPane->InsertColumn(COLUMN_STATUS, _("Status"), wxLIST_FORMAT_LEFT, 150); + + UpdateSelection(); } @@ -248,9 +248,16 @@ void CViewProjects::OnProjectSuspend( wxCommandEvent& event ) { wxASSERT(NULL != m_pTaskPane); wxASSERT(NULL != m_pListPane); - pFrame->UpdateStatusText(_("Suspending project...")); - pDoc->ProjectSuspend(m_pListPane->GetFirstSelected()); - pFrame->UpdateStatusText(wxT("")); + PROJECT* project = pDoc->project(m_pListPane->GetFirstSelected()); + if (project->suspended_via_gui) { + pFrame->UpdateStatusText(_("Resuming project...")); + pDoc->ProjectResume(m_pListPane->GetFirstSelected()); + pFrame->UpdateStatusText(wxT("")); + } else { + pFrame->UpdateStatusText(_("Suspending project...")); + pDoc->ProjectSuspend(m_pListPane->GetFirstSelected()); + pFrame->UpdateStatusText(wxT("")); + } UpdateSelection(); pFrame->ProcessRefreshView(); @@ -259,30 +266,6 @@ void CViewProjects::OnProjectSuspend( wxCommandEvent& event ) { } -void CViewProjects::OnProjectResume( wxCommandEvent& event ) { - wxLogTrace(wxT("Function Start/End"), wxT("CViewProjects::OnProjectResume - Function Begin")); - - CMainDocument* pDoc = wxGetApp().GetDocument(); - CMainFrame* pFrame = wxGetApp().GetFrame(); - - wxASSERT(NULL != pDoc); - wxASSERT(wxDynamicCast(pDoc, CMainDocument)); - wxASSERT(NULL != pFrame); - wxASSERT(wxDynamicCast(pFrame, CMainFrame)); - wxASSERT(NULL != m_pTaskPane); - wxASSERT(NULL != m_pListPane); - - pFrame->UpdateStatusText(_("Resuming project...")); - pDoc->ProjectResume(m_pListPane->GetFirstSelected()); - pFrame->UpdateStatusText(wxT("")); - - UpdateSelection(); - pFrame->ProcessRefreshView(); - - wxLogTrace(wxT("Function Start/End"), wxT("CViewProjects::OnProjectResume - Function End")); -} - - void CViewProjects::OnProjectNoNewWork( wxCommandEvent& event ) { wxLogTrace(wxT("Function Start/End"), wxT("CViewProjects::OnProjectNoNewWork - Function Begin")); @@ -296,9 +279,16 @@ void CViewProjects::OnProjectNoNewWork( wxCommandEvent& event ) { wxASSERT(NULL != m_pTaskPane); wxASSERT(NULL != m_pListPane); - pFrame->UpdateStatusText(_("Telling project to not fetch additional work...")); - pDoc->ProjectNoMoreWork(m_pListPane->GetFirstSelected()); - pFrame->UpdateStatusText(wxT("")); + PROJECT* project = pDoc->project(m_pListPane->GetFirstSelected()); + if (project->dont_request_more_work) { + pFrame->UpdateStatusText(_("Telling project to allow additional work downloads...")); + pDoc->ProjectAllowMoreWork(m_pListPane->GetFirstSelected()); + pFrame->UpdateStatusText(wxT("")); + } else { + pFrame->UpdateStatusText(_("Telling project to not fetch additional work...")); + pDoc->ProjectNoMoreWork(m_pListPane->GetFirstSelected()); + pFrame->UpdateStatusText(wxT("")); + } UpdateSelection(); pFrame->ProcessRefreshView(); @@ -307,28 +297,6 @@ void CViewProjects::OnProjectNoNewWork( wxCommandEvent& event ) { } -void CViewProjects::OnProjectAllowNewWork( wxCommandEvent& event ) { - wxLogTrace(wxT("Function Start/End"), wxT("CViewProjects::OnProjectAllowNewWork - Function Begin")); - - CMainDocument* pDoc = wxGetApp().GetDocument(); - CMainFrame* pFrame = wxGetApp().GetFrame(); - - wxASSERT(NULL != pDoc); - wxASSERT(wxDynamicCast(pDoc, CMainDocument)); - wxASSERT(NULL != pFrame); - wxASSERT(wxDynamicCast(pFrame, CMainFrame)); - wxASSERT(NULL != m_pTaskPane); - wxASSERT(NULL != m_pListPane); - - pFrame->UpdateStatusText(_("Telling project to allow additional work downloads...")); - pDoc->ProjectAllowMoreWork(m_pListPane->GetFirstSelected()); - pFrame->UpdateStatusText(wxT("")); - - UpdateSelection(); - pFrame->ProcessRefreshView(); - - wxLogTrace(wxT("Function Start/End"), wxT("CViewProjects::OnProjectAllowNewWork - Function End")); -} void CViewProjects::OnProjectReset( wxCommandEvent& event ) { @@ -647,7 +615,7 @@ void CViewProjects::UpdateSelection() { pGroup->button(BTN_NOWORK)->SetToolTip(wxString("Allow fetching new work for this project")); } else { pGroup->button(BTN_NOWORK)->SetLabel(wxString("No new work")); - pGroup->button(BTN_NOWORK)->SetToolTip(wxString("Don't allow fetching new work for this project")); + pGroup->button(BTN_NOWORK)->SetToolTip(wxString("Don't fetch new work for this project")); } pGroup->button(BTN_RESET)->Enable(); pGroup->button(BTN_DETACH)->Enable(); diff --git a/clientgui/ViewProjects.h b/clientgui/ViewProjects.h index 25e70e5075..3d200aca41 100644 --- a/clientgui/ViewProjects.h +++ b/clientgui/ViewProjects.h @@ -59,9 +59,7 @@ public: void OnProjectUpdate( wxCommandEvent& event ); void OnProjectSuspend( wxCommandEvent& event ); - void OnProjectResume( wxCommandEvent& event ); void OnProjectNoNewWork( wxCommandEvent& event ); - void OnProjectAllowNewWork( wxCommandEvent& event ); void OnProjectReset( wxCommandEvent& event ); void OnProjectDetach( wxCommandEvent& event ); void OnProjectAttach( wxCommandEvent& event ); diff --git a/clientgui/ViewWork.cpp b/clientgui/ViewWork.cpp index adc3ac93fa..45abdfaf92 100644 --- a/clientgui/ViewWork.cpp +++ b/clientgui/ViewWork.cpp @@ -42,6 +42,9 @@ #define COLUMN_REPORTDEADLINE 6 #define COLUMN_STATUS 7 +#define BTN_SUSPEND 0 +#define BTN_GRAPHICS 1 +#define BTN_ABORT 2 CWork::CWork() { m_strProjectName = wxEmptyString; @@ -71,7 +74,6 @@ IMPLEMENT_DYNAMIC_CLASS(CViewWork, CBOINCBaseView) BEGIN_EVENT_TABLE (CViewWork, CBOINCBaseView) EVT_BUTTON(ID_TASK_WORK_SUSPEND, CViewWork::OnWorkSuspend) - EVT_BUTTON(ID_TASK_WORK_RESUME, CViewWork::OnWorkResume) EVT_BUTTON(ID_TASK_WORK_SHOWGRAPHICS, CViewWork::OnWorkShowGraphics) EVT_BUTTON(ID_TASK_WORK_ABORT, CViewWork::OnWorkAbort) EVT_LIST_ITEM_SELECTED(ID_LIST_WORKVIEW, CViewWork::OnListSelected) @@ -100,16 +102,9 @@ CViewWork::CViewWork(wxNotebook* pNotebook) : pItem = new CTaskItem( _("Suspend"), - _("Suspend the result."), + _("Suspend work on the result."), ID_TASK_WORK_SUSPEND ); - pGroup->m_Tasks.push_back( pItem ); - - pItem = new CTaskItem( - _("Resume"), - _("Resume a suspended result."), - ID_TASK_WORK_RESUME - ); pGroup->m_Tasks.push_back( pItem ); pItem = new CTaskItem( @@ -120,9 +115,9 @@ CViewWork::CViewWork(wxNotebook* pNotebook) : pGroup->m_Tasks.push_back( pItem ); pItem = new CTaskItem( - _("Abort result"), - _("Delete the result from the work queue. " - "This will prevent you from being granted credit for the result."), + _("Abort"), + _("Abandon work on the result. " + "You will get no credit for it."), ID_TASK_WORK_ABORT ); pGroup->m_Tasks.push_back( pItem ); @@ -140,6 +135,8 @@ CViewWork::CViewWork(wxNotebook* pNotebook) : m_pListPane->InsertColumn(COLUMN_TOCOMPLETION, _("To completion"), wxLIST_FORMAT_RIGHT, 100); m_pListPane->InsertColumn(COLUMN_REPORTDEADLINE, _("Report deadline"), wxLIST_FORMAT_LEFT, 150); m_pListPane->InsertColumn(COLUMN_STATUS, _("Status"), wxLIST_FORMAT_LEFT, 135); + + UpdateSelection(); } @@ -172,9 +169,16 @@ void CViewWork::OnWorkSuspend( wxCommandEvent& event ) { wxASSERT(NULL != m_pTaskPane); wxASSERT(NULL != m_pListPane); - pFrame->UpdateStatusText(_("Suspending result...")); - pDoc->WorkSuspend(m_pListPane->GetFirstSelected()); - pFrame->UpdateStatusText(wxT("")); + RESULT* result = pDoc->result(m_pListPane->GetFirstSelected()); + if (result->suspended_via_gui) { + pFrame->UpdateStatusText(_("Resuming result...")); + pDoc->WorkResume(m_pListPane->GetFirstSelected()); + pFrame->UpdateStatusText(wxT("")); + } else { + pFrame->UpdateStatusText(_("Suspending result...")); + pDoc->WorkSuspend(m_pListPane->GetFirstSelected()); + pFrame->UpdateStatusText(wxT("")); + } UpdateSelection(); pFrame->ProcessRefreshView(); @@ -182,31 +186,6 @@ void CViewWork::OnWorkSuspend( wxCommandEvent& event ) { wxLogTrace(wxT("Function Start/End"), wxT("CViewWork::OnWorkSuspend - Function End")); } - -void CViewWork::OnWorkResume( wxCommandEvent& event ) { - wxLogTrace(wxT("Function Start/End"), wxT("CViewWork::OnWorkResume - Function Begin")); - - CMainDocument* pDoc = wxGetApp().GetDocument(); - CMainFrame* pFrame = wxGetApp().GetFrame(); - - wxASSERT(NULL != pDoc); - wxASSERT(wxDynamicCast(pDoc, CMainDocument)); - wxASSERT(NULL != pFrame); - wxASSERT(wxDynamicCast(pFrame, CMainFrame)); - wxASSERT(NULL != m_pTaskPane); - wxASSERT(NULL != m_pListPane); - - pFrame->UpdateStatusText(_("Resuming result...")); - pDoc->WorkResume(m_pListPane->GetFirstSelected()); - pFrame->UpdateStatusText(wxT("")); - - UpdateSelection(); - pFrame->ProcessRefreshView(); - - wxLogTrace(wxT("Function Start/End"), wxT("CViewWork::OnWorkResume - Function End")); -} - - void CViewWork::OnWorkShowGraphics( wxCommandEvent& event ) { wxLogTrace(wxT("Function Start/End"), wxT("CViewWork::OnWorkShowGraphics - Function Begin")); @@ -226,29 +205,36 @@ void CViewWork::OnWorkShowGraphics( wxCommandEvent& event ) { pDoc->GetConnectedComputerName(strMachineName); + RESULT* result = pDoc->result(m_pListPane->GetFirstSelected()); + + // TODO: implement hide as well as show + if (1) { #ifdef _WIN32 - if (!strMachineName.empty()) { - iAnswer = wxMessageBox( - _("Are you sure you wish to display graphics on a remote machine?"), - _("Show graphics"), - wxYES_NO | wxICON_QUESTION, - this - ); - } else { - iAnswer = wxYES; - } + if (!strMachineName.empty()) { + iAnswer = wxMessageBox( + _("Are you sure you wish to display graphics on a remote machine?"), + _("Show graphics"), + wxYES_NO | wxICON_QUESTION, + this + ); + } else { + iAnswer = wxYES; + } #else - iAnswer = wxYES; + iAnswer = wxYES; #endif - if (wxYES == iAnswer) { - pDoc->WorkShowGraphics( - m_pListPane->GetFirstSelected(), - false, - wxGetApp().m_strDefaultWindowStation, - wxGetApp().m_strDefaultDesktop, - wxGetApp().m_strDefaultDisplay - ); + if (wxYES == iAnswer) { + pDoc->WorkShowGraphics( + m_pListPane->GetFirstSelected(), + false, + wxGetApp().m_strDefaultWindowStation, + wxGetApp().m_strDefaultDesktop, + wxGetApp().m_strDefaultDisplay + ); + } + + pFrame->UpdateStatusText(wxT("")); } pFrame->UpdateStatusText(wxT("")); @@ -450,6 +436,31 @@ wxInt32 CViewWork::UpdateCache(long item, long column, wxString& strNewData) { void CViewWork::UpdateSelection() { + CTaskItemGroup* pGroup = m_TaskGroups[0]; + + if (m_pListPane->GetSelectedItemCount() == 0) { + pGroup->button(BTN_SUSPEND)->Disable(); + pGroup->button(BTN_GRAPHICS)->Disable(); + pGroup->button(BTN_ABORT)->Disable(); + } else { + CMainDocument* pDoc = wxGetApp().GetDocument(); + RESULT* result = pDoc->result(m_pListPane->GetFirstSelected()); + pGroup->button(BTN_SUSPEND)->Enable(); + if (result->suspended_via_gui) { + pGroup->button(BTN_SUSPEND)->SetLabel(wxString("Resume")); + pGroup->button(BTN_SUSPEND)->SetToolTip(wxString("Resume work for this result")); + } else { + pGroup->button(BTN_SUSPEND)->SetLabel(wxString("Suspend")); + pGroup->button(BTN_SUSPEND)->SetToolTip(wxString("Suspend work for this result")); + } + if (result->supports_graphics) { + pGroup->button(BTN_GRAPHICS)->Enable(); + } else { + pGroup->button(BTN_GRAPHICS)->Disable(); + } + pGroup->button(BTN_ABORT)->Enable(); + + } } diff --git a/clientgui/ViewWork.h b/clientgui/ViewWork.h index 6051398829..4fd26f81aa 100644 --- a/clientgui/ViewWork.h +++ b/clientgui/ViewWork.h @@ -59,7 +59,6 @@ public: virtual const char** GetViewIcon(); void OnWorkSuspend( wxCommandEvent& event ); - void OnWorkResume( wxCommandEvent& event ); void OnWorkShowGraphics( wxCommandEvent& event ); void OnWorkAbort( wxCommandEvent& event ); diff --git a/lib/gui_rpc_client.h b/lib/gui_rpc_client.h index 5733e2a762..7009f1fff7 100644 --- a/lib/gui_rpc_client.h +++ b/lib/gui_rpc_client.h @@ -194,6 +194,7 @@ public: double rss_bytes; double estimated_cpu_time_remaining; bool supports_graphics; + int graphics_mode_acked; APP* app; WORKUNIT* wup;