GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 66.7% 26 / 0 / 39
Functions: 66.7% 8 / 0 / 12
Branches: 51.4% 18 / 0 / 35

src/model/ScheduleInterval.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 "ScheduleInterval.hpp"
7 #include "ScheduleInterval_Impl.hpp"
8 #include "ScheduleFixedInterval.hpp"
9 #include "ScheduleFixedInterval_Impl.hpp"
10 #include "ScheduleVariableInterval.hpp"
11 #include "ScheduleVariableInterval_Impl.hpp"
12 #include "Model.hpp"
13
14 #include "ScheduleTypeLimits.hpp"
15 #include "ScheduleTypeLimits_Impl.hpp"
16
17 #include "../utilities/idf/IdfExtensibleGroup.hpp"
18
19 #include <utilities/idd/OS_Schedule_Compact_FieldEnums.hxx>
20
21 #include "../utilities/data/TimeSeries.hpp"
22 #include "../utilities/core/Assert.hpp"
23
24 using openstudio::Handle;
25 using openstudio::OptionalHandle;
26 using openstudio::HandleVector;
27 using openstudio::IdfObject;
28 using openstudio::WorkspaceObject;
29 using openstudio::OptionalWorkspaceObject;
30 using openstudio::WorkspaceObjectVector;
31 using openstudio::Workspace;
32
33 namespace openstudio {
34 namespace model {
35
36 namespace detail {
37
38 33 ScheduleInterval_Impl::ScheduleInterval_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
39 33 : Schedule_Impl(idfObject, model, keepHandle) {}
40
41 ✗ ScheduleInterval_Impl::ScheduleInterval_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle)
42 ✗ : Schedule_Impl(other, model, keepHandle) {}
43
44 15 ScheduleInterval_Impl::ScheduleInterval_Impl(const ScheduleInterval_Impl& other, Model_Impl* model, bool keepHandle)
45 15 : Schedule_Impl(other, model, keepHandle) {}
46
47 // Get all output variable names that could be associated with this object.
48 ✗ const std::vector<std::string>& ScheduleInterval_Impl::outputVariableNames() const {
49 ✗ static const std::vector<std::string> result;
50 ✗ return result;
51 }
52
53 // return the parent object in the hierarchy
54 ✗ boost::optional<ParentObject> ScheduleInterval_Impl::parent() const {
55 ✗ return {};
56 }
57
58 // return any children objects in the hierarchy
59 22 std::vector<ModelObject> ScheduleInterval_Impl::children() const {
60 22 std::vector<ModelObject> result;
61 22 return result;
62 }
63
64 ✗ std::vector<double> ScheduleInterval_Impl::values() const {
65 ✗ return toStandardVector(timeSeries().values());
66 }
67
68 } // namespace detail
69
70 15 boost::optional<ScheduleInterval> ScheduleInterval::fromTimeSeries(const openstudio::TimeSeries& timeSeries, Model& model) {
71 15 boost::optional<ScheduleInterval> result;
72
3/3
✓ Branch 1 taken 15 times.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 5 times.
30 if (timeSeries.intervalLength()) {
73
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
10 result = ScheduleFixedInterval(model);
74
3/4
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 10 times.
10 if (!result->setTimeSeries(timeSeries)) {
75 ✗ result->remove();
76 ✗ return {};
77 }
78 } else {
79
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 result = ScheduleVariableInterval(model);
80
3/4
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5 times.
5 if (!result->setTimeSeries(timeSeries)) {
81 ✗ result->remove();
82 ✗ return {};
83 }
84 }
85 15 return result;
86 15 }
87
88 20 openstudio::TimeSeries ScheduleInterval::timeSeries() const {
89
1/1
✓ Branch 3 taken 20 times.
20 return getImpl<detail::ScheduleInterval_Impl>()->timeSeries();
90 }
91
92 21 bool ScheduleInterval::setTimeSeries(const openstudio::TimeSeries& timeSeries) {
93
1/1
✓ Branch 3 taken 21 times.
21 return getImpl<detail::ScheduleInterval_Impl>()->setTimeSeries(timeSeries);
94 }
95
96 // constructor
97 33 ScheduleInterval::ScheduleInterval(IddObjectType type, const Model& model) : Schedule(type, model) {
98
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
✗ Branch 5 not taken.
33 OS_ASSERT(getImpl<detail::ScheduleInterval_Impl>());
99 33 }
100
101
1/1
✓ Branch 3 taken 86 times.
86 ScheduleInterval::ScheduleInterval(std::shared_ptr<detail::ScheduleInterval_Impl> impl) : Schedule(std::move(impl)) {
102
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 86 times.
✗ Branch 5 not taken.
86 OS_ASSERT(getImpl<detail::ScheduleInterval_Impl>());
103 86 }
104
105 } // namespace model
106 } // namespace openstudio
107