src/model/AvailabilityManagerScheduledOn.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 "AvailabilityManagerScheduledOn.hpp" | ||
| 7 | #include "AvailabilityManagerScheduledOn_Impl.hpp" | ||
| 8 | |||
| 9 | #include "Model.hpp" | ||
| 10 | #include "Schedule.hpp" | ||
| 11 | #include "Schedule_Impl.hpp" | ||
| 12 | #include "ScheduleTypeLimits.hpp" | ||
| 13 | #include "ScheduleTypeRegistry.hpp" | ||
| 14 | |||
| 15 | #include <utilities/idd/IddEnums.hxx> | ||
| 16 | #include <utilities/idd/OS_AvailabilityManager_ScheduledOn_FieldEnums.hxx> | ||
| 17 | |||
| 18 | #include "../utilities/core/Assert.hpp" | ||
| 19 | |||
| 20 | namespace openstudio { | ||
| 21 | namespace model { | ||
| 22 | |||
| 23 | namespace detail { | ||
| 24 | |||
| 25 | 7 | AvailabilityManagerScheduledOn_Impl::AvailabilityManagerScheduledOn_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 26 | 7 | : AvailabilityManager_Impl(idfObject, model, keepHandle) { | |
| 27 |
4/6✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 13 not taken.
|
7 | OS_ASSERT(idfObject.iddObject().type() == AvailabilityManagerScheduledOn::iddObjectType()); |
| 28 | 7 | } | |
| 29 | |||
| 30 | ✗ | AvailabilityManagerScheduledOn_Impl::AvailabilityManagerScheduledOn_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, | |
| 31 | ✗ | bool keepHandle) | |
| 32 | ✗ | : AvailabilityManager_Impl(other, model, keepHandle) { | |
| 33 | ✗ | OS_ASSERT(other.iddObject().type() == AvailabilityManagerScheduledOn::iddObjectType()); | |
| 34 | ✗ | } | |
| 35 | |||
| 36 | 5 | AvailabilityManagerScheduledOn_Impl::AvailabilityManagerScheduledOn_Impl(const AvailabilityManagerScheduledOn_Impl& other, Model_Impl* model, | |
| 37 | 5 | bool keepHandle) | |
| 38 | 5 | : AvailabilityManager_Impl(other, model, keepHandle) {} | |
| 39 | |||
| 40 | ✗ | const std::vector<std::string>& AvailabilityManagerScheduledOn_Impl::outputVariableNames() const { | |
| 41 | ✗ | static const std::vector<std::string> result{"Availability Manager Scheduled On Control Status"}; | |
| 42 | ✗ | return result; | |
| 43 | ✗ | } | |
| 44 | |||
| 45 | 3 | IddObjectType AvailabilityManagerScheduledOn_Impl::iddObjectType() const { | |
| 46 | 3 | return AvailabilityManagerScheduledOn::iddObjectType(); | |
| 47 | } | ||
| 48 | |||
| 49 | ✗ | std::vector<ScheduleTypeKey> AvailabilityManagerScheduledOn_Impl::getScheduleTypeKeys(const Schedule& schedule) const { | |
| 50 | ✗ | std::vector<ScheduleTypeKey> result; | |
| 51 | ✗ | UnsignedVector fieldIndices = getSourceIndices(schedule.handle()); | |
| 52 | ✗ | UnsignedVector::const_iterator b(fieldIndices.begin()); | |
| 53 | ✗ | UnsignedVector::const_iterator e(fieldIndices.end()); | |
| 54 | ✗ | if (std::find(b, e, OS_AvailabilityManager_ScheduledOnFields::ScheduleName) != e) { | |
| 55 | ✗ | result.push_back(ScheduleTypeKey("AvailabilityManagerScheduledOn", "Availability Manager Scheduled On")); | |
| 56 | } | ||
| 57 | ✗ | return result; | |
| 58 | ✗ | } | |
| 59 | |||
| 60 | 7 | Schedule AvailabilityManagerScheduledOn_Impl::schedule() const { | |
| 61 |
1/1✓ Branch 1 taken 7 times.
|
7 | boost::optional<Schedule> value = optionalSchedule(); |
| 62 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
|
7 | if (!value) { |
| 63 | ✗ | LOG_AND_THROW(briefDescription() << " does not have an Schedule attached."); | |
| 64 | } | ||
| 65 |
2/2✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
|
14 | return value.get(); |
| 66 | 7 | } | |
| 67 | |||
| 68 | 9 | bool AvailabilityManagerScheduledOn_Impl::setSchedule(Schedule& schedule) { | |
| 69 |
3/3✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
|
36 | bool result = ModelObject_Impl::setSchedule(OS_AvailabilityManager_ScheduledOnFields::ScheduleName, "AvailabilityManagerScheduledOn", |
| 70 | "Availability Manager Scheduled On", schedule); | ||
| 71 | 9 | return result; | |
| 72 | } | ||
| 73 | |||
| 74 | 7 | boost::optional<Schedule> AvailabilityManagerScheduledOn_Impl::optionalSchedule() const { | |
| 75 |
2/2✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
|
7 | return getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_AvailabilityManager_ScheduledOnFields::ScheduleName); |
| 76 | } | ||
| 77 | |||
| 78 | } // namespace detail | ||
| 79 | |||
| 80 | 7 | AvailabilityManagerScheduledOn::AvailabilityManagerScheduledOn(const Model& model) | |
| 81 | 7 | : AvailabilityManager(AvailabilityManagerScheduledOn::iddObjectType(), model) { | |
| 82 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 5 not taken.
|
7 | OS_ASSERT(getImpl<detail::AvailabilityManagerScheduledOn_Impl>()); |
| 83 | { | ||
| 84 |
1/1✓ Branch 1 taken 7 times.
|
7 | auto schedule = model.alwaysOnDiscreteSchedule(); |
| 85 |
1/1✓ Branch 1 taken 7 times.
|
7 | setSchedule(schedule); |
| 86 | 7 | } | |
| 87 | 7 | } | |
| 88 | |||
| 89 | 7615 | IddObjectType AvailabilityManagerScheduledOn::iddObjectType() { | |
| 90 |
1/1✓ Branch 1 taken 7615 times.
|
7615 | return {IddObjectType::OS_AvailabilityManager_ScheduledOn}; |
| 91 | } | ||
| 92 | |||
| 93 | 7 | Schedule AvailabilityManagerScheduledOn::schedule() const { | |
| 94 |
1/1✓ Branch 3 taken 7 times.
|
7 | return getImpl<detail::AvailabilityManagerScheduledOn_Impl>()->schedule(); |
| 95 | } | ||
| 96 | |||
| 97 | 9 | bool AvailabilityManagerScheduledOn::setSchedule(Schedule& schedule) { | |
| 98 |
1/1✓ Branch 3 taken 9 times.
|
9 | return getImpl<detail::AvailabilityManagerScheduledOn_Impl>()->setSchedule(schedule); |
| 99 | } | ||
| 100 | |||
| 101 | /// @cond | ||
| 102 | 5 | AvailabilityManagerScheduledOn::AvailabilityManagerScheduledOn(std::shared_ptr<detail::AvailabilityManagerScheduledOn_Impl> impl) | |
| 103 |
1/1✓ Branch 2 taken 5 times.
|
5 | : AvailabilityManager(impl) {} |
| 104 | /// @endcond | ||
| 105 | |||
| 106 | } // namespace model | ||
| 107 | } // namespace openstudio | ||
| 108 |