GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 81.7% 403 / 0 / 493
Functions: 86.5% 64 / 0 / 74
Branches: 65.7% 550 / 0 / 837

src/model/AirLoopHVACOutdoorAirSystem.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 "AirLoopHVACOutdoorAirSystem.hpp"
7 #include "AirLoopHVACOutdoorAirSystem_Impl.hpp"
8 #include "AirLoopHVACDedicatedOutdoorAirSystem.hpp"
9 #include "AirLoopHVACDedicatedOutdoorAirSystem_Impl.hpp"
10 #include "AirToAirComponent.hpp"
11 #include "AirToAirComponent_Impl.hpp"
12 #include "WaterToAirComponent.hpp"
13 #include "WaterToAirComponent_Impl.hpp"
14 #include "ZoneHVACComponent.hpp"
15 #include "ZoneHVACComponent_Impl.hpp"
16 #include "ControllerOutdoorAir.hpp"
17 #include "ControllerOutdoorAir_Impl.hpp"
18 #include "Node.hpp"
19 #include "Node_Impl.hpp"
20 #include "AirLoopHVAC.hpp"
21 #include "AirLoopHVAC_Impl.hpp"
22 #include "AirflowNetworkDistributionNode.hpp"
23 #include "AirflowNetworkDistributionNode_Impl.hpp"
24 #include "Model.hpp"
25 #include "Model_Impl.hpp"
26 #include "ModelExtensibleGroup.hpp"
27 #include "SetpointManager.hpp"
28 #include "SetpointManager_Impl.hpp"
29
30 #include "../utilities/core/Assert.hpp"
31 #include "../utilities/core/Compare.hpp"
32 #include "../utilities/core/ContainersMove.hpp"
33 #include "../utilities/data/DataEnums.hpp"
34 #include "../utilities/idf/IdfExtensibleGroup.hpp"
35
36 #include <utilities/idd/OS_AirLoopHVAC_OutdoorAirSystem_FieldEnums.hxx>
37 #include <utilities/idd/OS_AvailabilityManagerAssignmentList_FieldEnums.hxx>
38 #include <utilities/idd/OS_Controller_OutdoorAir_FieldEnums.hxx>
39 #include <utilities/idd/IddEnums.hxx>
40
41 #include <algorithm>
42 #include <utility>
43
44 namespace openstudio {
45
46 namespace model {
47
48 namespace detail {
49
50 // Helpers
51 6113 std::pair<bool, boost::optional<ModelObject>> getOutletNodeForComponent(const ModelObject& modelObject) {
52
3/3
✓ Branch 1 taken 6113 times.
✓ Branch 3 taken 5502 times.
✓ Branch 4 taken 611 times.
12226 if (auto comp_ = modelObject.optionalCast<StraightComponent>()) {
53
2/2
✓ Branch 1 taken 5502 times.
✓ Branch 4 taken 5502 times.
5502 return {true, comp_->outletModelObject()};
54
3/3
✓ Branch 1 taken 611 times.
✓ Branch 3 taken 544 times.
✓ Branch 4 taken 67 times.
1222 } else if (auto comp_ = modelObject.optionalCast<AirToAirComponent>()) {
55
2/2
✓ Branch 1 taken 544 times.
✓ Branch 4 taken 544 times.
544 return {true, comp_->secondaryAirOutletModelObject()};
56
3/3
✓ Branch 1 taken 67 times.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 26 times.
134 } else if (auto comp_ = modelObject.optionalCast<WaterToAirComponent>()) {
57
2/2
✓ Branch 1 taken 41 times.
✓ Branch 4 taken 41 times.
41 return {true, comp_->airOutletModelObject()};
58
2/3
✓ Branch 1 taken 26 times.
✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
52 } else if (auto comp_ = modelObject.optionalCast<ZoneHVACComponent>()) {
59
2/2
✓ Branch 1 taken 26 times.
✓ Branch 4 taken 26 times.
26 return {true, comp_->airOutletModelObject()};
60 6817 }
61 ✗ return {false, boost::none};
62 }
63
64 285 AirLoopHVACOutdoorAirSystem_Impl::AirLoopHVACOutdoorAirSystem_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
65 285 : HVACComponent_Impl(idfObject, model, keepHandle) {
66
4/6
✓ Branch 1 taken 285 times.
✓ Branch 4 taken 285 times.
✓ Branch 7 taken 285 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 285 times.
✗ Branch 13 not taken.
285 OS_ASSERT(idfObject.iddObject().type() == AirLoopHVACOutdoorAirSystem::iddObjectType());
67 285 }
68
69 39 AirLoopHVACOutdoorAirSystem_Impl::AirLoopHVACOutdoorAirSystem_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model,
70 39 bool keepHandle)
71 39 : HVACComponent_Impl(other, model, keepHandle) {
72
4/6
✓ Branch 1 taken 39 times.
✓ Branch 4 taken 39 times.
✓ Branch 7 taken 39 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 39 times.
✗ Branch 13 not taken.
39 OS_ASSERT(other.iddObject().type() == AirLoopHVACOutdoorAirSystem::iddObjectType());
73 39 }
74
75 139 AirLoopHVACOutdoorAirSystem_Impl::AirLoopHVACOutdoorAirSystem_Impl(const AirLoopHVACOutdoorAirSystem_Impl& other, Model_Impl* model,
76 139 bool keepHandle)
77 139 : HVACComponent_Impl(other, model, keepHandle) {}
78
79 // virtual destructor
80
81 // return the parent object in the hierarchy
82 8 boost::optional<ParentObject> AirLoopHVACOutdoorAirSystem_Impl::parent() const {
83 8 return {};
84 }
85
86 58 std::vector<ModelObject> AirLoopHVACOutdoorAirSystem_Impl::children() const {
87 58 std::vector<ModelObject> result;
88
2/2
✓ Branch 1 taken 58 times.
✓ Branch 4 taken 58 times.
58 result.push_back(this->getControllerOutdoorAir());
89 std::vector<AirflowNetworkDistributionNode> myAFNItems =
90
3/3
✓ Branch 1 taken 58 times.
✓ Branch 4 taken 58 times.
✓ Branch 7 taken 58 times.
58 getObject<ModelObject>().getModelObjectSources<AirflowNetworkDistributionNode>(AirflowNetworkDistributionNode::iddObjectType());
91
1/1
✓ Branch 5 taken 58 times.
58 result.insert(result.end(), myAFNItems.begin(), myAFNItems.end());
92 116 return result;
93 58 }
94
95 // Get all output variable names that could be associated with this object.
96 1 const std::vector<std::string>& AirLoopHVACOutdoorAirSystem_Impl::outputVariableNames() const {
97
2/4
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
1 static const std::vector<std::string> result;
98 // Not Appropriate: No variables available
99 // The impact of using outside air/mechanical ventilation is described in the section: Outdoor Air Ventilation Outputs.
100 1 return result;
101 }
102
103 1875 IddObjectType AirLoopHVACOutdoorAirSystem_Impl::iddObjectType() const {
104 1875 return AirLoopHVACOutdoorAirSystem::iddObjectType();
105 }
106
107 416 unsigned AirLoopHVACOutdoorAirSystem_Impl::returnAirPort() const {
108 416 return openstudio::OS_AirLoopHVAC_OutdoorAirSystemFields::ReturnAirStreamNodeName;
109 }
110
111 5749 unsigned AirLoopHVACOutdoorAirSystem_Impl::outdoorAirPort() const {
112 5749 return openstudio::OS_AirLoopHVAC_OutdoorAirSystemFields::OutdoorAirStreamNodeName;
113 }
114
115 4945 unsigned AirLoopHVACOutdoorAirSystem_Impl::reliefAirPort() const {
116 4945 return openstudio::OS_AirLoopHVAC_OutdoorAirSystemFields::ReliefAirStreamNodeName;
117 }
118
119 7022 unsigned AirLoopHVACOutdoorAirSystem_Impl::mixedAirPort() const {
120 7022 return openstudio::OS_AirLoopHVAC_OutdoorAirSystemFields::MixedAirNodeName;
121 }
122
123 179 OptionalModelObject AirLoopHVACOutdoorAirSystem_Impl::returnAirModelObject() const {
124 179 return this->connectedObject(this->returnAirPort());
125 }
126
127 5473 OptionalModelObject AirLoopHVACOutdoorAirSystem_Impl::outdoorAirModelObject() const {
128 5473 return this->connectedObject(this->outdoorAirPort());
129 }
130
131 4669 OptionalModelObject AirLoopHVACOutdoorAirSystem_Impl::reliefAirModelObject() const {
132 4669 return this->connectedObject(this->reliefAirPort());
133 }
134
135 6785 OptionalModelObject AirLoopHVACOutdoorAirSystem_Impl::mixedAirModelObject() const {
136 6785 return this->connectedObject(this->mixedAirPort());
137 }
138
139 456 ControllerOutdoorAir AirLoopHVACOutdoorAirSystem_Impl::getControllerOutdoorAir() const {
140
3/3
✓ Branch 1 taken 456 times.
✓ Branch 4 taken 456 times.
✓ Branch 7 taken 456 times.
456 return this->getTarget(openstudio::OS_AirLoopHVAC_OutdoorAirSystemFields::ControllerName)->cast<ControllerOutdoorAir>();
141 }
142
143 254 bool AirLoopHVACOutdoorAirSystem_Impl::setControllerOutdoorAir(const ControllerOutdoorAir& controllerOutdoorAir) {
144
2/2
✓ Branch 1 taken 254 times.
✓ Branch 4 taken 254 times.
254 return this->setPointer(openstudio::OS_AirLoopHVAC_OutdoorAirSystemFields::ControllerName, controllerOutdoorAir.handle());
145 }
146
147 8 ModelObject AirLoopHVACOutdoorAirSystem_Impl::clone(Model model) const {
148
3/3
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
8 auto oaclone = ModelObject_Impl::clone(model).cast<AirLoopHVACOutdoorAirSystem>();
149
150 // Clone OA controller
151
4/4
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
✓ Branch 10 taken 8 times.
8 auto controllerOutdoorAir = getControllerOutdoorAir().clone(model).cast<ControllerOutdoorAir>();
152
1/1
✓ Branch 1 taken 8 times.
8 oaclone.setControllerOutdoorAir(controllerOutdoorAir);
153
154
3/3
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
16 oaclone.setString(oaclone.mixedAirPort(), "");
155
3/3
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
16 oaclone.setString(oaclone.returnAirPort(), "");
156
3/3
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
16 oaclone.setString(oaclone.outdoorAirPort(), "");
157
3/3
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
8 oaclone.setString(oaclone.reliefAirPort(), "");
158
159
1/1
✓ Branch 1 taken 8 times.
8 Node oaNodeClone(model);
160
5/5
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
✓ Branch 10 taken 8 times.
✓ Branch 13 taken 8 times.
8 model.connect(oaNodeClone, oaNodeClone.outletPort(), oaclone, oaclone.outdoorAirPort());
161
162
1/1
✓ Branch 1 taken 8 times.
8 Node reliefNodeClone(model);
163
5/5
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
✓ Branch 10 taken 8 times.
✓ Branch 13 taken 8 times.
8 model.connect(oaclone, oaclone.reliefAirPort(), reliefNodeClone, reliefNodeClone.inletPort());
164
165 // Clone oa stream comps
166 // Note that in the case of AirToAirComponent, this also does stuff to the relief side!
167
3/3
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
8 auto oaComps = oaComponents();
168
1/1
✓ Branch 3 taken 8 times.
8 std::reverse(oaComps.begin(), oaComps.end());
169 8 std::vector<Node> oaNodes;
170
171
2/2
✓ Branch 5 taken 40 times.
✓ Branch 6 taken 8 times.
48 for (const auto& comp : oaComps) {
172
4/4
✓ Branch 1 taken 40 times.
✓ Branch 4 taken 40 times.
✓ Branch 7 taken 24 times.
✓ Branch 8 taken 16 times.
40 if (comp.iddObjectType() == Node::iddObjectType()) {
173
2/2
✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
24 oaNodes.push_back(comp.cast<Node>());
174 } else {
175
3/3
✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 7 taken 16 times.
16 auto compClone = comp.clone(model).cast<HVACComponent>();
176
1/1
✓ Branch 1 taken 16 times.
16 compClone.addToNode(oaNodeClone);
177 16 }
178 }
179
180
4/4
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
✓ Branch 10 taken 8 times.
8 auto oaNodeClones = subsetCastVector<Node>(oaclone.oaComponents());
181
1/1
✓ Branch 3 taken 8 times.
8 std::reverse(oaNodeClones.begin(), oaNodeClones.end());
182
183
1/2
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if (oaNodes.size() == oaNodeClones.size()) {
184
2/2
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 8 times.
32 for (size_t i = 0; i < oaNodes.size(); ++i) {
185
1/1
✓ Branch 2 taken 24 times.
24 const auto node = oaNodes[i];
186
1/1
✓ Branch 2 taken 24 times.
24 auto cloneNode = oaNodeClones[i];
187
188
1/1
✓ Branch 1 taken 24 times.
24 auto spms = node.setpointManagers();
189
1/2
✗ Branch 5 not taken.
✓ Branch 6 taken 24 times.
24 for (const auto& spm : spms) {
190 ✗ auto spmclone = spm.clone(model).cast<SetpointManager>();
191 ✗ spmclone.addToNode(cloneNode);
192 ✗ }
193 24 }
194 }
195
196 // Clone relief stream comps
197
198
3/3
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
8 auto reliefComps = reliefComponents();
199
200
1/1
✓ Branch 1 taken 8 times.
8 auto reliefAirToAirComps = subsetCastVector<AirToAirComponent>(reliefComps);
201
202 8 std::vector<Node> reliefNodes;
203
204
2/2
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 6 times.
8 if (reliefAirToAirComps.empty()) {
205 // Business as usual, but this is faster this way as we keep the same node to connect to throughout
206 2 std::vector<Node> reliefNodes;
207
208
2/2
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 2 times.
8 for (const auto& comp : reliefComps) {
209
4/4
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 2 times.
6 if (comp.iddObjectType() == Node::iddObjectType()) {
210
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 reliefNodes.push_back(comp.cast<Node>());
211 } else {
212
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 auto compClone = comp.clone(model).cast<HVACComponent>();
213
1/1
✓ Branch 1 taken 2 times.
2 compClone.addToNode(reliefNodeClone);
214 2 }
215 }
216 2 } else {
217
3/3
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
6 auto targetNode = oaclone.reliefAirModelObject()->cast<Node>();
218
219
2/2
✓ Branch 5 taken 34 times.
✓ Branch 6 taken 6 times.
40 for (const auto& comp : reliefComps) {
220
4/4
✓ Branch 1 taken 34 times.
✓ Branch 4 taken 34 times.
✓ Branch 7 taken 20 times.
✓ Branch 8 taken 14 times.
34 if (comp.iddObjectType() == Node::iddObjectType()) {
221
2/2
✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
20 reliefNodes.push_back(comp.cast<Node>());
222
3/3
✓ Branch 1 taken 14 times.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 6 times.
28 } else if (comp.optionalCast<AirToAirComponent>()) {
223
1/1
✓ Branch 1 taken 8 times.
8 auto reliefCloneMo_ = targetNode.outletModelObject();
224
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 4 not taken.
8 OS_ASSERT(reliefCloneMo_);
225
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
8 auto reliefCloneAirToAir_ = reliefCloneMo_->optionalCast<AirToAirComponent>();
226
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 4 not taken.
8 OS_ASSERT(reliefCloneAirToAir_);
227
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
8 auto mo_ = reliefCloneAirToAir_->secondaryAirOutletModelObject();
228
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 4 not taken.
8 OS_ASSERT(mo_);
229
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
8 targetNode = mo_->cast<Node>();
230 8 } else {
231
3/3
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
6 auto compClone = comp.clone(model).cast<HVACComponent>();
232
1/1
✓ Branch 1 taken 6 times.
6 compClone.addToNode(targetNode);
233
1/1
✓ Branch 1 taken 6 times.
6 auto [ok, mo_] = getOutletNodeForComponent(compClone);
234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (!ok) {
235 ✗ LOG_AND_THROW("For " << briefDescription() << ", unexpected reliefComponent found: " << compClone.briefDescription());
236 }
237
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 4 not taken.
6 OS_ASSERT(mo_);
238
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 targetNode = mo_->cast<Node>();
239 6 }
240 }
241 6 }
242
243
4/4
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
✓ Branch 10 taken 8 times.
8 auto reliefNodeClones = subsetCastVector<Node>(oaclone.reliefComponents());
244
245
2/2
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 2 times.
8 if (reliefNodes.size() == reliefNodeClones.size()) {
246
2/2
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 6 times.
26 for (size_t i = 0; i < reliefNodes.size(); ++i) {
247
1/1
✓ Branch 2 taken 20 times.
20 const auto node = reliefNodes[i];
248
1/1
✓ Branch 2 taken 20 times.
20 auto cloneNode = reliefNodeClones[i];
249
250
1/1
✓ Branch 1 taken 20 times.
20 auto spms = node.setpointManagers();
251
1/2
✗ Branch 5 not taken.
✓ Branch 6 taken 20 times.
20 for (const auto& spm : spms) {
252 ✗ auto spmclone = spm.clone(model).cast<SetpointManager>();
253 ✗ spmclone.addToNode(cloneNode);
254 ✗ }
255 20 }
256 }
257
258 16 return std::move(oaclone);
259 8 }
260
261 15 std::vector<IdfObject> AirLoopHVACOutdoorAirSystem_Impl::remove() {
262 // Handle h = this->handle();
263
264 15 ModelObjectVector modelObjects;
265 15 ModelObjectVector::iterator it;
266
3/3
✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
15 modelObjects = this->components();
267
2/2
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 15 times.
97 for (it = modelObjects.begin(); it != modelObjects.end(); ++it) {
268
2/3
✓ Branch 2 taken 82 times.
✓ Branch 4 taken 82 times.
✗ Branch 5 not taken.
164 if (OptionalHVACComponent comp = it->optionalCast<HVACComponent>()) {
269
3/3
✓ Branch 2 taken 82 times.
✓ Branch 5 taken 68 times.
✓ Branch 6 taken 14 times.
82 if (!it->handle().isNull()) {
270
2/2
✓ Branch 1 taken 68 times.
✓ Branch 4 taken 68 times.
68 comp->disconnect();
271
2/2
✓ Branch 1 taken 68 times.
✓ Branch 4 taken 68 times.
68 comp->remove();
272 }
273 82 }
274 }
275
276 //reliefAirModelObject()->remove();
277 //outdoorAirModelObject()->remove();
278
4/4
✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
✓ Branch 10 taken 15 times.
15 model().disconnect(getObject<ModelObject>(), outdoorAirPort());
279
4/4
✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
✓ Branch 10 taken 15 times.
15 model().disconnect(getObject<ModelObject>(), reliefAirPort());
280
281
2/3
✓ Branch 1 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
30 if (auto airLoop_ = this->airLoopHVAC()) {
282 ✗ OptionalNode targetModelObject;
283 ✗ OptionalNode sourceModelObject;
284 ✗ targetModelObject = this->mixedAirModelObject()->optionalCast<Node>();
285 ✗ sourceModelObject = this->returnAirModelObject()->optionalCast<Node>();
286 // OptionalUnsigned targetPort = this->connectedObjectPort(openstudio::OS_AirLoopHVAC_OutdoorAirSystemFields::MixedAirNodeName);
287 ✗ OptionalUnsigned sourcePort = this->connectedObjectPort(openstudio::OS_AirLoopHVAC_OutdoorAirSystemFields::ReturnAirStreamNodeName);
288
289 ✗ OptionalModelObject target2ModelObject = targetModelObject->outletModelObject();
290 ✗ OptionalModelObject source2ModelObject = sourceModelObject->inletModelObject();
291 ✗ OptionalUnsigned target2Port = targetModelObject->connectedObjectPort(targetModelObject->outletPort());
292 ✗ OptionalUnsigned source2Port = sourceModelObject->connectedObjectPort(sourceModelObject->inletPort());
293
294 ✗ OptionalNode supplyInletNode = airLoop_->supplyInletNode();
295 ✗ OptionalNode supplyOutletNode = OptionalNode(airLoop_->supplyOutletNodes().front());
296
297 ✗ model().disconnect(getObject<ModelObject>(), returnAirPort());
298 ✗ model().disconnect(getObject<ModelObject>(), mixedAirPort());
299
300 // If the component is stuck directly between the inlet and outlet node.
301 ✗ if (supplyInletNode->handle() == sourceModelObject->handle() && supplyOutletNode->handle() == targetModelObject->handle()) {
302 ✗ this->model().connect(supplyInletNode.get(), supplyInletNode->outletPort(), supplyOutletNode.get(), supplyOutletNode->inletPort());
303 }
304 // If the component is at the very end of the supply path, but there is another component
305 // preceding this one.
306 ✗ else if (supplyOutletNode->handle() == targetModelObject->handle()) {
307 ✗ sourceModelObject->remove();
308 ✗ this->model().connect(source2ModelObject.get(), source2Port.get(), supplyOutletNode.get(), supplyOutletNode->inletPort());
309 }
310 // else remove the component and the outlet node
311 else {
312 ✗ targetModelObject->remove();
313 ✗ this->model().connect(sourceModelObject.get(), sourcePort.get(), target2ModelObject.get(), target2Port.get());
314 }
315 15 }
316
317
2/2
✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
15 getControllerOutdoorAir().remove();
318
319
1/1
✓ Branch 1 taken 15 times.
30 return ModelObject_Impl::remove(); // NOLINT(bugprone-parent-virtual-call)
320 15 }
321
322 6434 std::vector<HVACComponent> AirLoopHVACOutdoorAirSystem_Impl::edges(const boost::optional<HVACComponent>& /*prev*/) {
323 6434 std::vector<HVACComponent> edges;
324
2/3
✓ Branch 1 taken 6434 times.
✓ Branch 3 taken 6434 times.
✗ Branch 4 not taken.
12868 if (auto edgeModelObject = this->mixedAirModelObject()) {
325
3/4
✓ Branch 1 taken 6434 times.
✓ Branch 4 taken 6434 times.
✓ Branch 6 taken 6434 times.
✗ Branch 7 not taken.
12868 if (auto edgeObject = edgeModelObject->optionalCast<HVACComponent>()) {
326
2/2
✓ Branch 1 taken 6434 times.
✓ Branch 4 taken 6434 times.
6434 edges.push_back(*edgeObject);
327 6434 }
328 6434 }
329 6434 return edges;
330 ✗ }
331
332 5230 std::vector<ModelObject> AirLoopHVACOutdoorAirSystem_Impl::oaComponents(openstudio::IddObjectType type) const {
333 5230 std::vector<ModelObject> modelObjects;
334
1/1
✓ Branch 1 taken 5230 times.
5230 modelObjects.reserve(10); // Abritrary, but it wouldn't be common to have more objects than that
335
336
1/1
✓ Branch 1 taken 5230 times.
5230 OptionalModelObject modelObject = this->outdoorAirModelObject();
337
338
2/2
✓ Branch 0 taken 10668 times.
✓ Branch 1 taken 5230 times.
21128 while (modelObject) {
339
4/4
✓ Branch 1 taken 10668 times.
✓ Branch 4 taken 10668 times.
✓ Branch 6 taken 9897 times.
✓ Branch 7 taken 771 times.
21336 if (auto comp_ = modelObject->optionalCast<StraightComponent>()) {
340
2/2
✓ Branch 1 taken 9897 times.
✓ Branch 4 taken 9897 times.
9897 modelObject = comp_->inletModelObject();
341
2/2
✓ Branch 1 taken 9897 times.
✓ Branch 7 taken 9897 times.
9897 modelObjects.insert(modelObjects.begin(), std::move(*comp_));
342
4/4
✓ Branch 1 taken 771 times.
✓ Branch 4 taken 771 times.
✓ Branch 6 taken 594 times.
✓ Branch 7 taken 177 times.
1542 } else if (auto comp_ = modelObject->optionalCast<AirToAirComponent>()) {
343
2/2
✓ Branch 1 taken 594 times.
✓ Branch 4 taken 594 times.
594 modelObject = comp_->primaryAirInletModelObject();
344
2/2
✓ Branch 1 taken 594 times.
✓ Branch 7 taken 594 times.
594 modelObjects.insert(modelObjects.begin(), std::move(*comp_));
345
4/4
✓ Branch 1 taken 177 times.
✓ Branch 4 taken 177 times.
✓ Branch 6 taken 133 times.
✓ Branch 7 taken 44 times.
354 } else if (auto comp_ = modelObject->optionalCast<WaterToAirComponent>()) {
346
2/2
✓ Branch 1 taken 133 times.
✓ Branch 4 taken 133 times.
133 modelObject = comp_->airInletModelObject();
347
2/2
✓ Branch 1 taken 133 times.
✓ Branch 7 taken 133 times.
133 modelObjects.insert(modelObjects.begin(), std::move(*comp_));
348
3/4
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 6 taken 44 times.
✗ Branch 7 not taken.
88 } else if (auto comp_ = modelObject->optionalCast<ZoneHVACComponent>()) {
349 // For AirLoopHVACUnitarySystem and ZoneHVACTerminalUnitVariableRefrigerantFlow
350
3/3
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
44 modelObject = comp_->inletNode();
351
2/2
✓ Branch 1 taken 44 times.
✓ Branch 7 taken 44 times.
44 modelObjects.insert(modelObjects.begin(), std::move(*comp_));
352 } else {
353 ✗ LOG_AND_THROW("For " << briefDescription() << ", unexpected oaComponent found: " << modelObject->briefDescription());
354 11660 }
355 }
356
3/3
✓ Branch 1 taken 5230 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 5227 times.
5230 if (type != IddObjectType::Catchall) {
357
1/1
✓ Branch 3 taken 3 times.
6 modelObjects.erase(
358
2/2
✓ Branch 1 taken 7 times.
✓ Branch 7 taken 3 times.
10 std::remove_if(modelObjects.begin(), modelObjects.end(), [&](const auto& mo) -> bool { return mo.iddObjectType() != type; }),
359 6 modelObjects.end());
360 }
361 10460 return modelObjects;
362 5230 }
363
364 4543 std::vector<ModelObject> AirLoopHVACOutdoorAirSystem_Impl::reliefComponents(openstudio::IddObjectType type) const {
365 4543 std::vector<ModelObject> modelObjects;
366
1/1
✓ Branch 1 taken 4543 times.
4543 modelObjects.reserve(10); // Abritrary, but it wouldn't be common to have more objects than that
367
368
1/1
✓ Branch 1 taken 4543 times.
4543 OptionalModelObject modelObject = this->reliefAirModelObject();
369
370
2/2
✓ Branch 0 taken 6107 times.
✓ Branch 1 taken 4543 times.
15193 while (modelObject) {
371
2/2
✓ Branch 1 taken 6107 times.
✓ Branch 4 taken 6107 times.
6107 auto [ok, mo_] = getOutletNodeForComponent(*modelObject);
372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6107 times.
6107 if (!ok) {
373 ✗ LOG_AND_THROW("For " << briefDescription() << ", unexpected reliefComponent found: " << modelObject->briefDescription());
374 }
375
2/2
✓ Branch 1 taken 6107 times.
✓ Branch 5 taken 6107 times.
6107 modelObjects.emplace_back(std::move(*modelObject));
376
1/1
✓ Branch 1 taken 6107 times.
6107 modelObject = mo_;
377 6107 }
378
379
3/3
✓ Branch 1 taken 4543 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 4540 times.
4543 if (type != IddObjectType::Catchall) {
380
1/1
✓ Branch 3 taken 3 times.
6 modelObjects.erase(
381
2/2
✓ Branch 1 taken 7 times.
✓ Branch 7 taken 3 times.
10 std::remove_if(modelObjects.begin(), modelObjects.end(), [&](const auto& mo) -> bool { return mo.iddObjectType() != type; }),
382 6 modelObjects.end());
383 }
384 9086 return modelObjects;
385 4543 }
386
387 672 boost::optional<Node> AirLoopHVACOutdoorAirSystem_Impl::outboardOANode() const {
388
3/3
✓ Branch 1 taken 672 times.
✓ Branch 4 taken 672 times.
✓ Branch 7 taken 672 times.
672 auto modelObjects = this->oaComponents();
389
390
1/2
✓ Branch 1 taken 672 times.
✗ Branch 2 not taken.
672 if (!modelObjects.empty()) {
391
1/1
✓ Branch 2 taken 672 times.
672 return modelObjects.front().optionalCast<Node>();
392 }
393
394 ✗ return boost::none;
395 672 }
396
397 289 boost::optional<Node> AirLoopHVACOutdoorAirSystem_Impl::outboardReliefNode() const {
398
3/3
✓ Branch 1 taken 289 times.
✓ Branch 4 taken 289 times.
✓ Branch 7 taken 289 times.
289 auto modelObjects = this->reliefComponents();
399
400
1/2
✓ Branch 1 taken 289 times.
✗ Branch 2 not taken.
289 if (!modelObjects.empty()) {
401
1/1
✓ Branch 2 taken 289 times.
289 return modelObjects.back().optionalCast<Node>();
402 }
403
404 ✗ return boost::none;
405 289 }
406
407 111 boost::optional<AirLoopHVAC> AirLoopHVACOutdoorAirSystem_Impl::airLoopHVAC() const {
408
409
2/2
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 76 times.
222 if (m_airLoopHVAC) { // HVACComponent_Impl caches
410 35 return m_airLoopHVAC;
411 }
412
413
4/4
✓ Branch 1 taken 76 times.
✓ Branch 4 taken 76 times.
✓ Branch 12 taken 67 times.
✓ Branch 13 taken 17 times.
84 for (auto& airLoop : this->model().getConcreteModelObjects<AirLoopHVAC>()) {
414
4/4
✓ Branch 1 taken 67 times.
✓ Branch 4 taken 67 times.
✓ Branch 7 taken 59 times.
✓ Branch 8 taken 8 times.
134 if (airLoop.supplyComponent(this->handle())) {
415
1/1
✓ Branch 1 taken 59 times.
59 m_airLoopHVAC = airLoop;
416
1/1
✓ Branch 1 taken 59 times.
59 return airLoop;
417 }
418 76 }
419
420 17 return boost::none;
421 }
422
423 4051 std::vector<ModelObject> AirLoopHVACOutdoorAirSystem_Impl::components(openstudio::IddObjectType type) const {
424
3/3
✓ Branch 1 taken 4051 times.
✓ Branch 4 taken 4051 times.
✓ Branch 7 taken 4051 times.
4051 return openstudio::concat<ModelObject>(this->oaComponents(type), this->reliefComponents(type));
425 }
426
427 3922 boost::optional<ModelObject> AirLoopHVACOutdoorAirSystem_Impl::component(openstudio::Handle handle) const {
428
3/3
✓ Branch 1 taken 3922 times.
✓ Branch 4 taken 3922 times.
✓ Branch 7 taken 3922 times.
3922 auto comps = components();
429
430
3/3
✓ Branch 3 taken 3922 times.
✓ Branch 6 taken 9932 times.
✓ Branch 9 taken 9932 times.
13854 auto it = std::find_if(comps.begin(), comps.end(), [&](const ModelObject& comp) { return (comp.handle() == handle); });
431
2/2
✓ Branch 2 taken 872 times.
✓ Branch 3 taken 3050 times.
3922 if (it != comps.end()) {
432
1/1
✓ Branch 2 taken 872 times.
872 return *it;
433 }
434
435 3050 return boost::none;
436 3922 }
437
438 298 boost::optional<ModelObject> AirLoopHVACOutdoorAirSystem_Impl::oaComponent(openstudio::Handle handle) const {
439
3/3
✓ Branch 1 taken 298 times.
✓ Branch 4 taken 298 times.
✓ Branch 7 taken 298 times.
298 auto comps = oaComponents();
440
441
3/3
✓ Branch 3 taken 298 times.
✓ Branch 6 taken 512 times.
✓ Branch 9 taken 512 times.
810 auto it = std::find_if(comps.begin(), comps.end(), [&](const ModelObject& comp) { return (comp.handle() == handle); });
442
2/2
✓ Branch 2 taken 260 times.
✓ Branch 3 taken 38 times.
298 if (it != comps.end()) {
443
1/1
✓ Branch 2 taken 260 times.
260 return *it;
444 }
445
446 38 return boost::none;
447 298 }
448
449 38 boost::optional<ModelObject> AirLoopHVACOutdoorAirSystem_Impl::reliefComponent(openstudio::Handle handle) const {
450
3/3
✓ Branch 1 taken 38 times.
✓ Branch 4 taken 38 times.
✓ Branch 7 taken 38 times.
38 auto comps = reliefComponents();
451
452
3/3
✓ Branch 3 taken 38 times.
✓ Branch 6 taken 92 times.
✓ Branch 9 taken 92 times.
130 auto it = std::find_if(comps.begin(), comps.end(), [&](const ModelObject& comp) { return (comp.handle() == handle); });
453
1/2
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
38 if (it != comps.end()) {
454
1/1
✓ Branch 2 taken 38 times.
38 return *it;
455 }
456
457 ✗ return boost::none;
458 38 }
459
460 232 bool AirLoopHVACOutdoorAirSystem_Impl::addToNode(Node& node) {
461
462
1/1
✓ Branch 1 taken 232 times.
232 auto airLoop_ = node.airLoopHVAC();
463
464
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 232 times.
232 if (!airLoop_) {
465 ✗ return false;
466 }
467
468
4/5
✓ Branch 1 taken 232 times.
✓ Branch 4 taken 232 times.
✓ Branch 7 taken 232 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 232 times.
232 if (!airLoop_->supplyComponents(this->iddObjectType()).empty()) {
469 ✗ LOG(Warn, "AirLoopHVAC " << airLoop_->nameString() << " already has an AirLoopHVACOutdoorAirSystem assigned.");
470 ✗ return false;
471 }
472
473
5/5
✓ Branch 1 taken 232 times.
✓ Branch 4 taken 232 times.
✓ Branch 7 taken 232 times.
✓ Branch 11 taken 3 times.
✓ Branch 12 taken 229 times.
232 if (!airLoop_->supplyComponent(node.handle())) {
474 3 return false;
475 }
476
477
1/1
✓ Branch 1 taken 229 times.
229 Model _model = node.model();
478
1/1
✓ Branch 1 taken 229 times.
229 auto thisModelObject = getObject<ModelObject>();
479
480
19/26
✓ Branch 1 taken 229 times.
✓ Branch 4 taken 229 times.
✓ Branch 8 taken 229 times.
✓ Branch 10 taken 44 times.
✓ Branch 11 taken 185 times.
✓ Branch 13 taken 44 times.
✓ Branch 16 taken 44 times.
✓ Branch 19 taken 44 times.
✓ Branch 22 taken 44 times.
✓ Branch 25 taken 44 times.
✓ Branch 27 taken 43 times.
✓ Branch 28 taken 1 time.
✓ Branch 29 taken 44 times.
✓ Branch 30 taken 185 times.
✓ Branch 32 taken 44 times.
✓ Branch 33 taken 185 times.
✓ Branch 35 taken 229 times.
✗ Branch 36 not taken.
✓ Branch 38 taken 43 times.
✓ Branch 39 taken 186 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
229 if (node == airLoop_->supplyOutletNodes().front() && node.inletModelObject().get() == airLoop_->supplyInletNode()) {
481
3/3
✓ Branch 1 taken 43 times.
✓ Branch 4 taken 43 times.
✓ Branch 7 taken 43 times.
43 const unsigned oldOutletPort = node.connectedObjectPort(node.inletPort()).get();
482
1/1
✓ Branch 1 taken 43 times.
43 const unsigned oldInletPort = node.inletPort();
483
4/4
✓ Branch 1 taken 43 times.
✓ Branch 4 taken 43 times.
✓ Branch 7 taken 43 times.
✓ Branch 10 taken 43 times.
43 ModelObject oldSourceModelObject = node.connectedObject(node.inletPort()).get();
484
1/1
✓ Branch 1 taken 43 times.
43 ModelObject oldTargetModelObject = node;
485
486
3/3
✓ Branch 1 taken 43 times.
✓ Branch 4 taken 43 times.
✓ Branch 9 taken 43 times.
43 _model.connect(std::move(oldSourceModelObject), oldOutletPort, thisModelObject, returnAirPort());
487
2/2
✓ Branch 3 taken 43 times.
✓ Branch 8 taken 43 times.
43 _model.connect(std::move(thisModelObject), mixedAirPort(), std::move(oldTargetModelObject), oldInletPort);
488 43 return true;
489 43 }
490
491
19/26
✓ Branch 1 taken 186 times.
✓ Branch 4 taken 186 times.
✓ Branch 7 taken 186 times.
✓ Branch 9 taken 185 times.
✓ Branch 10 taken 1 time.
✓ Branch 12 taken 185 times.
✓ Branch 15 taken 185 times.
✓ Branch 19 taken 185 times.
✓ Branch 22 taken 185 times.
✓ Branch 25 taken 185 times.
✓ Branch 27 taken 12 times.
✓ Branch 28 taken 173 times.
✓ Branch 29 taken 185 times.
✓ Branch 30 taken 1 time.
✓ Branch 32 taken 185 times.
✓ Branch 33 taken 1 time.
✓ Branch 35 taken 186 times.
✗ Branch 36 not taken.
✓ Branch 38 taken 12 times.
✓ Branch 39 taken 174 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
186 if (node == airLoop_->supplyInletNode() && node.outletModelObject().get() == airLoop_->supplyOutletNodes().front()) {
492
1/1
✓ Branch 1 taken 12 times.
12 const unsigned oldOutletPort = node.outletPort();
493
3/3
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
12 const unsigned oldInletPort = node.connectedObjectPort(node.outletPort()).get();
494
1/1
✓ Branch 1 taken 12 times.
12 ModelObject oldSourceModelObject = node;
495
3/3
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
12 ModelObject oldTargetModelObject = node.outletModelObject().get();
496
497
3/3
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 9 taken 12 times.
12 _model.connect(std::move(oldSourceModelObject), oldOutletPort, thisModelObject, returnAirPort());
498
2/2
✓ Branch 3 taken 12 times.
✓ Branch 8 taken 12 times.
12 _model.connect(std::move(thisModelObject), mixedAirPort(), std::move(oldTargetModelObject), oldInletPort);
499 12 return true;
500 12 }
501
502
5/5
✓ Branch 1 taken 174 times.
✓ Branch 4 taken 174 times.
✓ Branch 8 taken 174 times.
✓ Branch 11 taken 1 time.
✓ Branch 12 taken 173 times.
174 if (node == airLoop_->supplyOutletNodes().front()) {
503
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 const unsigned oldOutletPort = node.connectedObjectPort(node.inletPort()).get();
504
1/1
✓ Branch 1 taken 1 time.
1 const unsigned oldInletPort = node.inletPort();
505
4/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
1 ModelObject oldSourceModelObject = node.connectedObject(node.inletPort()).get();
506
1/1
✓ Branch 1 taken 1 time.
1 ModelObject oldTargetModelObject = node;
507
508
1/1
✓ Branch 1 taken 1 time.
1 Node newNode(_model);
509
1/1
✓ Branch 1 taken 1 time.
1 const unsigned newNodeInletPort = newNode.inletPort();
510
1/1
✓ Branch 1 taken 1 time.
1 const unsigned newNodeOutletPort = newNode.outletPort();
511
2/2
✓ Branch 1 taken 1 time.
✓ Branch 6 taken 1 time.
1 _model.connect(std::move(oldSourceModelObject), oldOutletPort, newNode, newNodeInletPort);
512
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 9 taken 1 time.
1 _model.connect(std::move(newNode), newNodeOutletPort, thisModelObject, returnAirPort());
513
2/2
✓ Branch 3 taken 1 time.
✓ Branch 8 taken 1 time.
1 _model.connect(std::move(thisModelObject), mixedAirPort(), std::move(oldTargetModelObject), oldInletPort);
514 1 return true;
515 1 }
516
517 {
518
1/1
✓ Branch 1 taken 173 times.
173 const unsigned oldOutletPort = node.outletPort();
519
3/3
✓ Branch 1 taken 173 times.
✓ Branch 4 taken 173 times.
✓ Branch 7 taken 173 times.
173 const unsigned oldInletPort = node.connectedObjectPort(node.outletPort()).get();
520
1/1
✓ Branch 1 taken 173 times.
173 ModelObject oldSourceModelObject = node;
521
4/4
✓ Branch 1 taken 173 times.
✓ Branch 4 taken 173 times.
✓ Branch 7 taken 173 times.
✓ Branch 10 taken 173 times.
173 ModelObject oldTargetModelObject = node.connectedObject(node.outletPort()).get();
522
523
1/1
✓ Branch 1 taken 173 times.
173 Node newNode(_model);
524
1/1
✓ Branch 1 taken 173 times.
173 const unsigned newNodeInletPort = newNode.inletPort();
525
1/1
✓ Branch 1 taken 173 times.
173 const unsigned newNodeOutletPort = newNode.outletPort();
526
3/3
✓ Branch 1 taken 173 times.
✓ Branch 4 taken 173 times.
✓ Branch 9 taken 173 times.
173 _model.connect(std::move(oldSourceModelObject), oldOutletPort, thisModelObject, returnAirPort());
527
3/3
✓ Branch 1 taken 173 times.
✓ Branch 4 taken 173 times.
✓ Branch 9 taken 173 times.
173 _model.connect(std::move(thisModelObject), mixedAirPort(), newNode, newNodeInletPort);
528
1/1
✓ Branch 5 taken 173 times.
173 _model.connect(std::move(newNode), newNodeOutletPort, std::move(oldTargetModelObject), oldInletPort);
529 173 return true;
530 173 }
531 232 }
532
533 ✗ boost::optional<ModelObject> AirLoopHVACOutdoorAirSystem_Impl::controllerOutdoorAirAsModelObject() const {
534 ✗ OptionalModelObject result = getControllerOutdoorAir();
535 ✗ return result;
536 }
537
538 ✗ boost::optional<ModelObject> AirLoopHVACOutdoorAirSystem_Impl::outboardOANodeAsModelObject() const {
539 ✗ if (auto mo_ = this->outboardOANode()) {
540 ✗ return std::move(*mo_);
541 ✗ }
542 ✗ return boost::none;
543 }
544
545 ✗ boost::optional<ModelObject> AirLoopHVACOutdoorAirSystem_Impl::outboardReliefNodeAsModelObject() const {
546 ✗ if (auto mo_ = this->outboardReliefNode()) {
547 ✗ return std::move(*mo_);
548 ✗ }
549 ✗ return boost::none;
550 }
551
552 ✗ boost::optional<ModelObject> AirLoopHVACOutdoorAirSystem_Impl::airLoopAsModelObject() const {
553 ✗ if (auto mo_ = this->airLoopHVAC()) {
554 ✗ return std::move(*mo_);
555 ✗ }
556 ✗ return boost::none;
557 }
558
559 ✗ bool AirLoopHVACOutdoorAirSystem_Impl::setControllerOutdoorAirAsModelObject(const boost::optional<ModelObject>& modelObject) {
560 ✗ if (modelObject) {
561 ✗ OptionalControllerOutdoorAir intermediate = modelObject->optionalCast<ControllerOutdoorAir>();
562 ✗ if (intermediate) {
563 ✗ setControllerOutdoorAir(*intermediate);
564 ✗ return true;
565 }
566 ✗ }
567 ✗ return false;
568 }
569
570 ✗ AirflowNetworkDistributionNode AirLoopHVACOutdoorAirSystem_Impl::getAirflowNetworkDistributionNode() {
571 ✗ boost::optional<AirflowNetworkDistributionNode> opt = airflowNetworkDistributionNode();
572 ✗ if (opt) {
573 ✗ return opt.get();
574 }
575 ✗ return {model(), handle()};
576 ✗ }
577
578 ✗ boost::optional<AirflowNetworkDistributionNode> AirLoopHVACOutdoorAirSystem_Impl::airflowNetworkDistributionNode() const {
579 std::vector<AirflowNetworkDistributionNode> myAFNItems =
580 ✗ getObject<ModelObject>().getModelObjectSources<AirflowNetworkDistributionNode>(AirflowNetworkDistributionNode::iddObjectType());
581 ✗ auto count = myAFNItems.size();
582 ✗ if (count == 1) {
583 ✗ return myAFNItems[0];
584 ✗ } else if (count > 1) {
585 ✗ LOG(Warn, briefDescription() << " has more than one AirflowNetwork DistributionNode attached, returning first.");
586 ✗ return myAFNItems[0];
587 }
588 ✗ return boost::none;
589 ✗ }
590
591 194 boost::optional<AirLoopHVACDedicatedOutdoorAirSystem> AirLoopHVACOutdoorAirSystem_Impl::airLoopHVACDedicatedOutdoorAirSystem() const {
592
1/1
✓ Branch 1 taken 194 times.
194 auto thisOASystem = getObject<AirLoopHVACOutdoorAirSystem>();
593 std::vector<AirLoopHVACDedicatedOutdoorAirSystem> doaSystems =
594
2/2
✓ Branch 1 taken 194 times.
✓ Branch 4 taken 194 times.
194 thisOASystem.getModelObjectSources<AirLoopHVACDedicatedOutdoorAirSystem>(AirLoopHVACDedicatedOutdoorAirSystem::iddObjectType());
595
2/2
✓ Branch 1 taken 178 times.
✓ Branch 2 taken 16 times.
194 if (doaSystems.empty()) {
596 178 return boost::none;
597
1/2
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
16 } else if (doaSystems.size() == 1) {
598
2/2
✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
16 return doaSystems.at(0);
599 } else {
600 ✗ LOG(Error, "More than one AirLoopHVACDedicatedOutdoorAirSystem points to this AirLoopHVACOutdoorAirSystem");
601 ✗ return boost::none;
602 }
603 194 }
604
605 3 ComponentType AirLoopHVACOutdoorAirSystem_Impl::componentType() const {
606 3 bool has_cooling = false;
607 3 bool has_heating = false;
608
6/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 19 taken 12 times.
✓ Branch 20 taken 3 times.
18 for (const auto& comp : subsetCastVector<HVACComponent>(components())) {
609
1/1
✓ Branch 1 taken 12 times.
12 auto compType = comp.componentType();
610
3/3
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 11 times.
12 if (compType == ComponentType::Cooling) {
611 1 has_cooling = true;
612
3/3
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 9 times.
11 } else if (compType == ComponentType::Heating) {
613 2 has_heating = true;
614
2/3
✓ Branch 1 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 } else if (compType == ComponentType::Both) {
615 ✗ has_cooling = true;
616 ✗ has_heating = true;
617 }
618 3 }
619
620
3/4
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 time.
✗ Branch 3 not taken.
3 if (has_cooling && has_heating) {
621
1/1
✓ Branch 1 taken 1 time.
1 return ComponentType::Both;
622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 } else if (has_cooling) {
623 ✗ return ComponentType::Cooling;
624
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
2 } else if (has_heating) {
625
1/1
✓ Branch 1 taken 1 time.
1 return ComponentType::Heating;
626 }
627
1/1
✓ Branch 1 taken 1 time.
1 return ComponentType::None;
628 }
629
630 3 std::vector<FuelType> AirLoopHVACOutdoorAirSystem_Impl::coolingFuelTypes() const {
631 3 std::set<FuelType> result;
632
6/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 19 taken 12 times.
✓ Branch 20 taken 3 times.
18 for (const auto& comp : subsetCastVector<HVACComponent>(components())) {
633
3/3
✓ Branch 1 taken 12 times.
✓ Branch 8 taken 1 time.
✓ Branch 9 taken 12 times.
13 for (auto& ft : comp.coolingFuelTypes()) {
634
1/1
✓ Branch 1 taken 1 time.
1 result.insert(ft);
635 12 }
636 3 }
637
1/1
✓ Branch 3 taken 3 times.
9 return {result.begin(), result.end()};
638 3 }
639
640 3 std::vector<FuelType> AirLoopHVACOutdoorAirSystem_Impl::heatingFuelTypes() const {
641 3 std::set<FuelType> result;
642
6/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 19 taken 12 times.
✓ Branch 20 taken 3 times.
18 for (const auto& comp : subsetCastVector<HVACComponent>(components())) {
643
3/3
✓ Branch 1 taken 12 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 12 times.
14 for (auto& ft : comp.heatingFuelTypes()) {
644
1/1
✓ Branch 1 taken 2 times.
2 result.insert(ft);
645 12 }
646 3 }
647
1/1
✓ Branch 3 taken 3 times.
9 return {result.begin(), result.end()};
648 3 }
649
650 3 std::vector<AppGFuelType> AirLoopHVACOutdoorAirSystem_Impl::appGHeatingFuelTypes() const {
651 3 std::set<AppGFuelType> result;
652
6/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 19 taken 12 times.
✓ Branch 20 taken 3 times.
18 for (const auto& comp : subsetCastVector<HVACComponent>(components())) {
653
3/3
✓ Branch 1 taken 12 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 12 times.
14 for (auto& ft : comp.appGHeatingFuelTypes()) {
654
1/1
✓ Branch 1 taken 2 times.
2 result.insert(ft);
655 12 }
656 3 }
657
1/1
✓ Branch 3 taken 3 times.
9 return {result.begin(), result.end()};
658 3 }
659
660 } // namespace detail
661
662 // create a new AirLoopHVACOutdoorAirSystem object in the model's workspace
663 244 AirLoopHVACOutdoorAirSystem::AirLoopHVACOutdoorAirSystem(Model& model, const ControllerOutdoorAir& controller)
664 244 : HVACComponent(AirLoopHVACOutdoorAirSystem::iddObjectType(), model) {
665
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 244 times.
✗ Branch 5 not taken.
244 OS_ASSERT(getImpl<detail::AirLoopHVACOutdoorAirSystem_Impl>());
666
667
1/1
✓ Branch 1 taken 244 times.
244 setControllerOutdoorAir(controller);
668
669
1/1
✓ Branch 1 taken 244 times.
244 Node oaNode(model);
670
2/2
✓ Branch 1 taken 244 times.
✓ Branch 4 taken 244 times.
244 oaNode.setName("Outboard OA Node");
671
5/5
✓ Branch 1 taken 244 times.
✓ Branch 4 taken 244 times.
✓ Branch 7 taken 244 times.
✓ Branch 10 taken 244 times.
✓ Branch 13 taken 244 times.
244 model.connect(oaNode, oaNode.outletPort(), *this, outdoorAirPort());
672
673
1/1
✓ Branch 1 taken 244 times.
244 Node reliefNode(model);
674
2/2
✓ Branch 1 taken 244 times.
✓ Branch 4 taken 244 times.
244 reliefNode.setName("Relief Node");
675
5/5
✓ Branch 1 taken 244 times.
✓ Branch 4 taken 244 times.
✓ Branch 7 taken 244 times.
✓ Branch 10 taken 244 times.
✓ Branch 13 taken 244 times.
244 model.connect(*this, reliefAirPort(), reliefNode, reliefNode.inletPort());
676 244 }
677
678 1 AirLoopHVACOutdoorAirSystem::AirLoopHVACOutdoorAirSystem(Model& model) : HVACComponent(AirLoopHVACOutdoorAirSystem::iddObjectType(), model) {
679
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 1 time.
✗ Branch 5 not taken.
1 OS_ASSERT(getImpl<detail::AirLoopHVACOutdoorAirSystem_Impl>());
680
681
1/1
✓ Branch 1 taken 1 time.
1 ControllerOutdoorAir controller(model);
682
1/1
✓ Branch 1 taken 1 time.
1 setControllerOutdoorAir(controller);
683
684
1/1
✓ Branch 1 taken 1 time.
1 Node oaNode(model);
685
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 oaNode.setName("Outboard OA Node");
686
5/5
✓ 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.
1 model.connect(oaNode, oaNode.outletPort(), *this, outdoorAirPort());
687
688
1/1
✓ Branch 1 taken 1 time.
1 Node reliefNode(model);
689
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 reliefNode.setName("Relief Node");
690
5/5
✓ 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.
1 model.connect(*this, reliefAirPort(), reliefNode, reliefNode.inletPort());
691 1 }
692
693 4768 AirLoopHVACOutdoorAirSystem::AirLoopHVACOutdoorAirSystem(std::shared_ptr<detail::AirLoopHVACOutdoorAirSystem_Impl> impl)
694
1/1
✓ Branch 3 taken 4768 times.
4768 : HVACComponent(std::move(impl)) {}
695
696 8 unsigned AirLoopHVACOutdoorAirSystem::returnAirPort() const {
697
1/1
✓ Branch 3 taken 8 times.
8 return getImpl<detail::AirLoopHVACOutdoorAirSystem_Impl>()->returnAirPort();
698 }
699
700 261 unsigned AirLoopHVACOutdoorAirSystem::outdoorAirPort() const {
701
1/1
✓ Branch 3 taken 261 times.
261 return getImpl<detail::AirLoopHVACOutdoorAirSystem_Impl>()->outdoorAirPort();
702 }
703
704 261 unsigned AirLoopHVACOutdoorAirSystem::reliefAirPort() const {
705
1/1
✓ Branch 3 taken 261 times.
261 return getImpl<detail::AirLoopHVACOutdoorAirSystem_Impl>()->reliefAirPort();
706 }
707
708 8 unsigned AirLoopHVACOutdoorAirSystem::mixedAirPort() const {
709
1/1
✓ Branch 3 taken 8 times.
8 return getImpl<detail::AirLoopHVACOutdoorAirSystem_Impl>()->mixedAirPort();
710 }
711
712 179 OptionalModelObject AirLoopHVACOutdoorAirSystem::returnAirModelObject() {
713
1/1
✓ Branch 3 taken 179 times.
179 return getImpl<detail::AirLoopHVACOutdoorAirSystem_Impl>()->returnAirModelObject();
714 }
715
716 243 OptionalModelObject AirLoopHVACOutdoorAirSystem::outdoorAirModelObject() {
717
1/1
✓ Branch 3 taken 243 times.
243 return getImpl<detail::AirLoopHVACOutdoorAirSystem_Impl>()->outdoorAirModelObject();
718 }
719
720 126 OptionalModelObject AirLoopHVACOutdoorAirSystem::reliefAirModelObject() {
721
1/1
✓ Branch 3 taken 126 times.
126 return getImpl<detail::AirLoopHVACOutdoorAirSystem_Impl>()->reliefAirModelObject();
722 }
723
724 351 OptionalModelObject AirLoopHVACOutdoorAirSystem::mixedAirModelObject() {
725
1/1
✓ Branch 3 taken 351 times.
351 return getImpl<detail::AirLoopHVACOutdoorAirSystem_Impl>()->mixedAirModelObject();
726 }
727
728 375 ControllerOutdoorAir AirLoopHVACOutdoorAirSystem::getControllerOutdoorAir() const {
729
1/1
✓ Branch 3 taken 375 times.
375 return getImpl<detail::AirLoopHVACOutdoorAirSystem_Impl>()->getControllerOutdoorAir();
730 }
731
732 254 bool AirLoopHVACOutdoorAirSystem::setControllerOutdoorAir(const ControllerOutdoorAir& controllerOutdoorAir) {
733
1/1
✓ Branch 3 taken 254 times.
254 return getImpl<detail::AirLoopHVACOutdoorAirSystem_Impl>()->setControllerOutdoorAir(controllerOutdoorAir);
734 }
735
736 672 boost::optional<Node> AirLoopHVACOutdoorAirSystem::outboardOANode() const {
737
1/1
✓ Branch 3 taken 672 times.
672 return getImpl<detail::AirLoopHVACOutdoorAirSystem_Impl>()->outboardOANode();
738 }
739
740 289 boost::optional<Node> AirLoopHVACOutdoorAirSystem::outboardReliefNode() const {
741
1/1
✓ Branch 3 taken 289 times.
289 return getImpl<detail::AirLoopHVACOutdoorAirSystem_Impl>()->outboardReliefNode();
742 }
743
744 201 std::vector<ModelObject> AirLoopHVACOutdoorAirSystem::oaComponents(openstudio::IddObjectType type) const {
745
1/1
✓ Branch 3 taken 201 times.
201 return getImpl<detail::AirLoopHVACOutdoorAirSystem_Impl>()->oaComponents(type);
746 }
747
748 157 std::vector<ModelObject> AirLoopHVACOutdoorAirSystem::reliefComponents(openstudio::IddObjectType type) const {
749
1/1
✓ Branch 3 taken 157 times.
157 return getImpl<detail::AirLoopHVACOutdoorAirSystem_Impl>()->reliefComponents(type);
750 }
751
752 102 std::vector<ModelObject> AirLoopHVACOutdoorAirSystem::components(openstudio::IddObjectType type) const {
753
1/1
✓ Branch 3 taken 102 times.
102 return getImpl<detail::AirLoopHVACOutdoorAirSystem_Impl>()->components(type);
754 }
755
756 3922 boost::optional<ModelObject> AirLoopHVACOutdoorAirSystem::component(openstudio::Handle handle) const {
757
1/1
✓ Branch 3 taken 3922 times.
3922 return getImpl<detail::AirLoopHVACOutdoorAirSystem_Impl>()->component(handle);
758 }
759
760 298 boost::optional<ModelObject> AirLoopHVACOutdoorAirSystem::oaComponent(openstudio::Handle handle) const {
761
1/1
✓ Branch 3 taken 298 times.
298 return getImpl<detail::AirLoopHVACOutdoorAirSystem_Impl>()->oaComponent(handle);
762 }
763
764 38 boost::optional<ModelObject> AirLoopHVACOutdoorAirSystem::reliefComponent(openstudio::Handle handle) const {
765
1/1
✓ Branch 3 taken 38 times.
38 return getImpl<detail::AirLoopHVACOutdoorAirSystem_Impl>()->reliefComponent(handle);
766 }
767
768 ✗ boost::optional<AirLoopHVAC> AirLoopHVACOutdoorAirSystem::airLoop() const {
769 ✗ return getImpl<detail::AirLoopHVACOutdoorAirSystem_Impl>()->airLoopHVAC();
770 }
771
772 14138 IddObjectType AirLoopHVACOutdoorAirSystem::iddObjectType() {
773
1/1
✓ Branch 1 taken 14138 times.
14138 return {IddObjectType::OS_AirLoopHVAC_OutdoorAirSystem};
774 }
775
776 ✗ AirflowNetworkDistributionNode AirLoopHVACOutdoorAirSystem::getAirflowNetworkDistributionNode() {
777 ✗ return getImpl<detail::AirLoopHVACOutdoorAirSystem_Impl>()->getAirflowNetworkDistributionNode();
778 }
779
780 ✗ boost::optional<AirflowNetworkDistributionNode> AirLoopHVACOutdoorAirSystem::airflowNetworkDistributionNode() const {
781 ✗ return getImpl<detail::AirLoopHVACOutdoorAirSystem_Impl>()->airflowNetworkDistributionNode();
782 }
783
784 194 boost::optional<AirLoopHVACDedicatedOutdoorAirSystem> AirLoopHVACOutdoorAirSystem::airLoopHVACDedicatedOutdoorAirSystem() const {
785
1/1
✓ Branch 3 taken 194 times.
194 return getImpl<detail::AirLoopHVACOutdoorAirSystem_Impl>()->airLoopHVACDedicatedOutdoorAirSystem();
786 }
787
788 } // namespace model
789 } // namespace openstudio
790