Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #5116 - Annoying FT warnings for always XX Scheduled missing the schedule type limits object #5117

Merged
merged 2 commits into from
Mar 25, 2024

Conversation

jmarrec
Copy link
Collaborator

@jmarrec jmarrec commented Mar 19, 2024

Pull request overview

Pull Request Author

  • Model API Changes / Additions
  • Any new or modified fields have been implemented in the EnergyPlus ForwardTranslator (and ReverseTranslator as appropriate)
  • Model API methods are tested (in src/model/test)
  • EnergyPlus ForwardTranslator Tests (in src/energyplus/Test)
  • If a new object or method, added a test in NREL/OpenStudio-resources: Add Link
  • If needed, added VersionTranslation rules for the objects (src/osversion/VersionTranslator.cpp)
  • Verified that C# bindings built fine on Windows, partial classes used as needed, etc.
  • All new and existing tests passes
  • If methods have been deprecated, update rest of code to use the new methods

Labels:

  • If change to an IDD file, add the label IDDChange
  • If breaking existing API, add the label APIChange
  • If deemed ready, add label Pull Request - Ready for CI so that CI builds your PR

Review Checklist

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • Code Style, strip trailing whitespace, etc.
  • All related changes have been implemented: model changes, model tests, FT changes, FT tests, VersionTranslation, OS App
  • Labeling is ok
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified

```
$ Products/openstudio_energyplus_tests -- --gtest_filter=*NoUselessWarnings*
Running main() from /home/conan/w/BuildSingleReference/.conan/data/gtest/1.11.0/_/_/build/e019a06362b932ca5d1b082b6c112aa150c88de4/source_subfolder/googletest/src/gtest_main.cc
Note: Google Test filter = *NoUselessWarnings*
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from EnergyPlusFixture
[ RUN      ] EnergyPlusFixture.NoUselessWarnings
/home/julien/Software/Others/OpenStudio/src/energyplus/Test/ForwardTranslator_GTest.cpp:987: Failure
Expected equality of these values:
  0
  logMessages.size()
    Which is: 3
Expected no messages logged, got: ["Object of type 'Schedule:Constant' and named 'Always On Discrete', points to an object named OnOff from field 1, but that object cannot be located.", "Object of type 'Schedule:Constant' and named 'Always Off Discrete', points to an object named OnOff 1 from field 1, but that object cannot be located.", "Object of type 'Schedule:Constant' and named 'Always On Continuous', points to an object named Fractional from field 1, but that object cannot be located."]
[  FAILED  ] EnergyPlusFixture.NoUselessWarnings (16 ms)
[----------] 1 test from EnergyPlusFixture (16 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (16 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] EnergyPlusFixture.NoUselessWarnings
```
@jmarrec jmarrec added severity - Normal Bug component - IDF Translation Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. labels Mar 19, 2024
@jmarrec jmarrec self-assigned this Mar 19, 2024
Comment on lines +968 to +988
TEST_F(EnergyPlusFixture, NoUselessWarnings) {
// Test for #5116
Model m;
auto yd = m.getUniqueModelObject<model::YearDescription>();
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<openstudio::LogMessage> logMessages = sink.logMessages();

std::vector<std::string> 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);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New test.

Before fix:

$ Products/openstudio_energyplus_tests -- --gtest_filter=*NoUselessWarnings*
Running main() from /home/conan/w/BuildSingleReference/.conan/data/gtest/1.11.0/_/_/build/e019a06362b932ca5d1b082b6c112aa150c88de4/source_subfolder/googletest/src/gtest_main.cc
Note: Google Test filter = *NoUselessWarnings*
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from EnergyPlusFixture
[ RUN      ] EnergyPlusFixture.NoUselessWarnings
/home/julien/Software/Others/OpenStudio/src/energyplus/Test/ForwardTranslator_GTest.cpp:987: Failure
Expected equality of these values:
  0
  logMessages.size()
    Which is: 3
Expected no messages logged, got: ["Object of type 'Schedule:Constant' and named 'Always On Discrete', points to an object named OnOff from field 1, but that object cannot be located.", "Object of type 'Schedule:Constant' and named 'Always Off Discrete', points to an object named OnOff 1 from field 1, but that object cannot be located.", "Object of type 'Schedule:Constant' and named 'Always On Continuous', points to an object named Fractional from field 1, but that object cannot be located."]
[  FAILED  ] EnergyPlusFixture.NoUselessWarnings (16 ms)
[----------] 1 test from EnergyPlusFixture (16 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (16 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] EnergyPlusFixture.NoUselessWarnings

Comment on lines +3675 to +3683
// Make sure these get in the idf file
{
auto schedule = model.alwaysOnDiscreteSchedule();
translateAndMapModelObject(schedule);
schedule = model.alwaysOffDiscreteSchedule();
translateAndMapModelObject(schedule);
schedule = model.alwaysOnContinuousSchedule();
translateAndMapModelObject(schedule);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just reordering things a bit.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reordering is the fix?

Copy link
Collaborator Author

@jmarrec jmarrec Mar 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep. auto schedule = model.alwaysOnDiscreteSchedule(); => this creates a schedule BUT also a ScheduleTypeLimits, if it wasn't instantiated already.

I put it above and not below the loop to translate all ScheduleTypeLimits.

Translating a scheduleconstant does not trigger translate of the ScheduleTypeLimits attached to it.

@jmarrec jmarrec merged commit f916fc1 into develop Mar 25, 2024
4 of 6 checks passed
@jmarrec jmarrec deleted the 5116_useless_warnings_FT branch March 25, 2024 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component - IDF Translation Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. severity - Normal Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Annoying FT warnings for always XX Scheduled missing the schedule type limits object
3 participants