GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 82.9% 92 / 0 / 111
Functions: 87.9% 29 / 0 / 33
Branches: 58.3% 49 / 0 / 84

src/model/PhotovoltaicPerformanceSimple.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 "PhotovoltaicPerformanceSimple.hpp"
7 #include "PhotovoltaicPerformanceSimple_Impl.hpp"
8
9 #include "Schedule.hpp"
10 #include "Schedule_Impl.hpp"
11 #include "ScheduleTypeLimits.hpp"
12 #include "ScheduleTypeRegistry.hpp"
13
14 #include <utilities/idd/IddFactory.hxx>
15 #include <utilities/idd/IddEnums.hxx>
16 #include <utilities/idd/OS_PhotovoltaicPerformance_Simple_FieldEnums.hxx>
17
18 #include "../utilities/units/Unit.hpp"
19
20 #include "../utilities/core/Assert.hpp"
21
22 namespace openstudio {
23 namespace model {
24
25 namespace detail {
26
27 16 PhotovoltaicPerformanceSimple_Impl::PhotovoltaicPerformanceSimple_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
28 16 : PhotovoltaicPerformance_Impl(idfObject, model, keepHandle) {
29
4/6
✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 7 taken 16 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 16 times.
✗ Branch 13 not taken.
16 OS_ASSERT(idfObject.iddObject().type() == PhotovoltaicPerformanceSimple::iddObjectType());
30 16 }
31
32 ✗ PhotovoltaicPerformanceSimple_Impl::PhotovoltaicPerformanceSimple_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model,
33 ✗ bool keepHandle)
34 ✗ : PhotovoltaicPerformance_Impl(other, model, keepHandle) {
35 ✗ OS_ASSERT(other.iddObject().type() == PhotovoltaicPerformanceSimple::iddObjectType());
36 ✗ }
37
38 4 PhotovoltaicPerformanceSimple_Impl::PhotovoltaicPerformanceSimple_Impl(const PhotovoltaicPerformanceSimple_Impl& other, Model_Impl* model,
39 4 bool keepHandle)
40 4 : PhotovoltaicPerformance_Impl(other, model, keepHandle) {}
41
42 // TODO: remove
43 ✗ const std::vector<std::string>& PhotovoltaicPerformanceSimple_Impl::outputVariableNames() const {
44 ✗ static const std::vector<std::string> result;
45 // Not appropriate: no specific variables
46 ✗ return result;
47 }
48
49 ✗ IddObjectType PhotovoltaicPerformanceSimple_Impl::iddObjectType() const {
50 ✗ return PhotovoltaicPerformanceSimple::iddObjectType();
51 }
52
53 ✗ std::vector<ScheduleTypeKey> PhotovoltaicPerformanceSimple_Impl::getScheduleTypeKeys(const Schedule& schedule) const {
54 // TODO: Check schedule display names.
55 ✗ std::vector<ScheduleTypeKey> result;
56 ✗ UnsignedVector fieldIndices = getSourceIndices(schedule.handle());
57 ✗ UnsignedVector::const_iterator b(fieldIndices.begin());
58 ✗ UnsignedVector::const_iterator e(fieldIndices.end());
59 ✗ if (std::find(b, e, OS_PhotovoltaicPerformance_SimpleFields::EfficiencyScheduleName) != e) {
60 ✗ result.push_back(ScheduleTypeKey("PhotovoltaicPerformanceSimple", "Efficiency"));
61 }
62 ✗ return result;
63 ✗ }
64
65 4 double PhotovoltaicPerformanceSimple_Impl::fractionOfSurfaceAreaWithActiveSolarCells() const {
66
1/1
✓ Branch 1 taken 4 times.
4 boost::optional<double> value = getDouble(OS_PhotovoltaicPerformance_SimpleFields::FractionofSurfaceAreawithActiveSolarCells, true);
67
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 4 not taken.
4 OS_ASSERT(value);
68
1/1
✓ Branch 1 taken 4 times.
8 return value.get();
69 }
70
71 1 bool PhotovoltaicPerformanceSimple_Impl::isfractionOfSurfaceAreaWithActiveSolarCellsDefaulted() const {
72 1 return isEmpty(OS_PhotovoltaicPerformance_SimpleFields::FractionofSurfaceAreawithActiveSolarCells);
73 }
74
75 5 std::string PhotovoltaicPerformanceSimple_Impl::conversionEfficiencyInputMode() const {
76
1/1
✓ Branch 1 taken 5 times.
5 boost::optional<std::string> result = getString(OS_PhotovoltaicPerformance_SimpleFields::ConversionEfficiencyInputMode, true);
77
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 4 not taken.
5 OS_ASSERT(result);
78
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
10 return result.get();
79 5 }
80
81 8 boost::optional<double> PhotovoltaicPerformanceSimple_Impl::fixedEfficiency() const {
82 8 return getDouble(OS_PhotovoltaicPerformance_SimpleFields::ValueforCellEfficiencyifFixed, true);
83 }
84
85 3 boost::optional<Schedule> PhotovoltaicPerformanceSimple_Impl::efficiencySchedule() const {
86
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 return getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_PhotovoltaicPerformance_SimpleFields::EfficiencyScheduleName);
87 }
88
89 1 bool PhotovoltaicPerformanceSimple_Impl::setFractionOfSurfaceAreaWithActiveSolarCells(double fractionOfSurfaceAreaWithActiveSolarCells) {
90 bool result =
91 1 setDouble(OS_PhotovoltaicPerformance_SimpleFields::FractionofSurfaceAreawithActiveSolarCells, fractionOfSurfaceAreaWithActiveSolarCells);
92 1 return result;
93 }
94
95 1 void PhotovoltaicPerformanceSimple_Impl::resetFractionOfSurfaceAreaWithActiveSolarCells() {
96
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_PhotovoltaicPerformance_SimpleFields::FractionofSurfaceAreawithActiveSolarCells, "");
97
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
98 1 }
99
100 20 bool PhotovoltaicPerformanceSimple_Impl::setConversionEfficiencyInputMode(const std::string& conversionEfficiencyInputMode) {
101 20 return setString(OS_PhotovoltaicPerformance_SimpleFields::ConversionEfficiencyInputMode, conversionEfficiencyInputMode);
102 }
103
104 19 bool PhotovoltaicPerformanceSimple_Impl::setFixedEfficiency(double fixedEfficiency) {
105 19 bool result = setDouble(OS_PhotovoltaicPerformance_SimpleFields::ValueforCellEfficiencyifFixed, fixedEfficiency);
106
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if (result) {
107
2/2
✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
19 result = setConversionEfficiencyInputMode("Fixed");
108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 OS_ASSERT(result);
109
2/2
✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
38 result = setString(OS_PhotovoltaicPerformance_SimpleFields::EfficiencyScheduleName, "");
110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 OS_ASSERT(result);
111 }
112 19 return result;
113 }
114
115 1 void PhotovoltaicPerformanceSimple_Impl::resetFixedEfficiency() {
116 1 setDefaultFixedEfficiency();
117 1 }
118
119 1 bool PhotovoltaicPerformanceSimple_Impl::setEfficiencySchedule(Schedule& schedule) {
120 bool result =
121
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
4 setSchedule(OS_PhotovoltaicPerformance_SimpleFields::EfficiencyScheduleName, "PhotovoltaicPerformanceSimple", "Efficiency", schedule);
122
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (result) {
123
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 result = setConversionEfficiencyInputMode("Scheduled");
124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
125
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 result = setString(OS_PhotovoltaicPerformance_SimpleFields::ValueforCellEfficiencyifFixed, "");
126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
127 }
128 1 return result;
129 }
130
131 1 void PhotovoltaicPerformanceSimple_Impl::resetEfficiencySchedule() {
132 1 setDefaultFixedEfficiency();
133 1 }
134
135 18 bool PhotovoltaicPerformanceSimple_Impl::setDefaultFixedEfficiency() {
136 18 bool result = setFixedEfficiency(0.12);
137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 OS_ASSERT(result);
138 18 return result;
139 }
140
141 } // namespace detail
142
143 16 PhotovoltaicPerformanceSimple::PhotovoltaicPerformanceSimple(const Model& model)
144 16 : PhotovoltaicPerformance(PhotovoltaicPerformanceSimple::iddObjectType(), model) {
145
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 5 not taken.
16 OS_ASSERT(getImpl<detail::PhotovoltaicPerformanceSimple_Impl>());
146
1/1
✓ Branch 3 taken 16 times.
16 getImpl<detail::PhotovoltaicPerformanceSimple_Impl>()->setDefaultFixedEfficiency();
147 16 }
148
149 7634 IddObjectType PhotovoltaicPerformanceSimple::iddObjectType() {
150
1/1
✓ Branch 1 taken 7634 times.
7634 return {IddObjectType::OS_PhotovoltaicPerformance_Simple};
151 }
152
153 4 double PhotovoltaicPerformanceSimple::fractionOfSurfaceAreaWithActiveSolarCells() const {
154
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::PhotovoltaicPerformanceSimple_Impl>()->fractionOfSurfaceAreaWithActiveSolarCells();
155 }
156
157 1 bool PhotovoltaicPerformanceSimple::isfractionOfSurfaceAreaWithActiveSolarCellsDefaulted() const {
158
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::PhotovoltaicPerformanceSimple_Impl>()->isfractionOfSurfaceAreaWithActiveSolarCellsDefaulted();
159 }
160
161 5 std::string PhotovoltaicPerformanceSimple::conversionEfficiencyInputMode() const {
162
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::PhotovoltaicPerformanceSimple_Impl>()->conversionEfficiencyInputMode();
163 }
164
165 8 boost::optional<double> PhotovoltaicPerformanceSimple::fixedEfficiency() const {
166
1/1
✓ Branch 3 taken 8 times.
8 return getImpl<detail::PhotovoltaicPerformanceSimple_Impl>()->fixedEfficiency();
167 }
168
169 3 boost::optional<Schedule> PhotovoltaicPerformanceSimple::efficiencySchedule() const {
170
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::PhotovoltaicPerformanceSimple_Impl>()->efficiencySchedule();
171 }
172
173 1 bool PhotovoltaicPerformanceSimple::setFractionOfSurfaceAreaWithActiveSolarCells(double fractionOfSurfaceAreaWithActiveSolarCells) {
174
1/1
✓ Branch 3 taken 1 time.
2 return getImpl<detail::PhotovoltaicPerformanceSimple_Impl>()->setFractionOfSurfaceAreaWithActiveSolarCells(
175 2 fractionOfSurfaceAreaWithActiveSolarCells);
176 }
177
178 1 void PhotovoltaicPerformanceSimple::resetFractionOfSurfaceAreaWithActiveSolarCells() {
179
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::PhotovoltaicPerformanceSimple_Impl>()->resetFractionOfSurfaceAreaWithActiveSolarCells();
180 1 }
181
182 1 bool PhotovoltaicPerformanceSimple::setFixedEfficiency(double fixedEfficiency) {
183
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::PhotovoltaicPerformanceSimple_Impl>()->setFixedEfficiency(fixedEfficiency);
184 }
185
186 1 void PhotovoltaicPerformanceSimple::resetFixedEfficiency() {
187
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::PhotovoltaicPerformanceSimple_Impl>()->resetFixedEfficiency();
188 1 }
189
190 1 bool PhotovoltaicPerformanceSimple::setEfficiencySchedule(Schedule& schedule) {
191
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::PhotovoltaicPerformanceSimple_Impl>()->setEfficiencySchedule(schedule);
192 }
193
194 1 void PhotovoltaicPerformanceSimple::resetEfficiencySchedule() {
195
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::PhotovoltaicPerformanceSimple_Impl>()->resetEfficiencySchedule();
196 1 }
197
198 /// @cond
199 1 PhotovoltaicPerformanceSimple::PhotovoltaicPerformanceSimple(std::shared_ptr<detail::PhotovoltaicPerformanceSimple_Impl> impl)
200
1/1
✓ Branch 3 taken 1 time.
1 : PhotovoltaicPerformance(std::move(impl)) {}
201 /// @endcond
202
203 } // namespace model
204 } // namespace openstudio
205