-
Notifications
You must be signed in to change notification settings - Fork 195
/
ScheduleRuleset.cpp
649 lines (556 loc) · 24.8 KB
/
ScheduleRuleset.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
/***********************************************************************************************************************
* OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC, and other contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following
* disclaimer.
*
* (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided with the distribution.
*
* (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote products
* derived from this software without specific prior written permission from the respective party.
*
* (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative works
* may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without specific prior
* written permission from Alliance for Sustainable Energy, LLC.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE UNITED STATES GOVERNMENT, OR THE UNITED
* STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************************************************************/
#include "ScheduleRuleset.hpp"
#include "ScheduleRuleset_Impl.hpp"
#include "ScheduleRule.hpp"
#include "ScheduleRule_Impl.hpp"
#include "ScheduleDay.hpp"
#include "ScheduleDay_Impl.hpp"
#include "ScheduleTypeLimits.hpp"
#include "ScheduleTypeLimits_Impl.hpp"
#include "ScheduleTypeRegistry.hpp"
#include "YearDescription.hpp"
#include "YearDescription_Impl.hpp"
#include "Model.hpp"
#include "Model_Impl.hpp"
#include "ModelExtensibleGroup.hpp"
#include <utilities/idd/OS_Schedule_Ruleset_FieldEnums.hxx>
#include <utilities/idd/IddEnums.hxx>
#include "../utilities/core/Assert.hpp"
#include "../utilities/time/Date.hpp"
namespace openstudio {
namespace model {
namespace detail {
ScheduleRuleset_Impl::ScheduleRuleset_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
: Schedule_Impl(idfObject, model, keepHandle) {
OS_ASSERT(idfObject.iddObject().type() == ScheduleRuleset::iddObjectType());
}
ScheduleRuleset_Impl::ScheduleRuleset_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle)
: Schedule_Impl(other, model, keepHandle) {
OS_ASSERT(other.iddObject().type() == ScheduleRuleset::iddObjectType());
}
ScheduleRuleset_Impl::ScheduleRuleset_Impl(const ScheduleRuleset_Impl& other, Model_Impl* model, bool keepHandle)
: Schedule_Impl(other, model, keepHandle) {}
ModelObject ScheduleRuleset_Impl::clone(Model model) const {
ModelObject newScheduleRulesetAsModelObject = ModelObject_Impl::clone(model);
ScheduleRuleset newScheduleRuleset = newScheduleRulesetAsModelObject.cast<ScheduleRuleset>();
ModelObject newDefaultDaySchedule = defaultDaySchedule().clone(model);
bool test = newScheduleRuleset.setPointer(OS_Schedule_RulesetFields::DefaultDayScheduleName, newDefaultDaySchedule.handle());
OS_ASSERT(test);
if (!isSummerDesignDayScheduleDefaulted()) {
ModelObject newSummerDesignDaySchedule = summerDesignDaySchedule().clone(model);
test = newScheduleRuleset.setPointer(OS_Schedule_RulesetFields::SummerDesignDayScheduleName, newSummerDesignDaySchedule.handle());
OS_ASSERT(test);
}
if (!isWinterDesignDayScheduleDefaulted()) {
ModelObject newWinterDesignDaySchedule = winterDesignDaySchedule().clone(model);
test = newScheduleRuleset.setPointer(OS_Schedule_RulesetFields::WinterDesignDayScheduleName, newWinterDesignDaySchedule.handle());
OS_ASSERT(test);
}
if (!isHolidayScheduleDefaulted()) {
ModelObject newHolidaySchedule = holidaySchedule().clone(model);
test = newScheduleRuleset.setPointer(OS_Schedule_RulesetFields::HolidayScheduleName, newHolidaySchedule.handle());
OS_ASSERT(test);
}
for (ScheduleRule scheduleRule : scheduleRules()) {
ModelObject newScheduleRule = scheduleRule.clone(model);
test = newScheduleRule.setParent(newScheduleRuleset);
OS_ASSERT(test);
}
return newScheduleRulesetAsModelObject;
}
std::vector<ResourceObject> ScheduleRuleset_Impl::resources() const {
// remove daySchedule as a resource so it can be a child
ResourceObjectVector result = ModelObject_Impl::resources();
ScheduleDayVector daySchedules(1u, defaultDaySchedule());
if (!isSummerDesignDayScheduleDefaulted()) {
daySchedules.push_back(summerDesignDaySchedule());
}
if (!isWinterDesignDayScheduleDefaulted()) {
daySchedules.push_back(winterDesignDaySchedule());
}
if (!isHolidayScheduleDefaulted()) {
daySchedules.push_back(holidaySchedule());
}
auto it = result.begin();
while (it != result.end()) {
auto jit = std::find(daySchedules.begin(), daySchedules.end(), *it);
if (jit != daySchedules.end()) {
it = result.erase(it);
daySchedules.erase(jit);
} else {
++it;
}
}
return result;
}
std::vector<ModelObject> ScheduleRuleset_Impl::children() const {
std::vector<ModelObject> result;
// can add the ScheduleDays as children because removed from resource list
if (OptionalScheduleDay schedule = optionalDefaultDaySchedule()) {
result.push_back(*schedule);
}
if (!this->isSummerDesignDayScheduleDefaulted()) {
result.push_back(this->summerDesignDaySchedule());
}
if (!this->isWinterDesignDayScheduleDefaulted()) {
result.push_back(this->winterDesignDaySchedule());
}
if (!this->isHolidayScheduleDefaulted()) {
result.push_back(this->holidaySchedule());
}
for (ScheduleRule scheduleRule : this->scheduleRules()) {
result.push_back(scheduleRule);
}
return result;
}
const std::vector<std::string>& ScheduleRuleset_Impl::outputVariableNames() const {
static const std::vector<std::string> result{"Schedule Value"};
return result;
}
IddObjectType ScheduleRuleset_Impl::iddObjectType() const {
return ScheduleRuleset::iddObjectType();
}
boost::optional<ScheduleTypeLimits> ScheduleRuleset_Impl::scheduleTypeLimits() const {
return getObject<ModelObject>().getModelObjectTarget<ScheduleTypeLimits>(OS_Schedule_RulesetFields::ScheduleTypeLimitsName);
}
std::vector<double> ScheduleRuleset_Impl::values() const {
return DoubleVector();
}
bool ScheduleRuleset_Impl::setScheduleTypeLimits(const ScheduleTypeLimits& scheduleTypeLimits) {
if (scheduleTypeLimits.model() != model()) {
return false;
}
if (!candidateIsCompatibleWithCurrentUse(scheduleTypeLimits)) {
return false;
}
bool result = setPointer(OS_Schedule_RulesetFields::ScheduleTypeLimitsName, scheduleTypeLimits.handle());
if (result) {
result = defaultDaySchedule().setScheduleTypeLimits(scheduleTypeLimits);
OS_ASSERT(result);
if (!isSummerDesignDayScheduleDefaulted()) {
result = summerDesignDaySchedule().setScheduleTypeLimits(scheduleTypeLimits);
OS_ASSERT(result);
}
if (!isWinterDesignDayScheduleDefaulted()) {
result = winterDesignDaySchedule().setScheduleTypeLimits(scheduleTypeLimits);
OS_ASSERT(result);
}
if (!isHolidayScheduleDefaulted()) {
result = holidaySchedule().setScheduleTypeLimits(scheduleTypeLimits);
OS_ASSERT(result);
}
ScheduleRuleVector rules = scheduleRules();
for (const ScheduleRule& rule : rules) {
result = rule.daySchedule().setScheduleTypeLimits(scheduleTypeLimits);
OS_ASSERT(result);
}
}
return result;
}
bool ScheduleRuleset_Impl::resetScheduleTypeLimits() {
bool result(false);
if (okToResetScheduleTypeLimits()) {
result = setString(OS_Schedule_RulesetFields::ScheduleTypeLimitsName, "");
OS_ASSERT(result);
result = defaultDaySchedule().resetScheduleTypeLimits();
OS_ASSERT(result);
if (!isSummerDesignDayScheduleDefaulted()) {
result = summerDesignDaySchedule().resetScheduleTypeLimits();
OS_ASSERT(result);
}
if (!isWinterDesignDayScheduleDefaulted()) {
result = winterDesignDaySchedule().resetScheduleTypeLimits();
OS_ASSERT(result);
}
if (!isHolidayScheduleDefaulted()) {
result = holidaySchedule().resetScheduleTypeLimits();
OS_ASSERT(result);
}
ScheduleRuleVector rules = scheduleRules();
for (ScheduleRule& rule : rules) {
result = rule.daySchedule().resetScheduleTypeLimits();
OS_ASSERT(result);
}
}
return result;
}
ScheduleDay ScheduleRuleset_Impl::defaultDaySchedule() const {
OptionalScheduleDay result = optionalDefaultDaySchedule();
if (!result) {
LOG_AND_THROW(briefDescription() << " has been corrupted. It no longer points to a default "
<< "OS:Schedule:Day object.");
}
return *result;
}
ScheduleDay ScheduleRuleset_Impl::summerDesignDaySchedule() const {
OptionalScheduleDay result =
getObject<ScheduleRuleset>().getModelObjectTarget<ScheduleDay>(OS_Schedule_RulesetFields::SummerDesignDayScheduleName);
if (result) {
return *result;
}
return this->defaultDaySchedule();
}
bool ScheduleRuleset_Impl::isSummerDesignDayScheduleDefaulted() const {
return this->isEmpty(OS_Schedule_RulesetFields::SummerDesignDayScheduleName);
}
ScheduleDay ScheduleRuleset_Impl::winterDesignDaySchedule() const {
OptionalScheduleDay result =
getObject<ScheduleRuleset>().getModelObjectTarget<ScheduleDay>(OS_Schedule_RulesetFields::WinterDesignDayScheduleName);
if (result) {
return *result;
}
return this->defaultDaySchedule();
}
bool ScheduleRuleset_Impl::isWinterDesignDayScheduleDefaulted() const {
return this->isEmpty(OS_Schedule_RulesetFields::WinterDesignDayScheduleName);
}
ScheduleDay ScheduleRuleset_Impl::holidaySchedule() const {
OptionalScheduleDay result = getObject<ScheduleRuleset>().getModelObjectTarget<ScheduleDay>(OS_Schedule_RulesetFields::HolidayScheduleName);
if (result) {
return *result;
}
return this->defaultDaySchedule();
}
bool ScheduleRuleset_Impl::isHolidayScheduleDefaulted() const {
return this->isEmpty(OS_Schedule_RulesetFields::HolidayScheduleName);
}
bool ScheduleRuleset_Impl::setSummerDesignDaySchedule(const ScheduleDay& schedule) {
if (OptionalScheduleTypeLimits candidateLimits = schedule.scheduleTypeLimits()) {
if (OptionalScheduleTypeLimits parentLimits = scheduleTypeLimits()) {
if (!isCompatible(*parentLimits, *candidateLimits)) {
return false;
}
} else {
return false;
}
}
boost::optional<ScheduleDay> existingSummerDDSchedule;
if (!this->isSummerDesignDayScheduleDefaulted()) {
existingSummerDDSchedule = this->summerDesignDaySchedule();
}
ModelObject clone = schedule.clone();
bool result = setPointer(OS_Schedule_RulesetFields::SummerDesignDayScheduleName, clone.handle());
OS_ASSERT(result);
if (OptionalScheduleTypeLimits limits = scheduleTypeLimits()) {
result = summerDesignDaySchedule().setScheduleTypeLimits(*limits);
OS_ASSERT(result);
}
if (existingSummerDDSchedule) {
existingSummerDDSchedule->remove();
}
return result;
}
void ScheduleRuleset_Impl::resetSummerDesignDaySchedule() {
boost::optional<ScheduleDay> existingSummerDDSchedule;
if (!this->isSummerDesignDayScheduleDefaulted()) {
existingSummerDDSchedule = this->summerDesignDaySchedule();
}
bool test = this->setString(OS_Schedule_RulesetFields::SummerDesignDayScheduleName, "");
OS_ASSERT(test);
if (existingSummerDDSchedule) {
existingSummerDDSchedule->remove();
}
}
bool ScheduleRuleset_Impl::setWinterDesignDaySchedule(const ScheduleDay& schedule) {
if (OptionalScheduleTypeLimits candidateLimits = schedule.scheduleTypeLimits()) {
if (OptionalScheduleTypeLimits parentLimits = scheduleTypeLimits()) {
if (!isCompatible(*parentLimits, *candidateLimits)) {
return false;
}
} else {
return false;
}
}
boost::optional<ScheduleDay> existingWinterDDSchedule;
if (!this->isWinterDesignDayScheduleDefaulted()) {
ScheduleDay existingWinterDDSchedule = this->winterDesignDaySchedule();
}
ModelObject clone = schedule.clone();
bool result = setPointer(OS_Schedule_RulesetFields::WinterDesignDayScheduleName, clone.handle());
OS_ASSERT(result);
if (OptionalScheduleTypeLimits limits = scheduleTypeLimits()) {
result = winterDesignDaySchedule().setScheduleTypeLimits(*limits);
OS_ASSERT(result);
}
if (existingWinterDDSchedule) {
existingWinterDDSchedule->remove();
}
return result;
}
void ScheduleRuleset_Impl::resetWinterDesignDaySchedule() {
boost::optional<ScheduleDay> existingWinterDDSchedule;
if (!this->isWinterDesignDayScheduleDefaulted()) {
existingWinterDDSchedule = this->winterDesignDaySchedule();
}
bool test = this->setString(OS_Schedule_RulesetFields::WinterDesignDayScheduleName, "");
OS_ASSERT(test);
if (existingWinterDDSchedule) {
existingWinterDDSchedule->remove();
}
}
bool ScheduleRuleset_Impl::setHolidaySchedule(const ScheduleDay& schedule) {
if (OptionalScheduleTypeLimits candidateLimits = schedule.scheduleTypeLimits()) {
if (OptionalScheduleTypeLimits parentLimits = scheduleTypeLimits()) {
if (!isCompatible(*parentLimits, *candidateLimits)) {
return false;
}
} else {
return false;
}
}
boost::optional<ScheduleDay> existingHolidaySchedule;
if (!this->isHolidayScheduleDefaulted()) {
existingHolidaySchedule = this->holidaySchedule();
}
ModelObject clone = schedule.clone();
bool result = setPointer(OS_Schedule_RulesetFields::HolidayScheduleName, clone.handle());
OS_ASSERT(result);
if (OptionalScheduleTypeLimits limits = scheduleTypeLimits()) {
result = holidaySchedule().setScheduleTypeLimits(*limits);
OS_ASSERT(result);
}
if (existingHolidaySchedule) {
existingHolidaySchedule->remove();
}
return result;
}
void ScheduleRuleset_Impl::resetHolidaySchedule() {
boost::optional<ScheduleDay> existingHolidaySchedule;
if (!this->isHolidayScheduleDefaulted()) {
existingHolidaySchedule = this->holidaySchedule();
}
bool test = this->setString(OS_Schedule_RulesetFields::HolidayScheduleName, "");
OS_ASSERT(test);
if (existingHolidaySchedule) {
existingHolidaySchedule->remove();
}
}
struct ScheduleRuleIndexCompare
{
bool operator()(const ScheduleRule& left, const ScheduleRule& right) const {
return (left.ruleIndex() < right.ruleIndex());
}
};
std::vector<ScheduleRule> ScheduleRuleset_Impl::scheduleRules() const {
std::vector<ScheduleRule> result = this->getObject<ModelObject>().getModelObjectSources<ScheduleRule>(ScheduleRule::iddObjectType());
std::sort(result.begin(), result.end(), ScheduleRuleIndexCompare());
return result;
}
bool ScheduleRuleset_Impl::setScheduleRuleIndex(ScheduleRule& scheduleRule, unsigned index) {
std::vector<ScheduleRule> scheduleRules = this->scheduleRules();
unsigned N = scheduleRules.size();
boost::optional<unsigned> indexFound;
for (unsigned i = 0; i < N; ++i) {
if (scheduleRule.handle() == scheduleRules[i].handle()) {
indexFound = i;
if (indexFound == index) {
if (scheduleRule.ruleIndex() == (int)index) {
return true;
}
}
// set index for target rule, when called in constructor this rule has no index
scheduleRule.setRuleIndex(index);
break;
}
}
if (!indexFound) {
return false;
}
int increment = 0;
for (unsigned i = 0; i < N; ++i) {
// have to move remaining rules up to fill hole
if (i == indexFound) {
increment--;
continue;
}
// have to move this and remaining cells down
if (i == index) {
if (index < indexFound) {
increment++;
}
}
if (increment != 0) {
OS_ASSERT(i + increment >= 0);
unsigned newIndex = i + increment;
OS_ASSERT(newIndex < N);
scheduleRules[i].setRuleIndex(newIndex);
}
// have to move this and remaining cells down
if (i == index) {
if (index > indexFound) {
increment++;
}
}
}
return true;
}
std::vector<int> ScheduleRuleset_Impl::getActiveRuleIndices(const openstudio::Date& startDate, const openstudio::Date& endDate) const {
// need to check or adjust assumed base year on input date?
// populate dates to check
std::vector<openstudio::Date> dates;
if (startDate <= endDate) {
openstudio::Date date = startDate;
while (date <= endDate) {
dates.push_back(date);
date += Time(1);
}
} else {
openstudio::Date date = startDate;
openstudio::Date endOfYear(MonthOfYear::Dec, 31);
while (date <= endOfYear) {
dates.push_back(date);
date += Time(1);
}
date = openstudio::Date(MonthOfYear::Jan, 1);
while (date <= endDate) {
dates.push_back(date);
date += Time(1);
}
}
unsigned numDates = dates.size();
// check if each rule contains each date
std::vector<ScheduleRule> scheduleRules = this->scheduleRules();
unsigned numRules = scheduleRules.size();
std::vector<std::vector<bool>> test;
for (unsigned i = 0; i < numRules; ++i) {
test.push_back(scheduleRules[i].containsDates(dates));
}
// now create result
std::vector<int> result(numDates, -1);
for (unsigned j = 0; j < numDates; ++j) {
for (unsigned i = 0; i < numRules; ++i) {
if (test[i][j]) {
result[j] = i;
break;
}
}
}
return result;
}
std::vector<ScheduleDay> ScheduleRuleset_Impl::getDaySchedules(const openstudio::Date& startDate, const openstudio::Date& endDate) const {
std::vector<ScheduleDay> result;
ScheduleDay defaultDaySchedule = this->defaultDaySchedule();
std::vector<ScheduleRule> scheduleRules = this->scheduleRules();
std::vector<int> activeRuleIndices = this->getActiveRuleIndices(startDate, endDate);
for (int i : activeRuleIndices) {
if (i == -1) {
result.push_back(defaultDaySchedule);
} else {
result.push_back(scheduleRules[i].daySchedule());
}
}
return result;
}
bool ScheduleRuleset_Impl::moveToEnd(ScheduleRule& scheduleRule) {
std::vector<ScheduleRule> scheduleRules = this->scheduleRules();
return setScheduleRuleIndex(scheduleRule, scheduleRules.size() - 1);
}
void ScheduleRuleset_Impl::ensureNoLeapDays() {
for (ScheduleRule scheduleRule : this->scheduleRules()) {
scheduleRule.ensureNoLeapDays();
}
}
boost::optional<ScheduleDay> ScheduleRuleset_Impl::optionalDefaultDaySchedule() const {
return getObject<ScheduleRuleset>().getModelObjectTarget<ScheduleDay>(OS_Schedule_RulesetFields::DefaultDayScheduleName);
}
} // namespace detail
ScheduleRuleset::ScheduleRuleset(const Model& model) : Schedule(ScheduleRuleset::iddObjectType(), model) {
OS_ASSERT(getImpl<detail::ScheduleRuleset_Impl>());
ScheduleDay defaultDaySchedule(model);
getImpl<detail::ScheduleRuleset_Impl>()->setPointer(OS_Schedule_RulesetFields::DefaultDayScheduleName, defaultDaySchedule.handle());
}
ScheduleRuleset::ScheduleRuleset(const Model& model, double value) : Schedule(ScheduleRuleset::iddObjectType(), model) {
OS_ASSERT(getImpl<detail::ScheduleRuleset_Impl>());
ScheduleDay defaultDaySchedule(model, value);
getImpl<detail::ScheduleRuleset_Impl>()->setPointer(OS_Schedule_RulesetFields::DefaultDayScheduleName, defaultDaySchedule.handle());
}
IddObjectType ScheduleRuleset::iddObjectType() {
IddObjectType result(IddObjectType::OS_Schedule_Ruleset);
return result;
}
/// @cond
ScheduleRuleset::ScheduleRuleset(std::shared_ptr<detail::ScheduleRuleset_Impl> impl) : Schedule(std::move(impl)) {}
/// @endcond
ScheduleDay ScheduleRuleset::defaultDaySchedule() const {
return getImpl<detail::ScheduleRuleset_Impl>()->defaultDaySchedule();
}
ScheduleDay ScheduleRuleset::summerDesignDaySchedule() const {
return getImpl<detail::ScheduleRuleset_Impl>()->summerDesignDaySchedule();
}
bool ScheduleRuleset::isSummerDesignDayScheduleDefaulted() const {
return getImpl<detail::ScheduleRuleset_Impl>()->isSummerDesignDayScheduleDefaulted();
}
ScheduleDay ScheduleRuleset::winterDesignDaySchedule() const {
return getImpl<detail::ScheduleRuleset_Impl>()->winterDesignDaySchedule();
}
bool ScheduleRuleset::isWinterDesignDayScheduleDefaulted() const {
return getImpl<detail::ScheduleRuleset_Impl>()->isWinterDesignDayScheduleDefaulted();
}
ScheduleDay ScheduleRuleset::holidaySchedule() const {
return getImpl<detail::ScheduleRuleset_Impl>()->holidaySchedule();
}
bool ScheduleRuleset::isHolidayScheduleDefaulted() const {
return getImpl<detail::ScheduleRuleset_Impl>()->isHolidayScheduleDefaulted();
}
bool ScheduleRuleset::setSummerDesignDaySchedule(const ScheduleDay& schedule) {
return getImpl<detail::ScheduleRuleset_Impl>()->setSummerDesignDaySchedule(schedule);
}
void ScheduleRuleset::resetSummerDesignDaySchedule() {
return getImpl<detail::ScheduleRuleset_Impl>()->resetSummerDesignDaySchedule();
}
bool ScheduleRuleset::setWinterDesignDaySchedule(const ScheduleDay& schedule) {
return getImpl<detail::ScheduleRuleset_Impl>()->setWinterDesignDaySchedule(schedule);
}
void ScheduleRuleset::resetWinterDesignDaySchedule() {
return getImpl<detail::ScheduleRuleset_Impl>()->resetWinterDesignDaySchedule();
}
bool ScheduleRuleset::setHolidaySchedule(const ScheduleDay& schedule) {
return getImpl<detail::ScheduleRuleset_Impl>()->setHolidaySchedule(schedule);
}
void ScheduleRuleset::resetHolidaySchedule() {
return getImpl<detail::ScheduleRuleset_Impl>()->resetHolidaySchedule();
}
std::vector<ScheduleRule> ScheduleRuleset::scheduleRules() const {
return getImpl<detail::ScheduleRuleset_Impl>()->scheduleRules();
}
bool ScheduleRuleset::setScheduleRuleIndex(ScheduleRule& scheduleRule, unsigned index) {
return getImpl<detail::ScheduleRuleset_Impl>()->setScheduleRuleIndex(scheduleRule, index);
}
std::vector<int> ScheduleRuleset::getActiveRuleIndices(const openstudio::Date& startDate, const openstudio::Date& endDate) const {
return getImpl<detail::ScheduleRuleset_Impl>()->getActiveRuleIndices(startDate, endDate);
}
std::vector<ScheduleDay> ScheduleRuleset::getDaySchedules(const openstudio::Date& startDate, const openstudio::Date& endDate) const {
return getImpl<detail::ScheduleRuleset_Impl>()->getDaySchedules(startDate, endDate);
}
bool ScheduleRuleset::moveToEnd(ScheduleRule& scheduleRule) {
return getImpl<detail::ScheduleRuleset_Impl>()->moveToEnd(scheduleRule);
}
} // namespace model
} // namespace openstudio