GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 89.8% 53 / 0 / 59
Functions: 100.0% 3 / 0 / 3
Branches: 75.0% 75 / 0 / 100

src/energyplus/ForwardTranslator/ForwardTranslateElectricEquipment.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 "../ForwardTranslator.hpp"
7
8 #include "../../model/Model.hpp"
9 #include "../../model/ElectricEquipment.hpp"
10 #include "../../model/ElectricEquipment_Impl.hpp"
11 #include "../../model/ElectricEquipmentDefinition.hpp"
12 #include "../../model/ElectricEquipmentDefinition_Impl.hpp"
13 #include "../../model/Space.hpp"
14 #include "../../model/Space_Impl.hpp"
15 #include "../../model/SpaceType.hpp"
16 #include "../../model/SpaceType_Impl.hpp"
17 #include "../../model/ThermalZone.hpp"
18 #include "../../model/ThermalZone_Impl.hpp"
19 #include "../../model/Schedule.hpp"
20 #include "../../model/Schedule_Impl.hpp"
21 #include "../../model/LifeCycleCost.hpp"
22
23 #include <utilities/idd/ElectricEquipment_FieldEnums.hxx>
24 #include <utilities/idd/ElectricEquipment_Instance_FieldEnums.hxx>
25 #include "../../utilities/idd/IddEnums.hpp"
26 #include <utilities/idd/IddEnums.hxx>
27
28 using namespace openstudio::model;
29
30 namespace openstudio {
31
32 namespace energyplus {
33
34 282 boost::optional<IdfObject> ForwardTranslator::translateElectricEquipment(ElectricEquipment& modelObject) {
35
2/2
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 257 times.
282 if (m_forwardTranslatorOptions.excludeSpaceLoadInstances()) {
36 25 return translateElectricEquipmentLegacy(modelObject);
37 }
38 257 return translateElectricEquipmentInstance(modelObject);
39 }
40
41 25 boost::optional<IdfObject> ForwardTranslator::translateElectricEquipmentLegacy(ElectricEquipment& modelObject) {
42
43
2/2
✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
25 IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::ElectricEquipment, modelObject);
44
45
2/4
✓ Branch 1 taken 25 times.
✗ Branch 7 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 25 times.
25 for (LifeCycleCost lifeCycleCost : modelObject.lifeCycleCosts()) {
46 ✗ translateAndMapModelObject(lifeCycleCost);
47 25 }
48
49
1/1
✓ Branch 1 taken 25 times.
25 ElectricEquipmentDefinition definition = modelObject.electricEquipmentDefinition();
50
51
1/1
✓ Branch 1 taken 25 times.
25 IdfObject parentIdfObject = getSpaceLoadParent(modelObject);
52
2/2
✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
25 idfObject.setString(ElectricEquipmentFields::ZoneorZoneListorSpaceorSpaceListName, parentIdfObject.nameString());
53
54
3/3
✓ Branch 1 taken 25 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 21 times.
50 if (boost::optional<Schedule> schedule = modelObject.schedule()) {
55
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 auto idf_schedule_ = translateAndMapModelObject(*schedule);
56
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 4 not taken.
4 OS_ASSERT(idf_schedule_);
57
3/3
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
4 idfObject.setString(ElectricEquipmentFields::ScheduleName, idf_schedule_->nameString());
58 29 }
59
60
2/2
✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
25 idfObject.setString(ElectricEquipmentFields::DesignLevelCalculationMethod, definition.designLevelCalculationMethod());
61
62
1/1
✓ Branch 1 taken 25 times.
25 double multiplier = modelObject.multiplier();
63
64
1/1
✓ Branch 1 taken 25 times.
25 OptionalDouble d = definition.designLevel();
65
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 8 times.
25 if (d) {
66
2/2
✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
17 idfObject.setDouble(ElectricEquipmentFields::DesignLevel, (*d) * multiplier);
67 }
68
69
1/1
✓ Branch 1 taken 25 times.
25 d = definition.wattsperSpaceFloorArea();
70
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 17 times.
25 if (d) {
71
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
8 idfObject.setDouble(ElectricEquipmentFields::WattsperFloorArea, (*d) * multiplier);
72 }
73
74
1/1
✓ Branch 1 taken 25 times.
25 d = definition.wattsperPerson();
75
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if (d) {
76 ✗ idfObject.setDouble(ElectricEquipmentFields::WattsperPerson, (*d) * multiplier);
77 }
78
79
2/3
✓ Branch 1 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25 times.
25 if (!definition.isFractionLatentDefaulted()) {
80 ✗ idfObject.setDouble(ElectricEquipmentFields::FractionLatent, definition.fractionLatent());
81 }
82
83
2/3
✓ Branch 1 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25 times.
25 if (!definition.isFractionRadiantDefaulted()) {
84 ✗ idfObject.setDouble(ElectricEquipmentFields::FractionRadiant, definition.fractionRadiant());
85 }
86
87
2/3
✓ Branch 1 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25 times.
25 if (!definition.isFractionLostDefaulted()) {
88 ✗ idfObject.setDouble(ElectricEquipmentFields::FractionLost, definition.fractionLost());
89 }
90
91
2/3
✓ Branch 1 taken 25 times.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
25 if (!modelObject.isEndUseSubcategoryDefaulted()) {
92
2/2
✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
25 idfObject.setString(ElectricEquipmentFields::EndUseSubcategory, modelObject.endUseSubcategory());
93 }
94
95
1/1
✓ Branch 1 taken 25 times.
50 return idfObject;
96 25 }
97
98 257 boost::optional<IdfObject> ForwardTranslator::translateElectricEquipmentInstance(ElectricEquipment& modelObject) {
99
100
2/2
✓ Branch 1 taken 257 times.
✓ Branch 4 taken 257 times.
257 IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::ElectricEquipment_Instance, modelObject);
101
102
2/4
✓ Branch 1 taken 257 times.
✗ Branch 7 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 257 times.
257 for (LifeCycleCost lifeCycleCost : modelObject.lifeCycleCosts()) {
103 ✗ translateAndMapModelObject(lifeCycleCost);
104 257 }
105
106
1/1
✓ Branch 1 taken 257 times.
257 ElectricEquipmentDefinition definition = modelObject.electricEquipmentDefinition();
107
1/1
✓ Branch 1 taken 257 times.
257 auto definitionIdfObject_ = translateAndMapModelObject(definition);
108
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 257 times.
✗ Branch 4 not taken.
257 OS_ASSERT(definitionIdfObject_);
109
3/3
✓ Branch 1 taken 257 times.
✓ Branch 4 taken 257 times.
✓ Branch 7 taken 257 times.
257 idfObject.setString(ElectricEquipment_InstanceFields::ElectricEquipmentDefinitionName, definitionIdfObject_->nameString());
110
111
1/1
✓ Branch 1 taken 257 times.
257 IdfObject parentIdfObject = getSpaceLoadParent(modelObject);
112
2/2
✓ Branch 1 taken 257 times.
✓ Branch 4 taken 257 times.
257 idfObject.setString(ElectricEquipment_InstanceFields::ZoneorZoneListorSpaceorSpaceListName, parentIdfObject.nameString());
113
114
3/3
✓ Branch 1 taken 257 times.
✓ Branch 3 taken 244 times.
✓ Branch 4 taken 13 times.
514 if (boost::optional<Schedule> schedule = modelObject.schedule()) {
115
2/2
✓ Branch 1 taken 244 times.
✓ Branch 4 taken 244 times.
244 auto idf_schedule_ = translateAndMapModelObject(*schedule);
116
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 244 times.
✗ Branch 4 not taken.
244 OS_ASSERT(idf_schedule_);
117
3/3
✓ Branch 1 taken 244 times.
✓ Branch 4 taken 244 times.
✓ Branch 7 taken 244 times.
244 idfObject.setString(ElectricEquipment_InstanceFields::ScheduleName, idf_schedule_->nameString());
118 501 }
119
120
2/2
✓ Branch 1 taken 257 times.
✓ Branch 4 taken 257 times.
257 idfObject.setDouble(ElectricEquipment_InstanceFields::Multiplier, modelObject.multiplier());
121
122
3/3
✓ Branch 1 taken 257 times.
✓ Branch 3 taken 87 times.
✓ Branch 4 taken 170 times.
257 if (!modelObject.isEndUseSubcategoryDefaulted()) {
123
2/2
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
87 idfObject.setString(ElectricEquipment_InstanceFields::EndUseSubcategory, modelObject.endUseSubcategory());
124 }
125
126
1/1
✓ Branch 1 taken 257 times.
514 return idfObject;
127 257 }
128
129 } // namespace energyplus
130
131 } // namespace openstudio
132