std::vector<EnergyManagementSystemProgram> EnergyManagementSystemProgramCallingManager_Impl::programs() const {
   // loop through extensible groups and return vector of programs
   std::vector<EnergyManagementSystemProgram> result;
   auto groups = extensibleGroups();
   
   for (const auto & elem : groups) {
     WorkspaceExtensibleGroup group = elem.cast<WorkspaceExtensibleGroup>();
     boost::optional<WorkspaceObject> wo = group.getTarget(OS_EnergyManagementSystem_ProgramCallingManagerExtensibleFields::ProgramName);
     if (wo){
       EnergyManagementSystemProgram program = wo->cast<EnergyManagementSystemProgram>();
       result.push_back(program);
     }  
   }
   return result;
 }
  boost::optional<EnergyManagementSystemProgram> EnergyManagementSystemProgramCallingManager_Impl::getProgram(unsigned index) const {
    //return program at index 
    boost::optional<EnergyManagementSystemProgram> result;
    auto groups = extensibleGroups();
    unsigned sizeOfGroup = numExtensibleGroups();

    if ((index < sizeOfGroup) && (!groups[index].empty())) {
      WorkspaceExtensibleGroup group = groups[index].cast<WorkspaceExtensibleGroup>();
      boost::optional<WorkspaceObject> wo = group.getTarget(OS_EnergyManagementSystem_ProgramCallingManagerExtensibleFields::ProgramName);
      if (wo) {
        EnergyManagementSystemProgram program = wo->cast<EnergyManagementSystemProgram>();
        result = program;
      }
    }
    return result;
  }
コード例 #3
0
  std::vector<WaterUseEquipment> WaterUseConnections_Impl::waterUseEquipment() const
  {
    std::vector<WaterUseEquipment> result;

    std::vector<IdfExtensibleGroup> groups = extensibleGroups();

    for( const auto & elem : groups )
    {
      WorkspaceExtensibleGroup group = elem.cast<WorkspaceExtensibleGroup>();

      boost::optional<WorkspaceObject> wo = group.getTarget(OS_WaterUse_ConnectionsExtensibleFields::WaterUseEquipmentName);
       
      if( wo )
      {
        WaterUseEquipment equipment = wo->cast<WaterUseEquipment>();

        result.push_back(equipment);
      }
    }

    return result;
  }
