GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 80.0% 16 / 0 / 20
Functions: 100.0% 2 / 0 / 2
Branches: 63.6% 28 / 0 / 44

src/workflow/RunTranslator.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 "OSWorkflow.hpp"
7
8 #include "Util.hpp"
9
10 #include "../model/Model.hpp"
11 #include "../model/WeatherFile.hpp"
12 #include "../model/Facility.hpp"
13 #include "../model/Facility_Impl.hpp"
14 #include "../model/Building.hpp"
15 #include "../model/Building_Impl.hpp"
16 #include "../energyplus/ForwardTranslator.hpp"
17
18 #include "../utilities/filetypes/WorkflowJSON.hpp"
19 #include "../utilities/filetypes/RunOptions.hpp"
20 #include "../utilities/filetypes/ForwardTranslatorOptions.hpp"
21
22 #include "../utilities/core/Filesystem.hpp"
23
24 namespace openstudio {
25
26 12 void OSWorkflow::runTranslator() {
27
28 12 state = State::Translator;
29
30 // skip if halted
31 // TODO: I don't understand this
32
2/3
✓ Branch 1 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
12 if (runner.halted()) {
33 ✗ LOG(Info, "Workflow halted, skipping the OSM to IDF translation");
34 // This allows model arguments to still be calculated
35 ✗ workspace_ = Workspace{};
36 ✗ return;
37 }
38
39
1/1
✓ Branch 1 taken 12 times.
12 auto runDir = workflowJSON.absoluteRunDir();
40
2/4
✓ Branch 1 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 6 not taken.
12 OS_ASSERT(openstudio::filesystem::is_directory(runDir));
41
42 // Copy in the weather file
43
1/2
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
12 if (!epwPath.empty()) {
44
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
24 openstudio::filesystem::copy_file(epwPath, runDir / "in.epw", openstudio::filesystem::copy_options::overwrite_existing);
45 } else {
46 ✗ LOG(Warn, "EPW file not found");
47 }
48
49 // Translate the OSM to an IDF
50
5/5
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
12 LOG(Info, "Beginning the translation to IDF")
51
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
24 detailedTimeBlock("Translating to EnergyPlus IDF", [this]() {
52
1/1
✓ Branch 1 taken 12 times.
12 openstudio::energyplus::ForwardTranslator ft;
53
4/4
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
12 ft.setForwardTranslatorOptions(workflowJSON.runOptions()->forwardTranslatorOptions());
54
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
12 workspace_ = ft.translateModel(model);
55 12 });
56
57
5/5
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
12 LOG(Info, "Successfully translated to IDF");
58
59
1/1
✓ Branch 1 taken 12 times.
12 saveIDFToRootDirIfDebug();
60 12 }
61
62 } // namespace openstudio
63