GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 42.2% 73 / 0 / 173
Functions: 47.5% 19 / 0 / 40
Branches: 25.9% 60 / 0 / 232

src/model/ZoneHVACBaseboardConvectiveWater.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 "ZoneHVACBaseboardConvectiveWater.hpp"
7 #include "ZoneHVACBaseboardConvectiveWater_Impl.hpp"
8
9 // TODO: Check the following class names against object getters and setters.
10 #include "Schedule.hpp"
11 #include "Schedule_Impl.hpp"
12 #include "StraightComponent.hpp"
13 #include "StraightComponent_Impl.hpp"
14 #include "CoilHeatingWaterBaseboard.hpp"
15 #include "CoilHeatingWaterBaseboard_Impl.hpp"
16 #include "ScheduleTypeLimits.hpp"
17 #include "ScheduleTypeRegistry.hpp"
18 #include "ThermalZone.hpp"
19 #include "ThermalZone_Impl.hpp"
20 #include "Model.hpp"
21 #include "Model_Impl.hpp"
22
23 #include <utilities/idd/OS_ZoneHVAC_Baseboard_Convective_Water_FieldEnums.hxx>
24 #include <utilities/idd/IddEnums.hxx>
25
26 #include "../utilities/core/Assert.hpp"
27 #include "../utilities/data/DataEnums.hpp"
28
29 namespace openstudio {
30 namespace model {
31
32 namespace detail {
33
34 1 ZoneHVACBaseboardConvectiveWater_Impl::ZoneHVACBaseboardConvectiveWater_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
35 1 : ZoneHVACComponent_Impl(idfObject, model, keepHandle) {
36
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(idfObject.iddObject().type() == ZoneHVACBaseboardConvectiveWater::iddObjectType());
37 1 }
38
39 ✗ ZoneHVACBaseboardConvectiveWater_Impl::ZoneHVACBaseboardConvectiveWater_Impl(const openstudio::detail::WorkspaceObject_Impl& other,
40 ✗ Model_Impl* model, bool keepHandle)
41 ✗ : ZoneHVACComponent_Impl(other, model, keepHandle) {
42 ✗ OS_ASSERT(other.iddObject().type() == ZoneHVACBaseboardConvectiveWater::iddObjectType());
43 ✗ }
44
45 ✗ ZoneHVACBaseboardConvectiveWater_Impl::ZoneHVACBaseboardConvectiveWater_Impl(const ZoneHVACBaseboardConvectiveWater_Impl& other,
46 ✗ Model_Impl* model, bool keepHandle)
47 ✗ : ZoneHVACComponent_Impl(other, model, keepHandle) {}
48
49 ✗ ModelObject ZoneHVACBaseboardConvectiveWater_Impl::clone(Model model) const {
50 ✗ auto baseboardConvWaterClone = ZoneHVACComponent_Impl::clone(model).cast<ZoneHVACBaseboardConvectiveWater>();
51
52 ✗ auto t_heatingCoil = heatingCoil();
53 ✗ auto heatingCoilClone = t_heatingCoil.clone(model).cast<StraightComponent>();
54
55 ✗ baseboardConvWaterClone.setHeatingCoil(heatingCoilClone);
56
57 ✗ if (model == this->model()) {
58 ✗ if (auto plant = t_heatingCoil.plantLoop()) {
59 ✗ plant->addDemandBranchForComponent(heatingCoilClone);
60 ✗ }
61 }
62
63 ✗ return std::move(baseboardConvWaterClone);
64 ✗ }
65
66 ✗ std::vector<IdfObject> ZoneHVACBaseboardConvectiveWater_Impl::remove() {
67 ✗ if (boost::optional<CoilHeatingWaterBaseboard> waterHeatingCoil = heatingCoil().optionalCast<CoilHeatingWaterBaseboard>()) {
68 ✗ if (boost::optional<PlantLoop> plantLoop = waterHeatingCoil->plantLoop()) {
69 ✗ plantLoop->removeDemandBranchWithComponent(waterHeatingCoil.get());
70 ✗ }
71 ✗ }
72 ✗ return ZoneHVACComponent_Impl::remove();
73 }
74
75 ✗ const std::vector<std::string>& ZoneHVACBaseboardConvectiveWater_Impl::outputVariableNames() const {
76 static const std::vector<std::string> result{
77 "Baseboard Total Heating Rate", "Baseboard Total Heating Energy", "Baseboard Hot Water Energy",
78 "Baseboard Hot Water Mass Flow Rate", "Baseboard Air Mass Flow Rate", "Baseboard Air Inlet Temperature",
79 ✗ "Baseboard Air Outlet Temperature", "Baseboard Water Inlet Temperature", "Baseboard Water Outlet Temperature"};
80 ✗ return result;
81 ✗ }
82
83 ✗ IddObjectType ZoneHVACBaseboardConvectiveWater_Impl::iddObjectType() const {
84 ✗ return ZoneHVACBaseboardConvectiveWater::iddObjectType();
85 }
86
87 ✗ std::vector<ScheduleTypeKey> ZoneHVACBaseboardConvectiveWater_Impl::getScheduleTypeKeys(const Schedule& schedule) const {
88 ✗ std::vector<ScheduleTypeKey> result;
89 ✗ UnsignedVector fieldIndices = getSourceIndices(schedule.handle());
90 ✗ UnsignedVector::const_iterator b(fieldIndices.begin());
91 ✗ UnsignedVector::const_iterator e(fieldIndices.end());
92 ✗ if (std::find(b, e, OS_ZoneHVAC_Baseboard_Convective_WaterFields::AvailabilityScheduleName) != e) {
93 ✗ result.push_back(ScheduleTypeKey("ZoneHVACBaseboardConvectiveWater", "Availability"));
94 }
95 ✗ return result;
96 ✗ }
97 ✗ unsigned ZoneHVACBaseboardConvectiveWater_Impl::inletPort() const {
98 ✗ return 0; // this object has no inlet or outlet node
99 }
100
101 ✗ std::vector<ModelObject> ZoneHVACBaseboardConvectiveWater_Impl::children() const {
102 ✗ std::vector<ModelObject> result;
103 ✗ if (OptionalStraightComponent intermediate = optionalHeatingCoil()) {
104 ✗ result.push_back(*intermediate);
105 ✗ }
106 ✗ return result;
107 ✗ }
108
109 ✗ unsigned ZoneHVACBaseboardConvectiveWater_Impl::outletPort() const {
110 ✗ return 0; // this object has no inlet or outlet node
111 }
112 1 Schedule ZoneHVACBaseboardConvectiveWater_Impl::availabilitySchedule() const {
113
1/1
✓ Branch 1 taken 1 time.
1 boost::optional<Schedule> value = optionalAvailabilitySchedule();
114
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 if (!value) {
115 ✗ LOG_AND_THROW(briefDescription() << " does not have an Availability Schedule attached.");
116 }
117
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 return value.get();
118 1 }
119
120 1 StraightComponent ZoneHVACBaseboardConvectiveWater_Impl::heatingCoil() const {
121
1/1
✓ Branch 1 taken 1 time.
1 boost::optional<StraightComponent> value = optionalHeatingCoil();
122
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 if (!value) {
123 ✗ LOG_AND_THROW(briefDescription() << " does not have an Heating Coil attached.");
124 }
125
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 return value.get();
126 1 }
127
128 2 bool ZoneHVACBaseboardConvectiveWater_Impl::setAvailabilitySchedule(Schedule& schedule) {
129
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
8 bool result = setSchedule(OS_ZoneHVAC_Baseboard_Convective_WaterFields::AvailabilityScheduleName, "ZoneHVACBaseboardConvectiveWater",
130 "Availability", schedule);
131 2 return result;
132 }
133
134 2 bool ZoneHVACBaseboardConvectiveWater_Impl::setHeatingCoil(const StraightComponent& baseboardHeatingCoil) {
135
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 bool result = setPointer(OS_ZoneHVAC_Baseboard_Convective_WaterFields::HeatingCoilName, baseboardHeatingCoil.handle());
136 2 return result;
137 }
138
139 1 boost::optional<Schedule> ZoneHVACBaseboardConvectiveWater_Impl::optionalAvailabilitySchedule() const {
140
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 return getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_ZoneHVAC_Baseboard_Convective_WaterFields::AvailabilityScheduleName);
141 }
142
143 1 boost::optional<StraightComponent> ZoneHVACBaseboardConvectiveWater_Impl::optionalHeatingCoil() const {
144
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 return getObject<ModelObject>().getModelObjectTarget<StraightComponent>(OS_ZoneHVAC_Baseboard_Convective_WaterFields::HeatingCoilName);
145 }
146
147 ✗ boost::optional<ModelObject> ZoneHVACBaseboardConvectiveWater_Impl::availabilityScheduleAsModelObject() const {
148 ✗ OptionalModelObject result = availabilitySchedule();
149 ✗ return result;
150 }
151
152 ✗ boost::optional<ModelObject> ZoneHVACBaseboardConvectiveWater_Impl::heatingCoilAsModelObject() const {
153 ✗ OptionalModelObject result = heatingCoil();
154 ✗ return result;
155 }
156
157 ✗ bool ZoneHVACBaseboardConvectiveWater_Impl::setAvailabilityScheduleAsModelObject(const boost::optional<ModelObject>& modelObject) {
158 ✗ if (modelObject) {
159 ✗ OptionalSchedule intermediate = modelObject->optionalCast<Schedule>();
160 ✗ if (intermediate) {
161 ✗ Schedule schedule(*intermediate);
162 ✗ return setAvailabilitySchedule(schedule);
163 ✗ }
164 ✗ }
165 ✗ return false;
166 }
167
168 ✗ bool ZoneHVACBaseboardConvectiveWater_Impl::setHeatingCoilAsModelObject(const boost::optional<ModelObject>& modelObject) {
169 ✗ if (modelObject) {
170 ✗ OptionalStraightComponent intermediate = modelObject->optionalCast<StraightComponent>();
171 ✗ if (intermediate) {
172 ✗ StraightComponent baseboardHeatingCoil(*intermediate);
173 ✗ return setHeatingCoil(baseboardHeatingCoil);
174 ✗ }
175 ✗ }
176 ✗ return false;
177 }
178
179 6 boost::optional<ThermalZone> ZoneHVACBaseboardConvectiveWater_Impl::thermalZone() const {
180
1/1
✓ Branch 1 taken 6 times.
6 auto thisObject = this->getObject<ModelObject>();
181
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 std::vector<ThermalZone> thermalZones = this->model().getConcreteModelObjects<ThermalZone>();
182
2/2
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 3 times.
8 for (const auto& thermalZone : thermalZones) {
183
1/1
✓ Branch 1 taken 5 times.
5 std::vector<ModelObject> equipment = thermalZone.equipment();
184
185
3/3
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 2 times.
5 if (std::find(equipment.begin(), equipment.end(), thisObject) != equipment.end()) {
186
1/1
✓ Branch 1 taken 3 times.
3 return thermalZone;
187 }
188 5 }
189 3 return boost::none;
190 6 }
191
192 //reimplemented to override the base-class method in ZoneHVACComponent
193 //because this component doesn't get attached to the zone inlet and zone outlet nodes
194 1 bool ZoneHVACBaseboardConvectiveWater_Impl::addToThermalZone(ThermalZone& thermalZone) {
195
1/1
✓ Branch 1 taken 1 time.
1 Model m = this->model();
196
197
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 time.
1 if (thermalZone.model() != m) {
198 ✗ return false;
199 }
200
201
2/3
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
1 if (thermalZone.isPlenum()) {
202 ✗ return false;
203 }
204
205
1/1
✓ Branch 1 taken 1 time.
1 removeFromThermalZone();
206
207
1/1
✓ Branch 1 taken 1 time.
1 thermalZone.setUseIdealAirLoads(false);
208
209
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 thermalZone.addEquipment(this->getObject<ZoneHVACComponent>());
210
211 1 return true;
212 1 }
213
214 //reimplemented to override the base-class method in ZoneHVACComponent
215 //because this component doesn't get attached to the zone inlet and zone outlet nodes
216 //and therefore doesn't need to be removed from them when removed from the zone
217 2 void ZoneHVACBaseboardConvectiveWater_Impl::removeFromThermalZone() {
218
3/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
4 if (boost::optional<ThermalZone> thermalZone = this->thermalZone()) {
219
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 thermalZone->removeEquipment(this->getObject<ZoneHVACComponent>());
220 2 }
221 2 }
222
223 ✗ std::vector<EMSActuatorNames> ZoneHVACBaseboardConvectiveWater_Impl::emsActuatorNames() const {
224 ✗ std::vector<EMSActuatorNames> actuators{{"ZoneBaseboard:OutdoorTemperatureControlled", "Power Level"}};
225 ✗ return actuators;
226 ✗ }
227
228 ✗ std::vector<std::string> ZoneHVACBaseboardConvectiveWater_Impl::emsInternalVariableNames() const {
229 ✗ std::vector<std::string> types{"Simple Zone Baseboard Capacity At Low Temperature", "Simple Zone Baseboard Capacity At High Temperature"};
230 ✗ return types;
231 ✗ }
232
233 ✗ ComponentType ZoneHVACBaseboardConvectiveWater_Impl::componentType() const {
234 ✗ return ComponentType::Heating;
235 }
236
237 ✗ std::vector<FuelType> ZoneHVACBaseboardConvectiveWater_Impl::coolingFuelTypes() const {
238 ✗ return {};
239 }
240
241 ✗ std::vector<FuelType> ZoneHVACBaseboardConvectiveWater_Impl::heatingFuelTypes() const {
242 ✗ return heatingCoil().heatingFuelTypes();
243 }
244
245 ✗ std::vector<AppGFuelType> ZoneHVACBaseboardConvectiveWater_Impl::appGHeatingFuelTypes() const {
246 ✗ return heatingCoil().appGHeatingFuelTypes();
247 }
248
249 } // namespace detail
250
251 1 ZoneHVACBaseboardConvectiveWater::ZoneHVACBaseboardConvectiveWater(const Model& model, Schedule& availabilitySchedule,
252 1 StraightComponent& heatingCoilBaseboard)
253 1 : ZoneHVACComponent(ZoneHVACBaseboardConvectiveWater::iddObjectType(), model) {
254
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 1 time.
✗ Branch 5 not taken.
1 OS_ASSERT(getImpl<detail::ZoneHVACBaseboardConvectiveWater_Impl>());
255
256 // OS_ZoneHVAC_Baseboard_Convective_WaterFields::AvailabilityScheduleName
257 // OS_ZoneHVAC_Baseboard_Convective_WaterFields::HeatingCoilName
258
1/1
✓ Branch 1 taken 1 time.
1 bool ok = setAvailabilitySchedule(availabilitySchedule);
259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 if (!ok) {
260 ✗ remove();
261 ✗ LOG_AND_THROW("Unable to set " << briefDescription() << "'s availability schedule to " << availabilitySchedule.briefDescription() << ".");
262 }
263
1/1
✓ Branch 1 taken 1 time.
1 ok = setHeatingCoil(heatingCoilBaseboard);
264
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
1 OS_ASSERT(ok);
265 1 }
266
267 7730 IddObjectType ZoneHVACBaseboardConvectiveWater::iddObjectType() {
268
1/1
✓ Branch 1 taken 7730 times.
7730 return {IddObjectType::OS_ZoneHVAC_Baseboard_Convective_Water};
269 }
270
271 1 Schedule ZoneHVACBaseboardConvectiveWater::availabilitySchedule() const {
272
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::ZoneHVACBaseboardConvectiveWater_Impl>()->availabilitySchedule();
273 }
274
275 1 StraightComponent ZoneHVACBaseboardConvectiveWater::heatingCoil() const {
276
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::ZoneHVACBaseboardConvectiveWater_Impl>()->heatingCoil();
277 }
278
279 2 bool ZoneHVACBaseboardConvectiveWater::setAvailabilitySchedule(Schedule& schedule) {
280
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::ZoneHVACBaseboardConvectiveWater_Impl>()->setAvailabilitySchedule(schedule);
281 }
282
283 2 bool ZoneHVACBaseboardConvectiveWater::setHeatingCoil(const StraightComponent& baseboardHeatingCoil) {
284
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::ZoneHVACBaseboardConvectiveWater_Impl>()->setHeatingCoil(baseboardHeatingCoil);
285 }
286 4 boost::optional<ThermalZone> ZoneHVACBaseboardConvectiveWater::thermalZone() const {
287
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::ZoneHVACBaseboardConvectiveWater_Impl>()->thermalZone();
288 }
289
290 1 bool ZoneHVACBaseboardConvectiveWater::addToThermalZone(ThermalZone& thermalZone) {
291
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::ZoneHVACBaseboardConvectiveWater_Impl>()->addToThermalZone(thermalZone);
292 }
293
294 1 void ZoneHVACBaseboardConvectiveWater::removeFromThermalZone() {
295
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::ZoneHVACBaseboardConvectiveWater_Impl>()->removeFromThermalZone();
296 }
297 /// @cond
298 ✗ ZoneHVACBaseboardConvectiveWater::ZoneHVACBaseboardConvectiveWater(std::shared_ptr<detail::ZoneHVACBaseboardConvectiveWater_Impl> impl)
299 ✗ : ZoneHVACComponent(std::move(impl)) {}
300 /// @endcond
301
302 } // namespace model
303 } // namespace openstudio
304