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