当前位置: 首页>>代码示例>>C++>>正文


C++ OptionalString类代码示例

本文整理汇总了C++中OptionalString的典型用法代码示例。如果您正苦于以下问题:C++ OptionalString类的具体用法?C++ OptionalString怎么用?C++ OptionalString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了OptionalString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getString

 std::string EnergyManagementSystemProgramCallingManager_Impl::callingPoint() const {
   OptionalString results = getString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint,true);
   if (results) {
     return results.get();
   }
   return "";
 }
开发者ID:chlimit,项目名称:OpenStudio,代码行数:7,代码来源:EnergyManagementSystemProgramCallingManager.cpp

示例2: isEmpty

bool IdfExtensibleGroup::isEmpty(unsigned fieldIndex) const
{
  OptionalString test = this->getString(fieldIndex, false);
  if (!test || test.get() == ""){
    return true;
  }
  return false;
}
开发者ID:ChengXinDL,项目名称:OpenStudio,代码行数:8,代码来源:IdfExtensibleGroup.cpp

示例3: majorMinorBuildRegex

  void WeatherFileFinder::extractDetails(
      const IdfFile &t_idffile,
      ToolVersion &t_version,
      boost::optional<std::string> &t_filelocationname,
      boost::optional<std::string> &t_weatherfilename)
  {
    IdfObjectVector versionObjects = t_idffile.getObjectsByType(IddObjectType::Version);
    if(versionObjects.size() == 1){
      OptionalString version = versionObjects[0].getString(VersionFields::VersionIdentifier, true);
      if (version){
        boost::regex majorMinorBuildRegex("^(\\d*?)\\.(\\d*?)\\.(\\d*?)$");
        boost::regex majorMinorRegex("^(\\d*?)\\.(\\d*?)$");
        boost::regex majorRegex("^(\\d*?)$");

        boost::smatch matches;
        if (boost::regex_search(*version, matches, majorMinorBuildRegex)){
          unsigned major = boost::lexical_cast<unsigned>(std::string(matches[1].first, matches[1].second));
          unsigned minor = boost::lexical_cast<unsigned>(std::string(matches[2].first, matches[2].second));
          unsigned build = boost::lexical_cast<unsigned>(std::string(matches[3].first, matches[3].second));
          t_version = ToolVersion(major, minor, build);
        }else if(boost::regex_search(*version, matches, majorMinorRegex)){
          unsigned major = boost::lexical_cast<unsigned>(std::string(matches[1].first, matches[1].second));
          unsigned minor = boost::lexical_cast<unsigned>(std::string(matches[2].first, matches[2].second));
          t_version = ToolVersion(major, minor);
        }else if(boost::regex_search(*version, matches, majorRegex)){
          unsigned major = boost::lexical_cast<unsigned>(std::string(matches[1].first, matches[1].second));
          t_version = ToolVersion(major);
        }
      }
    }

    IdfObjectVector locationObjects = t_idffile.getObjectsByType(IddObjectType::Site_Location);
    if(locationObjects.size() == 1){
      OptionalString locationname = locationObjects[0].getString(Site_LocationFields::Name, true);
      if (locationname && !locationname->empty()){
        LOG(Debug, "Location name field from IDF: " << *locationname);
        t_filelocationname = locationname;
      }
    }

    std::string header = t_idffile.header();
    std::vector<std::string> headerlines;
    boost::split(headerlines, header, boost::is_any_of("\n\r"), boost::algorithm::token_compress_on);
    for (std::vector<std::string>::const_iterator itr = headerlines.begin();
         itr != headerlines.end();
         ++itr)
    {
      boost::smatch matches;
     
      if (boost::regex_match(*itr, matches, boost::regex(".*!\\s+WeatherFileName=(.*)"),boost::regex_constants::match_all))
      {
        std::string match = matches[1];
        t_weatherfilename = match;
        break;
      }
    }
  }
开发者ID:ChengXinDL,项目名称:OpenStudio,代码行数:57,代码来源:WeatherFileFinder.cpp

示例4: TEST_F

TEST_F(DataFixture, Attribute_DisplayName) {
  Attribute attribute("WWR",0.23);
  OptionalString displayName = attribute.displayName();
  EXPECT_FALSE(displayName);
  displayName = attribute.displayName(true);
  ASSERT_TRUE(displayName);
  EXPECT_EQ("WWR",displayName.get());
  attribute.setDisplayName("Window-to-wall ratio (ratio of fenestration area to gross surface area).");
  displayName = attribute.displayName(true);
  ASSERT_TRUE(displayName);
  EXPECT_NE("WWR",displayName.get());
}
开发者ID:Anto-F,项目名称:OpenStudio,代码行数:12,代码来源:Attribute_GTest.cpp

示例5: TEST_F

TEST_F(ModelFixture, ComponentWatcher_BadComponentDataFromWorkspace) {
  Workspace ws;
  OptionalWorkspaceObject owo = ws.addObject(IdfObject(IddObjectType::OS_ComponentData));
  ASSERT_TRUE(owo);
  // make component data ok except points to non-existent object
  WorkspaceObject cd = *owo;
  OptionalString oName = cd.name(); // should have been set by constructor
  ASSERT_TRUE(oName);
  EXPECT_FALSE(oName->empty());
  cd.setString(OS_ComponentDataFields::UUID,toString(createUUID()));
  cd.setString(OS_ComponentDataFields::VersionUUID,toString(createUUID()));
  StringVector values;
  values.push_back("My Material");
  IdfExtensibleGroup eg = cd.pushExtensibleGroup(values);
  EXPECT_TRUE(eg.empty()); // Cannot register a bad pointer.

  EXPECT_EQ(1u,ws.numObjects());
  Model model(ws);
  // expect ComponentWatcher creation to kick out ComponentData
  EXPECT_EQ(0u,model.numObjects());
}
开发者ID:Anto-F,项目名称:OpenStudio,代码行数:21,代码来源:Component_GTest.cpp

示例6: idfObject

