-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix #4404 #4453 - Fix issues with ForwardTranslator options #4454
Conversation
fdbb166
to
fbf771c
Compare
e76ab8a
to
1dff48b
Compare
// If the user manually added an OutputTableSummaryReports, but he also opted-in to exclude it on the FT, which decision do we keep? | ||
// Given that it's a much harder to set the option on the FT, I'll respect that one | ||
if (!m_excludeHTMLOutputReport) { | ||
auto optOutputTableSummaryReports = model.getOptionalUniqueModelObject<model::OutputTableSummaryReports>(); | ||
// Add default one if none explicitly specified | ||
if (!optOutputTableSummaryReports) { | ||
auto outputTableSummaryReports = model.getUniqueModelObject<model::OutputTableSummaryReports>(); | ||
outputTableSummaryReports.addSummaryReport("AllSummary"); | ||
translateAndMapModelObject(outputTableSummaryReports); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix #4453
if (!m_excludeLCCObjects) { | ||
bool hasAtLeastOneCost = std::any_of(m_idfObjects.cbegin(), m_idfObjects.cend(), [](const auto& obj) { | ||
auto iddObjType = obj.iddObject().type(); | ||
return (iddObjType == openstudio::IddObjectType::LifeCycleCost_NonrecurringCost) | ||
|| (iddObjType == openstudio::IddObjectType::LifeCycleCost_RecurringCosts); | ||
}); | ||
|
||
if (!hasAtLeastOneCost) { | ||
// add default cost | ||
auto& idfObject = m_idfObjects.emplace_back(openstudio::IddObjectType::LifeCycleCost_NonrecurringCost); | ||
idfObject.setString(LifeCycleCost_NonrecurringCostFields::Name, "Default Cost"); | ||
idfObject.setString(LifeCycleCost_NonrecurringCostFields::Category, "Construction"); | ||
idfObject.setDouble(LifeCycleCost_NonrecurringCostFields::Cost, 0.0); | ||
idfObject.setString(LifeCycleCost_NonrecurringCostFields::StartofCosts, "ServicePeriod"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix #4404 + use std::any_of instead of looping on all objects (and not even breaking as soon as one is found).
Also use emplace_back to construct in place for performance reasons
EXPECT_EQ("HTML", obj.getString(0).get()); | ||
EXPECT_EQ("None", obj.getString(1, true).get()); // Return default | ||
EXPECT_FALSE(obj.getString(1, false, true)); // not initialized | ||
} | ||
|
||
ft.setExcludeLCCObjects(true); | ||
{ | ||
Workspace w = ft.translateModel(m); | ||
|
||
EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_Parameters)); | ||
EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_UsePriceEscalation)); | ||
EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_NonrecurringCost)); | ||
|
||
EXPECT_EQ(1u, w.numObjectsOfType(IddObjectType::Output_VariableDictionary)); | ||
EXPECT_EQ(1u, w.numObjectsOfType(IddObjectType::Output_SQLite)); | ||
EXPECT_EQ(1u, w.numObjectsOfType(IddObjectType::Output_Table_SummaryReports)); | ||
|
||
auto objs = w.getObjectsByType(IddObjectType::OutputControl_Table_Style); | ||
ASSERT_EQ(1, objs.size()); | ||
auto obj = objs[0]; | ||
EXPECT_EQ("HTML", obj.getString(0).get()); | ||
EXPECT_EQ("None", obj.getString(1, true).get()); // Return default | ||
EXPECT_FALSE(obj.getString(1, false, true)); // not initialized | ||
} | ||
|
||
ft.setExcludeVariableDictionary(true); | ||
{ | ||
Workspace w = ft.translateModel(m); | ||
|
||
EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_Parameters)); | ||
EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_UsePriceEscalation)); | ||
EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_NonrecurringCost)); | ||
|
||
EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::Output_VariableDictionary)); | ||
EXPECT_EQ(1u, w.numObjectsOfType(IddObjectType::Output_SQLite)); | ||
EXPECT_EQ(1u, w.numObjectsOfType(IddObjectType::Output_Table_SummaryReports)); | ||
|
||
auto objs = w.getObjectsByType(IddObjectType::OutputControl_Table_Style); | ||
ASSERT_EQ(1, objs.size()); | ||
auto obj = objs[0]; | ||
EXPECT_EQ("HTML", obj.getString(0).get()); | ||
EXPECT_EQ("None", obj.getString(1, true).get()); // Return default | ||
EXPECT_FALSE(obj.getString(1, false, true)); // not initialized | ||
} | ||
|
||
ft.setExcludeSQliteOutputReport(true); | ||
{ | ||
Workspace w = ft.translateModel(m); | ||
|
||
EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_Parameters)); | ||
EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_UsePriceEscalation)); | ||
EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_NonrecurringCost)); | ||
|
||
EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::Output_VariableDictionary)); | ||
EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::Output_SQLite)); | ||
EXPECT_EQ(1u, w.numObjectsOfType(IddObjectType::Output_Table_SummaryReports)); | ||
|
||
auto objs = w.getObjectsByType(IddObjectType::OutputControl_Table_Style); | ||
ASSERT_EQ(1, objs.size()); | ||
auto obj = objs[0]; | ||
EXPECT_EQ("HTML", obj.getString(0).get()); | ||
EXPECT_EQ("None", obj.getString(1, true).get()); // Return default | ||
EXPECT_FALSE(obj.getString(1, false, true)); // not initialized | ||
} | ||
|
||
ft.setIPTabularOutput(true); | ||
{ | ||
Workspace w = ft.translateModel(m); | ||
|
||
EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_Parameters)); | ||
EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_UsePriceEscalation)); | ||
EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_NonrecurringCost)); | ||
|
||
EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::Output_VariableDictionary)); | ||
EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::Output_SQLite)); | ||
EXPECT_EQ(1u, w.numObjectsOfType(IddObjectType::Output_Table_SummaryReports)); | ||
|
||
auto objs = w.getObjectsByType(IddObjectType::OutputControl_Table_Style); | ||
ASSERT_EQ(1, objs.size()); | ||
auto obj = objs[0]; | ||
EXPECT_EQ("HTML", obj.getString(0).get()); | ||
EXPECT_EQ("InchPound", obj.getString(1, false, true).get()); | ||
} | ||
|
||
ft.setExcludeHTMLOutputReport(true); | ||
{ | ||
Workspace w = ft.translateModel(m); | ||
|
||
EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_Parameters)); | ||
EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_UsePriceEscalation)); | ||
EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_RecurringCosts)); | ||
|
||
EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::Output_VariableDictionary)); | ||
EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::Output_SQLite)); | ||
EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::Output_Table_SummaryReports)); | ||
|
||
// This also turns off the OutputControl:Table:Style | ||
EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::OutputControl_Table_Style)); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a unit test for all options
CI Results for 1dff48b:
|
I'd be happy to test this but I don't see any Ubuntu or Windows builds above? |
@shorowit installers are up now |
Verified that this fixes the issue for me. Thanks, @jmarrec! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
I added a unit test for all options. #4404 is confirmed, but I also found out that Output:Table:SummaryReports was problematic also.
Pull Request Author
src/model/test
)src/energyplus/Test
)src/osversion/VersionTranslator.cpp
)Labels:
IDDChange
APIChange
Pull Request - Ready for CI
so that CI builds your PRReview Checklist
This will not be exhaustively relevant to every PR.