GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 58.7% 101 / 0 / 172
Functions: 66.7% 28 / 0 / 42
Branches: 28.5% 70 / 0 / 246

src/model/AirTerminalDualDuctConstantVolume.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 "AirTerminalDualDuctConstantVolume.hpp"
7 #include "AirTerminalDualDuctConstantVolume_Impl.hpp"
8 #include "AirLoopHVAC.hpp"
9 #include "AirLoopHVAC_Impl.hpp"
10 #include "Schedule.hpp"
11 #include "Schedule_Impl.hpp"
12 #include "Model.hpp"
13 #include "Model_Impl.hpp"
14 #include "Mixer.hpp"
15 #include "Mixer_Impl.hpp"
16 #include "Node.hpp"
17 #include "Node_Impl.hpp"
18 #include "ScheduleTypeLimits.hpp"
19 #include "ScheduleTypeRegistry.hpp"
20
21 #include <utilities/idd/IddFactory.hxx>
22 #include <utilities/idd/IddEnums.hxx>
23 #include <utilities/idd/OS_AirTerminal_DualDuct_ConstantVolume_FieldEnums.hxx>
24
25 #include "../utilities/core/Assert.hpp"
26 #include "../utilities/data/DataEnums.hpp"
27
28 namespace openstudio {
29 namespace model {
30
31 namespace detail {
32
33 10 AirTerminalDualDuctConstantVolume_Impl::AirTerminalDualDuctConstantVolume_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
34 10 : Mixer_Impl(idfObject, model, keepHandle) {
35
4/6
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✓ Branch 7 taken 10 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 10 times.
✗ Branch 13 not taken.
10 OS_ASSERT(idfObject.iddObject().type() == AirTerminalDualDuctConstantVolume::iddObjectType());
36 10 }
37
38 ✗ AirTerminalDualDuctConstantVolume_Impl::AirTerminalDualDuctConstantVolume_Impl(const openstudio::detail::WorkspaceObject_Impl& other,
39 ✗ Model_Impl* model, bool keepHandle)
40 ✗ : Mixer_Impl(other, model, keepHandle) {
41 ✗ OS_ASSERT(other.iddObject().type() == AirTerminalDualDuctConstantVolume::iddObjectType());
42 ✗ }
43
44 4 AirTerminalDualDuctConstantVolume_Impl::AirTerminalDualDuctConstantVolume_Impl(const AirTerminalDualDuctConstantVolume_Impl& other,
45 4 Model_Impl* model, bool keepHandle)
46 4 : Mixer_Impl(other, model, keepHandle) {}
47
48 ✗ const std::vector<std::string>& AirTerminalDualDuctConstantVolume_Impl::outputVariableNames() const {
49 static const std::vector<std::string> result{
50 // These apply to all AirTerminals
51 "Zone Air Terminal Sensible Heating Energy", "Zone Air Terminal Sensible Heating Rate",
52 "Zone Air Terminal Sensible Cooling Energy", "Zone Air Terminal Sensible Cooling Rate",
53
54 ✗ "Zone Air Terminal Cold Supply Duct Damper Position", "Zone Air Terminal Hot Supply Duct Damper Position"};
55 ✗ return result;
56 ✗ }
57
58 24 IddObjectType AirTerminalDualDuctConstantVolume_Impl::iddObjectType() const {
59 24 return AirTerminalDualDuctConstantVolume::iddObjectType();
60 }
61
62 // Availability Schedule
63 ✗ std::vector<ScheduleTypeKey> AirTerminalDualDuctConstantVolume_Impl::getScheduleTypeKeys(const Schedule& schedule) const {
64 ✗ std::vector<ScheduleTypeKey> result;
65 ✗ UnsignedVector fieldIndices = getSourceIndices(schedule.handle());
66 ✗ UnsignedVector::const_iterator b(fieldIndices.begin());
67 ✗ UnsignedVector::const_iterator e(fieldIndices.end());
68 ✗ if (std::find(b, e, OS_AirTerminal_DualDuct_ConstantVolumeFields::AvailabilitySchedule) != e) {
69 ✗ result.push_back(ScheduleTypeKey("AirTerminalDualDuctConstantVolume", "Availability Schedule"));
70 }
71 ✗ return result;
72 ✗ }
73
74 5 Schedule AirTerminalDualDuctConstantVolume_Impl::availabilitySchedule() const {
75 boost::optional<Schedule> result =
76
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_AirTerminal_DualDuct_ConstantVolumeFields::AvailabilitySchedule);
77
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
5 if (!result) {
78 ✗ LOG_AND_THROW(briefDescription() << " does not have an Availability Schedule attached.");
79 }
80
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
10 return result.get();
81 5 }
82
83 12 bool AirTerminalDualDuctConstantVolume_Impl::setAvailabilitySchedule(Schedule& schedule) {
84
3/3
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
48 bool result = setSchedule(OS_AirTerminal_DualDuct_ConstantVolumeFields::AvailabilitySchedule, "AirTerminalDualDuctConstantVolume",
85 "Availability Schedule", schedule);
86 12 return result;
87 }
88
89 116 unsigned AirTerminalDualDuctConstantVolume_Impl::outletPort() const {
90 116 return OS_AirTerminal_DualDuct_ConstantVolumeFields::AirOutletNode;
91 }
92
93 34 unsigned AirTerminalDualDuctConstantVolume_Impl::inletPort(unsigned branchIndex) const {
94
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 17 times.
34 if (branchIndex == 0) {
95 17 return OS_AirTerminal_DualDuct_ConstantVolumeFields::HotAirInletNode;
96
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 } else if (branchIndex == 1) {
97 17 return OS_AirTerminal_DualDuct_ConstantVolumeFields::ColdAirInletNode;
98 } else {
99 ✗ LOG(Warn, "Calling inletPort with branchIndex greater than 1 for " << briefDescription() << " is not valid.");
100 ✗ LOG(Warn, briefDescription() << " has only two branches.");
101 ✗ return std::numeric_limits<unsigned>::max();
102 }
103 }
104
105 ✗ unsigned AirTerminalDualDuctConstantVolume_Impl::nextInletPort() const {
106 ✗ LOG(Warn, "nextInletPort is not supported for " << briefDescription() << " .");
107 ✗ LOG(Warn, "Ports cannot be added or removed for " << briefDescription() << " .");
108 ✗ return std::numeric_limits<unsigned>::max();
109 }
110
111 ✗ unsigned AirTerminalDualDuctConstantVolume_Impl::newInletPortAfterBranch(unsigned /*branchIndex*/) {
112 ✗ LOG(Warn, "newInletPortAfterBranch is not supported for " << briefDescription() << " .");
113 ✗ LOG(Warn, "Ports cannot be added or removed for " << briefDescription() << " .");
114 ✗ return std::numeric_limits<unsigned>::max();
115 }
116
117 ✗ void AirTerminalDualDuctConstantVolume_Impl::removePortForBranch(unsigned /*branchIndex*/) {
118 ✗ LOG(Warn, "removePortForBranch is not supported for " << briefDescription() << " .");
119 ✗ LOG(Warn, "Ports cannot be added or removed for " << briefDescription() << " .");
120 ✗ }
121
122 // Maximum Air Flow Rate
123 5 boost::optional<double> AirTerminalDualDuctConstantVolume_Impl::maximumAirFlowRate() const {
124 5 return getDouble(OS_AirTerminal_DualDuct_ConstantVolumeFields::MaximumAirFlowRate, true);
125 }
126
127 5 bool AirTerminalDualDuctConstantVolume_Impl::isMaximumAirFlowRateAutosized() const {
128 5 bool result = false;
129
1/1
✓ Branch 1 taken 5 times.
5 boost::optional<std::string> value = getString(OS_AirTerminal_DualDuct_ConstantVolumeFields::MaximumAirFlowRate, true);
130
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (value) {
131
3/3
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
10 result = openstudio::istringEqual(value.get(), "autosize");
132 }
133 5 return result;
134 5 }
135
136 2 bool AirTerminalDualDuctConstantVolume_Impl::setMaximumAirFlowRate(double maximumAirFlowRate) {
137 2 bool result = setDouble(OS_AirTerminal_DualDuct_ConstantVolumeFields::MaximumAirFlowRate, maximumAirFlowRate);
138 2 return result;
139 }
140
141 11 void AirTerminalDualDuctConstantVolume_Impl::autosizeMaximumAirFlowRate() {
142
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
22 bool result = setString(OS_AirTerminal_DualDuct_ConstantVolumeFields::MaximumAirFlowRate, "autosize");
143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 OS_ASSERT(result);
144 11 }
145
146 ✗ boost::optional<double> AirTerminalDualDuctConstantVolume_Impl::autosizedMaximumAirFlowRate() const {
147 ✗ return getAutosizedValue("Maximum Air Flow Rate", "m3/s");
148 }
149
150 4 boost::optional<Node> AirTerminalDualDuctConstantVolume_Impl::hotAirInletNode() const {
151 4 boost::optional<Node> node;
152
3/3
✓ Branch 1 taken 4 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 1 time.
8 if (auto mo = inletModelObject(0)) {
153
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 node = mo->optionalCast<Node>();
154
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 4 not taken.
3 OS_ASSERT(node);
155 4 }
156 4 return node;
157 ✗ }
158
159 4 boost::optional<Node> AirTerminalDualDuctConstantVolume_Impl::coldAirInletNode() const {
160 4 boost::optional<Node> node;
161
3/3
✓ Branch 1 taken 4 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 1 time.
8 if (auto mo = inletModelObject(1)) {
162
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 node = mo->optionalCast<Node>();
163
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 4 not taken.
3 OS_ASSERT(node);
164 4 }
165 4 return node;
166 ✗ }
167
168 2 std::vector<IdfObject> AirTerminalDualDuctConstantVolume_Impl::remove() {
169
1/1
✓ Branch 1 taken 2 times.
2 auto modelObject = getObject<AirTerminalDualDuctConstantVolume>();
170
4/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
2 AirLoopHVAC_Impl::removeDualDuctTerminalFromAirLoopHVAC(modelObject, inletPort(0), inletPort(1), outletPort());
171
1/1
✓ Branch 1 taken 2 times.
4 return Mixer_Impl::remove();
172 2 }
173
174 7 bool AirTerminalDualDuctConstantVolume_Impl::addToNode(Node& node) {
175
1/1
✓ Branch 1 taken 7 times.
7 auto mo = getObject<AirTerminalDualDuctConstantVolume>();
176
4/4
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
✓ Branch 10 taken 7 times.
14 return AirLoopHVAC_Impl::addDualDuctTerminalToNode(mo, inletPort(0), inletPort(1), outletPort(), node);
177 7 }
178
179 1 ModelObject AirTerminalDualDuctConstantVolume_Impl::clone(Model model) const {
180
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 auto t_clone = Mixer_Impl::clone(model).cast<AirTerminalDualDuctConstantVolume>();
181
182
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 t_clone.setString(OS_AirTerminal_DualDuct_ConstantVolumeFields::HotAirInletNode, "");
183
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 t_clone.setString(OS_AirTerminal_DualDuct_ConstantVolumeFields::ColdAirInletNode, "");
184
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 t_clone.setString(OS_AirTerminal_DualDuct_ConstantVolumeFields::AirOutletNode, "");
185
186 2 return std::move(t_clone);
187 1 }
188
189 2 bool AirTerminalDualDuctConstantVolume_Impl::isRemovable() const {
190 2 return HVACComponent_Impl::isRemovable();
191 }
192
193 ✗ void AirTerminalDualDuctConstantVolume_Impl::autosize() {
194 ✗ autosizeMaximumAirFlowRate();
195 ✗ }
196
197 ✗ void AirTerminalDualDuctConstantVolume_Impl::applySizingValues() {
198 ✗ boost::optional<double> val;
199 ✗ val = autosizedMaximumAirFlowRate();
200 ✗ if (val) {
201 ✗ setMaximumAirFlowRate(val.get());
202 }
203 ✗ }
204
205 ✗ ComponentType AirTerminalDualDuctConstantVolume_Impl::componentType() const {
206 ✗ if (auto a_ = airLoopHVAC()) {
207 ✗ return a_->componentType();
208 ✗ }
209
210 ✗ return ComponentType::None;
211 }
212
213 ✗ std::vector<FuelType> AirTerminalDualDuctConstantVolume_Impl::coolingFuelTypes() const {
214 ✗ if (auto a_ = airLoopHVAC()) {
215 ✗ return a_->coolingFuelTypes();
216 ✗ }
217 ✗ return {};
218 }
219
220 ✗ std::vector<FuelType> AirTerminalDualDuctConstantVolume_Impl::heatingFuelTypes() const {
221 ✗ if (auto a_ = airLoopHVAC()) {
222 ✗ return a_->heatingFuelTypes();
223 ✗ }
224 ✗ return {};
225 }
226
227 ✗ std::vector<AppGFuelType> AirTerminalDualDuctConstantVolume_Impl::appGHeatingFuelTypes() const {
228 ✗ if (auto a_ = airLoopHVAC()) {
229 ✗ return a_->appGHeatingFuelTypes();
230 ✗ }
231 ✗ return {};
232 }
233
234 } // namespace detail
235
236 10 AirTerminalDualDuctConstantVolume::AirTerminalDualDuctConstantVolume(const Model& model)
237 10 : Mixer(AirTerminalDualDuctConstantVolume::iddObjectType(), model) {
238
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
✗ Branch 5 not taken.
10 OS_ASSERT(getImpl<detail::AirTerminalDualDuctConstantVolume_Impl>());
239
240
1/1
✓ Branch 1 taken 10 times.
10 Schedule sch = model.alwaysOnDiscreteSchedule();
241
1/1
✓ Branch 1 taken 10 times.
10 bool ok = setAvailabilitySchedule(sch);
242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (!ok) {
243 ✗ remove();
244 ✗ LOG_AND_THROW("Unable to set " << briefDescription() << "'s availability schedule to " << sch.briefDescription() << ".");
245 }
246
247
1/1
✓ Branch 1 taken 10 times.
10 autosizeMaximumAirFlowRate();
248 10 }
249
250 7642 IddObjectType AirTerminalDualDuctConstantVolume::iddObjectType() {
251
1/1
✓ Branch 1 taken 7642 times.
7642 return {IddObjectType::OS_AirTerminal_DualDuct_ConstantVolume};
252 }
253
254 5 Schedule AirTerminalDualDuctConstantVolume::availabilitySchedule() const {
255
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::AirTerminalDualDuctConstantVolume_Impl>()->availabilitySchedule();
256 }
257
258 12 bool AirTerminalDualDuctConstantVolume::setAvailabilitySchedule(Schedule& schedule) {
259
1/1
✓ Branch 3 taken 12 times.
12 return getImpl<detail::AirTerminalDualDuctConstantVolume_Impl>()->setAvailabilitySchedule(schedule);
260 }
261
262 4 boost::optional<Node> AirTerminalDualDuctConstantVolume::hotAirInletNode() const {
263
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::AirTerminalDualDuctConstantVolume_Impl>()->hotAirInletNode();
264 }
265
266 4 boost::optional<Node> AirTerminalDualDuctConstantVolume::coldAirInletNode() const {
267
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::AirTerminalDualDuctConstantVolume_Impl>()->coldAirInletNode();
268 }
269
270 5 boost::optional<double> AirTerminalDualDuctConstantVolume::maximumAirFlowRate() const {
271
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::AirTerminalDualDuctConstantVolume_Impl>()->maximumAirFlowRate();
272 }
273
274 5 bool AirTerminalDualDuctConstantVolume::isMaximumAirFlowRateAutosized() const {
275
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::AirTerminalDualDuctConstantVolume_Impl>()->isMaximumAirFlowRateAutosized();
276 }
277
278 2 bool AirTerminalDualDuctConstantVolume::setMaximumAirFlowRate(double maximumAirFlowRate) {
279
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::AirTerminalDualDuctConstantVolume_Impl>()->setMaximumAirFlowRate(maximumAirFlowRate);
280 }
281
282 11 void AirTerminalDualDuctConstantVolume::autosizeMaximumAirFlowRate() {
283
1/1
✓ Branch 3 taken 11 times.
11 getImpl<detail::AirTerminalDualDuctConstantVolume_Impl>()->autosizeMaximumAirFlowRate();
284 11 }
285
286 ✗ boost::optional<double> AirTerminalDualDuctConstantVolume::autosizedMaximumAirFlowRate() const {
287 ✗ return getImpl<detail::AirTerminalDualDuctConstantVolume_Impl>()->autosizedMaximumAirFlowRate();
288 }
289
290 /*
291 *void AirTerminalDualDuctConstantVolume::autosize() {
292 * getImpl<detail::AirTerminalDualDuctConstantVolume_Impl>()->autosize();
293 *}
294 *
295 *void AirTerminalDualDuctConstantVolume::applySizingValues() {
296 * getImpl<detail::AirTerminalDualDuctConstantVolume_Impl>()->applySizingValues();
297 *}
298 */
299
300 /// @cond
301 14 AirTerminalDualDuctConstantVolume::AirTerminalDualDuctConstantVolume(std::shared_ptr<detail::AirTerminalDualDuctConstantVolume_Impl> impl)
302
1/1
✓ Branch 2 taken 14 times.
14 : Mixer(impl) {}
303 /// @endcond
304
305 } // namespace model
306 } // namespace openstudio
307