GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 55.7% 54 / 0 / 97
Functions: 100.0% 1 / 0 / 1
Branches: 40.2% 74 / 0 / 184

src/energyplus/ReverseTranslator/ReverseTranslateZoneVentilationWindandStackOpenArea.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/ZoneVentilationWindandStackOpenArea.hpp"
9 #include "../../model/ZoneVentilationWindandStackOpenArea_Impl.hpp"
10 #include "../../model/Space.hpp"
11 #include "../../model/Space_Impl.hpp"
12 #include "../../model/ThermalZone.hpp"
13 #include "../../model/Schedule.hpp"
14 #include "../../model/Schedule_Impl.hpp"
15
16 #include <utilities/idd/ZoneVentilation_WindandStackOpenArea_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 1 OptionalModelObject ReverseTranslator::translateZoneVentilationWindandStackOpenArea(const WorkspaceObject& workspaceObject) {
27
4/5
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 time.
1 if (workspaceObject.iddObject().type() != IddObjectType::ZoneVentilation_WindandStackOpenArea) {
28 ✗ LOG(Error, "WorkspaceObject is not IddObjectType: ZoneVentilation:WindandStackOpenArea");
29 ✗ return boost::none;
30 }
31
32 // Start by checking if the WorkspaceObject has a ThermalZone before you even initialize a ModelObject
33 1 boost::optional<ThermalZone> _zone;
34
1/1
✓ Branch 1 taken 1 time.
1 OptionalWorkspaceObject target = workspaceObject.getTarget(openstudio::ZoneVentilation_WindandStackOpenAreaFields::ZoneorSpaceName);
35
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (target) {
36
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
37
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (modelObject) {
38
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<Space> _space = modelObject->optionalCast<Space>()) {
39
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 _zone = _space->thermalZone();
40 1 }
41 }
42 1 }
43
44
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 if (!_zone.has_value()) {
45 ✗ LOG(Error, "Zone not found for workspace object " << workspaceObject.briefDescription() << ", it will not be Reverse Translated.");
46 ✗ return boost::none;
47 }
48
49
1/1
✓ Branch 1 taken 1 time.
1 openstudio::model::ZoneVentilationWindandStackOpenArea ventilation(m_model);
50
51
1/1
✓ Branch 1 taken 1 time.
1 OptionalString s = workspaceObject.name();
52
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (s) {
53
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 ventilation.setName(*s);
54 }
55
56
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 ventilation.addToThermalZone(_zone.get());
57
58
1/1
✓ Branch 1 taken 1 time.
1 OptionalDouble _d = workspaceObject.getDouble(openstudio::ZoneVentilation_WindandStackOpenAreaFields::OpeningArea);
59
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (_d) {
60
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 ventilation.setOpeningArea(_d.get());
61 } else {
62 // This one has a default of zero, but we should care about it (zero means it's useless too)
63 ✗ LOG(Error, "Opening Area value not found for workspace object " << workspaceObject.briefDescription());
64 }
65
66
1/1
✓ Branch 1 taken 1 time.
1 target = workspaceObject.getTarget(openstudio::ZoneVentilation_WindandStackOpenAreaFields::OpeningAreaFractionScheduleName);
67
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 if (target) {
68 ✗ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
69 ✗ if (modelObject) {
70 ✗ if (boost::optional<Schedule> _sch = modelObject->optionalCast<Schedule>()) {
71 ✗ ventilation.setOpeningAreaFractionSchedule(_sch.get());
72 ✗ }
73 }
74 ✗ }
75
76
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if ((_d = workspaceObject.getDouble(openstudio::ZoneVentilation_WindandStackOpenAreaFields::OpeningEffectiveness))) {
77
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 ventilation.setOpeningEffectiveness(_d.get());
78 } else {
79 ✗ ventilation.autocalculateOpeningEffectiveness();
80 }
81
82
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if ((_d = workspaceObject.getDouble(openstudio::ZoneVentilation_WindandStackOpenAreaFields::EffectiveAngle))) {
83
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 ventilation.setEffectiveAngle(_d.get());
84 }
85
86
2/3
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
2 if ((_d = workspaceObject.getDouble(openstudio::ZoneVentilation_WindandStackOpenAreaFields::HeightDifference))) {
87 ✗ ventilation.setHeightDifference(_d.get());
88 }
89
90
2/3
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
2 if ((_d = workspaceObject.getDouble(openstudio::ZoneVentilation_WindandStackOpenAreaFields::DischargeCoefficientforOpening))) {
91 ✗ ventilation.setDischargeCoefficientforOpening(_d.get());
92 } else {
93
1/1
✓ Branch 1 taken 1 time.
1 ventilation.autocalculateDischargeCoefficientforOpening();
94 }
95
96
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if ((_d = workspaceObject.getDouble(openstudio::ZoneVentilation_WindandStackOpenAreaFields::MinimumIndoorTemperature))) {
97
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 ventilation.setMinimumIndoorTemperature(_d.get());
98 }
99
100
1/1
✓ Branch 1 taken 1 time.
1 target = workspaceObject.getTarget(openstudio::ZoneVentilation_WindandStackOpenAreaFields::MinimumIndoorTemperatureScheduleName);
101
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (target) {
102
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
103
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (modelObject) {
104
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<Schedule> _sch = modelObject->optionalCast<Schedule>()) {
105
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 ventilation.setMinimumIndoorTemperatureSchedule(_sch.get());
106 1 }
107 }
108 1 }
109
110
2/3
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
2 if ((_d = workspaceObject.getDouble(openstudio::ZoneVentilation_WindandStackOpenAreaFields::MaximumIndoorTemperature))) {
111 ✗ ventilation.setMaximumIndoorTemperature(_d.get());
112 }
113
114
1/1
✓ Branch 1 taken 1 time.
1 target = workspaceObject.getTarget(openstudio::ZoneVentilation_WindandStackOpenAreaFields::MaximumIndoorTemperatureScheduleName);
115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 if (target) {
116 ✗ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
117 ✗ if (modelObject) {
118 ✗ if (boost::optional<Schedule> _sch = modelObject->optionalCast<Schedule>()) {
119 ✗ ventilation.setMaximumIndoorTemperatureSchedule(_sch.get());
120 ✗ }
121 }
122 ✗ }
123
124
2/3
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
2 if ((_d = workspaceObject.getDouble(openstudio::ZoneVentilation_WindandStackOpenAreaFields::DeltaTemperature))) {
125 ✗ ventilation.setDeltaTemperature(_d.get());
126 }
127
128
1/1
✓ Branch 1 taken 1 time.
1 target = workspaceObject.getTarget(openstudio::ZoneVentilation_WindandStackOpenAreaFields::DeltaTemperatureScheduleName);
129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 if (target) {
130 ✗ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
131 ✗ if (modelObject) {
132 ✗ if (boost::optional<Schedule> _sch = modelObject->optionalCast<Schedule>()) {
133 ✗ ventilation.setDeltaTemperatureSchedule(_sch.get());
134 ✗ }
135 }
136 ✗ }
137
138
2/3
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
2 if ((_d = workspaceObject.getDouble(openstudio::ZoneVentilation_WindandStackOpenAreaFields::MinimumOutdoorTemperature))) {
139 ✗ ventilation.setMinimumOutdoorTemperature(_d.get());
140 }
141
142
1/1
✓ Branch 1 taken 1 time.
1 target = workspaceObject.getTarget(openstudio::ZoneVentilation_WindandStackOpenAreaFields::MinimumOutdoorTemperatureScheduleName);
143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 if (target) {
144 ✗ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
145 ✗ if (modelObject) {
146 ✗ if (boost::optional<Schedule> _sch = modelObject->optionalCast<Schedule>()) {
147 ✗ ventilation.setMinimumOutdoorTemperatureSchedule(_sch.get());
148 ✗ }
149 }
150 ✗ }
151
152
2/3
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
2 if ((_d = workspaceObject.getDouble(openstudio::ZoneVentilation_WindandStackOpenAreaFields::MaximumOutdoorTemperature))) {
153 ✗ ventilation.setMaximumOutdoorTemperature(_d.get());
154 }
155
156
1/1
✓ Branch 1 taken 1 time.
1 target = workspaceObject.getTarget(openstudio::ZoneVentilation_WindandStackOpenAreaFields::MaximumOutdoorTemperatureScheduleName);
157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 if (target) {
158 ✗ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
159 ✗ if (modelObject) {
160 ✗ if (boost::optional<Schedule> _sch = modelObject->optionalCast<Schedule>()) {
161 ✗ ventilation.setMaximumOutdoorTemperatureSchedule(_sch.get());
162 ✗ }
163 }
164 ✗ }
165
166
2/3
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
2 if ((_d = workspaceObject.getDouble(openstudio::ZoneVentilation_WindandStackOpenAreaFields::MaximumWindSpeed))) {
167 ✗ ventilation.setMaximumWindSpeed(_d.get());
168 }
169
170
1/1
✓ Branch 1 taken 1 time.
1 return ventilation;
171 1 }
172
173 } // namespace energyplus
174
175 } // namespace openstudio
176