コード例 #1
0
void AnalysisDriverTestLibrarySingleton::initialize(const openstudio::path& outputDataDirectory,
        const openstudio::path& baselineModelDirectory)
{
    // create outputDataDirectory and save path as member data
    if (!boost::filesystem::exists(outputDataDirectory)) {
        boost::filesystem::create_directory(outputDataDirectory);
    }
    m_outputDataDirectory = outputDataDirectory;

    // create example model and put in outputDataDirectory
    Model model = exampleModel();
    openstudio::path exampleModelDir = m_outputDataDirectory / toPath("ExampleModel");
    openstudio::path exampleWeatherFileDir = exampleModelDir / toPath("example/files");
    openstudio::path weatherFilePath = exampleWeatherFileDir / toPath("USA_CO_Golden-NREL.724666_TMY3.epw");
    if (!boost::filesystem::exists(exampleModelDir)) {
        boost::filesystem::create_directory(exampleModelDir);
        boost::filesystem::create_directory(exampleWeatherFileDir.parent_path());
        boost::filesystem::create_directory(exampleWeatherFileDir);
        openstudio::path originalWeatherFilePath = energyPlusWeatherDataPath() / toPath("USA_CO_Golden-NREL.724666_TMY3.epw");
        boost::filesystem::copy_file(originalWeatherFilePath,weatherFilePath);
    }
    EpwFile epwFile(weatherFilePath);
    WeatherFile::setWeatherFile(model,epwFile);
    openstudio::path exampleModelPath = exampleModelDir / toPath("example.osm");
    model.save(exampleModelPath,true);
    m_baselineModels.push_back(exampleModelPath);

    // loop through files in baselineModelDirectory (non-recursive) and save .osm paths
    QDir srcDir(toQString(baselineModelDirectory));

    for (const QFileInfo& info : srcDir.entryInfoList(QDir::Files)) {
        if ((info.suffix() == "osm") || (info.suffix() == "idf")) {
            m_baselineModels.push_back(baselineModelDirectory / toPath(info.fileName()));
        }
    }

}
コード例 #2
0
boost::optional<openstudio::EpwFile> translateEpw(openstudio::path epwpath, openstudio::path outpath)
{
  boost::optional<openstudio::EpwFile> epw;
  try
  {
    openstudio::EpwFile epwFile(epwpath,true);
    try
    {
      epwFile.translateToWth(outpath);
    }
    catch(...) // Is this going to work?
    {
      std::cout << "Translation of EPW file failed, weather will be steady state" << std::endl;
      return false;
    }
    epw = boost::optional<openstudio::EpwFile>(epwFile);
  }
  catch(...)
  {
    std::cout << "Failed to correctly load EPW file, weather will be steady state" << std::endl;
    return false;
  }
  return epw;
}