diff --git a/src/energyplus/ForwardTranslator.cpp b/src/energyplus/ForwardTranslator.cpp index 68816a177f4..31393f4b260 100644 --- a/src/energyplus/ForwardTranslator.cpp +++ b/src/energyplus/ForwardTranslator.cpp @@ -3672,6 +3672,16 @@ namespace energyplus { void ForwardTranslator::translateSchedules(const model::Model& model) { + // Make sure these get in the idf file + { + auto schedule = model.alwaysOnDiscreteSchedule(); + translateAndMapModelObject(schedule); + schedule = model.alwaysOffDiscreteSchedule(); + translateAndMapModelObject(schedule); + schedule = model.alwaysOnContinuousSchedule(); + translateAndMapModelObject(schedule); + } + // loop over schedule type limits std::vector objects = model.getObjectsByType(IddObjectType::OS_ScheduleTypeLimits); std::sort(objects.begin(), objects.end(), WorkspaceObjectNameLess()); @@ -3698,16 +3708,6 @@ namespace energyplus { translateAndMapModelObject(modelObject); } } - - // Make sure these get in the idf file - { - auto schedule = model.alwaysOnDiscreteSchedule(); - translateAndMapModelObject(schedule); - schedule = model.alwaysOffDiscreteSchedule(); - translateAndMapModelObject(schedule); - schedule = model.alwaysOnContinuousSchedule(); - translateAndMapModelObject(schedule); - } } void ForwardTranslator::translateAirflowNetwork(const model::Model& model) { diff --git a/src/energyplus/Test/ForwardTranslator_GTest.cpp b/src/energyplus/Test/ForwardTranslator_GTest.cpp index 616debb083a..ba1621c4c04 100644 --- a/src/energyplus/Test/ForwardTranslator_GTest.cpp +++ b/src/energyplus/Test/ForwardTranslator_GTest.cpp @@ -44,6 +44,8 @@ #include "../../model/OutputVariable_Impl.hpp" #include "../../model/Version.hpp" #include "../../model/Version_Impl.hpp" +#include "../../model/YearDescription.hpp" +#include "../../model/YearDescription_Impl.hpp" #include "../../model/ZoneCapacitanceMultiplierResearchSpecial.hpp" #include "../../model/ZoneCapacitanceMultiplierResearchSpecial_Impl.hpp" @@ -64,14 +66,15 @@ #include -#include - #include +#include #include - #include +#include +#include + using namespace openstudio::energyplus; using namespace openstudio::model; using namespace openstudio; @@ -557,8 +560,8 @@ TEST_F(EnergyPlusFixture,ForwardTranslatorTest_AllObjects) { } */ -/* This test fails because objects of the same type share state across the Logger -See detailed notes below. This test is disabled and commented out. +/* This test fails because objects of the same type share state across the Logger +See detailed notes below. This test is disabled and commented out. TEST_F(EnergyPlusFixture, ForwardTranslatorTest_MultipleTranslatorsInScope) { Model model; Space space(model); // not in thermal zone will generate a warning @@ -632,8 +635,8 @@ class ForwardTranslatorThread std::future future; }; -/* ForwardTranslatorTest_MultiThreadedLogMessages is disabled. -See notes below for reasons why this tests fails due to race conditions. +/* ForwardTranslatorTest_MultiThreadedLogMessages is disabled. +See notes below for reasons why this tests fails due to race conditions. TEST_F(EnergyPlusFixture, ForwardTranslatorTest_MultiThreadedLogMessages) { // Logger::instance().standardOutLogger().enable(); @@ -961,3 +964,25 @@ TEST_F(EnergyPlusFixture, Ensure_Name_Unicity_ZoneAndZoneListAndSpaceAndSpaceLis EXPECT_NE(wos[i1].nameString(), wos[i2].nameString()); } } + +TEST_F(EnergyPlusFixture, NoUselessWarnings) { + // Test for #5116 + Model m; + auto yd = m.getUniqueModelObject(); + EXPECT_TRUE(yd.setDayofWeekforStartDay("Tuesday")); + + ForwardTranslator ft; + StringStreamLogSink sink; + sink.setLogLevel(Warn); + + Workspace w = ft.translateModel(m); + EXPECT_EQ(0u, ft.errors().size()); + EXPECT_EQ(0u, ft.warnings().size()); + + std::vector logMessages = sink.logMessages(); + + std::vector logStrings; + std::transform(logMessages.cbegin(), logMessages.cend(), std::back_inserter(logStrings), + [](const auto& logMessage) { return logMessage.logMessage(); }); + EXPECT_EQ(0, logMessages.size()) << fmt::format("Expected no messages logged, got: {}", logStrings); +}