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


C++ openstudio类代码示例

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


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

示例1: FileLogSink

void EnergyPlusFixture::SetUpTestCase() {
  // set up logging
  logFile = FileLogSink(toPath("./EnergyPlusFixture.log"));
  logFile->setLogLevel(Debug);
  openstudio::Logger::instance().standardOutLogger().disable();

  // initialize component paths
  openstudio::path basePath = resourcesPath()/openstudio::toPath("energyplus/Components/");
  // idfComponents consists of .first = path to directory, .second = component type
  idfComponents.push_back(std::pair<openstudio::path,std::string>(basePath/openstudio::toPath("idf_roof_1"),"roof"));
  idfComponents.push_back(std::pair<openstudio::path,std::string>(basePath/openstudio::toPath("idf_roof_2"),"roof"));
  idfComponents.push_back(std::pair<openstudio::path,std::string>(basePath/openstudio::toPath("idf_roof_3"),"roof"));
  idfComponents.push_back(std::pair<openstudio::path,std::string>(basePath/openstudio::toPath("idf_roof_4"),"roof"));
  idfComponents.push_back(std::pair<openstudio::path,std::string>(basePath/openstudio::toPath("idf_roof_5"),"roof"));
  idfComponents.push_back(std::pair<openstudio::path,std::string>(basePath/openstudio::toPath("idf_designday_1"),"designday"));
  idfComponents.push_back(std::pair<openstudio::path,std::string>(basePath/openstudio::toPath("idf_designday_2"),"designday"));
  idfComponents.push_back(std::pair<openstudio::path,std::string>(basePath/openstudio::toPath("idf_designday_3"),"designday"));
  idfComponents.push_back(std::pair<openstudio::path,std::string>(basePath/openstudio::toPath("idf_designday_4"),"designday"));
  idfComponents.push_back(std::pair<openstudio::path,std::string>(basePath/openstudio::toPath("idf_designday_5"),"designday"));

  // delete translated components
  BOOST_FOREACH(const ComponentDirectoryAndType& idfComponent,idfComponents) {
    // delete any *.osc and oscomponent.xml files in the directory
    for (openstudio::directory_iterator it(idfComponent.first), itEnd; it != itEnd; ++it) {
      if (boost::filesystem::is_regular_file(it->status())) {
        std::string ext = openstudio::toString(boost::filesystem::extension(*it));
        if (ext == ".osc") { boost::filesystem::remove(it->path()); }
        if ((ext == ".xml") && (openstudio::toString(it->filename()) == "oscomponent")) { 
          boost::filesystem::remove(it->path()); 
        }
      }
    } // for iterator over directory
  } // foreach component

}
开发者ID:CraigCasey,项目名称:OpenStudio,代码行数:35,代码来源:EnergyPlusFixture.cpp

示例2: TEST

TEST(Table, Serialization)
{
  // construct table
  openstudio::path p = resourcesPath()/toPath("utilities/Table/EUI.csv");
  Table table = Table::load(p);
  table.setTitle("EUIs");
  table.setCaption("EUIs of several buildings");
  table.setNHead(2);
  table.setNLeft(2);
  p = resourcesPath()/toPath("utilities/Table/EUI.ost");

  // serialize
  openstudio::Time start = openstudio::Time::currentTime();
  table.save(p);
  openstudio::Time totalTime = openstudio::Time::currentTime() - start;
  LOG_FREE(Info, "openstudio.Table", "Time to serialize a small table = " << totalTime);

  // [email protected] Uncommenting this line results in a compiler error that I haven't been
  // able to debug.
  // OptionalTable ot;

  // deserialize
  start = openstudio::Time::currentTime();
  Table loaded = Table::load(p);
  totalTime = openstudio::Time::currentTime() - start;
  LOG_FREE(Info, "openstudio.Table", "Time to deserialize a small table = " << totalTime);
  ASSERT_EQ(static_cast<unsigned>(10),loaded.nRows());
  ASSERT_EQ(static_cast<unsigned>(6),loaded.nCols());
  std::stringstream ss;
  ss << std::fixed << std::setprecision(0) << table[2][2];
  EXPECT_EQ("120",ss.str()); ss.str("");
}
开发者ID:CUEBoxer,项目名称:OpenStudio,代码行数:32,代码来源:Table_GTest.cpp

