GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 83.3% 244 / 0 / 293
Functions: 74.0% 37 / 0 / 50
Branches: 85.3% 382 / 0 / 448

src/model/HVACComponent.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 "HVACComponent.hpp"
7 #include "HVACComponent_Impl.hpp"
8 #include "ZoneHVACComponent.hpp"
9 #include "ZoneHVACComponent_Impl.hpp"
10 #include "StraightComponent.hpp"
11 #include "StraightComponent_Impl.hpp"
12 #include "AirLoopHVAC.hpp"
13 #include "AirLoopHVAC_Impl.hpp"
14 #include "PlantLoop.hpp"
15 #include "PlantLoop_Impl.hpp"
16 #include "Node.hpp"
17 #include "Node_Impl.hpp"
18 #include "Splitter.hpp"
19 #include "Splitter_Impl.hpp"
20 #include "Mixer.hpp"
21 #include "Mixer_Impl.hpp"
22 #include "AirLoopHVACOutdoorAirSystem.hpp"
23 #include "AirLoopHVACOutdoorAirSystem_Impl.hpp"
24 #include "Model.hpp"
25 #include "Model_Impl.hpp"
26
27 #include "../utilities/core/Assert.hpp"
28 // #include "../utilities/data/DataEnums.hpp"
29
30 namespace openstudio {
31 namespace model {
32
33 namespace detail {
34
35 ✗ HVACComponent_Impl::HVACComponent_Impl(IddObjectType type, Model_Impl* model) : ParentObject_Impl(type, model) {}
36
37 28881 HVACComponent_Impl::HVACComponent_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
38 28881 : ParentObject_Impl(idfObject, model, keepHandle) {}
39
40 4161 HVACComponent_Impl::HVACComponent_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle)
41 4161 : ParentObject_Impl(other, model, keepHandle) {}
42
43 10390 HVACComponent_Impl::HVACComponent_Impl(const HVACComponent_Impl& other, Model_Impl* model, bool keepHandles)
44 10390 : ParentObject_Impl(other, model, keepHandles) {}
45
46 3307 boost::optional<Loop> HVACComponent_Impl::loop() const {
47
3/3
✓ Branch 1 taken 3307 times.
✓ Branch 3 taken 872 times.
✓ Branch 4 taken 2435 times.
6614 if (boost::optional<AirLoopHVAC> airLoopHVAC = this->airLoopHVAC()) {
48
2/2
✓ Branch 1 taken 872 times.
✓ Branch 4 taken 872 times.
872 return airLoopHVAC->optionalCast<Loop>();
49
3/3
✓ Branch 1 taken 2435 times.
✓ Branch 3 taken 327 times.
✓ Branch 4 taken 2108 times.
4870 } else if (boost::optional<PlantLoop> plantLoop = this->plantLoop()) {
50
2/2
✓ Branch 1 taken 327 times.
✓ Branch 4 taken 327 times.
327 return plantLoop->optionalCast<Loop>();
51 } else {
52 2108 return boost::none;
53 5742 }
54 }
55
56 10181 boost::optional<AirLoopHVAC> HVACComponent_Impl::airLoopHVAC() const {
57
2/2
✓ Branch 1 taken 2949 times.
✓ Branch 2 taken 7232 times.
20362 if (m_airLoopHVAC) {
58 2949 return m_airLoopHVAC;
59 } else {
60
2/2
✓ Branch 1 taken 7232 times.
✓ Branch 4 taken 7232 times.
7232 AirLoopHVACVector airLoops = this->model().getConcreteModelObjects<AirLoopHVAC>();
61
62
2/2
✓ Branch 5 taken 6244 times.
✓ Branch 6 taken 3796 times.
10040 for (auto& airLoop : airLoops) {
63
4/4
✓ Branch 1 taken 6244 times.
✓ Branch 4 taken 6244 times.
✓ Branch 7 taken 3051 times.
✓ Branch 8 taken 3193 times.
12488 if (airLoop.component(this->handle())) {
64
1/1
✓ Branch 1 taken 3051 times.
3051 m_airLoopHVAC = airLoop;
65
1/1
✓ Branch 1 taken 3051 times.
6487 return airLoop;
66 }
67
3/3
✓ Branch 1 taken 3193 times.
✓ Branch 3 taken 1430 times.
✓ Branch 4 taken 1763 times.
6386 if (OptionalAirLoopHVACOutdoorAirSystem oaSystem = airLoop.airLoopHVACOutdoorAirSystem()) {
68
5/5
✓ Branch 1 taken 1430 times.
✓ Branch 4 taken 1430 times.
✓ Branch 7 taken 1430 times.
✓ Branch 10 taken 385 times.
✓ Branch 11 taken 1045 times.
2860 if (oaSystem->component(this->handle())) {
69
1/1
✓ Branch 1 taken 385 times.
385 m_airLoopHVAC = airLoop;
70
1/1
✓ Branch 1 taken 385 times.
385 return airLoop;
71 }
72 3193 }
73 }
74 7232 }
75
76 3796 return boost::none;
77 }
78
79 3702 boost::optional<AirLoopHVACOutdoorAirSystem> HVACComponent_Impl::airLoopHVACOutdoorAirSystem() const {
80
2/2
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 3651 times.
7404 if (m_airLoopHVACOutdoorAirSystem) {
81 51 return m_airLoopHVACOutdoorAirSystem;
82 } else {
83
2/2
✓ Branch 1 taken 3651 times.
✓ Branch 4 taken 3651 times.
3651 AirLoopHVACOutdoorAirSystemVector oaLoops = this->model().getConcreteModelObjects<AirLoopHVACOutdoorAirSystem>();
84
85
2/2
✓ Branch 5 taken 2483 times.
✓ Branch 6 taken 3173 times.
5656 for (auto& oaLoop : oaLoops) {
86
4/4
✓ Branch 1 taken 2483 times.
✓ Branch 4 taken 2483 times.
✓ Branch 7 taken 478 times.
✓ Branch 8 taken 2005 times.
4966 if (oaLoop.component(this->handle())) {
87
1/1
✓ Branch 1 taken 478 times.
478 m_airLoopHVACOutdoorAirSystem = oaLoop;
88
1/1
✓ Branch 1 taken 478 times.
478 return oaLoop;
89 }
90 }
91 3651 }
92
93 3173 return boost::none;
94 }
95
96 4010 boost::optional<PlantLoop> HVACComponent_Impl::plantLoop() const {
97
2/2
✓ Branch 1 taken 600 times.
✓ Branch 2 taken 3410 times.
8020 if (m_plantLoop) {
98 600 return m_plantLoop;
99 } else {
100
2/2
✓ Branch 1 taken 3410 times.
✓ Branch 4 taken 3410 times.
3410 std::vector<PlantLoop> plantLoops = this->model().getConcreteModelObjects<PlantLoop>();
101
102
2/2
✓ Branch 5 taken 2403 times.
✓ Branch 6 taken 2552 times.
4955 for (auto& plantLoop : plantLoops) {
103
4/4
✓ Branch 1 taken 2403 times.
✓ Branch 4 taken 2403 times.
✓ Branch 7 taken 858 times.
✓ Branch 8 taken 1545 times.
4806 if (plantLoop.component(this->handle())) {
104
1/1
✓ Branch 1 taken 858 times.
858 m_plantLoop = plantLoop;
105
1/1
✓ Branch 1 taken 858 times.
858 return plantLoop;
106 }
107 }
108 3410 }
109
110 2552 return boost::none;
111 }
112
113 147 bool HVACComponent_Impl::removeFromLoop(const HVACComponent& systemStartComponent, const HVACComponent& systemEndComponent,
114 unsigned componentInletPort, unsigned componentOutletPort) {
115
1/1
✓ Branch 1 taken 147 times.
147 auto _model = model();
116
1/1
✓ Branch 1 taken 147 times.
147 auto thisObject = getObject<HVACComponent>();
117
118
3/4
✓ Branch 1 taken 147 times.
✓ Branch 4 taken 147 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 147 times.
147 if (systemStartComponent.model() != _model) {
119 ✗ return false;
120 }
121
3/4
✓ Branch 1 taken 147 times.
✓ Branch 4 taken 147 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 147 times.
147 if (systemEndComponent.model() != _model) {
122 ✗ return false;
123 }
124
125
1/1
✓ Branch 1 taken 147 times.
147 auto inletComponent = connectedObject(componentInletPort);
126
1/1
✓ Branch 1 taken 147 times.
147 auto outletComponent = connectedObject(componentOutletPort);
127
1/1
✓ Branch 1 taken 147 times.
147 auto inletComponentOutletPort = connectedObjectPort(componentInletPort);
128
1/1
✓ Branch 1 taken 147 times.
147 auto outletComponentInletPort = connectedObjectPort(componentOutletPort);
129
130
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 147 times.
147 if (!inletComponent) {
131 ✗ return false;
132 }
133
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 147 times.
147 if (!outletComponent) {
134 ✗ return false;
135 }
136
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 147 times.
147 if (!inletComponentOutletPort) {
137 ✗ return false;
138 }
139
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 147 times.
147 if (!outletComponentInletPort) {
140 ✗ return false;
141 }
142
143
2/2
✓ Branch 1 taken 147 times.
✓ Branch 4 taken 147 times.
147 auto inletNode = inletComponent->optionalCast<Node>();
144
2/2
✓ Branch 1 taken 147 times.
✓ Branch 4 taken 147 times.
147 auto outletNode = outletComponent->optionalCast<Node>();
145 147 boost::optional<Splitter> splitter;
146 147 boost::optional<Mixer> mixer;
147
148
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if (inletNode) {
149
4/4
✓ Branch 1 taken 147 times.
✓ Branch 4 taken 147 times.
✓ Branch 6 taken 143 times.
✓ Branch 7 taken 4 times.
294 if (auto mo = inletNode->inletModelObject()) {
150
2/2
✓ Branch 1 taken 143 times.
✓ Branch 4 taken 143 times.
143 splitter = mo->optionalCast<Splitter>();
151 147 }
152 }
153
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if (outletNode) {
154
3/4
✓ Branch 1 taken 147 times.
✓ Branch 4 taken 147 times.
✓ Branch 6 taken 147 times.
✗ Branch 7 not taken.
294 if (auto mo = outletNode->outletModelObject()) {
155
2/2
✓ Branch 1 taken 147 times.
✓ Branch 4 taken 147 times.
147 mixer = mo->optionalCast<Mixer>();
156 147 }
157 }
158
159
14/14
✓ Branch 1 taken 147 times.
✓ Branch 4 taken 147 times.
✓ Branch 7 taken 147 times.
✓ Branch 10 taken 147 times.
✓ Branch 12 taken 23 times.
✓ Branch 13 taken 124 times.
✓ Branch 15 taken 23 times.
✓ Branch 18 taken 23 times.
✓ Branch 21 taken 23 times.
✓ Branch 24 taken 23 times.
✓ Branch 26 taken 12 times.
✓ Branch 27 taken 11 times.
✓ Branch 28 taken 12 times.
✓ Branch 29 taken 135 times.
147 if (systemStartComponent.handle() == inletComponent->handle() && systemEndComponent.handle() == outletComponent->handle()) {
160 // This component is between the systemStartComponent and the systemEndComponent
161 // ie. the supply or demand inlet or outlet Nodes,
162 // or the oa system end points on either the relief or inlet air streams.
163
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
12 _model.disconnect(thisObject, componentInletPort);
164
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
12 _model.disconnect(thisObject, componentOutletPort);
165
166
7/7
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
✓ Branch 16 taken 12 times.
✓ Branch 19 taken 12 times.
12 _model.connect(inletComponent.get(), inletComponentOutletPort.get(), outletComponent.get(), outletComponentInletPort.get());
167
168 12 return true;
169
6/6
✓ Branch 1 taken 135 times.
✓ Branch 4 taken 135 times.
✓ Branch 7 taken 135 times.
✓ Branch 10 taken 135 times.
✓ Branch 12 taken 27 times.
✓ Branch 13 taken 108 times.
135 } else if (systemEndComponent.handle() == outletComponent->handle()) {
170 // Here the systemEndComponent is immediately downstream of this component,
171 // but there are other components (besides systemStartComponent) upstream.
172 27 boost::optional<ModelObject> newInletComponent;
173 27 boost::optional<unsigned> newInletComponentOutletPort;
174
175 // Make sure we don't end up with two nodes next to each other after this component is removed
176
3/6
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27 times.
✗ Branch 5 not taken.
54 if (inletNode && outletNode) {
177
2/2
✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
27 newInletComponent = inletNode->inletModelObject();
178
4/4
✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
✓ Branch 7 taken 27 times.
✓ Branch 10 taken 27 times.
27 newInletComponentOutletPort = inletNode->connectedObjectPort(inletNode->inletPort());
179
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 27 times.
✗ Branch 4 not taken.
27 OS_ASSERT(newInletComponent);
180
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 27 times.
✗ Branch 4 not taken.
27 OS_ASSERT(newInletComponentOutletPort);
181 } else {
182 ✗ newInletComponent = inletComponent;
183 ✗ newInletComponentOutletPort = inletComponentOutletPort;
184 }
185
186
2/2
✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
27 _model.disconnect(thisObject, componentInletPort);
187
2/2
✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
27 _model.disconnect(thisObject, componentOutletPort);
188
189 // inletNode->remove() would have failed if we did it before the disconnect
190
3/6
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27 times.
✗ Branch 5 not taken.
54 if (inletNode && outletNode) {
191
2/2
✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
27 inletNode->remove();
192 }
193
194
7/7
✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
✓ Branch 7 taken 27 times.
✓ Branch 10 taken 27 times.
✓ Branch 13 taken 27 times.
✓ Branch 16 taken 27 times.
✓ Branch 19 taken 27 times.
27 _model.connect(newInletComponent.get(), newInletComponentOutletPort.get(), outletComponent.get(), outletComponentInletPort.get());
195 27 return true;
196
6/6
✓ Branch 1 taken 78 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 75 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 75 times.
✓ Branch 6 taken 33 times.
213 } else if (splitter && mixer) {
197 // If the component is the only component (except nodes) between a splitter mixer pair
198
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 4 not taken.
75 OS_ASSERT(inletNode);
199
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 4 not taken.
75 OS_ASSERT(outletNode);
200
201
4/4
✓ Branch 1 taken 75 times.
✓ Branch 4 taken 75 times.
✓ Branch 7 taken 75 times.
✓ Branch 10 taken 75 times.
75 int i = splitter->branchIndexForOutletModelObject(inletNode.get());
202
3/3
✓ Branch 1 taken 75 times.
✓ Branch 4 taken 75 times.
✓ Branch 7 taken 75 times.
75 int j = mixer->branchIndexForInletModelObject(outletNode.get());
203
204
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
✗ Branch 3 not taken.
75 OS_ASSERT(i == j);
205
206
2/2
✓ Branch 1 taken 75 times.
✓ Branch 4 taken 75 times.
75 splitter->removePortForBranch(i);
207
2/2
✓ Branch 1 taken 75 times.
✓ Branch 4 taken 75 times.
75 mixer->removePortForBranch(i);
208
209
2/2
✓ Branch 1 taken 75 times.
✓ Branch 4 taken 75 times.
75 _model.disconnect(thisObject, componentInletPort);
210
2/2
✓ Branch 1 taken 75 times.
✓ Branch 4 taken 75 times.
75 _model.disconnect(thisObject, componentOutletPort);
211
212
2/2
✓ Branch 1 taken 75 times.
✓ Branch 4 taken 75 times.
75 inletNode->remove();
213
2/2
✓ Branch 1 taken 75 times.
✓ Branch 4 taken 75 times.
75 outletNode->remove();
214
215
4/4
✓ Branch 1 taken 75 times.
✓ Branch 4 taken 75 times.
✓ Branch 8 taken 61 times.
✓ Branch 9 taken 14 times.
75 if (!splitter->lastOutletModelObject()) {
216
1/1
✓ Branch 1 taken 61 times.
61 Node newNode(_model);
217
7/7
✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 7 taken 61 times.
✓ Branch 10 taken 61 times.
✓ Branch 13 taken 61 times.
✓ Branch 16 taken 61 times.
✓ Branch 19 taken 61 times.
61 _model.connect(splitter.get(), splitter->nextOutletPort(), newNode, newNode.inletPort());
218
7/7
✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 7 taken 61 times.
✓ Branch 10 taken 61 times.
✓ Branch 13 taken 61 times.
✓ Branch 16 taken 61 times.
✓ Branch 19 taken 61 times.
61 _model.connect(newNode, newNode.outletPort(), mixer.get(), mixer->nextInletPort());
219 61 }
220
221 75 return true;
222 } else {
223 33 boost::optional<ModelObject> newOutletComponent;
224 33 boost::optional<unsigned> newOutletComponentInletPort;
225
226
3/6
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
66 if (inletNode && outletNode) {
227
2/2
✓ Branch 1 taken 33 times.
✓ Branch 4 taken 33 times.
33 newOutletComponent = outletNode->outletModelObject();
228
4/4
✓ Branch 1 taken 33 times.
✓ Branch 4 taken 33 times.
✓ Branch 7 taken 33 times.
✓ Branch 10 taken 33 times.
33 newOutletComponentInletPort = outletNode->connectedObjectPort(outletNode->outletPort());
229 }
230
231
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
33 if (!newOutletComponent) {
232 ✗ newOutletComponent = outletComponent;
233 }
234
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
33 if (!newOutletComponentInletPort) {
235 ✗ newOutletComponentInletPort = outletComponentInletPort;
236 }
237
238
2/2
✓ Branch 1 taken 33 times.
✓ Branch 4 taken 33 times.
33 _model.disconnect(thisObject, componentInletPort);
239
2/2
✓ Branch 1 taken 33 times.
✓ Branch 4 taken 33 times.
33 _model.disconnect(thisObject, componentOutletPort);
240
241 // outletNode->remove() would have failed if we did it before the disconnect
242
3/6
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
66 if (inletNode && outletNode) {
243
2/2
✓ Branch 1 taken 33 times.
✓ Branch 4 taken 33 times.
33 outletNode->remove();
244 }
245
246
8/8
✓ Branch 1 taken 33 times.
✓ Branch 4 taken 33 times.
✓ Branch 7 taken 33 times.
✓ Branch 10 taken 33 times.
✓ Branch 13 taken 33 times.
✓ Branch 16 taken 33 times.
✓ Branch 19 taken 33 times.
✓ Branch 22 taken 33 times.
33 model().connect(inletComponent.get(), inletComponentOutletPort.get(), newOutletComponent.get(), newOutletComponentInletPort.get());
247
248 33 return true;
249 33 }
250
251 return false;
252 147 }
253
254 1676 bool HVACComponent_Impl::addToNode(Node& node, const HVACComponent& systemStartComponent, const HVACComponent& systemEndComponent,
255 unsigned componentInletPort, unsigned componentOutletPort) {
256
1/1
✓ Branch 1 taken 1676 times.
1676 Model _model = model();
257
1/1
✓ Branch 1 taken 1676 times.
1676 auto thisModelObject = getObject<ModelObject>();
258
259
3/4
✓ Branch 1 taken 1676 times.
✓ Branch 4 taken 1676 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1676 times.
1676 if (node.model() != _model) {
260 ✗ return false;
261 }
262
3/4
✓ Branch 1 taken 1676 times.
✓ Branch 4 taken 1676 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1676 times.
1676 if (systemStartComponent.model() != _model) {
263 ✗ return false;
264 }
265
3/4
✓ Branch 1 taken 1676 times.
✓ Branch 4 taken 1676 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1676 times.
1676 if (systemEndComponent.model() != _model) {
266 ✗ return false;
267 }
268
269
12/14
✓ Branch 1 taken 1676 times.
✓ Branch 3 taken 435 times.
✓ Branch 4 taken 1241 times.
✓ Branch 6 taken 435 times.
✓ Branch 9 taken 435 times.
✓ Branch 12 taken 435 times.
✓ Branch 14 taken 199 times.
✓ Branch 15 taken 236 times.
✓ Branch 16 taken 435 times.
✓ Branch 17 taken 1241 times.
✓ Branch 19 taken 199 times.
✓ Branch 20 taken 1477 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
1676 if ((node == systemEndComponent) && (node.inletModelObject().get() == systemStartComponent)) {
270
3/3
✓ Branch 1 taken 199 times.
✓ Branch 4 taken 199 times.
✓ Branch 7 taken 199 times.
199 unsigned oldOutletPort = node.connectedObjectPort(node.inletPort()).get();
271
1/1
✓ Branch 1 taken 199 times.
199 unsigned oldInletPort = node.inletPort();
272
4/4
✓ Branch 1 taken 199 times.
✓ Branch 4 taken 199 times.
✓ Branch 7 taken 199 times.
✓ Branch 10 taken 199 times.
199 ModelObject oldSourceModelObject = node.connectedObject(node.inletPort()).get();
273
1/1
✓ Branch 1 taken 199 times.
199 ModelObject oldTargetModelObject = node;
274
275 // If systemStartComponent is not a node we need to insert one so that there
276 // is a node between systemStartComponent and this component we are adding
277 // This situation occurs in the oa system relief stream.
278
3/3
✓ Branch 1 taken 199 times.
✓ Branch 5 taken 21 times.
✓ Branch 6 taken 178 times.
199 if (!systemStartComponent.optionalCast<Node>()) {
279
1/1
✓ Branch 1 taken 21 times.
21 Node newNode(_model);
280
4/4
✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
✓ Branch 7 taken 21 times.
✓ Branch 10 taken 21 times.
21 _model.connect(oldSourceModelObject, oldOutletPort, newNode, newNode.inletPort());
281
1/1
✓ Branch 1 taken 21 times.
21 oldOutletPort = newNode.outletPort();
282
1/1
✓ Branch 1 taken 21 times.
21 oldSourceModelObject = newNode;
283 21 }
284
285
3/3
✓ Branch 1 taken 199 times.
✓ Branch 4 taken 199 times.
✓ Branch 7 taken 199 times.
199 _model.connect(oldSourceModelObject, oldOutletPort, thisModelObject, componentInletPort);
286
3/3
✓ Branch 1 taken 199 times.
✓ Branch 4 taken 199 times.
✓ Branch 7 taken 199 times.
199 _model.connect(thisModelObject, componentOutletPort, oldTargetModelObject, oldInletPort);
287 199 return true;
288
12/14
✓ Branch 3 taken 1477 times.
✓ Branch 5 taken 786 times.
✓ Branch 6 taken 691 times.
✓ Branch 8 taken 786 times.
✓ Branch 11 taken 786 times.
✓ Branch 14 taken 786 times.
✓ Branch 16 taken 374 times.
✓ Branch 17 taken 412 times.
✓ Branch 18 taken 786 times.
✓ Branch 19 taken 691 times.
✓ Branch 21 taken 374 times.
✓ Branch 22 taken 1103 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
1676 } else if ((node == systemStartComponent) && (node.outletModelObject().get() == systemEndComponent)) {
289
3/3
✓ Branch 1 taken 374 times.
✓ Branch 4 taken 374 times.
✓ Branch 7 taken 374 times.
374 unsigned oldInletPort = node.connectedObjectPort(node.outletPort()).get();
290
1/1
✓ Branch 1 taken 374 times.
374 unsigned oldOutletPort = node.outletPort();
291
4/4
✓ Branch 1 taken 374 times.
✓ Branch 4 taken 374 times.
✓ Branch 7 taken 374 times.
✓ Branch 10 taken 374 times.
374 ModelObject oldTargetModelObject = node.connectedObject(node.outletPort()).get();
292
1/1
✓ Branch 1 taken 374 times.
374 ModelObject oldSourceModelObject = node;
293
294 // If systemEndComponent is not a node we need to insert one so that there
295 // is a node between systemEndComponent and this component we are adding
296 // This situation occurs in the oa system outdoor air stream.
297
3/3
✓ Branch 1 taken 374 times.
✓ Branch 5 taken 203 times.
✓ Branch 6 taken 171 times.
374 if (!systemEndComponent.optionalCast<Node>()) {
298
1/1
✓ Branch 1 taken 203 times.
203 Node newNode(_model);
299
4/4
✓ Branch 1 taken 203 times.
✓ Branch 4 taken 203 times.
✓ Branch 7 taken 203 times.
✓ Branch 10 taken 203 times.
203 _model.connect(newNode, newNode.outletPort(), oldTargetModelObject, oldInletPort);
300
1/1
✓ Branch 1 taken 203 times.
203 oldInletPort = newNode.inletPort();
301
1/1
✓ Branch 1 taken 203 times.
203 oldTargetModelObject = newNode;
302 203 }
303
304
3/3
✓ Branch 1 taken 374 times.
✓ Branch 4 taken 374 times.
✓ Branch 7 taken 374 times.
374 _model.connect(oldSourceModelObject, oldOutletPort, thisModelObject, componentInletPort);
305
3/3
✓ Branch 1 taken 374 times.
✓ Branch 4 taken 374 times.
✓ Branch 7 taken 374 times.
374 _model.connect(thisModelObject, componentOutletPort, oldTargetModelObject, oldInletPort);
306 374 return true;
307
3/3
✓ Branch 3 taken 1103 times.
✓ Branch 5 taken 236 times.
✓ Branch 6 taken 867 times.
1477 } else if (node == systemEndComponent) {
308
3/3
✓ Branch 1 taken 236 times.
✓ Branch 4 taken 236 times.
✓ Branch 7 taken 236 times.
236 unsigned oldOutletPort = node.connectedObjectPort(node.inletPort()).get();
309
1/1
✓ Branch 1 taken 236 times.
236 unsigned oldInletPort = node.inletPort();
310
4/4
✓ Branch 1 taken 236 times.
✓ Branch 4 taken 236 times.
✓ Branch 7 taken 236 times.
✓ Branch 10 taken 236 times.
236 ModelObject oldSourceModelObject = node.connectedObject(node.inletPort()).get();
311
1/1
✓ Branch 1 taken 236 times.
236 ModelObject oldTargetModelObject = node;
312
313
1/1
✓ Branch 1 taken 236 times.
236 Node newNode(_model);
314
4/4
✓ Branch 1 taken 236 times.
✓ Branch 4 taken 236 times.
✓ Branch 7 taken 236 times.
✓ Branch 10 taken 236 times.
236 _model.connect(oldSourceModelObject, oldOutletPort, newNode, newNode.inletPort());
315
4/4
✓ Branch 1 taken 236 times.
✓ Branch 4 taken 236 times.
✓ Branch 7 taken 236 times.
✓ Branch 10 taken 236 times.
236 _model.connect(newNode, newNode.outletPort(), thisModelObject, componentInletPort);
316
3/3
✓ Branch 1 taken 236 times.
✓ Branch 4 taken 236 times.
✓ Branch 7 taken 236 times.
236 _model.connect(thisModelObject, componentOutletPort, oldTargetModelObject, oldInletPort);
317 236 return true;
318 236 } else {
319
1/1
✓ Branch 1 taken 867 times.
867 unsigned oldOutletPort = node.outletPort();
320
3/3
✓ Branch 1 taken 867 times.
✓ Branch 4 taken 867 times.
✓ Branch 7 taken 867 times.
867 unsigned oldInletPort = node.connectedObjectPort(node.outletPort()).get();
321
1/1
✓ Branch 1 taken 867 times.
867 ModelObject oldSourceModelObject = node;
322
4/4
✓ Branch 1 taken 867 times.
✓ Branch 4 taken 867 times.
✓ Branch 7 taken 867 times.
✓ Branch 10 taken 867 times.
867 ModelObject oldTargetModelObject = node.connectedObject(node.outletPort()).get();
323
324
1/1
✓ Branch 1 taken 867 times.
867 Node newNode(_model);
325
3/3
✓ Branch 1 taken 867 times.
✓ Branch 4 taken 867 times.
✓ Branch 7 taken 867 times.
867 _model.connect(oldSourceModelObject, oldOutletPort, thisModelObject, componentInletPort);
326
4/4
✓ Branch 1 taken 867 times.
✓ Branch 4 taken 867 times.
✓ Branch 7 taken 867 times.
✓ Branch 10 taken 867 times.
867 _model.connect(thisModelObject, componentOutletPort, newNode, newNode.inletPort());
327
4/4
✓ Branch 1 taken 867 times.
✓ Branch 4 taken 867 times.
✓ Branch 7 taken 867 times.
✓ Branch 10 taken 867 times.
867 _model.connect(newNode, newNode.outletPort(), oldTargetModelObject, oldInletPort);
328 867 return true;
329 867 }
330
331 return false;
332 1676 }
333
334 2 bool HVACComponent_Impl::addToNode(Node& /*node*/) {
335 2 return false;
336 }
337
338 44 std::vector<ModelObject> HVACComponent_Impl::children() const {
339 44 return {};
340 }
341
342 87 boost::optional<ParentObject> HVACComponent_Impl::parent() const {
343 87 return {};
344 }
345
346 ✗ bool HVACComponent_Impl::addToSplitter(Splitter& /*splitter*/) {
347 ✗ return false;
348 }
349
350 ✗ const std::vector<std::string>& HVACComponent_Impl::outputVariableNames() const {
351 ✗ static const std::vector<std::string> result;
352 ✗ return result;
353 }
354
355 22 void HVACComponent_Impl::disconnect() {
356 22 return;
357 }
358
359 458 bool HVACComponent_Impl::isRemovable() const {
360
3/3
✓ Branch 1 taken 458 times.
✓ Branch 4 taken 41 times.
✓ Branch 5 taken 417 times.
916 if (containingHVACComponent()) {
361 41 return false;
362
3/3
✓ Branch 1 taken 417 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 411 times.
834 } else if (containingZoneHVACComponent()) {
363 6 return false;
364
2/3
✓ Branch 1 taken 411 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 411 times.
822 } else if (containingStraightComponent()) {
365 ✗ return false;
366 } else {
367 411 return true;
368 }
369 }
370
371 495 std::vector<IdfObject> HVACComponent_Impl::remove() {
372
2/2
✓ Branch 1 taken 474 times.
✓ Branch 2 taken 21 times.
495 if (this->isRemovable()) {
373 474 return ParentObject_Impl::remove();
374 } else {
375 21 return {};
376 }
377 }
378
379 ✗ boost::optional<ModelObject> HVACComponent_Impl::airLoopHVACAsModelObject() const {
380 ✗ if (OptionalAirLoopHVAC intermediate = airLoopHVAC()) {
381 ✗ return *intermediate;
382 ✗ }
383 ✗ return boost::none;
384 }
385
386 ✗ boost::optional<ModelObject> HVACComponent_Impl::plantLoopAsModelObject() const {
387 ✗ if (OptionalPlantLoop intermediate = plantLoop()) {
388 ✗ return *intermediate;
389 ✗ }
390 ✗ return boost::none;
391 }
392
393 ✗ boost::optional<ModelObject> HVACComponent_Impl::airLoopHVACOutdoorAirSystemAsModelObject() const {
394 ✗ if (OptionalAirLoopHVACOutdoorAirSystem intermediate = airLoopHVACOutdoorAirSystem()) {
395 ✗ return *intermediate;
396 ✗ }
397 ✗ return boost::none;
398 }
399
400 454 ModelObject HVACComponent_Impl::clone(Model model) const {
401 // Note: JM 2018-08-29: children controls what we see in the Inspector in OS App, and it's not necessarilly what we want to clone
402 // So the parent/children link is broken on purpose here
403
2/2
✓ Branch 1 taken 454 times.
✓ Branch 4 taken 454 times.
454 return ModelObject_Impl::clone(model);
404 }
405
406 ✗ std::vector<HVACComponent> HVACComponent_Impl::edges(const boost::optional<HVACComponent>& /*previous*/) {
407 ✗ return {};
408 }
409
410 253 boost::optional<HVACComponent> HVACComponent_Impl::containingHVACComponent() const {
411 253 return boost::none;
412 }
413
414 304 boost::optional<ZoneHVACComponent> HVACComponent_Impl::containingZoneHVACComponent() const {
415 304 return boost::none;
416 }
417
418 474 boost::optional<StraightComponent> HVACComponent_Impl::containingStraightComponent() const {
419 474 return boost::none;
420 }
421
422 // default implementation does nothing.
423 // should only be used by objects that have
424 // no autosized fields
425 ✗ void HVACComponent_Impl::autosize() {
426 ✗ return;
427 }
428
429 // default implementation does nothing.
430 // should only be used by objects that have
431 // no autosized fields
432 ✗ void HVACComponent_Impl::applySizingValues() {
433 ✗ return;
434 }
435
436 ✗ std::vector<EMSActuatorNames> HVACComponent_Impl::emsActuatorNames() const {
437 ✗ return {};
438 }
439
440 ✗ std::vector<std::string> HVACComponent_Impl::emsInternalVariableNames() const {
441 ✗ return {};
442 }
443
444 // ComponentType HVACComponent_Impl::componentType() const {
445 // return ComponentType::None;
446 // }
447
448 // std::vector<FuelType> HVACComponent_Impl::coolingFuelTypes() const {
449 // return {};
450 // }
451
452 // std::vector<FuelType> HVACComponent_Impl::heatingFuelTypes() const {
453 // return {};
454 // }
455
456 // std::vector<AppGFuelType> HVACComponent_Impl::appGHeatingFuelTypes() const {
457 // return {};
458 // }
459
460 } // namespace detail
461
462
1/1
✓ Branch 3 taken 520953 times.
520953 HVACComponent::HVACComponent(std::shared_ptr<detail::HVACComponent_Impl> p) : ParentObject(std::move(p)) {}
463
464 24690 HVACComponent::HVACComponent(IddObjectType type, const Model& model) : ParentObject(type, model) {
465
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 24690 times.
✗ Branch 5 not taken.
24690 OS_ASSERT(getImpl<detail::HVACComponent_Impl>());
466 24690 }
467
468 1193 boost::optional<Loop> HVACComponent::loop() const {
469
1/1
✓ Branch 3 taken 1193 times.
1193 return getImpl<detail::HVACComponent_Impl>()->loop();
470 }
471
472 1645 boost::optional<AirLoopHVAC> HVACComponent::airLoopHVAC() const {
473
1/1
✓ Branch 3 taken 1645 times.
1645 return getImpl<detail::HVACComponent_Impl>()->airLoopHVAC();
474 }
475
476 2096 boost::optional<AirLoopHVACOutdoorAirSystem> HVACComponent::airLoopHVACOutdoorAirSystem() const {
477
1/1
✓ Branch 3 taken 2096 times.
2096 return getImpl<detail::HVACComponent_Impl>()->airLoopHVACOutdoorAirSystem();
478 }
479
480 1222 boost::optional<PlantLoop> HVACComponent::plantLoop() const {
481
1/1
✓ Branch 3 taken 1222 times.
1222 return getImpl<detail::HVACComponent_Impl>()->plantLoop();
482 }
483
484 3358 bool HVACComponent::addToNode(Node& node) {
485
1/1
✓ Branch 3 taken 3358 times.
3358 return getImpl<detail::HVACComponent_Impl>()->addToNode(node);
486 }
487
488 ✗ bool HVACComponent::addToSplitter(Splitter& splitter) {
489 ✗ return getImpl<detail::HVACComponent_Impl>()->addToSplitter(splitter);
490 }
491
492 400 void HVACComponent::disconnect() {
493
1/1
✓ Branch 3 taken 400 times.
400 return getImpl<detail::HVACComponent_Impl>()->disconnect();
494 }
495
496 24 bool HVACComponent::isRemovable() const {
497
1/1
✓ Branch 3 taken 24 times.
24 return getImpl<detail::HVACComponent_Impl>()->isRemovable();
498 }
499
500 1054 std::vector<IdfObject> HVACComponent::remove() {
501
1/1
✓ Branch 3 taken 1054 times.
1054 return getImpl<detail::HVACComponent_Impl>()->remove();
502 }
503
504 288 boost::optional<HVACComponent> HVACComponent::containingHVACComponent() const {
505
1/1
✓ Branch 3 taken 288 times.
288 return getImpl<detail::HVACComponent_Impl>()->containingHVACComponent();
506 }
507
508 199 boost::optional<ZoneHVACComponent> HVACComponent::containingZoneHVACComponent() const {
509
1/1
✓ Branch 3 taken 199 times.
199 return getImpl<detail::HVACComponent_Impl>()->containingZoneHVACComponent();
510 }
511
512 65 boost::optional<StraightComponent> HVACComponent::containingStraightComponent() const {
513
1/1
✓ Branch 3 taken 65 times.
65 return getImpl<detail::HVACComponent_Impl>()->containingStraightComponent();
514 }
515
516 7 void HVACComponent::autosize() {
517
1/1
✓ Branch 3 taken 7 times.
7 return getImpl<detail::HVACComponent_Impl>()->autosize();
518 }
519
520 ✗ void HVACComponent::applySizingValues() {
521 ✗ return getImpl<detail::HVACComponent_Impl>()->applySizingValues();
522 }
523
524 4645 ComponentType HVACComponent::componentType() const {
525
1/1
✓ Branch 3 taken 4645 times.
4645 return getImpl<detail::HVACComponent_Impl>()->componentType();
526 }
527
528 274 std::vector<FuelType> HVACComponent::coolingFuelTypes() const {
529
1/1
✓ Branch 3 taken 274 times.
274 return getImpl<detail::HVACComponent_Impl>()->coolingFuelTypes();
530 }
531
532 401 std::vector<FuelType> HVACComponent::heatingFuelTypes() const {
533
1/1
✓ Branch 3 taken 401 times.
401 return getImpl<detail::HVACComponent_Impl>()->heatingFuelTypes();
534 }
535
536 387 std::vector<AppGFuelType> HVACComponent::appGHeatingFuelTypes() const {
537
1/1
✓ Branch 3 taken 387 times.
387 return getImpl<detail::HVACComponent_Impl>()->appGHeatingFuelTypes();
538 }
539
540 } // namespace model
541
542 } // namespace openstudio
543