MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / removeFromLoop

Method removeFromLoop

src/model/HVACComponent.cpp:113–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111 }
112
113 bool HVACComponent_Impl::removeFromLoop(const HVACComponent& systemStartComponent, const HVACComponent& systemEndComponent,
114 unsigned componentInletPort, unsigned componentOutletPort) {
115 auto _model = model();
116 auto thisObject = getObject<HVACComponent>();
117
118 if (systemStartComponent.model() != _model) {
119 return false;
120 }
121 if (systemEndComponent.model() != _model) {
122 return false;
123 }
124
125 auto inletComponent = connectedObject(componentInletPort);
126 auto outletComponent = connectedObject(componentOutletPort);
127 auto inletComponentOutletPort = connectedObjectPort(componentInletPort);
128 auto outletComponentInletPort = connectedObjectPort(componentOutletPort);
129
130 if (!inletComponent) {
131 return false;
132 }
133 if (!outletComponent) {
134 return false;
135 }
136 if (!inletComponentOutletPort) {
137 return false;
138 }
139 if (!outletComponentInletPort) {
140 return false;
141 }
142
143 auto inletNode = inletComponent->optionalCast<Node>();
144 auto outletNode = outletComponent->optionalCast<Node>();
145 boost::optional<Splitter> splitter;
146 boost::optional<Mixer> mixer;
147
148 if (inletNode) {
149 if (auto mo = inletNode->inletModelObject()) {
150 splitter = mo->optionalCast<Splitter>();
151 }
152 }
153 if (outletNode) {
154 if (auto mo = outletNode->outletModelObject()) {
155 mixer = mo->optionalCast<Mixer>();
156 }
157 }
158
159 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 _model.disconnect(thisObject, componentInletPort);
164 _model.disconnect(thisObject, componentOutletPort);
165
166 _model.connect(inletComponent.get(), inletComponentOutletPort.get(), outletComponent.get(), outletComponentInletPort.get());
167
168 return true;
169 } else if (systemEndComponent.handle() == outletComponent->handle()) {
170 // Here the systemEndComponent is immediately downstream of this component,

Callers 7

removeSupplySplitterMethod · 0.45
TEST_FFunction · 0.45
TEST_FFunction · 0.45
TEST_FFunction · 0.45
TEST_FFunction · 0.45
TEST_FFunction · 0.45
TEST_FFunction · 0.45

Calls 15

connectedObjectPortMethod · 0.80
lastOutletModelObjectMethod · 0.80
modelMethod · 0.45
inletModelObjectMethod · 0.45
outletModelObjectMethod · 0.45
handleMethod · 0.45
disconnectMethod · 0.45
connectMethod · 0.45
getMethod · 0.45
inletPortMethod · 0.45

Tested by 6

TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36