GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 40.9% 92 / 0 / 225
Functions: 55.6% 35 / 0 / 63
Branches: 30.6% 66 / 0 / 216

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