コード例 #4
0
OptionalModelObject ReverseTranslator::translateZoneList( const WorkspaceObject & workspaceObject )
{
   if( workspaceObject.iddObject().type() != IddObjectType::Zone ){
    LOG(Error, "WorkspaceObject is not IddObjectType: Zone");
    return boost::none;
  }

  openstudio::model::SpaceType spaceType( m_model );

  OptionalString s = workspaceObject.name();
  if(s){
    spaceType.setName(*s);
  }

  for (const IdfExtensibleGroup& idfGroup : workspaceObject.extensibleGroups()){
    WorkspaceExtensibleGroup workspaceGroup = idfGroup.cast<WorkspaceExtensibleGroup>();
    
    OptionalWorkspaceObject target = workspaceGroup.getTarget(0);
    if (target){
      OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
      if (modelObject){
        if (modelObject->optionalCast<Space>()){
          Space space = modelObject->cast<Space>();

          if (space.spaceType()){
            LOG(Warn, "Overriding previously assigned SpaceType for Space '" << space.name().get() << "'");
          }

          space.setSpaceType(spaceType);

        }
      }
    }
  }

  return spaceType;
}
コード例 #5
0
OptionalModelObject ReverseTranslator::translateSizingZone( const WorkspaceObject & workspaceObject )
{
    boost::optional<WorkspaceObject> target = workspaceObject.getTarget(Sizing_ZoneFields::ZoneorZoneListName);

    std::vector<ThermalZone> thermalZones;

    if( target ) {

        // just one thermal zone
        boost::optional<ModelObject> mo;
        if (target->iddObject().type() == IddObjectType::Zone) {
            mo = translateAndMapWorkspaceObject(target.get());
            if( mo ) {
                if( boost::optional<Space> space = mo->optionalCast<Space>() ) {
                    boost::optional<ThermalZone> thermalZone = space->thermalZone();
                    if (thermalZone) {
                        thermalZones.push_back(*thermalZone);
                    }
                }
            }
        } else if (target->iddObject().type() == IddObjectType::ZoneList) {

            // get all thermal zones in zone list
            for (const IdfExtensibleGroup& idfGroup : target->extensibleGroups()) {
                WorkspaceExtensibleGroup workspaceGroup = idfGroup.cast<WorkspaceExtensibleGroup>();
                OptionalWorkspaceObject owo = workspaceGroup.getTarget(0);
                if (owo) {
                    mo = translateAndMapWorkspaceObject(owo.get());
                    if( mo ) {
                        if( boost::optional<Space> space = mo->optionalCast<Space>() ) {
                            boost::optional<ThermalZone> thermalZone = space->thermalZone();
                            if (thermalZone) {
                                thermalZones.push_back(*thermalZone);
                            }
                        }
                    }
                }
            }
        }
    }

    if(thermalZones.empty())
    {
        LOG(Error, "Error importing object: "
            << workspaceObject.briefDescription()
            << " Can't find associated ThermalZone(s).");

        return boost::none;
    }

    boost::optional<ModelObject> result;
    for (ThermalZone thermalZone : thermalZones) {

        // sizing zone is constructed in thermal zone ctor
        openstudio::model::SizingZone sizingZone = thermalZone.sizingZone();

        // return first sizing zone
        if (!result) {
            result = sizingZone;
        }

        boost::optional<std::string> s;
        boost::optional<double> value;

        // ZoneCoolingDesignSupplyAirTemperature

        value = workspaceObject.getDouble(Sizing_ZoneFields::ZoneCoolingDesignSupplyAirTemperature);
        if( value )
        {
            sizingZone.setZoneCoolingDesignSupplyAirTemperature(value.get());
        }

        // ZoneHeatingDesignSupplyAirTemperature

        value = workspaceObject.getDouble(Sizing_ZoneFields::ZoneHeatingDesignSupplyAirTemperature);
        if( value )
        {
            sizingZone.setZoneHeatingDesignSupplyAirTemperature(value.get());
        }

        // ZoneCoolingDesignSupplyAirHumidityRatio

        value = workspaceObject.getDouble(Sizing_ZoneFields::ZoneHeatingDesignSupplyAirHumidityRatio);
        if( value )
        {
            sizingZone.setZoneHeatingDesignSupplyAirHumidityRatio(value.get());
        }

        // ZoneHeatingDesignSupplyAirHumidityRatio

        value = workspaceObject.getDouble(Sizing_ZoneFields::ZoneHeatingDesignSupplyAirHumidityRatio);
        if( value )
        {
            sizingZone.setZoneHeatingDesignSupplyAirHumidityRatio(value.get());
        }

        // DesignSpecificationOutdoorAirObjectName

        target = workspaceObject.getTarget(Sizing_ZoneFields::DesignSpecificationOutdoorAirObjectName);
        if (target) {
            OptionalModelObject mo = translateDesignSpecificationOutdoorAir(*target);
            if (mo) {
                if (mo->optionalCast<DesignSpecificationOutdoorAir>()) {
                    std::vector<Space> spaces = thermalZone.spaces();
                    OS_ASSERT(spaces.size() == 1);
                    spaces[0].setDesignSpecificationOutdoorAir(mo->cast<DesignSpecificationOutdoorAir>());
                }
            }
        }

        // ZoneHeatingSizingFactor

        value = workspaceObject.getDouble(Sizing_ZoneFields::ZoneHeatingSizingFactor);
        if( value )
        {
            sizingZone.setZoneHeatingSizingFactor(value.get());
        }

        // ZoneCoolingSizingFactor

        value = workspaceObject.getDouble(Sizing_ZoneFields::ZoneCoolingSizingFactor);
        if( value )
        {
            sizingZone.setZoneCoolingSizingFactor(value.get());
        }

        // CoolingDesignAirFlowMethod

        s = workspaceObject.getString(Sizing_ZoneFields::CoolingDesignAirFlowMethod);
        if( s )
        {
            sizingZone.setCoolingDesignAirFlowMethod(s.get());
        }

        // CoolingDesignAirFlowRate

        value = workspaceObject.getDouble(Sizing_ZoneFields::CoolingDesignAirFlowRate);
        if( value )
        {
            sizingZone.setCoolingDesignAirFlowRate(value.get());
        }

        // CoolingMinimumAirFlowperZoneFloorArea

        value = workspaceObject.getDouble(Sizing_ZoneFields::CoolingMinimumAirFlowperZoneFloorArea);
        if( value )
        {
            sizingZone.setCoolingMinimumAirFlowperZoneFloorArea(value.get());
        }

        // CoolingMinimumAirFlow

        value = workspaceObject.getDouble(Sizing_ZoneFields::CoolingMinimumAirFlow);
        if( value )
        {
            sizingZone.setCoolingMinimumAirFlow(value.get());
        }

        // CoolingMinimumAirFlowFraction

        value = workspaceObject.getDouble(Sizing_ZoneFields::CoolingMinimumAirFlowFraction);
        if( value )
        {
            sizingZone.setCoolingMinimumAirFlowFraction(value.get());
        }

        // HeatingDesignAirFlowMethod

        s = workspaceObject.getString(Sizing_ZoneFields::HeatingDesignAirFlowMethod);
        if( s )
        {
            sizingZone.setHeatingDesignAirFlowMethod(s.get());
        }

        // HeatingDesignAirFlowRate

        value = workspaceObject.getDouble(Sizing_ZoneFields::HeatingDesignAirFlowRate);
        if( value )
        {
            sizingZone.setHeatingDesignAirFlowRate(value.get());
        }

        // HeatingMaximumAirFlowperZoneFloorArea

        value = workspaceObject.getDouble(Sizing_ZoneFields::HeatingMaximumAirFlowperZoneFloorArea);
        if( value )
        {
            sizingZone.setHeatingMaximumAirFlowperZoneFloorArea(value.get());
        }

        // HeatingMaximumAirFlow

        value = workspaceObject.getDouble(Sizing_ZoneFields::HeatingMaximumAirFlow);
        if( value )
        {
            sizingZone.setHeatingMaximumAirFlow(value.get());
        }

        // HeatingMaximumAirFlowFraction

        value = workspaceObject.getDouble(Sizing_ZoneFields::HeatingMaximumAirFlowFraction);
        if( value )
        {
            sizingZone.setHeatingMaximumAirFlowFraction(value.get());
        }

        //DesignSpecification_ZoneAirDistribution

        boost::optional<WorkspaceObject> _designSpecification
            = workspaceObject.getTarget(Sizing_ZoneFields::DesignSpecificationZoneAirDistributionObjectName);

        if( _designSpecification )
        {
            // ZoneAirDistributionEffectivenessinCoolingMode

            value = _designSpecification->getDouble(
                        DesignSpecification_ZoneAirDistributionFields::ZoneAirDistributionEffectivenessinCoolingMode);
            if( value )
            {
                sizingZone.setDesignZoneAirDistributionEffectivenessinCoolingMode(value.get());
            }

            // ZoneAirDistributionEffectivenessinHeatingMode

            value = _designSpecification->getDouble(
                        DesignSpecification_ZoneAirDistributionFields::ZoneAirDistributionEffectivenessinHeatingMode);
            if( value )
            {
                sizingZone.setDesignZoneAirDistributionEffectivenessinHeatingMode(value.get());
            }
        }

    }

    return result;
}