Skip to content

Commit

Permalink
Commiting the WIP I had on one of my machines.
Browse files Browse the repository at this point in the history
Add outputDiangostics: both this and OutputTabeSUmmary throw

Can't find Impl?

* thread #1, name = 'OpenStudioApp', stop reason = signal SIGSEGV: invalid address (fault address: 0x555500000000)
  * frame #0: 0x00007fffedb3a0eb libstdc++.so.6`__dynamic_cast + 27
    frame #1: 0x0000555555a398ba OpenStudioApp`std::shared_ptr<openstudio::model::detail::OutputDiagnostics_Impl> std::dynamic_pointer_cast<openstudio::model::detail::OutputDiagnostics_Impl, openstudio::detail::IdfObject_Impl>(__r=nullptr) at shared_ptr.h:499
    frame #2: 0x0000555555a2e944 OpenStudioApp`std::shared_ptr<openstudio::model::detail::OutputDiagnostics_Impl> openstudio::IdfObject::getImpl<openstudio::model::detail::OutputDiagnostics_Impl>(this=0x00007fffffff9ec0) const at IdfObject.hpp:381
    frame #3: 0x00007ffff47f911b libopenstudiolib.so`openstudio::model::OutputDiagnostics::keys[abi:cxx11](this=0x00007fffffff9ec0) const at OutputDiagnostics.cpp:153
    frame #4: 0x0000555555a17f78 OpenStudioApp`operator(__closure=0x0000555557f179c0) at SimSettingsView.cpp:1918
  • Loading branch information
jmarrec committed Feb 10, 2021
1 parent 2859809 commit 695f279
Show file tree
Hide file tree
Showing 2 changed files with 160 additions and 1 deletion.
150 changes: 149 additions & 1 deletion src/openstudio_lib/SimSettingsView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "../shared_gui_components/OSSwitch.hpp"
#include "SchedulesView.hpp" // ScheduleCalendarWidget, MonthView

