MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / translateIdfToEPJSONWithEP

Function translateIdfToEPJSONWithEP

src/epjson/test/epJSONFixture.cpp:134–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134Json::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
160openstudio::path epJSONFixture::completeIDFPath(const openstudio::path& idf) {
161 return openstudio::getEnergyPlusDirectory() / openstudio::toPath("ExampleFiles") / idf;

Callers 1

doEPJSONTranslationsMethod · 0.85

Calls 5

setFileExtensionFunction · 0.85
ExceptionFunction · 0.85
loadJSONFunction · 0.85
toStringFunction · 0.50
toPathFunction · 0.50

Tested by

no test coverage detected