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

Add AirLoopHVAC to ThreeJS user data #4407

Merged

Conversation

antoine-galataud
Copy link
Contributor

Pull request overview

First step in implementation of openstudiocoalition/OpenStudioApplication#413

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

@tijcolem
Copy link
Collaborator

Hi @antoine-galataud! Thank you for your contribution! This looks great. Before we can officially accept and merge would you mind reviewing our code contribution policy (https://www.openstudio.net/openstudio-contribution-policy) and then send me a consent email (my contact info is at the bottom). This is only a one time thing so any future contributions won't need this. =)

@tijcolem tijcolem added component - Utilities Geometry Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. labels Aug 30, 2021
@antoine-galataud
Copy link
Contributor Author

Builds failed but I can't access the CI tool (times out on every attempt). Is there an other convenient way to obtain build results?

@tijcolem
Copy link
Collaborator

@antoine-galataud I just emailed you concerning build logs.

This is the snippet of the error message for osx-incremental

/Users/jenkins/git/OpenStudioIncremental/develop/src/utilities/geometry/Test/ThreeJS_GTest.cpp:56:30: error: loop variable 'sceneChild' of type 'const openstudio::ThreeSceneChild' creates a copy from type 'const openstudio::ThreeSceneChild' [-Werror,-Wrange-loop-analysis]

  for (const ThreeSceneChild sceneChild : sceneChildren) {

                             ^

/Users/jenkins/git/OpenStudioIncremental/develop/src/utilities/geometry/Test/ThreeJS_GTest.cpp:56:8: note: use reference type 'const openstudio::ThreeSceneChild &' to prevent copying

  for (const ThreeSceneChild sceneChild : sceneChildren) {

       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                             &

/Users/jenkins/git/OpenStudioIncremental/develop/src/utilities/geometry/Test/ThreeJS_GTest.cpp:62:39: error: loop variable 'metadata' of type 'const openstudio::ThreeModelObjectMetadata' creates a copy from type 'const openstudio::ThreeModelObjectMetadata' [-Werror,-Wrange-loop-analysis]

  for (const ThreeModelObjectMetadata metadata : scene->metadata().modelObjectMetadata()) {

                                      ^

/Users/jenkins/git/OpenStudioIncremental/develop/src/utilities/geometry/Test/ThreeJS_GTest.cpp:62:8: note: use reference type 'const openstudio::ThreeModelObjectMetadata &' to prevent copying

  for (const ThreeModelObjectMetadata metadata : scene->metadata().modelObjectMetadata()) {

       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                                      &

2 errors generated.

make[2]: *** [src/utilities/CMakeFiles/openstudio_utilities_tests.dir/geometry/Test/ThreeJS_GTest.cpp.o] Error 1

make[2]: *** Waiting for unfinished jobs....

[ 23%] Building CXX object src/model/CMakeFiles/openstudio_model_tests.dir/test/ThreeJSReverseTranslator_GTest.cpp.o

make[1]: *** [src/utilities/CMakeFiles/openstudio_utilities_tests.dir/all] Error 2

make[1]: *** Waiting for unfinished jobs....

Consolidate compiler generated dependencies of target openstudio_radiance_tests

@jmarrec
Copy link
Collaborator

jmarrec commented Sep 1, 2021

@tijcolem I already added review suggest for these unecessary copies, but I forgot to post my review.. so it was only visible on /files

Edit:: I apply these two sugestions

src/utilities/geometry/Test/ThreeJS_GTest.cpp Outdated Show resolved Hide resolved
src/utilities/geometry/Test/ThreeJS_GTest.cpp Outdated Show resolved Hide resolved
Comment on lines 61 to 65
bool alhvac_metadata_found = false;
for (const ThreeModelObjectMetadata metadata : scene->metadata().modelObjectMetadata()) {
alhvac_metadata_found |= istringEqual("OS:AirLoopHVAC", metadata.iddObjectType()) && istringEqual("Air Loop HVAC 1", metadata.name());
}
ASSERT_TRUE(alhvac_metadata_found);
Copy link
Collaborator

@jmarrec jmarrec Aug 25, 2021

Choose a reason for hiding this comment

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

Suggested change
bool alhvac_metadata_found = false;
for (const ThreeModelObjectMetadata metadata : scene->metadata().modelObjectMetadata()) {
alhvac_metadata_found |= istringEqual("OS:AirLoopHVAC", metadata.iddObjectType()) && istringEqual("Air Loop HVAC 1", metadata.name());
}
ASSERT_TRUE(alhvac_metadata_found);
std::vector<ThreeModelObjectMetadata> metadatas = scene->metadata().modelObjectMetadata();
EXPECT_TRUE(std::any_of(metadatas.cbegin(), metadatas.cend(), [](const auto& metadata) {
return istringEqual("OS:AirLoopHVAC", metadata.iddObjectType()) && istringEqual("Air Loop HVAC 1", metadata.name();
})
);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice construct, although makes it a bit harder to read IMHO. But my C++ skills are a bit rusted ;)

@jmarrec
Copy link
Collaborator

jmarrec commented Sep 1, 2021

osx has a failing test but that's irrelevant here

[ RUN      ] BCLFixture.BCLComponent

/Users/jenkins/git/OpenStudioIncremental/develop/src/utilities/bcl/test/BCLComponent_GTest.cpp:44: Failure

Expected equality of these values:

  "philadelphia pa [724086 TMY2-13739]"

  component.name()

    Which is: ""

@tijcolem
Copy link
Collaborator

tijcolem commented Sep 1, 2021

cool, yep that failing test is unrelated to this PR. Need to check on windows but Linux and Mac seems happy now.

@antoine-galataud
Copy link
Contributor Author

Thanks @tijcolem and @jmarrec for reviewing and fixing.

// checking user data
std::vector<ThreeSceneChild> sceneChildren = scene->object().children();
for (const ThreeSceneChild& sceneChild : sceneChildren) {
EXPECT_DOUBLE_EQ(1, sceneChild.userData().airLoopHVACNames().size());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we change to EXPECT_DOUBLE_EQ(1, double(sceneChild.userData().airLoopHVACNames().size()));

windows is throwing the following due to treating warning as error when compiling.

D:\jenkins\openstudio\develop\src\utilities\geometry\Test\ThreeJS_GTest.cpp(57,5): error C2220: the following warning is treated as an error [D:\jenkins\openstudio\develop\build\src\utilities\openstudio_utilities_tests.vcxproj]
D:\jenkins\openstudio\develop\src\utilities\geometry\Test\ThreeJS_GTest.cpp(57,5): warning C4244: 'argument': conversion from 'unsigned __int64' to 'RawType', possible loss of data [D:\jenkins\openstudio\develop\build\src\utilities\openstudio_utilities_tests.vcxproj]

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nah, you want EXPECT_EQ(1, xxx.size()); (or EXPECT_EQ(1u, xxx.size()); )

Copy link
Collaborator

Choose a reason for hiding this comment

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

Even better!

Copy link
Collaborator

@tijcolem tijcolem left a comment

Choose a reason for hiding this comment

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

Thanks @antoine-galataud for making those changes. I looked CI and Ubuntu 20.04 and osx are unrelated so this looks good to drop in!

@tijcolem tijcolem merged commit b29bc47 into NREL:develop Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component - Utilities Geometry Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants