src/energyplus/ReverseTranslator/ReverseTranslateShadingSiteDetailed.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 | #include "../GeometryTranslator.hpp" | ||
| 8 | |||
| 9 | #include "../../model/ShadingSurface.hpp" | ||
| 10 | #include "../../model/ShadingSurface_Impl.hpp" | ||
| 11 | #include "../../model/ShadingSurfaceGroup.hpp" | ||
| 12 | #include "../../model/ShadingSurfaceGroup_Impl.hpp" | ||
| 13 | #include "../../model/Schedule.hpp" | ||
| 14 | #include "../../model/Schedule_Impl.hpp" | ||
| 15 | |||
| 16 | #include <utilities/idd/Shading_Site_Detailed_FieldEnums.hxx> | ||
| 17 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 18 | #include <utilities/idd/IddEnums.hxx> | ||
| 19 | |||
| 20 | using namespace openstudio::model; | ||
| 21 | |||
| 22 | namespace openstudio { | ||
| 23 | |||
| 24 | namespace energyplus { | ||
| 25 | |||
| 26 | 11 | OptionalModelObject ReverseTranslator::translateShadingSiteDetailed(const WorkspaceObject& workspaceObject) { | |
| 27 |
4/5✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 11 times.
|
11 | if (workspaceObject.iddObject().type() != IddObjectType::Shading_Site_Detailed) { |
| 28 | ✗ | LOG(Error, "WorkspaceObject is not IddObjectType: Shading:Site:Detailed"); | |
| 29 | ✗ | return boost::none; | |
| 30 | } | ||
| 31 | |||
| 32 |
1/1✓ Branch 1 taken 11 times.
|
11 | openstudio::Point3dVector vertices = getVertices(Shading_Site_DetailedFields::NumberofVertices + 1, workspaceObject); |
| 33 | |||
| 34 | 11 | boost::optional<ShadingSurface> shadingSurface; | |
| 35 | try { | ||
| 36 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
11 | shadingSurface = ShadingSurface(vertices, m_model); |
| 37 | ✗ | } catch (const std::exception&) { | |
| 38 | ✗ | LOG(Error, "Cannot create ShadingSurface for object: " << workspaceObject); | |
| 39 | ✗ | return boost::none; | |
| 40 | ✗ | } | |
| 41 | |||
| 42 |
1/1✓ Branch 1 taken 11 times.
|
11 | OptionalString s = workspaceObject.name(); |
| 43 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | if (s) { |
| 44 |
3/3✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
|
11 | shadingSurface->setName(*s); |
| 45 | } | ||
| 46 | |||
| 47 | // look for first site level shading surface group | ||
| 48 | 11 | OptionalShadingSurfaceGroup shadingSurfaceGroup; | |
| 49 |
3/3✓ Branch 1 taken 11 times.
✓ Branch 8 taken 15 times.
✓ Branch 9 taken 6 times.
|
21 | for (const ShadingSurfaceGroup& group : m_model.getConcreteModelObjects<ShadingSurfaceGroup>()) { |
| 50 |
5/5✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
✓ Branch 11 taken 5 times.
✓ Branch 12 taken 10 times.
|
45 | if (istringEqual("Site", group.shadingSurfaceType())) { |
| 51 |
1/1✓ Branch 1 taken 5 times.
|
5 | shadingSurfaceGroup = group; |
| 52 | 5 | break; | |
| 53 | } | ||
| 54 | 11 | } | |
| 55 | |||
| 56 | // if not found make one | ||
| 57 |
2/2✓ Branch 1 taken 6 times.
✓ Branch 2 taken 5 times.
|
11 | if (!shadingSurfaceGroup) { |
| 58 |
2/2✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
|
6 | shadingSurfaceGroup = ShadingSurfaceGroup(m_model); |
| 59 |
3/3✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
|
18 | shadingSurfaceGroup->setShadingSurfaceType("Site"); |
| 60 | } | ||
| 61 | |||
| 62 |
3/3✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
|
11 | shadingSurface->setShadingSurfaceGroup(*shadingSurfaceGroup); |
| 63 | |||
| 64 |
1/1✓ Branch 1 taken 11 times.
|
11 | OptionalWorkspaceObject target = workspaceObject.getTarget(openstudio::Shading_Site_DetailedFields::TransmittanceScheduleName); |
| 65 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
|
11 | if (target) { |
| 66 | ✗ | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); | |
| 67 | ✗ | if (modelObject) { | |
| 68 | ✗ | if (OptionalSchedule intermediate = modelObject->optionalCast<Schedule>()) { | |
| 69 | ✗ | Schedule schedule(*intermediate); | |
| 70 | ✗ | shadingSurface->setTransmittanceSchedule(schedule); | |
| 71 | ✗ | } | |
| 72 | } | ||
| 73 | ✗ | } | |
| 74 | |||
| 75 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
11 | return shadingSurface.get(); |
| 76 | 11 | } | |
| 77 | |||
| 78 | } // namespace energyplus | ||
| 79 | |||
| 80 | } // namespace openstudio | ||
| 81 |