示例3: TEST_F

TEST_F(CoreFixture, PathWatcher_Dir)
{
  Application::instance().application();

  openstudio::path path = toPath("./");
  ASSERT_TRUE(boost::filesystem::exists(path));

  openstudio::path filePath = toPath("./PathWatcher_Dir");
  if (boost::filesystem::exists(filePath)){
    boost::filesystem::remove(filePath);
  }
  ASSERT_FALSE(boost::filesystem::exists(filePath));

  TestPathWatcher watcher(path);
  EXPECT_FALSE(watcher.changed);

  EXPECT_EQ(path.string(), watcher.path().string());

  // catches the file addition
  TestFileWriter w1(filePath, "test 1"); w1.start(); 
  while (!w1.isFinished()){  
    // do not call process events
    QThread::yieldCurrentThread();
  }
  EXPECT_TRUE(boost::filesystem::exists(filePath));

  // calls processEvents
  System::msleep(10);

  EXPECT_TRUE(watcher.changed);
  watcher.changed = false;
  EXPECT_FALSE(watcher.changed);

  // does not catch changes to the file
  TestFileWriter w2(filePath, "test 2"); w2.start(); 
  while (!w2.isFinished()){  
    // do not call process events
    QThread::yieldCurrentThread();
  }
  EXPECT_TRUE(boost::filesystem::exists(filePath));

  // calls processEvents
  System::msleep(10);

  EXPECT_FALSE(watcher.changed);
  
  // catches file removal
  TestFileRemover r1(filePath); r1.start();
  while (!r1.isFinished()){  
    // do not call process events
    QThread::yieldCurrentThread();
  }
  EXPECT_FALSE(boost::filesystem::exists(filePath));

  // calls processEvents
  System::msleep(10);

  EXPECT_TRUE(watcher.changed);
}
开发者ID:CUEBoxer,项目名称:OpenStudio,代码行数:59,代码来源:PathWatcher_GTest.cpp

示例4: TEST

TEST(EnumHelpers, isMember)
{
  openstudio::enums::TestEnum te("third");
  openstudio::StringVector members;
  members.push_back("first");
  members.push_back("elephant"); // bad values are ignored
  EXPECT_FALSE(isMember(te,members));
  members.push_back("third");
  EXPECT_TRUE(isMember(te,members));
}
开发者ID:airguider,项目名称:OpenStudio,代码行数:10,代码来源:EnumHelpers_GTest.cpp

示例5: FileLogSink

void SqlFileFixture::SetUpTestCase()
{
  logFile = FileLogSink(toPath("./SqlFileFixture.log"));
  logFile->setLogLevel(Debug);

  openstudio::path path;
  path = resourcesPath()/toPath("energyplus/5ZoneAirCooled/eplusout.sql");
  sqlFile = openstudio::SqlFile(path);
  ASSERT_TRUE(sqlFile.connectionOpen());
}
开发者ID:ChengXinDL,项目名称:OpenStudio,代码行数:10,代码来源:SqlFileFixture.cpp

示例6: FileLogSink

void ProjectFixture::SetUpTestCase() {
  // set up logging
  logFile = FileLogSink(toPath("./ProjectFixture.log"));
  logFile->setLogLevel(Info);
  openstudio::Logger::instance().standardOutLogger().disable();

  // set up data folder
  if (!boost::filesystem::exists(toPath("ProjectFixtureData"))) {
    boost::filesystem::create_directory(toPath("ProjectFixtureData"));
  }

}
开发者ID:pepsi7959,项目名称:OpenStudio,代码行数:12,代码来源:ProjectFixture.cpp

示例7: FileLogSink

