GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 84.4% 65 / 0 / 77
Functions: 100.0% 1 / 0 / 1
Branches: 66.1% 109 / 0 / 165

src/energyplus/ReverseTranslator/ReverseTranslateLights.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/Lights.hpp"
9 #include "../../model/Lights_Impl.hpp"
10 #include "../../model/LightsDefinition.hpp"
11 #include "../../model/LightsDefinition_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/Lights_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::translateLights(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::Lights) {
33 ✗ LOG(Error, "WorkspaceObject " << workspaceObject.briefDescription() << " is not IddObjectType: Lights");
34 ✗ return boost::none;
35 }
36
37 // create the definition
38
1/1
✓ Branch 1 taken 36 times.
36 openstudio::model::LightsDefinition 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::LightsFields::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("LightingLevel", *s)) {
50
1/1
✓ Branch 1 taken 8 times.
8 d = workspaceObject.getDouble(openstudio::LightsFields::LightingLevel);
51
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 if (d) {
52
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 definition.setLightingLevel(*d);
53 } else {
54
6/6
✓ 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 16 taken 2 times.
2 LOG(Error, "LightingLevel 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::LightsFields::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::LightsFields::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::LightsFields::ReturnAirFraction);
75
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 9 times.
36 if (d) {
76
2/2
✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
27 definition.setReturnAirFraction(*d);
77 }
78
79
1/1
✓ Branch 1 taken 36 times.
36 d = workspaceObject.getDouble(openstudio::LightsFields::FractionRadiant);
80
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 9 times.
36 if (d) {
81
2/2
✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
27 definition.setFractionRadiant(*d);
82 }
83
84
1/1
✓ Branch 1 taken 36 times.
36 d = workspaceObject.getDouble(openstudio::LightsFields::FractionVisible);
85
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 9 times.
36 if (d) {
86
2/2
✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
27 definition.setFractionVisible(*d);
87 }
88
89
1/1
✓ Branch 1 taken 36 times.
36 s = workspaceObject.getString(openstudio::LightsFields::ReturnAirFractionCalculatedfromPlenumTemperature);
90
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 10 times.
36 if (s) {
91
4/5
✓ Branch 1 taken 26 times.
✓ Branch 4 taken 26 times.
✓ Branch 7 taken 26 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 26 times.
78 if (istringEqual("Yes", *s)) {
92 ✗ definition.setReturnAirFractionCalculatedfromPlenumTemperature(true);
93 } else {
94
1/1
✓ Branch 1 taken 26 times.
26 definition.setReturnAirFractionCalculatedfromPlenumTemperature(false);
95 }
96 }
97
98
1/1
✓ Branch 1 taken 36 times.
36 d = workspaceObject.getDouble(openstudio::LightsFields::ReturnAirFractionFunctionofPlenumTemperatureCoefficient1);
99
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if (d) {
100 ✗ definition.setReturnAirFractionFunctionofPlenumTemperatureCoefficient1(*d);
101 }
102
103
1/1
✓ Branch 1 taken 36 times.
36 d = workspaceObject.getDouble(openstudio::LightsFields::ReturnAirFractionFunctionofPlenumTemperatureCoefficient2);
104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if (d) {
105 ✗ definition.setReturnAirFractionFunctionofPlenumTemperatureCoefficient2(*d);
106 }
107
108 // create the instance
109
1/1
✓ Branch 1 taken 36 times.
36 Lights lights(definition);
110
111
1/1
✓ Branch 1 taken 36 times.
36 s = workspaceObject.name();
112
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (s) {
113
2/2
✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
36 lights.setName(*s);
114 }
115
116
1/1
✓ Branch 1 taken 36 times.
36 OptionalWorkspaceObject target = workspaceObject.getTarget(openstudio::LightsFields::ZoneorZoneListorSpaceorSpaceListName);
117
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (target) {
118
2/2
✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
36 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
119
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (modelObject) {
120
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>()) {
121
3/3
✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 7 taken 29 times.
29 lights.setSpace(modelObject->cast<Space>());
122
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>()) {
123
3/3
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
7 lights.setSpaceType(modelObject->cast<SpaceType>());
124 }
125 }
126 36 }
127
128
1/1
✓ Branch 1 taken 36 times.
36 target = workspaceObject.getTarget(openstudio::LightsFields::ScheduleName);
129
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 2 times.
36 if (target) {
130
2/2
✓ Branch 1 taken 34 times.
✓ Branch 4 taken 34 times.
34 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
131
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if (modelObject) {
132
3/4
✓ Branch 1 taken 34 times.
✓ Branch 4 taken 34 times.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
68 if (OptionalSchedule intermediate = modelObject->optionalCast<Schedule>()) {
133
2/2
✓ Branch 1 taken 34 times.
✓ Branch 4 taken 34 times.
34 Schedule schedule(*intermediate);
134
1/1
✓ Branch 1 taken 34 times.
34 lights.setSchedule(schedule);
135 68 }
136 }
137 34 }
138
139
1/1
✓ Branch 1 taken 36 times.
36 d = workspaceObject.getDouble(openstudio::LightsFields::FractionReplaceable);
140
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 2 times.
36 if (d) {
141
2/2
✓ Branch 1 taken 34 times.
✓ Branch 4 taken 34 times.
34 lights.setFractionReplaceable(*d);
142 }
143
144
1/1
✓ Branch 1 taken 36 times.
36 s = workspaceObject.getString(openstudio::LightsFields::EndUseSubcategory);
145
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 2 times.
36 if (s) {
146
2/2
✓ Branch 1 taken 34 times.
✓ Branch 4 taken 34 times.
34 lights.setEndUseSubcategory(*s);
147 }
148
149
1/1
✓ Branch 1 taken 36 times.
36 return lights;
150 36 }
151
152 } // namespace energyplus
153
154 } // namespace openstudio
155