GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 97.9% 92 / 0 / 94
Functions: 100.0% 1 / 0 / 1
Branches: 76.8% 142 / 0 / 185

src/energyplus/ReverseTranslator/ReverseTranslateScheduleWeekDaily.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/ScheduleWeek.hpp"
9 #include "../../model/ScheduleWeek_Impl.hpp"
10 #include "../../model/ScheduleDay.hpp"
11 #include "../../model/ScheduleDay_Impl.hpp"
12
13 #include <utilities/idd/Schedule_Week_Daily_FieldEnums.hxx>
14 #include <utilities/idd/OS_Schedule_Week_FieldEnums.hxx>
15 #include "../../utilities/idd/IddEnums.hpp"
16 #include <utilities/idd/IddEnums.hxx>
17
18 using namespace openstudio::model;
19
20 namespace openstudio {
21
22 namespace energyplus {
23
24 59 OptionalModelObject ReverseTranslator::translateScheduleWeekDaily(const WorkspaceObject& workspaceObject) {
25
4/5
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 59 times.
59 if (workspaceObject.iddObject().type() != IddObjectType::Schedule_Week_Daily) {
26 ✗ LOG(Error, "WorkspaceObject is not IddObjectType: Schedule:Week");
27 ✗ return boost::none;
28 }
29
30 // create the schedule
31
1/1
✓ Branch 1 taken 59 times.
59 ScheduleWeek scheduleWeek(m_model);
32
33
1/1
✓ Branch 1 taken 59 times.
59 OptionalString s = workspaceObject.name();
34
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if (s) {
35
2/2
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
59 scheduleWeek.setName(*s);
36 }
37
38
1/1
✓ Branch 1 taken 59 times.
59 OptionalWorkspaceObject target = workspaceObject.getTarget(Schedule_Week_DailyFields::SundaySchedule_DayName);
39
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if (target) {
40
2/2
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
59 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
41
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if (modelObject) {
42
3/4
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
✗ Branch 8 not taken.
118 if (modelObject->optionalCast<ScheduleDay>()) {
43
3/3
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
59 scheduleWeek.setSundaySchedule(modelObject->cast<ScheduleDay>());
44 }
45 }
46 59 }
47
48
1/1
✓ Branch 1 taken 59 times.
59 target = workspaceObject.getTarget(Schedule_Week_DailyFields::MondaySchedule_DayName);
49
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if (target) {
50
2/2
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
59 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
51
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if (modelObject) {
52
3/4
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
✗ Branch 8 not taken.
118 if (modelObject->optionalCast<ScheduleDay>()) {
53
3/3
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
59 scheduleWeek.setMondaySchedule(modelObject->cast<ScheduleDay>());
54 }
55 }
56 59 }
57
58
1/1
✓ Branch 1 taken 59 times.
59 target = workspaceObject.getTarget(Schedule_Week_DailyFields::TuesdaySchedule_DayName);
59
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if (target) {
60
2/2
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
59 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
61
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if (modelObject) {
62
3/4
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
✗ Branch 8 not taken.
118 if (modelObject->optionalCast<ScheduleDay>()) {
63
3/3
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
59 scheduleWeek.setTuesdaySchedule(modelObject->cast<ScheduleDay>());
64 }
65 }
66 59 }
67
68
1/1
✓ Branch 1 taken 59 times.
59 target = workspaceObject.getTarget(Schedule_Week_DailyFields::WednesdaySchedule_DayName);
69
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if (target) {
70
2/2
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
59 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
71
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if (modelObject) {
72
3/4
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
✗ Branch 8 not taken.
118 if (modelObject->optionalCast<ScheduleDay>()) {
73
3/3
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
59 scheduleWeek.setWednesdaySchedule(modelObject->cast<ScheduleDay>());
74 }
75 }
76 59 }
77
78
1/1
✓ Branch 1 taken 59 times.
59 target = workspaceObject.getTarget(Schedule_Week_DailyFields::ThursdaySchedule_DayName);
79
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if (target) {
80
2/2
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
59 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
81
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if (modelObject) {
82
3/4
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
✗ Branch 8 not taken.
118 if (modelObject->optionalCast<ScheduleDay>()) {
83
3/3
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
59 scheduleWeek.setThursdaySchedule(modelObject->cast<ScheduleDay>());
84 }
85 }
86 59 }
87
88
1/1
✓ Branch 1 taken 59 times.
59 target = workspaceObject.getTarget(Schedule_Week_DailyFields::FridaySchedule_DayName);
89
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if (target) {
90
2/2
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
59 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
91
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if (modelObject) {
92
3/4
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
✗ Branch 8 not taken.
118 if (modelObject->optionalCast<ScheduleDay>()) {
93
3/3
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
59 scheduleWeek.setFridaySchedule(modelObject->cast<ScheduleDay>());
94 }
95 }
96 59 }
97
98
1/1
✓ Branch 1 taken 59 times.
59 target = workspaceObject.getTarget(Schedule_Week_DailyFields::SaturdaySchedule_DayName);
99
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if (target) {
100
2/2
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
59 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
101
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if (modelObject) {
102
3/4
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
✗ Branch 8 not taken.
118 if (modelObject->optionalCast<ScheduleDay>()) {
103
3/3
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
59 scheduleWeek.setSaturdaySchedule(modelObject->cast<ScheduleDay>());
104 }
105 }
106 59 }
107
108
1/1
✓ Branch 1 taken 59 times.
59 target = workspaceObject.getTarget(Schedule_Week_DailyFields::HolidaySchedule_DayName);
109
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if (target) {
110
2/2
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
59 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
111
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if (modelObject) {
112
3/4
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
✗ Branch 8 not taken.
118 if (modelObject->optionalCast<ScheduleDay>()) {
113
3/3
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
59 scheduleWeek.setHolidaySchedule(modelObject->cast<ScheduleDay>());
114 }
115 }
116 59 }
117
118
1/1
✓ Branch 1 taken 59 times.
59 target = workspaceObject.getTarget(Schedule_Week_DailyFields::SummerDesignDaySchedule_DayName);
119
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if (target) {
120
2/2
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
59 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
121
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if (modelObject) {
122
3/4
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
✗ Branch 8 not taken.
118 if (modelObject->optionalCast<ScheduleDay>()) {
123
3/3
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
59 scheduleWeek.setSummerDesignDaySchedule(modelObject->cast<ScheduleDay>());
124 }
125 }
126 59 }
127
128
1/1
✓ Branch 1 taken 59 times.
59 target = workspaceObject.getTarget(Schedule_Week_DailyFields::WinterDesignDaySchedule_DayName);
129
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if (target) {
130
2/2
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
59 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
131
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if (modelObject) {
132
3/4
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
✗ Branch 8 not taken.
118 if (modelObject->optionalCast<ScheduleDay>()) {
133
3/3
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
59 scheduleWeek.setWinterDesignDaySchedule(modelObject->cast<ScheduleDay>());
134 }
135 }
136 59 }
137
138
1/1
✓ Branch 1 taken 59 times.
59 target = workspaceObject.getTarget(Schedule_Week_DailyFields::CustomDay1Schedule_DayName);
139
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if (target) {
140
2/2
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
59 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
141
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if (modelObject) {
142
3/4
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
✗ Branch 8 not taken.
118 if (modelObject->optionalCast<ScheduleDay>()) {
143
3/3
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
59 scheduleWeek.setCustomDay1Schedule(modelObject->cast<ScheduleDay>());
144 }
145 }
146 59 }
147
148
1/1
✓ Branch 1 taken 59 times.
59 target = workspaceObject.getTarget(Schedule_Week_DailyFields::CustomDay2Schedule_DayName);
149
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if (target) {
150
2/2
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
59 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
151
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if (modelObject) {
152
3/4
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
✗ Branch 8 not taken.
118 if (modelObject->optionalCast<ScheduleDay>()) {
153
3/3
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
59 scheduleWeek.setCustomDay2Schedule(modelObject->cast<ScheduleDay>());
154 }
155 }
156 59 }
157
158
1/1
✓ Branch 1 taken 59 times.
59 return scheduleWeek;
159 59 }
160
161 } // namespace energyplus
162
163 } // namespace openstudio
164