GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 64.2% 34 / 0 / 53
Functions: 78.6% 11 / 0 / 14
Branches: 29.4% 20 / 0 / 68

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