boost::optional<Node> AirTerminalDualDuctVAV_Impl::hotAirInletNode() const {
   boost::optional<Node> node;
   if( auto mo = inletModelObject(0) ) {
     node = mo->optionalCast<Node>();
     OS_ASSERT(node);
   }
   return node;
 }
 boost::optional<Node> AirTerminalDualDuctVAVOutdoorAir_Impl::recirculatedAirInletNode() const {
   boost::optional<Node> node;
   if( auto mo = inletModelObject(1) ) {
     node = mo->optionalCast<Node>();
     OS_ASSERT(node);
   }
   return node;
 }
示例#3
0
void Mixer_Impl::removePortForBranch(unsigned branchIndex)
{
    int _nextBranchIndex = nextBranchIndex();
    model().disconnect(getObject<ModelObject>(),inletPort(branchIndex));
    for(int i = branchIndex + 1; i < _nextBranchIndex; i++ )
    {
        ModelObject mo = inletModelObject(i).get();
        unsigned port = connectedObjectPort( inletPort(i) ).get();
        model().disconnect(getObject<ModelObject>(),inletPort(i));
        model().connect(mo,port,getObject<ModelObject>(),inletPort(i-1));
    }
}
示例#4
0
unsigned Mixer_Impl::branchIndexForInletModelObject( ModelObject modelObject )
{
    unsigned stop = nextBranchIndex();

    for(unsigned i = 0; i < stop; i++)
    {
        if( inletModelObject(i) == modelObject )
        {
            return i;
        }
    }
    return 0;
}
示例#5
0
  bool Node_Impl::isConnected(const ModelObject & modelObject)
  {
    if( auto mo = outletModelObject() ) {
      if( modelObject.handle() == mo->handle() ) {
        return true;
      }
    }
    if( auto mo = inletModelObject() ) {
      if( modelObject.handle() == mo->handle() ) {
        return true;
      }
    }

    return false;
  }
示例#6
0
unsigned Mixer_Impl::newInletPortAfterBranch(unsigned branchIndex)
{
    //std::vector<ModelObject> modelObjects = inletModelObjects();
    unsigned stop = nextBranchIndex();
    for(unsigned i = branchIndex; i < stop; i++ )
    {
        ModelObject mo = inletModelObject(i).get();
        unsigned port = connectedObjectPort( inletPort(i) ).get();
        model().connect(getObject<ModelObject>(),inletPort(i+2),mo,port);
    }

    Model _model = model();
    Node node( _model );

    _model.connect( node,node.outletPort(),getObject<ModelObject>(),inletPort(branchIndex+1) );

    return inletPort(branchIndex++);
}
示例#7
0
  bool HVACComponent_Impl::removeFromLoop( const HVACComponent & systemStartComponent, 
    const HVACComponent & systemEndComponent,
    unsigned componentInletPort,
    unsigned componentOutletPort )
  {
    auto _model = model();
    auto thisObject = getObject<HVACComponent>();
    
    if( systemStartComponent.model() != _model ) return false;
    if( systemEndComponent.model() != _model ) return false;

    auto inletComponent = connectedObject( componentInletPort );
    auto outletComponent = connectedObject( componentOutletPort );
    auto inletComponentOutletPort = connectedObjectPort( componentInletPort );
    auto outletComponentInletPort = connectedObjectPort( componentOutletPort );

    if( ! inletComponent ) return false;
    if( ! outletComponent ) return false;
    if( ! inletComponentOutletPort ) return false;
    if( ! outletComponentInletPort ) return false;

    auto inletNode = inletComponent->optionalCast<Node>();
    auto outletNode = outletComponent->optionalCast<Node>();
    boost::optional<Splitter> splitter;
    boost::optional<Mixer> mixer;

    if( inletNode ) {
      if( auto mo = inletNode->inletModelObject() ) {
        splitter = mo->optionalCast<Splitter>();
      }
    }
    if( outletNode ) {
      if( auto mo = outletNode->outletModelObject() ) {
        mixer = mo->optionalCast<Mixer>();
      }
    }

    if( systemStartComponent.handle() == inletComponent->handle() 
        && systemEndComponent.handle() == outletComponent->handle() ) {
      // This component is between the systemStartComponent and the systemEndComponent
      // ie. the supply or demand inlet or outlet Nodes,
      // or the oa system end points on either the relief or inlet air streams.
      _model.disconnect(thisObject,componentInletPort); 
      _model.disconnect(thisObject,componentOutletPort); 

      _model.connect( inletComponent.get(), inletComponentOutletPort.get(), 
                       outletComponent.get(), outletComponentInletPort.get() );
      
      return true;
    } else if( systemEndComponent.handle() == outletComponent->handle() ) {
      // Here the systemEndComponent is immediately downstream of this component,
      // but there are other components (besides systemStartComponent) upstream.
      boost::optional<ModelObject> newInletComponent;
      boost::optional<unsigned> newInletComponentOutletPort;

      // Make sure we don't end up with two nodes next to each other after this component is removed
      if( inletNode && outletNode ) {
        newInletComponent = inletNode->inletModelObject();
        newInletComponentOutletPort = inletNode->connectedObjectPort(inletNode->inletPort());
        OS_ASSERT(newInletComponent);
        OS_ASSERT(newInletComponentOutletPort);
      } else {
        newInletComponent = inletComponent;
        newInletComponentOutletPort = inletComponentOutletPort;
      }

      _model.disconnect(thisObject,componentInletPort); 
      _model.disconnect(thisObject,componentOutletPort); 

      // inletNode->remove() would have failed if we did it before the disconnect
      if( inletNode && outletNode ) {
        inletNode->remove();
      }

      _model.connect( newInletComponent.get(), newInletComponentOutletPort.get(), 
                       outletComponent.get(), outletComponentInletPort.get() );
      return true;
    } else if( splitter && mixer ) {
      // If the component is the only component (except nodes) between a splitter mixer pair
      OS_ASSERT(inletNode);
      OS_ASSERT(outletNode);

      int i = splitter->branchIndexForOutletModelObject(inletNode.get());
      int j = mixer->branchIndexForInletModelObject(outletNode.get());

      OS_ASSERT(i == j);

      splitter->removePortForBranch(i);
      mixer->removePortForBranch(i);

      _model.disconnect(thisObject,componentInletPort); 
      _model.disconnect(thisObject,componentOutletPort); 

      inletNode->remove();
      outletNode->remove();

      if( ! splitter->lastOutletModelObject() )
      {
        Node newNode(_model);
        _model.connect(splitter.get(),splitter->nextOutletPort(),newNode,newNode.inletPort());
        _model.connect(newNode,newNode.outletPort(),mixer.get(),mixer->nextInletPort());
      }

      return true;
    } else {
      boost::optional<ModelObject> newOutletComponent; 
      boost::optional<unsigned> newOutletComponentInletPort;

      if( inletNode && outletNode ) {
        newOutletComponent = outletNode->outletModelObject();
        newOutletComponentInletPort = outletNode->connectedObjectPort(outletNode->outletPort());
      }

      if( ! newOutletComponent ) newOutletComponent = outletComponent;
      if( ! newOutletComponentInletPort ) newOutletComponentInletPort = outletComponentInletPort;

      _model.disconnect(thisObject,componentInletPort); 
      _model.disconnect(thisObject,componentOutletPort); 

      // outletNode->remove() would have failed if we did it before the disconnect
      if( inletNode && outletNode ) {
        outletNode->remove();
      }

      model().connect( inletComponent.get(), inletComponentOutletPort.get(), 
                       newOutletComponent.get(), newOutletComponentInletPort.get() );

      return true;
    }

    return false;
  }