// initialize static members
void UnitsFixture::SetUpTestCase() 
{
  logFile = FileLogSink(toPath("./UnitsFixture.log"));
  logFile->setLogLevel(Debug);
  Logger::instance().standardOutLogger().disable();
  
  tol = 1.0E-8;

  openstudio::DoubleVector vals = openstudio::toStandardVector(openstudio::randVector(0.0,1000.0,8760u));
  openstudio::Unit u = openstudio::createSIPower();
  for (double val : vals) {
    testQuantityVector.push_back(openstudio::Quantity(val,u));
  }
  testOSQuantityVector = openstudio::OSQuantityVector(u,vals);
}
开发者ID:pepsi7959,项目名称:OpenStudio,代码行数:16,代码来源:UnitsFixture.cpp

示例8: TEST_F

TEST_F(UnitsFixture,QuantityRegex_DecomposeAtomicUnits) {
  std::string uStr("m");
  std::pair<std::string,int> result;
  result = decomposeAtomicUnitString(uStr);
  EXPECT_EQ("m",result.first); EXPECT_EQ(1,result.second);

  uStr = "kg^3"; result = decomposeAtomicUnitString(uStr);
  EXPECT_EQ("kg",result.first); EXPECT_EQ(3,result.second);

  uStr = "short^{-3291}"; result = decomposeAtomicUnitString(uStr);
  EXPECT_EQ("short",result.first); EXPECT_EQ(-3291,result.second);

  EXPECT_THROW(decomposeAtomicUnitString("kg^{2}"),openstudio::Exception);
  EXPECT_THROW(decomposeAtomicUnitString("kg/s"),openstudio::Exception);
}
开发者ID:ChengXinDL,项目名称:OpenStudio,代码行数:15,代码来源:QuantityRegex_GTest.cpp

示例9: FileLogSink

void IddFixture::SetUpTestCase()
{
  // set up logging
  logFile = FileLogSink(toPath("./IddFixture.log"));
  logFile->setLogLevel(Debug);

  // load from factory and time it
  openstudio::Time start = openstudio::Time::currentTime();
  epIddFile = openstudio::IddFactory::instance().getIddFile(openstudio::IddFileType::EnergyPlus);
  iddLoadTime = openstudio::Time::currentTime() - start;

  LOG(Info, "EnergyPlus IddFile load time (from IddFactory) = " << iddLoadTime);

  start = openstudio::Time::currentTime();
  osIddFile = openstudio::IddFactory::instance().getIddFile(openstudio::IddFileType::OpenStudio);
  iddLoadTime = openstudio::Time::currentTime() - start;

  LOG(Info, "OpenStudio IddFile load time (from IddFactory) = " << iddLoadTime);
}
开发者ID:pepsi7959,项目名称:OpenStudio,代码行数:19,代码来源:IddFixture.cpp

示例10: LOG

TEST_F(UnitsFixture,IPUnit_ArithmeticOperators)
{
    LOG(Debug,"IPUnit_ArithmeticOperators");

    IPUnit u1;
    IPUnit u2 = createIPForce();
    IPUnit u3(IPExpnt(1));

    u1 *= u3;
    testStreamOutput("lb_m",u1);
    Unit u4 = u2*u3;
    ASSERT_TRUE(u4.system() == UnitSystem::IP);
    testStreamOutput("lb_m*lb_f",u4);
    u4.cast<IPUnit>().lbfToLbm();
    testStreamOutput("lb_m^2*ft/s^2",u4);

    Unit u5 = u4/u3;
    EXPECT_TRUE(u5.system() == UnitSystem::IP);
    EXPECT_TRUE(u5 == u2);

    Unit u6 = pow(u5,-6);
    EXPECT_TRUE(u6.system() == UnitSystem::IP);
    testStreamOutput("s^12/lb_m^6*ft^6",u6);
    u6.pow(1,3);
    testStreamOutput("s^4/lb_m^2*ft^2",u6);
}
开发者ID:BIMDataHub,项目名称:OpenStudio-IFC-Importer,代码行数:26,代码来源:IPUnit_GTest.cpp

