| 290 | } |
| 291 | |
| 292 | bool processInput(fs::path const &inputFilePath, |
| 293 | json const &schema, |
| 294 | OutputTypes outputType, |
| 295 | fs::path outputDirPath, |
| 296 | std::string &outputTypeStr, |
| 297 | bool convertHVACTemplate) |
| 298 | { |
| 299 | auto validation(std::make_unique<Validation>(&schema)); |
| 300 | auto idf_parser(std::make_unique<IdfParser>()); |
| 301 | json epJSON; |
| 302 | |
| 303 | auto const inputDirPath = EnergyPlus::FileSystem::getParentDirectoryPath(inputFilePath); |
| 304 | |
| 305 | if (outputDirPath.empty()) { |
| 306 | outputDirPath = inputDirPath; |
| 307 | } |
| 308 | |
| 309 | auto const inputFileType = EnergyPlus::FileSystem::getFileType(inputFilePath); |
| 310 | |
| 311 | const bool isEpJSON = EnergyPlus::FileSystem::is_all_json_type(inputFileType); |
| 312 | const bool isCBOR = (inputFileType == EnergyPlus::FileSystem::FileTypes::CBOR); |
| 313 | const bool isMsgPack = (inputFileType == EnergyPlus::FileSystem::FileTypes::MsgPack); |
| 314 | const bool isUBJSON = (inputFileType == EnergyPlus::FileSystem::FileTypes::UBJSON); |
| 315 | const bool isBSON = (inputFileType == EnergyPlus::FileSystem::FileTypes::BSON); |
| 316 | const bool isIDForIMF = EnergyPlus::FileSystem::is_idf_type(inputFileType); // IDF or IMF |
| 317 | const bool isDDY = (inputFileType == EnergyPlus::FileSystem::FileTypes::DDY); |
| 318 | |
| 319 | if (!(isEpJSON || isIDForIMF || isDDY)) { |
| 320 | displayMessage("ERROR: Input file must have IDF, IMF, DDY, or epJSON extension."); |
| 321 | return false; |
| 322 | } |
| 323 | |
| 324 | if (outputType == OutputTypes::epJSON && |
| 325 | (inputFileType == EnergyPlus::FileSystem::FileTypes::EpJSON || inputFileType == EnergyPlus::FileSystem::FileTypes::JSON)) { |
| 326 | displayMessage("Same output format as input format requested (epJSON). Skipping conversion and moving to next file."); |
| 327 | return false; |
| 328 | } else if (outputType == OutputTypes::IDF && (isIDForIMF || isDDY)) { |
| 329 | displayMessage("Same output format as input format requested (IDF). Skipping conversion and moving to next file."); |
| 330 | return false; |
| 331 | } else if (outputType == OutputTypes::CBOR && isCBOR) { |
| 332 | displayMessage("Same output format as input format requested (CBOR). Skipping conversion and moving to next file."); |
| 333 | return false; |
| 334 | } else if (outputType == OutputTypes::MsgPack && isMsgPack) { |
| 335 | displayMessage("Same output format as input format requested (MsgPack). Skipping conversion and moving to next file."); |
| 336 | return false; |
| 337 | } else if (outputType == OutputTypes::UBJSON && isUBJSON) { |
| 338 | displayMessage("Same output format as input format requested (UBJSON). Skipping conversion and moving to next file."); |
| 339 | return false; |
| 340 | } else if (outputType == OutputTypes::BSON && isBSON) { |
| 341 | displayMessage("Same output format as input format requested (BSON). Skipping conversion and moving to next file."); |
| 342 | return false; |
| 343 | } |
| 344 | |
| 345 | if (!EnergyPlus::FileSystem::fileExists(inputFilePath)) { |
| 346 | displayMessage("Input file path {} not found", inputFilePath.generic_string()); |
| 347 | return false; |
| 348 | } |
| 349 |
no test coverage detected