MCPcopy Create free account
hub / github.com/NatLabRockies/EnergyPlus / processInput

Method processInput

src/EnergyPlus/InputProcessing/InputProcessor.cc:262–326  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

260}
261
262void InputProcessor::processInput(EnergyPlusData &state)
263{
264 if (!FileSystem::fileExists(state.dataStrGlobals->inputFilePath)) {
265 ShowFatalError(state, EnergyPlus::format("Input file path {} not found", state.dataStrGlobals->inputFilePath.string()));
266 return;
267 }
268
269 try {
270 if (!state.dataGlobal->isEpJSON) {
271 auto input_file = FileSystem::readFile(state.dataStrGlobals->inputFilePath); // (AUTO_OK_OBJ)
272
273 bool success = true;
274 epJSON = idf_parser->decode(input_file, schema(), success);
275
276 if (state.dataGlobal->outputEpJSONConversion || state.dataGlobal->outputEpJSONConversionOnly) {
277 json epJSONClean = epJSON;
278 cleanEPJSON(epJSONClean);
279 fs::path convertedIDF = FileSystem::makeNativePath(
280 FileSystem::replaceFileExtension(state.dataStrGlobals->outDirPath / state.dataStrGlobals->inputFilePathNameOnly, ".epJSON"));
281 FileSystem::writeFile<FileSystem::FileTypes::EpJSON>(convertedIDF, epJSONClean);
282 }
283 } else {
284 epJSON = FileSystem::readJSON(state.dataStrGlobals->inputFilePath);
285 }
286 } catch (const std::exception &e) {
287 ShowSevereError(state, e.what());
288 ShowFatalError(state, "Errors occurred on processing input file. Preceding condition(s) cause termination.");
289 }
290
291 bool is_valid = validation->validate(epJSON);
292 bool hasErrors = processErrors(state);
293 bool versionMatch = checkVersionMatch(state);
294 bool unsupportedFound = checkForUnsupportedObjects(state);
295
296 if (!is_valid || hasErrors || unsupportedFound) {
297 ShowFatalError(state, "Errors occurred on processing input file. Preceding condition(s) cause termination.");
298 }
299
300 if (state.dataGlobal->isEpJSON && (state.dataGlobal->outputEpJSONConversion || state.dataGlobal->outputEpJSONConversionOnly)) {
301 if (versionMatch) {
302 std::string const encoded = idf_parser->encode(epJSON, schema());
303 fs::path convertedEpJSON = FileSystem::makeNativePath(
304 FileSystem::replaceFileExtension(state.dataStrGlobals->outDirPath / state.dataStrGlobals->inputFilePathNameOnly, ".idf"));
305 FileSystem::writeFile<FileSystem::FileTypes::IDF>(convertedEpJSON, encoded);
306 } else {
307 ShowWarningError(state, "Skipping conversion of epJSON to IDF due to mismatched Version.");
308 }
309 }
310
311 initializeMaps();
312
313 int MaxArgs = 0;
314 int MaxAlpha = 0;
315 int MaxNumeric = 0;
316 getMaxSchemaArgs(MaxArgs, MaxAlpha, MaxNumeric);
317
318 state.dataIPShortCut->cAlphaFieldNames.allocate(MaxAlpha);
319 state.dataIPShortCut->cAlphaArgs.allocate(MaxAlpha);

Callers 1

commonRunFunction · 0.80

Calls 15

fileExistsFunction · 0.85
ShowFatalErrorFunction · 0.85
formatFunction · 0.85
readFileFunction · 0.85
makeNativePathFunction · 0.85
replaceFileExtensionFunction · 0.85
readJSONFunction · 0.85
ShowSevereErrorFunction · 0.85
processErrorsFunction · 0.85
checkVersionMatchFunction · 0.85
ShowWarningErrorFunction · 0.85

Tested by

no test coverage detected