GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 81.0% 128 / 0 / 158
Functions: 80.0% 24 / 0 / 30
Branches: 69.4% 152 / 0 / 219

src/model/AirTerminalSingleDuctInletSideMixer.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 "AirTerminalSingleDuctInletSideMixer.hpp"
7 #include "AirTerminalSingleDuctInletSideMixer_Impl.hpp"
8 #include "ThermalZone.hpp"
9 #include "ThermalZone_Impl.hpp"
10 #include "ZoneHVACComponent.hpp"
11 #include "ZoneHVACComponent_Impl.hpp"
12 #include "Model.hpp"
13 #include "Model_Impl.hpp"
14 #include "Node.hpp"
15 #include "Node_Impl.hpp"
16 #include "Splitter.hpp"
17 #include "Splitter_Impl.hpp"
18 #include "Mixer.hpp"
19 #include "Mixer_Impl.hpp"
20 #include "PortList.hpp"
21 #include "PortList_Impl.hpp"
22
23 #include <utilities/idd/IddFactory.hxx>
24 #include <utilities/idd/IddEnums.hxx>
25 #include <utilities/idd/OS_AirTerminal_SingleDuct_InletSideMixer_FieldEnums.hxx>
26
27 #include "../utilities/core/Assert.hpp"
28 #include "../utilities/data/DataEnums.hpp"
29
30 namespace openstudio {
31 namespace model {
32
33 namespace detail {
34
35 16 AirTerminalSingleDuctInletSideMixer_Impl::AirTerminalSingleDuctInletSideMixer_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
36 16 : StraightComponent_Impl(idfObject, model, keepHandle) {
37
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() == AirTerminalSingleDuctInletSideMixer::iddObjectType());
38 16 }
39
40 1 AirTerminalSingleDuctInletSideMixer_Impl::AirTerminalSingleDuctInletSideMixer_Impl(const openstudio::detail::WorkspaceObject_Impl& other,
41 1 Model_Impl* model, bool keepHandle)
42 1 : StraightComponent_Impl(other, model, keepHandle) {
43
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() == AirTerminalSingleDuctInletSideMixer::iddObjectType());
44 1 }
45
46 4 AirTerminalSingleDuctInletSideMixer_Impl::AirTerminalSingleDuctInletSideMixer_Impl(const AirTerminalSingleDuctInletSideMixer_Impl& other,
47 4 Model_Impl* model, bool keepHandle)
48 4 : StraightComponent_Impl(other, model, keepHandle) {}
49
50 ✗ const std::vector<std::string>& AirTerminalSingleDuctInletSideMixer_Impl::outputVariableNames() const {
51 ✗ static const std::vector<std::string> result;
52 ✗ return result;
53 }
54
55 15 IddObjectType AirTerminalSingleDuctInletSideMixer_Impl::iddObjectType() const {
56 15 return AirTerminalSingleDuctInletSideMixer::iddObjectType();
57 }
58
59 30 unsigned AirTerminalSingleDuctInletSideMixer_Impl::inletPort() const {
60 30 return OS_AirTerminal_SingleDuct_InletSideMixerFields::TerminalUnitPrimaryAirInlet;
61 }
62
63 94 unsigned AirTerminalSingleDuctInletSideMixer_Impl::outletPort() const {
64 94 return OS_AirTerminal_SingleDuct_InletSideMixerFields::TerminalUnitOutlet;
65 }
66
67 19 bool AirTerminalSingleDuctInletSideMixer_Impl::addToNode(Node& node) {
68
1/1
✓ Branch 1 taken 19 times.
19 Model _model = node.model();
69
70
2/3
✓ Branch 1 taken 19 times.
✓ Branch 3 taken 19 times.
✗ Branch 4 not taken.
38 if (boost::optional<ModelObject> outlet = node.outletModelObject()) {
71 19 boost::optional<ThermalZone> thermalZone;
72
73
4/4
✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 12 times.
38 if (boost::optional<PortList> portList = outlet->optionalCast<PortList>()) {
74
3/3
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
7 thermalZone = portList->thermalZone();
75 19 }
76
77
15/19
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 7 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 7 times.
✓ Branch 11 taken 5 times.
✓ Branch 13 taken 7 times.
✓ Branch 16 taken 6 times.
✓ Branch 17 taken 1 time.
✓ Branch 18 taken 7 times.
✓ Branch 19 taken 12 times.
✓ Branch 21 taken 12 times.
✓ Branch 22 taken 7 times.
✓ Branch 24 taken 13 times.
✓ Branch 25 taken 6 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
57 if (thermalZone || (outlet->optionalCast<Mixer>() && node.airLoopHVAC())) {
78
2/3
✓ Branch 1 taken 13 times.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
26 if (boost::optional<ModelObject> inlet = node.inletModelObject()) {
79
3/4
✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
✓ Branch 6 taken 13 times.
✗ Branch 7 not taken.
26 if (boost::optional<Splitter> splitter = inlet->optionalCast<Splitter>()) {
80
1/1
✓ Branch 1 taken 13 times.
13 boost::optional<ModelObject> sourceModelObject = inlet;
81
2/2
✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
13 boost::optional<unsigned> sourcePort = node.connectedObjectPort(node.inletPort());
82
83
3/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
26 if (sourcePort && sourceModelObject) {
84
1/1
✓ Branch 1 taken 13 times.
13 Node inletNode(_model);
85
86
6/6
✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
✓ Branch 7 taken 13 times.
✓ Branch 10 taken 13 times.
✓ Branch 13 taken 13 times.
✓ Branch 16 taken 13 times.
13 _model.connect(sourceModelObject.get(), sourcePort.get(), inletNode, inletNode.inletPort());
87
88
5/5
✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
✓ Branch 7 taken 13 times.
✓ Branch 10 taken 13 times.
✓ Branch 13 taken 13 times.
13 _model.connect(inletNode, inletNode.outletPort(), this->getObject<ModelObject>(), this->inletPort());
89
90
5/5
✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
✓ Branch 7 taken 13 times.
✓ Branch 10 taken 13 times.
✓ Branch 13 taken 13 times.
13 _model.connect(this->getObject<ModelObject>(), outletPort(), node, node.inletPort());
91
92
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 6 times.
13 if (thermalZone) {
93
1/1
✓ Branch 1 taken 7 times.
7 auto mo = this->getObject<AirTerminalSingleDuctInletSideMixer>();
94
2/2
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
7 thermalZone->addEquipment(mo);
95 7 }
96
97 13 return true;
98 13 }
99 26 }
100 13 }
101 }
102 38 }
103
104 6 return false;
105 19 }
106
107 3 std::vector<IdfObject> AirTerminalSingleDuctInletSideMixer_Impl::remove() {
108
1/1
✓ Branch 1 taken 3 times.
3 Model _model = this->model();
109
1/1
✓ Branch 1 taken 3 times.
3 auto thisObject = this->getObject<AirTerminalSingleDuctInletSideMixer>();
110 3 boost::optional<ThermalZone> t_thermalZone;
111 3 boost::optional<ZoneHVACComponent> t_zoneComp;
112
113
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<AirLoopHVAC> t_airLoopHVAC = airLoopHVAC()) {
114 std::vector<ZoneHVACComponent> zoneComps =
115
7/7
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
6 subsetCastVector<ZoneHVACComponent>(t_airLoopHVAC->demandComponents(thisObject, t_airLoopHVAC->demandOutletNode()));
116
2/2
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 2 times.
3 if (!zoneComps.empty()) {
117
1/1
✓ Branch 2 taken 1 time.
1 t_zoneComp = zoneComps.front();
118
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 t_thermalZone = t_zoneComp->thermalZone();
119
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 t_zoneComp->removeFromThermalZone();
120 }
121 6 }
122
123
1/1
✓ Branch 1 taken 3 times.
3 boost::optional<ModelObject> sourceModelObject = this->inletModelObject();
124
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 boost::optional<unsigned> sourcePort = this->connectedObjectPort(this->inletPort());
125
126
1/1
✓ Branch 1 taken 3 times.
3 boost::optional<ModelObject> targetModelObject = this->outletModelObject();
127
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 boost::optional<unsigned> targetPort = this->connectedObjectPort(this->outletPort());
128
129
1/1
✓ Branch 1 taken 3 times.
3 std::vector<ThermalZone> thermalZones = _model.getConcreteModelObjects<ThermalZone>();
130
2/2
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 1 time.
3 for (auto& thermalZone : thermalZones) {
131
1/1
✓ Branch 1 taken 2 times.
2 std::vector<ModelObject> equipment = thermalZone.equipment();
132
133
2/3
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
2 if (std::find(equipment.begin(), equipment.end(), thisObject) != equipment.end()) {
134
1/1
✓ Branch 1 taken 2 times.
2 thermalZone.removeEquipment(thisObject);
135
136 2 break;
137 }
138 2 }
139
140
5/10
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
12 if (sourcePort && sourceModelObject && targetPort && targetModelObject) {
141
3/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
6 if (boost::optional<Node> inletNode = sourceModelObject->optionalCast<Node>()) {
142
3/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
6 if (boost::optional<ModelObject> source2ModelObject = inletNode->inletModelObject()) {
143
5/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
6 if (boost::optional<unsigned> source2Port = inletNode->connectedObjectPort(inletNode->inletPort())) {
144
7/7
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
3 _model.connect(source2ModelObject.get(), source2Port.get(), targetModelObject.get(), targetPort.get());
145
146
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 inletNode->disconnect();
147
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 inletNode->remove();
148
149
1/1
✓ Branch 1 taken 3 times.
3 std::vector<IdfObject> result = StraightComponent_Impl::remove();
150
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
3 if (t_thermalZone) {
151
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 t_zoneComp->addToThermalZone(t_thermalZone.get());
152 }
153 3 return result;
154 3 }
155 3 }
156 3 }
157 }
158
159 ✗ model().disconnect(getObject<ModelObject>(), inletPort());
160 ✗ model().disconnect(getObject<ModelObject>(), outletPort());
161
162 ✗ return StraightComponent_Impl::remove();
163 3 }
164
165 4 bool AirTerminalSingleDuctInletSideMixer_Impl::isRemovable() const {
166 4 return true;
167 }
168
169 10 unsigned AirTerminalSingleDuctInletSideMixer_Impl::secondaryAirInletPort() const {
170 10 return OS_AirTerminal_SingleDuct_InletSideMixerFields::TerminalUnitSecondaryAirInlet;
171 }
172
173 6 boost::optional<Node> AirTerminalSingleDuctInletSideMixer_Impl::secondaryAirInletNode() const {
174 6 boost::optional<Node> result;
175
4/4
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 1 time.
12 if (boost::optional<ModelObject> mo = connectedObject(secondaryAirInletPort())) {
176
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 result = mo->optionalCast<Node>();
177 6 }
178 6 return result;
179 ✗ }
180
181 4 bool AirTerminalSingleDuctInletSideMixer_Impl::controlForOutdoorAir() const {
182 4 return getBooleanFieldValue(OS_AirTerminal_SingleDuct_InletSideMixerFields::ControlForOutdoorAir);
183 }
184
185 17 bool AirTerminalSingleDuctInletSideMixer_Impl::setControlForOutdoorAir(bool controlForOutdoorAir) {
186 17 return setBooleanFieldValue(OS_AirTerminal_SingleDuct_InletSideMixerFields::ControlForOutdoorAir, controlForOutdoorAir);
187 }
188
189 5 std::string AirTerminalSingleDuctInletSideMixer_Impl::perPersonVentilationRateMode() const {
190
1/1
✓ Branch 1 taken 5 times.
5 boost::optional<std::string> value = getString(OS_AirTerminal_SingleDuct_InletSideMixerFields::PerPersonVentilationRateMode, true);
191
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 4 not taken.
5 OS_ASSERT(value);
192
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
10 return value.get();
193 5 }
194
195 18 bool AirTerminalSingleDuctInletSideMixer_Impl::setPerPersonVentilationRateMode(const std::string& perPersonVentilationRateMode) {
196 18 bool result = setString(OS_AirTerminal_SingleDuct_InletSideMixerFields::PerPersonVentilationRateMode, perPersonVentilationRateMode);
197 18 return result;
198 }
199
200 ✗ ComponentType AirTerminalSingleDuctInletSideMixer_Impl::componentType() const {
201 ✗ if (auto a_ = airLoopHVAC()) {
202 ✗ return a_->componentType();
203 ✗ }
204
205 ✗ return ComponentType::None;
206 }
207
208 ✗ std::vector<FuelType> AirTerminalSingleDuctInletSideMixer_Impl::coolingFuelTypes() const {
209 ✗ if (auto a_ = airLoopHVAC()) {
210 ✗ return a_->coolingFuelTypes();
211 ✗ }
212 ✗ return {};
213 }
214
215 ✗ std::vector<FuelType> AirTerminalSingleDuctInletSideMixer_Impl::heatingFuelTypes() const {
216 ✗ if (auto a_ = airLoopHVAC()) {
217 ✗ return a_->heatingFuelTypes();
218 ✗ }
219 ✗ return {};
220 }
221
222 ✗ std::vector<AppGFuelType> AirTerminalSingleDuctInletSideMixer_Impl::appGHeatingFuelTypes() const {
223 ✗ if (auto a_ = airLoopHVAC()) {
224 ✗ return a_->appGHeatingFuelTypes();
225 ✗ }
226 ✗ return {};
227 }
228
229 } // namespace detail
230
231 15 AirTerminalSingleDuctInletSideMixer::AirTerminalSingleDuctInletSideMixer(const Model& model)
232 15 : StraightComponent(AirTerminalSingleDuctInletSideMixer::iddObjectType(), model) {
233
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 5 not taken.
15 OS_ASSERT(getImpl<detail::AirTerminalSingleDuctInletSideMixer_Impl>());
234
235 // This is a very OA-centric object, so enabled by default
236
1/1
✓ Branch 1 taken 15 times.
15 setControlForOutdoorAir(true);
237
238 // E+ IDD default
239
2/2
✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
15 setPerPersonVentilationRateMode("CurrentOccupancy");
240 15 }
241
242 7775 IddObjectType AirTerminalSingleDuctInletSideMixer::iddObjectType() {
243
1/1
✓ Branch 1 taken 7775 times.
7775 return {IddObjectType::OS_AirTerminal_SingleDuct_InletSideMixer};
244 }
245
246 ✗ std::vector<std::string> AirTerminalSingleDuctInletSideMixer::perPersonVentilationRateModeValues() {
247 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(),
248 ✗ OS_AirTerminal_SingleDuct_InletSideMixerFields::PerPersonVentilationRateMode);
249 }
250
251 4 unsigned AirTerminalSingleDuctInletSideMixer::secondaryAirInletPort() const {
252
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::AirTerminalSingleDuctInletSideMixer_Impl>()->secondaryAirInletPort();
253 }
254
255 6 boost::optional<Node> AirTerminalSingleDuctInletSideMixer::secondaryAirInletNode() const {
256
1/1
✓ Branch 3 taken 6 times.
6 return getImpl<detail::AirTerminalSingleDuctInletSideMixer_Impl>()->secondaryAirInletNode();
257 }
258
259 // Instead of Design Specification Outdoor Air Object Name
260 4 bool AirTerminalSingleDuctInletSideMixer::controlForOutdoorAir() const {
261
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::AirTerminalSingleDuctInletSideMixer_Impl>()->controlForOutdoorAir();
262 }
263
264 17 bool AirTerminalSingleDuctInletSideMixer::setControlForOutdoorAir(bool controlForOutdoorAir) {
265
1/1
✓ Branch 3 taken 17 times.
17 return getImpl<detail::AirTerminalSingleDuctInletSideMixer_Impl>()->setControlForOutdoorAir(controlForOutdoorAir);
266 }
267
268 // Per Person Ventilation Rate Mode
269 5 std::string AirTerminalSingleDuctInletSideMixer::perPersonVentilationRateMode() const {
270
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::AirTerminalSingleDuctInletSideMixer_Impl>()->perPersonVentilationRateMode();
271 }
272
273 18 bool AirTerminalSingleDuctInletSideMixer::setPerPersonVentilationRateMode(const std::string& perPersonVentilationRateMode) {
274
1/1
✓ Branch 3 taken 18 times.
18 return getImpl<detail::AirTerminalSingleDuctInletSideMixer_Impl>()->setPerPersonVentilationRateMode(perPersonVentilationRateMode);
275 }
276
277 /// @cond
278 19 AirTerminalSingleDuctInletSideMixer::AirTerminalSingleDuctInletSideMixer(std::shared_ptr<detail::AirTerminalSingleDuctInletSideMixer_Impl> impl)
279
1/1
✓ Branch 3 taken 19 times.
19 : StraightComponent(std::move(impl)) {}
280 /// @endcond
281
282 } // namespace model
283 } // namespace openstudio
284