src/model/AirToAirComponent.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 "AirToAirComponent.hpp" | ||
| 7 | #include "AirToAirComponent_Impl.hpp" | ||
| 8 | #include "AirLoopHVAC.hpp" | ||
| 9 | #include "AirLoopHVAC_Impl.hpp" | ||
| 10 | #include "Node.hpp" | ||
| 11 | #include "Node_Impl.hpp" | ||
| 12 | #include "AirLoopHVACOutdoorAirSystem.hpp" | ||
| 13 | #include "AirLoopHVACOutdoorAirSystem_Impl.hpp" | ||
| 14 | #include "Model.hpp" | ||
| 15 | #include "Model_Impl.hpp" | ||
| 16 | #include "../utilities/core/Assert.hpp" | ||
| 17 | |||
| 18 | namespace openstudio { | ||
| 19 | |||
| 20 | namespace model { | ||
| 21 | |||
| 22 | namespace detail { | ||
| 23 | |||
| 24 | ✗ | AirToAirComponent_Impl::AirToAirComponent_Impl(IddObjectType type, Model_Impl* model) : HVACComponent_Impl(type, model) {} | |
| 25 | |||
| 26 | 91 | AirToAirComponent_Impl::AirToAirComponent_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 27 | 91 | : HVACComponent_Impl(idfObject, model, keepHandle) {} | |
| 28 | |||
| 29 | 1 | AirToAirComponent_Impl::AirToAirComponent_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) | |
| 30 | 1 | : HVACComponent_Impl(other, model, keepHandle) {} | |
| 31 | |||
| 32 | 39 | AirToAirComponent_Impl::AirToAirComponent_Impl(const AirToAirComponent_Impl& other, Model_Impl* model, bool keepHandles) | |
| 33 | 39 | : HVACComponent_Impl(other, model, keepHandles) {} | |
| 34 | |||
| 35 | 639 | OptionalModelObject AirToAirComponent_Impl::primaryAirInletModelObject() const { | |
| 36 | 639 | return connectedObject(primaryAirInletPort()); | |
| 37 | } | ||
| 38 | |||
| 39 | 46 | OptionalModelObject AirToAirComponent_Impl::primaryAirOutletModelObject() const { | |
| 40 | 46 | return connectedObject(primaryAirOutletPort()); | |
| 41 | } | ||
| 42 | |||
| 43 | 56 | OptionalModelObject AirToAirComponent_Impl::secondaryAirInletModelObject() const { | |
| 44 | 56 | return connectedObject(secondaryAirInletPort()); | |
| 45 | } | ||
| 46 | |||
| 47 | 602 | OptionalModelObject AirToAirComponent_Impl::secondaryAirOutletModelObject() const { | |
| 48 | 602 | return connectedObject(secondaryAirOutletPort()); | |
| 49 | } | ||
| 50 | |||
| 51 | 20 | std::vector<openstudio::IdfObject> AirToAirComponent_Impl::remove() { | |
| 52 |
1/1✓ Branch 1 taken 20 times.
|
20 | Model _model = model(); |
| 53 | |||
| 54 | 20 | boost::optional<Node> oaOutletNode; | |
| 55 | 20 | boost::optional<ModelObject> oaOutletModelObject; | |
| 56 | 20 | boost::optional<unsigned> oaOutletModelObjectPort; | |
| 57 | |||
| 58 | 20 | boost::optional<Node> oaInletNode; | |
| 59 | |||
| 60 | 20 | boost::optional<Node> reliefInletNode; | |
| 61 | 20 | boost::optional<ModelObject> reliefInletModelObject; | |
| 62 | 20 | boost::optional<unsigned> reliefInletModelObjectPort; | |
| 63 | |||
| 64 | 20 | boost::optional<Node> reliefOutletNode; | |
| 65 | |||
| 66 |
11/16✓ Branch 1 taken 20 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 2 times.
✓ Branch 7 taken 18 times.
✓ Branch 10 taken 11 times.
✓ Branch 11 taken 7 times.
✓ Branch 12 taken 18 times.
✓ Branch 13 taken 2 times.
✓ Branch 15 taken 20 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 11 times.
✓ Branch 19 taken 9 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
58 | if (primaryAirOutletModelObject() && primaryAirInletModelObject()) { |
| 67 |
1/1✓ Branch 1 taken 11 times.
|
11 | boost::optional<ModelObject> mo = primaryAirOutletModelObject(); |
| 68 | |||
| 69 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
11 | boost::optional<Node> node = mo->optionalCast<Node>(); |
| 70 | |||
| 71 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 4 not taken.
|
11 | OS_ASSERT(node); |
| 72 | |||
| 73 |
1/1✓ Branch 1 taken 11 times.
|
11 | oaOutletNode = node; |
| 74 | |||
| 75 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
11 | boost::optional<ModelObject> mo2 = oaOutletNode->outletModelObject(); |
| 76 | |||
| 77 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 4 not taken.
|
11 | OS_ASSERT(mo2); |
| 78 | |||
| 79 |
1/1✓ Branch 1 taken 11 times.
|
11 | oaOutletModelObject = mo2; |
| 80 | |||
| 81 |
4/4✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✓ Branch 10 taken 11 times.
|
11 | oaOutletModelObjectPort = oaOutletNode->connectedObjectPort(oaOutletNode->outletPort()); |
| 82 | |||
| 83 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 4 not taken.
|
11 | OS_ASSERT(oaOutletModelObjectPort); |
| 84 | |||
| 85 |
1/1✓ Branch 1 taken 11 times.
|
11 | mo2 = primaryAirInletModelObject(); |
| 86 | |||
| 87 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 4 not taken.
|
11 | OS_ASSERT(mo2); |
| 88 | |||
| 89 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
11 | node = mo2->optionalCast<Node>(); |
| 90 | |||
| 91 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 4 not taken.
|
11 | OS_ASSERT(node); |
| 92 | |||
| 93 |
1/1✓ Branch 1 taken 11 times.
|
11 | oaInletNode = node; |
| 94 | 11 | } | |
| 95 | |||
| 96 |
10/16✓ Branch 1 taken 20 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 2 times.
✓ Branch 7 taken 18 times.
✓ Branch 10 taken 18 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 18 times.
✓ Branch 13 taken 2 times.
✓ Branch 15 taken 20 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 18 times.
✓ Branch 19 taken 2 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
58 | if (secondaryAirInletModelObject() && secondaryAirOutletModelObject()) { |
| 97 |
1/1✓ Branch 1 taken 18 times.
|
18 | boost::optional<ModelObject> mo = secondaryAirInletModelObject(); |
| 98 | |||
| 99 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
|
18 | boost::optional<Node> node = mo->optionalCast<Node>(); |
| 100 | |||
| 101 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 4 not taken.
|
18 | OS_ASSERT(node); |
| 102 | |||
| 103 |
1/1✓ Branch 1 taken 18 times.
|
18 | reliefInletNode = node; |
| 104 | |||
| 105 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
|
18 | boost::optional<ModelObject> mo2 = reliefInletNode->inletModelObject(); |
| 106 | |||
| 107 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 4 not taken.
|
18 | OS_ASSERT(mo2); |
| 108 | |||
| 109 |
1/1✓ Branch 1 taken 18 times.
|
18 | reliefInletModelObject = mo2; |
| 110 | |||
| 111 |
4/4✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
✓ Branch 7 taken 18 times.
✓ Branch 10 taken 18 times.
|
18 | reliefInletModelObjectPort = reliefInletNode->connectedObjectPort(reliefInletNode->inletPort()); |
| 112 | |||
| 113 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 4 not taken.
|
18 | OS_ASSERT(reliefInletModelObjectPort); |
| 114 | |||
| 115 |
1/1✓ Branch 1 taken 18 times.
|
18 | mo2 = secondaryAirOutletModelObject(); |
| 116 | |||
| 117 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 4 not taken.
|
18 | OS_ASSERT(mo2); |
| 118 | |||
| 119 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
|
18 | node = mo2->optionalCast<Node>(); |
| 120 | |||
| 121 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 4 not taken.
|
18 | OS_ASSERT(node); |
| 122 | |||
| 123 |
1/1✓ Branch 1 taken 18 times.
|
18 | reliefOutletNode = node; |
| 124 | 18 | } | |
| 125 | |||
| 126 |
6/8✓ Branch 0 taken 11 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11 times.
✓ Branch 7 taken 9 times.
|
42 | if (oaOutletModelObject && oaInletNode && oaOutletNode) { |
| 127 |
8/8✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✓ Branch 10 taken 11 times.
✓ Branch 13 taken 11 times.
✓ Branch 16 taken 11 times.
✓ Branch 19 taken 11 times.
✓ Branch 22 taken 11 times.
|
11 | _model.connect(oaInletNode.get(), oaInletNode->outletPort(), oaOutletModelObject.get(), oaOutletModelObjectPort.get()); |
| 128 | |||
| 129 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
11 | oaOutletNode->remove(); |
| 130 | } | ||
| 131 | |||
| 132 |
6/8✓ Branch 0 taken 18 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 2 times.
|
56 | if (reliefInletModelObject && reliefOutletNode && reliefInletNode) { |
| 133 |
8/8✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
✓ Branch 7 taken 18 times.
✓ Branch 10 taken 18 times.
✓ Branch 13 taken 18 times.
✓ Branch 16 taken 18 times.
✓ Branch 19 taken 18 times.
✓ Branch 22 taken 18 times.
|
18 | _model.connect(reliefInletModelObject.get(), reliefInletModelObjectPort.get(), reliefOutletNode.get(), reliefOutletNode->inletPort()); |
| 134 | |||
| 135 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
|
18 | reliefInletNode->disconnect(); |
| 136 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
|
18 | reliefInletNode->remove(); |
| 137 | } | ||
| 138 | |||
| 139 |
1/1✓ Branch 1 taken 20 times.
|
40 | return HVACComponent_Impl::remove(); |
| 140 | 20 | } | |
| 141 | |||
| 142 | 40 | bool AirToAirComponent_Impl::addToNode(Node& node) { | |
| 143 |
1/1✓ Branch 1 taken 40 times.
|
40 | Model _model = node.model(); |
| 144 |
1/1✓ Branch 1 taken 40 times.
|
40 | boost::optional<AirLoopHVACOutdoorAirSystem> oaSystem = node.airLoopHVACOutdoorAirSystem(); |
| 145 | |||
| 146 |
2/3✓ Branch 1 taken 40 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 40 times.
|
80 | if (airLoopHVACOutdoorAirSystem()) { |
| 147 | ✗ | return false; | |
| 148 | } | ||
| 149 | |||
| 150 |
1/2✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
|
40 | if (oaSystem) { |
| 151 | // The OA node that we will connect to | ||
| 152 | 40 | boost::optional<Node> oaNode; | |
| 153 | |||
| 154 | // The node on the relief side that we should connect to | ||
| 155 | 40 | boost::optional<Node> reliefNode; | |
| 156 | |||
| 157 |
4/4✓ Branch 1 taken 40 times.
✓ Branch 4 taken 40 times.
✓ Branch 7 taken 40 times.
✓ Branch 10 taken 40 times.
|
40 | Node outboardOANode = oaSystem->outboardOANode().get(); |
| 158 |
4/4✓ Branch 1 taken 40 times.
✓ Branch 4 taken 40 times.
✓ Branch 7 taken 40 times.
✓ Branch 10 taken 40 times.
|
40 | Node outboardReliefNode = oaSystem->outboardReliefNode().get(); |
| 159 |
1/1✓ Branch 1 taken 40 times.
|
40 | auto thisObject = getObject<HVACComponent>(); |
| 160 | |||
| 161 | // next / prev components are going to be assigned either the next downstream AirToAirComponent or the end of the air stream | ||
| 162 | // The end of the air stream is either the OA systems itself or the outboard relief / supply nodes. | ||
| 163 | // Downstream is from the perspective of the particular side of the OA System the component is on. | ||
| 164 | // Downstream on the supply side is toward the OA Mixer itself. | ||
| 165 | // Downstream on the relief side is toward the most outboard relief node | ||
| 166 | 40 | boost::optional<HVACComponent> nextSupplyComponent; | |
| 167 | 40 | boost::optional<HVACComponent> prevSupplyComponent; | |
| 168 | |||
| 169 | 40 | boost::optional<HVACComponent> nextReliefComponent; | |
| 170 | 40 | boost::optional<HVACComponent> prevReliefComponent; | |
| 171 | |||
| 172 |
4/4✓ Branch 1 taken 40 times.
✓ Branch 4 taken 40 times.
✓ Branch 7 taken 40 times.
✓ Branch 10 taken 40 times.
|
80 | std::vector<ModelObject> oaComponents = oaSystem->oaComponents(); |
| 173 |
4/4✓ Branch 1 taken 40 times.
✓ Branch 4 taken 40 times.
✓ Branch 7 taken 40 times.
✓ Branch 10 taken 40 times.
|
80 | std::vector<ModelObject> reliefComponents = oaSystem->reliefComponents(); |
| 174 | |||
| 175 |
5/5✓ Branch 1 taken 40 times.
✓ Branch 4 taken 40 times.
✓ Branch 7 taken 40 times.
✓ Branch 10 taken 32 times.
✓ Branch 11 taken 8 times.
|
80 | if (oaSystem->oaComponent(node.handle())) { |
| 176 |
1/1✓ Branch 1 taken 32 times.
|
32 | oaNode = node; |
| 177 | |||
| 178 | // n will be the number of HVACComponent objects from the drop node to "nextSupplyComponent" | ||
| 179 | 32 | int n = -1; | |
| 180 | |||
| 181 | // bigNPrime will be the number of HVACComponent objects from prevReliefComponent to nextReliefComponent | ||
| 182 | 32 | int bigNPrime = -1; | |
| 183 | |||
| 184 | // Find nextSupplyComponent | ||
| 185 | |||
| 186 |
1/1✓ Branch 3 taken 32 times.
|
32 | auto dropNodeLocation = std::find(oaComponents.begin(), oaComponents.end(), node); |
| 187 | |||
| 188 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
✗ Branch 5 not taken.
|
32 | OS_ASSERT(dropNodeLocation != oaComponents.end()); |
| 189 | |||
| 190 |
2/2✓ Branch 3 taken 101 times.
✓ Branch 4 taken 21 times.
|
122 | for (auto it = dropNodeLocation; it != oaComponents.end(); ++it) { |
| 191 | 101 | n++; | |
| 192 | |||
| 193 |
4/4✓ Branch 2 taken 101 times.
✓ Branch 5 taken 101 times.
✓ Branch 9 taken 11 times.
✓ Branch 10 taken 90 times.
|
202 | if ((nextSupplyComponent = it->optionalCast<AirToAirComponent>())) { |
| 194 | 11 | break; | |
| 195 | } | ||
| 196 | } | ||
| 197 | |||
| 198 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 2 taken 11 times.
|
32 | if (!nextSupplyComponent) { |
| 199 |
1/1✓ Branch 1 taken 21 times.
|
21 | nextSupplyComponent = oaSystem; |
| 200 | } | ||
| 201 | |||
| 202 | // Find prevSupplyComponent | ||
| 203 | |||
| 204 |
1/1✓ Branch 3 taken 32 times.
|
32 | auto rDropNodeLocation = std::find(oaComponents.rbegin(), oaComponents.rend(), node); |
| 205 | |||
| 206 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
✗ Branch 5 not taken.
|
32 | OS_ASSERT(rDropNodeLocation != oaComponents.rend()); |
| 207 | |||
| 208 |
2/2✓ Branch 4 taken 44 times.
✓ Branch 5 taken 26 times.
|
70 | for (auto it = rDropNodeLocation; it != oaComponents.rend(); ++it) { |
| 209 |
5/5✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
✓ Branch 11 taken 6 times.
✓ Branch 12 taken 38 times.
|
88 | if ((prevSupplyComponent = it->optionalCast<AirToAirComponent>())) { |
| 210 | 6 | break; | |
| 211 | } | ||
| 212 | } | ||
| 213 | |||
| 214 |
2/2✓ Branch 1 taken 26 times.
✓ Branch 2 taken 6 times.
|
32 | if (!prevSupplyComponent) { |
| 215 |
1/1✓ Branch 1 taken 26 times.
|
26 | prevSupplyComponent = outboardOANode; |
| 216 | } | ||
| 217 | |||
| 218 | // Find prevReliefComponent | ||
| 219 | |||
| 220 |
1/1✓ Branch 1 taken 32 times.
|
32 | prevReliefComponent = nextSupplyComponent; |
| 221 | |||
| 222 | // Find nextReliefComponent | ||
| 223 | |||
| 224 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 4 not taken.
|
32 | OS_ASSERT(prevReliefComponent); |
| 225 | |||
| 226 | 32 | std::vector<ModelObject>::iterator prevReliefComponentLocation; | |
| 227 | |||
| 228 |
5/5✓ Branch 1 taken 32 times.
✓ Branch 4 taken 32 times.
✓ Branch 7 taken 32 times.
✓ Branch 9 taken 11 times.
✓ Branch 10 taken 21 times.
|
32 | if (prevReliefComponent.get() != oaSystem.get()) { |
| 229 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 6 taken 11 times.
|
11 | prevReliefComponentLocation = std::find(reliefComponents.begin(), reliefComponents.end(), prevReliefComponent.get()); |
| 230 | } else { | ||
| 231 | 21 | prevReliefComponentLocation = reliefComponents.begin(); | |
| 232 | } | ||
| 233 | |||
| 234 |
2/2✓ Branch 3 taken 51 times.
✓ Branch 4 taken 26 times.
|
77 | for (auto it = prevReliefComponentLocation; it != reliefComponents.end(); ++it) { |
| 235 | 51 | bigNPrime++; | |
| 236 | |||
| 237 |
4/4✓ Branch 2 taken 51 times.
✓ Branch 5 taken 51 times.
✓ Branch 9 taken 17 times.
✓ Branch 10 taken 34 times.
|
102 | if ((nextReliefComponent = it->optionalCast<AirToAirComponent>())) { |
| 238 |
4/4✓ Branch 1 taken 17 times.
✓ Branch 5 taken 17 times.
✓ Branch 7 taken 6 times.
✓ Branch 8 taken 11 times.
|
17 | if (*it != prevReliefComponent.get()) { |
| 239 | 6 | break; | |
| 240 | } | ||
| 241 | } | ||
| 242 | } | ||
| 243 | |||
| 244 |
2/2✓ Branch 1 taken 26 times.
✓ Branch 2 taken 6 times.
|
32 | if (!nextReliefComponent) { |
| 245 |
1/1✓ Branch 1 taken 26 times.
|
26 | nextReliefComponent = outboardReliefNode; |
| 246 | } | ||
| 247 | |||
| 248 | // Find the relief node | ||
| 249 | |||
| 250 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 28 times.
|
32 | if (n < bigNPrime) { |
| 251 |
1/1✓ Branch 3 taken 4 times.
|
4 | boost::optional<ModelObject> mo = *(prevReliefComponentLocation + n); |
| 252 | |||
| 253 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 4 not taken.
|
4 | OS_ASSERT(mo); |
| 254 | |||
| 255 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | reliefNode = mo->optionalCast<Node>(); |
| 256 | |||
| 257 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 4 not taken.
|
4 | OS_ASSERT(reliefNode); |
| 258 | 4 | } else { | |
| 259 |
4/4✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
✓ Branch 6 taken 26 times.
✓ Branch 7 taken 2 times.
|
28 | if (nextReliefComponent.get() == outboardReliefNode) { |
| 260 |
1/1✓ Branch 1 taken 26 times.
|
26 | reliefNode = outboardReliefNode; |
| 261 | } else { | ||
| 262 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | boost::optional<AirToAirComponent> comp = nextReliefComponent->optionalCast<AirToAirComponent>(); |
| 263 | |||
| 264 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 4 not taken.
|
2 | OS_ASSERT(comp); |
| 265 | |||
| 266 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | boost::optional<ModelObject> comp2 = comp->secondaryAirInletModelObject(); |
| 267 | |||
| 268 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | reliefNode = comp2->optionalCast<Node>(); |
| 269 | |||
| 270 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 4 not taken.
|
2 | OS_ASSERT(reliefNode); |
| 271 | 2 | } | |
| 272 | } | ||
| 273 | |||
| 274 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 4 not taken.
|
32 | OS_ASSERT(reliefNode); |
| 275 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 4 not taken.
|
32 | OS_ASSERT(oaNode); |
| 276 |
4/5✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
✓ Branch 10 taken 8 times.
✗ Branch 11 not taken.
|
16 | } else if (oaSystem->reliefComponent(node.handle())) { |
| 277 |
1/1✓ Branch 1 taken 8 times.
|
8 | reliefNode = node; |
| 278 | |||
| 279 | // n will be the number of HVACComponent objects from the drop node to "nextReliefComponent" | ||
| 280 | 8 | int n = -1; | |
| 281 | |||
| 282 | // bigNPrime will be the number of HVACComponent objects from prevSupplyComponent to nextSupplyComponent | ||
| 283 | 8 | int bigNPrime = -1; | |
| 284 | |||
| 285 | // Find nextReliefComponent | ||
| 286 | |||
| 287 |
1/1✓ Branch 3 taken 8 times.
|
8 | auto dropNodeLocation = std::find(reliefComponents.begin(), reliefComponents.end(), node); |
| 288 | |||
| 289 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 5 not taken.
|
8 | OS_ASSERT(dropNodeLocation != reliefComponents.end()); |
| 290 | |||
| 291 |
2/2✓ Branch 3 taken 10 times.
✓ Branch 4 taken 6 times.
|
16 | for (auto it = dropNodeLocation; it != reliefComponents.end(); ++it) { |
| 292 | 10 | n++; | |
| 293 | |||
| 294 |
4/4✓ Branch 2 taken 10 times.
✓ Branch 5 taken 10 times.
✓ Branch 9 taken 2 times.
✓ Branch 10 taken 8 times.
|
20 | if ((nextReliefComponent = it->optionalCast<AirToAirComponent>())) { |
| 295 | 2 | break; | |
| 296 | } | ||
| 297 | } | ||
| 298 | |||
| 299 |
2/2✓ Branch 1 taken 6 times.
✓ Branch 2 taken 2 times.
|
8 | if (!nextReliefComponent) { |
| 300 |
1/1✓ Branch 1 taken 6 times.
|
6 | nextReliefComponent = outboardReliefNode; |
| 301 | } | ||
| 302 | |||
| 303 | // Find prevReliefComponent | ||
| 304 | |||
| 305 |
1/1✓ Branch 3 taken 8 times.
|
8 | auto rDropNodeLocation = std::find(reliefComponents.rbegin(), reliefComponents.rend(), node); |
| 306 | |||
| 307 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 5 not taken.
|
8 | OS_ASSERT(rDropNodeLocation != reliefComponents.rend()); |
| 308 | |||
| 309 |
2/2✓ Branch 4 taken 14 times.
✓ Branch 5 taken 2 times.
|
16 | for (auto it = rDropNodeLocation; it != reliefComponents.rend(); ++it) { |
| 310 |
5/5✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
✓ Branch 7 taken 14 times.
✓ Branch 11 taken 6 times.
✓ Branch 12 taken 8 times.
|
28 | if ((prevReliefComponent = it->optionalCast<AirToAirComponent>())) { |
| 311 | 6 | break; | |
| 312 | } | ||
| 313 | } | ||
| 314 | |||
| 315 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 2 taken 6 times.
|
8 | if (!prevReliefComponent) { |
| 316 |
1/1✓ Branch 1 taken 2 times.
|
2 | prevReliefComponent = oaSystem; |
| 317 | } | ||
| 318 | |||
| 319 | // Find prevSupplyComponent | ||
| 320 | |||
| 321 |
4/4✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 6 times.
|
8 | if (nextReliefComponent.get() != outboardReliefNode) { |
| 322 |
1/1✓ Branch 1 taken 2 times.
|
2 | prevSupplyComponent = nextReliefComponent; |
| 323 | } else { | ||
| 324 |
1/1✓ Branch 1 taken 6 times.
|
6 | prevSupplyComponent = outboardOANode; |
| 325 | } | ||
| 326 | |||
| 327 | // Find nextSupplyComponent | ||
| 328 | |||
| 329 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 4 not taken.
|
8 | OS_ASSERT(prevSupplyComponent); |
| 330 | |||
| 331 | 8 | std::vector<ModelObject>::iterator prevSupplyComponentLocation; | |
| 332 | |||
| 333 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 6 taken 8 times.
|
8 | prevSupplyComponentLocation = std::find(oaComponents.begin(), oaComponents.end(), prevSupplyComponent.get()); |
| 334 | |||
| 335 |
1/2✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
|
14 | for (auto it = prevSupplyComponentLocation; it != oaComponents.end(); ++it) { |
| 336 | 14 | bigNPrime++; | |
| 337 | |||
| 338 |
4/4✓ Branch 2 taken 14 times.
✓ Branch 5 taken 14 times.
✓ Branch 9 taken 8 times.
✓ Branch 10 taken 6 times.
|
28 | if ((nextSupplyComponent = it->optionalCast<AirToAirComponent>())) { |
| 339 | 8 | break; | |
| 340 | } | ||
| 341 | } | ||
| 342 | |||
| 343 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
|
8 | if (!nextSupplyComponent) { |
| 344 | ✗ | nextSupplyComponent = oaSystem; | |
| 345 | } | ||
| 346 | |||
| 347 | // Find the oaNode | ||
| 348 | |||
| 349 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
|
8 | if (n < bigNPrime) { |
| 350 |
1/1✓ Branch 3 taken 6 times.
|
6 | boost::optional<ModelObject> mo = *(prevSupplyComponentLocation + n); |
| 351 | |||
| 352 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 4 not taken.
|
6 | OS_ASSERT(mo); |
| 353 | |||
| 354 |
2/2✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
|
6 | oaNode = mo->optionalCast<Node>(); |
| 355 | |||
| 356 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 4 not taken.
|
6 | OS_ASSERT(oaNode); |
| 357 | 6 | } else { | |
| 358 |
4/5✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
|
2 | if (nextSupplyComponent.get() == oaSystem.get()) { |
| 359 | ✗ | oaNode = oaSystem->outdoorAirModelObject()->cast<Node>(); | |
| 360 | } else { | ||
| 361 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | boost::optional<AirToAirComponent> comp = nextSupplyComponent->optionalCast<AirToAirComponent>(); |
| 362 | |||
| 363 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 4 not taken.
|
2 | OS_ASSERT(comp); |
| 364 | |||
| 365 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | boost::optional<ModelObject> comp2 = comp->primaryAirInletModelObject(); |
| 366 | |||
| 367 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | oaNode = comp2->optionalCast<Node>(); |
| 368 | |||
| 369 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 4 not taken.
|
2 | OS_ASSERT(oaNode); |
| 370 | 2 | } | |
| 371 | } | ||
| 372 | |||
| 373 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 4 not taken.
|
8 | OS_ASSERT(reliefNode); |
| 374 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 4 not taken.
|
8 | OS_ASSERT(oaNode); |
| 375 | } | ||
| 376 | |||
| 377 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
✗ Branch 4 not taken.
|
40 | OS_ASSERT(reliefNode); |
| 378 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
✗ Branch 4 not taken.
|
40 | OS_ASSERT(oaNode); |
| 379 | |||
| 380 | // Make new connections on the oa side | ||
| 381 | |||
| 382 |
4/4✓ Branch 1 taken 40 times.
✓ Branch 4 taken 40 times.
✓ Branch 7 taken 40 times.
✓ Branch 10 taken 40 times.
|
40 | ModelObject oldOutletModelObject = oaNode->outletModelObject().get(); |
| 383 |
5/5✓ Branch 1 taken 40 times.
✓ Branch 4 taken 40 times.
✓ Branch 7 taken 40 times.
✓ Branch 10 taken 40 times.
✓ Branch 13 taken 40 times.
|
40 | unsigned oldInletPort = oaNode->connectedObjectPort(oaNode->outletPort()).get(); |
| 384 | |||
| 385 |
1/1✓ Branch 1 taken 40 times.
|
40 | Node newNode(_model); |
| 386 |
1/1✓ Branch 1 taken 40 times.
|
40 | newNode.createName(); |
| 387 | |||
| 388 |
7/7✓ Branch 1 taken 40 times.
✓ Branch 4 taken 40 times.
✓ Branch 7 taken 40 times.
✓ Branch 10 taken 40 times.
✓ Branch 13 taken 40 times.
✓ Branch 16 taken 40 times.
✓ Branch 19 taken 40 times.
|
40 | _model.connect(oaNode.get(), oaNode->outletPort(), thisObject, primaryAirInletPort()); |
| 389 | |||
| 390 |
5/5✓ Branch 1 taken 40 times.
✓ Branch 4 taken 40 times.
✓ Branch 7 taken 40 times.
✓ Branch 10 taken 40 times.
✓ Branch 13 taken 40 times.
|
40 | _model.connect(thisObject, primaryAirOutletPort(), newNode, newNode.inletPort()); |
| 391 | |||
| 392 |
4/4✓ Branch 1 taken 40 times.
✓ Branch 4 taken 40 times.
✓ Branch 7 taken 40 times.
✓ Branch 10 taken 40 times.
|
40 | _model.connect(newNode, newNode.outletPort(), oldOutletModelObject, oldInletPort); |
| 393 | |||
| 394 | // Make new connections on the relief side | ||
| 395 | |||
| 396 |
1/1✓ Branch 1 taken 40 times.
|
40 | Node newNode2(_model); |
| 397 |
1/1✓ Branch 1 taken 40 times.
|
40 | newNode2.createName(); |
| 398 | |||
| 399 |
4/4✓ Branch 1 taken 40 times.
✓ Branch 4 taken 40 times.
✓ Branch 6 taken 32 times.
✓ Branch 7 taken 8 times.
|
40 | if (reliefNode.get() == outboardReliefNode) { |
| 400 |
3/3✓ Branch 1 taken 32 times.
✓ Branch 4 taken 32 times.
✓ Branch 7 taken 32 times.
|
32 | ModelObject oldMO = outboardReliefNode.inletModelObject().get(); |
| 401 |
3/3✓ Branch 1 taken 32 times.
✓ Branch 4 taken 32 times.
✓ Branch 7 taken 32 times.
|
32 | unsigned oldPort = outboardReliefNode.connectedObjectPort(outboardReliefNode.inletPort()).get(); |
| 402 | |||
| 403 |
4/4✓ Branch 1 taken 32 times.
✓ Branch 4 taken 32 times.
✓ Branch 7 taken 32 times.
✓ Branch 10 taken 32 times.
|
32 | _model.connect(oldMO, oldPort, newNode2, newNode2.inletPort()); |
| 404 | |||
| 405 |
5/5✓ Branch 1 taken 32 times.
✓ Branch 4 taken 32 times.
✓ Branch 7 taken 32 times.
✓ Branch 10 taken 32 times.
✓ Branch 13 taken 32 times.
|
32 | _model.connect(newNode2, newNode2.outletPort(), thisObject, secondaryAirInletPort()); |
| 406 | |||
| 407 |
5/5✓ Branch 1 taken 32 times.
✓ Branch 4 taken 32 times.
✓ Branch 7 taken 32 times.
✓ Branch 10 taken 32 times.
✓ Branch 13 taken 32 times.
|
32 | _model.connect(thisObject, secondaryAirOutletPort(), outboardReliefNode, outboardReliefNode.inletPort()); |
| 408 | 32 | } else { | |
| 409 |
4/4✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
✓ Branch 10 taken 8 times.
|
8 | ModelObject oldReliefOutletModelObject = reliefNode->outletModelObject().get(); |
| 410 |
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 | unsigned oldReliefInletPort = reliefNode->connectedObjectPort(reliefNode->outletPort()).get(); |
| 411 | |||
| 412 |
7/7✓ 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.
✓ Branch 16 taken 8 times.
✓ Branch 19 taken 8 times.
|
8 | _model.connect(reliefNode.get(), reliefNode->outletPort(), thisObject, secondaryAirInletPort()); |
| 413 | |||
| 414 |
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(thisObject, secondaryAirOutletPort(), newNode2, newNode2.inletPort()); |
| 415 | |||
| 416 |
4/4✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
✓ Branch 10 taken 8 times.
|
8 | _model.connect(newNode2, newNode2.outletPort(), oldReliefOutletModelObject, oldReliefInletPort); |
| 417 | 8 | } | |
| 418 | |||
| 419 | 40 | return true; | |
| 420 | 40 | } | |
| 421 | |||
| 422 | ✗ | return false; | |
| 423 | 40 | } | |
| 424 | |||
| 425 | 13 | ModelObject AirToAirComponent_Impl::clone(Model model) const { | |
| 426 |
3/3✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
✓ Branch 7 taken 13 times.
|
13 | auto mo = HVACComponent_Impl::clone(model).cast<AirToAirComponent>(); |
| 427 | |||
| 428 |
3/3✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
✓ Branch 7 taken 13 times.
|
26 | mo.setString(mo.primaryAirInletPort(), ""); |
| 429 |
3/3✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
✓ Branch 7 taken 13 times.
|
26 | mo.setString(mo.primaryAirOutletPort(), ""); |
| 430 |
3/3✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
✓ Branch 7 taken 13 times.
|
26 | mo.setString(mo.secondaryAirInletPort(), ""); |
| 431 |
3/3✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
✓ Branch 7 taken 13 times.
|
13 | mo.setString(mo.secondaryAirOutletPort(), ""); |
| 432 | |||
| 433 | 26 | return std::move(mo); | |
| 434 | 13 | } | |
| 435 | |||
| 436 | } // namespace detail | ||
| 437 | |||
| 438 | 90 | AirToAirComponent::AirToAirComponent(IddObjectType type, const Model& model) : HVACComponent(type, model) { | |
| 439 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 90 times.
✗ Branch 5 not taken.
|
90 | OS_ASSERT(getImpl<detail::AirToAirComponent_Impl>()); |
| 440 | 90 | } | |
| 441 | |||
| 442 |
1/1✓ Branch 3 taken 1345 times.
|
1345 | AirToAirComponent::AirToAirComponent(std::shared_ptr<detail::AirToAirComponent_Impl> p) : HVACComponent(std::move(p)) {} |
| 443 | |||
| 444 | 13 | unsigned AirToAirComponent::primaryAirInletPort() const { | |
| 445 |
1/1✓ Branch 3 taken 13 times.
|
13 | return getImpl<detail::AirToAirComponent_Impl>()->primaryAirInletPort(); |
| 446 | } | ||
| 447 | |||
| 448 | 13 | unsigned AirToAirComponent::primaryAirOutletPort() const { | |
| 449 |
1/1✓ Branch 3 taken 13 times.
|
13 | return getImpl<detail::AirToAirComponent_Impl>()->primaryAirOutletPort(); |
| 450 | } | ||
| 451 | |||
| 452 | 13 | unsigned AirToAirComponent::secondaryAirInletPort() const { | |
| 453 |
1/1✓ Branch 3 taken 13 times.
|
13 | return getImpl<detail::AirToAirComponent_Impl>()->secondaryAirInletPort(); |
| 454 | } | ||
| 455 | |||
| 456 | 13 | unsigned AirToAirComponent::secondaryAirOutletPort() const { | |
| 457 |
1/1✓ Branch 3 taken 13 times.
|
13 | return getImpl<detail::AirToAirComponent_Impl>()->secondaryAirOutletPort(); |
| 458 | } | ||
| 459 | |||
| 460 | 610 | OptionalModelObject AirToAirComponent::primaryAirInletModelObject() const { | |
| 461 |
1/1✓ Branch 3 taken 610 times.
|
610 | return getImpl<detail::AirToAirComponent_Impl>()->primaryAirInletModelObject(); |
| 462 | } | ||
| 463 | |||
| 464 | 15 | OptionalModelObject AirToAirComponent::primaryAirOutletModelObject() const { | |
| 465 |
1/1✓ Branch 3 taken 15 times.
|
15 | return getImpl<detail::AirToAirComponent_Impl>()->primaryAirOutletModelObject(); |
| 466 | } | ||
| 467 | |||
| 468 | 18 | OptionalModelObject AirToAirComponent::secondaryAirInletModelObject() const { | |
| 469 |
1/1✓ Branch 3 taken 18 times.
|
18 | return getImpl<detail::AirToAirComponent_Impl>()->secondaryAirInletModelObject(); |
| 470 | } | ||
| 471 | |||
| 472 | 566 | OptionalModelObject AirToAirComponent::secondaryAirOutletModelObject() const { | |
| 473 |
1/1✓ Branch 3 taken 566 times.
|
566 | return getImpl<detail::AirToAirComponent_Impl>()->secondaryAirOutletModelObject(); |
| 474 | } | ||
| 475 | |||
| 476 | 13 | std::vector<IdfObject> AirToAirComponent::remove() { | |
| 477 |
1/1✓ Branch 3 taken 13 times.
|
13 | return getImpl<detail::AirToAirComponent_Impl>()->remove(); |
| 478 | } | ||
| 479 | |||
| 480 | 35 | bool AirToAirComponent::addToNode(Node& node) { | |
| 481 |
1/1✓ Branch 3 taken 35 times.
|
35 | return getImpl<detail::AirToAirComponent_Impl>()->addToNode(node); |
| 482 | } | ||
| 483 | |||
| 484 | 5 | ModelObject AirToAirComponent::clone(Model model) const { | |
| 485 |
2/2✓ Branch 3 taken 5 times.
✓ Branch 6 taken 5 times.
|
5 | return getImpl<detail::AirToAirComponent_Impl>()->clone(model); |
| 486 | } | ||
| 487 | |||
| 488 | } // namespace model | ||
| 489 | |||
| 490 | } // namespace openstudio | ||
| 491 |