| 132 | } |
| 133 | |
| 134 | Json::Value translateIdfToEPJSONWithEP(const openstudio::path& location) { |
| 135 | |
| 136 | // In case for some reason the energyplus CLI cannot do the conversion, we do not want to pick up an old artifact |
| 137 | const auto epJSONFile = openstudio::setFileExtension(location, "epJSON", true); |
| 138 | if (openstudio::filesystem::exists(epJSONFile)) { |
| 139 | openstudio::filesystem::remove(epJSONFile); |
| 140 | } |
| 141 | |
| 142 | std::string cmd = fmt::format("{} --output-directory {} --convert-only {}", openstudio::toString(openstudio::getEnergyPlusExecutable().native()), |
| 143 | openstudio::toString(location.parent_path().native()), openstudio::toString(location.native())); |
| 144 | |
| 145 | [[maybe_unused]] auto result = std::system(cmd.c_str()); |
| 146 | if (!openstudio::filesystem::exists(epJSONFile)) { |
| 147 | throw openstudio::Exception(fmt::format("Error during the E+ CLI call (return code {}), epJSON wasn't created at {}\ncmd = '{}'\n", result, |
| 148 | openstudio::toString(epJSONFile), cmd)); |
| 149 | } |
| 150 | |
| 151 | auto root = openstudio::epJSON::loadJSON(epJSONFile); |
| 152 | |
| 153 | const auto outputLocation = location.parent_path() / openstudio::toPath("eplus-rewritten.epJSON"); |
| 154 | std::ofstream ofs(openstudio::toString(outputLocation), std::ofstream::trunc); |
| 155 | ofs << root.toStyledString() << '\n'; |
| 156 | |
| 157 | return root; |
| 158 | } |
| 159 | |
| 160 | openstudio::path epJSONFixture::completeIDFPath(const openstudio::path& idf) { |
| 161 | return openstudio::getEnergyPlusDirectory() / openstudio::toPath("ExampleFiles") / idf; |
no test coverage detected