src/energyplus/ForwardTranslator/ForwardTranslatePythonPluginSearchPaths.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************************************************** | ||
| 2 | * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. | ||
| 3 | * See also https://openstudio.net/license | ||
| 4 | ***********************************************************************************************************************/ | ||
| 5 | |||
| 6 | #include "../ForwardTranslator.hpp" | ||
| 7 | #include "../../model/Model.hpp" | ||
| 8 | |||
| 9 | #include "../../model/PythonPluginSearchPaths.hpp" | ||
| 10 | |||
| 11 | #include "../../utilities/idf/IdfExtensibleGroup.hpp" | ||
| 12 | |||
| 13 | #include <utilities/idd/PythonPlugin_SearchPaths_FieldEnums.hxx> | ||
| 14 | #include <utilities/idd/IddEnums.hxx> | ||
| 15 | |||
| 16 | constexpr static auto pythonSearchPathsName = "Python Plugin Search Paths"; | ||
| 17 | |||
| 18 | using namespace openstudio::model; | ||
| 19 | |||
| 20 | namespace openstudio { | ||
| 21 | |||
| 22 | namespace energyplus { | ||
| 23 | |||
| 24 | 4 | boost::optional<IdfObject> ForwardTranslator::translatePythonPluginSearchPaths(model::PythonPluginSearchPaths& modelObject) { | |
| 25 | |||
| 26 |
1/1✓ Branch 1 taken 4 times.
|
4 | auto searchPaths = modelObject.searchPaths(); |
| 27 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 2 taken 3 times.
|
4 | if (searchPaths.empty()) { |
| 28 | 1 | return boost::none; | |
| 29 | } | ||
| 30 | |||
| 31 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | IdfObject idfObject = createAndRegisterIdfObject(openstudio::IddObjectType::PythonPlugin_SearchPaths, modelObject); |
| 32 | |||
| 33 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | idfObject.setName(pythonSearchPathsName); |
| 34 | |||
| 35 | // Add Current Working Directory to Search Path: Optional Boolean | ||
| 36 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 2 times.
|
3 | if (modelObject.addCurrentWorkingDirectorytoSearchPath()) { |
| 37 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | idfObject.setString(PythonPlugin_SearchPathsFields::AddCurrentWorkingDirectorytoSearchPath, "Yes"); |
| 38 | } else { | ||
| 39 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | idfObject.setString(PythonPlugin_SearchPathsFields::AddCurrentWorkingDirectorytoSearchPath, "No"); |
| 40 | } | ||
| 41 | |||
| 42 | // Add Input File Directory to Search Path: Optional Boolean | ||
| 43 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 2 times.
|
3 | if (modelObject.addInputFileDirectorytoSearchPath()) { |
| 44 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | idfObject.setString(PythonPlugin_SearchPathsFields::AddInputFileDirectorytoSearchPath, "Yes"); |
| 45 | } else { | ||
| 46 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | idfObject.setString(PythonPlugin_SearchPathsFields::AddInputFileDirectorytoSearchPath, "No"); |
| 47 | } | ||
| 48 | |||
| 49 | // Add epin Environment Variable to Search Path: Optional Boolean | ||
| 50 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 2 times.
|
3 | if (modelObject.addepinEnvironmentVariabletoSearchPath()) { |
| 51 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | idfObject.setString(PythonPlugin_SearchPathsFields::AddepinEnvironmentVariabletoSearchPath, "Yes"); |
| 52 | } else { | ||
| 53 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | idfObject.setString(PythonPlugin_SearchPathsFields::AddepinEnvironmentVariabletoSearchPath, "No"); |
| 54 | } | ||
| 55 | |||
| 56 | // Search Path | ||
| 57 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 8 taken 6 times.
✓ Branch 9 taken 3 times.
|
9 | for (const openstudio::path& searchPath : modelObject.searchPaths()) { |
| 58 |
1/1✓ Branch 1 taken 6 times.
|
6 | IdfExtensibleGroup eg = idfObject.pushExtensibleGroup(); |
| 59 |
2/2✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
|
6 | eg.setString(PythonPlugin_SearchPathsExtensibleFields::SearchPath, searchPath.generic_string()); |
| 60 | 9 | } | |
| 61 | |||
| 62 |
1/1✓ Branch 1 taken 3 times.
|
3 | return idfObject; |
| 63 | 4 | } // End of translate function | |
| 64 | |||
| 65 | } // end namespace energyplus | ||
| 66 | } // end namespace openstudio | ||
| 67 |