bool ZoneHVACBaseboardConvectiveElectric_Impl::addToThermalZone(ThermalZone & thermalZone)
  {
    Model m = this->model();

    if( thermalZone.model() != m )
    {
      return false;
    }

    if( thermalZone.isPlenum() )
    {
      return false;
    }

    removeFromThermalZone();

    thermalZone.setUseIdealAirLoads(false);

    thermalZone.addEquipment(this->getObject<ZoneHVACComponent>());

    return true;
  }
  //reimplemented to override the base-class method in ZoneHVACComponent
  //because this component doesn't get attached to the zone inlet and zone outlet nodes
  bool ZoneHVACLowTempRadiantVarFlow_Impl::addToThermalZone(ThermalZone & thermalZone)
  {
    Model m = this->model();

    if( thermalZone.model() != m )
    {
      return false;
    }

    if( thermalZone.isPlenum() )
    {
      return false;
    }

    removeFromThermalZone();

    thermalZone.setUseIdealAirLoads(false);

    thermalZone.addEquipment(this->getObject<ZoneHVACComponent>());

    return true;
  }
  bool AirTerminalSingleDuctParallelPIUReheat_Impl::setInducedAirPlenumZone(ThermalZone & plenumZone)
  {
    bool result = true;

    if( ! plenumZone.isPlenum() )
    {
      result = false;
    }

    boost::optional<Node> t_secondaryAirInletNode;
    if( result )
    {
      t_secondaryAirInletNode = secondaryAirInletNode();
      if( ! t_secondaryAirInletNode )
      {
        result = false;
      }
    }

    boost::optional<AirLoopHVACReturnPlenum> plenum;
    if( result )
    {
      plenum = plenumZone.getImpl<detail::ThermalZone_Impl>()->airLoopHVACReturnPlenum();
      if( ! plenum )
      {
        result = false;
      }
    }

    if( result )
    {
      Model t_model = model();
      PortList pl = plenum->getImpl<detail::AirLoopHVACReturnPlenum_Impl>()->inducedAirOutletPortList();
      t_model.connect(pl,pl.nextPort(),t_secondaryAirInletNode.get(),t_secondaryAirInletNode->inletPort());
    }

    return result;
  }
  bool ZoneHVACComponent_Impl::addToThermalZone(ThermalZone & thermalZone)
  {
    Model m = this->model();

    if( thermalZone.model() != m ) {
      return false;
    }

    if( thermalZone.isPlenum() ) {
      return false;
    }

    removeFromThermalZone();

    thermalZone.setUseIdealAirLoads(false);

    // Connect nodes if this is an air based zone hvac component
    if( inletPort() != 0u && outletPort() != 0u ) {
      // Exhaust Node
      Node exhaustNode(m);
      PortList exhaustPortList = thermalZone.exhaustPortList();
      unsigned nextPort = exhaustPortList.nextPort();
      m.connect(exhaustPortList,nextPort,exhaustNode,exhaustNode.inletPort());
      ModelObject mo = this->getObject<ModelObject>();
      m.connect(exhaustNode,exhaustNode.outletPort(),mo,this->inletPort());

      // Air Inlet Node
      Node airInletNode(m);
      PortList inletPortList = thermalZone.inletPortList();
      unsigned nextInletPort = inletPortList.nextPort();
      m.connect(airInletNode,airInletNode.outletPort(),inletPortList,nextInletPort);
      m.connect(mo,this->outletPort(),airInletNode,airInletNode.inletPort());
    }

    thermalZone.addEquipment(this->getObject<ZoneHVACComponent>());

    return true;
  }