boost::optional<IdfObject> ForwardTranslator::translateDaylightingDeviceShelf( model::DaylightingDeviceShelf & modelObject )
{
  IdfObject idfObject(openstudio::IddObjectType::DaylightingDevice_Shelf);

  m_idfObjects.push_back(idfObject);

  idfObject.setString(DaylightingDevice_ShelfFields::Name, modelObject.name().get());

  OptionalString s = modelObject.getString(OS_DaylightingDevice_ShelfFields::WindowName, false, true);
  if (s){
    idfObject.setString(DaylightingDevice_ShelfFields::WindowName, *s);
  }else{
    LOG(Error, "Missing required input 'Window Name' for DaylightingDevice:Shelf named '" << modelObject.name().get() << "'");
  }

  // TODO: make sure inside shelf is converted to a surface
  s = modelObject.getString(OS_DaylightingDevice_ShelfFields::InsideShelfName, false, true);
  if (s){
    idfObject.setString(DaylightingDevice_ShelfFields::InsideShelfName, *s);
  }

  s = modelObject.getString(OS_DaylightingDevice_ShelfFields::OutsideShelfName, false, true);
  if (s){
    idfObject.setString(DaylightingDevice_ShelfFields::OutsideShelfName, *s);
  }

  // TODO: map construction from shading surface
  s.reset();
  if (s){
    idfObject.setString(DaylightingDevice_ShelfFields::OutsideShelfConstructionName, *s);
  }

  OptionalDouble d = modelObject.getDouble(OS_DaylightingDevice_ShelfFields::ViewFactortoOutsideShelf, false);
  if (d){
    idfObject.setDouble(DaylightingDevice_ShelfFields::ViewFactortoOutsideShelf, *d);
  }

  return boost::none;
}
开发者ID:ORNL-BTRIC,项目名称:OpenStudio,代码行数:39,代码来源:ForwardTranslateDaylightingDeviceShelf.cpp

示例7: TEST_F

