bool ConnectorSplitter_Impl::addToNode(Node & node) { auto t_model = model(); if( node.model() != t_model ) { return false; } if( loop() ) { return false; } if( ! outletModelObjects().empty() ) { LOG(Warn, briefDescription() << " must not have existing outlet connections to use addToNode method."); return false; } auto t_nodeAirLoop = node.airLoopHVAC(); if( ! t_nodeAirLoop ) { LOG(Warn, briefDescription() << " must be added to an AirLoopHVAC supply node use addToNode method."); return false; } if( ! t_nodeAirLoop->supplyComponent(node.handle()) ) { LOG(Warn, briefDescription() << " must be added to an AirLoopHVAC supply node use addToNode method."); return false; } if( ! t_nodeAirLoop->supplyComponents(iddObjectType()).empty() ) { LOG(Warn, briefDescription() << " already has a splitter."); return false; } auto supplyInletNode = t_nodeAirLoop->supplyInletNode(); auto supplyOutletNode = t_nodeAirLoop->supplyOutletNode(); // Hook Up Duct "A" auto t_inletPort = inletPort(); auto portA = nextOutletPort(); HVACComponent_Impl::addToNode(node, supplyInletNode, supplyOutletNode, t_inletPort, portA); // Hook Up Duct "B" Node supplyOutletNodeB(t_model); auto thisObject = getObject<model::HVACComponent>(); auto portB = nextOutletPort(); t_model.connect(thisObject,portB,supplyOutletNodeB,supplyOutletNodeB.inletPort()); t_model.connect(supplyOutletNodeB,supplyOutletNodeB.outletPort(),t_nodeAirLoop.get(),t_nodeAirLoop->getImpl<detail::AirLoopHVAC_Impl>()->supplyOutletPortB()); return true; }
bool WaterToWaterComponent_Impl::addToNode(Node & node) { auto _model = node.model(); auto thisModelObject = getObject<ModelObject>(); auto t_plantLoop = node.plantLoop(); boost::optional<unsigned> componentInletPort; boost::optional<unsigned> componentOutletPort; boost::optional<HVACComponent> systemStartComponent; boost::optional<HVACComponent> systemEndComponent; if( node.getImpl<Node_Impl>()->isConnected(thisModelObject) ) return false; if( t_plantLoop ) { if( t_plantLoop->supplyComponent(node.handle()) ) { systemStartComponent = t_plantLoop->supplyInletNode(); systemEndComponent = t_plantLoop->supplyOutletNode(); componentInletPort = supplyInletPort(); componentOutletPort = supplyOutletPort(); removeFromPlantLoop(); } else if( t_plantLoop->demandComponent(node.handle()) ) { systemStartComponent = t_plantLoop->demandInletNode(); systemEndComponent = t_plantLoop->demandOutletNode(); componentInletPort = demandInletPort(); componentOutletPort = demandOutletPort(); removeFromSecondaryPlantLoop(); } } if( systemStartComponent && systemEndComponent && componentOutletPort && componentInletPort ) { return HVACComponent_Impl::addToNode(node,systemStartComponent.get(),systemEndComponent.get(),componentInletPort.get(),componentOutletPort.get()); } else { return false; } }
bool WaterToAirComponent_Impl::addToNode(Node & node) { auto _model = node.model(); auto thisModelObject = getObject<ModelObject>(); auto t_airLoop = node.airLoopHVAC(); auto t_plantLoop = node.plantLoop(); auto t_oaSystem = node.airLoopHVACOutdoorAirSystem(); boost::optional<unsigned> componentInletPort; boost::optional<unsigned> componentOutletPort; boost::optional<HVACComponent> systemStartComponent; boost::optional<HVACComponent> systemEndComponent; if( node.getImpl<Node_Impl>()->isConnected(thisModelObject) ) return false; if( t_airLoop && ! t_oaSystem ) { if( t_airLoop->demandComponent( node.handle() ) ) return false; systemStartComponent = t_airLoop->supplyInletNode(); auto nodes = t_airLoop->supplyOutletNodes(); OS_ASSERT( ! nodes.empty() ); if( (nodes.size() == 2u) && (! t_airLoop->supplyComponents(node,nodes[1]).empty()) ) { systemEndComponent = nodes[1]; } else { systemEndComponent = nodes[0]; } OS_ASSERT(systemEndComponent); componentInletPort = airInletPort(); componentOutletPort = airOutletPort(); removeFromAirLoopHVAC(); } else if( t_oaSystem ) { if( t_oaSystem->oaComponent(node.handle()) ) { systemStartComponent = t_oaSystem->outboardOANode(); systemEndComponent = t_oaSystem.get(); componentInletPort = airInletPort(); componentOutletPort = airOutletPort(); } else if( t_oaSystem->reliefComponent(node.handle()) ) { systemStartComponent = t_oaSystem.get(); systemEndComponent = t_oaSystem->outboardReliefNode(); componentInletPort = airInletPort(); componentOutletPort = airOutletPort(); } removeFromAirLoopHVAC(); } else if( t_plantLoop ) { if( ! t_plantLoop->demandComponent( node.handle() ) ) return false; systemStartComponent = t_plantLoop->demandInletNode(); systemEndComponent = t_plantLoop->demandOutletNode(); componentInletPort = waterInletPort(); componentOutletPort = waterOutletPort(); removeFromPlantLoop(); } if( systemStartComponent && systemEndComponent && componentOutletPort && componentInletPort ) { return HVACComponent_Impl::addToNode(node,systemStartComponent.get(),systemEndComponent.get(),componentInletPort.get(),componentOutletPort.get()); } else { return false; } }