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 #3314 - GBXML translate spaces etc even if Facility and/or Building aren't instantiated #4000

Merged
merged 4 commits into from Jun 18, 2020

Conversation

jmarrec
Copy link
Collaborator

@jmarrec jmarrec commented Jun 18, 2020

Pull request overview

Also fix a ReverseTranslator issue that I found where the Material Roughness ends up empty.

Pull Request Author

Add to this list or remove from it as applicable. This is a simple templated set of guidelines.

  • 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)
  • Checked behavior in OpenStudioApplication, adjusted policies as needed (src/openstudio_lib/library/OpenStudioPolicy.xml)
  • 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

@jmarrec jmarrec added severity - Normal Bug component - gbXML Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. labels Jun 18, 2020
@jmarrec jmarrec self-assigned this Jun 18, 2020
Comment on lines +96 to +99
// Facility and Building could not be explicitly instantiated in the model, but the functions still need to be called so that Spaces and surfaces
// are translated. Facility and Building both are UniqueModelObjects, so passing model here as an argument is harmless
boost::optional<pugi::xml_node> translateFacility(const openstudio::model::Model& model, pugi::xml_node& parent);
boost::optional<pugi::xml_node> translateBuilding(const openstudio::model::Model& model, pugi::xml_node& parent);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Private methods now take model instead of facility / building. And in there it will conditionally check if there is a facility / building to use or default things.

Comment on lines +417 to +428
// `model` is `const`, so we shouldn't call getUniqueModelObject<model::Facility> which will **create** a new object in there.
boost::optional<model::Facility> _facility = model.getOptionalUniqueModelObject<model::Facility>();

auto result = parent.append_child("Campus");
m_translatedObjects[facility.handle()] = result;
std::string name = "Facility";

boost::optional<std::string> name = facility.name();
if (_facility) {
m_translatedObjects[_facility->handle()] = result;
if (auto _s = _facility->name()) {
name = _s.get();
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Check if there is an actual explicitly instantiated Facility object to use, otherwise default things.


// translate surfaces
// TODO: JM 2020-06-18 Why is translateSpace not responsible to call this one?
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I find it strange that the Surfaces are translated in translateFacility

@jmarrec jmarrec changed the title Fix #3314 - GBXML translate spaces etc even if Facility and/or Building aren't isntantianted Fix #3314 - GBXML translate spaces etc even if Facility and/or Building aren't instantiated Jun 18, 2020
@jmarrec jmarrec requested a review from tijcolem June 18, 2020 13:39
@tijcolem tijcolem merged commit ade3112 into develop Jun 18, 2020
@tijcolem tijcolem deleted the 3314_gbXML_Facility branch June 18, 2020 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component - gbXML 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.

gbXML translation does not roundtrip unless Facility object present
2 participants