GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 21.6% 8 / 0 / 37
Functions: 100.0% 1 / 0 / 1
Branches: 20.5% 16 / 0 / 78

src/energyplus/ReverseTranslator/ReverseTranslateScheduleFile.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 "../ReverseTranslator.hpp"
7
8 #include "../../model/ScheduleFile.hpp"
9 #include "../../model/ScheduleFile_Impl.hpp"
10 #include "../../model/ExternalFile.hpp"
11 #include "../../model/ExternalFile_Impl.hpp"
12
13 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
14
15 #include <utilities/idd/Schedule_File_FieldEnums.hxx>
16 #include <utilities/idd/OS_Schedule_File_FieldEnums.hxx>
17 #include "../../utilities/idd/IddEnums.hpp"
18 #include <utilities/idd/IddEnums.hxx>
19
20 using namespace openstudio::model;
21
22 namespace openstudio {
23
24 namespace energyplus {
25
26 1 OptionalModelObject ReverseTranslator::translateScheduleFile(const WorkspaceObject& workspaceObject) {
27
4/5
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 time.
1 if (workspaceObject.iddObject().type() != IddObjectType::Schedule_File) {
28 ✗ LOG(Error, "WorkspaceObject is not IddObjectType: Schedule:File");
29 ✗ return boost::none;
30 }
31
32
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 std::string fileName = workspaceObject.getString(Schedule_FileFields::FileName).get();
33
1/1
✓ Branch 1 taken 1 time.
1 boost::optional<ExternalFile> extfile = ExternalFile::getExternalFile(m_model, fileName);
34
35
1/2
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
1 if (!extfile) {
36
7/7
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
1 LOG(Error, "Could not translate Schedule:File, cannot find file \"" << fileName << "\"");
37 1 return boost::none;
38 }
39
40 ✗ ScheduleFile scheduleFile(extfile.get(), workspaceObject.getInt(Schedule_FileFields::ColumnNumber).get(),
41 ✗ workspaceObject.getInt(Schedule_FileFields::RowstoSkipatTop).get());
42
43 ✗ OptionalWorkspaceObject target = workspaceObject.getTarget(Schedule_FileFields::ScheduleTypeLimitsName);
44 ✗ if (target) {
45 ✗ OptionalModelObject scheduleTypeLimits = translateAndMapWorkspaceObject(*target);
46 ✗ if (scheduleTypeLimits) {
47 ✗ scheduleFile.setPointer(OS_Schedule_FileFields::ScheduleTypeLimitsName, scheduleTypeLimits->handle());
48 }
49 ✗ }
50
51 ✗ if (OptionalString os = workspaceObject.name()) {
52 ✗ scheduleFile.setName(*os);
53 ✗ }
54
55 ✗ if (OptionalInt oi = workspaceObject.getInt(Schedule_FileFields::NumberofHoursofData)) {
56 ✗ scheduleFile.setNumberofHoursofData(*oi);
57 }
58
59 ✗ if (OptionalString os = workspaceObject.getString(Schedule_FileFields::ColumnSeparator)) {
60 ✗ scheduleFile.setColumnSeparator(*os);
61 ✗ }
62
63 ✗ if (OptionalString os = workspaceObject.getString(Schedule_FileFields::InterpolatetoTimestep)) {
64 ✗ if (openstudio::istringEqual("Yes", *os)) {
65 ✗ scheduleFile.setInterpolatetoTimestep(true);
66 }
67 ✗ }
68
69 ✗ if (OptionalInt oi = workspaceObject.getInt(Schedule_FileFields::MinutesperItem)) {
70 ✗ scheduleFile.setMinutesperItem(*oi);
71 }
72
73 ✗ if (OptionalString os = workspaceObject.getString(Schedule_FileFields::AdjustScheduleforDaylightSavings)) {
74 ✗ if (openstudio::istringEqual("Yes", *os)) {
75 ✗ scheduleFile.setAdjustScheduleforDaylightSavings(true);
76 }
77 ✗ }
78
79 ✗ return scheduleFile;
80 1 }
81
82 } // namespace energyplus
83
84 } // namespace openstudio
85