GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 91.4% 128 / 0 / 140
Functions: 94.9% 37 / 0 / 39
Branches: 69.8% 111 / 0 / 159

src/model/UnitarySystemPerformanceMultispeed.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 "UnitarySystemPerformanceMultispeed.hpp"
7 #include "UnitarySystemPerformanceMultispeed_Impl.hpp"
8 #include "ModelExtensibleGroup.hpp"
9
10 #include <utilities/idd/IddFactory.hxx>
11
12 #include <utilities/idd/OS_UnitarySystemPerformance_Multispeed_FieldEnums.hxx>
13 #include <utilities/idd/IddEnums.hxx>
14
15 #include "../utilities/core/Assert.hpp"
16
17 namespace openstudio {
18 namespace model {
19
20 namespace detail {
21 15 UnitarySystemPerformanceMultispeed_Impl::UnitarySystemPerformanceMultispeed_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
22 15 : ModelObject_Impl(idfObject, model, keepHandle) {
23
4/6
✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 15 times.
✗ Branch 13 not taken.
15 OS_ASSERT(idfObject.iddObject().type() == UnitarySystemPerformanceMultispeed::iddObjectType());
24 15 }
25
26 1 UnitarySystemPerformanceMultispeed_Impl::UnitarySystemPerformanceMultispeed_Impl(const openstudio::detail::WorkspaceObject_Impl& other,
27 1 Model_Impl* model, bool keepHandle)
28 1 : ModelObject_Impl(other, model, keepHandle) {
29
4/6
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 time.
✗ Branch 13 not taken.
1 OS_ASSERT(other.iddObject().type() == UnitarySystemPerformanceMultispeed::iddObjectType());
30 1 }
31
32 11 UnitarySystemPerformanceMultispeed_Impl::UnitarySystemPerformanceMultispeed_Impl(const UnitarySystemPerformanceMultispeed_Impl& other,
33 11 Model_Impl* model, bool keepHandle)
34 11 : ModelObject_Impl(other, model, keepHandle) {}
35
36 ✗ const std::vector<std::string>& UnitarySystemPerformanceMultispeed_Impl::outputVariableNames() const {
37 ✗ static const std::vector<std::string> result;
38 ✗ return result;
39 }
40
41 ✗ IddObjectType UnitarySystemPerformanceMultispeed_Impl::iddObjectType() const {
42 ✗ return UnitarySystemPerformanceMultispeed::iddObjectType();
43 }
44
45 15 bool UnitarySystemPerformanceMultispeed_Impl::singleModeOperation() const {
46
1/1
✓ Branch 1 taken 15 times.
15 boost::optional<std::string> value = getString(OS_UnitarySystemPerformance_MultispeedFields::SingleModeOperation, true);
47
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 4 not taken.
15 OS_ASSERT(value);
48
3/3
✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
45 return openstudio::istringEqual("Yes", value.get());
49 15 }
50
51 3 bool UnitarySystemPerformanceMultispeed_Impl::setSingleModeOperation(bool singleMode) {
52
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 3 times.
✓ Branch 6 taken 3 times.
9 return setString(OS_UnitarySystemPerformance_MultispeedFields::SingleModeOperation, singleMode ? "Yes" : "No");
53 }
54
55 1 void UnitarySystemPerformanceMultispeed_Impl::resetSingleModeOperation() {
56
3/5
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 9 not taken.
2 OS_ASSERT(setString(OS_UnitarySystemPerformance_MultispeedFields::SingleModeOperation, ""));
57 1 }
58
59 13 double UnitarySystemPerformanceMultispeed_Impl::noLoadSupplyAirflowRateRatio() const {
60
1/1
✓ Branch 1 taken 13 times.
13 boost::optional<double> value = getDouble(OS_UnitarySystemPerformance_MultispeedFields::NoLoadSupplyAirFlowRateRatio, true);
61
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 4 not taken.
13 OS_ASSERT(value);
62
1/1
✓ Branch 1 taken 13 times.
26 return value.get();
63 }
64
65 15 bool UnitarySystemPerformanceMultispeed_Impl::setNoLoadSupplyAirflowRateRatio(double noLoadSupplyAirflowRateRatio) {
66 15 bool result = setDouble(OS_UnitarySystemPerformance_MultispeedFields::NoLoadSupplyAirFlowRateRatio, noLoadSupplyAirflowRateRatio);
67 15 return result;
68 }
69
70 22 boost::optional<double> UnitarySystemPerformanceMultispeed_Impl::readDoubleFieldOrAutosize(unsigned fieldNum,
71 const ModelExtensibleGroup& group) const {
72
1/1
✓ Branch 1 taken 22 times.
22 boost::optional<double> result = group.getDouble(fieldNum);
73
2/2
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 16 times.
22 if (!result) {
74
1/1
✓ Branch 1 taken 6 times.
6 boost::optional<std::string> resultString = group.getString(fieldNum);
75
8/17
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
✓ Branch 10 taken 6 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 6 times.
✓ Branch 14 taken 6 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 6 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 6 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
18 if (!resultString || !openstudio::istringEqual(resultString.get(), "autosize")) {
76 ✗ LOG(Error, "Could not read SupplyAirflowRatioField " << group.groupIndex() << " in " << briefDescription() << ".");
77 }
78 6 }
79 22 return result;
80 }
81
82 15 std::vector<SupplyAirflowRatioField> UnitarySystemPerformanceMultispeed_Impl::supplyAirflowRatioFields() const {
83 15 std::vector<SupplyAirflowRatioField> result;
84
85
4/4
✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 12 taken 11 times.
✓ Branch 13 taken 15 times.
26 for (const ModelExtensibleGroup& group : castVector<ModelExtensibleGroup>(extensibleGroups())) {
86 boost::optional<double> heatingRatio =
87
1/1
✓ Branch 1 taken 11 times.
11 readDoubleFieldOrAutosize(OS_UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio, group);
88 boost::optional<double> coolingRatio =
89
1/1
✓ Branch 1 taken 11 times.
11 readDoubleFieldOrAutosize(OS_UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio, group);
90
6/6
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 5 times.
18 if (heatingRatio && coolingRatio) {
91
4/4
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
✓ Branch 10 taken 6 times.
6 result.push_back(SupplyAirflowRatioField(*heatingRatio, *coolingRatio));
92
5/6
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 4 times.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 time.
✓ Branch 6 taken 4 times.
5 } else if (heatingRatio && !coolingRatio) {
93
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 result.push_back(SupplyAirflowRatioField::fromHeatingRatio(*heatingRatio));
94
5/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 1 time.
4 } else if (coolingRatio && !heatingRatio) {
95
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 result.push_back(SupplyAirflowRatioField::fromCoolingRatio(*coolingRatio));
96 } else {
97
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 result.push_back(SupplyAirflowRatioField());
98 }
99 15 }
100 15 return result;
101 ✗ }
102
103 1 bool UnitarySystemPerformanceMultispeed_Impl::setSupplyAirflowRatioFields(const std::vector<SupplyAirflowRatioField>& airflowRatioFields) {
104
1/1
✓ Branch 1 taken 1 time.
1 std::vector<SupplyAirflowRatioField> originalFields = supplyAirflowRatioFields();
105
106 1 bool result = true;
107
108
1/1
✓ Branch 1 taken 1 time.
1 clearExtensibleGroups(false);
109
2/2
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 1 time.
3 for (const auto& airflowRatioField : airflowRatioFields) {
110
4/7
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
2 if (!(result && addSupplyAirflowRatioField(airflowRatioField))) {
111 ✗ result = false;
112 }
113 }
114
115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 if (!result) {
116 ✗ clearExtensibleGroups(false);
117 ✗ for (const auto& airflowRatioField : originalFields) {
118 ✗ addSupplyAirflowRatioField(airflowRatioField);
119 }
120 }
121
122 1 return result;
123 1 }
124
125 11 bool UnitarySystemPerformanceMultispeed_Impl::addSupplyAirflowRatioField(const SupplyAirflowRatioField& airflowRatio) {
126
1/1
✓ Branch 1 taken 11 times.
11 std::vector<std::string> values = airflowRatio.getHeatingCoolingRatiosAsStrings();
127
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 auto group = pushExtensibleGroup(values, false).cast<ModelExtensibleGroup>();
128
1/1
✓ Branch 1 taken 11 times.
22 return (!group.empty());
129 11 }
130
131 5 bool UnitarySystemPerformanceMultispeed_Impl::addSupplyAirflowRatioField(double heatingRatio, double coolingRatio) {
132
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 return addSupplyAirflowRatioField(SupplyAirflowRatioField(heatingRatio, coolingRatio));
133 }
134
135 1 void UnitarySystemPerformanceMultispeed_Impl::resetSupplyAirflowRatioFields() {
136
1/1
✓ Branch 1 taken 1 time.
1 clearExtensibleGroups(false);
137 1 }
138
139 } // namespace detail
140
141 3 SupplyAirflowRatioField::SupplyAirflowRatioField() : m_heatingRatio(boost::none), m_coolingRatio(boost::none) {}
142
143 12 SupplyAirflowRatioField::SupplyAirflowRatioField(double heatingRatio, double coolingRatio)
144 12 : m_heatingRatio(heatingRatio), m_coolingRatio(coolingRatio) {}
145
146 9 SupplyAirflowRatioField::SupplyAirflowRatioField(bool isHeating, double value) : m_heatingRatio(boost::none), m_coolingRatio(boost::none) {
147
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 6 times.
9 if (isHeating) {
148 3 m_heatingRatio = value;
149 } else {
150 6 m_coolingRatio = value;
151 }
152 9 }
153
154 3 SupplyAirflowRatioField SupplyAirflowRatioField::fromHeatingRatio(double heatingRatio) {
155 3 return {true, heatingRatio};
156 }
157
158 6 SupplyAirflowRatioField SupplyAirflowRatioField::fromCoolingRatio(double coolingRatio) {
159 6 return {false, coolingRatio};
160 }
161
162 4 boost::optional<double> SupplyAirflowRatioField::heatingRatio() const {
163 4 return m_heatingRatio;
164 }
165
166 5 boost::optional<double> SupplyAirflowRatioField::coolingRatio() const {
167 5 return m_coolingRatio;
168 }
169
170 5 bool SupplyAirflowRatioField::isHeatingRatioAutosized() const {
171 5 return !m_heatingRatio;
172 }
173
174 5 bool SupplyAirflowRatioField::isCoolingRatioAutosized() const {
175 5 return !m_coolingRatio;
176 }
177
178 17 std::vector<std::string> SupplyAirflowRatioField::getHeatingCoolingRatiosAsStrings() const {
179 17 std::vector<std::string> values;
180
2/2
✓ Branch 3 taken 34 times.
✓ Branch 4 taken 17 times.
51 for (const auto& item : {m_heatingRatio, m_coolingRatio}) {
181
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 8 times.
34 if (item) {
182
3/3
✓ Branch 1 taken 26 times.
✓ Branch 4 taken 26 times.
✓ Branch 7 taken 26 times.
26 values.push_back(openstudio::toString(*item));
183 } else {
184
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
16 values.push_back("autosize");
185 }
186 }
187 17 return values;
188 ✗ }
189
190 14 UnitarySystemPerformanceMultispeed::UnitarySystemPerformanceMultispeed(const Model& model)
191 14 : ModelObject(UnitarySystemPerformanceMultispeed::iddObjectType(), model) {
192
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✗ Branch 5 not taken.
14 OS_ASSERT(getImpl<detail::UnitarySystemPerformanceMultispeed_Impl>());
193
194
1/1
✓ Branch 1 taken 14 times.
14 bool ok = setNoLoadSupplyAirflowRateRatio(1.0);
195
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 3 not taken.
14 OS_ASSERT(ok);
196 14 }
197
198 7758 IddObjectType UnitarySystemPerformanceMultispeed::iddObjectType() {
199
1/1
✓ Branch 1 taken 7758 times.
7758 return {IddObjectType::OS_UnitarySystemPerformance_Multispeed};
200 }
201
202 15 bool UnitarySystemPerformanceMultispeed::singleModeOperation() const {
203
1/1
✓ Branch 3 taken 15 times.
15 return getImpl<detail::UnitarySystemPerformanceMultispeed_Impl>()->singleModeOperation();
204 }
205
206 3 bool UnitarySystemPerformanceMultispeed::setSingleModeOperation(bool singleMode) {
207
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::UnitarySystemPerformanceMultispeed_Impl>()->setSingleModeOperation(singleMode);
208 }
209
210 1 void UnitarySystemPerformanceMultispeed::resetSingleModeOperation() {
211
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::UnitarySystemPerformanceMultispeed_Impl>()->resetSingleModeOperation();
212 1 }
213
214 13 double UnitarySystemPerformanceMultispeed::noLoadSupplyAirflowRateRatio() const {
215
1/1
✓ Branch 3 taken 13 times.
13 return getImpl<detail::UnitarySystemPerformanceMultispeed_Impl>()->noLoadSupplyAirflowRateRatio();
216 }
217
218 15 bool UnitarySystemPerformanceMultispeed::setNoLoadSupplyAirflowRateRatio(double noLoadSupplyAirflowRateRatio) {
219
1/1
✓ Branch 3 taken 15 times.
15 return getImpl<detail::UnitarySystemPerformanceMultispeed_Impl>()->setNoLoadSupplyAirflowRateRatio(noLoadSupplyAirflowRateRatio);
220 }
221
222 14 std::vector<SupplyAirflowRatioField> UnitarySystemPerformanceMultispeed::supplyAirflowRatioFields() const {
223
1/1
✓ Branch 3 taken 14 times.
14 return getImpl<detail::UnitarySystemPerformanceMultispeed_Impl>()->supplyAirflowRatioFields();
224 }
225
226 1 bool UnitarySystemPerformanceMultispeed::setSupplyAirflowRatioFields(const std::vector<SupplyAirflowRatioField>& airflowRatioFields) {
227
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::UnitarySystemPerformanceMultispeed_Impl>()->setSupplyAirflowRatioFields(airflowRatioFields);
228 }
229
230 4 bool UnitarySystemPerformanceMultispeed::addSupplyAirflowRatioField(const SupplyAirflowRatioField& airflowRatio) {
231
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::UnitarySystemPerformanceMultispeed_Impl>()->addSupplyAirflowRatioField(airflowRatio);
232 }
233
234 5 bool UnitarySystemPerformanceMultispeed::addSupplyAirflowRatioField(double heatingRatio, double coolingRatio) {
235
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::UnitarySystemPerformanceMultispeed_Impl>()->addSupplyAirflowRatioField(heatingRatio, coolingRatio);
236 }
237
238 1 void UnitarySystemPerformanceMultispeed::resetSupplyAirflowRatioFields() {
239
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::UnitarySystemPerformanceMultispeed_Impl>()->resetSupplyAirflowRatioFields();
240 1 }
241
242 /// @cond
243 35 UnitarySystemPerformanceMultispeed::UnitarySystemPerformanceMultispeed(std::shared_ptr<detail::UnitarySystemPerformanceMultispeed_Impl> impl)
244
1/1
✓ Branch 3 taken 35 times.
35 : ModelObject(std::move(impl)) {}
245 /// @endcond
246
247 } // namespace model
248 } // namespace openstudio
249