GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 70.6% 24 / 0 / 34
Functions: 100.0% 1 / 0 / 1
Branches: 40.0% 36 / 0 / 90

src/energyplus/ReverseTranslator/ReverseTranslateSurfacePropertyLocalEnvironment.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/SurfacePropertyLocalEnvironment.hpp"
9
10 #include "../../model/Surface.hpp"
11 #include "../../model/Surface_Impl.hpp"
12 #include "../../model/SubSurface.hpp"
13 #include "../../model/SubSurface_Impl.hpp"
14
15 #include "../../model/Schedule.hpp"
16 #include "../../model/Schedule_Impl.hpp"
17
18 #include "../../model/SurfacePropertySurroundingSurfaces.hpp"
19 #include "../../model/SurfacePropertySurroundingSurfaces_Impl.hpp"
20
21 // #include "../../model/OutdoorAirNode.hpp"
22 // #include "../../model/OutdoorAirNode_Impl.hpp"
23
24 #include <utilities/idd/SurfaceProperty_LocalEnvironment_FieldEnums.hxx>
25 #include <utilities/idd/IddEnums.hxx>
26
27 using namespace openstudio::model;
28
29 namespace openstudio {
30
31 namespace energyplus {
32
33 1 boost::optional<ModelObject> ReverseTranslator::translateSurfacePropertyLocalEnvironment(const WorkspaceObject& workspaceObject) {
34 1 boost::optional<WorkspaceObject> wo_;
35 1 boost::optional<ModelObject> mo_;
36
37 1 boost::optional<ModelObject> mo_planarSurface;
38
39 1 boost::optional<SurfacePropertyLocalEnvironment> localEnv_;
40 // Exterior Surface Name: Optional Object
41
2/3
✓ Branch 1 taken 1 time.
✓ Branch 5 taken 1 time.
✗ Branch 6 not taken.
2 if ((wo_ = workspaceObject.getTarget(SurfaceProperty_LocalEnvironmentFields::ExteriorSurfaceName))) {
42
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 8 taken 1 time.
✗ Branch 9 not taken.
2 if ((mo_ = translateAndMapWorkspaceObject(wo_.get()))) {
43
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
2 if (boost::optional<Surface> _exteriorSurface = mo_->optionalCast<Surface>()) {
44
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 localEnv_ = openstudio::model::SurfacePropertyLocalEnvironment(_exteriorSurface.get());
45 ✗ } else if (boost::optional<SubSurface> _exteriorSurface = mo_->optionalCast<SubSurface>()) {
46 ✗ localEnv_ = openstudio::model::SurfacePropertyLocalEnvironment(_exteriorSurface.get());
47 } else {
48 ✗ LOG(Error, workspaceObject.briefDescription()
49 << " has a wrong type for 'Exterior Surface Name', expected Surface or SubSurface, got " << mo_->briefDescription());
50 ✗ return boost::none;
51 1 }
52 } else {
53 ✗ LOG(Error, workspaceObject.briefDescription() << " has a wrong type for 'Exterior Surface Name'");
54 ✗ return boost::none;
55 }
56 } else {
57 ✗ LOG(Error, workspaceObject.briefDescription() << " does not have an 'Exterior Surface Name' attached.");
58 ✗ return boost::none;
59 }
60
61
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 SurfacePropertyLocalEnvironment modelObject = localEnv_.get();
62
63 // Name
64
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 modelObject.setName(workspaceObject.nameString());
65
66 // External Shading Fraction Schedule Name: Optional Object
67
2/3
✓ Branch 1 taken 1 time.
✓ Branch 5 taken 1 time.
✗ Branch 6 not taken.
2 if ((wo_ = workspaceObject.getTarget(SurfaceProperty_LocalEnvironmentFields::SunlitFractionScheduleName))) {
68
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 8 taken 1 time.
✗ Branch 9 not taken.
2 if ((mo_ = translateAndMapWorkspaceObject(wo_.get()))) {
69
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
2 if (auto externalShadingFractionSchedule_ = mo_->optionalCast<Schedule>()) {
70
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 modelObject.setExternalShadingFractionSchedule(externalShadingFractionSchedule_.get());
71 } else {
72 ✗ LOG(Warn, workspaceObject.briefDescription() << " has a wrong type for 'External Shading Fraction Schedule Name'");
73 1 }
74 }
75 }
76 // Surrounding Surfaces Object Name: Optional Object
77
2/3
✓ Branch 1 taken 1 time.
✓ Branch 5 taken 1 time.
✗ Branch 6 not taken.
2 if ((wo_ = workspaceObject.getTarget(SurfaceProperty_LocalEnvironmentFields::SurroundingSurfacesObjectName))) {
78
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 8 taken 1 time.
✗ Branch 9 not taken.
2 if ((mo_ = translateAndMapWorkspaceObject(wo_.get()))) {
79
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
2 if (auto sp_ = mo_->optionalCast<SurfacePropertySurroundingSurfaces>()) {
80
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 modelObject.setSurfacePropertySurroundingSurfaces(sp_.get());
81 } else {
82 ✗ LOG(Warn, workspaceObject.briefDescription() << " has a wrong type for 'Surrounding Surfaces Object Name'");
83 1 }
84 }
85 }
86
87 // Outdoor Air Node Name: Optional Object
88 // if ((wo_ = workspaceObject.getTarget(SurfaceProperty_LocalEnvironmentFields::OutdoorAirNodeName))) {
89 // if ((mo_ = translateAndMapWorkspaceObject(wo_.get()))) {
90 // if (boost::optional<OutdoorAirNode> _outdoorAirNode = mo_->optionalCast<OutdoorAirNode>()) {
91 // modelObject.setOutdoorAirNode(_outdoorAirNode.get());
92 // } else {
93 // LOG(Warn, workspaceObject.briefDescription() << " has a wrong type for 'Outdoor Air Node Name'");
94 // }
95 // }
96 // }
97
98
1/1
✓ Branch 1 taken 1 time.
1 return modelObject;
99 1 } // End of translate function
100
101 } // end namespace energyplus
102 } // end namespace openstudio
103