GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 34.2% 78 / 0 / 228
Functions: 47.5% 28 / 0 / 59
Branches: 24.2% 52 / 0 / 215

src/model/HotWaterEquipment.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 "HotWaterEquipment.hpp"
7 #include "HotWaterEquipment_Impl.hpp"
8
9 #include "HotWaterEquipmentDefinition.hpp"
10 #include "HotWaterEquipmentDefinition_Impl.hpp"
11 #include "Schedule.hpp"
12 #include "Schedule_Impl.hpp"
13 #include "Space.hpp"
14 #include "Space_Impl.hpp"
15 #include "SpaceType.hpp"
16 #include "SpaceType_Impl.hpp"
17 #include "DefaultScheduleSet.hpp"
18 #include "DefaultScheduleSet_Impl.hpp"
19 #include "LifeCycleCost.hpp"
20 #include "Model.hpp"
21
22 #include <utilities/idd/OS_HotWaterEquipment_FieldEnums.hxx>
23 #include <utilities/idd/IddEnums.hxx>
24
25 #include "../utilities/core/Assert.hpp"
26
27 namespace openstudio {
28 namespace model {
29
30 namespace detail {
31
32 7 HotWaterEquipment_Impl::HotWaterEquipment_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
33 7 : SpaceLoadInstance_Impl(idfObject, model, keepHandle) {
34
4/6
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 13 not taken.
7 OS_ASSERT(idfObject.iddObject().type() == HotWaterEquipment::iddObjectType());
35 7 }
36
37 ✗ HotWaterEquipment_Impl::HotWaterEquipment_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle)
38 ✗ : SpaceLoadInstance_Impl(other, model, keepHandle) {
39 ✗ OS_ASSERT(other.iddObject().type() == HotWaterEquipment::iddObjectType());
40 ✗ }
41
42 4 HotWaterEquipment_Impl::HotWaterEquipment_Impl(const HotWaterEquipment_Impl& other, Model_Impl* model, bool keepHandle)
43 4 : SpaceLoadInstance_Impl(other, model, keepHandle) {}
44
45 ✗ const std::vector<std::string>& HotWaterEquipment_Impl::outputVariableNames() const {
46 static const std::vector<std::string> result{
47 "Hot Water Equipment District Heating Rate",
48 "Hot Water Equipment District Heating Energy",
49 "Hot Water Equipment Radiant Heating Energy",
50 "Hot Water Equipment Radiant Heating Rate",
51 "Hot Water Equipment Convective Heating Energy",
52 "Hot Water Equipment Convective Heating Rate",
53 "Hot Water Equipment Latent Gain Energy",
54 "Hot Water Equipment Latent Gain Rate",
55 "Hot Water Equipment Lost Heat Energy",
56 "Hot Water Equipment Lost Heat Rate",
57 "Hot Water Equipment Total Heating Energy",
58 "Hot Water Equipment Total Heating Rate"
59
60 // Reported in ThermalZone
61 //"Zone Hot Water Equipment District Heating Rate",
62 //"Zone Hot Water Equipment District Heating Energy",
63 //"Zone Hot Water Equipment Radiant Heating Energy",
64 //"Zone Hot Water Equipment Radiant Heating Rate",
65 //"Zone Hot Water Equipment Convective Heating Energy",
66 //"Zone Hot Water Equipment Convective Heating Rate",
67 //"Zone Hot Water Equipment Latent Gain Energy",
68 //"Zone Hot Water Equipment Latent Gain Rate",
69 //"Zone Hot Water Equipment Lost Heat Energy",
70 //"Zone Hot Water Equipment Lost Heat Rate",
71 //"Zone Hot Water Equipment Total Heating Energy",
72 //"Zone Hot Water Equipment Total Heating Rate"
73 ✗ };
74 ✗ return result;
75 ✗ }
76
77 ✗ IddObjectType HotWaterEquipment_Impl::iddObjectType() const {
78 ✗ return HotWaterEquipment::iddObjectType();
79 }
80
81 ✗ std::vector<ScheduleTypeKey> HotWaterEquipment_Impl::getScheduleTypeKeys(const Schedule& schedule) const {
82 ✗ std::vector<ScheduleTypeKey> result;
83 ✗ UnsignedVector fieldIndices = getSourceIndices(schedule.handle());
84 ✗ UnsignedVector::const_iterator b(fieldIndices.begin());
85 ✗ UnsignedVector::const_iterator e(fieldIndices.end());
86 ✗ if (std::find(b, e, OS_HotWaterEquipmentFields::ScheduleName) != e) {
87 ✗ result.push_back(ScheduleTypeKey("HotWaterEquipment", "Hot Water Equipment"));
88 }
89 ✗ return result;
90 ✗ }
91
92 ✗ bool HotWaterEquipment_Impl::hardSize() {
93 ✗ boost::optional<Space> space = this->space();
94 ✗ if (!space) {
95 ✗ return false;
96 }
97
98 ✗ this->makeUnique();
99
100 ✗ HotWaterEquipmentDefinition hotWaterEquipmentDefinition = this->hotWaterEquipmentDefinition();
101 ✗ for (LifeCycleCost& cost : hotWaterEquipmentDefinition.lifeCycleCosts()) {
102 ✗ cost.convertToCostPerEach();
103 ✗ }
104
105 ✗ boost::optional<double> designLevel = hotWaterEquipmentDefinition.designLevel();
106 ✗ if (designLevel) {
107 ✗ return true;
108 }
109
110 ✗ boost::optional<double> wattsperSpaceFloorArea = hotWaterEquipmentDefinition.wattsperSpaceFloorArea();
111 ✗ if (wattsperSpaceFloorArea) {
112 ✗ return hotWaterEquipmentDefinition.setDesignLevel(*wattsperSpaceFloorArea * space->floorArea());
113 }
114
115 ✗ boost::optional<double> wattsperPerson = hotWaterEquipmentDefinition.wattsperPerson();
116 ✗ if (wattsperPerson) {
117 ✗ return hotWaterEquipmentDefinition.setDesignLevel(*wattsperPerson * space->numberOfPeople());
118 }
119
120 ✗ return false;
121 ✗ }
122
123 ✗ bool HotWaterEquipment_Impl::hardApplySchedules() {
124 ✗ bool result = false;
125 ✗ boost::optional<Schedule> schedule = this->schedule();
126 ✗ if (schedule) {
127 ✗ result = this->setSchedule(*schedule);
128 }
129 ✗ return result;
130 ✗ }
131
132 49 double HotWaterEquipment_Impl::multiplier() const {
133
1/1
✓ Branch 1 taken 49 times.
49 boost::optional<double> value = getDouble(OS_HotWaterEquipmentFields::Multiplier, true);
134
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 49 times.
✗ Branch 4 not taken.
49 OS_ASSERT(value);
135
1/1
✓ Branch 1 taken 49 times.
98 return value.get();
136 }
137
138 ✗ bool HotWaterEquipment_Impl::isMultiplierDefaulted() const {
139 ✗ return isEmpty(OS_HotWaterEquipmentFields::Multiplier);
140 }
141
142 ✗ bool HotWaterEquipment_Impl::isAbsolute() const {
143 ✗ HotWaterEquipmentDefinition definition = hotWaterEquipmentDefinition();
144 ✗ if (definition.designLevel()) {
145 ✗ return true;
146 }
147 ✗ return false;
148 ✗ }
149
150 4 std::string HotWaterEquipment_Impl::endUseSubcategory() const {
151
1/1
✓ Branch 1 taken 4 times.
4 boost::optional<std::string> value = getString(OS_HotWaterEquipmentFields::EndUseSubcategory, true);
152
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 4 not taken.
4 OS_ASSERT(value);
153
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
8 return value.get();
154 4 }
155
156 4 bool HotWaterEquipment_Impl::isEndUseSubcategoryDefaulted() const {
157 4 return isEmpty(OS_HotWaterEquipmentFields::EndUseSubcategory);
158 }
159
160 3 bool HotWaterEquipment_Impl::setMultiplier(double multiplier) {
161 3 bool result = setDouble(OS_HotWaterEquipmentFields::Multiplier, multiplier);
162 3 return result;
163 }
164
165 ✗ void HotWaterEquipment_Impl::resetMultiplier() {
166 ✗ bool result = setString(OS_HotWaterEquipmentFields::Multiplier, "");
167 ✗ OS_ASSERT(result);
168 ✗ }
169
170 8 bool HotWaterEquipment_Impl::setEndUseSubcategory(const std::string& endUseSubcategory) {
171 8 bool result = setString(OS_HotWaterEquipmentFields::EndUseSubcategory, endUseSubcategory);
172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 OS_ASSERT(result);
173 8 return result;
174 }
175
176 ✗ void HotWaterEquipment_Impl::resetEndUseSubcategory() {
177 ✗ bool result = setString(OS_HotWaterEquipmentFields::EndUseSubcategory, "");
178 ✗ OS_ASSERT(result);
179 ✗ }
180
181 20 int HotWaterEquipment_Impl::spaceIndex() const {
182 20 return OS_HotWaterEquipmentFields::SpaceorSpaceTypeName;
183 }
184
185 56 int HotWaterEquipment_Impl::definitionIndex() const {
186 56 return OS_HotWaterEquipmentFields::HotWaterEquipmentDefinitionName;
187 }
188
189 4 boost::optional<Schedule> HotWaterEquipment_Impl::schedule() const {
190
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 boost::optional<Schedule> result = getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_HotWaterEquipmentFields::ScheduleName);
191
2/2
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1 time.
4 if (!result) {
192 // search upwards
193
1/1
✓ Branch 1 taken 3 times.
3 OptionalSpace space = this->space();
194
1/1
✓ Branch 1 taken 3 times.
3 OptionalSpaceType spaceType = this->spaceType();
195
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (space) {
196
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 result = space->getDefaultSchedule(DefaultScheduleType::HotWaterEquipmentSchedule);
197 ✗ } else if (spaceType) {
198 ✗ result = spaceType->getDefaultSchedule(DefaultScheduleType::HotWaterEquipmentSchedule);
199 }
200 3 }
201 4 return result;
202 ✗ }
203
204 ✗ bool HotWaterEquipment_Impl::isScheduleDefaulted() const {
205 ✗ return isEmpty(OS_HotWaterEquipmentFields::ScheduleName);
206 }
207
208 1 bool HotWaterEquipment_Impl::setSchedule(Schedule& schedule) {
209
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
4 bool result = ModelObject_Impl::setSchedule(OS_HotWaterEquipmentFields::ScheduleName, "HotWaterEquipment", "Hot Water Equipment", schedule);
210 1 return result;
211 }
212
213 ✗ void HotWaterEquipment_Impl::resetSchedule() {
214 ✗ bool result = setString(OS_HotWaterEquipmentFields::ScheduleName, "");
215 ✗ OS_ASSERT(result);
216 ✗ }
217
218 49 HotWaterEquipmentDefinition HotWaterEquipment_Impl::hotWaterEquipmentDefinition() const {
219
2/2
✓ Branch 1 taken 49 times.
✓ Branch 4 taken 49 times.
49 return this->definition().cast<HotWaterEquipmentDefinition>();
220 }
221
222 ✗ bool HotWaterEquipment_Impl::setHotWaterEquipmentDefinition(const HotWaterEquipmentDefinition& definition) {
223 ✗ return this->setPointer(this->definitionIndex(), definition.handle());
224 }
225
226 ✗ bool HotWaterEquipment_Impl::setDefinition(const SpaceLoadDefinition& definition) {
227 ✗ bool result = false;
228 ✗ boost::optional<HotWaterEquipmentDefinition> hotWaterEquipmentDefinition = definition.optionalCast<HotWaterEquipmentDefinition>();
229 ✗ if (hotWaterEquipmentDefinition) {
230 ✗ result = setHotWaterEquipmentDefinition(*hotWaterEquipmentDefinition);
231 }
232 ✗ return result;
233 ✗ }
234
235 ✗ boost::optional<double> HotWaterEquipment_Impl::designLevel() const {
236 ✗ OptionalDouble result = hotWaterEquipmentDefinition().designLevel();
237 ✗ if (result) {
238 ✗ return result.get() * multiplier();
239 }
240 ✗ return result;
241 }
242
243 ✗ boost::optional<double> HotWaterEquipment_Impl::powerPerFloorArea() const {
244 ✗ OptionalDouble result = hotWaterEquipmentDefinition().wattsperSpaceFloorArea();
245 ✗ if (result) {
246 ✗ return result.get() * multiplier();
247 }
248 ✗ return result;
249 }
250
251 ✗ boost::optional<double> HotWaterEquipment_Impl::powerPerPerson() const {
252 ✗ OptionalDouble result = hotWaterEquipmentDefinition().wattsperPerson();
253 ✗ if (result) {
254 ✗ return result.get() * multiplier();
255 }
256 ✗ return result;
257 }
258
259 35 double HotWaterEquipment_Impl::getDesignLevel(double floorArea, double numPeople) const {
260
3/3
✓ Branch 1 taken 35 times.
✓ Branch 4 taken 35 times.
✓ Branch 7 taken 35 times.
35 return hotWaterEquipmentDefinition().getDesignLevel(floorArea, numPeople) * multiplier();
261 }
262
263 5 double HotWaterEquipment_Impl::getPowerPerFloorArea(double floorArea, double numPeople) const {
264
3/3
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
5 return hotWaterEquipmentDefinition().getPowerPerFloorArea(floorArea, numPeople) * multiplier();
265 }
266
267 5 double HotWaterEquipment_Impl::getPowerPerPerson(double floorArea, double numPeople) const {
268
3/3
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
5 return hotWaterEquipmentDefinition().getPowerPerPerson(floorArea, numPeople) * multiplier();
269 }
270
271 ✗ boost::optional<ModelObject> HotWaterEquipment_Impl::hotWaterEquipmentDefinitionAsModelObject() const {
272 ✗ OptionalModelObject result = hotWaterEquipmentDefinition();
273 ✗ return result;
274 }
275
276 ✗ boost::optional<ModelObject> HotWaterEquipment_Impl::scheduleAsModelObject() const {
277 ✗ OptionalModelObject result;
278 ✗ OptionalSchedule intermediate = schedule();
279 ✗ if (intermediate) {
280 ✗ result = *intermediate;
281 }
282 ✗ return result;
283 ✗ }
284
285 ✗ bool HotWaterEquipment_Impl::setHotWaterEquipmentDefinitionAsModelObject(const boost::optional<ModelObject>& modelObject) {
286 ✗ if (modelObject) {
287 ✗ OptionalHotWaterEquipmentDefinition intermediate = modelObject->optionalCast<HotWaterEquipmentDefinition>();
288 ✗ if (intermediate) {
289 ✗ return setHotWaterEquipmentDefinition(*intermediate);
290 }
291 ✗ }
292 ✗ return false;
293 }
294
295 ✗ bool HotWaterEquipment_Impl::setScheduleAsModelObject(const boost::optional<ModelObject>& modelObject) {
296 ✗ if (modelObject) {
297 ✗ OptionalSchedule intermediate = modelObject->optionalCast<Schedule>();
298 ✗ if (intermediate) {
299 ✗ Schedule schedule(*intermediate);
300 ✗ return setSchedule(schedule);
301 ✗ } else {
302 ✗ return false;
303 }
304 ✗ } else {
305 ✗ resetSchedule();
306 }
307 ✗ return true;
308 }
309
310 ✗ std::vector<EMSActuatorNames> HotWaterEquipment_Impl::emsActuatorNames() const {
311 ✗ std::vector<EMSActuatorNames> actuators{{"HotWaterEquipment", "District Heating Power Level"}};
312 ✗ return actuators;
313 ✗ }
314
315 ✗ std::vector<std::string> HotWaterEquipment_Impl::emsInternalVariableNames() const {
316 ✗ std::vector<std::string> types{"Process District Heat Design Level"};
317 ✗ return types;
318 ✗ }
319
320 } // namespace detail
321
322 7 HotWaterEquipment::HotWaterEquipment(const HotWaterEquipmentDefinition& hotWaterEquipmentDefinition)
323 7 : SpaceLoadInstance(HotWaterEquipment::iddObjectType(), hotWaterEquipmentDefinition) {
324
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 5 not taken.
7 OS_ASSERT(getImpl<detail::HotWaterEquipment_Impl>());
325
326 /*
327 *Schedule sch = this->model().alwaysOnDiscreteSchedule();
328 *bool test = this->setSchedule(sch);
329 *OS_ASSERT(test);
330 *test = this->setMultiplier(1.0);
331 *OS_ASSERT(test);
332 */
333
2/2
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
7 bool test = this->setEndUseSubcategory("General");
334
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 3 not taken.
7 OS_ASSERT(test);
335 7 }
336
337 10873 IddObjectType HotWaterEquipment::iddObjectType() {
338
1/1
✓ Branch 1 taken 10873 times.
10873 IddObjectType result(IddObjectType::OS_HotWaterEquipment);
339 10873 return result;
340 }
341
342 4 std::string HotWaterEquipment::endUseSubcategory() const {
343
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::HotWaterEquipment_Impl>()->endUseSubcategory();
344 }
345
346 4 bool HotWaterEquipment::isEndUseSubcategoryDefaulted() const {
347
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::HotWaterEquipment_Impl>()->isEndUseSubcategoryDefaulted();
348 }
349
350 3 bool HotWaterEquipment::setMultiplier(double multiplier) {
351
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::HotWaterEquipment_Impl>()->setMultiplier(multiplier);
352 }
353
354 ✗ void HotWaterEquipment::resetMultiplier() {
355 ✗ getImpl<detail::HotWaterEquipment_Impl>()->resetMultiplier();
356 ✗ }
357
358 8 bool HotWaterEquipment::setEndUseSubcategory(const std::string& endUseSubcategory) {
359
1/1
✓ Branch 3 taken 8 times.
8 return getImpl<detail::HotWaterEquipment_Impl>()->setEndUseSubcategory(endUseSubcategory);
360 }
361
362 ✗ void HotWaterEquipment::resetEndUseSubcategory() {
363 ✗ getImpl<detail::HotWaterEquipment_Impl>()->resetEndUseSubcategory();
364 ✗ }
365
366 4 boost::optional<Schedule> HotWaterEquipment::schedule() const {
367
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::HotWaterEquipment_Impl>()->schedule();
368 }
369
370 ✗ bool HotWaterEquipment::isScheduleDefaulted() const {
371 ✗ return getImpl<detail::HotWaterEquipment_Impl>()->isScheduleDefaulted();
372 }
373
374 1 bool HotWaterEquipment::setSchedule(Schedule& schedule) {
375
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::HotWaterEquipment_Impl>()->setSchedule(schedule);
376 }
377
378 ✗ void HotWaterEquipment::resetSchedule() {
379 ✗ getImpl<detail::HotWaterEquipment_Impl>()->resetSchedule();
380 ✗ }
381
382 4 HotWaterEquipmentDefinition HotWaterEquipment::hotWaterEquipmentDefinition() const {
383
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::HotWaterEquipment_Impl>()->hotWaterEquipmentDefinition();
384 }
385
386 ✗ bool HotWaterEquipment::setHotWaterEquipmentDefinition(const HotWaterEquipmentDefinition& hotWaterEquipmentDefinition) {
387 ✗ return getImpl<detail::HotWaterEquipment_Impl>()->setHotWaterEquipmentDefinition(hotWaterEquipmentDefinition);
388 }
389
390 ✗ boost::optional<double> HotWaterEquipment::designLevel() const {
391 ✗ return getImpl<detail::HotWaterEquipment_Impl>()->designLevel();
392 }
393
394 ✗ boost::optional<double> HotWaterEquipment::powerPerFloorArea() const {
395 ✗ return getImpl<detail::HotWaterEquipment_Impl>()->powerPerFloorArea();
396 }
397
398 ✗ boost::optional<double> HotWaterEquipment::powerPerPerson() const {
399 ✗ return getImpl<detail::HotWaterEquipment_Impl>()->powerPerPerson();
400 }
401
402 35 double HotWaterEquipment::getDesignLevel(double floorArea, double numPeople) const {
403
1/1
✓ Branch 3 taken 35 times.
35 return getImpl<detail::HotWaterEquipment_Impl>()->getDesignLevel(floorArea, numPeople);
404 }
405
406 5 double HotWaterEquipment::getPowerPerFloorArea(double floorArea, double numPeople) const {
407
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::HotWaterEquipment_Impl>()->getPowerPerFloorArea(floorArea, numPeople);
408 }
409
410 5 double HotWaterEquipment::getPowerPerPerson(double floorArea, double numPeople) const {
411
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::HotWaterEquipment_Impl>()->getPowerPerPerson(floorArea, numPeople);
412 }
413
414 /// @cond
415
1/1
✓ Branch 3 taken 57 times.
57 HotWaterEquipment::HotWaterEquipment(std::shared_ptr<detail::HotWaterEquipment_Impl> impl) : SpaceLoadInstance(std::move(impl)) {}
416 /// @endcond
417
418 } // namespace model
419 } // namespace openstudio
420