GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 86.4% 133 / 0 / 154
Functions: 100.0% 1 / 0 / 1
Branches: 57.2% 202 / 0 / 353

src/energyplus/ReverseTranslator/ReverseTranslatePeople.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/People.hpp"
9 #include "../../model/People_Impl.hpp"
10 #include "../../model/ComfortViewFactorAngles.hpp"
11 #include "../../model/PeopleDefinition.hpp"
12 #include "../../model/PeopleDefinition_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/Schedule.hpp"
18 #include "../../model/Schedule_Impl.hpp"
19
20 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
21
22 #include <utilities/idd/People_FieldEnums.hxx>
23 #include "../../utilities/idd/IddEnums.hpp"
24 #include <utilities/idd/IddEnums.hxx>
25
26 #include "../../utilities/core/Assert.hpp"
27
28 using namespace openstudio::model;
29
30 namespace openstudio {
31
32 namespace energyplus {
33
34 36 OptionalModelObject ReverseTranslator::translatePeople(const WorkspaceObject& workspaceObject) {
35
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::People) {
36 ✗ LOG(Error, "WorkspaceObject is not IddObjectType: People");
37 ✗ return boost::none;
38 }
39
40 // create the definition
41
1/1
✓ Branch 1 taken 36 times.
36 openstudio::model::PeopleDefinition definition(m_model);
42
43
1/1
✓ Branch 1 taken 36 times.
36 OptionalString s = workspaceObject.name();
44
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (s) {
45
3/3
✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
✓ Branch 7 taken 36 times.
36 definition.setName(*s + " Definition");
46 }
47
48
1/1
✓ Branch 1 taken 36 times.
36 s = workspaceObject.getString(openstudio::PeopleFields::NumberofPeopleCalculationMethod, true);
49
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 4 not taken.
36 OS_ASSERT(s);
50
51 36 OptionalDouble d;
52
5/5
✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
✓ Branch 7 taken 36 times.
✓ Branch 10 taken 7 times.
✓ Branch 11 taken 29 times.
108 if (istringEqual("People", *s)) {
53
1/1
✓ Branch 1 taken 7 times.
7 d = workspaceObject.getDouble(openstudio::PeopleFields::NumberofPeople);
54
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if (d) {
55
2/2
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
7 definition.setNumberofPeople(*d);
56 } else {
57 ✗ LOG(Error, "People value not found for workspace object " << workspaceObject);
58 }
59
5/5
✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 7 taken 29 times.
✓ Branch 10 taken 7 times.
✓ Branch 11 taken 22 times.
87 } else if (istringEqual("People/Area", *s)) {
60
1/1
✓ Branch 1 taken 7 times.
7 d = workspaceObject.getDouble(openstudio::PeopleFields::PeopleperFloorArea);
61
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if (d) {
62
2/2
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
7 definition.setPeopleperSpaceFloorArea(*d);
63 } else {
64 ✗ LOG(Error, "People/Area value not found for workspace object " << workspaceObject);
65 }
66
4/5
✓ Branch 1 taken 22 times.
✓ Branch 4 taken 22 times.
✓ Branch 7 taken 22 times.
✓ Branch 10 taken 22 times.
✗ Branch 11 not taken.
66 } else if (istringEqual("Area/Person", *s)) {
67
1/1
✓ Branch 1 taken 22 times.
22 d = workspaceObject.getDouble(openstudio::PeopleFields::FloorAreaperPerson);
68
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (d) {
69
2/2
✓ Branch 1 taken 22 times.
✓ Branch 4 taken 22 times.
22 definition.setSpaceFloorAreaperPerson(*d);
70 } else {
71 ✗ LOG(Error, "Area/Person value not found for workspace object " << workspaceObject);
72 }
73 } else {
74 ✗ LOG(Error, "Unknown NumberofPeopleCalculationMethod value for workspace object" << workspaceObject);
75 }
76
77
1/1
✓ Branch 1 taken 36 times.
36 d = workspaceObject.getDouble(openstudio::PeopleFields::FractionRadiant);
78
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 2 times.
36 if (d) {
79
2/2
✓ Branch 1 taken 34 times.
✓ Branch 4 taken 34 times.
34 definition.setFractionRadiant(*d);
80 }
81
82
1/1
✓ Branch 1 taken 36 times.
36 d = workspaceObject.getDouble(openstudio::PeopleFields::SensibleHeatFraction);
83
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 35 times.
36 if (d) {
84
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 definition.setSensibleHeatFraction(*d);
85 }
86
87
1/1
✓ Branch 1 taken 36 times.
36 d = workspaceObject.getDouble(openstudio::PeopleFields::CarbonDioxideGenerationRate);
88
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 9 times.
36 if (d) {
89
2/2
✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
27 definition.setCarbonDioxideGenerationRate(*d);
90 }
91
92
1/1
✓ Branch 1 taken 36 times.
36 s = workspaceObject.getString(openstudio::PeopleFields::EnableASHRAE55ComfortWarnings);
93
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 7 times.
36 if (s) {
94
5/5
✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 7 taken 29 times.
✓ Branch 10 taken 1 time.
✓ Branch 11 taken 28 times.
87 if (istringEqual("Yes", *s)) {
95
1/1
✓ Branch 1 taken 1 time.
1 definition.setEnableASHRAE55ComfortWarnings(true);
96 } else {
97
1/1
✓ Branch 1 taken 28 times.
28 definition.setEnableASHRAE55ComfortWarnings(false);
98 }
99 }
100
101
1/1
✓ Branch 1 taken 36 times.
36 s = workspaceObject.getString(openstudio::PeopleFields::MeanRadiantTemperatureCalculationType);
102
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 7 times.
36 if (s) {
103
2/2
✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
29 definition.setMeanRadiantTemperatureCalculationType(*s);
104 }
105
106 // As of 22.2.0, this is no longer possible to make this an extensible field
107 // because E+ added 3 regular fields at the end (eg: Ankle Level Velocity Schedule Name)
108
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 36 times.
288 for (unsigned i = PeopleFields::ThermalComfortModel1Type, k = 0; i <= PeopleFields::ThermalComfortModel7Type; ++i) {
109
1/1
✓ Branch 1 taken 252 times.
252 s = workspaceObject.getString(i, false, true);
110
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 222 times.
252 if (s) {
111
2/2
✓ Branch 1 taken 30 times.
✓ Branch 4 taken 30 times.
30 definition.setThermalComfortModelType(k++, *s);
112 }
113 }
114
115 // create the instance
116
1/1
✓ Branch 1 taken 36 times.
36 People people(definition);
117
118
1/1
✓ Branch 1 taken 36 times.
36 OptionalWorkspaceObject target = workspaceObject.getTarget(openstudio::PeopleFields::SurfaceName_AngleFactorListName);
119
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 35 times.
36 if (target) {
120
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
2 if (auto modelObject = translateAndMapWorkspaceObject(*target)) {
121
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 people.setSurfaceNameAngleFactorListName(*modelObject);
122 1 }
123 }
124
125
1/1
✓ Branch 1 taken 36 times.
36 s = workspaceObject.name();
126
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (s) {
127
2/2
✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
36 people.setName(*s);
128 }
129
130
1/1
✓ Branch 1 taken 36 times.
36 target = workspaceObject.getTarget(openstudio::PeopleFields::ZoneorZoneListorSpaceorSpaceListName);
131
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (target) {
132
2/2
✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
36 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
133
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (modelObject) {
134
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>()) {
135
3/3
✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 7 taken 29 times.
29 people.setSpace(modelObject->cast<Space>());
136
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>()) {
137
3/3
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
7 people.setSpaceType(modelObject->cast<SpaceType>());
138 }
139 }
140 36 }
141
142
1/1
✓ Branch 1 taken 36 times.
36 target = workspaceObject.getTarget(openstudio::PeopleFields::NumberofPeopleScheduleName);
143
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 2 times.
36 if (target) {
144
2/2
✓ Branch 1 taken 34 times.
✓ Branch 4 taken 34 times.
34 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
145
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if (modelObject) {
146
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>()) {
147
2/2
✓ Branch 1 taken 34 times.
✓ Branch 4 taken 34 times.
34 Schedule schedule(*intermediate);
148
1/1
✓ Branch 1 taken 34 times.
34 bool ok = people.setNumberofPeopleSchedule(schedule);
149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
34 if (!ok) {
150 ✗ LOG(Warn, "Unable to set " << people.briefDescription() << "'s Number of People schedule to " << schedule.briefDescription()
151 << ", likely because of a ScheduleTypeLimits conflict.");
152 }
153 68 }
154 }
155 34 }
156
157
1/1
✓ Branch 1 taken 36 times.
36 target = workspaceObject.getTarget(openstudio::PeopleFields::ActivityLevelScheduleName);
158
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 2 times.
36 if (target) {
159
2/2
✓ Branch 1 taken 34 times.
✓ Branch 4 taken 34 times.
34 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
160
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if (modelObject) {
161
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>()) {
162
2/2
✓ Branch 1 taken 34 times.
✓ Branch 4 taken 34 times.
34 Schedule schedule(*intermediate);
163
1/1
✓ Branch 1 taken 34 times.
34 bool ok = people.setActivityLevelSchedule(schedule);
164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
34 if (!ok) {
165 ✗ LOG(Warn, "Unable to set " << people.briefDescription() << "'s Activity Level schedule to " << schedule.briefDescription()
166 << ", likely because of a ScheduleTypeLimits conflict.");
167 }
168 68 }
169 }
170 34 }
171
172
1/1
✓ Branch 1 taken 36 times.
36 target = workspaceObject.getTarget(openstudio::PeopleFields::WorkEfficiencyScheduleName);
173
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 9 times.
36 if (target) {
174
2/2
✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
27 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
175
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if (modelObject) {
176
3/4
✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
✓ Branch 6 taken 27 times.
✗ Branch 7 not taken.
54 if (OptionalSchedule intermediate = modelObject->optionalCast<Schedule>()) {
177
2/2
✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
27 Schedule schedule(*intermediate);
178
1/1
✓ Branch 1 taken 27 times.
27 bool ok = people.setWorkEfficiencySchedule(schedule);
179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if (!ok) {
180 ✗ LOG(Warn, "Unable to set " << people.briefDescription() << "'s Work Efficiency schedule to " << schedule.briefDescription()
181 << ", likely because of a ScheduleTypeLimits conflict.");
182 }
183 54 }
184 }
185 27 }
186
187
1/1
✓ Branch 1 taken 36 times.
36 s = workspaceObject.getString(openstudio::PeopleFields::ClothingInsulationCalculationMethod);
188
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 7 times.
36 if (s) {
189
2/2
✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
29 people.setClothingInsulationCalculationMethod(*s);
190 }
191
192
1/1
✓ Branch 1 taken 36 times.
36 target = workspaceObject.getTarget(openstudio::PeopleFields::ClothingInsulationCalculationMethodScheduleName);
193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if (target) {
194 ✗ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
195 ✗ if (modelObject) {
196 ✗ if (OptionalSchedule intermediate = modelObject->optionalCast<Schedule>()) {
197 ✗ Schedule schedule(*intermediate);
198 ✗ bool ok = people.setClothingInsulationCalculationMethodSchedule(schedule);
199 ✗ if (!ok) {
200 ✗ LOG(Warn, "Unable to set " << people.briefDescription() << "'s Clothing Insulation Calculation Method schedule to "
201 << schedule.briefDescription() << ", likely because of a ScheduleTypeLimits conflict.");
202 }
203 ✗ }
204 }
205 ✗ }
206
207
1/1
✓ Branch 1 taken 36 times.
36 target = workspaceObject.getTarget(openstudio::PeopleFields::ClothingInsulationScheduleName);
208
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 9 times.
36 if (target) {
209
2/2
✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
27 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
210
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if (modelObject) {
211
3/4
✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
✓ Branch 6 taken 27 times.
✗ Branch 7 not taken.
54 if (OptionalSchedule intermediate = modelObject->optionalCast<Schedule>()) {
212
2/2
✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
27 Schedule schedule(*intermediate);
213
1/1
✓ Branch 1 taken 27 times.
27 bool ok = people.setClothingInsulationSchedule(schedule);
214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if (!ok) {
215 ✗ LOG(Warn, "Unable to set " << people.briefDescription() << "'s Clothing Insulation schedule to " << schedule.briefDescription()
216 << ", likely because of a ScheduleTypeLimits conflict.");
217 }
218 54 }
219 }
220 27 }
221
222
1/1
✓ Branch 1 taken 36 times.
36 target = workspaceObject.getTarget(openstudio::PeopleFields::AirVelocityScheduleName);
223
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 9 times.
36 if (target) {
224
2/2
✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
27 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
225
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if (modelObject) {
226
3/4
✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
✓ Branch 6 taken 27 times.
✗ Branch 7 not taken.
54 if (OptionalSchedule intermediate = modelObject->optionalCast<Schedule>()) {
227
2/2
✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
27 Schedule schedule(*intermediate);
228
1/1
✓ Branch 1 taken 27 times.
27 bool ok = people.setAirVelocitySchedule(schedule);
229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if (!ok) {
230 ✗ LOG(Error, "Unable to set " << people.briefDescription() << "'s Air Velocity schedule to " << schedule.briefDescription()
231 << ", likely because of a ScheduleTypeLimits conflict.");
232 }
233 54 }
234 }
235 27 }
236
237
1/1
✓ Branch 1 taken 36 times.
36 target = workspaceObject.getTarget(openstudio::PeopleFields::AnkleLevelAirVelocityScheduleName);
238
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 35 times.
36 if (target) {
239
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
240
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (modelObject) {
241
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
2 if (OptionalSchedule intermediate = modelObject->optionalCast<Schedule>()) {
242
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 Schedule schedule(*intermediate);
243
1/1
✓ Branch 1 taken 1 time.
1 bool ok = people.setAnkleLevelAirVelocitySchedule(schedule);
244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 if (!ok) {
245 ✗ LOG(Error, "Unable to set " << people.briefDescription() << "'s Ankle Level Air Velocity schedule to " << schedule.briefDescription()
246 << ", likely because of a ScheduleTypeLimits conflict.");
247 }
248 2 }
249 }
250 1 }
251
252
1/1
✓ Branch 1 taken 36 times.
36 d = workspaceObject.getDouble(openstudio::PeopleFields::ColdStressTemperatureThreshold);
253
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 35 times.
36 if (d) {
254
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 people.setColdStressTemperatureThreshold(*d);
255 }
256
257
1/1
✓ Branch 1 taken 36 times.
36 d = workspaceObject.getDouble(openstudio::PeopleFields::HeatStressTemperatureThreshold);
258
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 35 times.
36 if (d) {
259
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 people.setHeatStressTemperatureThreshold(*d);
260 }
261
262
1/1
✓ Branch 1 taken 36 times.
36 return people;
263 36 }
264
265 } // namespace energyplus
266
267 } // namespace openstudio
268