GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 80.0% 321 / 0 / 401
Functions: 75.0% 66 / 0 / 88
Branches: 41.4% 242 / 0 / 584

src/model/AvailabilityManagerNightCycle.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 "AvailabilityManagerNightCycle.hpp"
7 #include "AvailabilityManagerNightCycle_Impl.hpp"
8 #include "Schedule.hpp"
9 #include "Schedule_Impl.hpp"
10 #include "ThermalZone.hpp"
11 #include "ThermalZone_Impl.hpp"
12 #include "ScheduleTypeLimits.hpp"
13 #include "ScheduleTypeRegistry.hpp"
14 #include "ModelObject.hpp"
15 #include "ModelObjectList.hpp"
16 #include "ModelObjectList_Impl.hpp"
17 #include "Model.hpp"
18 #include "Loop.hpp"
19 #include "AirLoopHVAC.hpp"
20 #include "AirLoopHVAC_Impl.hpp"
21
22 #include <utilities/idd/IddFactory.hxx>
23
24 #include <utilities/idd/OS_AvailabilityManager_NightCycle_FieldEnums.hxx>
25 #include <utilities/idd/IddEnums.hxx>
26 #include "../utilities/units/Unit.hpp"
27 #include "../utilities/core/Assert.hpp"
28
29 namespace openstudio {
30 namespace model {
31
32 namespace detail {
33
34 20 AvailabilityManagerNightCycle_Impl::AvailabilityManagerNightCycle_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
35 20 : AvailabilityManager_Impl(idfObject, model, keepHandle) {
36
4/6
✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
✓ Branch 7 taken 20 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 20 times.
✗ Branch 13 not taken.
20 OS_ASSERT(idfObject.iddObject().type() == AvailabilityManagerNightCycle::iddObjectType());
37 20 }
38
39 3 AvailabilityManagerNightCycle_Impl::AvailabilityManagerNightCycle_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model,
40 3 bool keepHandle)
41 3 : AvailabilityManager_Impl(other, model, keepHandle) {
42
4/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 3 times.
✗ Branch 13 not taken.
3 OS_ASSERT(other.iddObject().type() == AvailabilityManagerNightCycle::iddObjectType());
43 3 }
44
45 11 AvailabilityManagerNightCycle_Impl::AvailabilityManagerNightCycle_Impl(const AvailabilityManagerNightCycle_Impl& other, Model_Impl* model,
46 11 bool keepHandle)
47 11 : AvailabilityManager_Impl(other, model, keepHandle) {}
48
49 ✗ const std::vector<std::string>& AvailabilityManagerNightCycle_Impl::outputVariableNames() const {
50 ✗ static const std::vector<std::string> result{"Availability Manager Night Cycle Control Status"};
51 ✗ return result;
52 ✗ }
53
54 1 IddObjectType AvailabilityManagerNightCycle_Impl::iddObjectType() const {
55 1 return AvailabilityManagerNightCycle::iddObjectType();
56 }
57
58 ✗ std::vector<ScheduleTypeKey> AvailabilityManagerNightCycle_Impl::getScheduleTypeKeys(const Schedule& schedule) const {
59 ✗ std::vector<ScheduleTypeKey> result;
60 ✗ UnsignedVector fieldIndices = getSourceIndices(schedule.handle());
61 ✗ UnsignedVector::const_iterator b(fieldIndices.begin());
62 ✗ UnsignedVector::const_iterator e(fieldIndices.end());
63 ✗ if (std::find(b, e, OS_AvailabilityManager_NightCycleFields::ApplicabilitySchedule) != e) {
64 ✗ result.push_back(ScheduleTypeKey("AvailabilityManagerNightCycle", "Applicability Schedule"));
65 }
66 ✗ return result;
67 ✗ }
68
69 9 boost::optional<Schedule> AvailabilityManagerNightCycle_Impl::optionalApplicabilitySchedule() const {
70
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 return getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_AvailabilityManager_NightCycleFields::ApplicabilitySchedule);
71 }
72
73 9 Schedule AvailabilityManagerNightCycle_Impl::applicabilitySchedule() const {
74
1/1
✓ Branch 1 taken 9 times.
9 boost::optional<Schedule> value = optionalApplicabilitySchedule();
75
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
9 if (!value) {
76 ✗ LOG_AND_THROW(briefDescription() << " does not have an Applicability Schedule attached.");
77 }
78
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
18 return value.get();
79 9 }
80
81 19 bool AvailabilityManagerNightCycle_Impl::setApplicabilitySchedule(Schedule& schedule) {
82
3/3
✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
✓ Branch 7 taken 19 times.
76 bool result = setSchedule(OS_AvailabilityManager_NightCycleFields::ApplicabilitySchedule, "AvailabilityManagerNightCycle",
83 "Applicability Schedule", schedule);
84 19 return result;
85 }
86
87 3 ModelObject AvailabilityManagerNightCycle_Impl::clone(Model model) const {
88
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 auto avmClone = ModelObject_Impl::clone(model).cast<AvailabilityManagerNightCycle>();
89
90 // Now recreate the lists
91 // Control Zone List
92
1/1
✓ Branch 1 taken 3 times.
3 ModelObjectList controlThermalZoneList = ModelObjectList(model);
93
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 controlThermalZoneList.setName(this->name().get() + " Control Zone List");
94
1/1
✓ Branch 3 taken 3 times.
6 bool ok = avmClone.getImpl<detail::AvailabilityManager_Impl>()->setPointer(OS_AvailabilityManager_NightCycleFields::ControlZoneorZoneListName,
95
1/1
✓ Branch 1 taken 3 times.
6 controlThermalZoneList.handle());
96
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
3 OS_ASSERT(ok);
97
98 // Cooling Control Zone List
99
1/1
✓ Branch 1 taken 3 times.
3 ModelObjectList coolingControlThermalZoneList = ModelObjectList(model);
100
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 coolingControlThermalZoneList.setName(this->name().get() + " Cooling Control Zone List");
101
1/1
✓ Branch 3 taken 3 times.
6 ok = avmClone.getImpl<detail::AvailabilityManager_Impl>()->setPointer(OS_AvailabilityManager_NightCycleFields::CoolingControlZoneorZoneListName,
102
1/1
✓ Branch 1 taken 3 times.
6 coolingControlThermalZoneList.handle());
103
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
3 OS_ASSERT(ok);
104
105 // Heating Control Zone List
106
1/1
✓ Branch 1 taken 3 times.
3 ModelObjectList heatingControlThermalZoneList = ModelObjectList(model);
107
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 heatingControlThermalZoneList.setName(this->name().get() + " Heating Control Zone List");
108
1/1
✓ Branch 3 taken 3 times.
6 ok = avmClone.getImpl<detail::AvailabilityManager_Impl>()->setPointer(OS_AvailabilityManager_NightCycleFields::HeatingControlZoneorZoneListName,
109
1/1
✓ Branch 1 taken 3 times.
6 heatingControlThermalZoneList.handle());
110
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
3 OS_ASSERT(ok);
111
112 // Heating Zone Fans Only Zone List
113
1/1
✓ Branch 1 taken 3 times.
3 ModelObjectList heatingZoneFansOnlyThermalZoneList = ModelObjectList(model);
114
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 heatingZoneFansOnlyThermalZoneList.setName(this->name().get() + " Heating Zone Fans Only Zone List");
115
1/1
✓ Branch 3 taken 3 times.
6 ok = avmClone.getImpl<detail::AvailabilityManager_Impl>()->setPointer(
116
1/1
✓ Branch 1 taken 3 times.
6 OS_AvailabilityManager_NightCycleFields::HeatingZoneFansOnlyZoneorZoneListName, heatingZoneFansOnlyThermalZoneList.handle());
117
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
3 OS_ASSERT(ok);
118
119 6 return std::move(avmClone);
120 3 }
121
122 2 std::vector<IdfObject> AvailabilityManagerNightCycle_Impl::remove() {
123 2 std::vector<IdfObject> result;
124
125 // Remove the ModelObjectLists. You have to clear them first, or it'll also remove the ThermalZones contained within.
126 {
127
1/1
✓ Branch 1 taken 2 times.
2 ModelObjectList mo_list = controlThermalZoneList();
128
1/1
✓ Branch 1 taken 2 times.
2 mo_list.removeAllModelObjects();
129
1/1
✓ Branch 1 taken 2 times.
2 std::vector<IdfObject> removedMoList = mo_list.remove();
130
1/1
✓ Branch 5 taken 2 times.
2 result.insert(result.end(), removedMoList.begin(), removedMoList.end());
131 2 }
132
133 {
134
1/1
✓ Branch 1 taken 2 times.
2 ModelObjectList mo_list = coolingControlThermalZoneList();
135
1/1
✓ Branch 1 taken 2 times.
2 mo_list.removeAllModelObjects();
136
1/1
✓ Branch 1 taken 2 times.
2 std::vector<IdfObject> removedMoList = mo_list.remove();
137
1/1
✓ Branch 5 taken 2 times.
2 result.insert(result.end(), removedMoList.begin(), removedMoList.end());
138 2 }
139
140 {
141
1/1
✓ Branch 1 taken 2 times.
2 ModelObjectList mo_list = heatingControlThermalZoneList();
142
1/1
✓ Branch 1 taken 2 times.
2 mo_list.removeAllModelObjects();
143
1/1
✓ Branch 1 taken 2 times.
2 std::vector<IdfObject> removedMoList = mo_list.remove();
144
1/1
✓ Branch 5 taken 2 times.
2 result.insert(result.end(), removedMoList.begin(), removedMoList.end());
145 2 }
146
147 {
148
1/1
✓ Branch 1 taken 2 times.
2 ModelObjectList mo_list = heatingZoneFansOnlyThermalZoneList();
149
1/1
✓ Branch 1 taken 2 times.
2 mo_list.removeAllModelObjects();
150
1/1
✓ Branch 1 taken 2 times.
2 std::vector<IdfObject> removedMoList = mo_list.remove();
151
1/1
✓ Branch 5 taken 2 times.
2 result.insert(result.end(), removedMoList.begin(), removedMoList.end());
152 2 }
153
154
1/1
✓ Branch 1 taken 2 times.
2 std::vector<IdfObject> AvailabilityManagerNightCycle = ModelObject_Impl::remove();
155
1/1
✓ Branch 5 taken 2 times.
2 result.insert(result.end(), AvailabilityManagerNightCycle.begin(), AvailabilityManagerNightCycle.end());
156
157 4 return result;
158 2 }
159
160 15 boost::optional<AirLoopHVAC> AvailabilityManagerNightCycle_Impl::airLoopHVAC() const {
161
3/3
✓ Branch 1 taken 15 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 3 times.
30 if (boost::optional<Loop> _loop = loop()) {
162
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
12 return _loop->optionalCast<AirLoopHVAC>();
163 15 }
164 3 return boost::none;
165 }
166
167 9 boost::optional<Schedule> AvailabilityManagerNightCycle_Impl::fanSchedule() const {
168 9 boost::optional<Schedule> result;
169
3/3
✓ Branch 1 taken 9 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 1 time.
18 if (boost::optional<AirLoopHVAC> _airLoop = airLoopHVAC()) {
170
3/3
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
8 result = _airLoop->availabilitySchedule();
171 9 }
172 9 return result;
173 ✗ }
174
175 8 std::string AvailabilityManagerNightCycle_Impl::controlType() const {
176
1/1
✓ Branch 1 taken 8 times.
8 boost::optional<std::string> value = getString(OS_AvailabilityManager_NightCycleFields::ControlType, true);
177
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 4 not taken.
8 OS_ASSERT(value);
178
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
16 return value.get();
179 8 }
180
181 ✗ bool AvailabilityManagerNightCycle_Impl::isControlTypeDefaulted() const {
182 ✗ return isEmpty(OS_AvailabilityManager_NightCycleFields::ControlType);
183 }
184
185 5 double AvailabilityManagerNightCycle_Impl::thermostatTolerance() const {
186
1/1
✓ Branch 1 taken 5 times.
5 boost::optional<double> value = getDouble(OS_AvailabilityManager_NightCycleFields::ThermostatTolerance, true);
187
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 4 not taken.
5 OS_ASSERT(value);
188
1/1
✓ Branch 1 taken 5 times.
10 return value.get();
189 }
190
191 ✗ bool AvailabilityManagerNightCycle_Impl::isThermostatToleranceDefaulted() const {
192 ✗ return isEmpty(OS_AvailabilityManager_NightCycleFields::ThermostatTolerance);
193 }
194
195 7 double AvailabilityManagerNightCycle_Impl::cyclingRunTime() const {
196
1/1
✓ Branch 1 taken 7 times.
7 boost::optional<double> value = getDouble(OS_AvailabilityManager_NightCycleFields::CyclingRunTime, true);
197
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 4 not taken.
7 OS_ASSERT(value);
198
1/1
✓ Branch 1 taken 7 times.
14 return value.get();
199 }
200
201 ✗ bool AvailabilityManagerNightCycle_Impl::isCyclingRunTimeDefaulted() const {
202 ✗ return isEmpty(OS_AvailabilityManager_NightCycleFields::CyclingRunTime);
203 }
204
205 15 bool AvailabilityManagerNightCycle_Impl::setControlType(const std::string& controlType) {
206 15 bool result = setString(OS_AvailabilityManager_NightCycleFields::ControlType, controlType);
207 15 return result;
208 }
209
210 ✗ void AvailabilityManagerNightCycle_Impl::resetControlType() {
211 ✗ bool result = setString(OS_AvailabilityManager_NightCycleFields::ControlType, "");
212 ✗ OS_ASSERT(result);
213 ✗ }
214
215 22 bool AvailabilityManagerNightCycle_Impl::setThermostatTolerance(double thermostatTolerance) {
216 22 bool result = setDouble(OS_AvailabilityManager_NightCycleFields::ThermostatTolerance, thermostatTolerance);
217 22 return result;
218 }
219
220 ✗ void AvailabilityManagerNightCycle_Impl::resetThermostatTolerance() {
221 ✗ bool result = setString(OS_AvailabilityManager_NightCycleFields::ThermostatTolerance, "");
222 ✗ OS_ASSERT(result);
223 ✗ }
224
225 23 bool AvailabilityManagerNightCycle_Impl::setCyclingRunTime(double cyclingRunTime) {
226 23 bool result = setDouble(OS_AvailabilityManager_NightCycleFields::CyclingRunTime, cyclingRunTime);
227 23 return result;
228 }
229
230 ✗ void AvailabilityManagerNightCycle_Impl::resetCyclingRunTime() {
231 ✗ bool result = setString(OS_AvailabilityManager_NightCycleFields::CyclingRunTime, "");
232 ✗ OS_ASSERT(result);
233 ✗ }
234
235 ✗ std::vector<std::string> AvailabilityManagerNightCycle_Impl::controlTypeValues() const {
236 ✗ return AvailabilityManagerNightCycle::controlTypeValues();
237 }
238
239 // Cycling Run Time Control Type
240 ✗ std::vector<std::string> AvailabilityManagerNightCycle_Impl::cyclingRunTimeControlTypeValues() const {
241 ✗ return AvailabilityManagerNightCycle::cyclingRunTimeControlTypeValues();
242 }
243
244 7 std::string AvailabilityManagerNightCycle_Impl::cyclingRunTimeControlType() const {
245
1/1
✓ Branch 1 taken 7 times.
7 boost::optional<std::string> value = getString(OS_AvailabilityManager_NightCycleFields::CyclingRunTimeControlType, true);
246
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 4 not taken.
7 OS_ASSERT(value);
247
2/2
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
14 return value.get();
248 7 }
249
250 ✗ bool AvailabilityManagerNightCycle_Impl::isCyclingRunTimeControlTypeDefaulted() const {
251 ✗ return isEmpty(OS_AvailabilityManager_NightCycleFields::CyclingRunTimeControlType);
252 }
253
254 1 bool AvailabilityManagerNightCycle_Impl::setCyclingRunTimeControlType(const std::string& cyclingRunTimeControlType) {
255 1 bool result = setString(OS_AvailabilityManager_NightCycleFields::CyclingRunTimeControlType, cyclingRunTimeControlType);
256 1 return result;
257 }
258
259 ✗ void AvailabilityManagerNightCycle_Impl::resetCyclingRunTimeControlType() {
260 ✗ bool result = setString(OS_AvailabilityManager_NightCycleFields::CyclingRunTimeControlType, "");
261 ✗ OS_ASSERT(result);
262 ✗ }
263
264 // Control Zone
265 29 ModelObjectList AvailabilityManagerNightCycle_Impl::controlThermalZoneList() const {
266 boost::optional<ModelObjectList> mo_list =
267
2/2
✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
29 getObject<ModelObject>().getModelObjectTarget<ModelObjectList>(OS_AvailabilityManager_NightCycleFields::ControlZoneorZoneListName);
268
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if (mo_list) {
269
2/2
✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
58 return mo_list.get();
270 } else {
271 ✗ LOG_AND_THROW(briefDescription() << " does not have a controlThermalZoneList attached");
272 }
273 29 }
274 4 void AvailabilityManagerNightCycle_Impl::clearControlThermalZoneList() {
275
1/1
✓ Branch 1 taken 4 times.
4 ModelObjectList mo_list = controlThermalZoneList();
276
1/1
✓ Branch 1 taken 4 times.
4 mo_list.removeAllModelObjects();
277 4 }
278
279 20 std::vector<ThermalZone> AvailabilityManagerNightCycle_Impl::controlThermalZones() const {
280
1/1
✓ Branch 1 taken 20 times.
20 ModelObjectList mo_list = controlThermalZoneList();
281 20 std::vector<ThermalZone> result;
282
3/3
✓ Branch 1 taken 20 times.
✓ Branch 8 taken 11 times.
✓ Branch 9 taken 20 times.
31 for (const ModelObject& mo : mo_list.modelObjects()) {
283
1/1
✓ Branch 1 taken 11 times.
11 boost::optional<ThermalZone> thermalZone = mo.optionalCast<ThermalZone>();
284
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (thermalZone) {
285
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 result.push_back(thermalZone.get());
286 } else {
287 ✗ LOG_AND_THROW(briefDescription() << " appears to have non ThermalZone objects in the controlThermalZones list");
288 }
289 31 }
290 40 return result;
291 20 }
292
293 3 bool AvailabilityManagerNightCycle_Impl::setControlThermalZones(const std::vector<ThermalZone>& thermalZones) {
294 // Clear it first
295
1/1
✓ Branch 1 taken 3 times.
3 clearControlThermalZoneList();
296 3 bool result = false;
297
298
1/1
✓ Branch 1 taken 3 times.
3 ModelObjectList mo_list = controlThermalZoneList();
299
2/2
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 3 times.
7 for (const ThermalZone& thermalZone : thermalZones) {
300
1/1
✓ Branch 1 taken 4 times.
4 result = mo_list.addModelObject(thermalZone);
301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!result) {
302 ✗ LOG_AND_THROW("Adding " << thermalZone.briefDescription() << " to ControlThermalZones failed for " << briefDescription());
303 }
304 }
305 3 return result;
306 3 }
307
308 1 void AvailabilityManagerNightCycle_Impl::resetControlThermalZones() {
309 // Clear it
310 1 clearControlThermalZoneList();
311 1 }
312
313 // Cooling Control Zones
314 26 ModelObjectList AvailabilityManagerNightCycle_Impl::coolingControlThermalZoneList() const {
315 boost::optional<ModelObjectList> mo_list =
316
2/2
✓ Branch 1 taken 26 times.
✓ Branch 4 taken 26 times.
26 getObject<ModelObject>().getModelObjectTarget<ModelObjectList>(OS_AvailabilityManager_NightCycleFields::CoolingControlZoneorZoneListName);
317
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if (mo_list) {
318
2/2
✓ Branch 1 taken 26 times.
✓ Branch 4 taken 26 times.
52 return mo_list.get();
319 } else {
320 ✗ LOG_AND_THROW(briefDescription() << " does not have a coolingControlThermalZoneList attached");
321 }
322 26 }
323
324 3 void AvailabilityManagerNightCycle_Impl::clearCoolingControlThermalZoneList() {
325
1/1
✓ Branch 1 taken 3 times.
3 ModelObjectList mo_list = coolingControlThermalZoneList();
326
1/1
✓ Branch 1 taken 3 times.
3 mo_list.removeAllModelObjects();
327 3 }
328
329 19 std::vector<ThermalZone> AvailabilityManagerNightCycle_Impl::coolingControlThermalZones() const {
330
1/1
✓ Branch 1 taken 19 times.
19 ModelObjectList mo_list = coolingControlThermalZoneList();
331 19 std::vector<ThermalZone> result;
332
3/3
✓ Branch 1 taken 19 times.
✓ Branch 8 taken 12 times.
✓ Branch 9 taken 19 times.
31 for (const ModelObject& mo : mo_list.modelObjects()) {
333
1/1
✓ Branch 1 taken 12 times.
12 boost::optional<ThermalZone> thermalZone = mo.optionalCast<ThermalZone>();
334
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if (thermalZone) {
335
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
12 result.push_back(thermalZone.get());
336 } else {
337 ✗ LOG_AND_THROW(briefDescription() << " appears to have non ThermalZone objects in the coolingControlThermalZones list");
338 }
339 31 }
340 38 return result;
341 19 }
342
343 2 bool AvailabilityManagerNightCycle_Impl::setCoolingControlThermalZones(const std::vector<ThermalZone>& thermalZones) {
344 // Clear it first
345
1/1
✓ Branch 1 taken 2 times.
2 clearCoolingControlThermalZoneList();
346 2 bool result = false;
347
348
1/1
✓ Branch 1 taken 2 times.
2 ModelObjectList mo_list = coolingControlThermalZoneList();
349
2/2
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 2 times.
5 for (const ThermalZone& thermalZone : thermalZones) {
350
1/1
✓ Branch 1 taken 3 times.
3 result = mo_list.addModelObject(thermalZone);
351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!result) {
352 ✗ LOG_AND_THROW("Adding " << thermalZone.briefDescription() << " to CoolingControlThermalZones failed for " << briefDescription());
353 }
354 }
355 2 return result;
356 2 }
357
358 1 void AvailabilityManagerNightCycle_Impl::resetCoolingControlThermalZones() {
359 // Clear it
360 1 clearCoolingControlThermalZoneList();
361 1 }
362
363 // Heating Control Zones
364 28 ModelObjectList AvailabilityManagerNightCycle_Impl::heatingControlThermalZoneList() const {
365 boost::optional<ModelObjectList> mo_list =
366
2/2
✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
28 getObject<ModelObject>().getModelObjectTarget<ModelObjectList>(OS_AvailabilityManager_NightCycleFields::HeatingControlZoneorZoneListName);
367
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if (mo_list) {
368
2/2
✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
56 return mo_list.get();
369 } else {
370 ✗ LOG_AND_THROW(briefDescription() << " does not have a heatingControlThermalZoneList attached");
371 }
372 28 }
373
374 4 void AvailabilityManagerNightCycle_Impl::clearHeatingControlThermalZoneList() {
375
1/1
✓ Branch 1 taken 4 times.
4 ModelObjectList mo_list = heatingControlThermalZoneList();
376
1/1
✓ Branch 1 taken 4 times.
4 mo_list.removeAllModelObjects();
377 4 }
378
379 19 std::vector<ThermalZone> AvailabilityManagerNightCycle_Impl::heatingControlThermalZones() const {
380
1/1
✓ Branch 1 taken 19 times.
19 ModelObjectList mo_list = heatingControlThermalZoneList();
381 19 std::vector<ThermalZone> result;
382
3/3
✓ Branch 1 taken 19 times.
✓ Branch 8 taken 24 times.
✓ Branch 9 taken 19 times.
43 for (const ModelObject& mo : mo_list.modelObjects()) {
383
1/1
✓ Branch 1 taken 24 times.
24 boost::optional<ThermalZone> thermalZone = mo.optionalCast<ThermalZone>();
384
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if (thermalZone) {
385
2/2
✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
24 result.push_back(thermalZone.get());
386 } else {
387 ✗ LOG_AND_THROW(briefDescription() << " appears to have non ThermalZone objects in the heatingControlThermalZones list");
388 }
389 43 }
390 38 return result;
391 19 }
392
393 3 bool AvailabilityManagerNightCycle_Impl::setHeatingControlThermalZones(const std::vector<ThermalZone>& thermalZones) {
394 // Clear it first
395
1/1
✓ Branch 1 taken 3 times.
3 clearHeatingControlThermalZoneList();
396 3 bool result = false;
397
398
1/1
✓ Branch 1 taken 3 times.
3 ModelObjectList mo_list = heatingControlThermalZoneList();
399
2/2
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 3 times.
9 for (const ThermalZone& thermalZone : thermalZones) {
400
1/1
✓ Branch 1 taken 6 times.
6 result = mo_list.addModelObject(thermalZone);
401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (!result) {
402 ✗ LOG_AND_THROW("Adding " << thermalZone.briefDescription() << " to HeatingControlThermalZones failed for " << briefDescription());
403 }
404 }
405 3 return result;
406 3 }
407
408 1 void AvailabilityManagerNightCycle_Impl::resetHeatingControlThermalZones() {
409 // Clear it
410 1 clearHeatingControlThermalZoneList();
411 1 }
412
413 // Heating Zone Fans Only Zones
414
415 28 ModelObjectList AvailabilityManagerNightCycle_Impl::heatingZoneFansOnlyThermalZoneList() const {
416
1/1
✓ Branch 1 taken 28 times.
56 boost::optional<ModelObjectList> mo_list = getObject<ModelObject>().getModelObjectTarget<ModelObjectList>(
417
1/1
✓ Branch 1 taken 28 times.
28 OS_AvailabilityManager_NightCycleFields::HeatingZoneFansOnlyZoneorZoneListName);
418
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if (mo_list) {
419
2/2
✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
56 return mo_list.get();
420 } else {
421 ✗ LOG_AND_THROW(briefDescription() << " does not have a heatingZoneFansOnlyThermalZoneList attached");
422 }
423 28 }
424
425 4 void AvailabilityManagerNightCycle_Impl::clearHeatingZoneFansOnlyThermalZoneList() {
426
1/1
✓ Branch 1 taken 4 times.
4 ModelObjectList mo_list = heatingZoneFansOnlyThermalZoneList();
427
1/1
✓ Branch 1 taken 4 times.
4 mo_list.removeAllModelObjects();
428 4 }
429
430 19 std::vector<ThermalZone> AvailabilityManagerNightCycle_Impl::heatingZoneFansOnlyThermalZones() const {
431
1/1
✓ Branch 1 taken 19 times.
19 ModelObjectList mo_list = heatingZoneFansOnlyThermalZoneList();
432 19 std::vector<ThermalZone> result;
433
3/3
✓ Branch 1 taken 19 times.
✓ Branch 8 taken 17 times.
✓ Branch 9 taken 19 times.
36 for (const ModelObject& mo : mo_list.modelObjects()) {
434
1/1
✓ Branch 1 taken 17 times.
17 boost::optional<ThermalZone> thermalZone = mo.optionalCast<ThermalZone>();
435
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if (thermalZone) {
436
2/2
✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
17 result.push_back(thermalZone.get());
437 } else {
438 ✗ LOG_AND_THROW(briefDescription() << " appears to have non ThermalZone objects in the heatingZoneFansOnlyThermalZones list");
439 }
440 36 }
441 38 return result;
442 19 }
443
444 3 bool AvailabilityManagerNightCycle_Impl::setHeatingZoneFansOnlyThermalZones(const std::vector<ThermalZone>& thermalZones) {
445 // Clear it first
446
1/1
✓ Branch 1 taken 3 times.
3 clearHeatingZoneFansOnlyThermalZoneList();
447 3 bool result = false;
448
1/1
✓ Branch 1 taken 3 times.
3 ModelObjectList mo_list = heatingZoneFansOnlyThermalZoneList();
449
2/2
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 3 times.
8 for (const ThermalZone& thermalZone : thermalZones) {
450
1/1
✓ Branch 1 taken 5 times.
5 result = mo_list.addModelObject(thermalZone);
451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!result) {
452 ✗ LOG_AND_THROW("Adding " << thermalZone.briefDescription() << " to HeatingZoneFansOnlyThermalZones failed for " << briefDescription());
453 }
454 }
455 3 return result;
456 3 }
457
458 1 void AvailabilityManagerNightCycle_Impl::resetHeatingZoneFansOnlyThermalZones() {
459 // Clear it
460 1 clearHeatingZoneFansOnlyThermalZoneList();
461 1 }
462
463 /*
464 * bool setControlThermalZones(const std::vector<ThermalZone>& thermalZones);
465 * void resetControlThermalZones();
466 *
467 * std::vector<ThermalZone> coolingControlZones() const;
468 * bool setCoolingControlZones(const std::vector<ThermalZone>& thermalZones);
469 * void resetCoolingControlZones();
470 *
471 * std::vector<ThermalZone> heatingControlZones() const;
472 * bool setHeatingControlZones(const std::vector<ThermalZone>& thermalZones);
473 * void resetHeatingControlZones();
474 *
475 * std::vector<ThermalZone> heatingZoneFansOnlyZones() const;
476 * bool setHeatingZoneFansOnlyZones(const std::vector<ThermalZone>& thermalZones);
477 * void resetHeatingZoneFansOnlyZones();
478 */
479
480 } // namespace detail
481
482 17 AvailabilityManagerNightCycle::AvailabilityManagerNightCycle(const Model& model)
483 17 : AvailabilityManager(AvailabilityManagerNightCycle::iddObjectType(), model) {
484
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
✗ Branch 5 not taken.
17 OS_ASSERT(getImpl<detail::AvailabilityManagerNightCycle_Impl>());
485
486 {
487
1/1
✓ Branch 1 taken 17 times.
17 auto schedule = model.alwaysOnDiscreteSchedule();
488
1/1
✓ Branch 1 taken 17 times.
17 setApplicabilitySchedule(schedule);
489 17 }
490
491
1/1
✓ Branch 1 taken 17 times.
17 setThermostatTolerance(1.0);
492
1/1
✓ Branch 1 taken 17 times.
17 setCyclingRunTime(3600);
493
494 // Control Zone List
495
1/1
✓ Branch 1 taken 17 times.
17 ModelObjectList controlThermalZoneList = ModelObjectList(model);
496
4/4
✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
✓ Branch 7 taken 17 times.
✓ Branch 10 taken 17 times.
17 controlThermalZoneList.setName(this->name().get() + " Control Zone List");
497
2/2
✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
17 bool ok = setPointer(OS_AvailabilityManager_NightCycleFields::ControlZoneorZoneListName, controlThermalZoneList.handle());
498
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 3 not taken.
17 OS_ASSERT(ok);
499
500 // Cooling Control Zone List
501
1/1
✓ Branch 1 taken 17 times.
17 ModelObjectList coolingControlThermalZoneList = ModelObjectList(model);
502
4/4
✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
✓ Branch 7 taken 17 times.
✓ Branch 10 taken 17 times.
17 coolingControlThermalZoneList.setName(this->name().get() + " Cooling Control Zone List");
503
2/2
✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
17 ok = setPointer(OS_AvailabilityManager_NightCycleFields::CoolingControlZoneorZoneListName, coolingControlThermalZoneList.handle());
504
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 3 not taken.
17 OS_ASSERT(ok);
505
506 // Heating Control Zone List
507
1/1
✓ Branch 1 taken 17 times.
17 ModelObjectList heatingControlThermalZoneList = ModelObjectList(model);
508
4/4
✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
✓ Branch 7 taken 17 times.
✓ Branch 10 taken 17 times.
17 heatingControlThermalZoneList.setName(this->name().get() + " Heating Control Zone List");
509
2/2
✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
17 ok = setPointer(OS_AvailabilityManager_NightCycleFields::HeatingControlZoneorZoneListName, heatingControlThermalZoneList.handle());
510
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 3 not taken.
17 OS_ASSERT(ok);
511
512 // Heating Zone Fans Only Zone List
513
1/1
✓ Branch 1 taken 17 times.
17 ModelObjectList heatingZoneFansOnlyThermalZoneList = ModelObjectList(model);
514
4/4
✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
✓ Branch 7 taken 17 times.
✓ Branch 10 taken 17 times.
17 heatingZoneFansOnlyThermalZoneList.setName(this->name().get() + " Heating Zone Fans Only Zone List");
515
2/2
✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
17 ok = setPointer(OS_AvailabilityManager_NightCycleFields::HeatingZoneFansOnlyZoneorZoneListName, heatingZoneFansOnlyThermalZoneList.handle());
516
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 3 not taken.
17 OS_ASSERT(ok);
517 17 }
518
519 7642 IddObjectType AvailabilityManagerNightCycle::iddObjectType() {
520
1/1
✓ Branch 1 taken 7642 times.
7642 return {IddObjectType::OS_AvailabilityManager_NightCycle};
521 }
522
523 ✗ std::vector<std::string> AvailabilityManagerNightCycle::controlTypeValues() {
524 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_AvailabilityManager_NightCycleFields::ControlType);
525 }
526
527 8 std::string AvailabilityManagerNightCycle::controlType() const {
528
1/1
✓ Branch 3 taken 8 times.
8 return getImpl<detail::AvailabilityManagerNightCycle_Impl>()->controlType();
529 }
530
531 ✗ bool AvailabilityManagerNightCycle::isControlTypeDefaulted() const {
532 ✗ return getImpl<detail::AvailabilityManagerNightCycle_Impl>()->isControlTypeDefaulted();
533 }
534
535 5 double AvailabilityManagerNightCycle::thermostatTolerance() const {
536
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::AvailabilityManagerNightCycle_Impl>()->thermostatTolerance();
537 }
538
539 ✗ bool AvailabilityManagerNightCycle::isThermostatToleranceDefaulted() const {
540 ✗ return getImpl<detail::AvailabilityManagerNightCycle_Impl>()->isThermostatToleranceDefaulted();
541 }
542
543 7 double AvailabilityManagerNightCycle::cyclingRunTime() const {
544
1/1
✓ Branch 3 taken 7 times.
7 return getImpl<detail::AvailabilityManagerNightCycle_Impl>()->cyclingRunTime();
545 }
546
547 ✗ bool AvailabilityManagerNightCycle::isCyclingRunTimeDefaulted() const {
548 ✗ return getImpl<detail::AvailabilityManagerNightCycle_Impl>()->isCyclingRunTimeDefaulted();
549 }
550
551 15 bool AvailabilityManagerNightCycle::setControlType(const std::string& controlType) {
552
1/1
✓ Branch 3 taken 15 times.
15 return getImpl<detail::AvailabilityManagerNightCycle_Impl>()->setControlType(controlType);
553 }
554
555 ✗ void AvailabilityManagerNightCycle::resetControlType() {
556 ✗ getImpl<detail::AvailabilityManagerNightCycle_Impl>()->resetControlType();
557 ✗ }
558
559 22 bool AvailabilityManagerNightCycle::setThermostatTolerance(double thermostatTolerance) {
560
1/1
✓ Branch 3 taken 22 times.
22 return getImpl<detail::AvailabilityManagerNightCycle_Impl>()->setThermostatTolerance(thermostatTolerance);
561 }
562
563 ✗ void AvailabilityManagerNightCycle::resetThermostatTolerance() {
564 ✗ getImpl<detail::AvailabilityManagerNightCycle_Impl>()->resetThermostatTolerance();
565 ✗ }
566
567 23 bool AvailabilityManagerNightCycle::setCyclingRunTime(double cyclingRunTime) {
568
1/1
✓ Branch 3 taken 23 times.
23 return getImpl<detail::AvailabilityManagerNightCycle_Impl>()->setCyclingRunTime(cyclingRunTime);
569 }
570
571 ✗ void AvailabilityManagerNightCycle::resetCyclingRunTime() {
572 ✗ getImpl<detail::AvailabilityManagerNightCycle_Impl>()->resetCyclingRunTime();
573 ✗ }
574
575 20 std::vector<ThermalZone> AvailabilityManagerNightCycle::controlThermalZones() const {
576
1/1
✓ Branch 3 taken 20 times.
20 return getImpl<detail::AvailabilityManagerNightCycle_Impl>()->controlThermalZones();
577 }
578 3 bool AvailabilityManagerNightCycle::setControlThermalZones(const std::vector<ThermalZone>& thermalZones) {
579
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::AvailabilityManagerNightCycle_Impl>()->setControlThermalZones(thermalZones);
580 }
581 1 void AvailabilityManagerNightCycle::resetControlThermalZones() {
582
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::AvailabilityManagerNightCycle_Impl>()->resetControlThermalZones();
583 1 }
584
585 19 std::vector<ThermalZone> AvailabilityManagerNightCycle::coolingControlThermalZones() const {
586
1/1
✓ Branch 3 taken 19 times.
19 return getImpl<detail::AvailabilityManagerNightCycle_Impl>()->coolingControlThermalZones();
587 }
588 2 bool AvailabilityManagerNightCycle::setCoolingControlThermalZones(const std::vector<ThermalZone>& thermalZones) {
589
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::AvailabilityManagerNightCycle_Impl>()->setCoolingControlThermalZones(thermalZones);
590 }
591 1 void AvailabilityManagerNightCycle::resetCoolingControlThermalZones() {
592
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::AvailabilityManagerNightCycle_Impl>()->resetCoolingControlThermalZones();
593 1 }
594
595 19 std::vector<ThermalZone> AvailabilityManagerNightCycle::heatingControlThermalZones() const {
596
1/1
✓ Branch 3 taken 19 times.
19 return getImpl<detail::AvailabilityManagerNightCycle_Impl>()->heatingControlThermalZones();
597 }
598 3 bool AvailabilityManagerNightCycle::setHeatingControlThermalZones(const std::vector<ThermalZone>& thermalZones) {
599
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::AvailabilityManagerNightCycle_Impl>()->setHeatingControlThermalZones(thermalZones);
600 }
601 1 void AvailabilityManagerNightCycle::resetHeatingControlThermalZones() {
602
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::AvailabilityManagerNightCycle_Impl>()->resetHeatingControlThermalZones();
603 1 }
604
605 19 std::vector<ThermalZone> AvailabilityManagerNightCycle::heatingZoneFansOnlyThermalZones() const {
606
1/1
✓ Branch 3 taken 19 times.
19 return getImpl<detail::AvailabilityManagerNightCycle_Impl>()->heatingZoneFansOnlyThermalZones();
607 }
608 3 bool AvailabilityManagerNightCycle::setHeatingZoneFansOnlyThermalZones(const std::vector<ThermalZone>& thermalZones) {
609
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::AvailabilityManagerNightCycle_Impl>()->setHeatingZoneFansOnlyThermalZones(thermalZones);
610 }
611 1 void AvailabilityManagerNightCycle::resetHeatingZoneFansOnlyThermalZones() {
612
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::AvailabilityManagerNightCycle_Impl>()->resetHeatingZoneFansOnlyThermalZones();
613 1 }
614
615 // Cycling Run Time Control Type
616 ✗ std::vector<std::string> AvailabilityManagerNightCycle::cyclingRunTimeControlTypeValues() {
617 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(),
618 ✗ OS_AvailabilityManager_NightCycleFields::CyclingRunTimeControlType);
619 }
620
621 7 std::string AvailabilityManagerNightCycle::cyclingRunTimeControlType() const {
622
1/1
✓ Branch 3 taken 7 times.
7 return getImpl<detail::AvailabilityManagerNightCycle_Impl>()->cyclingRunTimeControlType();
623 }
624
625 ✗ bool AvailabilityManagerNightCycle::isCyclingRunTimeControlTypeDefaulted() const {
626 ✗ return getImpl<detail::AvailabilityManagerNightCycle_Impl>()->isCyclingRunTimeControlTypeDefaulted();
627 }
628
629 1 bool AvailabilityManagerNightCycle::setCyclingRunTimeControlType(const std::string& cyclingRunTimeControlType) {
630
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::AvailabilityManagerNightCycle_Impl>()->setCyclingRunTimeControlType(cyclingRunTimeControlType);
631 }
632
633 ✗ void AvailabilityManagerNightCycle::resetCyclingRunTimeControlType() {
634 ✗ getImpl<detail::AvailabilityManagerNightCycle_Impl>()->resetCyclingRunTimeControlType();
635 ✗ }
636
637 6 boost::optional<AirLoopHVAC> AvailabilityManagerNightCycle::airLoopHVAC() const {
638
1/1
✓ Branch 3 taken 6 times.
6 return getImpl<detail::AvailabilityManagerNightCycle_Impl>()->airLoopHVAC();
639 }
640
641 9 Schedule AvailabilityManagerNightCycle::applicabilitySchedule() const {
642
1/1
✓ Branch 3 taken 9 times.
9 return getImpl<detail::AvailabilityManagerNightCycle_Impl>()->applicabilitySchedule();
643 }
644
645 19 bool AvailabilityManagerNightCycle::setApplicabilitySchedule(Schedule& schedule) {
646
1/1
✓ Branch 3 taken 19 times.
19 return getImpl<detail::AvailabilityManagerNightCycle_Impl>()->setApplicabilitySchedule(schedule);
647 }
648
649 9 boost::optional<Schedule> AvailabilityManagerNightCycle::fanSchedule() const {
650
1/1
✓ Branch 3 taken 9 times.
9 return getImpl<detail::AvailabilityManagerNightCycle_Impl>()->fanSchedule();
651 }
652
653 /// @cond
654 21 AvailabilityManagerNightCycle::AvailabilityManagerNightCycle(std::shared_ptr<detail::AvailabilityManagerNightCycle_Impl> impl)
655
1/1
✓ Branch 3 taken 21 times.
21 : AvailabilityManager(std::move(impl)) {}
656 /// @endcond
657
658 } // namespace model
659 } // namespace openstudio
660