| 1827 | } |
| 1828 | |
| 1829 | boost::optional<openstudio::model::ModelObject> ReverseTranslator::translateWeatherFile(const pugi::xml_node& element, |
| 1830 | openstudio::model::Model& model) { |
| 1831 | //<AnnualWeatherFile>F:/360Local/AEC/CBECCn/CBECC Source Files/CBECC-Com13/Data/EPW/SACRAMENTO-EXECUTIVE_724830_CZ2010.epw</AnnualWeatherFile> |
| 1832 | |
| 1833 | pugi::xml_node annualWeatherFileElement = element.child("AnnualWeatherFile"); |
| 1834 | |
| 1835 | if (!annualWeatherFileElement) { |
| 1836 | LOG(Error, "No annual weather file specified"); |
| 1837 | return boost::none; |
| 1838 | } |
| 1839 | |
| 1840 | openstudio::path epwFilePath = toPath(annualWeatherFileElement.text().as_string()); |
| 1841 | if (!epwFilePath.is_complete()) { |
| 1842 | epwFilePath = complete(epwFilePath, m_path.parent_path()); |
| 1843 | } |
| 1844 | |
| 1845 | if (!exists(epwFilePath)) { |
| 1846 | LOG(Error, "Annual weather file '" << toString(epwFilePath) << "' does not exist"); |
| 1847 | return boost::none; |
| 1848 | } |
| 1849 | |
| 1850 | boost::optional<EpwFile> epwFile; |
| 1851 | try { |
| 1852 | epwFile = EpwFile(epwFilePath); |
| 1853 | } catch (std::exception&) { |
| 1854 | LOG(Error, "Could not open epw file '" << toString(epwFilePath) << "'"); |
| 1855 | } |
| 1856 | |
| 1857 | if (!epwFile) { |
| 1858 | return boost::none; |
| 1859 | } |
| 1860 | |
| 1861 | // set weatherfile |
| 1862 | boost::optional<model::WeatherFile> weatherFile = model::WeatherFile::setWeatherFile(model, *epwFile); |
| 1863 | if (!weatherFile) { |
| 1864 | LOG(Error, "Failed to set weather file for model"); |
| 1865 | return boost::none; |
| 1866 | } |
| 1867 | |
| 1868 | return weatherFile.get(); |
| 1869 | } |
| 1870 | |
| 1871 | pugi::xml_node ReverseTranslator::supplySegment(const pugi::xml_node& fluidSegInRefElement) { |
| 1872 | |