GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 60.1% 110 / 0 / 183
Functions: 100.0% 1 / 0 / 1
Branches: 43.6% 182 / 0 / 417

src/energyplus/ForwardTranslator/ForwardTranslateAvailabilityManagerNightCycle.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 #include "../../model/AvailabilityManagerNightCycle.hpp"
8 #include "../../model/AvailabilityManagerNightCycle_Impl.hpp"
9 #include "../../model/Model.hpp"
10 #include "../../model/Schedule.hpp"
11 #include "../../model/Schedule_Impl.hpp"
12 #include "../../model/ThermalZone.hpp"
13 #include "../../model/ThermalZone_Impl.hpp"
14 #include "../../model/FanConstantVolume.hpp"
15 #include "../../model/FanConstantVolume_Impl.hpp"
16 #include "../../model/FanVariableVolume.hpp"
17 #include "../../model/FanVariableVolume_Impl.hpp"
18 #include "../../model/AirLoopHVAC.hpp"
19 #include "../../model/AirLoopHVAC_Impl.hpp"
20 #include "../../utilities/core/Assert.hpp"
21 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
22 #include <utilities/idd/AvailabilityManager_NightCycle_FieldEnums.hxx>
23 #include <utilities/idd/ZoneList_FieldEnums.hxx>
24 #include <utilities/idd/IddEnums.hxx>
25
26 using namespace openstudio::model;
27 using namespace std;
28
29 namespace openstudio {
30
31 namespace energyplus {
32
33 5 boost::optional<IdfObject> ForwardTranslator::translateAvailabilityManagerNightCycle(AvailabilityManagerNightCycle& modelObject) {
34
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 IdfObject idfObject(IddObjectType::AvailabilityManager_NightCycle);
35
1/1
✓ Branch 1 taken 5 times.
5 m_idfObjects.push_back(idfObject);
36
37 5 boost::optional<AirLoopHVAC> airLoopHVAC;
38
2/3
✓ Branch 1 taken 5 times.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
10 if (auto loop = modelObject.loop()) {
39
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 airLoopHVAC = loop->optionalCast<model::AirLoopHVAC>();
40 5 }
41
42 {
43
1/1
✓ Branch 1 taken 5 times.
5 auto schedule = modelObject.applicabilitySchedule();
44
3/3
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
5 idfObject.setString(AvailabilityManager_NightCycleFields::ApplicabilityScheduleName, schedule.name().get());
45 5 }
46
47 // Note: always true, we don't even translate the AVM:NightCycle if it's not on an airloop anyways
48 // Translation is triggered from the AirLoopHVAC itself
49 // if( airLoopHVAC ) {
50 // // Fan schedules are set to match the availabilitySchedule in the translator
51 // idfObject.setString(AvailabilityManager_NightCycleFields::FanScheduleName,airLoopHVAC->availabilitySchedule().name().get());
52 // }
53
54 // The above was moved to the model API directly, so use that instead. It will fetch the airLoopHVAC availability schedule (which we know exists)
55
2/3
✓ Branch 1 taken 5 times.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
10 if (boost::optional<Schedule> _fanSchedule = modelObject.fanSchedule()) {
56
4/4
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
✓ Branch 10 taken 5 times.
5 idfObject.setString(AvailabilityManager_NightCycleFields::FanScheduleName, _fanSchedule->name().get());
57 5 }
58
59
2/3
✓ Branch 1 taken 5 times.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
10 if (auto s = modelObject.name()) {
60
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 idfObject.setName(*s);
61 5 }
62
63 {
64
1/1
✓ Branch 1 taken 5 times.
5 auto value = modelObject.thermostatTolerance();
65
1/1
✓ Branch 1 taken 5 times.
5 idfObject.setDouble(AvailabilityManager_NightCycleFields::ThermostatTolerance, value);
66 }
67
68 // Cycling Run Time and Cycling Run Time Control Type
69 {
70
1/1
✓ Branch 1 taken 5 times.
5 double runtime = modelObject.cyclingRunTime();
71
1/1
✓ Branch 1 taken 5 times.
5 idfObject.setDouble(AvailabilityManager_NightCycleFields::CyclingRunTime, runtime);
72
1/1
✓ Branch 1 taken 5 times.
5 std::string cycRTCType = modelObject.cyclingRunTimeControlType();
73
74
4/4
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 2 times.
10 if (istringEqual(cycRTCType, "Thermostat")) {
75
11/11
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
✓ Branch 22 taken 3 times.
✓ Branch 26 taken 3 times.
✓ Branch 29 taken 3 times.
✓ Branch 32 taken 3 times.
3 LOG(Info, "With a Cycling Run Time Control Type set to '" << cycRTCType << "', the entered Cycling Run Time of '" << runtime
76 << "' seconds will be ignored for " << modelObject.briefDescription());
77 }
78
1/1
✓ Branch 1 taken 5 times.
5 idfObject.setString(AvailabilityManager_NightCycleFields::CyclingRunTimeControlType, cycRTCType);
79 5 }
80
81 // We'll use that later to default the control zone lists
82
1/1
✓ Branch 1 taken 5 times.
5 std::string controlType = modelObject.controlType();
83
1/1
✓ Branch 1 taken 5 times.
5 idfObject.setString(AvailabilityManager_NightCycleFields::ControlType, controlType);
84
85 // Zone Lists
86
1/1
✓ Branch 1 taken 5 times.
5 std::vector<ThermalZone> controlThermalZones = modelObject.controlThermalZones();
87
1/1
✓ Branch 1 taken 5 times.
5 std::vector<ThermalZone> coolingControlThermalZones = modelObject.coolingControlThermalZones();
88
1/1
✓ Branch 1 taken 5 times.
5 std::vector<ThermalZone> heatingControlThermalZones = modelObject.heatingControlThermalZones();
89
1/1
✓ Branch 1 taken 5 times.
5 std::vector<ThermalZone> heatingZoneFansOnlyThermalZones = modelObject.heatingZoneFansOnlyThermalZones();
90
91 // Size of Zone Lists for convenience
92 5 auto n_controlThermalZones = controlThermalZones.size();
93 5 auto n_coolingControlThermalZones = coolingControlThermalZones.size();
94 5 auto n_heatingControlThermalZones = heatingControlThermalZones.size();
95 5 auto n_heatingZoneFansOnlyThermalZones = heatingZoneFansOnlyThermalZones.size();
96
97 // Boolean to decide whether defaulting a given ZoneList to all zones served by system is needed or not
98 5 bool default_controlThermalZones = false;
99 5 bool default_coolingControlThermalZones = false;
100 5 bool default_heatingControlThermalZones = false;
101 5 bool default_heatingZoneFansOnlyThermalZones = false;
102
103 // Main logic to warn user and decide if defaulting is needed based on the Control Type entered
104
20/38
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 5 times.
✓ Branch 12 taken 5 times.
✓ Branch 14 taken 1 time.
✓ Branch 15 taken 4 times.
✓ Branch 17 taken 1 time.
✓ Branch 20 taken 1 time.
✗ Branch 22 not taken.
✓ Branch 23 taken 1 time.
✓ Branch 24 taken 1 time.
✓ Branch 25 taken 4 times.
✓ Branch 27 taken 1 time.
✓ Branch 28 taken 4 times.
✓ Branch 29 taken 5 times.
✗ Branch 30 not taken.
✓ Branch 32 taken 5 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 5 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 5 times.
✗ Branch 38 not taken.
✓ Branch 39 taken 4 times.
✓ Branch 40 taken 1 time.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
27 if (istringEqual(controlType, "StayOff") || istringEqual(controlType, "CycleOnAny") || istringEqual(controlType, "CycleOnAnyZoneFansOnly")) {
105
106 // All Control Zone Lists are ignored
107
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if ((n_controlThermalZones + n_coolingControlThermalZones + n_heatingControlThermalZones + n_heatingZoneFansOnlyThermalZones) > 0) {
108
10/10
✓ 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.
✓ Branch 19 taken 2 times.
✓ Branch 23 taken 2 times.
✓ Branch 26 taken 2 times.
✓ Branch 29 taken 2 times.
2 LOG(Info, "All Control Zone Lists will be ignored for " << modelObject.briefDescription() << " due to the Control Type of '" << controlType
109 << "'.");
110 }
111
112
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 time.
2 } else if (istringEqual(controlType, "CycleOnControlZone")) {
113
114 // Only the controlThermalZones isn't ignored
115 ✗ if ((n_coolingControlThermalZones + n_heatingControlThermalZones + n_heatingZoneFansOnlyThermalZones) > 0) {
116 ✗ LOG(Info, "All Control Zone Lists other than 'Control Zone List' will be ignored for "
117 << modelObject.briefDescription() << " due to the Control Type of '" << controlType << "'.");
118 }
119
120 // Check if need to default the controlThermalZones
121 // Another option might have been to switch the control Type to CycleOnAny
122 ✗ if (n_controlThermalZones == 0) {
123 ✗ default_controlThermalZones = true;
124 }
125
126
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
2 } else if (istringEqual(controlType, "CycleOnAnyCoolingZone")) {
127
128 // Only the coolingControlThermalZones isn't ignored
129
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if ((n_controlThermalZones + n_heatingControlThermalZones + n_heatingZoneFansOnlyThermalZones) > 0) {
130
10/10
✓ 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.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 23 taken 1 time.
✓ Branch 26 taken 1 time.
✓ Branch 29 taken 1 time.
1 LOG(Info, "All Control Zone Lists other than 'Cooling Control Zone List' will be ignored for "
131 << modelObject.briefDescription() << " due to the Control Type of '" << controlType << "'.");
132 }
133
134 // Check if need to default
135
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (n_coolingControlThermalZones == 0) {
136 1 default_coolingControlThermalZones = true;
137 }
138
139 ✗ } else if (istringEqual(controlType, "CycleOnAnyHeatingZone")) {
140
141 // Only the heatingControlThermalZones, and heatingZoneFansOnlyThermalZones aren't ignored
142 ✗ if ((n_controlThermalZones + n_coolingControlThermalZones) > 0) {
143 ✗ LOG(Info, "All Control Zone Lists other than 'Heating Control Zone List' and optionally "
144 "'Heating Zone Fans Only Zone List' will be ignored for "
145 << modelObject.briefDescription() << " due to the Control Type of '" << controlType << "'.");
146 }
147
148 // Check if need to default
149 ✗ if (n_heatingControlThermalZones == 0) {
150 ✗ default_heatingControlThermalZones = true;
151 }
152 // TODO: @kbenne
153 // here we should't default the heatingZoneFansOnlyThermalZones
154 // I view that as an option to enable cycling on zone fans only or not,
155 // while you only get central heating operation (not possible with CycleOnAny)
156
157 ✗ } else if (istringEqual(controlType, "CycleOnAnyHeatingZoneFansOnly")) {
158
159 // Only the heatingZoneFansOnlyThermalZones isn't ignored
160 ✗ if ((n_controlThermalZones + n_coolingControlThermalZones + n_heatingControlThermalZones) > 0) {
161 ✗ LOG(Info, "All Control Zone Lists other than 'Heating Zone Fans Only Zone List' will be ignored for "
162 << modelObject.briefDescription() << " due to the Control Type of '" << controlType << "'.");
163 }
164
165 // Check if need to default
166 ✗ if (n_heatingZoneFansOnlyThermalZones == 0) {
167 ✗ default_heatingZoneFansOnlyThermalZones = true;
168 }
169
170 ✗ } else if (istringEqual(controlType, "CycleOnAnyCoolingOrHeatingZone")) {
171
172 // Only the coolingControlThermalZones, coolingControlThermalZones, and optionally heatingZoneFansOnlyThermalZones aren't ignored
173 ✗ if (n_controlThermalZones > 0) {
174 ✗ LOG(Info, "All Control Zone Lists other than 'Heating Control Zone List', 'Cooling Control Zone List' and optionally "
175 "'Heating Zone Fans Only Zone List' will be ignored for "
176 << modelObject.briefDescription() << " due to the Control Type of '" << controlType << "'.");
177 }
178
179 // Check if need to default
180 ✗ if (n_heatingControlThermalZones == 0) {
181 ✗ default_heatingControlThermalZones = true;
182 }
183 ✗ if (n_coolingControlThermalZones == 0) {
184 ✗ default_coolingControlThermalZones = true;
185 }
186 // TODO: @kbenne
187 // Here we should default the heatingZoneFansOnlyThermalZones
188 // Because otherwise the user could have just chosen "CycleOnAny"
189 ✗ if (n_heatingZoneFansOnlyThermalZones == 0) {
190 ✗ default_heatingZoneFansOnlyThermalZones = true;
191 }
192
193 } else {
194 // should never get there, unless a new ControlType is added later...
195 ✗ LOG_AND_THROW("Unknown Control Type of '" << controlType << "' for " << modelObject.briefDescription());
196 } // End of Main logic to warn user and decide if defaulting is needed based on the Control Type entered
197
198 // Whether a Zone List will actually be unused or not, we still translate it (perhaps the user is going to use the IDF later)
199
200 // Control Thermal Zones
201 {
202 // Create a ZoneList, and populate it
203
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 IdfObject zoneList(IddObjectType::ZoneList);
204
3/3
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
5 std::string zoneListName = modelObject.name().get() + " Control Zones List";
205
1/1
✓ Branch 1 taken 5 times.
5 zoneList.setName(zoneListName);
206 bool write_zonelist;
207
208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (default_controlThermalZones) {
209 // Get all zones served by the AirLoop attached to it
210 ✗ if (airLoopHVAC) {
211 ✗ for (const ThermalZone& tz : airLoopHVAC->thermalZones()) {
212 ✗ auto eg = zoneList.pushExtensibleGroup();
213 ✗ eg.setString(ZoneListExtensibleFields::ZoneName, tz.name().get());
214 ✗ }
215 ✗ LOG(Warn, "Defaulting the Control Zone List to all zones served by the AirLoopHVAC attached to " << modelObject.briefDescription());
216 ✗ write_zonelist = true;
217 } else {
218 // Note: we never get here because the translation of the AVM:NightCyle isn't done if no AirLoopHVAC attached
219 ✗ LOG(Error, "Control Zone List is expected for " << modelObject.briefDescription()
220 << " but it cannot be defaulted because it isn't on an AirLoopHVAC");
221 ✗ write_zonelist = false;
222 }
223 } else {
224
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if (n_controlThermalZones > 0) {
225
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (n_controlThermalZones == 1) {
226 // If only one, just write the thermalZone name directly
227 3 write_zonelist = false;
228
3/3
✓ Branch 2 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 8 taken 3 times.
3 idfObject.setString(AvailabilityManager_NightCycleFields::ControlZoneorZoneListName, controlThermalZones[0].name().get());
229 } else {
230 // More than one, we indeed create a zone list
231 ✗ for (const ThermalZone& tz : controlThermalZones) {
232 ✗ auto eg = zoneList.pushExtensibleGroup();
233 ✗ eg.setString(ZoneListExtensibleFields::ZoneName, tz.name().get());
234 ✗ }
235 ✗ write_zonelist = true;
236 }
237 } else {
238 // No zones = no zonelist
239 2 write_zonelist = false;
240 }
241 }
242 // Write ZoneList to the IDF and set the AVM ZoneList field to it only if something meaningful happened
243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (write_zonelist) {
244 ✗ idfObject.setString(AvailabilityManager_NightCycleFields::ControlZoneorZoneListName, zoneListName);
245 ✗ m_idfObjects.push_back(zoneList);
246 }
247 5 }
248
249 // Cooling Control Thermal Zones
250 {
251 // Create a ZoneList, and populate it
252
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 IdfObject zoneList(IddObjectType::ZoneList);
253
3/3
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
5 std::string zoneListName = modelObject.name().get() + " Cooling Control Zones List";
254
1/1
✓ Branch 1 taken 5 times.
5 zoneList.setName(zoneListName);
255 bool write_zonelist;
256
257
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 4 times.
5 if (default_coolingControlThermalZones) {
258 // Get all zones served by the AirLoop attached to it
259
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (airLoopHVAC) {
260
4/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 11 taken 4 times.
✓ Branch 12 taken 1 time.
5 for (const ThermalZone& tz : airLoopHVAC->thermalZones()) {
261
1/1
✓ Branch 1 taken 4 times.
4 auto eg = zoneList.pushExtensibleGroup();
262
3/3
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
4 eg.setString(ZoneListExtensibleFields::ZoneName, tz.name().get());
263 5 }
264
7/7
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 14 taken 1 time.
✓ Branch 17 taken 1 time.
✓ Branch 20 taken 1 time.
1 LOG(Warn, "Defaulting the Cooling Control Zone List to all zones served by the AirLoopHVAC attached to " << modelObject.briefDescription());
265 1 write_zonelist = true;
266 } else {
267 ✗ LOG(Error, "Cooling Control Zone List is expected for " << modelObject.briefDescription()
268 << " but it cannot be defaulted because it isn't on an AirLoopHVAC");
269 ✗ write_zonelist = false;
270 }
271 } else {
272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (n_coolingControlThermalZones > 0) {
273 ✗ if (n_coolingControlThermalZones == 1) {
274 // If only one, just write the thermalZone name directly
275 ✗ write_zonelist = false;
276 ✗ idfObject.setString(AvailabilityManager_NightCycleFields::CoolingControlZoneorZoneListName, coolingControlThermalZones[0].name().get());
277 } else {
278 // More than one, we indeed create a zone list
279 ✗ for (const ThermalZone& tz : coolingControlThermalZones) {
280 ✗ auto eg = zoneList.pushExtensibleGroup();
281 ✗ eg.setString(ZoneListExtensibleFields::ZoneName, tz.name().get());
282 ✗ }
283 ✗ write_zonelist = true;
284 }
285 } else {
286 // No zones = no zonelist
287 4 write_zonelist = false;
288 }
289 }
290 // Write ZoneList to the IDF and set the AVM ZoneList field to it only if something meaningful happened
291
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 4 times.
5 if (write_zonelist) {
292
1/1
✓ Branch 1 taken 1 time.
1 idfObject.setString(AvailabilityManager_NightCycleFields::CoolingControlZoneorZoneListName, zoneListName);
293
1/1
✓ Branch 1 taken 1 time.
1 m_idfObjects.push_back(zoneList);
294 }
295 5 }
296
297 // Heating Control Thermal Zones
298 {
299 // Create a ZoneList, and populate it
300
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 IdfObject zoneList(IddObjectType::ZoneList);
301
3/3
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
5 std::string zoneListName = modelObject.name().get() + " Heating Control Zones List";
302
1/1
✓ Branch 1 taken 5 times.
5 zoneList.setName(zoneListName);
303 bool write_zonelist;
304
305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (default_heatingControlThermalZones) {
306 // Get all zones served by the AirLoop attached to it
307 ✗ if (airLoopHVAC) {
308 ✗ for (const ThermalZone& tz : airLoopHVAC->thermalZones()) {
309 ✗ auto eg = zoneList.pushExtensibleGroup();
310 ✗ eg.setString(ZoneListExtensibleFields::ZoneName, tz.name().get());
311 ✗ }
312 ✗ LOG(Warn, "Defaulting the Heating Control Zone List to all zones served by the AirLoopHVAC attached to " << modelObject.briefDescription());
313 ✗ write_zonelist = true;
314 } else {
315 ✗ LOG(Error, "Cooling Heating Zone List is expected for " << modelObject.briefDescription()
316 << " but it cannot be defaulted because it isn't on an AirLoopHVAC");
317 ✗ write_zonelist = false;
318 }
319 } else {
320
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if (n_heatingControlThermalZones > 0) {
321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (n_heatingControlThermalZones == 1) {
322 // If only one, just write the thermalZone name directly
323 ✗ write_zonelist = false;
324 ✗ idfObject.setString(AvailabilityManager_NightCycleFields::HeatingControlZoneorZoneListName, heatingControlThermalZones[0].name().get());
325 } else {
326 // More than one, we indeed create a zone list
327
328
2/2
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 3 times.
9 for (const ThermalZone& tz : heatingControlThermalZones) {
329
1/1
✓ Branch 1 taken 6 times.
6 auto eg = zoneList.pushExtensibleGroup();
330
3/3
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
6 eg.setString(ZoneListExtensibleFields::ZoneName, tz.name().get());
331 6 }
332 3 write_zonelist = true;
333 }
334 } else {
335 // No zones = no zonelist
336 2 write_zonelist = false;
337 }
338 }
339 // Write ZoneList to the IDF and set the AVM ZoneList field to it only if something meaningful happened
340
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if (write_zonelist) {
341
1/1
✓ Branch 1 taken 3 times.
3 idfObject.setString(AvailabilityManager_NightCycleFields::HeatingControlZoneorZoneListName, zoneListName);
342
1/1
✓ Branch 1 taken 3 times.
3 m_idfObjects.push_back(zoneList);
343 }
344 5 }
345
346 // Heating Zone Fans Only Thermal Zones
347 {
348 // Create a ZoneList, and populate it
349
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 IdfObject zoneList(IddObjectType::ZoneList);
350
3/3
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
5 std::string zoneListName = modelObject.name().get() + " Heating Zone Fans Only Zones List";
351
1/1
✓ Branch 1 taken 5 times.
5 zoneList.setName(zoneListName);
352 bool write_zonelist;
353
354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (default_heatingZoneFansOnlyThermalZones) {
355 // Get all zones served by the AirLoop attached to it
356 ✗ if (airLoopHVAC) {
357 ✗ for (const ThermalZone& tz : airLoopHVAC->thermalZones()) {
358 ✗ auto eg = zoneList.pushExtensibleGroup();
359 ✗ eg.setString(ZoneListExtensibleFields::ZoneName, tz.name().get());
360 ✗ }
361 ✗ LOG(Warn, "Defaulting the Heating Zone Fans Only Zones List to all zones served by the AirLoopHVAC attached to "
362 << modelObject.briefDescription());
363 ✗ write_zonelist = true;
364 } else {
365 ✗ LOG(Error, "Heating Zone Fans Only Zones List is expected for " << modelObject.briefDescription()
366 << " but it cannot be defaulted because it isn't on an AirLoopHVAC");
367 ✗ write_zonelist = false;
368 }
369 } else {
370
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if (n_heatingZoneFansOnlyThermalZones > 0) {
371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (n_heatingZoneFansOnlyThermalZones == 1) {
372 // If only one, just write the thermalZone name directly
373 ✗ write_zonelist = false;
374 ✗ idfObject.setString(AvailabilityManager_NightCycleFields::HeatingZoneFansOnlyZoneorZoneListName,
375 ✗ heatingZoneFansOnlyThermalZones[0].name().get());
376 } else {
377 // More than one, we indeed create a zone list
378
2/2
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 3 times.
12 for (const ThermalZone& tz : heatingZoneFansOnlyThermalZones) {
379
1/1
✓ Branch 1 taken 9 times.
9 auto eg = zoneList.pushExtensibleGroup();
380
3/3
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
9 eg.setString(ZoneListExtensibleFields::ZoneName, tz.name().get());
381 9 }
382 3 write_zonelist = true;
383 }
384 } else {
385 // No zones = no zonelist
386 2 write_zonelist = false;
387 }
388 }
389 // Write ZoneList to the IDF and set the AVM ZoneList field to it only if something meaningful happened
390
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if (write_zonelist) {
391
1/1
✓ Branch 1 taken 3 times.
3 idfObject.setString(AvailabilityManager_NightCycleFields::HeatingZoneFansOnlyZoneorZoneListName, zoneListName);
392
1/1
✓ Branch 1 taken 3 times.
3 m_idfObjects.push_back(zoneList);
393 }
394 5 }
395
396
1/1
✓ Branch 1 taken 5 times.
10 return idfObject;
397 5 }
398
399 } // namespace energyplus
400 } // namespace openstudio
401