From 5a4085c988e0040ae541c4fb2fc41a7319156d2b Mon Sep 17 00:00:00 2001 From: Steven Janzou Date: Tue, 21 Sep 2021 00:36:56 -0600 Subject: [PATCH 1/4] Examples of getting and setting array values with the schednumeric control. --- src/combinecases.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/combinecases.cpp b/src/combinecases.cpp index 434f0fd5c1..8d62211e94 100644 --- a/src/combinecases.cpp +++ b/src/combinecases.cpp @@ -152,12 +152,24 @@ void CombineCasesDialog::OnEvt(wxCommandEvent& e) case_window->UpdateResults(); // Maybe just return the value instead of setting the table value directly? - // Set array + // Set array from user interface control //if (auto pvv = current_case->Values().Get("degradation")) { // double v[] = { 1.0, 2.0, 3.0, 4.0 }; // pvv->Set(v, 4); // current_case->VariableChanged("degradation"); // triggers UI update //} + + // Get array value from user interface control + if (auto pvv = current_case->Values().Get("degradation")) { + auto aDegradation = pvv->Array(); // std::vector + wxString sDegradation; + for (auto degradation : aDegradation) { + sDegradation += wxString::Format("%g,", degradation); + } + wxMessageBox(sDegradation.Left(sDegradation.size()-1), "Degradation Array", wxOK, this); + } + + int x = 1; } From 9c7b70105846a7c291472c885d4cce5acf06496a Mon Sep 17 00:00:00 2001 From: Steven Janzou Date: Wed, 22 Sep 2021 04:13:57 -0600 Subject: [PATCH 2/4] DataArray dialog and SchedNumeric examples --- src/combinecases.cpp | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/combinecases.cpp b/src/combinecases.cpp index 8d62211e94..4021d65a2d 100644 --- a/src/combinecases.cpp +++ b/src/combinecases.cpp @@ -158,19 +158,34 @@ void CombineCasesDialog::OnEvt(wxCommandEvent& e) // pvv->Set(v, 4); // current_case->VariableChanged("degradation"); // triggers UI update //} - - // Get array value from user interface control + + // Get current degradation value from user interface control if (auto pvv = current_case->Values().Get("degradation")) { - auto aDegradation = pvv->Array(); // std::vector - wxString sDegradation; - for (auto degradation : aDegradation) { - sDegradation += wxString::Format("%g,", degradation); - } - wxMessageBox(sDegradation.Left(sDegradation.size()-1), "Degradation Array", wxOK, this); + auto acurrentDegradation = pvv->Array(); // current degradation value from interface + // set to desired degradation value + double_vec anewDegradation; + anewDegradation.push_back(0.5); // set to single value or different array value - ssc keys on length of array - single values are arrays of length 1 + pvv->Set(anewDegradation); + case_window->RunBaseCase(); + // get whatever results you would like here + // reset degradation + pvv->Set(acurrentDegradation); + // no need to reset UI if no property changed } - - - int x = 1; + + + // Generic power plant edit data array + AFDataArrayButton* dab = new AFDataArrayButton(this, wxID_ANY); + std::vector aVal(8760, 1.0); + dab->Set(aVal); + dab->OnPressed(e); + // change in dialog + dab->Get(aVal); // get updated values + // Do something with updated values - the array can be from a variable as in the degradation section above + wxString out; + for (auto val : aVal) + out += wxString::Format("%g,", val); + wxMessageBox(out.Left(out.Length()-1), "Data Array Values"); } EndModal(wxID_OK); From 2d9af733ee0003ccf58bb74e6960ea3ba3fb1e46 Mon Sep 17 00:00:00 2001 From: Steven Janzou Date: Thu, 23 Sep 2021 04:40:01 -0600 Subject: [PATCH 3/4] Fix CaseWindow::GetInputPage() to retrun correct string --- src/casewin.cpp | 3 +-- src/combinecases.cpp | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/casewin.cpp b/src/casewin.cpp index 3ae3946bea..5ab6af30d9 100644 --- a/src/casewin.cpp +++ b/src/casewin.cpp @@ -831,8 +831,7 @@ void CaseWindow::DetachCurrentInputPage() wxString CaseWindow::GetInputPage() { - wxArrayString input_pages = GetInputPages(); - wxString input_page = input_pages[m_pageFlipper->GetSelection()]; + wxString input_page = m_inputPageList->GetStringSelection(); // do checks return input_page; } diff --git a/src/combinecases.cpp b/src/combinecases.cpp index 5185bd47b3..6eda2a3ae6 100644 --- a/src/combinecases.cpp +++ b/src/combinecases.cpp @@ -361,8 +361,8 @@ void CombineCasesDialog::OnEvt(wxCommandEvent& e) // Update UI with results case_window->UpdateResults(); - //case_window->SwitchToInputPage("case_page_orig"); // TODO: switch to original page (how to get current page?) - case_window->SwitchToPage("results"); + case_window->SwitchToInputPage(case_page_orig); // switch to original page + case_window->SwitchToPage("results"); // this overwrites the input page selection but input page selected is still highlighted } //For user benefit, change the fixed O&M schedule back to a single value if all entries are the same From 7799202e1b06ede3335bfda9d64d1e1f4f130d9f Mon Sep 17 00:00:00 2001 From: Steven Janzou Date: Wed, 29 Sep 2021 03:05:52 -0600 Subject: [PATCH 4/4] Update to pull request #708 --- src/combinecases.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/combinecases.cpp b/src/combinecases.cpp index 6eda2a3ae6..4d9fe9f59c 100644 --- a/src/combinecases.cpp +++ b/src/combinecases.cpp @@ -83,7 +83,7 @@ CombineCasesDialog::CombineCasesDialog(wxWindow* parent, const wxString& title, // '\n provide an annual AC degradation rate to use for the combined project,' // '\n or enter a zero to ignore degradation.'; // TODO: make this a SchedNumeric instead so a schedule could be used - m_spndDegradation = new wxSpinCtrlDouble(this, ID_spndDegradation, "Annual AC Degradation", wxDefaultPosition, wxSize(54, 22), + m_spndDegradation = new wxSpinCtrlDouble(this, ID_spndDegradation, "Annual AC Degradation", wxDefaultPosition, wxSize(54, 28), wxSP_ARROW_KEYS, 0, 100, m_generic_degradation[0], 0.1, "wxspndDegradation"); wxString degradation_label = "%/year Annual AC degradation rate"; wxBoxSizer* szdegradation = new wxBoxSizer(wxHORIZONTAL); @@ -205,9 +205,14 @@ void CombineCasesDialog::OnEvt(wxCommandEvent& e) inflation_vv->Set(inflation); } - // Simulate - bcsim.Clear(); - bool ok = bcsim.Invoke(); + bool ok = false; + { + wxBusyCursor wait; + + // Simulate + bcsim.Clear(); + ok = bcsim.Invoke(true); // true to suppress flux map simulation dialog + } // check that the case ran if (!ok) {