GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 84.1% 53 / 0 / 63
Functions: 100.0% 1 / 0 / 1
Branches: 60.6% 83 / 0 / 137

src/energyplus/ReverseTranslator/ReverseTranslateElectricEquipment.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/ElectricEquipment.hpp"
9 #include "../../model/ElectricEquipment_Impl.hpp"
10 #include "../../model/ElectricEquipmentDefinition.hpp"
11 #include "../../model/ElectricEquipmentDefinition_Impl.hpp"
12 #include "../../model/Space.hpp"
13 #include "../../model/Space_Impl.hpp"
14 #include "../../model/SpaceType.hpp"
15 #include "../../model/SpaceType_Impl.hpp"
16 #include "../../model/Schedule.hpp"
17 #include "../../model/Schedule_Impl.hpp"
18
19 #include <utilities/idd/ElectricEquipment_FieldEnums.hxx>
20 #include "../../utilities/idd/IddEnums.hpp"
21 #include <utilities/idd/IddEnums.hxx>
22
23 #include "../../utilities/core/Assert.hpp"
24
25 using namespace openstudio::model;
26
27 namespace openstudio {
28
29 namespace energyplus {
30
31 36 OptionalModelObject ReverseTranslator::translateElectricEquipment(const WorkspaceObject& workspaceObject) {
32
4/5
✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
✓ Branch 7 taken 36 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 36 times.
36 if (workspaceObject.iddObject().type() != IddObjectType::ElectricEquipment) {
33 ✗ LOG(Error, "WorkspaceObject is not IddObjectType: ElectricEquipment");
34 ✗ return boost::none;
35 }
36
37 // create the definition
38
1/1
✓ Branch 1 taken 36 times.
36 openstudio::model::ElectricEquipmentDefinition definition(m_model);
39
40
1/1
✓ Branch 1 taken 36 times.
36 OptionalString s = workspaceObject.name();
41
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (s) {
42
3/3
✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
✓ Branch 7 taken 36 times.
36 definition.setName(*s + " Definition");
43 }
44
45
1/1
✓ Branch 1 taken 36 times.
36 s = workspaceObject.getString(openstudio::ElectricEquipmentFields::DesignLevelCalculationMethod, true);
46
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 4 not taken.
36 OS_ASSERT(s);
47
48 36 OptionalDouble d;
49
5/5
✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
✓ Branch 7 taken 36 times.
✓ Branch 10 taken 8 times.
✓ Branch 11 taken 28 times.
108 if (istringEqual("EquipmentLevel", *s)) {
50
1/1
✓ Branch 1 taken 8 times.
8 d = workspaceObject.getDouble(openstudio::ElectricEquipmentFields::DesignLevel);
51
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (d) {
52
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
8 definition.setDesignLevel(*d);
53 } else {
54 ✗ LOG(Error, "EquipmentLevel value not found for workspace object " << workspaceObject);
55 }
56
4/5
✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
✓ Branch 7 taken 28 times.
✓ Branch 10 taken 28 times.
✗ Branch 11 not taken.
84 } else if (istringEqual("Watts/Area", *s)) {
57
1/1
✓ Branch 1 taken 28 times.
28 d = workspaceObject.getDouble(openstudio::ElectricEquipmentFields::WattsperFloorArea);
58
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if (d) {
59
2/2
✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
28 definition.setWattsperSpaceFloorArea(*d);
60 } else {
61 ✗ LOG(Error, "Watts/Area value not found for workspace object " << workspaceObject);
62 }
63 ✗ } else if (istringEqual("Watts/Person", *s)) {
64 ✗ d = workspaceObject.getDouble(openstudio::ElectricEquipmentFields::WattsperPerson);
65 ✗ if (d) {
66 ✗ definition.setWattsperPerson(*d);
67 } else {
68 ✗ LOG(Error, "Watts/Person value not found for workspace object " << workspaceObject);
69 }
70 } else {
71 ✗ LOG(Error, "Unknown DesignLevelCalculationMethod value for workspace object" << workspaceObject);
72 }
73
74
1/1
✓ Branch 1 taken 36 times.
36 d = workspaceObject.getDouble(openstudio::ElectricEquipmentFields::FractionLatent);
75
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 7 times.
36 if (d) {
76
2/2
✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
29 definition.setFractionLatent(*d);
77 }
78
79
1/1
✓ Branch 1 taken 36 times.
36 d = workspaceObject.getDouble(openstudio::ElectricEquipmentFields::FractionRadiant);
80
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 7 times.
36 if (d) {
81
2/2
✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
29 definition.setFractionRadiant(*d);
82 }
83
84
1/1
✓ Branch 1 taken 36 times.
36 d = workspaceObject.getDouble(openstudio::ElectricEquipmentFields::FractionLost);
85
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 7 times.
36 if (d) {
86
2/2
✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
29 definition.setFractionLost(*d);
87 }
88
89 // create the instance
90
1/1
✓ Branch 1 taken 36 times.
36 ElectricEquipment electricEquipment(definition);
91
92
1/1
✓ Branch 1 taken 36 times.
36 s = workspaceObject.name();
93
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (s) {
94
2/2
✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
36 electricEquipment.setName(*s);
95 }
96
97
1/1
✓ Branch 1 taken 36 times.
36 OptionalWorkspaceObject target = workspaceObject.getTarget(openstudio::ElectricEquipmentFields::ZoneorZoneListorSpaceorSpaceListName);
98
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (target) {
99
2/2
✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
36 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
100
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (modelObject) {
101
4/4
✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
✓ Branch 7 taken 29 times.
✓ Branch 8 taken 7 times.
72 if (modelObject->optionalCast<Space>()) {
102
3/3
✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 7 taken 29 times.
29 electricEquipment.setSpace(modelObject->cast<Space>());
103
3/4
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
14 } else if (modelObject->optionalCast<SpaceType>()) {
104
3/3
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
7 electricEquipment.setSpaceType(modelObject->cast<SpaceType>());
105 }
106 }
107 36 }
108
109
1/1
✓ Branch 1 taken 36 times.
36 target = workspaceObject.getTarget(openstudio::ElectricEquipmentFields::ScheduleName);
110
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (target) {
111
2/2
✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
36 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
112
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (modelObject) {
113
3/4
✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
✓ Branch 6 taken 36 times.
✗ Branch 7 not taken.
72 if (OptionalSchedule intermediate = modelObject->optionalCast<Schedule>()) {
114
2/2
✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
36 Schedule schedule = *intermediate;
115
1/1
✓ Branch 1 taken 36 times.
36 electricEquipment.setSchedule(schedule);
116 72 }
117 }
118 36 }
119
120
1/1
✓ Branch 1 taken 36 times.
36 s = workspaceObject.getString(openstudio::ElectricEquipmentFields::EndUseSubcategory);
121
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (s) {
122
2/2
✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
36 electricEquipment.setEndUseSubcategory(*s);
123 }
124
125
1/1
✓ Branch 1 taken 36 times.
36 return electricEquipment;
126 36 }
127
128 } // namespace energyplus
129
130 } // namespace openstudio
131