GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 97.5% 158 / 0 / 162
Functions: 97.1% 33 / 0 / 34
Branches: 85.2% 167 / 0 / 196

src/model/SetpointManagerMixedAir.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 "SetpointManagerMixedAir.hpp"
7 #include "SetpointManagerMixedAir_Impl.hpp"
8 #include "Model.hpp"
9 #include "Node.hpp"
10 #include "Node_Impl.hpp"
11 #include "FanComponentModel.hpp"
12 #include "FanComponentModel_Impl.hpp"
13 #include "FanConstantVolume.hpp"
14 #include "FanConstantVolume_Impl.hpp"
15 #include "FanVariableVolume.hpp"
16 #include "FanVariableVolume_Impl.hpp"
17 #include "FanOnOff.hpp"
18 #include "FanOnOff_Impl.hpp"
19 #include "FanSystemModel.hpp"
20 #include "FanSystemModel_Impl.hpp"
21 #include "AirLoopHVAC.hpp"
22 #include "AirLoopHVACOutdoorAirSystem.hpp"
23 #include "PlantLoop.hpp"
24 #include <utilities/idd/OS_SetpointManager_MixedAir_FieldEnums.hxx>
25 #include <utilities/idd/IddEnums.hxx>
26 #include "../utilities/core/Compare.hpp"
27 #include "../utilities/core/Assert.hpp"
28
29 namespace openstudio {
30
31 namespace model {
32
33 namespace detail {
34
35 808 SetpointManagerMixedAir_Impl::SetpointManagerMixedAir_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
36 808 : SetpointManager_Impl(idfObject, model, keepHandle) {
37
4/6
✓ Branch 1 taken 808 times.
✓ Branch 4 taken 808 times.
✓ Branch 7 taken 808 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 808 times.
✗ Branch 13 not taken.
808 OS_ASSERT(idfObject.iddObject().type() == SetpointManagerMixedAir::iddObjectType());
38 808 }
39
40 100 SetpointManagerMixedAir_Impl::SetpointManagerMixedAir_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model,
41 100 bool keepHandle)
42 100 : SetpointManager_Impl(other, model, keepHandle) {
43
4/6
✓ Branch 1 taken 100 times.
✓ Branch 4 taken 100 times.
✓ Branch 7 taken 100 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 100 times.
✗ Branch 13 not taken.
100 OS_ASSERT(other.iddObject().type() == SetpointManagerMixedAir::iddObjectType());
44 100 }
45
46 216 SetpointManagerMixedAir_Impl::SetpointManagerMixedAir_Impl(const SetpointManagerMixedAir_Impl& other, Model_Impl* model, bool keepHandles)
47 216 : SetpointManager_Impl(other, model, keepHandles) {}
48
49 4 const std::vector<std::string>& SetpointManagerMixedAir_Impl::outputVariableNames() const {
50
3/4
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
4 static const std::vector<std::string> result;
51 4 return result;
52 }
53
54 4 IddObjectType SetpointManagerMixedAir_Impl::iddObjectType() const {
55 4 return SetpointManagerMixedAir::iddObjectType();
56 }
57
58 703 bool SetpointManagerMixedAir_Impl::addToNode(Node& node) {
59 703 bool added = SetpointManager_Impl::addToNode(node);
60
2/2
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 1 time.
703 if (added) {
61
2/3
✓ Branch 1 taken 702 times.
✓ Branch 3 taken 702 times.
✗ Branch 4 not taken.
1404 if (boost::optional<AirLoopHVAC> _airLoop = node.airLoopHVAC()) {
62 702 std::vector<StraightComponent> fans;
63
4/4
✓ Branch 1 taken 702 times.
✓ Branch 4 taken 702 times.
✓ Branch 7 taken 702 times.
✓ Branch 10 taken 702 times.
1404 std::vector<ModelObject> supplyComponents = _airLoop->supplyComponents();
64
65
2/2
✓ Branch 4 taken 6268 times.
✓ Branch 5 taken 702 times.
6970 for (auto it = supplyComponents.begin(); it != supplyComponents.end(); ++it) {
66
3/3
✓ Branch 2 taken 6268 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 6262 times.
12536 if (boost::optional<FanVariableVolume> variableFan = it->optionalCast<FanVariableVolume>()) {
67
2/2
✓ Branch 1 taken 6 times.
✓ Branch 6 taken 6 times.
6 fans.insert(fans.begin(), *variableFan);
68
3/3
✓ Branch 2 taken 6262 times.
✓ Branch 4 taken 686 times.
✓ Branch 5 taken 5576 times.
12524 } else if (boost::optional<FanConstantVolume> constantFan = it->optionalCast<FanConstantVolume>()) {
69
2/2
✓ Branch 1 taken 686 times.
✓ Branch 6 taken 686 times.
686 fans.insert(fans.begin(), *constantFan);
70 }
71 // TODO: FanOnOff?
72
3/3
✓ Branch 2 taken 5576 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 5573 times.
11152 else if (boost::optional<FanSystemModel> systemModelFan = it->optionalCast<FanSystemModel>()) {
73
2/2
✓ Branch 1 taken 3 times.
✓ Branch 6 taken 3 times.
3 fans.insert(fans.begin(), *systemModelFan);
74
2/3
✓ Branch 2 taken 5573 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5573 times.
11146 } else if (boost::optional<FanComponentModel> componentModelFan = it->optionalCast<FanComponentModel>()) {
75 ✗ fans.insert(fans.begin(), *componentModelFan);
76 23679 }
77 }
78
79
2/2
✓ Branch 1 taken 695 times.
✓ Branch 2 taken 7 times.
702 if (!fans.empty()) {
80
1/1
✓ Branch 2 taken 695 times.
695 StraightComponent fan = fans.front();
81
4/5
✓ Branch 1 taken 695 times.
✓ Branch 4 taken 695 times.
✓ Branch 7 taken 695 times.
✓ Branch 11 taken 695 times.
✗ Branch 12 not taken.
1390 if (OptionalNode inletNode = fan.inletModelObject()->optionalCast<Node>()) {
82
2/2
✓ Branch 1 taken 695 times.
✓ Branch 4 taken 695 times.
695 this->setFanInletNode(*inletNode);
83 695 }
84
4/5
✓ Branch 1 taken 695 times.
✓ Branch 4 taken 695 times.
✓ Branch 7 taken 695 times.
✓ Branch 11 taken 695 times.
✗ Branch 12 not taken.
1390 if (OptionalNode outletNode = fan.outletModelObject()->optionalCast<Node>()) {
85
2/2
✓ Branch 1 taken 695 times.
✓ Branch 4 taken 695 times.
695 this->setFanOutletNode(*outletNode);
86 695 }
87 695 }
88
89
2/2
✓ Branch 1 taken 702 times.
✓ Branch 4 taken 702 times.
702 Node supplyOutletNode = _airLoop->supplyOutletNode();
90
1/1
✓ Branch 1 taken 702 times.
702 this->setReferenceSetpointNode(supplyOutletNode);
91 702 return true;
92 1404 }
93 }
94 1 return false;
95 }
96
97 2 ModelObject SetpointManagerMixedAir_Impl::clone(Model model) const {
98
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 auto clonedObject = SetpointManager_Impl::clone(model).cast<SetpointManagerMixedAir>();
99
1/1
✓ Branch 3 taken 2 times.
2 clonedObject.getImpl<detail::SetpointManagerMixedAir_Impl>()->resetReferenceSetpointNode();
100
1/1
✓ Branch 3 taken 2 times.
2 clonedObject.getImpl<detail::SetpointManagerMixedAir_Impl>()->resetFanInletNode();
101
1/1
✓ Branch 3 taken 2 times.
2 clonedObject.getImpl<detail::SetpointManagerMixedAir_Impl>()->resetFanOutletNode();
102 4 return std::move(clonedObject);
103 2 }
104
105 106 std::string SetpointManagerMixedAir_Impl::controlVariable() const {
106
1/1
✓ Branch 1 taken 106 times.
106 boost::optional<std::string> value = getString(OS_SetpointManager_MixedAirFields::ControlVariable, true);
107
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 4 not taken.
106 OS_ASSERT(value);
108
2/2
✓ Branch 1 taken 106 times.
✓ Branch 4 taken 106 times.
212 return value.get();
109 106 }
110
111 714 bool SetpointManagerMixedAir_Impl::setControlVariable(const std::string& value) {
112 714 return setString(OS_SetpointManager_MixedAirFields::ControlVariable, value);
113 }
114
115 127 boost::optional<Node> SetpointManagerMixedAir_Impl::referenceSetpointNode() {
116
2/2
✓ Branch 1 taken 127 times.
✓ Branch 4 taken 127 times.
127 return getObject<ModelObject>().getModelObjectTarget<Node>(OS_SetpointManager_MixedAirFields::ReferenceSetpointNodeName);
117 }
118
119 702 bool SetpointManagerMixedAir_Impl::setReferenceSetpointNode(Node& node) {
120
2/2
✓ Branch 1 taken 702 times.
✓ Branch 4 taken 702 times.
702 bool result = setPointer(OS_SetpointManager_MixedAirFields::ReferenceSetpointNodeName, node.handle());
121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 702 times.
702 OS_ASSERT(result);
122 702 return result;
123 }
124
125 2 void SetpointManagerMixedAir_Impl::resetReferenceSetpointNode() {
126
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
4 bool result = setString(OS_SetpointManager_MixedAirFields::ReferenceSetpointNodeName, "");
127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 OS_ASSERT(result);
128 2 }
129
130 133 boost::optional<Node> SetpointManagerMixedAir_Impl::fanInletNode() {
131
2/2
✓ Branch 1 taken 133 times.
✓ Branch 4 taken 133 times.
133 return getObject<ModelObject>().getModelObjectTarget<Node>(OS_SetpointManager_MixedAirFields::FanInletNodeName);
132 }
133
134 698 bool SetpointManagerMixedAir_Impl::setFanInletNode(Node& node) {
135
2/2
✓ Branch 1 taken 698 times.
✓ Branch 4 taken 698 times.
698 bool result = setPointer(OS_SetpointManager_MixedAirFields::FanInletNodeName, node.handle());
136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 698 times.
698 OS_ASSERT(result);
137 698 return result;
138 }
139
140 2 void SetpointManagerMixedAir_Impl::resetFanInletNode() {
141
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
4 bool result = setString(OS_SetpointManager_MixedAirFields::FanInletNodeName, "");
142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 OS_ASSERT(result);
143 2 }
144
145 133 boost::optional<Node> SetpointManagerMixedAir_Impl::fanOutletNode() {
146
2/2
✓ Branch 1 taken 133 times.
✓ Branch 4 taken 133 times.
133 return getObject<ModelObject>().getModelObjectTarget<Node>(OS_SetpointManager_MixedAirFields::FanOutletNodeName);
147 }
148
149 698 bool SetpointManagerMixedAir_Impl::setFanOutletNode(Node& node) {
150
2/2
✓ Branch 1 taken 698 times.
✓ Branch 4 taken 698 times.
698 bool result = setPointer(OS_SetpointManager_MixedAirFields::FanOutletNodeName, node.handle());
151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 698 times.
698 OS_ASSERT(result);
152 698 return result;
153 }
154
155 2 void SetpointManagerMixedAir_Impl::resetFanOutletNode() {
156
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
4 bool result = setString(OS_SetpointManager_MixedAirFields::FanOutletNodeName, "");
157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 OS_ASSERT(result);
158 2 }
159
160 2538 boost::optional<Node> SetpointManagerMixedAir_Impl::setpointNode() const {
161
2/2
✓ Branch 1 taken 2538 times.
✓ Branch 4 taken 2538 times.
2538 return getObject<ModelObject>().getModelObjectTarget<Node>(OS_SetpointManager_MixedAirFields::SetpointNodeorNodeListName);
162 }
163
164 702 bool SetpointManagerMixedAir_Impl::setSetpointNode(const Node& node) {
165
2/2
✓ Branch 1 taken 702 times.
✓ Branch 4 taken 702 times.
702 return setPointer(OS_SetpointManager_MixedAirFields::SetpointNodeorNodeListName, node.handle());
166 }
167
168 2 void SetpointManagerMixedAir_Impl::resetSetpointNode() {
169
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
4 bool result = setString(OS_SetpointManager_MixedAirFields::SetpointNodeorNodeListName, "");
170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 OS_ASSERT(result);
171 2 }
172
173 } // namespace detail
174
175 704 SetpointManagerMixedAir::SetpointManagerMixedAir(const Model& model) : SetpointManager(SetpointManagerMixedAir::iddObjectType(), model) {
176
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 704 times.
✗ Branch 5 not taken.
704 OS_ASSERT(getImpl<detail::SetpointManagerMixedAir_Impl>());
177
2/2
✓ Branch 1 taken 704 times.
✓ Branch 4 taken 704 times.
704 setControlVariable("Temperature");
178 704 }
179
180
1/1
✓ Branch 3 taken 138 times.
138 SetpointManagerMixedAir::SetpointManagerMixedAir(std::shared_ptr<detail::SetpointManagerMixedAir_Impl> p) : SetpointManager(std::move(p)) {}
181
182 9352 IddObjectType SetpointManagerMixedAir::iddObjectType() {
183
1/1
✓ Branch 1 taken 9352 times.
9352 IddObjectType result(IddObjectType::OS_SetpointManager_MixedAir);
184 9352 return result;
185 }
186
187 4 std::string SetpointManagerMixedAir::controlVariable() const {
188
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::SetpointManagerMixedAir_Impl>()->controlVariable();
189 }
190
191 714 bool SetpointManagerMixedAir::setControlVariable(const std::string& controlVariable) {
192
1/1
✓ Branch 3 taken 714 times.
714 return getImpl<detail::SetpointManagerMixedAir_Impl>()->setControlVariable(controlVariable);
193 }
194
195 127 boost::optional<Node> SetpointManagerMixedAir::referenceSetpointNode() {
196
1/1
✓ Branch 3 taken 127 times.
127 return getImpl<detail::SetpointManagerMixedAir_Impl>()->referenceSetpointNode();
197 }
198
199 ✗ bool SetpointManagerMixedAir::setReferenceSetpointNode(Node& node) {
200 ✗ return getImpl<detail::SetpointManagerMixedAir_Impl>()->setReferenceSetpointNode(node);
201 }
202
203 133 boost::optional<Node> SetpointManagerMixedAir::fanInletNode() {
204
1/1
✓ Branch 3 taken 133 times.
133 return getImpl<detail::SetpointManagerMixedAir_Impl>()->fanInletNode();
205 }
206
207 3 bool SetpointManagerMixedAir::setFanInletNode(Node& node) {
208
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::SetpointManagerMixedAir_Impl>()->setFanInletNode(node);
209 }
210
211 133 boost::optional<Node> SetpointManagerMixedAir::fanOutletNode() {
212
1/1
✓ Branch 3 taken 133 times.
133 return getImpl<detail::SetpointManagerMixedAir_Impl>()->fanOutletNode();
213 }
214
215 3 bool SetpointManagerMixedAir::setFanOutletNode(Node& node) {
216
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::SetpointManagerMixedAir_Impl>()->setFanOutletNode(node);
217 }
218
219 131 boost::optional<Node> SetpointManagerMixedAir::setpointNode() const {
220
1/1
✓ Branch 3 taken 131 times.
131 return getImpl<detail::SetpointManagerMixedAir_Impl>()->setpointNode();
221 }
222
223 224 void SetpointManagerMixedAir::updateFanInletOutletNodes(AirLoopHVAC& airLoopHVAC) {
224 224 boost::optional<Node> fanInletNode;
225 224 boost::optional<Node> fanOutletNode;
226
227 224 std::vector<StraightComponent> fans;
228
229
3/3
✓ Branch 1 taken 224 times.
✓ Branch 4 taken 224 times.
✓ Branch 7 taken 224 times.
448 std::vector<ModelObject> supplyComponents = airLoopHVAC.supplyComponents();
230
231
2/2
✓ Branch 5 taken 811 times.
✓ Branch 6 taken 224 times.
1035 for (const auto& supplyComponent : supplyComponents) {
232
3/3
✓ Branch 1 taken 811 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 789 times.
1622 if (boost::optional<FanVariableVolume> variableFan = supplyComponent.optionalCast<FanVariableVolume>()) {
233
2/2
✓ Branch 1 taken 22 times.
✓ Branch 6 taken 22 times.
22 fans.insert(fans.begin(), *variableFan);
234
3/3
✓ Branch 1 taken 789 times.
✓ Branch 3 taken 192 times.
✓ Branch 4 taken 597 times.
1578 } else if (boost::optional<FanConstantVolume> constantFan = supplyComponent.optionalCast<FanConstantVolume>()) {
235
2/2
✓ Branch 1 taken 192 times.
✓ Branch 6 taken 192 times.
192 fans.insert(fans.begin(), *constantFan);
236
2/3
✓ Branch 1 taken 597 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 597 times.
1194 } else if (boost::optional<FanOnOff> onOffFan = supplyComponent.optionalCast<FanOnOff>()) {
237 ✗ fans.insert(fans.begin(), *onOffFan);
238
3/3
✓ Branch 1 taken 597 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 592 times.
1194 } else if (boost::optional<FanSystemModel> systemModelFan = supplyComponent.optionalCast<FanSystemModel>()) {
239
2/2
✓ Branch 1 taken 5 times.
✓ Branch 6 taken 5 times.
5 fans.insert(fans.begin(), *systemModelFan);
240
3/3
✓ Branch 1 taken 592 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 589 times.
1184 } else if (boost::optional<FanComponentModel> componentModelFan = supplyComponent.optionalCast<FanComponentModel>()) {
241
2/2
✓ Branch 1 taken 3 times.
✓ Branch 6 taken 3 times.
3 fans.insert(fans.begin(), *componentModelFan);
242 3386 }
243 }
244
245
2/2
✓ Branch 1 taken 220 times.
✓ Branch 2 taken 4 times.
224 if (!fans.empty()) {
246 220 boost::optional<ModelObject> mo;
247
248
1/1
✓ Branch 2 taken 220 times.
220 mo = fans.front().inletModelObject();
249
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if (mo) {
250
2/2
✓ Branch 1 taken 220 times.
✓ Branch 4 taken 220 times.
220 fanInletNode = mo->optionalCast<Node>();
251 }
252
253
1/1
✓ Branch 2 taken 220 times.
220 mo = fans.front().outletModelObject();
254
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if (mo) {
255
2/2
✓ Branch 1 taken 220 times.
✓ Branch 4 taken 220 times.
220 fanOutletNode = mo->optionalCast<Node>();
256 }
257 220 }
258
259
5/6
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 220 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 220 times.
✓ Branch 5 taken 4 times.
444 if (fanInletNode && fanOutletNode) {
260
4/4
✓ Branch 1 taken 220 times.
✓ Branch 4 taken 220 times.
✓ Branch 7 taken 220 times.
✓ Branch 10 taken 220 times.
440 std::vector<model::Node> nodes = subsetCastVector<model::Node>(airLoopHVAC.supplyComponents());
261
262
2/2
✓ Branch 5 taken 511 times.
✓ Branch 6 taken 220 times.
731 for (auto& node : nodes) {
263
2/2
✓ Branch 1 taken 511 times.
✓ Branch 4 taken 511 times.
511 std::vector<SetpointManagerMixedAir> setpointManagers = subsetCastVector<SetpointManagerMixedAir>(node.setpointManagers());
264
2/2
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 508 times.
511 if (!setpointManagers.empty()) {
265
1/1
✓ Branch 2 taken 3 times.
3 SetpointManagerMixedAir spm = setpointManagers.front();
266
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 spm.setFanInletNode(fanInletNode.get());
267
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 spm.setFanOutletNode(fanOutletNode.get());
268 3 }
269 511 }
270 220 }
271 224 }
272
273 } // namespace model
274
275 } // namespace openstudio
276