src/model/WaterToWaterComponent.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 "WaterToWaterComponent.hpp" | ||
| 7 | #include "WaterToWaterComponent_Impl.hpp" | ||
| 8 | #include "AirLoopHVAC.hpp" | ||
| 9 | #include "AirLoopHVAC_Impl.hpp" | ||
| 10 | #include "PlantLoop.hpp" | ||
| 11 | #include "PlantLoop_Impl.hpp" | ||
| 12 | #include "Node.hpp" | ||
| 13 | #include "Node_Impl.hpp" | ||
| 14 | #include "AirLoopHVACOutdoorAirSystem.hpp" | ||
| 15 | #include "AirLoopHVACOutdoorAirSystem_Impl.hpp" | ||
| 16 | #include "Model.hpp" | ||
| 17 | #include "Model_Impl.hpp" | ||
| 18 | #include "Splitter.hpp" | ||
| 19 | #include "Splitter_Impl.hpp" | ||
| 20 | #include "Mixer.hpp" | ||
| 21 | #include "Mixer_Impl.hpp" | ||
| 22 | #include "../utilities/core/Assert.hpp" | ||
| 23 | |||
| 24 | namespace openstudio { | ||
| 25 | |||
| 26 | namespace model { | ||
| 27 | |||
| 28 | namespace detail { | ||
| 29 | |||
| 30 | ✗ | WaterToWaterComponent_Impl::WaterToWaterComponent_Impl(IddObjectType type, Model_Impl* model) : HVACComponent_Impl(type, model) {} | |
| 31 | |||
| 32 | 219 | WaterToWaterComponent_Impl::WaterToWaterComponent_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 33 | 219 | : HVACComponent_Impl(idfObject, model, keepHandle) {} | |
| 34 | |||
| 35 | 29 | WaterToWaterComponent_Impl::WaterToWaterComponent_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) | |
| 36 | 29 | : HVACComponent_Impl(other, model, keepHandle) {} | |
| 37 | |||
| 38 | 138 | WaterToWaterComponent_Impl::WaterToWaterComponent_Impl(const WaterToWaterComponent_Impl& other, Model_Impl* model, bool keepHandles) | |
| 39 | 138 | : HVACComponent_Impl(other, model, keepHandles) {} | |
| 40 | |||
| 41 | 2377 | OptionalModelObject WaterToWaterComponent_Impl::supplyInletModelObject() const { | |
| 42 | 2377 | return connectedObject(supplyInletPort()); | |
| 43 | } | ||
| 44 | |||
| 45 | 1760 | OptionalModelObject WaterToWaterComponent_Impl::supplyOutletModelObject() const { | |
| 46 | 1760 | return connectedObject(supplyOutletPort()); | |
| 47 | } | ||
| 48 | |||
| 49 | 899 | OptionalModelObject WaterToWaterComponent_Impl::demandInletModelObject() const { | |
| 50 | 899 | return connectedObject(demandInletPort()); | |
| 51 | } | ||
| 52 | |||
| 53 | 1069 | OptionalModelObject WaterToWaterComponent_Impl::demandOutletModelObject() const { | |
| 54 | 1069 | return connectedObject(demandOutletPort()); | |
| 55 | } | ||
| 56 | |||
| 57 | 2223 | std::vector<HVACComponent> WaterToWaterComponent_Impl::edges(const boost::optional<HVACComponent>& prev) { | |
| 58 | 2223 | std::vector<HVACComponent> edges; | |
| 59 | |||
| 60 | 1491 | auto pushSupplyOutletModelObject = [&]() { | |
| 61 |
3/3✓ Branch 1 taken 1491 times.
✓ Branch 3 taken 1489 times.
✓ Branch 4 taken 2 times.
|
2982 | if (auto edgeModelObject = supplyOutletModelObject()) { |
| 62 |
2/2✓ Branch 1 taken 1489 times.
✓ Branch 4 taken 1489 times.
|
1489 | auto edgeHVACComponent = edgeModelObject->optionalCast<HVACComponent>(); |
| 63 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 1489 times.
✗ Branch 4 not taken.
|
1489 | OS_ASSERT(edgeHVACComponent); |
| 64 |
2/2✓ Branch 1 taken 1489 times.
✓ Branch 4 taken 1489 times.
|
1489 | edges.push_back(edgeHVACComponent.get()); |
| 65 | 2980 | } | |
| 66 | 1491 | }; | |
| 67 | |||
| 68 | 632 | auto pushDemandOutletModelObject = [&]() { | |
| 69 |
3/3✓ Branch 1 taken 632 times.
✓ Branch 3 taken 594 times.
✓ Branch 4 taken 38 times.
|
1264 | if (auto edgeModelObject = demandOutletModelObject()) { |
| 70 |
2/2✓ Branch 1 taken 594 times.
✓ Branch 4 taken 594 times.
|
594 | auto edgeHVACComponent = edgeModelObject->optionalCast<HVACComponent>(); |
| 71 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 594 times.
✗ Branch 4 not taken.
|
594 | OS_ASSERT(edgeHVACComponent); |
| 72 |
2/2✓ Branch 1 taken 594 times.
✓ Branch 4 taken 594 times.
|
594 | edges.push_back(edgeHVACComponent.get()); |
| 73 | 1226 | } | |
| 74 | 632 | }; | |
| 75 | |||
| 76 | 194 | auto pushTertiaryOutletModelObject = [&]() { | |
| 77 |
3/3✓ Branch 1 taken 194 times.
✓ Branch 3 taken 137 times.
✓ Branch 4 taken 57 times.
|
388 | if (auto edgeModelObject = tertiaryOutletModelObject()) { |
| 78 |
2/2✓ Branch 1 taken 137 times.
✓ Branch 4 taken 137 times.
|
137 | auto edgeHVACComponent = edgeModelObject->optionalCast<HVACComponent>(); |
| 79 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 137 times.
✗ Branch 4 not taken.
|
137 | OS_ASSERT(edgeHVACComponent); |
| 80 |
2/2✓ Branch 1 taken 137 times.
✓ Branch 4 taken 137 times.
|
137 | edges.push_back(edgeHVACComponent.get()); |
| 81 | 331 | } | |
| 82 | 2417 | }; | |
| 83 | |||
| 84 |
2/2✓ Branch 0 taken 2158 times.
✓ Branch 1 taken 65 times.
|
2223 | if (prev) { |
| 85 |
3/3✓ Branch 1 taken 2158 times.
✓ Branch 3 taken 2093 times.
✓ Branch 4 taken 65 times.
|
4316 | if (auto inletModelObject = supplyInletModelObject()) { |
| 86 |
5/5✓ Branch 1 taken 2093 times.
✓ Branch 4 taken 2093 times.
✓ Branch 7 taken 2093 times.
✓ Branch 9 taken 1426 times.
✓ Branch 10 taken 667 times.
|
2093 | if (prev.get() == inletModelObject.get()) { |
| 87 |
1/1✓ Branch 1 taken 1426 times.
|
1426 | pushSupplyOutletModelObject(); |
| 88 | 1426 | return edges; | |
| 89 | } | ||
| 90 | 2158 | } | |
| 91 |
3/3✓ Branch 1 taken 732 times.
✓ Branch 3 taken 710 times.
✓ Branch 4 taken 22 times.
|
1464 | if (auto inletModelObject = demandInletModelObject()) { |
| 92 |
5/5✓ Branch 1 taken 710 times.
✓ Branch 4 taken 710 times.
✓ Branch 7 taken 710 times.
✓ Branch 9 taken 567 times.
✓ Branch 10 taken 143 times.
|
710 | if (prev.get() == inletModelObject.get()) { |
| 93 |
1/1✓ Branch 1 taken 567 times.
|
567 | pushDemandOutletModelObject(); |
| 94 | 567 | return edges; | |
| 95 | } | ||
| 96 | 732 | } | |
| 97 |
3/3✓ Branch 1 taken 165 times.
✓ Branch 3 taken 129 times.
✓ Branch 4 taken 36 times.
|
330 | if (auto inletModelObject = tertiaryInletModelObject()) { |
| 98 |
4/5✓ Branch 1 taken 129 times.
✓ Branch 4 taken 129 times.
✓ Branch 7 taken 129 times.
✓ Branch 9 taken 129 times.
✗ Branch 10 not taken.
|
129 | if (prev.get() == inletModelObject.get()) { |
| 99 |
1/1✓ Branch 1 taken 129 times.
|
129 | pushTertiaryOutletModelObject(); |
| 100 | 129 | return edges; | |
| 101 | } | ||
| 102 | 165 | } | |
| 103 | } else { | ||
| 104 |
1/1✓ Branch 1 taken 65 times.
|
65 | pushSupplyOutletModelObject(); |
| 105 |
1/1✓ Branch 1 taken 65 times.
|
65 | pushDemandOutletModelObject(); |
| 106 |
1/1✓ Branch 1 taken 65 times.
|
65 | pushTertiaryOutletModelObject(); |
| 107 | 65 | return edges; | |
| 108 | } | ||
| 109 | |||
| 110 | 36 | return edges; | |
| 111 | ✗ | } | |
| 112 | |||
| 113 | 17 | std::vector<openstudio::IdfObject> WaterToWaterComponent_Impl::remove() { | |
| 114 | 17 | removeFromPlantLoop(); | |
| 115 | |||
| 116 | 17 | removeFromSecondaryPlantLoop(); | |
| 117 | |||
| 118 | 17 | removeFromTertiaryPlantLoop(); | |
| 119 | |||
| 120 | 17 | return HVACComponent_Impl::remove(); | |
| 121 | } | ||
| 122 | |||
| 123 | 14 | boost::optional<ParentObject> WaterToWaterComponent_Impl::parent() const { | |
| 124 | 14 | return {}; | |
| 125 | } | ||
| 126 | |||
| 127 | 28 | std::vector<ModelObject> WaterToWaterComponent_Impl::children() const { | |
| 128 | 28 | std::vector<ModelObject> result; | |
| 129 | |||
| 130 | 28 | return result; | |
| 131 | } | ||
| 132 | |||
| 133 | ✗ | void WaterToWaterComponent_Impl::disconnect() { | |
| 134 | ✗ | auto mo = this->getObject<ModelObject>(); | |
| 135 | ✗ | this->model().disconnect(mo, this->supplyInletPort()); | |
| 136 | ✗ | this->model().disconnect(mo, this->supplyOutletPort()); | |
| 137 | ✗ | this->model().disconnect(mo, this->demandInletPort()); | |
| 138 | ✗ | this->model().disconnect(mo, this->demandOutletPort()); | |
| 139 | ✗ | this->model().disconnect(mo, this->tertiaryInletPort()); | |
| 140 | ✗ | this->model().disconnect(mo, this->tertiaryOutletPort()); | |
| 141 | ✗ | } | |
| 142 | |||
| 143 | 156 | bool WaterToWaterComponent_Impl::addToNode(Node& node) { | |
| 144 |
1/1✓ Branch 1 taken 156 times.
|
156 | auto _model = node.model(); |
| 145 |
1/1✓ Branch 1 taken 156 times.
|
156 | auto thisModelObject = getObject<ModelObject>(); |
| 146 |
1/1✓ Branch 1 taken 156 times.
|
156 | auto t_plantLoop = node.plantLoop(); |
| 147 | |||
| 148 | 156 | boost::optional<unsigned> componentInletPort; | |
| 149 | 156 | boost::optional<unsigned> componentOutletPort; | |
| 150 | |||
| 151 | 156 | boost::optional<HVACComponent> systemStartComponent; | |
| 152 | 156 | boost::optional<HVACComponent> systemEndComponent; | |
| 153 | |||
| 154 |
2/3✓ Branch 3 taken 156 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 156 times.
|
156 | if (node.getImpl<Node_Impl>()->isConnected(thisModelObject)) { |
| 155 | ✗ | return false; | |
| 156 | } | ||
| 157 | |||
| 158 |
2/2✓ Branch 0 taken 154 times.
✓ Branch 1 taken 2 times.
|
156 | if (t_plantLoop) { |
| 159 |
5/5✓ Branch 1 taken 154 times.
✓ Branch 4 taken 154 times.
✓ Branch 7 taken 154 times.
✓ Branch 10 taken 94 times.
✓ Branch 11 taken 60 times.
|
308 | if (t_plantLoop->supplyComponent(node.handle())) { |
| 160 | |||
| 161 |
3/3✓ Branch 1 taken 94 times.
✓ Branch 4 taken 94 times.
✓ Branch 7 taken 94 times.
|
94 | systemStartComponent = t_plantLoop->supplyInletNode(); |
| 162 |
3/3✓ Branch 1 taken 94 times.
✓ Branch 4 taken 94 times.
✓ Branch 7 taken 94 times.
|
94 | systemEndComponent = t_plantLoop->supplyOutletNode(); |
| 163 |
2/2✓ Branch 1 taken 94 times.
✓ Branch 4 taken 94 times.
|
94 | componentInletPort = supplyInletPort(); |
| 164 |
2/2✓ Branch 1 taken 94 times.
✓ Branch 4 taken 94 times.
|
94 | componentOutletPort = supplyOutletPort(); |
| 165 | |||
| 166 |
1/1✓ Branch 1 taken 94 times.
|
94 | removeFromPlantLoop(); |
| 167 |
4/5✓ Branch 1 taken 60 times.
✓ Branch 4 taken 60 times.
✓ Branch 7 taken 60 times.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
|
120 | } else if (t_plantLoop->demandComponent(node.handle())) { |
| 168 | |||
| 169 |
3/3✓ Branch 1 taken 60 times.
✓ Branch 4 taken 60 times.
✓ Branch 7 taken 60 times.
|
60 | systemStartComponent = t_plantLoop->demandInletNode(); |
| 170 |
3/3✓ Branch 1 taken 60 times.
✓ Branch 4 taken 60 times.
✓ Branch 7 taken 60 times.
|
60 | systemEndComponent = t_plantLoop->demandOutletNode(); |
| 171 |
2/2✓ Branch 1 taken 60 times.
✓ Branch 4 taken 60 times.
|
60 | componentInletPort = demandInletPort(); |
| 172 |
2/2✓ Branch 1 taken 60 times.
✓ Branch 4 taken 60 times.
|
60 | componentOutletPort = demandOutletPort(); |
| 173 | |||
| 174 |
1/1✓ Branch 1 taken 60 times.
|
60 | removeFromSecondaryPlantLoop(); |
| 175 | } | ||
| 176 | } | ||
| 177 | |||
| 178 |
7/10✓ Branch 0 taken 154 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 154 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 154 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 154 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 154 times.
✓ Branch 9 taken 2 times.
|
618 | if (systemStartComponent && systemEndComponent && componentOutletPort && componentInletPort) { |
| 179 |
3/3✓ Branch 1 taken 154 times.
✓ Branch 4 taken 154 times.
✓ Branch 7 taken 154 times.
|
154 | return HVACComponent_Impl::addToNode(node, systemStartComponent.get(), systemEndComponent.get(), componentInletPort.get(), |
| 180 |
2/2✓ Branch 1 taken 154 times.
✓ Branch 4 taken 154 times.
|
308 | componentOutletPort.get()); |
| 181 | } else { | ||
| 182 | 2 | return false; | |
| 183 | } | ||
| 184 | 156 | } | |
| 185 | |||
| 186 | 14 | ModelObject WaterToWaterComponent_Impl::clone(Model model) const { | |
| 187 |
3/3✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
✓ Branch 7 taken 14 times.
|
14 | auto mo = HVACComponent_Impl::clone(model).cast<WaterToWaterComponent>(); |
| 188 | |||
| 189 |
3/3✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
✓ Branch 7 taken 14 times.
|
28 | mo.setString(mo.supplyInletPort(), ""); |
| 190 |
3/3✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
✓ Branch 7 taken 14 times.
|
28 | mo.setString(mo.supplyOutletPort(), ""); |
| 191 |
3/3✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
✓ Branch 7 taken 14 times.
|
28 | mo.setString(mo.demandInletPort(), ""); |
| 192 |
3/3✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
✓ Branch 7 taken 14 times.
|
28 | mo.setString(mo.demandOutletPort(), ""); |
| 193 |
3/3✓ Branch 1 taken 14 times.
✓ Branch 6 taken 14 times.
✓ Branch 9 taken 14 times.
|
28 | mo.setString(mo.getImpl<detail::WaterToWaterComponent_Impl>()->tertiaryInletPort(), ""); |
| 194 |
3/3✓ Branch 1 taken 14 times.
✓ Branch 6 taken 14 times.
✓ Branch 9 taken 14 times.
|
14 | mo.setString(mo.getImpl<detail::WaterToWaterComponent_Impl>()->tertiaryOutletPort(), ""); |
| 195 | |||
| 196 | 28 | return std::move(mo); | |
| 197 | 14 | } | |
| 198 | |||
| 199 | 210 | boost::optional<PlantLoop> WaterToWaterComponent_Impl::plantLoop() const { | |
| 200 |
2/2✓ Branch 1 taken 72 times.
✓ Branch 2 taken 138 times.
|
420 | if (m_plantLoop) { |
| 201 | 72 | return m_plantLoop; | |
| 202 | } else { | ||
| 203 | // Note: checking for supply side only isn't sufficient for CentralHeatPumpSystem | ||
| 204 | // because it is on the supply side of two plant loops: the heating and the cooling plant loop | ||
| 205 | // We rely on tertiaryPlantLoop() method which checks for actual node connections | ||
| 206 |
1/1✓ Branch 1 taken 138 times.
|
138 | boost::optional<PlantLoop> tertiaryPlantLoop = this->tertiaryPlantLoop(); |
| 207 | |||
| 208 |
2/2✓ Branch 1 taken 138 times.
✓ Branch 4 taken 138 times.
|
138 | std::vector<PlantLoop> plantLoops = this->model().getConcreteModelObjects<PlantLoop>(); |
| 209 | |||
| 210 |
2/2✓ Branch 5 taken 327 times.
✓ Branch 6 taken 80 times.
|
407 | for (const auto& elem : plantLoops) { |
| 211 |
1/1✓ Branch 1 taken 327 times.
|
327 | OptionalPlantLoop plantLoop = elem.optionalCast<PlantLoop>(); |
| 212 |
1/2✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
|
327 | if (plantLoop) { |
| 213 | // Check that the component is on the supply side of the PlantLoop | ||
| 214 |
5/5✓ Branch 1 taken 327 times.
✓ Branch 4 taken 327 times.
✓ Branch 7 taken 327 times.
✓ Branch 10 taken 62 times.
✓ Branch 11 taken 265 times.
|
654 | if (plantLoop->supplyComponent(this->handle())) { |
| 215 | // Skip the tertiary one | ||
| 216 |
2/2✓ Branch 0 taken 32 times.
✓ Branch 1 taken 30 times.
|
62 | if (tertiaryPlantLoop) { |
| 217 |
7/7✓ 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.
✓ Branch 15 taken 4 times.
✓ Branch 16 taken 28 times.
|
32 | if (plantLoop->handle() == tertiaryPlantLoop->handle()) { |
| 218 | 4 | continue; | |
| 219 | } | ||
| 220 | } | ||
| 221 | |||
| 222 |
1/1✓ Branch 1 taken 58 times.
|
58 | m_plantLoop = plantLoop; |
| 223 | |||
| 224 | 58 | return plantLoop; | |
| 225 | } | ||
| 226 | } | ||
| 227 | 327 | } | |
| 228 | 196 | } | |
| 229 | |||
| 230 | 80 | return boost::none; | |
| 231 | } | ||
| 232 | |||
| 233 | 636 | boost::optional<PlantLoop> WaterToWaterComponent_Impl::secondaryPlantLoop() const { | |
| 234 |
2/2✓ Branch 1 taken 128 times.
✓ Branch 2 taken 508 times.
|
1272 | if (m_secondaryPlantLoop) { |
| 235 | 128 | return m_secondaryPlantLoop; | |
| 236 | } else { | ||
| 237 | // JM: Same comment as for plantLoop() above | ||
| 238 | // Any WaterToWaterComponent that has an Heat Recovery loop could be on the demand side of two plant loops | ||
| 239 |
1/1✓ Branch 1 taken 508 times.
|
508 | boost::optional<PlantLoop> tertiaryPlantLoop = this->tertiaryPlantLoop(); |
| 240 | |||
| 241 |
2/2✓ Branch 1 taken 508 times.
✓ Branch 4 taken 508 times.
|
508 | std::vector<PlantLoop> plantLoops = this->model().getConcreteModelObjects<PlantLoop>(); |
| 242 | |||
| 243 |
2/2✓ Branch 5 taken 863 times.
✓ Branch 6 taken 425 times.
|
1288 | for (const auto& elem : plantLoops) { |
| 244 |
1/1✓ Branch 1 taken 863 times.
|
863 | OptionalPlantLoop plantLoop = elem.optionalCast<PlantLoop>(); |
| 245 |
1/2✓ Branch 0 taken 863 times.
✗ Branch 1 not taken.
|
863 | if (plantLoop) { |
| 246 |
5/5✓ Branch 1 taken 863 times.
✓ Branch 4 taken 863 times.
✓ Branch 7 taken 863 times.
✓ Branch 10 taken 107 times.
✓ Branch 11 taken 756 times.
|
1726 | if (plantLoop->demandComponent(this->handle())) { |
| 247 | |||
| 248 | // Skip the tertiary one | ||
| 249 |
2/2✓ Branch 0 taken 52 times.
✓ Branch 1 taken 55 times.
|
107 | if (tertiaryPlantLoop) { |
| 250 |
7/7✓ Branch 1 taken 52 times.
✓ Branch 4 taken 52 times.
✓ Branch 7 taken 52 times.
✓ Branch 10 taken 52 times.
✓ Branch 13 taken 52 times.
✓ Branch 15 taken 24 times.
✓ Branch 16 taken 28 times.
|
52 | if (plantLoop->handle() == tertiaryPlantLoop->handle()) { |
| 251 | 24 | continue; | |
| 252 | } | ||
| 253 | } | ||
| 254 | |||
| 255 |
1/1✓ Branch 1 taken 83 times.
|
83 | m_secondaryPlantLoop = plantLoop; |
| 256 | |||
| 257 | 83 | return plantLoop; | |
| 258 | } | ||
| 259 | } | ||
| 260 | 863 | } | |
| 261 | 591 | } | |
| 262 | |||
| 263 | 425 | return boost::none; | |
| 264 | } | ||
| 265 | |||
| 266 | 116 | bool WaterToWaterComponent_Impl::removeFromPlantLoop() { | |
| 267 |
3/3✓ Branch 1 taken 116 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 109 times.
|
232 | if (auto plant = plantLoop()) { |
| 268 |
7/7✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
✓ Branch 10 taken 7 times.
✓ Branch 13 taken 7 times.
✓ Branch 16 taken 7 times.
✓ Branch 19 taken 7 times.
|
7 | return HVACComponent_Impl::removeFromLoop(plant->supplyInletNode(), plant->supplyOutletNode(), supplyInletPort(), supplyOutletPort()); |
| 269 | 116 | } | |
| 270 | |||
| 271 | 109 | return false; | |
| 272 | } | ||
| 273 | |||
| 274 | 79 | bool WaterToWaterComponent_Impl::removeFromSecondaryPlantLoop() { | |
| 275 |
3/3✓ Branch 1 taken 79 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 61 times.
|
158 | if (auto plant = secondaryPlantLoop()) { |
| 276 |
7/7✓ 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.
|
18 | return HVACComponent_Impl::removeFromLoop(plant->demandInletNode(), plant->demandOutletNode(), demandInletPort(), demandOutletPort()); |
| 277 | 79 | } | |
| 278 | |||
| 279 | 61 | return false; | |
| 280 | } | ||
| 281 | |||
| 282 | 9 | unsigned WaterToWaterComponent_Impl::tertiaryInletPort() const { | |
| 283 | 9 | return std::numeric_limits<unsigned>::max(); | |
| 284 | } | ||
| 285 | |||
| 286 | 318 | unsigned WaterToWaterComponent_Impl::tertiaryOutletPort() const { | |
| 287 | 318 | return std::numeric_limits<unsigned>::max(); | |
| 288 | } | ||
| 289 | |||
| 290 | 864 | boost::optional<PlantLoop> WaterToWaterComponent_Impl::tertiaryPlantLoop() const { | |
| 291 |
2/2✓ Branch 1 taken 126 times.
✓ Branch 2 taken 738 times.
|
1728 | if (m_tertiaryPlantLoop) { |
| 292 | 126 | return m_tertiaryPlantLoop; | |
| 293 | } else { | ||
| 294 | 738 | boost::optional<HVACComponent> tertiaryOutletHVACComponent; | |
| 295 | |||
| 296 |
3/3✓ Branch 1 taken 738 times.
✓ Branch 3 taken 38 times.
✓ Branch 4 taken 700 times.
|
1476 | if (auto t_tertiaryOutletModelObject = tertiaryOutletModelObject()) { |
| 297 |
2/2✓ Branch 1 taken 38 times.
✓ Branch 4 taken 38 times.
|
38 | tertiaryOutletHVACComponent = t_tertiaryOutletModelObject->optionalCast<HVACComponent>(); |
| 298 | 738 | } | |
| 299 | |||
| 300 |
2/2✓ Branch 0 taken 38 times.
✓ Branch 1 taken 700 times.
|
738 | if (tertiaryOutletHVACComponent) { |
| 301 |
2/2✓ Branch 1 taken 38 times.
✓ Branch 4 taken 38 times.
|
38 | auto plantLoops = this->model().getConcreteModelObjects<PlantLoop>(); |
| 302 | |||
| 303 | // WaterToWaterComponent instances can be connected to tertiary plants | ||
| 304 | // from the demand or supply side so check for both possibilities | ||
| 305 |
2/2✓ Branch 5 taken 125 times.
✓ Branch 6 taken 30 times.
|
155 | for (const auto& plantLoop : plantLoops) { |
| 306 |
7/7✓ Branch 1 taken 125 times.
✓ Branch 4 taken 125 times.
✓ Branch 7 taken 125 times.
✓ Branch 10 taken 125 times.
✓ Branch 13 taken 125 times.
✓ Branch 19 taken 8 times.
✓ Branch 20 taken 117 times.
|
375 | if (!plantLoop.supplyComponents(plantLoop.supplyInletNode(), tertiaryOutletHVACComponent.get()).empty()) { |
| 307 |
1/1✓ Branch 1 taken 8 times.
|
8 | m_tertiaryPlantLoop = plantLoop; |
| 308 |
1/1✓ Branch 1 taken 8 times.
|
8 | return plantLoop; |
| 309 | } | ||
| 310 | } | ||
| 311 | |||
| 312 |
1/2✓ Branch 5 taken 34 times.
✗ Branch 6 not taken.
|
34 | for (const auto& plantLoop : plantLoops) { |
| 313 |
7/7✓ Branch 1 taken 34 times.
✓ Branch 4 taken 34 times.
✓ Branch 7 taken 34 times.
✓ Branch 10 taken 34 times.
✓ Branch 13 taken 34 times.
✓ Branch 19 taken 30 times.
✓ Branch 20 taken 4 times.
|
102 | if (!plantLoop.demandComponents(plantLoop.demandInletNode(), tertiaryOutletHVACComponent.get()).empty()) { |
| 314 |
1/1✓ Branch 1 taken 30 times.
|
30 | m_tertiaryPlantLoop = plantLoop; |
| 315 |
1/1✓ Branch 1 taken 30 times.
|
30 | return plantLoop; |
| 316 | } | ||
| 317 | } | ||
| 318 | 38 | } | |
| 319 | 738 | } | |
| 320 | |||
| 321 | 700 | return boost::none; | |
| 322 | } | ||
| 323 | |||
| 324 | 55 | bool WaterToWaterComponent_Impl::removeFromTertiaryPlantLoop() { | |
| 325 |
3/3✓ Branch 1 taken 55 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 43 times.
|
110 | if (auto plant = tertiaryPlantLoop()) { |
| 326 |
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 | return HVACComponent_Impl::removeFromLoop(plant->demandInletNode(), plant->demandOutletNode(), tertiaryInletPort(), tertiaryOutletPort()); |
| 327 | 55 | } | |
| 328 | |||
| 329 | 43 | return false; | |
| 330 | } | ||
| 331 | |||
| 332 | 26 | bool WaterToWaterComponent_Impl::addToTertiaryNode(Node& node) { | |
| 333 |
1/1✓ Branch 1 taken 26 times.
|
26 | auto _model = node.model(); |
| 334 |
1/1✓ Branch 1 taken 26 times.
|
26 | auto thisModelObject = getObject<ModelObject>(); |
| 335 |
1/1✓ Branch 1 taken 26 times.
|
26 | auto t_plantLoop = node.plantLoop(); |
| 336 | |||
| 337 |
2/2✓ Branch 1 taken 26 times.
✓ Branch 4 taken 26 times.
|
26 | boost::optional<unsigned> componentInletPort = tertiaryInletPort(); |
| 338 |
2/2✓ Branch 1 taken 26 times.
✓ Branch 4 taken 26 times.
|
26 | boost::optional<unsigned> componentOutletPort = tertiaryOutletPort(); |
| 339 | |||
| 340 | 26 | boost::optional<HVACComponent> systemStartComponent; | |
| 341 | 26 | boost::optional<HVACComponent> systemEndComponent; | |
| 342 | |||
| 343 |
2/3✓ Branch 3 taken 26 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 26 times.
|
26 | if (node.getImpl<Node_Impl>()->isConnected(thisModelObject)) { |
| 344 | ✗ | return false; | |
| 345 | } | ||
| 346 | |||
| 347 |
1/2✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
|
26 | if (t_plantLoop) { |
| 348 |
5/5✓ Branch 1 taken 26 times.
✓ Branch 4 taken 26 times.
✓ Branch 7 taken 26 times.
✓ Branch 10 taken 7 times.
✓ Branch 11 taken 19 times.
|
52 | if (t_plantLoop->supplyComponent(node.handle())) { |
| 349 | |||
| 350 |
3/3✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
|
7 | systemStartComponent = t_plantLoop->supplyInletNode(); |
| 351 |
3/3✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
|
7 | systemEndComponent = t_plantLoop->supplyOutletNode(); |
| 352 | |||
| 353 |
1/1✓ Branch 1 taken 7 times.
|
7 | removeFromTertiaryPlantLoop(); |
| 354 |
4/5✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
✓ Branch 7 taken 19 times.
✓ Branch 10 taken 19 times.
✗ Branch 11 not taken.
|
38 | } else if (t_plantLoop->demandComponent(node.handle())) { |
| 355 | |||
| 356 |
3/3✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
✓ Branch 7 taken 19 times.
|
19 | systemStartComponent = t_plantLoop->demandInletNode(); |
| 357 |
3/3✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
✓ Branch 7 taken 19 times.
|
19 | systemEndComponent = t_plantLoop->demandOutletNode(); |
| 358 | |||
| 359 |
1/1✓ Branch 1 taken 19 times.
|
19 | removeFromTertiaryPlantLoop(); |
| 360 | } | ||
| 361 | } | ||
| 362 | |||
| 363 |
5/10✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 26 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 26 times.
✗ Branch 9 not taken.
|
104 | if (systemStartComponent && systemEndComponent && componentOutletPort && componentInletPort) { |
| 364 |
3/3✓ Branch 1 taken 26 times.
✓ Branch 4 taken 26 times.
✓ Branch 7 taken 26 times.
|
26 | return HVACComponent_Impl::addToNode(node, systemStartComponent.get(), systemEndComponent.get(), componentInletPort.get(), |
| 365 |
2/2✓ Branch 1 taken 26 times.
✓ Branch 4 taken 26 times.
|
52 | componentOutletPort.get()); |
| 366 | } else { | ||
| 367 | ✗ | return false; | |
| 368 | } | ||
| 369 | 26 | } | |
| 370 | |||
| 371 | 209 | boost::optional<ModelObject> WaterToWaterComponent_Impl::tertiaryInletModelObject() const { | |
| 372 | 209 | return connectedObject(tertiaryInletPort()); | |
| 373 | } | ||
| 374 | |||
| 375 | 985 | boost::optional<ModelObject> WaterToWaterComponent_Impl::tertiaryOutletModelObject() const { | |
| 376 | 985 | return connectedObject(tertiaryOutletPort()); | |
| 377 | } | ||
| 378 | |||
| 379 | } // namespace detail | ||
| 380 | |||
| 381 | 190 | WaterToWaterComponent::WaterToWaterComponent(IddObjectType type, const Model& model) : HVACComponent(type, model) { | |
| 382 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 190 times.
✗ Branch 5 not taken.
|
190 | OS_ASSERT(getImpl<detail::WaterToWaterComponent_Impl>()); |
| 383 | 190 | } | |
| 384 | |||
| 385 |
1/1✓ Branch 3 taken 1377 times.
|
1377 | WaterToWaterComponent::WaterToWaterComponent(std::shared_ptr<detail::WaterToWaterComponent_Impl> p) : HVACComponent(std::move(p)) {} |
| 386 | |||
| 387 | 14 | unsigned WaterToWaterComponent::supplyInletPort() const { | |
| 388 |
1/1✓ Branch 3 taken 14 times.
|
14 | return getImpl<detail::WaterToWaterComponent_Impl>()->supplyInletPort(); |
| 389 | } | ||
| 390 | |||
| 391 | 14 | unsigned WaterToWaterComponent::supplyOutletPort() const { | |
| 392 |
1/1✓ Branch 3 taken 14 times.
|
14 | return getImpl<detail::WaterToWaterComponent_Impl>()->supplyOutletPort(); |
| 393 | } | ||
| 394 | |||
| 395 | 180 | OptionalModelObject WaterToWaterComponent::supplyInletModelObject() const { | |
| 396 |
1/1✓ Branch 3 taken 180 times.
|
180 | return getImpl<detail::WaterToWaterComponent_Impl>()->supplyInletModelObject(); |
| 397 | } | ||
| 398 | |||
| 399 | 206 | OptionalModelObject WaterToWaterComponent::supplyOutletModelObject() const { | |
| 400 |
1/1✓ Branch 3 taken 206 times.
|
206 | return getImpl<detail::WaterToWaterComponent_Impl>()->supplyOutletModelObject(); |
| 401 | } | ||
| 402 | |||
| 403 | 19 | unsigned WaterToWaterComponent::demandInletPort() const { | |
| 404 |
1/1✓ Branch 3 taken 19 times.
|
19 | return getImpl<detail::WaterToWaterComponent_Impl>()->demandInletPort(); |
| 405 | } | ||
| 406 | |||
| 407 | 19 | unsigned WaterToWaterComponent::demandOutletPort() const { | |
| 408 |
1/1✓ Branch 3 taken 19 times.
|
19 | return getImpl<detail::WaterToWaterComponent_Impl>()->demandOutletPort(); |
| 409 | } | ||
| 410 | |||
| 411 | 126 | OptionalModelObject WaterToWaterComponent::demandInletModelObject() const { | |
| 412 |
1/1✓ Branch 3 taken 126 times.
|
126 | return getImpl<detail::WaterToWaterComponent_Impl>()->demandInletModelObject(); |
| 413 | } | ||
| 414 | |||
| 415 | 139 | OptionalModelObject WaterToWaterComponent::demandOutletModelObject() const { | |
| 416 |
1/1✓ Branch 3 taken 139 times.
|
139 | return getImpl<detail::WaterToWaterComponent_Impl>()->demandOutletModelObject(); |
| 417 | } | ||
| 418 | |||
| 419 | 17 | std::vector<IdfObject> WaterToWaterComponent::remove() { | |
| 420 |
1/1✓ Branch 3 taken 17 times.
|
17 | return getImpl<detail::WaterToWaterComponent_Impl>()->remove(); |
| 421 | } | ||
| 422 | |||
| 423 | 105 | bool WaterToWaterComponent::addToNode(Node& node) { | |
| 424 |
1/1✓ Branch 3 taken 105 times.
|
105 | return getImpl<detail::WaterToWaterComponent_Impl>()->addToNode(node); |
| 425 | } | ||
| 426 | |||
| 427 | 14 | ModelObject WaterToWaterComponent::clone(Model model) const { | |
| 428 |
2/2✓ Branch 3 taken 14 times.
✓ Branch 6 taken 14 times.
|
14 | return getImpl<detail::WaterToWaterComponent_Impl>()->clone(model); |
| 429 | } | ||
| 430 | |||
| 431 | 118 | boost::optional<PlantLoop> WaterToWaterComponent::plantLoop() const { | |
| 432 |
1/1✓ Branch 3 taken 118 times.
|
118 | return getImpl<detail::WaterToWaterComponent_Impl>()->plantLoop(); |
| 433 | } | ||
| 434 | |||
| 435 | 29 | boost::optional<PlantLoop> WaterToWaterComponent::secondaryPlantLoop() const { | |
| 436 |
1/1✓ Branch 3 taken 29 times.
|
29 | return getImpl<detail::WaterToWaterComponent_Impl>()->secondaryPlantLoop(); |
| 437 | } | ||
| 438 | |||
| 439 | 5 | bool WaterToWaterComponent::removeFromPlantLoop() { | |
| 440 |
1/1✓ Branch 3 taken 5 times.
|
5 | return getImpl<detail::WaterToWaterComponent_Impl>()->removeFromPlantLoop(); |
| 441 | } | ||
| 442 | |||
| 443 | 8 | bool WaterToWaterComponent::removeFromSecondaryPlantLoop() { | |
| 444 |
1/1✓ Branch 3 taken 8 times.
|
8 | return getImpl<detail::WaterToWaterComponent_Impl>()->removeFromSecondaryPlantLoop(); |
| 445 | } | ||
| 446 | |||
| 447 | 13 | boost::optional<PlantLoop> WaterToWaterComponent::tertiaryPlantLoop() const { | |
| 448 |
1/1✓ Branch 3 taken 13 times.
|
13 | return getImpl<detail::WaterToWaterComponent_Impl>()->tertiaryPlantLoop(); |
| 449 | } | ||
| 450 | |||
| 451 | 12 | bool WaterToWaterComponent::removeFromTertiaryPlantLoop() { | |
| 452 |
1/1✓ Branch 3 taken 12 times.
|
12 | return getImpl<detail::WaterToWaterComponent_Impl>()->removeFromTertiaryPlantLoop(); |
| 453 | } | ||
| 454 | |||
| 455 | 16 | bool WaterToWaterComponent::addToTertiaryNode(Node& node) { | |
| 456 |
1/1✓ Branch 3 taken 16 times.
|
16 | return getImpl<detail::WaterToWaterComponent_Impl>()->addToTertiaryNode(node); |
| 457 | } | ||
| 458 | |||
| 459 | 28 | boost::optional<ModelObject> WaterToWaterComponent::tertiaryInletModelObject() const { | |
| 460 |
1/1✓ Branch 3 taken 28 times.
|
28 | return getImpl<detail::WaterToWaterComponent_Impl>()->tertiaryInletModelObject(); |
| 461 | } | ||
| 462 | |||
| 463 | 26 | boost::optional<ModelObject> WaterToWaterComponent::tertiaryOutletModelObject() const { | |
| 464 |
1/1✓ Branch 3 taken 26 times.
|
26 | return getImpl<detail::WaterToWaterComponent_Impl>()->tertiaryOutletModelObject(); |
| 465 | } | ||
| 466 | |||
| 467 | } // namespace model | ||
| 468 | |||
| 469 | } // namespace openstudio | ||
| 470 |