TEST_F(IdfFixture, IdfObject_StringFieldGetterWithReturnDefaultOption) {
  // NON-EXTENSIBLE OBJECT
  std::stringstream text;
  text << "Refrigeration:Condenser:AirCooled," << std::endl
       << "  MyCondenser," << std::endl
       << "  ," << std::endl
       << "  ," << std::endl // default is 0.0
       << "  ," << std::endl // default is "Fixed"
       << "  125.0;";        // default is 250.0
                             // default is 0.2
                             //
                             // default is "General"
                             // default is 0.0
                             // default is 0.0
                             // default is 0.0
  OptionalIdfObject oObj = IdfObject::load(text.str());
  ASSERT_TRUE(oObj);
  IdfObject object = *oObj;

  // returns set values
  OptionalString idfField = object.getString(0,true);
  ASSERT_TRUE(idfField);
  EXPECT_EQ("MyCondenser",*idfField);
  idfField = object.getString(1,true);
  ASSERT_TRUE(idfField);
  EXPECT_EQ("",*idfField);
  idfField = object.getString(4,true);
  ASSERT_TRUE(idfField);
  EXPECT_EQ("125.0",*idfField);

  // returns default for fields behind fields with set values
  idfField = object.getString(2,true);
  ASSERT_TRUE(idfField);
  EXPECT_EQ("0.0",*idfField);
  idfField = object.getString(3,true);
  ASSERT_TRUE(idfField);
  EXPECT_EQ("Fixed",*idfField);

  // returns default for non-existent fields
  idfField = object.getString(6,true);
  EXPECT_FALSE(idfField);
  idfField = object.getString(7,true);
  ASSERT_TRUE(idfField);
  EXPECT_EQ("General",*idfField);
  idfField = object.getString(8,true);
  ASSERT_TRUE(idfField);
  EXPECT_EQ("0.0",*idfField);
  idfField = object.getString(10,true);
  ASSERT_TRUE(idfField);
  EXPECT_EQ("0.0",*idfField);
  idfField = object.getString(11,true);
  EXPECT_FALSE(idfField);

  // EXTENSIBLE OBJECT
  text.str("");
  text << "DaylightingDevice:Tubular," << std::endl
       << "  MyTDD," << std::endl
       << "  MyDome," << std::endl
       << "  MyDiffuser," << std::endl
       << "  MyConstruction," << std::endl
       << "  1.0," << std::endl
       << "  2.0;";
       // \default 0.28
       // Transition Zone 1 Name
       // Transition Zone 1 Length
       // ... (extensible 2)
  oObj = IdfObject::load(text.str());
  ASSERT_TRUE(oObj);
  object = *oObj;
  EXPECT_EQ(6u,object.numFields());

  // returns set values
  idfField = object.getString(0,true);
  ASSERT_TRUE(idfField);
  EXPECT_EQ("MyTDD",*idfField);
  idfField = object.getString(5,true);
  ASSERT_TRUE(idfField);
  EXPECT_EQ("2.0",*idfField);

  // returns default for non-existent, non-extensible fields
  idfField = object.getString(6,true);
  ASSERT_TRUE(idfField);
  EXPECT_EQ("0.28",*idfField);
  EXPECT_EQ(6u,object.numFields());
  idfField = object.getString(6);
  EXPECT_FALSE(idfField);

  StringVector newGroup;
  newGroup.push_back("MyFirstTransistionZone");
  newGroup.push_back("1.5");
  ASSERT_FALSE(object.pushExtensibleGroup(newGroup).empty());

  // returns default for fields behind fields with set values
  idfField = object.getString(6,true);
  ASSERT_TRUE(idfField);
  EXPECT_EQ("0.28",*idfField);
  idfField = object.getString(6);
  ASSERT_TRUE(idfField);
  EXPECT_TRUE(idfField->empty());

//.........这里部分代码省略.........
开发者ID:ChengXinDL,项目名称:OpenStudio,代码行数:101,代码来源:IdfObject_GTest.cpp

示例8: idfObject

boost::optional<IdfObject> ForwardTranslator::translateTableMultiVariableLookup( TableMultiVariableLookup& modelObject )
{
  OptionalString s;
  OptionalDouble d;
  OptionalModelObject temp;
  OptionalInt n;  

  // Create a new IddObjectType::Table_MultiVariableLookup
  IdfObject idfObject(IddObjectType::Table_MultiVariableLookup);

  m_idfObjects.push_back(idfObject);

  // Name
  s = modelObject.name();
  if(s)
  {
    idfObject.setName(*s);
  }

  // InterpolationMethod
  if( (s = modelObject.interpolationMethod()) )
  {
    idfObject.setString(Table_MultiVariableLookupFields::InterpolationMethod,s.get());
  }

  // NumberofInterpolationPoints
  if( (n = modelObject.numberofInterpolationPoints()) )
  {
    idfObject.setInt(Table_MultiVariableLookupFields::NumberofInterpolationPoints,n.get());
  }

  // CurveType
  if( (s = modelObject.curveType()) )
  {
    idfObject.setString(Table_MultiVariableLookupFields::CurveType,s.get());
  }
  
  // TableDataFormat
  if( (s = modelObject.tableDataFormat()) )
  {
    idfObject.setString(Table_MultiVariableLookupFields::TableDataFormat,s.get());
  }

  // ExternalFileName
  // Not supported
  
  // X1SortOrder
  idfObject.setString(Table_MultiVariableLookupFields::X1SortOrder,"Ascending");
  
  // X2SortOrder
  idfObject.setString(Table_MultiVariableLookupFields::X2SortOrder,"Ascending");
  
  // NormalizationReference
  if( (d = modelObject.normalizationReference()) )
  {
    idfObject.setDouble(Table_MultiVariableLookupFields::NormalizationReference,d.get());
  }
  
  // MinimumValueofX1
  if( (d = modelObject.minimumValueofX1()) )
  {
    idfObject.setDouble(Table_MultiVariableLookupFields::MinimumValueofX1,d.get());
  }
  
  // MaximumValueofX1
  if( (d = modelObject.maximumValueofX1()) )
  {
    idfObject.setDouble(Table_MultiVariableLookupFields::MaximumValueofX1,d.get());
  }
  
  // MinimumValueofX2
  if( (d = modelObject.minimumValueofX2()) )
  {
    idfObject.setDouble(Table_MultiVariableLookupFields::MinimumValueofX2,d.get());
  }
  
  // MaximumValueofX2
  if( (d = modelObject.maximumValueofX2()) )
  {
    idfObject.setDouble(Table_MultiVariableLookupFields::MaximumValueofX2,d.get());
  }
  
  // MinimumValueofX3
  if( (d = modelObject.minimumValueofX3()) )
  {
    idfObject.setDouble(Table_MultiVariableLookupFields::MinimumValueofX3,d.get());
  }
  
  // MaximumValueofX3
  if( (d = modelObject.maximumValueofX3()) )
  {
    idfObject.setDouble(Table_MultiVariableLookupFields::MaximumValueofX3,d.get());
  }
  
  // MinimumValueofX4
  if( (d = modelObject.minimumValueofX4()) )
  {
    idfObject.setDouble(Table_MultiVariableLookupFields::MinimumValueofX4,d.get());
  }
  
//.........这里部分代码省略.........
开发者ID:jtanaa,项目名称:OpenStudio,代码行数:101,代码来源:ForwardTranslateTableMultiVariableLookup.cpp

示例9: LOG

OptionalModelObject ReverseTranslator::translateEnergyManagementSystemSubroutine(const WorkspaceObject & workspaceObject)
{
  if (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_Subroutine) {
    LOG(Error, "WorkspaceObject is not IddObjectType: EnergyManagementSystem_Subroutine");
    return boost::none;
  }

  OptionalString s = workspaceObject.getString(EnergyManagementSystem_SubroutineFields::Name);
  if (!s) {
    LOG(Error, "WorkspaceObject EnergyManagementSystem_Subroutine has no Name");
    return boost::none;
  }

  // Make sure we translate the objects that can be referenced here
  for (const WorkspaceObject& workspaceObject : m_workspace.objects()) {

    // Note: JM 2018-08-17
    // I think an EMS:Subroutine can reference another EMS:Subroutine, we might get problems from that:
    // The one that is being referenced would need be translated before the one that references before the name/uuid substitution happen.
    // But it's harder to control that order*, and this is really an edge case though, so not handling it.
    // * Can't add this condition without getting into a loop:
    // (workspaceObject.iddObject().type() == IddObjectType::EnergyManagementSystem_Subroutine)
    if (
        // These I'm sure we do need.
        (workspaceObject.iddObject().type() == IddObjectType::EnergyManagementSystem_Actuator)
        || (workspaceObject.iddObject().type() == IddObjectType::EnergyManagementSystem_Sensor)
        || (workspaceObject.iddObject().type() == IddObjectType::EnergyManagementSystem_ConstructionIndexVariable)
        || (workspaceObject.iddObject().type() == IddObjectType::EnergyManagementSystem_CurveOrTableIndexVariable)
        || (workspaceObject.iddObject().type() == IddObjectType::EnergyManagementSystem_GlobalVariable)
        || (workspaceObject.iddObject().type() == IddObjectType::EnergyManagementSystem_InternalVariable)
        || (workspaceObject.iddObject().type() == IddObjectType::EnergyManagementSystem_TrendVariable)
       ) {
      translateAndMapWorkspaceObject(workspaceObject);
    }
  }
  openstudio::model::EnergyManagementSystemSubroutine emsProgram(m_model);
  emsProgram.setName(*s);

  // Get all model objects that can be referenced int he EMS Program so we can do name / uid substitution
  const std::vector<IddObjectType> validIddObjectTypes{
    IddObjectType::OS_EnergyManagementSystem_Subroutine,
    IddObjectType::OS_EnergyManagementSystem_Actuator,
    IddObjectType::OS_EnergyManagementSystem_Sensor,
    IddObjectType::OS_EnergyManagementSystem_ConstructionIndexVariable,
    IddObjectType::OS_EnergyManagementSystem_CurveOrTableIndexVariable,
    IddObjectType::OS_EnergyManagementSystem_GlobalVariable,
    IddObjectType::OS_EnergyManagementSystem_InternalVariable,
    IddObjectType::OS_EnergyManagementSystem_TrendVariable
  };

  std::vector<model::ModelObject> modelObjects;
  for (const model::ModelObject& mo: m_model.modelObjects()) {
    if( std::find(validIddObjectTypes.begin(), validIddObjectTypes.end(), mo.iddObjectType()) != validIddObjectTypes.end() ) {
      modelObjects.push_back(mo);
    }
  }


  // Now, we should do the actual name/uid substitution on all lines of the program

  size_t pos, len;
  std::string newline, uid;

  unsigned n = workspaceObject.numExtensibleGroups();
  OptionalString line;

  // Loop on each line of the program
  for (unsigned i = 0; i < n; ++i) {
    line = workspaceObject.getExtensibleGroup(i).cast<WorkspaceExtensibleGroup>().getString(EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine);
    if (line) {
      newline = line.get();

      // Split line to get 'tokens' and look for ModelObject names
      // splitEMSLineToTokens returns already sanitized tokens (excludes reserved keywords, blank ones, functions, removes parenthesis, etc)
      std::vector<std::string> tokens = splitEMSLineToTokens(newline);

      for (std::string& token: tokens) {
        for (const model::ModelObject& mo: modelObjects) {
          // Check if program item is the name of a model object
          boost::optional<std::string> _name = mo.name();
          if ( _name && (_name.get() == token) ) {
            // replace model object's name with its handle
            pos = newline.find(token);
            len = token.length();
            uid = toString(mo.handle());
            newline.replace(pos, len, uid);
            // Now that we have done the replacement, no need to keep looping.
            // Plus, we should break out of the nested loop and go to the next "j"
            // Otherwise pos could become giberish if there's another object named the same
            // since it won't be able to find the already-replaced string (this shouldn't happen though)
            break;
          }
        } // end loop on all modelObjects

      } // end loop on all results in line
      emsProgram.addLine(newline);
    } // end if(line)
  } // End loop on each line of the program

  return emsProgram;
//.........这里部分代码省略.........
开发者ID:NREL,项目名称:OpenStudio,代码行数:101,代码来源:ReverseTranslateEnergyManagementSystemSubroutine.cpp

示例10: idfObject

boost::optional<IdfObject> ForwardTranslator::translateControllerOutdoorAir( ControllerOutdoorAir& modelObject )
{
  OptionalString s;
  OptionalDouble d;

  // Create a new IddObjectType::AirLoopHVAC_OutdoorAirSystem
  IdfObject idfObject(IddObjectType::Controller_OutdoorAir);

  m_idfObjects.push_back(idfObject);

  ///////////////////////////////////////////////////////////////////////////
  // Field: Name ////////////////////////////////////////////////////////////
  s = modelObject.name();
  if(s)
  {
    idfObject.setString(openstudio::Controller_OutdoorAirFields::Name,*s);
  }
  ///////////////////////////////////////////////////////////////////////////
  // Field: Relief Air Outlet Node Name /////////////////////////////////////
  s = modelObject.airLoopHVACOutdoorAirSystem()->reliefAirModelObject()->name();
  if(s)
  {
    idfObject.setString( openstudio::Controller_OutdoorAirFields::ReliefAirOutletNodeName,*s );
  }

  ///////////////////////////////////////////////////////////////////////////
  // Field: Return Air Outlet Node Name /////////////////////////////////////
  s = modelObject.airLoopHVACOutdoorAirSystem()->returnAirModelObject()->name();
  if(s)
  {
    idfObject.setString( openstudio::Controller_OutdoorAirFields::ReturnAirNodeName,*s );
  }

  ///////////////////////////////////////////////////////////////////////////
  // Field: Mixed Air Outlet Node Name //////////////////////////////////////
  s = modelObject.airLoopHVACOutdoorAirSystem()->mixedAirModelObject()->name();
  if(s)
  {
    idfObject.setString( openstudio::Controller_OutdoorAirFields::MixedAirNodeName,*s );
  }

  ///////////////////////////////////////////////////////////////////////////
  // Field: Actuator Node Name //////////////////////////////////////////////
  s = modelObject.airLoopHVACOutdoorAirSystem()->outboardOANode()->name();
  if(s)
  {
    idfObject.setString( openstudio::Controller_OutdoorAirFields::ActuatorNodeName,*s );
  }

  ///////////////////////////////////////////////////////////////////////////
  // Field: Minimum Outdoor Air Flow Rate ///////////////////////////////////
  if( modelObject.controllerMechanicalVentilation().demandControlledVentilation() )
  {
    idfObject.setDouble(openstudio::Controller_OutdoorAirFields::MinimumOutdoorAirFlowRate,0.0);
  }
  else
  {
    d = modelObject.minimumOutdoorAirFlowRate();
    if(d)
    {
      idfObject.setDouble(openstudio::Controller_OutdoorAirFields::MinimumOutdoorAirFlowRate,*d);
    }
    else
    {
      idfObject.setString(openstudio::Controller_OutdoorAirFields::MinimumOutdoorAirFlowRate,"Autosize");
    }
  }

  ///////////////////////////////////////////////////////////////////////////
  // Field: Maximum Outdoor Air Flow Rate ///////////////////////////////////
  d = modelObject.maximumOutdoorAirFlowRate();
  if(d)
  {
    idfObject.setDouble(openstudio::Controller_OutdoorAirFields::MaximumOutdoorAirFlowRate,*d);
  }
  else
  {
    idfObject.setString(openstudio::Controller_OutdoorAirFields::MaximumOutdoorAirFlowRate,"Autosize");
  }

  ///////////////////////////////////////////////////////////////////////////
  // Field: Economizer Control Type /////////////////////////////////////////
  idfObject.setString(openstudio::Controller_OutdoorAirFields::EconomizerControlType,
                      modelObject.getEconomizerControlType());

  ///////////////////////////////////////////////////////////////////////////
  // Field: Economizer Control Action Type //////////////////////////////////
  idfObject.setString(openstudio::Controller_OutdoorAirFields::EconomizerControlActionType,
                      modelObject.getEconomizerControlActionType());

  ///////////////////////////////////////////////////////////////////////////
  // Field: Economizer Maximum Limit DryBulb Temperature ////////////////////
  d = modelObject.getEconomizerMaximumLimitDryBulbTemperature();
  if (d){
    idfObject.setDouble(openstudio::Controller_OutdoorAirFields::EconomizerMaximumLimitDryBulbTemperature,d.get());
    }
  else {
    idfObject.setString(openstudio::Controller_OutdoorAirFields::EconomizerMaximumLimitDryBulbTemperature, "");
  }

//.........这里部分代码省略.........
开发者ID:ORNL-BTRIC,项目名称:OpenStudio,代码行数:101,代码来源:ForwardTranslateControllerOutdoorAir.cpp

示例11: idfObject

boost::optional<IdfObject> ForwardTranslator::translateCoolingTowerVariableSpeed( CoolingTowerVariableSpeed & modelObject )
{
  OptionalString s;
  OptionalDouble d;
  OptionalModelObject temp;

  IdfObject idfObject(IddObjectType::CoolingTower_VariableSpeed);

  m_idfObjects.push_back(idfObject);

  // Name

  s = modelObject.name();
  if(s)
  {
    idfObject.setName(*s);
  }

  // WaterInletNodeName

  temp = modelObject.inletModelObject();
  if(temp)
  {
    idfObject.setString(openstudio::CoolingTower_VariableSpeedFields::WaterInletNodeName,temp->name().get());
  }

  // WaterOutletNodeName

  temp = modelObject.outletModelObject();
  if(temp)
  {
    idfObject.setString(openstudio::CoolingTower_VariableSpeedFields::WaterOutletNodeName,temp->name().get());
  }

  // ModelType

  if( s = modelObject.modelType() )
  {
    idfObject.setString(CoolingTower_VariableSpeedFields::ModelType,s.get());
  }

  // ModelCoefficient

  if( boost::optional<ModelObject> mo = modelObject.modelCoefficient() )
  {
    if( boost::optional<IdfObject> _mo = translateAndMapModelObject(mo.get()) )
    {
      idfObject.setString(CoolingTower_VariableSpeedFields::ModelCoefficientName,_mo->name().get());
    }
  }

  // DesignInletAirWetBulbTemperature

  if( d = modelObject.designInletAirWetBulbTemperature() )
  {
    idfObject.setDouble(CoolingTower_VariableSpeedFields::DesignInletAirWetBulbTemperature,d.get());
  }

  // DesignApproachTemperature

  if( d = modelObject.designApproachTemperature() )
  {
    idfObject.setDouble(CoolingTower_VariableSpeedFields::DesignApproachTemperature,d.get());
  }

  // DesignRangeTemperature
  
  if( d = modelObject.designRangeTemperature() )
  {
    idfObject.setDouble(CoolingTower_VariableSpeedFields::DesignRangeTemperature,d.get());
  }

  // DesignWaterFlowRate 

  if( (d = modelObject.designWaterFlowRate()) )
  {
    idfObject.setDouble(openstudio::CoolingTower_VariableSpeedFields::DesignWaterFlowRate,d.get());
  }
  else if( modelObject.isDesignAirFlowRateAutosized() )
  {
    idfObject.setString(openstudio::CoolingTower_VariableSpeedFields::DesignWaterFlowRate,"Autosize");
  }

  // DesignAirFlowRate 

  if( (d = modelObject.designAirFlowRate()) )
  {
    idfObject.setDouble(openstudio::CoolingTower_VariableSpeedFields::DesignAirFlowRate,d.get());
  }
  else if( modelObject.isDesignAirFlowRateAutosized() )
  {
    idfObject.setString(openstudio::CoolingTower_VariableSpeedFields::DesignAirFlowRate,"Autosize");
  }

  // DesignFanPower

  if( d = modelObject.designFanPower() )
  {
    idfObject.setDouble(CoolingTower_VariableSpeedFields::DesignFanPower,d.get());
  }
//.........这里部分代码省略.........
开发者ID:CraigCasey,项目名称:OpenStudio,代码行数:101,代码来源:ForwardTranslateCoolingTowerVariableSpeed.cpp

示例12: LOG

OptionalModelObject ReverseTranslator::translateZoneMixing( const WorkspaceObject & workspaceObject )
{
  if( workspaceObject.iddObject().type() != IddObjectType::ZoneMixing ){
    LOG(Error, "WorkspaceObject is not IddObjectType: ZoneMixing");
    return boost::none;
  }

  OptionalWorkspaceObject target = workspaceObject.getTarget(openstudio::ZoneMixingFields::ZoneName);
  OptionalThermalZone zone;
  if (target){
    OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
    if (modelObject){
      zone = modelObject->optionalCast<ThermalZone>();
    }
  }
  
  if (!zone){
    return boost::none;
  }

  openstudio::model::ZoneMixing mixing(*zone);
  
  OptionalString s = workspaceObject.name();
  if(s){
    mixing.setName(*s);
  }

  target = workspaceObject.getTarget(openstudio::ZoneMixingFields::ScheduleName);
  if (target){
    OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
    if (modelObject){
      if (auto s = modelObject->optionalCast<Schedule>()){
        mixing.setSchedule(s.get());
      }
    }
  }

  s = workspaceObject.getString(openstudio::ZoneMixingFields::DesignFlowRateCalculationMethod, true);
  OS_ASSERT(s);

  OptionalDouble d;
  if (istringEqual("Flow/Zone", *s)){
    d = workspaceObject.getDouble(openstudio::ZoneMixingFields::DesignFlowRate);
    if (d){
      mixing.setDesignFlowRate(*d);
    } else{
      LOG(Error, "Flow/Zone value not found for workspace object " << workspaceObject);
    }
  } else if (istringEqual("Flow/Area", *s)){
    d = workspaceObject.getDouble(openstudio::ZoneMixingFields::FlowRateperZoneFloorArea);
    if (d){
      mixing.setFlowRateperZoneFloorArea(*d);
    } else{
      LOG(Error, "Flow/Area value not found for workspace object " << workspaceObject);
    }
  } else if (istringEqual("Flow/Person", *s)){
    d = workspaceObject.getDouble(openstudio::ZoneMixingFields::FlowRateperPerson);
    if (d){
      mixing.setFlowRateperPerson(*d);
    } else{
      LOG(Error, "Flow/Person value not found for workspace object " << workspaceObject);
    }
  } else if (istringEqual("AirChanges/Hour", *s)){
    d = workspaceObject.getDouble(openstudio::ZoneMixingFields::AirChangesperHour);
    if (d){
      mixing.setAirChangesperHour(*d);
    } else{
      LOG(Error, "AirChanges/Hour value not found for workspace object " << workspaceObject);
    }
  } else{
    LOG(Error, "Unknown DesignFlowRateCalculationMethod value for workspace object" << workspaceObject);
  }

  target = workspaceObject.getTarget(openstudio::ZoneMixingFields::SourceZoneName);
  if (target){
    OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
    if (modelObject){
      if (modelObject->optionalCast<ThermalZone>()){
        mixing.setSourceZone(modelObject->cast<ThermalZone>());
      }
    }
  }

  d = workspaceObject.getDouble(openstudio::ZoneMixingFields::DeltaTemperature);
  if (d){
    mixing.setDeltaTemperature(*d);
  }

  target = workspaceObject.getTarget(openstudio::ZoneMixingFields::DeltaTemperatureScheduleName);
  if (target){
    OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
    if (modelObject){
      if (auto s = modelObject->optionalCast<Schedule>()){
        mixing.setDeltaTemperatureSchedule(s.get());
      }
    }
  }

  target = workspaceObject.getTarget(openstudio::ZoneMixingFields::MinimumZoneTemperatureScheduleName);
  if (target){
//.........这里部分代码省略.........
开发者ID:jtanaa,项目名称:OpenStudio,代码行数:101,代码来源:ReverseTranslateZoneMixing.cpp

示例13: if

boost::optional<IdfObject> ForwardTranslator::translateChillerHeaterPerformanceElectricEIR( ChillerHeaterPerformanceElectricEIR & modelObject )
{
  OptionalString s;
  OptionalDouble value;
  OptionalModelObject temp;

  // Name
  IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::ChillerHeaterPerformance_Electric_EIR, modelObject);

  // ReferenceCoolingModeEvaporatorCapacity
  if( modelObject.isReferenceCoolingModeEvaporatorCapacityAutosized() ) {
    idfObject.setString(ChillerHeaterPerformance_Electric_EIRFields::ReferenceCoolingModeEvaporatorCapacity,"Autosize");
  }
  else if( (value = modelObject.referenceCoolingModeEvaporatorCapacity()) ) {
    idfObject.setDouble(ChillerHeaterPerformance_Electric_EIRFields::ReferenceCoolingModeEvaporatorCapacity,value.get()); 
  }

  // ReferenceCoolingModeCOP
  if( (value = modelObject.referenceCoolingModeCOP()) ) {
    idfObject.setDouble(ChillerHeaterPerformance_Electric_EIRFields::ReferenceCoolingModeCOP,value.get()); 
  }

  // ReferenceCoolingModeLeavingChilledWaterTemperature
  if( (value = modelObject.referenceCoolingModeLeavingChilledWaterTemperature()) ) {
    idfObject.setDouble(ChillerHeaterPerformance_Electric_EIRFields::ReferenceCoolingModeLeavingChilledWaterTemperature,value.get()); 
  }

  // ReferenceCoolingModeEnteringCondenserFluidTemperature
  if( (value = modelObject.referenceCoolingModeEnteringCondenserFluidTemperature()) ) {
    idfObject.setDouble(ChillerHeaterPerformance_Electric_EIRFields::ReferenceCoolingModeEnteringCondenserFluidTemperature,value.get()); 
  }

  // ReferenceCoolingModeLeavingCondenserWaterTemperature
  if( (value = modelObject.referenceCoolingModeLeavingCondenserWaterTemperature()) ) {
    idfObject.setDouble(ChillerHeaterPerformance_Electric_EIRFields::ReferenceCoolingModeLeavingCondenserWaterTemperature,value.get()); 
  }

  // ReferenceHeatingModeCoolingCapacityRatio
  if( (value = modelObject.referenceHeatingModeCoolingCapacityRatio()) ) {
    idfObject.setDouble(ChillerHeaterPerformance_Electric_EIRFields::ReferenceHeatingModeCoolingCapacityRatio,value.get()); 
  }

  // ReferenceHeatingModeCoolingPowerInputRatio
  if( (value = modelObject.referenceHeatingModeCoolingPowerInputRatio()) ) {
    idfObject.setDouble(ChillerHeaterPerformance_Electric_EIRFields::ReferenceHeatingModeCoolingPowerInputRatio,value.get()); 
  }

  // ReferenceHeatingModeLeavingChilledWaterTemperature
  if( (value = modelObject.referenceHeatingModeLeavingChilledWaterTemperature()) ) {
    idfObject.setDouble(ChillerHeaterPerformance_Electric_EIRFields::ReferenceHeatingModeLeavingChilledWaterTemperature,value.get()); 
  }

  // ReferenceHeatingModeLeavingCondenserWaterTemperature
  if( (value = modelObject.referenceHeatingModeLeavingCondenserWaterTemperature()) ) {
    idfObject.setDouble(ChillerHeaterPerformance_Electric_EIRFields::ReferenceHeatingModeLeavingCondenserWaterTemperature,value.get()); 
  }

  // ReferenceHeatingModeEnteringCondenserFluidTemperature
  if( (value = modelObject.referenceHeatingModeEnteringCondenserFluidTemperature()) ) {
    idfObject.setDouble(ChillerHeaterPerformance_Electric_EIRFields::ReferenceHeatingModeEnteringCondenserFluidTemperature,value.get()); 
  }

  // HeatingModeEnteringChilledWaterTemperatureLowLimit
  if( (value = modelObject.heatingModeEnteringChilledWaterTemperatureLowLimit()) ) {
    idfObject.setDouble(ChillerHeaterPerformance_Electric_EIRFields::HeatingModeEnteringChilledWaterTemperatureLowLimit,value.get()); 
  }

  // ChilledWaterFlowModeType
  if( (s = modelObject.chilledWaterFlowModeType()) ) {
    idfObject.setString(ChillerHeaterPerformance_Electric_EIRFields::ChilledWaterFlowModeType,s.get()); 
  }

  // DesignChilledWaterFlowRate
  if( modelObject.isDesignChilledWaterFlowRateAutosized() ) {
    idfObject.setString(ChillerHeaterPerformance_Electric_EIRFields::DesignChilledWaterFlowRate,"Autosize");
  }
  else if( (value = modelObject.designChilledWaterFlowRate()) ) {
    idfObject.setDouble(ChillerHeaterPerformance_Electric_EIRFields::DesignChilledWaterFlowRate,value.get()); 
  }

  // DesignCondenserWaterFlowRate
  if( modelObject.isDesignCondenserWaterFlowRateAutosized() ) {
    idfObject.setString(ChillerHeaterPerformance_Electric_EIRFields::DesignCondenserWaterFlowRate,"Autosize");
  }
  else if( (value = modelObject.designCondenserWaterFlowRate()) ) {
    idfObject.setDouble(ChillerHeaterPerformance_Electric_EIRFields::DesignCondenserWaterFlowRate,value.get()); 
  }

  // DesignHotWaterFlowRate
  if( (value = modelObject.designHotWaterFlowRate()) ) {
    idfObject.setDouble(ChillerHeaterPerformance_Electric_EIRFields::DesignHotWaterFlowRate,value.get()); 
  }

  // CompressorMotorEfficiency
  if( (value = modelObject.compressorMotorEfficiency()) ) {
    idfObject.setDouble(ChillerHeaterPerformance_Electric_EIRFields::CompressorMotorEfficiency,value.get()); 
  }

  // CondenserType
  if( (s = modelObject.condenserType()) ) {
//.........这里部分代码省略.........
开发者ID:jtanaa,项目名称:OpenStudio,代码行数:101,代码来源:ForwardTranslateChillerHeaterPerformanceElectricEIR.cpp

示例14: if

boost::optional<IdfObject> ForwardTranslator::translateEvaporativeFluidCoolerTwoSpeed( EvaporativeFluidCoolerTwoSpeed & modelObject )
{
  OptionalString s;
  OptionalDouble d;
  OptionalModelObject temp;
 
  //Name
  IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::EvaporativeFluidCooler_TwoSpeed, modelObject);

  // WaterInletNodeName
  temp = modelObject.inletModelObject();
  if(temp) {
    idfObject.setString(openstudio::EvaporativeFluidCooler_TwoSpeedFields::WaterInletNodeName,temp->name().get());
  }

  // WaterOutletNodeName
  temp = modelObject.outletModelObject();
  if(temp) {
    idfObject.setString(openstudio::EvaporativeFluidCooler_TwoSpeedFields::WaterOutletNodeName,temp->name().get());
  }

  // HighFanSpeedAirFlowRate
  if( modelObject.isHighFanSpeedAirFlowRateAutosized() )
  {
    idfObject.setString(openstudio::EvaporativeFluidCooler_TwoSpeedFields::HighFanSpeedAirFlowRate,"Autosize");
  } 
  else if( (d = modelObject.highFanSpeedAirFlowRate()) )
  {
    idfObject.setDouble(openstudio::EvaporativeFluidCooler_TwoSpeedFields::HighFanSpeedAirFlowRate,d.get());
  }

  // HighFanSpeedFanPower
  if( modelObject.isHighFanSpeedFanPowerAutosized() )
  {
    idfObject.setString(openstudio::EvaporativeFluidCooler_TwoSpeedFields::HighFanSpeedFanPower,"Autosize");
  } 
  else if( (d = modelObject.highFanSpeedFanPower()) )
  {
    idfObject.setDouble(openstudio::EvaporativeFluidCooler_TwoSpeedFields::HighFanSpeedFanPower,d.get());
  }

  // LowFanSpeedAirFlowRate
  if( modelObject.isLowFanSpeedAirFlowRateAutosized() )
  {
    idfObject.setString(openstudio::EvaporativeFluidCooler_TwoSpeedFields::LowFanSpeedAirFlowRate,"Autocalculate");
  } 
  else if( (d = modelObject.lowFanSpeedAirFlowRate()) )
  {
    idfObject.setDouble(openstudio::EvaporativeFluidCooler_TwoSpeedFields::LowFanSpeedAirFlowRate,d.get());
  }

  // LowFanSpeedAirFlowRateSizingFactor
  if( (d = modelObject.lowFanSpeedAirFlowRateSizingFactor()) )
  {
    idfObject.setDouble(openstudio::EvaporativeFluidCooler_TwoSpeedFields::LowFanSpeedAirFlowRateSizingFactor,d.get());
  }

  // LowFanSpeedFanPower
  if( modelObject.isLowFanSpeedFanPowerAutosized() )
  {
    idfObject.setString(openstudio::EvaporativeFluidCooler_TwoSpeedFields::LowFanSpeedFanPower,"Autocalculate");
  } 
  else if( (d = modelObject.lowFanSpeedFanPower()) )
  {
    idfObject.setDouble(openstudio::EvaporativeFluidCooler_TwoSpeedFields::LowFanSpeedFanPower,d.get());
  }

  // LowFanSpeedFanPowerSizingFactor
  if( (d = modelObject.lowFanSpeedFanPowerSizingFactor()) )
  {
    idfObject.setDouble(openstudio::EvaporativeFluidCooler_TwoSpeedFields::LowFanSpeedFanPowerSizingFactor,d.get());
  }

  // DesignSprayWaterFlowRate
  if( (d = modelObject.designSprayWaterFlowRate()) )
  {
    idfObject.setDouble(openstudio::EvaporativeFluidCooler_TwoSpeedFields::DesignSprayWaterFlowRate,d.get());
  }

  // PerformanceInputMethod
  if( (s = modelObject.performanceInputMethod()) )
  {
    idfObject.setString(openstudio::EvaporativeFluidCooler_TwoSpeedFields::PerformanceInputMethod,s.get());
  }

  // OutdoorAirInletNodeName
  idfObject.setString(openstudio::EvaporativeFluidCooler_TwoSpeedFields::OutdoorAirInletNodeName,"");

  // HeatRejectionCapacityandNominalCapacitySizingRatio
  if( (d = modelObject.heatRejectionCapacityandNominalCapacitySizingRatio()) )
  {
    idfObject.setDouble(openstudio::EvaporativeFluidCooler_TwoSpeedFields::HeatRejectionCapacityandNominalCapacitySizingRatio,d.get());
  }

  // HighSpeedStandardDesignCapacity
  if( (d = modelObject.highSpeedStandardDesignCapacity()) )
  {
    idfObject.setDouble(openstudio::EvaporativeFluidCooler_TwoSpeedFields::HighSpeedStandardDesignCapacity,d.get());
  }

//.........这里部分代码省略.........
开发者ID:MatthewSteen,项目名称:OpenStudio,代码行数:101,代码来源:ForwardTranslateEvaporativeFluidCoolerTwoSpeed.cpp

示例15: idfObject

boost::optional<IdfObject> ForwardTranslator::translateEvaporativeFluidCoolerSingleSpeed( EvaporativeFluidCoolerSingleSpeed & modelObject )
{
  OptionalString s;
  OptionalDouble d;
  OptionalModelObject temp;

  // Create a new IddObjectType::Evaporative_FluidCoolerSingleSpeed
  IdfObject idfObject(IddObjectType::EvaporativeFluidCooler_SingleSpeed);

  m_idfObjects.push_back(idfObject);
 
 //Name  
  s = modelObject.name();
  if(s)
  {
    idfObject.setName(*s);
  }

  // WaterInletNodeName

  temp = modelObject.inletModelObject();
  if(temp)
  {
    idfObject.setString(openstudio::EvaporativeFluidCooler_SingleSpeedFields::WaterInletNodeName,temp->name().get());
  }

  // WaterOutletNodeName

  temp = modelObject.outletModelObject();
  if(temp)
  {
    idfObject.setString(openstudio::EvaporativeFluidCooler_SingleSpeedFields::WaterOutletNodeName,temp->name().get());
  }

  
  // DesignAirFlowRate 

  if( (d = modelObject.designAirFlowRate()) )
  {
    idfObject.setDouble(openstudio::EvaporativeFluidCooler_SingleSpeedFields::DesignAirFlowRate,d.get());
  }
  else if( modelObject.isDesignAirFlowRateAutosized() )
  {
    idfObject.setString(openstudio::EvaporativeFluidCooler_SingleSpeedFields::DesignAirFlowRate,"Autosize");
  }
  
   // FanPoweratDesignAirFlowRate
  
  if( (d = modelObject.fanPoweratDesignAirFlowRate()) )
  {
    idfObject.setDouble(openstudio::EvaporativeFluidCooler_SingleSpeedFields::DesignAirFlowRateFanPower,d.get());
  }
  else if( modelObject.isFanPoweratDesignAirFlowRateAutosized() )
  {
    idfObject.setString(openstudio::EvaporativeFluidCooler_SingleSpeedFields::DesignAirFlowRateFanPower,"Autosize");
  }

     
  // DesignWaterFlowRate 

  if( (d = modelObject.designWaterFlowRate()) )
  {
    idfObject.setDouble(openstudio::EvaporativeFluidCooler_SingleSpeedFields::DesignWaterFlowRate,d.get());
  }
  else if( modelObject.isDesignWaterFlowRateAutosized() )
  {
    idfObject.setString(openstudio::EvaporativeFluidCooler_SingleSpeedFields::DesignWaterFlowRate,"Autosize");
  }

  // DesignSprayWaterFlowRate
  
  if( (d = modelObject.designSprayWaterFlowRate()) )
  {
    idfObject.setDouble(openstudio::EvaporativeFluidCooler_SingleSpeedFields::DesignSprayWaterFlowRate,d.get());
  }

  
 // PerformanceInputMethod

  if( (s = modelObject.performanceInputMethod()) )
  {
    idfObject.setString(openstudio::EvaporativeFluidCooler_SingleSpeedFields::PerformanceInputMethod,s.get());
  }
 
// OutdoorAirInletNodeName

  idfObject.setString(openstudio::EvaporativeFluidCooler_SingleSpeedFields::OutdoorAirInletNodeName,"");


// StandardDesignCapacity

   if( (d = modelObject.standardDesignCapacity()) )
  {
    idfObject.setDouble(openstudio::EvaporativeFluidCooler_SingleSpeedFields::StandardDesignCapacity,d.get());
  }
 
  // UFactorTimesAreaValueatDesignAirFlowRate

  if( (d = modelObject.ufactorTimesAreaValueatDesignAirFlowRate()) )
  {
//.........这里部分代码省略.........
开发者ID:jtanaa,项目名称:OpenStudio,代码行数:101,代码来源:ForwardTranslateEvaporativeFluidCoolerSingleSpeed.cpp


注:本文中的OptionalString类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。