Exemplo n.º 1
0
  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;
  }
Exemplo n.º 2
0
  void TemperingValve_Impl::setControlNodes()
  {
    auto plant = plantLoop();

    if( ! plant ) return;

    if( ! pumpOutletNode() ) {
      std::vector<ModelObject> allpumps;
      auto pumps = plant->supplyComponents(PumpVariableSpeed::iddObjectType());
      allpumps.insert(allpumps.end(),pumps.begin(),pumps.end());
      pumps = plant->supplyComponents(PumpConstantSpeed::iddObjectType());
      allpumps.insert(allpumps.end(),pumps.begin(),pumps.end());
      pumps = plant->supplyComponents(HeaderedPumpsConstantSpeed::iddObjectType());
      allpumps.insert(allpumps.end(),pumps.begin(),pumps.end());
      pumps = plant->supplyComponents(HeaderedPumpsVariableSpeed::iddObjectType());
      allpumps.insert(allpumps.end(),pumps.begin(),pumps.end());

      if( ! allpumps.empty() ) {
        if( auto mo = allpumps.back().cast<StraightComponent>().outletModelObject() ) {
          if( auto node = mo->optionalCast<Node>() ) {
            setPumpOutletNode(node);
          }
        }
      }
    }

    if( ! temperatureSetpointNode() ) {
      auto node = plant->supplyOutletNode();
      setTemperatureSetpointNode(node);
    }

    auto mixer = plant->supplyMixer();

    if( ! stream2SourceNode() ) { 
      TemperingValve thisObject = getObject<TemperingValve>();
      auto inletObjects = mixer.inletModelObjects();
      for( auto & inletObject : inletObjects ) {
        if( auto node = inletObject.optionalCast<Node>() ) {
          if( plant->supplyComponents(thisObject,node.get()).empty() ) {
            setStream2SourceNode(node.get());
          }
        }
      }
    }
  }
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;
  }
}