Ejemplo n.º 1
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());
          }
        }
      }
    }
  }
Ejemplo n.º 2
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;
  }
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;
    }
}