GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 93.2% 221 / 0 / 237
Functions: 100.0% 4 / 0 / 4
Branches: 80.5% 376 / 0 / 467

src/energyplus/ReverseTranslator/ReverseTranslateScheduleYear.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/ModelObject.hpp"
9
10 #include "../../model/ScheduleYear.hpp"
11 #include "../../model/ScheduleYear_Impl.hpp"
12 #include "../../model/ScheduleWeek.hpp"
13 #include "../../model/ScheduleWeek_Impl.hpp"
14
15 #include "../../model/ScheduleRuleset.hpp"
16 #include "../../model/ScheduleRuleset_Impl.hpp"
17 #include "../../model/ScheduleRule.hpp"
18 #include "../../model/ScheduleRule_Impl.hpp"
19 #include "../../model/ScheduleDay.hpp"
20 #include "../../model/ScheduleDay_Impl.hpp"
21
22 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
23 #include "../../utilities/idf/WorkspaceExtensibleGroup.hpp"
24
25 #include <utilities/idd/Schedule_Year_FieldEnums.hxx>
26 #include <utilities/idd/Schedule_Week_Compact_FieldEnums.hxx>
27 #include <utilities/idd/Schedule_Week_Daily_FieldEnums.hxx>
28
29 #include <utilities/idd/OS_Schedule_Year_FieldEnums.hxx>
30 #include <utilities/idd/OS_Schedule_Ruleset_FieldEnums.hxx>
31
32 #include "../../utilities/idd/IddEnums.hpp"
33 #include <utilities/idd/IddEnums.hxx>
34
35 #include "../../utilities/time/Date.hpp"
36 #include "../../utilities/core/ASCIIStrings.hpp"
37
38 using namespace openstudio::model;
39
40 namespace openstudio {
41
42 namespace energyplus {
43
44 struct SpecialDayScheduleNames
45 {
46 std::set<std::string> holidayScheduleDayNames;
47 std::set<std::string> summerDesignDayScheduleDayNames;
48 std::set<std::string> winterDesignDayScheduleDayNames;
49 std::set<std::string> customDay1ScheduleDayNames;
50 std::set<std::string> customDay2ScheduleDayNames;
51
52 48 [[nodiscard]] bool hasMoreThanOneSpecialDaysInEachType() const {
53
2/4
✓ Branch 2 taken 44 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 44 times.
✗ Branch 6 not taken.
92 return (holidayScheduleDayNames.size() > 1 || summerDesignDayScheduleDayNames.size() > 1 || winterDesignDayScheduleDayNames.size() > 1
54
4/6
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 4 times.
✓ Branch 3 taken 44 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 44 times.
92 || customDay1ScheduleDayNames.size() > 1 || customDay2ScheduleDayNames.size() > 1);
55 }
56 };
57
58 48 SpecialDayScheduleNames getSpecialDayScheduleNames(const WorkspaceObject& workspaceObject) {
59
60 48 SpecialDayScheduleNames specialDayScheduleNames;
61
1/1
✓ Branch 1 taken 48 times.
48 std::vector<IdfExtensibleGroup> extensibleGroups = workspaceObject.extensibleGroups();
62
2/2
✓ Branch 5 taken 65 times.
✓ Branch 6 taken 48 times.
113 for (const IdfExtensibleGroup& idfGroup : extensibleGroups) {
63
1/1
✓ Branch 1 taken 65 times.
65 auto workspaceGroup = idfGroup.cast<WorkspaceExtensibleGroup>();
64
65 // Schedule:Week:Daily, Schedule:Week:Compact
66
1/1
✓ Branch 1 taken 65 times.
65 OptionalWorkspaceObject scheduleWeek = workspaceGroup.getTarget(Schedule_YearExtensibleFields::Schedule_WeekName);
67
68
6/6
✓ Branch 1 taken 65 times.
✓ Branch 4 taken 65 times.
✓ Branch 7 taken 65 times.
✓ Branch 10 taken 65 times.
✓ Branch 14 taken 61 times.
✓ Branch 15 taken 4 times.
65 if (scheduleWeek->iddObject().type() == IddObjectType::Schedule_Week_Daily) {
69
3/4
✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 6 taken 61 times.
✗ Branch 7 not taken.
122 if (OptionalString holidayScheduleDayName = scheduleWeek->getString(Schedule_Week_DailyFields::HolidaySchedule_DayName)) {
70
2/2
✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
61 specialDayScheduleNames.holidayScheduleDayNames.emplace(*holidayScheduleDayName);
71 61 }
72
3/4
✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 6 taken 61 times.
✗ Branch 7 not taken.
122 if (OptionalString summerDesignDayScheduleDayName = scheduleWeek->getString(Schedule_Week_DailyFields::SummerDesignDaySchedule_DayName)) {
73
2/2
✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
61 specialDayScheduleNames.summerDesignDayScheduleDayNames.emplace(*summerDesignDayScheduleDayName);
74 61 }
75
3/4
✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 6 taken 61 times.
✗ Branch 7 not taken.
122 if (OptionalString winterDesignDayScheduleDayName = scheduleWeek->getString(Schedule_Week_DailyFields::WinterDesignDaySchedule_DayName)) {
76
2/2
✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
61 specialDayScheduleNames.winterDesignDayScheduleDayNames.emplace(*winterDesignDayScheduleDayName);
77 61 }
78
3/4
✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 6 taken 61 times.
✗ Branch 7 not taken.
122 if (OptionalString customDay1ScheduleDayName = scheduleWeek->getString(Schedule_Week_DailyFields::CustomDay1Schedule_DayName)) {
79
2/2
✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
61 specialDayScheduleNames.customDay1ScheduleDayNames.emplace(*customDay1ScheduleDayName);
80 61 }
81
3/4
✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 6 taken 61 times.
✗ Branch 7 not taken.
122 if (OptionalString customDay2ScheduleDayName = scheduleWeek->getString(Schedule_Week_DailyFields::CustomDay2Schedule_DayName)) {
82
2/2
✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
61 specialDayScheduleNames.customDay2ScheduleDayNames.emplace(*customDay2ScheduleDayName);
83 61 }
84
5/6
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 14 taken 4 times.
✗ Branch 15 not taken.
4 } else if (scheduleWeek->iddObject().type() == IddObjectType::Schedule_Week_Compact) {
85
86
4/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 11 taken 36 times.
✓ Branch 12 taken 4 times.
40 for (const IdfExtensibleGroup& dayTypeIdfGroup : scheduleWeek->extensibleGroups()) {
87
1/1
✓ Branch 1 taken 36 times.
36 auto dayTypeWorkspaceGroup = dayTypeIdfGroup.cast<WorkspaceExtensibleGroup>();
88
89
1/1
✓ Branch 1 taken 36 times.
36 boost::optional<std::string> dayType_ = dayTypeWorkspaceGroup.getString(Schedule_Week_CompactExtensibleFields::DayTypeList);
90
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 4 not taken.
36 OS_ASSERT(dayType_);
91
2/2
✓ Branch 1 taken 36 times.
✓ Branch 5 taken 36 times.
36 std::string dayTypeLower = openstudio::ascii_to_lower_copy(dayType_.get());
92
1/1
✓ Branch 1 taken 36 times.
36 boost::optional<std::string> scheduleDayName = dayTypeWorkspaceGroup.getString(Schedule_Week_CompactExtensibleFields::Schedule_DayName);
93
94
3/3
✓ Branch 1 taken 36 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 32 times.
36 if (dayTypeLower == "holiday") {
95
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 specialDayScheduleNames.holidayScheduleDayNames.emplace(*scheduleDayName);
96 }
97
2/3
✓ Branch 1 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
36 if (dayTypeLower == "summerdesignDay") {
98 ✗ specialDayScheduleNames.summerDesignDayScheduleDayNames.emplace(*scheduleDayName);
99 }
100
2/3
✓ Branch 1 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
36 if (dayTypeLower == "winterdesignDay") {
101 ✗ specialDayScheduleNames.winterDesignDayScheduleDayNames.emplace(*scheduleDayName);
102 }
103
3/3
✓ Branch 1 taken 36 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 32 times.
36 if (dayTypeLower == "customday1") {
104
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 specialDayScheduleNames.customDay1ScheduleDayNames.emplace(*scheduleDayName);
105 }
106
3/3
✓ Branch 1 taken 36 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 32 times.
36 if (dayTypeLower == "customday2") {
107
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 specialDayScheduleNames.customDay2ScheduleDayNames.emplace(*scheduleDayName);
108 }
109 40 }
110 }
111 65 }
112 96 return specialDayScheduleNames;
113 48 }
114
115 48 OptionalModelObject ReverseTranslator::translateScheduleYear(const WorkspaceObject& workspaceObject) {
116
4/5
✓ Branch 1 taken 48 times.
✓ Branch 4 taken 48 times.
✓ Branch 7 taken 48 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 48 times.
48 if (workspaceObject.iddObject().type() != IddObjectType::Schedule_Year) {
117 ✗ LOG(Error, "WorkspaceObject is not IddObjectType: Schedule:Year");
118 ✗ return boost::none;
119 }
120
121
1/1
✓ Branch 1 taken 48 times.
48 std::vector<IdfExtensibleGroup> extensibleGroups = workspaceObject.extensibleGroups();
122
1/1
✓ Branch 1 taken 48 times.
48 SpecialDayScheduleNames specialDayScheduleNames = getSpecialDayScheduleNames(workspaceObject);
123
124
2/2
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 44 times.
48 if (specialDayScheduleNames.hasMoreThanOneSpecialDaysInEachType()) {
125
1/1
✓ Branch 1 taken 4 times.
4 ScheduleYear scheduleYear(m_model);
126
127 //translate name
128
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 scheduleYear.setName(workspaceObject.nameString());
129
130 //translate schedule type limits name
131
1/1
✓ Branch 1 taken 4 times.
4 OptionalWorkspaceObject target = workspaceObject.getTarget(Schedule_YearFields::ScheduleTypeLimitsName);
132
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (target) {
133
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 OptionalModelObject scheduleTypeLimits = translateAndMapWorkspaceObject(*target);
134
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if (scheduleTypeLimits) {
135
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 scheduleYear.setPointer(OS_Schedule_YearFields::ScheduleTypeLimitsName, scheduleTypeLimits->handle());
136 }
137 4 }
138
139 //loop over extensible groups
140
141 4 unsigned n = extensibleGroups.size();
142
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 4 times.
14 for (unsigned i = 0; i < n; ++i) {
143 //read in extensible groups
144
1/1
✓ Branch 2 taken 10 times.
10 boost::optional<std::string> scheduleName = extensibleGroups[i].getString(Schedule_YearExtensibleFields::Schedule_WeekName);
145
1/1
✓ Branch 2 taken 10 times.
10 boost::optional<unsigned> startMonth = extensibleGroups[i].getUnsigned(Schedule_YearExtensibleFields::StartMonth);
146
1/1
✓ Branch 2 taken 10 times.
10 boost::optional<unsigned> startDay = extensibleGroups[i].getUnsigned(Schedule_YearExtensibleFields::StartDay);
147
1/1
✓ Branch 2 taken 10 times.
10 boost::optional<unsigned> endMonth = extensibleGroups[i].getUnsigned(Schedule_YearExtensibleFields::EndMonth);
148
1/1
✓ Branch 2 taken 10 times.
10 boost::optional<unsigned> endDay = extensibleGroups[i].getUnsigned(Schedule_YearExtensibleFields::EndDay);
149 // check for errors, assume sorted groups
150
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 6 times.
10 if (i == 0) {
151
3/8
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4 times.
4 if ((*startMonth != 1) && (*startDay != 1)) {
152 ✗ LOG(Error, *scheduleName + " does not start on January 1. Object not translated.");
153 ✗ return boost::none;
154 }
155
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
6 } else if (i == n - 1) {
156
3/8
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4 times.
4 if ((*endMonth != 12) && (*endDay != 31)) {
157 ✗ LOG(Error, *scheduleName + " does not end on December 31. Object not translated.");
158 ✗ return boost::none;
159 }
160 }
161 // reverse translate schedule week
162
2/2
✓ Branch 2 taken 10 times.
✓ Branch 5 taken 10 times.
10 target = extensibleGroups[i].cast<WorkspaceExtensibleGroup>().getTarget(Schedule_YearExtensibleFields::Schedule_WeekName);
163
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if (target) {
164
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
10 OptionalModelObject scheduleWeekName = translateAndMapWorkspaceObject(*target);
165
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if (scheduleWeekName) {
166
7/7
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✓ Branch 7 taken 10 times.
✓ Branch 10 taken 10 times.
✓ Branch 13 taken 10 times.
✓ Branch 16 taken 10 times.
✓ Branch 19 taken 10 times.
10 scheduleYear.addScheduleWeek(Date(*endMonth, *endDay), scheduleWeekName->cast<ScheduleWeek>());
167 }
168 10 }
169 10 }
170
171
1/1
✓ Branch 1 taken 4 times.
4 return scheduleYear;
172
173 4 } else {
174 // Special Days: for each type, not more than one exists (ScheduleRuleset can only accept a single one for each type)
175
176
1/1
✓ Branch 1 taken 44 times.
44 ScheduleRuleset scheduleRuleset(m_model);
177
178 // Name
179
2/2
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
44 scheduleRuleset.setName(workspaceObject.nameString());
180
181 // Schedule Type Limits Name
182
1/1
✓ Branch 1 taken 44 times.
44 OptionalWorkspaceObject target = workspaceObject.getTarget(Schedule_YearFields::ScheduleTypeLimitsName);
183
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if (target) {
184
2/2
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
44 OptionalModelObject scheduleTypeLimits = translateAndMapWorkspaceObject(*target);
185
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 3 times.
44 if (scheduleTypeLimits) {
186
3/3
✓ Branch 1 taken 41 times.
✓ Branch 4 taken 41 times.
✓ Branch 7 taken 41 times.
41 scheduleRuleset.setPointer(OS_Schedule_RulesetFields::ScheduleTypeLimitsName, scheduleTypeLimits->handle());
187 }
188 44 }
189
190 44 OptionalWorkspaceObject holidayScheduleDay;
191 44 OptionalWorkspaceObject summerDesignDayScheduleDay;
192 44 OptionalWorkspaceObject winterDesignDayScheduleDay;
193 44 OptionalWorkspaceObject customDay1ScheduleDay;
194 44 OptionalWorkspaceObject customDay2ScheduleDay;
195
196
2/2
✓ Branch 5 taken 55 times.
✓ Branch 6 taken 44 times.
99 for (const IdfExtensibleGroup& idfGroup : extensibleGroups) {
197
1/1
✓ Branch 1 taken 55 times.
55 auto workspaceGroup = idfGroup.cast<WorkspaceExtensibleGroup>();
198
199 OptionalWorkspaceObject scheduleWeek =
200
1/1
✓ Branch 1 taken 55 times.
55 workspaceGroup.getTarget(Schedule_YearExtensibleFields::Schedule_WeekName); // Schedule:Week:Daily, Schedule:Week:Compact
201
1/1
✓ Branch 1 taken 55 times.
55 OptionalInt startMonth = workspaceGroup.getInt(Schedule_YearExtensibleFields::StartMonth);
202
1/1
✓ Branch 1 taken 55 times.
55 OptionalInt startDay = workspaceGroup.getInt(Schedule_YearExtensibleFields::StartDay);
203
1/1
✓ Branch 1 taken 55 times.
55 OptionalInt endMonth = workspaceGroup.getInt(Schedule_YearExtensibleFields::EndMonth);
204
1/1
✓ Branch 1 taken 55 times.
55 OptionalInt endDay = workspaceGroup.getInt(Schedule_YearExtensibleFields::EndDay);
205
206
4/4
✓ Branch 1 taken 55 times.
✓ Branch 4 taken 55 times.
✓ Branch 7 taken 55 times.
✓ Branch 10 taken 55 times.
55 Date startDate(*startMonth, *startDay);
207
4/4
✓ Branch 1 taken 55 times.
✓ Branch 4 taken 55 times.
✓ Branch 7 taken 55 times.
✓ Branch 10 taken 55 times.
55 Date endDate(*endMonth, *endDay);
208
209 55 std::vector<std::string> dayScheduleNames;
210 55 std::vector<ScheduleRule> scheduleRules;
211
212 // Lambda helper, not making it into a function since I need the ReverseTranslator context to call translateAndMapWorkspaceObject and I don't
213 // want to define it into the ReverseTranslator.hpp
214 373 auto getOrCreateRule = [this, &scheduleRuleset, &startDate, &endDate, &dayScheduleNames,
215 &scheduleRules](const boost::optional<WorkspaceObject>& scheduleDay, const std::string& scheduleWeekName) {
216 373 boost::optional<ScheduleRule> scheduleRule;
217
218
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if (scheduleDay) {
219
2/2
✓ Branch 1 taken 373 times.
✓ Branch 4 taken 373 times.
373 std::string scheduleDayName = scheduleDay->nameString();
220
221
1/1
✓ Branch 3 taken 373 times.
373 auto it = std::find(dayScheduleNames.begin(), dayScheduleNames.end(), scheduleDayName);
222
2/2
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 80 times.
373 if (it != dayScheduleNames.end()) {
223
1/1
✓ Branch 4 taken 293 times.
293 scheduleRule = scheduleRules[it - dayScheduleNames.begin()];
224 } else {
225
3/4
✓ Branch 1 taken 80 times.
✓ Branch 4 taken 80 times.
✓ Branch 6 taken 80 times.
✗ Branch 7 not taken.
160 if (OptionalModelObject mo_daySchedule = translateAndMapWorkspaceObject(*scheduleDay)) {
226
2/2
✓ Branch 1 taken 80 times.
✓ Branch 4 taken 80 times.
80 auto daySchedule = mo_daySchedule->cast<ScheduleDay>();
227 // TODO: this clones daySchedule and sets the clone with a different name, which is annoying
228
229
2/2
✓ Branch 1 taken 80 times.
✓ Branch 4 taken 80 times.
80 scheduleRule = ScheduleRule(scheduleRuleset, daySchedule);
230 // LOG(Debug, "Creating a new rule named " << scheduleRule->nameString() << " for " << scheduleWeekName << " with daySchedule"
231 // << daySchedule.nameString() << ", startDate=" << startDate << ", endDate=" << endDate);
232
2/2
✓ Branch 1 taken 80 times.
✓ Branch 4 taken 80 times.
80 scheduleRule->setName(scheduleWeekName);
233
2/2
✓ Branch 1 taken 80 times.
✓ Branch 4 taken 80 times.
80 scheduleRule->setStartDate(startDate);
234
2/2
✓ Branch 1 taken 80 times.
✓ Branch 4 taken 80 times.
80 scheduleRule->setEndDate(endDate);
235
236
1/1
✓ Branch 1 taken 80 times.
80 dayScheduleNames.push_back(scheduleDayName);
237
2/2
✓ Branch 1 taken 80 times.
✓ Branch 4 taken 80 times.
80 scheduleRules.push_back(*scheduleRule);
238 160 }
239 }
240 373 }
241
242 373 return scheduleRule;
243 ✗ };
244
245
6/6
✓ Branch 1 taken 55 times.
✓ Branch 4 taken 55 times.
✓ Branch 7 taken 55 times.
✓ Branch 10 taken 55 times.
✓ Branch 14 taken 51 times.
✓ Branch 15 taken 4 times.
55 if (scheduleWeek->iddObject().type() == IddObjectType::Schedule_Week_Daily) {
246
247 // Handled at the end (common path)
248
2/2
✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
51 holidayScheduleDay = scheduleWeek->getTarget(Schedule_Week_DailyFields::HolidaySchedule_DayName);
249
2/2
✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
51 summerDesignDayScheduleDay = scheduleWeek->getTarget(Schedule_Week_DailyFields::SummerDesignDaySchedule_DayName);
250
2/2
✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
51 winterDesignDayScheduleDay = scheduleWeek->getTarget(Schedule_Week_DailyFields::WinterDesignDaySchedule_DayName);
251
2/2
✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
51 customDay1ScheduleDay = scheduleWeek->getTarget(Schedule_Week_DailyFields::CustomDay1Schedule_DayName);
252
2/2
✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
51 customDay2ScheduleDay = scheduleWeek->getTarget(Schedule_Week_DailyFields::CustomDay2Schedule_DayName);
253
254
4/4
✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
✓ Branch 7 taken 51 times.
✓ Branch 10 taken 51 times.
51 std::string scheduleWeekDailyName = scheduleWeek->getString(Schedule_Week_DailyFields::Name).get();
255
4/5
✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
✓ Branch 7 taken 51 times.
✓ Branch 11 taken 51 times.
✗ Branch 12 not taken.
102 if (auto schRule_ = getOrCreateRule(scheduleWeek->getTarget(Schedule_Week_DailyFields::SundaySchedule_DayName), scheduleWeekDailyName)) {
256
2/2
✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
51 schRule_->setApplySunday(true);
257 51 }
258
4/5
✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
✓ Branch 7 taken 51 times.
✓ Branch 11 taken 51 times.
✗ Branch 12 not taken.
102 if (auto schRule_ = getOrCreateRule(scheduleWeek->getTarget(Schedule_Week_DailyFields::MondaySchedule_DayName), scheduleWeekDailyName)) {
259
2/2
✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
51 schRule_->setApplyMonday(true);
260 51 }
261
4/5
✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
✓ Branch 7 taken 51 times.
✓ Branch 11 taken 51 times.
✗ Branch 12 not taken.
102 if (auto schRule_ = getOrCreateRule(scheduleWeek->getTarget(Schedule_Week_DailyFields::TuesdaySchedule_DayName), scheduleWeekDailyName)) {
262
2/2
✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
51 schRule_->setApplyTuesday(true);
263 51 }
264
4/5
✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
✓ Branch 7 taken 51 times.
✓ Branch 11 taken 51 times.
✗ Branch 12 not taken.
102 if (auto schRule_ = getOrCreateRule(scheduleWeek->getTarget(Schedule_Week_DailyFields::WednesdaySchedule_DayName), scheduleWeekDailyName)) {
265
2/2
✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
51 schRule_->setApplyWednesday(true);
266 51 }
267
4/5
✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
✓ Branch 7 taken 51 times.
✓ Branch 11 taken 51 times.
✗ Branch 12 not taken.
102 if (auto schRule_ = getOrCreateRule(scheduleWeek->getTarget(Schedule_Week_DailyFields::ThursdaySchedule_DayName), scheduleWeekDailyName)) {
268
2/2
✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
51 schRule_->setApplyThursday(true);
269 51 }
270
4/5
✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
✓ Branch 7 taken 51 times.
✓ Branch 11 taken 51 times.
✗ Branch 12 not taken.
102 if (auto schRule_ = getOrCreateRule(scheduleWeek->getTarget(Schedule_Week_DailyFields::FridaySchedule_DayName), scheduleWeekDailyName)) {
271
2/2
✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
51 schRule_->setApplyFriday(true);
272 51 }
273
4/5
✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
✓ Branch 7 taken 51 times.
✓ Branch 11 taken 51 times.
✗ Branch 12 not taken.
102 if (auto schRule_ = getOrCreateRule(scheduleWeek->getTarget(Schedule_Week_DailyFields::SaturdaySchedule_DayName), scheduleWeekDailyName)) {
274
2/2
✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
51 schRule_->setApplySaturday(true);
275 51 }
276
277
5/6
✓ Branch 2 taken 4 times.
✓ Branch 5 taken 4 times.
✓ Branch 8 taken 4 times.
✓ Branch 11 taken 4 times.
✓ Branch 15 taken 4 times.
✗ Branch 16 not taken.
55 } else if (scheduleWeek->iddObject().type() == IddObjectType::Schedule_Week_Compact) {
278
279
4/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
4 std::string scheduleWeekCompactName = scheduleWeek->getString(Schedule_Week_CompactFields::Name).get();
280
281
4/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 11 taken 36 times.
✓ Branch 12 taken 4 times.
40 for (const IdfExtensibleGroup& dayTypeIdfGroup : scheduleWeek->extensibleGroups()) {
282
1/1
✓ Branch 1 taken 36 times.
36 auto dayTypeWorkspaceGroup = dayTypeIdfGroup.cast<WorkspaceExtensibleGroup>();
283
284
3/3
✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
✓ Branch 7 taken 36 times.
36 std::string dayType = dayTypeWorkspaceGroup.getString(Schedule_Week_CompactExtensibleFields::DayTypeList).get();
285
1/1
✓ Branch 2 taken 36 times.
36 std::string dayTypeLower = openstudio::ascii_to_lower_copy(dayType);
286
1/1
✓ Branch 1 taken 36 times.
36 OptionalWorkspaceObject scheduleDay = dayTypeWorkspaceGroup.getTarget(Schedule_Week_CompactExtensibleFields::Schedule_DayName);
287
288
3/3
✓ Branch 1 taken 36 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 32 times.
36 if (dayTypeLower == "holiday") {
289
1/1
✓ Branch 1 taken 4 times.
4 holidayScheduleDay = scheduleDay;
290
3/3
✓ Branch 1 taken 32 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 28 times.
32 } else if (dayTypeLower == "summerdesignday") {
291
1/1
✓ Branch 1 taken 4 times.
4 summerDesignDayScheduleDay = scheduleDay;
292
3/3
✓ Branch 1 taken 28 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 24 times.
28 } else if (dayTypeLower == "winterdesignday") {
293
1/1
✓ Branch 1 taken 4 times.
4 winterDesignDayScheduleDay = scheduleDay;
294
3/3
✓ Branch 1 taken 24 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 20 times.
24 } else if (dayTypeLower == "customday1") {
295
1/1
✓ Branch 1 taken 4 times.
4 customDay1ScheduleDay = scheduleDay;
296
3/3
✓ Branch 1 taken 20 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 16 times.
20 } else if (dayTypeLower == "customday2") {
297
1/1
✓ Branch 1 taken 4 times.
4 customDay2ScheduleDay = scheduleDay;
298
2/3
✓ Branch 1 taken 16 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
32 } else if (auto schRule_ = getOrCreateRule(scheduleDay, scheduleWeekCompactName)) {
299 // TODO: allotherdays not correctly handled here
300
7/8
✓ Branch 1 taken 16 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 14 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 14 times.
✓ Branch 10 taken 2 times.
✓ Branch 11 taken 14 times.
16 if (dayTypeLower == "alldays" || dayTypeLower == "allotherdays") {
301
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 schRule_->setApplySunday(true);
302
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 schRule_->setApplyMonday(true);
303
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 schRule_->setApplyTuesday(true);
304
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 schRule_->setApplyWednesday(true);
305
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 schRule_->setApplyThursday(true);
306
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 schRule_->setApplyFriday(true);
307
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 schRule_->setApplySaturday(true);
308
2/3
✓ Branch 1 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
14 } else if (dayTypeLower == "weekdays") {
309 ✗ schRule_->setApplyMonday(true);
310 ✗ schRule_->setApplyTuesday(true);
311 ✗ schRule_->setApplyWednesday(true);
312 ✗ schRule_->setApplyThursday(true);
313 ✗ schRule_->setApplyFriday(true);
314
2/3
✓ Branch 1 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
14 } else if (dayTypeLower == "weekends") {
315 ✗ schRule_->setApplySunday(true);
316 ✗ schRule_->setApplySaturday(true);
317
3/3
✓ Branch 1 taken 14 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 12 times.
14 } else if (dayTypeLower == "sunday") {
318
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 schRule_->setApplySunday(true);
319
3/3
✓ Branch 1 taken 12 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 10 times.
12 } else if (dayTypeLower == "monday") {
320
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 schRule_->setApplyMonday(true);
321
3/3
✓ Branch 1 taken 10 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 8 times.
10 } else if (dayTypeLower == "tuesday") {
322
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 schRule_->setApplyTuesday(true);
323
3/3
✓ Branch 1 taken 8 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 6 times.
8 } else if (dayTypeLower == "wednesday") {
324
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 schRule_->setApplyWednesday(true);
325
3/3
✓ Branch 1 taken 6 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 4 times.
6 } else if (dayTypeLower == "thursday") {
326
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 schRule_->setApplyThursday(true);
327
3/3
✓ Branch 1 taken 4 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
4 } else if (dayTypeLower == "friday") {
328
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 schRule_->setApplyFriday(true);
329
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
2 } else if (dayTypeLower == "saturday") {
330
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 schRule_->setApplySaturday(true);
331 }
332 16 }
333 40 }
334 4 }
335 55 } // End loop on extensible groups
336
337 // Common path to both Schedule_Week_Daily and Schedule_Week_Compact
338
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if (holidayScheduleDay) {
339
3/4
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 6 taken 44 times.
✗ Branch 7 not taken.
88 if (auto mo_ = translateAndMapWorkspaceObject(*holidayScheduleDay)) {
340
2/2
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
44 auto scheduleDay = mo_->cast<ScheduleDay>();
341
1/1
✓ Branch 1 taken 44 times.
44 scheduleRuleset.setHolidaySchedule(scheduleDay);
342 88 }
343 }
344
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if (summerDesignDayScheduleDay) {
345
3/4
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 6 taken 44 times.
✗ Branch 7 not taken.
88 if (auto mo_ = translateAndMapWorkspaceObject(*summerDesignDayScheduleDay)) {
346
2/2
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
44 auto scheduleDay = mo_->cast<ScheduleDay>();
347
1/1
✓ Branch 1 taken 44 times.
44 scheduleRuleset.setSummerDesignDaySchedule(scheduleDay);
348 88 }
349 }
350
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if (winterDesignDayScheduleDay) {
351
3/4
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 6 taken 44 times.
✗ Branch 7 not taken.
88 if (auto mo_ = translateAndMapWorkspaceObject(*winterDesignDayScheduleDay)) {
352
2/2
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
44 auto scheduleDay = mo_->cast<ScheduleDay>();
353
1/1
✓ Branch 1 taken 44 times.
44 scheduleRuleset.setWinterDesignDaySchedule(scheduleDay);
354 88 }
355 }
356
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if (customDay1ScheduleDay) {
357
3/4
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 6 taken 44 times.
✗ Branch 7 not taken.
88 if (auto mo_ = translateAndMapWorkspaceObject(*customDay1ScheduleDay)) {
358
2/2
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
44 auto scheduleDay = mo_->cast<ScheduleDay>();
359
1/1
✓ Branch 1 taken 44 times.
44 scheduleRuleset.setCustomDay1Schedule(scheduleDay);
360 88 }
361 }
362
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if (customDay2ScheduleDay) {
363
3/4
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 6 taken 44 times.
✗ Branch 7 not taken.
88 if (auto mo_ = translateAndMapWorkspaceObject(*customDay2ScheduleDay)) {
364
2/2
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
44 auto scheduleDay = mo_->cast<ScheduleDay>();
365
1/1
✓ Branch 1 taken 44 times.
44 scheduleRuleset.setCustomDay2Schedule(scheduleDay);
366 88 }
367 }
368
1/1
✓ Branch 1 taken 44 times.
44 return scheduleRuleset;
369 44 } // end if hasMoreThanOneSpecialDaysInEachType()
370 48 }
371 } // namespace energyplus
372
373 } // namespace openstudio
374