GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 81.3% 113 / 0 / 139
Functions: 81.8% 36 / 0 / 44
Branches: 50.4% 69 / 0 / 137

src/model/SizingPlant.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 "SizingPlant.hpp"
7 #include "SizingPlant_Impl.hpp"
8 #include "PlantLoop.hpp"
9 #include "PlantLoop_Impl.hpp"
10 #include <utilities/idd/IddFactory.hxx>
11
12 #include <utilities/idd/OS_Sizing_Plant_FieldEnums.hxx>
13 #include <utilities/idd/IddEnums.hxx>
14 #include "../utilities/units/Unit.hpp"
15 #include "../utilities/core/Assert.hpp"
16
17 namespace openstudio {
18 namespace model {
19
20 namespace detail {
21
22 530 SizingPlant_Impl::SizingPlant_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
23 530 : ModelObject_Impl(idfObject, model, keepHandle) {
24
4/6
✓ Branch 1 taken 530 times.
✓ Branch 4 taken 530 times.
✓ Branch 7 taken 530 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 530 times.
✗ Branch 13 not taken.
530 OS_ASSERT(idfObject.iddObject().type() == SizingPlant::iddObjectType());
25 530 }
26
27 14 SizingPlant_Impl::SizingPlant_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle)
28 14 : ModelObject_Impl(other, model, keepHandle) {
29
4/6
✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
✓ Branch 7 taken 14 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 14 times.
✗ Branch 13 not taken.
14 OS_ASSERT(other.iddObject().type() == SizingPlant::iddObjectType());
30 14 }
31
32 279 SizingPlant_Impl::SizingPlant_Impl(const SizingPlant_Impl& other, Model_Impl* model, bool keepHandle)
33 279 : ModelObject_Impl(other, model, keepHandle) {}
34
35 ✗ const std::vector<std::string>& SizingPlant_Impl::outputVariableNames() const {
36 ✗ static const std::vector<std::string> result;
37 ✗ return result;
38 }
39
40 ✗ IddObjectType SizingPlant_Impl::iddObjectType() const {
41 ✗ return SizingPlant::iddObjectType();
42 }
43
44 2 bool SizingPlant_Impl::setParent(ParentObject& newParent) {
45 2 bool result = false;
46
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 if (boost::optional<PlantLoop> plantLoop = newParent.optionalCast<PlantLoop>()) {
47
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 result = this->setPlantLoop(plantLoop.get());
48 2 }
49 2 return result;
50 }
51
52 1767 PlantLoop SizingPlant_Impl::plantLoop() const {
53
1/1
✓ Branch 1 taken 1767 times.
1767 boost::optional<PlantLoop> value = optionalPlantLoop();
54
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1767 times.
1767 if (!value) {
55 ✗ LOG_AND_THROW(briefDescription() << " does not have a Plant Loop attached.");
56 }
57
2/2
✓ Branch 1 taken 1767 times.
✓ Branch 4 taken 1767 times.
3534 return value.get();
58 1767 }
59
60 240 std::string SizingPlant_Impl::loopType() const {
61
1/1
✓ Branch 1 taken 240 times.
240 boost::optional<std::string> value = getString(OS_Sizing_PlantFields::LoopType, true);
62
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 240 times.
✗ Branch 4 not taken.
240 OS_ASSERT(value);
63
2/2
✓ Branch 1 taken 240 times.
✓ Branch 4 taken 240 times.
480 return value.get();
64 240 }
65
66 488 double SizingPlant_Impl::designLoopExitTemperature() const {
67
1/1
✓ Branch 1 taken 488 times.
488 boost::optional<double> value = getDouble(OS_Sizing_PlantFields::DesignLoopExitTemperature, true);
68
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 488 times.
✗ Branch 4 not taken.
488 OS_ASSERT(value);
69
1/1
✓ Branch 1 taken 488 times.
976 return value.get();
70 }
71
72 240 double SizingPlant_Impl::loopDesignTemperatureDifference() const {
73
1/1
✓ Branch 1 taken 240 times.
240 boost::optional<double> value = getDouble(OS_Sizing_PlantFields::LoopDesignTemperatureDifference, true);
74
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 240 times.
✗ Branch 4 not taken.
240 OS_ASSERT(value);
75
1/1
✓ Branch 1 taken 240 times.
480 return value.get();
76 }
77
78 518 bool SizingPlant_Impl::setPlantLoop(const PlantLoop& plantLoop) {
79
2/2
✓ Branch 1 taken 518 times.
✓ Branch 4 taken 518 times.
518 bool result = setPointer(OS_Sizing_PlantFields::PlantorCondenserLoopName, plantLoop.handle());
80 518 return result;
81 }
82
83 529 bool SizingPlant_Impl::setLoopType(const std::string& loopType) {
84 529 bool result = setString(OS_Sizing_PlantFields::LoopType, loopType);
85 529 return result;
86 }
87
88 530 bool SizingPlant_Impl::setDesignLoopExitTemperature(double designLoopExitTemperature) {
89 530 bool result = setDouble(OS_Sizing_PlantFields::DesignLoopExitTemperature, designLoopExitTemperature);
90
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 530 times.
530 OS_ASSERT(result);
91 530 return result;
92 }
93
94 530 bool SizingPlant_Impl::setLoopDesignTemperatureDifference(double loopDesignTemperatureDifference) {
95 530 bool result = setDouble(OS_Sizing_PlantFields::LoopDesignTemperatureDifference, loopDesignTemperatureDifference);
96 530 return result;
97 }
98
99 1767 boost::optional<PlantLoop> SizingPlant_Impl::optionalPlantLoop() const {
100
2/2
✓ Branch 1 taken 1767 times.
✓ Branch 4 taken 1767 times.
1767 return getObject<ModelObject>().getModelObjectTarget<PlantLoop>(OS_Sizing_PlantFields::PlantorCondenserLoopName);
101 }
102
103 ✗ std::vector<std::string> SizingPlant_Impl::loopTypeValues() const {
104 ✗ return SizingPlant::loopTypeValues();
105 }
106
107 ✗ boost::optional<ModelObject> SizingPlant_Impl::plantLoopAsModelObject() const {
108 ✗ OptionalModelObject result = plantLoop();
109 ✗ return result;
110 }
111
112 ✗ bool SizingPlant_Impl::setPlantLoopAsModelObject(const boost::optional<ModelObject>& modelObject) {
113 ✗ if (modelObject) {
114 ✗ OptionalPlantLoop intermediate = modelObject->optionalCast<PlantLoop>();
115 ✗ if (intermediate) {
116 ✗ PlantLoop plantLoop(*intermediate);
117 ✗ return setPlantLoop(plantLoop);
118 ✗ }
119 ✗ }
120 ✗ return false;
121 }
122
123 261 std::string SizingPlant_Impl::sizingOption() const {
124
1/1
✓ Branch 1 taken 261 times.
261 boost::optional<std::string> value = getString(OS_Sizing_PlantFields::SizingOption, true);
125
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 261 times.
✗ Branch 4 not taken.
261 OS_ASSERT(value);
126
2/2
✓ Branch 1 taken 261 times.
✓ Branch 4 taken 261 times.
522 return value.get();
127 261 }
128
129 240 int SizingPlant_Impl::zoneTimestepsinAveragingWindow() const {
130
1/1
✓ Branch 1 taken 240 times.
240 boost::optional<int> value = getInt(OS_Sizing_PlantFields::ZoneTimestepsinAveragingWindow, true);
131
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 240 times.
✗ Branch 4 not taken.
240 OS_ASSERT(value);
132
1/1
✓ Branch 1 taken 240 times.
480 return value.get();
133 }
134
135 240 std::string SizingPlant_Impl::coincidentSizingFactorMode() const {
136
1/1
✓ Branch 1 taken 240 times.
240 boost::optional<std::string> value = getString(OS_Sizing_PlantFields::CoincidentSizingFactorMode, true);
137
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 240 times.
✗ Branch 4 not taken.
240 OS_ASSERT(value);
138
2/2
✓ Branch 1 taken 240 times.
✓ Branch 4 taken 240 times.
480 return value.get();
139 240 }
140
141 520 bool SizingPlant_Impl::setSizingOption(const std::string& sizingOption) {
142 520 bool result = setString(OS_Sizing_PlantFields::SizingOption, sizingOption);
143 520 return result;
144 }
145
146 516 bool SizingPlant_Impl::setZoneTimestepsinAveragingWindow(int zoneTimestepsinAveragingWindow) {
147 516 bool result = setInt(OS_Sizing_PlantFields::ZoneTimestepsinAveragingWindow, zoneTimestepsinAveragingWindow);
148 516 return result;
149 }
150
151 516 bool SizingPlant_Impl::setCoincidentSizingFactorMode(const std::string& coincidentSizingFactorMode) {
152 516 bool result = setString(OS_Sizing_PlantFields::CoincidentSizingFactorMode, coincidentSizingFactorMode);
153 516 return result;
154 }
155
156 } // namespace detail
157
158 516 SizingPlant::SizingPlant(const Model& model, const PlantLoop& plantLoop) : ModelObject(SizingPlant::iddObjectType(), model) {
159
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 516 times.
✗ Branch 5 not taken.
516 OS_ASSERT(getImpl<detail::SizingPlant_Impl>());
160
161
1/1
✓ Branch 1 taken 516 times.
516 setPlantLoop(plantLoop);
162
163
2/2
✓ Branch 1 taken 516 times.
✓ Branch 4 taken 516 times.
516 setLoopType("Heating");
164
1/1
✓ Branch 1 taken 516 times.
516 setDesignLoopExitTemperature(82.0);
165
1/1
✓ Branch 1 taken 516 times.
516 setLoopDesignTemperatureDifference(11.0);
166
2/2
✓ Branch 1 taken 516 times.
✓ Branch 4 taken 516 times.
516 setSizingOption("NonCoincident");
167
1/1
✓ Branch 1 taken 516 times.
516 setZoneTimestepsinAveragingWindow(1);
168
2/2
✓ Branch 1 taken 516 times.
✓ Branch 4 taken 516 times.
516 setCoincidentSizingFactorMode("None");
169 516 }
170
171 9187 IddObjectType SizingPlant::iddObjectType() {
172
1/1
✓ Branch 1 taken 9187 times.
9187 return {IddObjectType::OS_Sizing_Plant};
173 }
174
175 ✗ std::vector<std::string> SizingPlant::loopTypeValues() {
176 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_Sizing_PlantFields::LoopType);
177 }
178
179 1767 PlantLoop SizingPlant::plantLoop() const {
180
1/1
✓ Branch 3 taken 1767 times.
1767 return getImpl<detail::SizingPlant_Impl>()->plantLoop();
181 }
182
183 240 std::string SizingPlant::loopType() const {
184
1/1
✓ Branch 3 taken 240 times.
240 return getImpl<detail::SizingPlant_Impl>()->loopType();
185 }
186
187 488 double SizingPlant::designLoopExitTemperature() const {
188
1/1
✓ Branch 3 taken 488 times.
488 return getImpl<detail::SizingPlant_Impl>()->designLoopExitTemperature();
189 }
190
191 240 double SizingPlant::loopDesignTemperatureDifference() const {
192
1/1
✓ Branch 3 taken 240 times.
240 return getImpl<detail::SizingPlant_Impl>()->loopDesignTemperatureDifference();
193 }
194
195 516 bool SizingPlant::setPlantLoop(const PlantLoop& plantLoop) {
196
1/1
✓ Branch 3 taken 516 times.
516 return getImpl<detail::SizingPlant_Impl>()->setPlantLoop(plantLoop);
197 }
198
199 529 bool SizingPlant::setLoopType(const std::string& loopType) {
200
1/1
✓ Branch 3 taken 529 times.
529 return getImpl<detail::SizingPlant_Impl>()->setLoopType(loopType);
201 }
202
203 530 bool SizingPlant::setDesignLoopExitTemperature(double designLoopExitTemperature) {
204
1/1
✓ Branch 3 taken 530 times.
530 return getImpl<detail::SizingPlant_Impl>()->setDesignLoopExitTemperature(designLoopExitTemperature);
205 }
206
207 530 bool SizingPlant::setLoopDesignTemperatureDifference(double loopDesignTemperatureDifference) {
208
1/1
✓ Branch 3 taken 530 times.
530 return getImpl<detail::SizingPlant_Impl>()->setLoopDesignTemperatureDifference(loopDesignTemperatureDifference);
209 }
210
211 ✗ std::vector<std::string> SizingPlant::sizingOptionValues() {
212 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_Sizing_PlantFields::SizingOption);
213 }
214
215 ✗ std::vector<std::string> SizingPlant::coincidentSizingFactorModeValues() {
216 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_Sizing_PlantFields::CoincidentSizingFactorMode);
217 }
218
219 261 std::string SizingPlant::sizingOption() const {
220
1/1
✓ Branch 3 taken 261 times.
261 return getImpl<detail::SizingPlant_Impl>()->sizingOption();
221 }
222
223 240 int SizingPlant::zoneTimestepsinAveragingWindow() const {
224
1/1
✓ Branch 3 taken 240 times.
240 return getImpl<detail::SizingPlant_Impl>()->zoneTimestepsinAveragingWindow();
225 }
226
227 520 bool SizingPlant::setSizingOption(const std::string& sizingOption) {
228
1/1
✓ Branch 3 taken 520 times.
520 return getImpl<detail::SizingPlant_Impl>()->setSizingOption(sizingOption);
229 }
230
231 516 bool SizingPlant::setZoneTimestepsinAveragingWindow(int zoneTimestepsinAveragingWindow) {
232
1/1
✓ Branch 3 taken 516 times.
516 return getImpl<detail::SizingPlant_Impl>()->setZoneTimestepsinAveragingWindow(zoneTimestepsinAveragingWindow);
233 }
234
235 516 bool SizingPlant::setCoincidentSizingFactorMode(const std::string& coincidentSizingFactorMode) {
236
1/1
✓ Branch 3 taken 516 times.
516 return getImpl<detail::SizingPlant_Impl>()->setCoincidentSizingFactorMode(coincidentSizingFactorMode);
237 }
238
239 240 std::string SizingPlant::coincidentSizingFactorMode() const {
240
1/1
✓ Branch 3 taken 240 times.
240 return getImpl<detail::SizingPlant_Impl>()->coincidentSizingFactorMode();
241 }
242
243 /// @cond
244
1/1
✓ Branch 3 taken 1767 times.
1767 SizingPlant::SizingPlant(std::shared_ptr<detail::SizingPlant_Impl> impl) : ModelObject(std::move(impl)) {}
245 /// @endcond
246
247 } // namespace model
248 } // namespace openstudio
249