示例11: checksum

TEST(Checksum, Streams)
{
  stringstream ss;
  EXPECT_EQ(istream::goodbit, ss.rdstate());
  EXPECT_EQ("00000000", checksum(ss));

  // checksum tried to read from empty stream and both eof and fail bits are set
  EXPECT_EQ(istream::failbit | istream::eofbit, ss.rdstate());

  // need to clear the eofbit that was set when checksum read all the way through
  ss.clear();
  EXPECT_EQ(istream::goodbit, ss.rdstate());

  // write some more to the stringstream
  ss << "Hi there";
  EXPECT_EQ(istream::goodbit, ss.rdstate());
  EXPECT_EQ("1AD514BA", checksum(ss));

  // checksum read all the way through and eofbit is set
  EXPECT_EQ(istream::failbit | istream::eofbit, ss.rdstate());
  EXPECT_EQ("00000000", checksum(ss));
  EXPECT_EQ(istream::failbit | istream::eofbit, ss.rdstate());

  // need to clear the eofbit that was set when checksum read all the way through
  ss.clear();
  EXPECT_EQ(istream::goodbit, ss.rdstate());
  EXPECT_EQ("00000000", checksum(ss));
}
开发者ID:MatthewSteen,项目名称:OpenStudio,代码行数:28,代码来源:Checksum_GTest.cpp

示例12: LOG

TEST_F(UnitsFixture,BTUUnit_ArithmeticOperators)
{
  LOG(Debug,"BTUUnit_ArithmeticOperators");

  // /=
  BTUUnit P1(BTUExpnt(1));
  BTUUnit t1(BTUExpnt(0,0,1));
  P1 /= t1;
  EXPECT_EQ("Btu/h",P1.standardString(false));
  EXPECT_EQ(1,P1.baseUnitExponent("Btu"));
  EXPECT_EQ(-1,P1.baseUnitExponent("h"));
  EXPECT_EQ(0,P1.baseUnitExponent("ft"));
  EXPECT_EQ(0,P1.baseUnitExponent("m"));

  // *
  Unit E1 = P1 * t1;
  EXPECT_TRUE(E1.system() == UnitSystem::BTU);
  EXPECT_EQ("Btu",E1.standardString(false));
  EXPECT_EQ("",E1.prettyString());

  // /
  Unit u = P1/E1;
  u /= t1;
  EXPECT_TRUE(u.system() == UnitSystem::BTU);
  EXPECT_EQ("1/h^2",u.standardString(false));
  EXPECT_EQ(-2,u.baseUnitExponent("h"));
  EXPECT_EQ(0,u.baseUnitExponent("Btu"));

  // pow
  u.pow(-1,2);
  EXPECT_EQ("h",u.standardString(false));
  EXPECT_EQ(1,u.baseUnitExponent("h"));

}
开发者ID:jtanaa,项目名称:OpenStudio,代码行数:34,代码来源:BTUUnit_GTest.cpp

示例13: LOG

TEST_F(UnitsFixture,SIUnit_ArithmeticOperators)
{
    LOG(Debug,"SIUnit_ArithmeticOperators");

    SIUnit u1;
    SIUnit u2(SIExpnt(1,1,-2,0),0,"N");
    SIUnit u3(SIExpnt(1)); // kg
    SIUnit u4(SIExpnt(0,1,0,0),-2); // cm

    // multiplication
    u1 *= u3; // kg
    testStreamOutput("kg",u1);
    Unit u5 = u2*u3; // N*kg
    EXPECT_TRUE(u5.system() == UnitSystem::SI);
    testStreamOutput("N*kg",u5);
    Unit u6 = u2*u4; // cJ
    EXPECT_TRUE(u6.system() == UnitSystem::SI);
    testStreamOutput("cJ",u6);

    // division
    u6 /= u4;
    EXPECT_TRUE(u6 == u2);

    // power
    Unit u7 = pow(u4,6); // (cm)^6
    EXPECT_TRUE(u7.system() == UnitSystem::SI);
    testStreamOutput("cm^6",u7);
    EXPECT_EQ("p",u7.scale().abbr);
    u7.pow(1,3); // (cm)^2
    testStreamOutput("m(m^2)",u7); // no 10^-4 scale--moves to 10^-3
}
开发者ID:,项目名称:,代码行数:31,代码来源:

