src/model/ScheduleBase.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 "ScheduleBase.hpp" | ||
| 7 | #include "ScheduleBase_Impl.hpp" | ||
| 8 | |||
| 9 | #include "ScheduleTypeLimits.hpp" | ||
| 10 | #include "ScheduleTypeLimits_Impl.hpp" | ||
| 11 | |||
| 12 | #include "../utilities/idf/ValidityReport.hpp" | ||
| 13 | |||
| 14 | #include "../utilities/core/Assert.hpp" | ||
| 15 | |||
| 16 | namespace openstudio { | ||
| 17 | namespace model { | ||
| 18 | |||
| 19 | namespace detail { | ||
| 20 | |||
| 21 | // constructor | ||
| 22 | 18699 | ScheduleBase_Impl::ScheduleBase_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 23 | 18699 | : ResourceObject_Impl(idfObject, model, keepHandle) {} | |
| 24 | |||
| 25 | 5248 | ScheduleBase_Impl::ScheduleBase_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) | |
| 26 | 5248 | : ResourceObject_Impl(other, model, keepHandle) {} | |
| 27 | |||
| 28 | 16634 | ScheduleBase_Impl::ScheduleBase_Impl(const ScheduleBase_Impl& other, Model_Impl* model, bool keepHandles) | |
| 29 | 16634 | : ResourceObject_Impl(other, model, keepHandles) {} | |
| 30 | |||
| 31 | ✗ | bool ScheduleBase_Impl::okToResetScheduleTypeLimits() const { | |
| 32 | // can only reset if not used by object with keys | ||
| 33 | ✗ | for (const ModelObject& user : getObject<ScheduleBase>().getModelObjectSources<ModelObject>()) { | |
| 34 | ✗ | if (!user.optionalCast<ScheduleBase>()) { | |
| 35 | ✗ | return false; | |
| 36 | } | ||
| 37 | ✗ | } | |
| 38 | ✗ | return true; | |
| 39 | } | ||
| 40 | |||
| 41 | ✗ | bool ScheduleBase_Impl::valuesAreWithinBounds() const { | |
| 42 | ✗ | if (OptionalScheduleTypeLimits scheduleTypeLimits = this->scheduleTypeLimits()) { | |
| 43 | ✗ | OptionalDouble minBound = scheduleTypeLimits->lowerLimitValue(); | |
| 44 | ✗ | OptionalDouble maxBound = scheduleTypeLimits->upperLimitValue(); | |
| 45 | ✗ | if (minBound || maxBound) { | |
| 46 | ✗ | for (double value : values()) { | |
| 47 | ✗ | if (minBound && (value < *minBound)) { | |
| 48 | ✗ | return false; | |
| 49 | } | ||
| 50 | ✗ | if (maxBound && (value > *maxBound)) { | |
| 51 | ✗ | return false; | |
| 52 | } | ||
| 53 | ✗ | } | |
| 54 | } | ||
| 55 | ✗ | } | |
| 56 | ✗ | return true; | |
| 57 | } | ||
| 58 | |||
| 59 | ✗ | boost::optional<ModelObject> ScheduleBase_Impl::scheduleTypeLimitsAsModelObject() const { | |
| 60 | ✗ | OptionalModelObject result; | |
| 61 | ✗ | OptionalScheduleTypeLimits intermediate = scheduleTypeLimits(); | |
| 62 | ✗ | if (intermediate) { | |
| 63 | ✗ | result = *intermediate; | |
| 64 | } | ||
| 65 | ✗ | return result; | |
| 66 | ✗ | } | |
| 67 | |||
| 68 | ✗ | bool ScheduleBase_Impl::setScheduleTypeLimitsAsModelObject(const boost::optional<ModelObject>& modelObject) { | |
| 69 | ✗ | if (modelObject) { | |
| 70 | ✗ | OptionalScheduleTypeLimits intermediate = modelObject->optionalCast<ScheduleTypeLimits>(); | |
| 71 | ✗ | if (intermediate) { | |
| 72 | ✗ | return setScheduleTypeLimits(*intermediate); | |
| 73 | } else { | ||
| 74 | ✗ | return false; | |
| 75 | } | ||
| 76 | ✗ | } else { | |
| 77 | ✗ | resetScheduleTypeLimits(); | |
| 78 | } | ||
| 79 | ✗ | return true; | |
| 80 | } | ||
| 81 | |||
| 82 | } // namespace detail | ||
| 83 | |||
| 84 | 22450 | boost::optional<ScheduleTypeLimits> ScheduleBase::scheduleTypeLimits() const { | |
| 85 |
1/1✓ Branch 3 taken 22450 times.
|
22450 | return getImpl<detail::ScheduleBase_Impl>()->scheduleTypeLimits(); |
| 86 | } | ||
| 87 | |||
| 88 | 14121 | bool ScheduleBase::setScheduleTypeLimits(const ScheduleTypeLimits& scheduleTypeLimits) { | |
| 89 |
1/1✓ Branch 3 taken 14121 times.
|
14121 | return getImpl<detail::ScheduleBase_Impl>()->setScheduleTypeLimits(scheduleTypeLimits); |
| 90 | } | ||
| 91 | |||
| 92 | 5 | bool ScheduleBase::resetScheduleTypeLimits() { | |
| 93 |
1/1✓ Branch 3 taken 5 times.
|
5 | return getImpl<detail::ScheduleBase_Impl>()->resetScheduleTypeLimits(); |
| 94 | } | ||
| 95 | |||
| 96 | ✗ | void ScheduleBase::ensureNoLeapDays() { | |
| 97 | ✗ | getImpl<detail::ScheduleBase_Impl>()->ensureNoLeapDays(); | |
| 98 | ✗ | } | |
| 99 | |||
| 100 | /// @cond | ||
| 101 |
1/1✓ Branch 3 taken 109360 times.
|
109360 | ScheduleBase::ScheduleBase(std::shared_ptr<detail::ScheduleBase_Impl> impl) : ResourceObject(std::move(impl)) {} |
| 102 | |||
| 103 | 13377 | ScheduleBase::ScheduleBase(IddObjectType type, const Model& model) : ResourceObject(type, model) {} | |
| 104 | /// @endcond | ||
| 105 | |||
| 106 | } // namespace model | ||
| 107 | } // namespace openstudio | ||
| 108 |