GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 67.3% 210 / 0 / 312
Functions: 69.1% 56 / 0 / 81
Branches: 61.4% 232 / 0 / 378

src/model/LightsDefinition.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 "LightsDefinition.hpp"
7 #include "LightsDefinition_Impl.hpp"
8
9 #include <utilities/idd/IddFactory.hxx>
10
11 #include <utilities/idd/OS_Lights_Definition_FieldEnums.hxx>
12 #include <utilities/idd/IddEnums.hxx>
13
14 #include "../utilities/math/FloatCompare.hpp"
15 #include "../utilities/core/Compare.hpp"
16 #include "../utilities/core/Assert.hpp"
17
18 namespace openstudio {
19 namespace model {
20
21 namespace detail {
22
23 1194 LightsDefinition_Impl::LightsDefinition_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
24 1194 : SpaceLoadDefinition_Impl(idfObject, model, keepHandle) {
25
4/6
✓ Branch 1 taken 1194 times.
✓ Branch 4 taken 1194 times.
✓ Branch 7 taken 1194 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1194 times.
✗ Branch 13 not taken.
1194 OS_ASSERT(idfObject.iddObject().type() == LightsDefinition::iddObjectType());
26 1194 }
27
28 890 LightsDefinition_Impl::LightsDefinition_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle)
29 890 : SpaceLoadDefinition_Impl(other, model, keepHandle) {
30
4/6
✓ Branch 1 taken 890 times.
✓ Branch 4 taken 890 times.
✓ Branch 7 taken 890 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 890 times.
✗ Branch 13 not taken.
890 OS_ASSERT(other.iddObject().type() == LightsDefinition::iddObjectType());
31 890 }
32
33 408 LightsDefinition_Impl::LightsDefinition_Impl(const LightsDefinition_Impl& other, Model_Impl* model, bool keepHandle)
34 408 : SpaceLoadDefinition_Impl(other, model, keepHandle) {}
35
36 1 const std::vector<std::string>& LightsDefinition_Impl::outputVariableNames() const {
37
2/4
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
1 static const std::vector<std::string> result;
38 // Not appropriate: output is listed in Lights instead
39 1 return result;
40 }
41
42 1 IddObjectType LightsDefinition_Impl::iddObjectType() const {
43 1 return LightsDefinition::iddObjectType();
44 }
45
46 2358 std::string LightsDefinition_Impl::designLevelCalculationMethod() const {
47
1/1
✓ Branch 1 taken 2358 times.
2358 boost::optional<std::string> value = getString(OS_Lights_DefinitionFields::DesignLevelCalculationMethod, true);
48
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 2358 times.
✗ Branch 4 not taken.
2358 OS_ASSERT(value);
49
2/2
✓ Branch 1 taken 2358 times.
✓ Branch 4 taken 2358 times.
4716 return value.get();
50 2358 }
51
52 1477 boost::optional<double> LightsDefinition_Impl::lightingLevel() const {
53 1477 boost::optional<double> result;
54
5/5
✓ Branch 1 taken 1477 times.
✓ Branch 4 taken 1477 times.
✓ Branch 7 taken 1477 times.
✓ Branch 11 taken 1380 times.
✓ Branch 12 taken 97 times.
4431 if (istringEqual("LightingLevel", this->designLevelCalculationMethod())) {
55
1/1
✓ Branch 1 taken 1380 times.
1380 result = getDouble(OS_Lights_DefinitionFields::LightingLevel, true);
56 //OS_ASSERT(result);
57 }
58 1477 return result;
59 }
60
61 325 boost::optional<double> LightsDefinition_Impl::wattsperSpaceFloorArea() const {
62 325 boost::optional<double> result;
63
5/5
✓ Branch 1 taken 325 times.
✓ Branch 4 taken 325 times.
✓ Branch 7 taken 325 times.
✓ Branch 11 taken 231 times.
✓ Branch 12 taken 94 times.
975 if (istringEqual("Watts/Area", this->designLevelCalculationMethod())) {
64
1/1
✓ Branch 1 taken 231 times.
231 result = getDouble(OS_Lights_DefinitionFields::WattsperSpaceFloorArea, true);
65 //OS_ASSERT(result);
66 }
67 325 return result;
68 }
69
70 185 boost::optional<double> LightsDefinition_Impl::wattsperPerson() const {
71 185 boost::optional<double> result;
72
5/5
✓ Branch 1 taken 185 times.
✓ Branch 4 taken 185 times.
✓ Branch 7 taken 185 times.
✓ Branch 11 taken 16 times.
✓ Branch 12 taken 169 times.
555 if (istringEqual("Watts/Person", this->designLevelCalculationMethod())) {
73
1/1
✓ Branch 1 taken 16 times.
16 result = getDouble(OS_Lights_DefinitionFields::WattsperPerson, true);
74 //OS_ASSERT(result);
75 }
76 185 return result;
77 }
78
79 47 double LightsDefinition_Impl::fractionRadiant() const {
80
1/1
✓ Branch 1 taken 47 times.
47 boost::optional<double> value = getDouble(OS_Lights_DefinitionFields::FractionRadiant, true);
81
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 47 times.
✗ Branch 4 not taken.
47 OS_ASSERT(value);
82
1/1
✓ Branch 1 taken 47 times.
94 return value.get();
83 }
84
85 165 bool LightsDefinition_Impl::isFractionRadiantDefaulted() const {
86 165 return isEmpty(OS_Lights_DefinitionFields::FractionRadiant);
87 }
88
89 7 double LightsDefinition_Impl::fractionVisible() const {
90
1/1
✓ Branch 1 taken 7 times.
7 boost::optional<double> value = getDouble(OS_Lights_DefinitionFields::FractionVisible, true);
91
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 4 not taken.
7 OS_ASSERT(value);
92
1/1
✓ Branch 1 taken 7 times.
14 return value.get();
93 }
94
95 165 bool LightsDefinition_Impl::isFractionVisibleDefaulted() const {
96 165 return isEmpty(OS_Lights_DefinitionFields::FractionVisible);
97 }
98
99 7 double LightsDefinition_Impl::returnAirFraction() const {
100
1/1
✓ Branch 1 taken 7 times.
7 boost::optional<double> value = getDouble(OS_Lights_DefinitionFields::ReturnAirFraction, true);
101
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 4 not taken.
7 OS_ASSERT(value);
102
1/1
✓ Branch 1 taken 7 times.
14 return value.get();
103 }
104
105 165 bool LightsDefinition_Impl::isReturnAirFractionDefaulted() const {
106 165 return isEmpty(OS_Lights_DefinitionFields::ReturnAirFraction);
107 }
108
109 5 bool LightsDefinition_Impl::returnAirFractionCalculatedfromPlenumTemperature() const {
110
1/1
✓ Branch 1 taken 5 times.
5 boost::optional<std::string> value = getString(OS_Lights_DefinitionFields::ReturnAirFractionCalculatedfromPlenumTemperature, true);
111
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 4 not taken.
5 OS_ASSERT(value);
112
3/3
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
10 return openstudio::istringEqual(value.get(), "Yes");
113 5 }
114
115 165 bool LightsDefinition_Impl::isReturnAirFractionCalculatedfromPlenumTemperatureDefaulted() const {
116 165 return isEmpty(OS_Lights_DefinitionFields::ReturnAirFractionCalculatedfromPlenumTemperature);
117 }
118
119 ✗ double LightsDefinition_Impl::returnAirFractionFunctionofPlenumTemperatureCoefficient1() const {
120 ✗ boost::optional<double> value = getDouble(OS_Lights_DefinitionFields::ReturnAirFractionFunctionofPlenumTemperatureCoefficient1, true);
121 ✗ OS_ASSERT(value);
122 ✗ return value.get();
123 }
124
125 165 bool LightsDefinition_Impl::isReturnAirFractionFunctionofPlenumTemperatureCoefficient1Defaulted() const {
126 165 return isEmpty(OS_Lights_DefinitionFields::ReturnAirFractionFunctionofPlenumTemperatureCoefficient1);
127 }
128
129 ✗ double LightsDefinition_Impl::returnAirFractionFunctionofPlenumTemperatureCoefficient2() const {
130 ✗ boost::optional<double> value = getDouble(OS_Lights_DefinitionFields::ReturnAirFractionFunctionofPlenumTemperatureCoefficient2, true);
131 ✗ OS_ASSERT(value);
132 ✗ return value.get();
133 }
134
135 165 bool LightsDefinition_Impl::isReturnAirFractionFunctionofPlenumTemperatureCoefficient2Defaulted() const {
136 165 return isEmpty(OS_Lights_DefinitionFields::ReturnAirFractionFunctionofPlenumTemperatureCoefficient2);
137 }
138
139 747 bool LightsDefinition_Impl::setLightingLevel(boost::optional<double> lightingLevel) {
140 747 bool result = true;
141
1/2
✓ Branch 0 taken 747 times.
✗ Branch 1 not taken.
747 if (lightingLevel) {
142
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 747 times.
747 if (*lightingLevel < 0) {
143 ✗ result = false;
144 } else {
145 // This one could return false for good reasons, if NaN of Infinity was passed
146 747 result = setDouble(OS_Lights_DefinitionFields::LightingLevel, lightingLevel.get());
147
1/2
✓ Branch 0 taken 747 times.
✗ Branch 1 not taken.
747 if (result) {
148
2/2
✓ Branch 1 taken 747 times.
✓ Branch 4 taken 747 times.
1494 result = setString(OS_Lights_DefinitionFields::DesignLevelCalculationMethod, "LightingLevel");
149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 747 times.
747 OS_ASSERT(result);
150
2/2
✓ Branch 1 taken 747 times.
✓ Branch 4 taken 747 times.
1494 result = setString(OS_Lights_DefinitionFields::WattsperSpaceFloorArea, "");
151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 747 times.
747 OS_ASSERT(result);
152
2/2
✓ Branch 1 taken 747 times.
✓ Branch 4 taken 747 times.
1494 result = setString(OS_Lights_DefinitionFields::WattsperPerson, "");
153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 747 times.
747 OS_ASSERT(result);
154 }
155 }
156 } else {
157 ✗ if (istringEqual("LightingLevel", this->designLevelCalculationMethod())) {
158 ✗ result = setDouble(OS_Lights_DefinitionFields::LightingLevel, 0.0);
159 }
160 }
161 747 return result;
162 }
163
164 253 bool LightsDefinition_Impl::setWattsperSpaceFloorArea(boost::optional<double> wattsperSpaceFloorArea) {
165 253 bool result = true;
166
1/2
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
253 if (wattsperSpaceFloorArea) {
167
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 253 times.
253 if (*wattsperSpaceFloorArea < 0) {
168 ✗ result = false;
169 } else {
170 // This one could return false for good reasons, if NaN of Infinity was passed
171 253 result = setDouble(OS_Lights_DefinitionFields::WattsperSpaceFloorArea, wattsperSpaceFloorArea.get());
172
1/2
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
253 if (result) {
173
2/2
✓ Branch 1 taken 253 times.
✓ Branch 4 taken 253 times.
506 result = setString(OS_Lights_DefinitionFields::DesignLevelCalculationMethod, "Watts/Area");
174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 253 times.
253 OS_ASSERT(result);
175
2/2
✓ Branch 1 taken 253 times.
✓ Branch 4 taken 253 times.
506 result = setString(OS_Lights_DefinitionFields::LightingLevel, "");
176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 253 times.
253 OS_ASSERT(result);
177
2/2
✓ Branch 1 taken 253 times.
✓ Branch 4 taken 253 times.
506 result = setString(OS_Lights_DefinitionFields::WattsperPerson, "");
178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 253 times.
253 OS_ASSERT(result);
179 }
180 }
181 } else {
182 ✗ if (istringEqual("Watts/Area", this->designLevelCalculationMethod())) {
183 ✗ result = setDouble(OS_Lights_DefinitionFields::WattsperSpaceFloorArea, 0.0);
184 }
185 }
186 253 return result;
187 }
188
189 2 bool LightsDefinition_Impl::setWattsperPerson(boost::optional<double> wattsperPerson) {
190 2 bool result = true;
191
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (wattsperPerson) {
192
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 if (*wattsperPerson < 0) {
193 ✗ result = false;
194 } else {
195 // This one could return false for good reasons, if NaN of Infinity was passed
196 2 result = setDouble(OS_Lights_DefinitionFields::WattsperPerson, wattsperPerson.get());
197
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (result) {
198
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
4 result = setString(OS_Lights_DefinitionFields::DesignLevelCalculationMethod, "Watts/Person");
199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 OS_ASSERT(result);
200
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
4 result = setString(OS_Lights_DefinitionFields::LightingLevel, "");
201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 OS_ASSERT(result);
202
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
4 result = setString(OS_Lights_DefinitionFields::WattsperSpaceFloorArea, "");
203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 OS_ASSERT(result);
204 }
205 }
206 } else {
207 ✗ if (istringEqual("Watts/Person", this->designLevelCalculationMethod())) {
208 ✗ result = setDouble(OS_Lights_DefinitionFields::WattsperPerson, 0.0);
209 }
210 }
211 2 return result;
212 }
213
214 49 bool LightsDefinition_Impl::setFractionRadiant(double fractionRadiant) {
215 49 bool result = setDouble(OS_Lights_DefinitionFields::FractionRadiant, fractionRadiant);
216 49 return result;
217 }
218
219 ✗ void LightsDefinition_Impl::resetFractionRadiant() {
220 ✗ bool result = setString(OS_Lights_DefinitionFields::FractionRadiant, "");
221 ✗ OS_ASSERT(result);
222 ✗ }
223
224 28 bool LightsDefinition_Impl::setFractionVisible(double fractionVisible) {
225 28 bool result = setDouble(OS_Lights_DefinitionFields::FractionVisible, fractionVisible);
226 28 return result;
227 }
228
229 ✗ void LightsDefinition_Impl::resetFractionVisible() {
230 ✗ bool result = setString(OS_Lights_DefinitionFields::FractionVisible, "");
231 ✗ OS_ASSERT(result);
232 ✗ }
233
234 49 bool LightsDefinition_Impl::setReturnAirFraction(double returnAirFraction) {
235 49 bool result = setDouble(OS_Lights_DefinitionFields::ReturnAirFraction, returnAirFraction);
236 49 return result;
237 }
238
239 ✗ void LightsDefinition_Impl::resetReturnAirFraction() {
240 ✗ bool result = setString(OS_Lights_DefinitionFields::ReturnAirFraction, "");
241 ✗ OS_ASSERT(result);
242 ✗ }
243
244 26 bool LightsDefinition_Impl::setReturnAirFractionCalculatedfromPlenumTemperature(bool returnAirFractionCalculatedfromPlenumTemperature) {
245 26 bool result = false;
246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 if (returnAirFractionCalculatedfromPlenumTemperature) {
247 ✗ result = setString(OS_Lights_DefinitionFields::ReturnAirFractionCalculatedfromPlenumTemperature, "Yes");
248 } else {
249
2/2
✓ Branch 1 taken 26 times.
✓ Branch 4 taken 26 times.
78 result = setString(OS_Lights_DefinitionFields::ReturnAirFractionCalculatedfromPlenumTemperature, "No");
250 }
251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 OS_ASSERT(result);
252 26 return result;
253 }
254
255 ✗ void LightsDefinition_Impl::resetReturnAirFractionCalculatedfromPlenumTemperature() {
256 ✗ bool result = setString(OS_Lights_DefinitionFields::ReturnAirFractionCalculatedfromPlenumTemperature, "");
257 ✗ OS_ASSERT(result);
258 ✗ }
259
260 ✗ bool LightsDefinition_Impl::setReturnAirFractionFunctionofPlenumTemperatureCoefficient1(
261 double returnAirFractionFunctionofPlenumTemperatureCoefficient1) {
262 ✗ bool result = setDouble(OS_Lights_DefinitionFields::ReturnAirFractionFunctionofPlenumTemperatureCoefficient1,
263 returnAirFractionFunctionofPlenumTemperatureCoefficient1);
264 ✗ return result;
265 }
266
267 ✗ void LightsDefinition_Impl::resetReturnAirFractionFunctionofPlenumTemperatureCoefficient1() {
268 ✗ bool result = setString(OS_Lights_DefinitionFields::ReturnAirFractionFunctionofPlenumTemperatureCoefficient1, "");
269 ✗ OS_ASSERT(result);
270 ✗ }
271
272 ✗ bool LightsDefinition_Impl::setReturnAirFractionFunctionofPlenumTemperatureCoefficient2(
273 double returnAirFractionFunctionofPlenumTemperatureCoefficient2) {
274 ✗ bool result = setDouble(OS_Lights_DefinitionFields::ReturnAirFractionFunctionofPlenumTemperatureCoefficient2,
275 returnAirFractionFunctionofPlenumTemperatureCoefficient2);
276 ✗ return result;
277 }
278
279 ✗ void LightsDefinition_Impl::resetReturnAirFractionFunctionofPlenumTemperatureCoefficient2() {
280 ✗ bool result = setString(OS_Lights_DefinitionFields::ReturnAirFractionFunctionofPlenumTemperatureCoefficient2, "");
281 ✗ OS_ASSERT(result);
282 ✗ }
283
284 76 double LightsDefinition_Impl::getLightingPower(double floorArea, double numPeople) const {
285
1/1
✓ Branch 1 taken 76 times.
76 std::string method = designLevelCalculationMethod();
286
287
4/4
✓ Branch 1 taken 76 times.
✓ Branch 4 taken 76 times.
✓ Branch 7 taken 29 times.
✓ Branch 8 taken 47 times.
152 if (openstudio::istringEqual("LightingLevel", method)) {
288
2/2
✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
29 return lightingLevel().get();
289
4/4
✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
✓ Branch 7 taken 41 times.
✓ Branch 8 taken 6 times.
94 } else if (openstudio::istringEqual("Watts/Area", method)) {
290
2/2
✓ Branch 1 taken 41 times.
✓ Branch 4 taken 41 times.
41 return wattsperSpaceFloorArea().get() * floorArea;
291
3/4
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
12 } else if (openstudio::istringEqual("Watts/Person", method)) {
292
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 return wattsperPerson().get() * numPeople;
293 }
294
295 ✗ OS_ASSERT(false);
296 ✗ return 0.0;
297 76 }
298
299 104 double LightsDefinition_Impl::getPowerPerFloorArea(double floorArea, double numPeople) const {
300
1/1
✓ Branch 1 taken 104 times.
104 std::string method = designLevelCalculationMethod();
301
302
4/4
✓ Branch 1 taken 104 times.
✓ Branch 4 taken 104 times.
✓ Branch 7 taken 11 times.
✓ Branch 8 taken 93 times.
208 if (openstudio::istringEqual("LightingLevel", method)) {
303
2/2
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 9 times.
11 if (equal(floorArea, 0.0)) {
304
13/13
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 22 taken 2 times.
✓ Branch 25 taken 2 times.
✓ Branch 28 taken 2 times.
✓ Branch 31 taken 2 times.
✓ Branch 34 taken 2 times.
✓ Branch 38 taken 2 times.
✓ Branch 41 taken 2 times.
2 LOG_AND_THROW("Calculation would require division by zero.");
305 }
306
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 return lightingLevel().get() / floorArea;
307
4/4
✓ Branch 1 taken 93 times.
✓ Branch 4 taken 93 times.
✓ Branch 7 taken 87 times.
✓ Branch 8 taken 6 times.
186 } else if (openstudio::istringEqual("Watts/Area", method)) {
308
2/2
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
87 return wattsperSpaceFloorArea().get();
309
3/4
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
12 } else if (openstudio::istringEqual("Watts/Person", method)) {
310
2/2
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
6 if (equal(floorArea, 0.0)) {
311
13/13
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 22 taken 2 times.
✓ Branch 25 taken 2 times.
✓ Branch 28 taken 2 times.
✓ Branch 31 taken 2 times.
✓ Branch 34 taken 2 times.
✓ Branch 38 taken 2 times.
✓ Branch 41 taken 2 times.
2 LOG_AND_THROW("Calculation would require division by zero.");
312 }
313
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 return wattsperPerson().get() * numPeople / floorArea;
314 }
315
316 ✗ OS_ASSERT(false);
317 ✗ return 0.0;
318 104 }
319
320 17 double LightsDefinition_Impl::getPowerPerPerson(double floorArea, double numPeople) const {
321
1/1
✓ Branch 1 taken 17 times.
17 std::string method = designLevelCalculationMethod();
322
323
4/4
✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 12 times.
34 if (openstudio::istringEqual("LightingLevel", method)) {
324
2/2
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 3 times.
5 if (equal(numPeople, 0.0)) {
325
13/13
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 22 taken 2 times.
✓ Branch 25 taken 2 times.
✓ Branch 28 taken 2 times.
✓ Branch 31 taken 2 times.
✓ Branch 34 taken 2 times.
✓ Branch 38 taken 2 times.
✓ Branch 41 taken 2 times.
2 LOG_AND_THROW("Calculation would require division by zero.");
326 }
327
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 return lightingLevel().get() / numPeople;
328
4/4
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 8 times.
✓ Branch 8 taken 4 times.
24 } else if (openstudio::istringEqual("Watts/Area", method)) {
329
2/2
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 6 times.
8 if (equal(numPeople, 0.0)) {
330
13/13
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 22 taken 2 times.
✓ Branch 25 taken 2 times.
✓ Branch 28 taken 2 times.
✓ Branch 31 taken 2 times.
✓ Branch 34 taken 2 times.
✓ Branch 38 taken 2 times.
✓ Branch 41 taken 2 times.
2 LOG_AND_THROW("Calculation would require division by zero.");
331 }
332
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 return wattsperSpaceFloorArea().get() * floorArea / numPeople;
333
3/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
8 } else if (openstudio::istringEqual("Watts/Person", method)) {
334
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 return wattsperPerson().get();
335 }
336
337 ✗ OS_ASSERT(false);
338 ✗ return 0.0;
339 17 }
340
341 ✗ bool LightsDefinition_Impl::setDesignLevelCalculationMethod(const std::string& method, double floorArea, double numPeople) {
342
343 ✗ if (openstudio::istringEqual("lightinglevel", method)) {
344 ✗ return setLightingLevel(getLightingPower(floorArea, numPeople));
345 ✗ } else if (openstudio::istringEqual("watts/area", method)) {
346 ✗ return setWattsperSpaceFloorArea(getPowerPerFloorArea(floorArea, numPeople));
347 ✗ } else if (openstudio::istringEqual("watts/person", method)) {
348 ✗ return setWattsperPerson(getPowerPerPerson(floorArea, numPeople));
349 }
350
351 ✗ return false;
352 }
353
354 ✗ std::vector<EMSActuatorNames> LightsDefinition_Impl::emsActuatorNames() const {
355 ✗ std::vector<EMSActuatorNames> actuators{{"Lights", "Electricity Rate"}};
356 ✗ return actuators;
357 ✗ }
358
359 ✗ std::vector<std::string> LightsDefinition_Impl::emsInternalVariableNames() const {
360 ✗ std::vector<std::string> types{"Lighting Power Design Level"};
361 ✗ return types;
362 ✗ }
363
364 } // namespace detail
365
366 303 LightsDefinition::LightsDefinition(const Model& model) : SpaceLoadDefinition(LightsDefinition::iddObjectType(), model) {
367
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 303 times.
✗ Branch 5 not taken.
303 OS_ASSERT(getImpl<detail::LightsDefinition_Impl>());
368
2/4
✓ Branch 1 taken 303 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 303 times.
✗ Branch 6 not taken.
303 OS_ASSERT(this->setLightingLevel(0.0));
369 303 }
370
371 10124 IddObjectType LightsDefinition::iddObjectType() {
372
1/1
✓ Branch 1 taken 10124 times.
10124 IddObjectType result(IddObjectType::OS_Lights_Definition);
373 10124 return result;
374 }
375
376 ✗ std::vector<std::string> LightsDefinition::validDesignLevelCalculationMethodValues() {
377 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_Lights_DefinitionFields::DesignLevelCalculationMethod);
378 }
379
380 174 std::string LightsDefinition::designLevelCalculationMethod() const {
381
1/1
✓ Branch 3 taken 174 times.
174 return getImpl<detail::LightsDefinition_Impl>()->designLevelCalculationMethod();
382 }
383
384 1436 boost::optional<double> LightsDefinition::lightingLevel() const {
385
1/1
✓ Branch 3 taken 1436 times.
1436 return getImpl<detail::LightsDefinition_Impl>()->lightingLevel();
386 }
387
388 191 boost::optional<double> LightsDefinition::wattsperSpaceFloorArea() const {
389
1/1
✓ Branch 3 taken 191 times.
191 return getImpl<detail::LightsDefinition_Impl>()->wattsperSpaceFloorArea();
390 }
391
392 171 boost::optional<double> LightsDefinition::wattsperPerson() const {
393
1/1
✓ Branch 3 taken 171 times.
171 return getImpl<detail::LightsDefinition_Impl>()->wattsperPerson();
394 }
395
396 47 double LightsDefinition::fractionRadiant() const {
397
1/1
✓ Branch 3 taken 47 times.
47 return getImpl<detail::LightsDefinition_Impl>()->fractionRadiant();
398 }
399
400 165 bool LightsDefinition::isFractionRadiantDefaulted() const {
401
1/1
✓ Branch 3 taken 165 times.
165 return getImpl<detail::LightsDefinition_Impl>()->isFractionRadiantDefaulted();
402 }
403
404 7 double LightsDefinition::fractionVisible() const {
405
1/1
✓ Branch 3 taken 7 times.
7 return getImpl<detail::LightsDefinition_Impl>()->fractionVisible();
406 }
407
408 165 bool LightsDefinition::isFractionVisibleDefaulted() const {
409
1/1
✓ Branch 3 taken 165 times.
165 return getImpl<detail::LightsDefinition_Impl>()->isFractionVisibleDefaulted();
410 }
411
412 7 double LightsDefinition::returnAirFraction() const {
413
1/1
✓ Branch 3 taken 7 times.
7 return getImpl<detail::LightsDefinition_Impl>()->returnAirFraction();
414 }
415
416 165 bool LightsDefinition::isReturnAirFractionDefaulted() const {
417
1/1
✓ Branch 3 taken 165 times.
165 return getImpl<detail::LightsDefinition_Impl>()->isReturnAirFractionDefaulted();
418 }
419
420 5 bool LightsDefinition::returnAirFractionCalculatedfromPlenumTemperature() const {
421
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::LightsDefinition_Impl>()->returnAirFractionCalculatedfromPlenumTemperature();
422 }
423
424 165 bool LightsDefinition::isReturnAirFractionCalculatedfromPlenumTemperatureDefaulted() const {
425
1/1
✓ Branch 3 taken 165 times.
165 return getImpl<detail::LightsDefinition_Impl>()->isReturnAirFractionCalculatedfromPlenumTemperatureDefaulted();
426 }
427
428 ✗ double LightsDefinition::returnAirFractionFunctionofPlenumTemperatureCoefficient1() const {
429 ✗ return getImpl<detail::LightsDefinition_Impl>()->returnAirFractionFunctionofPlenumTemperatureCoefficient1();
430 }
431
432 165 bool LightsDefinition::isReturnAirFractionFunctionofPlenumTemperatureCoefficient1Defaulted() const {
433
1/1
✓ Branch 3 taken 165 times.
165 return getImpl<detail::LightsDefinition_Impl>()->isReturnAirFractionFunctionofPlenumTemperatureCoefficient1Defaulted();
434 }
435
436 ✗ double LightsDefinition::returnAirFractionFunctionofPlenumTemperatureCoefficient2() const {
437 ✗ return getImpl<detail::LightsDefinition_Impl>()->returnAirFractionFunctionofPlenumTemperatureCoefficient2();
438 }
439
440 165 bool LightsDefinition::isReturnAirFractionFunctionofPlenumTemperatureCoefficient2Defaulted() const {
441
1/1
✓ Branch 3 taken 165 times.
165 return getImpl<detail::LightsDefinition_Impl>()->isReturnAirFractionFunctionofPlenumTemperatureCoefficient2Defaulted();
442 }
443
444 747 bool LightsDefinition::setLightingLevel(double lightingLevel) {
445
2/2
✓ Branch 3 taken 747 times.
✓ Branch 6 taken 747 times.
747 return getImpl<detail::LightsDefinition_Impl>()->setLightingLevel(lightingLevel);
446 }
447
448 253 bool LightsDefinition::setWattsperSpaceFloorArea(double wattsperSpaceFloorArea) {
449
2/2
✓ Branch 3 taken 253 times.
✓ Branch 6 taken 253 times.
253 return getImpl<detail::LightsDefinition_Impl>()->setWattsperSpaceFloorArea(wattsperSpaceFloorArea);
450 }
451
452 2 bool LightsDefinition::setWattsperPerson(double wattsperPerson) {
453
2/2
✓ Branch 3 taken 2 times.
✓ Branch 6 taken 2 times.
2 return getImpl<detail::LightsDefinition_Impl>()->setWattsperPerson(wattsperPerson);
454 }
455
456 49 bool LightsDefinition::setFractionRadiant(double fractionRadiant) {
457
1/1
✓ Branch 3 taken 49 times.
49 return getImpl<detail::LightsDefinition_Impl>()->setFractionRadiant(fractionRadiant);
458 }
459
460 ✗ void LightsDefinition::resetFractionRadiant() {
461 ✗ getImpl<detail::LightsDefinition_Impl>()->resetFractionRadiant();
462 ✗ }
463
464 28 bool LightsDefinition::setFractionVisible(double fractionVisible) {
465
1/1
✓ Branch 3 taken 28 times.
28 return getImpl<detail::LightsDefinition_Impl>()->setFractionVisible(fractionVisible);
466 }
467
468 ✗ void LightsDefinition::resetFractionVisible() {
469 ✗ getImpl<detail::LightsDefinition_Impl>()->resetFractionVisible();
470 ✗ }
471
472 49 bool LightsDefinition::setReturnAirFraction(double returnAirFraction) {
473
1/1
✓ Branch 3 taken 49 times.
49 return getImpl<detail::LightsDefinition_Impl>()->setReturnAirFraction(returnAirFraction);
474 }
475
476 ✗ void LightsDefinition::resetReturnAirFraction() {
477 ✗ getImpl<detail::LightsDefinition_Impl>()->resetReturnAirFraction();
478 ✗ }
479
480 26 bool LightsDefinition::setReturnAirFractionCalculatedfromPlenumTemperature(bool returnAirFractionCalculatedfromPlenumTemperature) {
481
1/1
✓ Branch 3 taken 26 times.
52 return getImpl<detail::LightsDefinition_Impl>()->setReturnAirFractionCalculatedfromPlenumTemperature(
482 52 returnAirFractionCalculatedfromPlenumTemperature);
483 }
484
485 ✗ void LightsDefinition::resetReturnAirFractionCalculatedfromPlenumTemperature() {
486 ✗ getImpl<detail::LightsDefinition_Impl>()->resetReturnAirFractionCalculatedfromPlenumTemperature();
487 ✗ }
488
489 bool
490 ✗ LightsDefinition::setReturnAirFractionFunctionofPlenumTemperatureCoefficient1(double returnAirFractionFunctionofPlenumTemperatureCoefficient1) {
491 ✗ return getImpl<detail::LightsDefinition_Impl>()->setReturnAirFractionFunctionofPlenumTemperatureCoefficient1(
492 ✗ returnAirFractionFunctionofPlenumTemperatureCoefficient1);
493 }
494
495 ✗ void LightsDefinition::resetReturnAirFractionFunctionofPlenumTemperatureCoefficient1() {
496 ✗ getImpl<detail::LightsDefinition_Impl>()->resetReturnAirFractionFunctionofPlenumTemperatureCoefficient1();
497 ✗ }
498
499 bool
500 ✗ LightsDefinition::setReturnAirFractionFunctionofPlenumTemperatureCoefficient2(double returnAirFractionFunctionofPlenumTemperatureCoefficient2) {
501 ✗ return getImpl<detail::LightsDefinition_Impl>()->setReturnAirFractionFunctionofPlenumTemperatureCoefficient2(
502 ✗ returnAirFractionFunctionofPlenumTemperatureCoefficient2);
503 }
504
505 ✗ void LightsDefinition::resetReturnAirFractionFunctionofPlenumTemperatureCoefficient2() {
506 ✗ getImpl<detail::LightsDefinition_Impl>()->resetReturnAirFractionFunctionofPlenumTemperatureCoefficient2();
507 ✗ }
508
509 76 double LightsDefinition::getLightingPower(double floorArea, double numPeople) const {
510
1/1
✓ Branch 3 taken 76 times.
76 return getImpl<detail::LightsDefinition_Impl>()->getLightingPower(floorArea, numPeople);
511 }
512
513 104 double LightsDefinition::getPowerPerFloorArea(double floorArea, double numPeople) const {
514
1/1
✓ Branch 3 taken 100 times.
104 return getImpl<detail::LightsDefinition_Impl>()->getPowerPerFloorArea(floorArea, numPeople);
515 }
516
517 17 double LightsDefinition::getPowerPerPerson(double floorArea, double numPeople) const {
518
1/1
✓ Branch 3 taken 13 times.
17 return getImpl<detail::LightsDefinition_Impl>()->getPowerPerPerson(floorArea, numPeople);
519 }
520
521 ✗ bool LightsDefinition::setDesignLevelCalculationMethod(const std::string& method, double floorArea, double numPeople) {
522 ✗ return getImpl<detail::LightsDefinition_Impl>()->setDesignLevelCalculationMethod(method, floorArea, numPeople);
523 }
524
525 /// @cond
526
1/1
✓ Branch 3 taken 592 times.
592 LightsDefinition::LightsDefinition(std::shared_ptr<detail::LightsDefinition_Impl> impl) : SpaceLoadDefinition(std::move(impl)) {}
527 /// @endcond
528
529 } // namespace model
530 } // namespace openstudio
531