src/model/StraightComponent.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 "StraightComponent.hpp" | ||
| 7 | #include "StraightComponent_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 "AirflowNetworkEquivalentDuct.hpp" | ||
| 23 | #include "AirflowNetworkEquivalentDuct_Impl.hpp" | ||
| 24 | #include "../utilities/core/Assert.hpp" | ||
| 25 | |||
| 26 | namespace openstudio { | ||
| 27 | |||
| 28 | namespace model { | ||
| 29 | |||
| 30 | namespace detail { | ||
| 31 | |||
| 32 | ✗ | StraightComponent_Impl::StraightComponent_Impl(IddObjectType type, Model_Impl* model) : HVACComponent_Impl(type, model) {} | |
| 33 | |||
| 34 | 18472 | StraightComponent_Impl::StraightComponent_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 35 | 18472 | : HVACComponent_Impl(idfObject, model, keepHandle) {} | |
| 36 | |||
| 37 | 2350 | StraightComponent_Impl::StraightComponent_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) | |
| 38 | 2350 | : HVACComponent_Impl(other, model, keepHandle) {} | |
| 39 | |||
| 40 | 6729 | StraightComponent_Impl::StraightComponent_Impl(const StraightComponent_Impl& other, Model_Impl* model, bool keepHandles) | |
| 41 | 6729 | : HVACComponent_Impl(other, model, keepHandles) {} | |
| 42 | |||
| 43 | 16546 | OptionalModelObject StraightComponent_Impl::inletModelObject() const { | |
| 44 | 16546 | return connectedObject(inletPort()); | |
| 45 | } | ||
| 46 | |||
| 47 | 148420 | OptionalModelObject StraightComponent_Impl::outletModelObject() const { | |
| 48 | 148420 | return connectedObject(outletPort()); | |
| 49 | } | ||
| 50 | 1362 | bool StraightComponent_Impl::removeFromLoop() { | |
| 51 |
3/3✓ Branch 1 taken 1362 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 1358 times.
|
2724 | if (auto t_oaSystem = airLoopHVACOutdoorAirSystem()) { |
| 52 |
4/5✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
|
8 | if (t_oaSystem->oaComponent(handle())) { |
| 53 |
7/7✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 13 taken 4 times.
✓ Branch 16 taken 4 times.
✓ Branch 19 taken 4 times.
|
4 | return HVACComponent_Impl::removeFromLoop(t_oaSystem->outboardOANode().get(), t_oaSystem.get(), inletPort(), outletPort()); |
| 54 | ✗ | } else if (t_oaSystem->reliefComponent(handle())) { | |
| 55 | ✗ | return HVACComponent_Impl::removeFromLoop(t_oaSystem.get(), t_oaSystem->outboardReliefNode().get(), inletPort(), outletPort()); | |
| 56 | } | ||
| 57 |
3/3✓ Branch 1 taken 1358 times.
✓ Branch 3 taken 53 times.
✓ Branch 4 taken 1305 times.
|
2716 | } else if (auto t_loop = loop()) { |
| 58 |
5/5✓ Branch 1 taken 53 times.
✓ Branch 4 taken 53 times.
✓ Branch 7 taken 53 times.
✓ Branch 10 taken 44 times.
✓ Branch 11 taken 9 times.
|
106 | if (t_loop->supplyComponent(handle())) { |
| 59 |
7/7✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
✓ Branch 10 taken 44 times.
✓ Branch 13 taken 44 times.
✓ Branch 16 taken 44 times.
✓ Branch 19 taken 44 times.
|
44 | return HVACComponent_Impl::removeFromLoop(t_loop->supplyInletNode(), t_loop->supplyOutletNode(), inletPort(), outletPort()); |
| 60 |
4/5✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✓ Branch 10 taken 9 times.
✗ Branch 11 not taken.
|
18 | } else if (t_loop->demandComponent(handle())) { |
| 61 |
7/7✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✓ Branch 10 taken 9 times.
✓ Branch 13 taken 9 times.
✓ Branch 16 taken 9 times.
✓ Branch 19 taken 9 times.
|
9 | return HVACComponent_Impl::removeFromLoop(t_loop->demandInletNode(), t_loop->demandOutletNode(), inletPort(), outletPort()); |
| 62 | } | ||
| 63 | 2720 | } | |
| 64 | |||
| 65 | 1305 | return false; | |
| 66 | } | ||
| 67 | |||
| 68 | 187 | std::vector<openstudio::IdfObject> StraightComponent_Impl::remove() { | |
| 69 | 187 | removeFromLoop(); | |
| 70 | |||
| 71 | 187 | return HVACComponent_Impl::remove(); | |
| 72 | } | ||
| 73 | |||
| 74 | 307 | boost::optional<ParentObject> StraightComponent_Impl::parent() const { | |
| 75 | 307 | return {}; | |
| 76 | } | ||
| 77 | |||
| 78 | 368 | std::vector<ModelObject> StraightComponent_Impl::children() const { | |
| 79 | 368 | std::vector<ModelObject> result; | |
| 80 | 368 | return result; | |
| 81 | } | ||
| 82 | |||
| 83 | 9603 | OptionalAirLoopHVAC StraightComponent_Impl::airLoopHVAC() const { | |
| 84 | 9603 | return HVACComponent_Impl::airLoopHVAC(); | |
| 85 | } | ||
| 86 | |||
| 87 | 370 | void StraightComponent_Impl::disconnect() { | |
| 88 |
1/1✓ Branch 1 taken 370 times.
|
370 | auto mo = this->getObject<ModelObject>(); |
| 89 |
4/4✓ Branch 1 taken 370 times.
✓ Branch 4 taken 370 times.
✓ Branch 7 taken 370 times.
✓ Branch 10 taken 370 times.
|
370 | this->model().disconnect(mo, this->inletPort()); |
| 90 |
4/4✓ Branch 1 taken 370 times.
✓ Branch 4 taken 370 times.
✓ Branch 7 taken 370 times.
✓ Branch 10 taken 370 times.
|
370 | this->model().disconnect(mo, this->outletPort()); |
| 91 | 370 | } | |
| 92 | |||
| 93 | 30439 | std::vector<HVACComponent> StraightComponent_Impl::edges(const boost::optional<HVACComponent>& /*prev*/) { | |
| 94 | 30439 | std::vector<HVACComponent> edges; | |
| 95 |
3/3✓ Branch 1 taken 30439 times.
✓ Branch 3 taken 30435 times.
✓ Branch 4 taken 4 times.
|
60878 | if (auto edgeModelObject = outletModelObject()) { |
| 96 |
3/4✓ Branch 1 taken 30435 times.
✓ Branch 4 taken 30435 times.
✓ Branch 6 taken 30435 times.
✗ Branch 7 not taken.
|
60870 | if (auto edgeObject = edgeModelObject->optionalCast<HVACComponent>()) { |
| 97 |
2/2✓ Branch 1 taken 30435 times.
✓ Branch 4 taken 30435 times.
|
30435 | edges.push_back(*edgeObject); |
| 98 | 30435 | } | |
| 99 | 30439 | } | |
| 100 | 30439 | return edges; | |
| 101 | ✗ | } | |
| 102 | |||
| 103 | 1171 | bool StraightComponent_Impl::addToNode(Node& node) { | |
| 104 |
1/1✓ Branch 1 taken 1171 times.
|
1171 | Model _model = node.model(); |
| 105 |
1/1✓ Branch 1 taken 1171 times.
|
1171 | auto thisModelObject = getObject<ModelObject>(); |
| 106 |
1/1✓ Branch 1 taken 1171 times.
|
1171 | auto t_loop = node.loop(); |
| 107 |
1/1✓ Branch 1 taken 1171 times.
|
1171 | auto t_oaSystem = node.airLoopHVACOutdoorAirSystem(); |
| 108 | |||
| 109 |
1/1✓ Branch 1 taken 1171 times.
|
1171 | auto componentInletPort = inletPort(); |
| 110 |
1/1✓ Branch 1 taken 1171 times.
|
1171 | auto componentOutletPort = outletPort(); |
| 111 | |||
| 112 | 1171 | boost::optional<HVACComponent> systemStartComponent; | |
| 113 | 1171 | boost::optional<HVACComponent> systemEndComponent; | |
| 114 | |||
| 115 |
3/3✓ Branch 3 taken 1171 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 1169 times.
|
1171 | if (node.getImpl<Node_Impl>()->isConnected(thisModelObject)) { |
| 116 | 2 | return false; | |
| 117 | } | ||
| 118 | |||
| 119 |
6/6✓ Branch 0 taken 1124 times.
✓ Branch 1 taken 45 times.
✓ Branch 3 taken 926 times.
✓ Branch 4 taken 198 times.
✓ Branch 5 taken 926 times.
✓ Branch 6 taken 243 times.
|
1169 | if (t_loop && !t_oaSystem) { |
| 120 |
5/5✓ Branch 1 taken 926 times.
✓ Branch 4 taken 926 times.
✓ Branch 7 taken 926 times.
✓ Branch 10 taken 819 times.
✓ Branch 11 taken 107 times.
|
1852 | if (t_loop->supplyComponent(node.handle())) { |
| 121 |
3/3✓ Branch 1 taken 819 times.
✓ Branch 4 taken 819 times.
✓ Branch 7 taken 819 times.
|
819 | systemStartComponent = t_loop->supplyInletNode(); |
| 122 |
2/2✓ Branch 1 taken 819 times.
✓ Branch 4 taken 819 times.
|
819 | auto nodes = t_loop->supplyOutletNodes(); |
| 123 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 819 times.
✗ Branch 4 not taken.
|
819 | OS_ASSERT(!nodes.empty()); |
| 124 |
15/22✓ Branch 1 taken 3 times.
✓ Branch 2 taken 816 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 14 taken 3 times.
✓ Branch 17 taken 3 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 3 times.
✓ Branch 20 taken 816 times.
✓ Branch 22 taken 3 times.
✓ Branch 23 taken 816 times.
✓ Branch 25 taken 3 times.
✓ Branch 26 taken 816 times.
✓ Branch 27 taken 3 times.
✓ Branch 28 taken 816 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
|
825 | if ((nodes.size() == 2u) && (!t_loop->supplyComponents(node, nodes[1]).empty())) { |
| 125 |
1/1✓ Branch 2 taken 3 times.
|
3 | systemEndComponent = nodes[1]; |
| 126 | } else { | ||
| 127 |
1/1✓ Branch 2 taken 816 times.
|
816 | systemEndComponent = nodes[0]; |
| 128 | } | ||
| 129 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 819 times.
✗ Branch 4 not taken.
|
819 | OS_ASSERT(systemEndComponent); |
| 130 |
4/5✓ Branch 2 taken 107 times.
✓ Branch 5 taken 107 times.
✓ Branch 8 taken 107 times.
✓ Branch 11 taken 107 times.
✗ Branch 12 not taken.
|
1033 | } else if (t_loop->demandComponent(node.handle())) { |
| 131 |
3/3✓ Branch 1 taken 107 times.
✓ Branch 4 taken 107 times.
✓ Branch 7 taken 107 times.
|
107 | systemStartComponent = t_loop->demandInletNode(); |
| 132 |
3/3✓ Branch 1 taken 107 times.
✓ Branch 4 taken 107 times.
✓ Branch 7 taken 107 times.
|
107 | systemEndComponent = t_loop->demandOutletNode(); |
| 133 | } | ||
| 134 |
1/2✓ Branch 0 taken 243 times.
✗ Branch 1 not taken.
|
243 | } else if (t_oaSystem) { |
| 135 |
5/5✓ Branch 1 taken 243 times.
✓ Branch 4 taken 243 times.
✓ Branch 7 taken 243 times.
✓ Branch 10 taken 218 times.
✓ Branch 11 taken 25 times.
|
486 | if (t_oaSystem->oaComponent(node.handle())) { |
| 136 |
3/3✓ Branch 1 taken 218 times.
✓ Branch 4 taken 218 times.
✓ Branch 7 taken 218 times.
|
218 | systemStartComponent = t_oaSystem->outboardOANode(); |
| 137 |
2/2✓ Branch 1 taken 218 times.
✓ Branch 4 taken 218 times.
|
218 | systemEndComponent = t_oaSystem.get(); |
| 138 |
4/5✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
✓ Branch 10 taken 25 times.
✗ Branch 11 not taken.
|
50 | } else if (t_oaSystem->reliefComponent(node.handle())) { |
| 139 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
|
25 | systemStartComponent = t_oaSystem.get(); |
| 140 |
3/3✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
|
25 | systemEndComponent = t_oaSystem->outboardReliefNode(); |
| 141 | } | ||
| 142 | } | ||
| 143 | |||
| 144 |
3/6✓ Branch 0 taken 1169 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1169 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1169 times.
✗ Branch 5 not taken.
|
2338 | if (systemStartComponent && systemEndComponent) { |
| 145 |
1/1✓ Branch 1 taken 1169 times.
|
1169 | removeFromLoop(); |
| 146 |
3/3✓ Branch 1 taken 1169 times.
✓ Branch 4 taken 1169 times.
✓ Branch 7 taken 1169 times.
|
1169 | return HVACComponent_Impl::addToNode(node, systemStartComponent.get(), systemEndComponent.get(), componentInletPort, componentOutletPort); |
| 147 | } else { | ||
| 148 | ✗ | return false; | |
| 149 | } | ||
| 150 | 1171 | } | |
| 151 | |||
| 152 | 288 | ModelObject StraightComponent_Impl::clone(Model model) const { | |
| 153 |
3/3✓ Branch 1 taken 288 times.
✓ Branch 4 taken 288 times.
✓ Branch 7 taken 288 times.
|
288 | auto mo = HVACComponent_Impl::clone(model).cast<StraightComponent>(); |
| 154 | |||
| 155 |
3/3✓ Branch 1 taken 288 times.
✓ Branch 4 taken 288 times.
✓ Branch 7 taken 288 times.
|
576 | mo.setString(mo.inletPort(), ""); |
| 156 |
3/3✓ Branch 1 taken 288 times.
✓ Branch 4 taken 288 times.
✓ Branch 7 taken 288 times.
|
288 | mo.setString(mo.outletPort(), ""); |
| 157 | |||
| 158 | 576 | return std::move(mo); | |
| 159 | 288 | } | |
| 160 | |||
| 161 | } // namespace detail | ||
| 162 | |||
| 163 | 16103 | StraightComponent::StraightComponent(IddObjectType type, const Model& model) : HVACComponent(type, model) { | |
| 164 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 16103 times.
✗ Branch 5 not taken.
|
16103 | OS_ASSERT(getImpl<detail::StraightComponent_Impl>()); |
| 165 | 16103 | } | |
| 166 | |||
| 167 |
1/1✓ Branch 3 taken 151652 times.
|
151652 | StraightComponent::StraightComponent(std::shared_ptr<detail::StraightComponent_Impl> p) : HVACComponent(std::move(p)) {} |
| 168 | |||
| 169 | 13465 | unsigned StraightComponent::inletPort() const { | |
| 170 |
1/1✓ Branch 3 taken 13465 times.
|
13465 | return getImpl<detail::StraightComponent_Impl>()->inletPort(); |
| 171 | } | ||
| 172 | |||
| 173 | 13906 | unsigned StraightComponent::outletPort() const { | |
| 174 |
1/1✓ Branch 3 taken 13906 times.
|
13906 | return getImpl<detail::StraightComponent_Impl>()->outletPort(); |
| 175 | } | ||
| 176 | |||
| 177 | 14830 | OptionalModelObject StraightComponent::inletModelObject() const { | |
| 178 |
1/1✓ Branch 3 taken 14830 times.
|
14830 | return getImpl<detail::StraightComponent_Impl>()->inletModelObject(); |
| 179 | } | ||
| 180 | |||
| 181 | 10784 | OptionalModelObject StraightComponent::outletModelObject() const { | |
| 182 |
1/1✓ Branch 3 taken 10784 times.
|
10784 | return getImpl<detail::StraightComponent_Impl>()->outletModelObject(); |
| 183 | } | ||
| 184 | |||
| 185 | 6 | bool StraightComponent::removeFromLoop() { | |
| 186 |
1/1✓ Branch 3 taken 6 times.
|
6 | return getImpl<detail::StraightComponent_Impl>()->removeFromLoop(); |
| 187 | } | ||
| 188 | |||
| 189 | 4673 | OptionalAirLoopHVAC StraightComponent::airLoopHVAC() const { | |
| 190 |
1/1✓ Branch 3 taken 4673 times.
|
4673 | return getImpl<detail::StraightComponent_Impl>()->airLoopHVAC(); |
| 191 | } | ||
| 192 | |||
| 193 | } // namespace model | ||
| 194 | |||
| 195 | } // namespace openstudio | ||
| 196 |