#include <algorithm>
#include <openstudio/model/ConvergenceLimits.hpp>
#include <openstudio/model/ConvergenceLimits_Impl.hpp>
#include <openstudio/model/HeatBalanceAlgorithm.hpp>
Expand All @@ -51,6 +52,10 @@
#include <openstudio/model/OutputControlReportingTolerances_Impl.hpp>
#include <openstudio/model/OutputJSON.hpp>
#include <openstudio/model/OutputJSON_Impl.hpp>
#include <openstudio/model/OutputTableSummaryReports.hpp>
#include <openstudio/model/OutputTableSummaryReports_Impl.hpp>
#include <openstudio/model/OutputDiagnostics.hpp>
#include <openstudio/model/OutputDiagnostics_Impl.hpp>
#include <openstudio/model/OutsideSurfaceConvectionAlgorithm.hpp>
#include <openstudio/model/OutsideSurfaceConvectionAlgorithm_Impl.hpp>
#include <openstudio/model/ProgramControl.hpp>
Expand Down Expand Up @@ -215,7 +220,12 @@ SimSettingsView::SimSettingsView(bool isIP, const model::Model& model, QWidget*
m_json_optionType(nullptr),
m_json_outputJSON(nullptr),
m_json_outputCBOR(nullptr),
m_json_outputMessagePack(nullptr) {
m_json_outputMessagePack(nullptr),

// Advanced Output
m_table_allSummary(nullptr),
m_diagnostics_displayExtraWarnings(nullptr) {

connect(this, &SimSettingsView::toggleUnitsClicked, this, &SimSettingsView::toggleUnits);

// when the year settings object changes need to update the year in all child widgets
Expand Down Expand Up @@ -305,6 +315,14 @@ void SimSettingsView::createWidgets() {
collapsibleInspector = new CollapsibleInspector("Output JSON", createOutputJSONWidget());
mainLayout->addWidget(collapsibleInspector);

//******************* OS:Output:Table:SummaryReports *******************
collapsibleInspector = new CollapsibleInspector("Output Table Summary Reports", createOutputTableSummaryReportsWidget());
mainLayout->addWidget(collapsibleInspector);

//******************* OS:Output:Diagnostics *******************
collapsibleInspector = new CollapsibleInspector("Output Diagnostics", createOutputDiagnosticsWidget());
mainLayout->addWidget(collapsibleInspector);

mainLayout->addStretch();
}

Expand Down Expand Up @@ -1102,6 +1120,44 @@ QWidget* SimSettingsView::createOutputJSONWidget() {
return widget;
}

QWidget* SimSettingsView::createOutputTableSummaryReportsWidget() {

auto gridLayout = new QGridLayout();
gridLayout->setContentsMargins(7, 7, 7, 7);
gridLayout->setSpacing(GRID_LAYOUT_SPACING);
gridLayout->setAlignment(Qt::AlignLeft);

int row = 0;
int col = 0;

addField(gridLayout, row, col, "Enable AllSummary Report", m_table_allSummary);

auto widget = new QWidget();
widget->setLayout(gridLayout);
widget->hide();

return widget;
}

QWidget* SimSettingsView::createOutputDiagnosticsWidget() {

auto gridLayout = new QGridLayout();
gridLayout->setContentsMargins(7, 7, 7, 7);
gridLayout->setSpacing(GRID_LAYOUT_SPACING);
gridLayout->setAlignment(Qt::AlignLeft);

int row = 0;
int col = 0;

addField(gridLayout, row, col, "Enable AllSummary Report", m_diagnostics_displayExtraWarnings);

auto widget = new QWidget();
widget->setLayout(gridLayout);
widget->hide();

return widget;
}

void SimSettingsView::addField(QGridLayout* gridLayout, int row, int column, QString text, OSComboBox2*& comboBox) {
auto label = new QLabel(text, this);
label->setFixedWidth(TEXT_FIELD_WIDTH);
Expand Down Expand Up @@ -1210,6 +1266,8 @@ void SimSettingsView::attachAll() {
attachZoneAirContaminantBalance();
attachZoneCapacitanceMultipleResearchSpecial();
attachOutputJSON();
attachOutputTableSummaryReports();
attachOutputDiagnostics();
}

void SimSettingsView::detachAll() {
Expand All @@ -1230,6 +1288,8 @@ void SimSettingsView::detachAll() {
detachZoneCapacitanceMultipleResearchSpecial();
detachRadianceParameters();
detachOutputJSON();
detachOutputTableSummaryReports();
detachOutputDiagnostics();
}

void SimSettingsView::attachRunPeriod() {
Expand Down Expand Up @@ -1808,6 +1868,86 @@ void SimSettingsView::attachOutputJSON() {
);
}

void SimSettingsView::attachOutputTableSummaryReports() {
bool forceAllSummary = false;
// If it wasn't already in the model, it'll be initialized, and the Ctor defaults it to no fields, while the FT will add AllSummary if not present
// in the model, so to maintain behavior, we add the AllSummary report if needed
if (!m_model.outputTableSummaryReports()) {
forceAllSummary = true;
}

model::OutputTableSummaryReports mo = m_model.getUniqueModelObject<model::OutputTableSummaryReports>();
if (forceAllSummary) {
mo.enableAllSummaryReport();
}

// typedef std::function<bool()> BoolGetter
std::function<bool()> getter = [&mo]() {
if (mo.summaryReportIndex("AllSummary")) {
return true;
} else {
return false;
}
};

// void bind(const model::ModelObject& modelObject, BoolGetter get, boost::optional<BoolSetter> set = boost::none,
// boost::optional<NoFailAction> reset = boost::none, boost::optional<BasicQuery> isDefaulted = boost::none);


// typedef std::function<void(bool)> BoolSetter;
std::function<void(bool)> setter = [&mo](bool value) {
if (value) {
mo.enableAllSummaryReport();
} else if (boost::optional<unsigned> index = mo.summaryReportIndex("AllSummary")) {
mo.removeSummaryReport(index.get());
}
};

m_table_allSummary->bind(mo, getter, setter,
boost::none, // reset
boost::none // isDefaulted;
);
}

void SimSettingsView::attachOutputDiagnostics() {

model::OutputDiagnostics mo = m_model.getUniqueModelObject<model::OutputDiagnostics>();

// typedef std::function<bool()> BoolGetter
std::function<bool()> getter = [&mo]() {
auto ks = mo.keys();
return std::find_if(ks.begin(), ks.end(),
[](const std::string& k) {
return openstudio::istringEqual(k, "DisplayExtraWarnings");
}
) != ks.end();
};

// void bind(const model::ModelObject& modelObject, BoolGetter get, boost::optional<BoolSetter> set = boost::none,
// boost::optional<NoFailAction> reset = boost::none, boost::optional<BasicQuery> isDefaulted = boost::none);


// typedef std::function<void(bool)> BoolSetter;
std::function<void(bool)> setter = [&mo](bool value) {
if (value) {
mo.enableDisplayExtraWarnings();
} else {
auto ks = mo.keys();
ks.erase(std::remove_if(ks.begin(), ks.end(),
[](const std::string& k) {
return openstudio::istringEqual(k, "DisplayExtraWarnings");
}),
ks.end());
mo.setKeys(ks);
}
};

m_diagnostics_displayExtraWarnings->bind(mo, getter, setter,
boost::none, // reset
boost::none // isDefaulted;
);
}

void SimSettingsView::detachRunPeriod() {
m_useWeatherFileHolidaysandSpecialDays->unbind();
m_useWeatherFileDaylightSavingsPeriod->unbind();
Expand Down Expand Up @@ -1931,6 +2071,14 @@ void SimSettingsView::detachOutputJSON() {
m_json_outputMessagePack->unbind();
}

void SimSettingsView::detachOutputTableSummaryReports() {
m_table_allSummary->unbind();
}

void SimSettingsView::detachOutputDiagnostics() {
m_diagnostics_displayExtraWarnings->unbind();
}

//***** SLOTS *****

void SimSettingsView::on_runPeriodGroupClicked(int idx) {
Expand Down
11 changes: 11 additions & 0 deletions src/openstudio_lib/SimSettingsView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class SimSettingsView : public QWidget, public Nano::Observer
QWidget* createZoneCapacitanceMultipleResearchSpecialWidget();
QWidget* createRadianceParametersWidget();
QWidget* createOutputJSONWidget();
QWidget* createOutputTableSummaryReportsWidget();
QWidget* createOutputDiagnosticsWidget();

void addField(QGridLayout* gridLayout, int row, int column, QString text, OSComboBox2*& comboBox);

Expand Down Expand Up @@ -126,6 +128,8 @@ class SimSettingsView : public QWidget, public Nano::Observer
void attachZoneCapacitanceMultipleResearchSpecial();
void attachRadianceParameters();
void attachOutputJSON();
void attachOutputTableSummaryReports();
void attachOutputDiagnostics();

void detachAll();
void detachRunPeriod();
Expand All @@ -145,6 +149,8 @@ class SimSettingsView : public QWidget, public Nano::Observer
void detachZoneCapacitanceMultipleResearchSpecial();
void detachRadianceParameters();
void detachOutputJSON();
void detachOutputTableSummaryReports();
void detachOutputDiagnostics();

model::Model m_model;
boost::optional<model::ShadowCalculation> m_shadowCalculation;
Expand Down Expand Up @@ -279,6 +285,11 @@ class SimSettingsView : public QWidget, public Nano::Observer
OSSwitch2* m_json_outputCBOR;
OSSwitch2* m_json_outputMessagePack;

// Advanced Output
// These are extensible groups in the SDK, but we care only about common settings
OSSwitch2* m_table_allSummary;
OSSwitch2* m_diagnostics_displayExtraWarnings;

signals:

void toggleUnitsClicked(bool displayIP);
Expand Down

0 comments on commit 695f279

Please sign in to comment.