src/energyplus/ReverseTranslator/ReverseTranslateSurfacePropertyGroundSurfaces.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************************************************** | ||
| 2 | * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. | ||
| 3 | * See also https://openstudio.net/license | ||
| 4 | ***********************************************************************************************************************/ | ||
| 5 | |||
| 6 | #include "../ReverseTranslator.hpp" | ||
| 7 | |||
| 8 | #include "../../model/SurfacePropertyGroundSurfaces.hpp" | ||
| 9 | #include "../../model/Schedule.hpp" | ||
| 10 | #include "../../model/Schedule_Impl.hpp" | ||
| 11 | |||
| 12 | #include "../../utilities/idf/IdfExtensibleGroup.hpp" | ||
| 13 | #include "../../utilities/idf/WorkspaceExtensibleGroup.hpp" | ||
| 14 | |||
| 15 | #include <utilities/idd/SurfaceProperty_GroundSurfaces_FieldEnums.hxx> | ||
| 16 | #include <utilities/idd/IddEnums.hxx> | ||
| 17 | |||
| 18 | using namespace openstudio::model; | ||
| 19 | |||
| 20 | namespace openstudio { | ||
| 21 | |||
| 22 | namespace energyplus { | ||
| 23 | |||
| 24 | 1 | boost::optional<ModelObject> ReverseTranslator::translateSurfacePropertyGroundSurfaces(const WorkspaceObject& workspaceObject) { | |
| 25 | |||
| 26 | // Instantiate an object of the class to store the values, | ||
| 27 |
1/1✓ Branch 1 taken 1 time.
|
1 | openstudio::model::SurfacePropertyGroundSurfaces modelObject(m_model); |
| 28 | |||
| 29 | // Name | ||
| 30 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
|
2 | if (boost::optional<std::string> _name = workspaceObject.name()) { |
| 31 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | modelObject.setName(_name.get()); |
| 32 | 1 | } | |
| 33 | |||
| 34 | // Extensible groups | ||
| 35 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 1 time.
|
6 | for (const IdfExtensibleGroup& eg : workspaceObject.extensibleGroups()) { |
| 36 |
1/1✓ Branch 1 taken 5 times.
|
5 | auto weg = eg.cast<WorkspaceExtensibleGroup>(); |
| 37 | |||
| 38 |
3/3✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
|
5 | auto groundSurfaceName = weg.getString(SurfaceProperty_GroundSurfacesExtensibleFields::GroundSurfaceName).get(); |
| 39 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
|
5 | if (groundSurfaceName.empty()) { |
| 40 | ✗ | LOG(Warn, "Extensible group " << eg.groupIndex() << "(0-indexed) has an empty Ground Surface Name field, skipping group"); | |
| 41 | ✗ | continue; | |
| 42 | ✗ | } | |
| 43 | |||
| 44 | // This has a default of 0, so roll with it | ||
| 45 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
|
5 | auto viewFactor = weg.getDouble(SurfaceProperty_GroundSurfacesExtensibleFields::GroundSurfaceViewFactor).get(); |
| 46 | |||
| 47 | 5 | boost::optional<Schedule> tempSch_; | |
| 48 | 5 | boost::optional<Schedule> refSch_; | |
| 49 | |||
| 50 |
3/3✓ Branch 1 taken 5 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 3 times.
|
10 | if (auto wo_ = weg.getTarget(SurfaceProperty_GroundSurfacesExtensibleFields::GroundSurfaceTemperatureScheduleName)) { |
| 51 |
3/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
|
4 | if (auto mo_ = translateAndMapWorkspaceObject(wo_.get())) { |
| 52 |
3/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
|
4 | if (boost::optional<Schedule> sch_ = mo_->optionalCast<Schedule>()) { |
| 53 |
1/1✓ Branch 1 taken 2 times.
|
2 | tempSch_ = sch_; |
| 54 | } else { | ||
| 55 | ✗ | LOG(Warn, "Extensible group " << eg.groupIndex() << "(0-indexed) has a wrong type for Temperature Schedule, expected Schedule, got " | |
| 56 | << tempSch_->briefDescription()); | ||
| 57 | 2 | } | |
| 58 | } else { | ||
| 59 | ✗ | LOG(Warn, "Could not translate Temperature Schedule for Extensible group " << eg.groupIndex()); | |
| 60 | 2 | } | |
| 61 | 5 | } | |
| 62 | |||
| 63 |
3/3✓ Branch 1 taken 5 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 2 times.
|
10 | if (auto wo_ = weg.getTarget(SurfaceProperty_GroundSurfacesExtensibleFields::GroundSurfaceReflectanceScheduleName)) { |
| 64 |
3/4✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
|
6 | if (auto mo_ = translateAndMapWorkspaceObject(wo_.get())) { |
| 65 |
3/4✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
|
6 | if (boost::optional<Schedule> sch_ = mo_->optionalCast<Schedule>()) { |
| 66 |
1/1✓ Branch 1 taken 3 times.
|
3 | refSch_ = sch_; |
| 67 | } else { | ||
| 68 | ✗ | LOG(Warn, "Extensible group " << eg.groupIndex() << "(0-indexed) has a wrong type for Reflectance Schedule, expected Schedule, got " | |
| 69 | << tempSch_->briefDescription()); | ||
| 70 | 3 | } | |
| 71 | } else { | ||
| 72 | ✗ | LOG(Warn, "Could not translate Reflectance Schedule for Extensible group " << eg.groupIndex()); | |
| 73 | 3 | } | |
| 74 | 5 | } | |
| 75 | |||
| 76 |
3/3✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
|
5 | modelObject.addGroundSurfaceGroup(groundSurfaceName, viewFactor, tempSch_, refSch_); |
| 77 | 6 | } | |
| 78 | |||
| 79 |
1/1✓ Branch 1 taken 1 time.
|
2 | return modelObject; |
| 80 | 1 | } // End of translate function | |
| 81 | |||
| 82 | } // end namespace energyplus | ||
| 83 | } // end namespace openstudio | ||
| 84 |