示例14: decomposeAtomicUnitString

TEST_F(UnitsFixture,QuantityRegex_PumpFields) {

  std::string aUnit;
  // Design Shaft Power per Unit Flow Rate per Unit Head is posing problems
  // After trial and error, I can format the IDD so it works: No parenthesis, one divisor
  // Currently this is the only one that passes
  aUnit = "W*s/m^3*Pa"; EXPECT_TRUE(isUnit(aUnit));
  aUnit = "W*min/gal*ftH_{2}O"; EXPECT_TRUE(isUnit(aUnit));


  std::pair<std::string,int> atomicDecomp;

  aUnit = "ftH_{2}O";
  // this shouldn't be an atomic unit!
  // EXPECT_FALSE(isAtomicUnit(aUnit));

  // But we can at least make sure that the decomposition at least returns the right exponent (1...)
  atomicDecomp = decomposeAtomicUnitString(aUnit);
  EXPECT_EQ("ftH_{2}O", atomicDecomp.first);
  EXPECT_EQ(1, atomicDecomp.second);

  aUnit = "1/ftH_{2}O";
  EXPECT_FALSE(containsScientificNotationValue(aUnit));
  // There is no multiplier (km, ms, etc)
  // This returns TRUE, like above... but we'll make sure it ends up fine...
  // EXPECT_FALSE(containsAtomicUnit(aUnit));

  // 1 over something is a Compound Unit)
  EXPECT_TRUE(containsCompoundUnit(aUnit));

  EXPECT_FALSE(containsScaledUnit(aUnit));
  EXPECT_FALSE(containsDirectScaledUnit(aUnit));
  EXPECT_TRUE(isUnit(aUnit));

  ASSERT_TRUE(isCompoundUnit(aUnit));

  std::pair< std::vector<std::string>,std::vector<std::string> > result;

  result = decomposeCompoundUnitString(aUnit);
  // Nothing on numerator
  ASSERT_EQ(static_cast<size_t>(0),result.first.size());
  // Should have one unit on the denominator
  ASSERT_EQ(static_cast<size_t>(1),result.second.size());
  EXPECT_EQ("ftH_{2}O",result.second[0]);


  // All of these variations do fail
/*
 *  aUnit = "(W*s)/(m^3*Pa)"; EXPECT_TRUE(isUnit(aUnit));
 *  aUnit = "(W*s)/(m^3*Pa)"; EXPECT_TRUE(isUnit(aUnit));
 *
 *  aUnit = "(W*min)/(gal*ftH_{2}O)"; EXPECT_TRUE(isUnit(aUnit));
 *  aUnit = "W*min/(gal*ftH_{2}O)"; EXPECT_TRUE(isUnit(aUnit));
 *
 *  aUnit = "W/((m^3/s)*Pa)"; EXPECT_TRUE(isUnit(aUnit));
 *  aUnit = "W/((gal/min)*ftH_{2}O)"; EXPECT_TRUE(isUnit(aUnit));
 */

}
开发者ID:NREL,项目名称:OpenStudio,代码行数:59,代码来源:QuantityRegex_GTest.cpp

示例15: logBeforeAndAfterPathInformation

void logBeforeAndAfterPathInformation(const std::string& functionName,
                                      const path& before,const path& after) {
  std::stringstream ssb,ssa;
  
  printPathInformation(ssb,before);
  printPathInformation(ssa,after);
  
  LOG_FREE(Debug,"CoreFixture","Before " << functionName << ": " << ssb.str() << std::endl 
           << "After " << functionName << ": " << ssa.str() << std::endl);
}
开发者ID:ChengXinDL,项目名称:OpenStudio,代码行数:10,代码来源:Path_GTest.cpp


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