Skip to content

Commit

Permalink
Add ZoneHVACEvaporativeCoolerUnit to all evaporative cooler component…
Browse files Browse the repository at this point in the history
… models `containingZoneHVACComponent`

cf #5326 (comment)
  • Loading branch information
jmarrec committed Jan 9, 2025
1 parent 3d15a25 commit 25ff3d2
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/model/EvaporativeCoolerDirectResearchSpecial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#include "Curve_Impl.hpp"
#include "Model.hpp"

// containing ZoneHVAC Component
#include "ZoneHVACEvaporativeCoolerUnit.hpp"
#include "ZoneHVACEvaporativeCoolerUnit_Impl.hpp"

#include "../utilities/core/Assert.hpp"
#include "../utilities/core/Compare.hpp"
#include "../utilities/data/DataEnums.hpp"
Expand Down Expand Up @@ -126,6 +130,28 @@ namespace model {
return value.get();
}

boost::optional<ZoneHVACComponent> EvaporativeCoolerDirectResearchSpecial_Impl::containingZoneHVACComponent() const {

std::vector<ZoneHVACComponent> zoneHVACComponent = this->model().getModelObjects<ZoneHVACComponent>();
for (const auto& elem : zoneHVACComponent) {
switch (elem.iddObject().type().value()) {
case openstudio::IddObjectType::OS_ZoneHVAC_EvaporativeCoolerUnit: {
auto component = elem.cast<ZoneHVACEvaporativeCoolerUnit>();
if (component.firstEvaporativeCooler().handle() == this->handle()) {
return elem;
}
// I guess it's fine since this is optional anyways
// } else if (auto comp_ = component.secondEvaporativeCooler(); comp_ && comp_->handle() == this->handle()) { return elem; }
break;
}
default: {
break;
}
}
}
return boost::none;
}

bool EvaporativeCoolerDirectResearchSpecial_Impl::setAvailabilitySchedule(Schedule& schedule) {
bool result = setSchedule(OS_EvaporativeCooler_Direct_ResearchSpecialFields::AvailabilityScheduleName, "EvaporativeCoolerDirectResearchSpecial",
"Availability", schedule);
Expand Down
2 changes: 2 additions & 0 deletions src/model/EvaporativeCoolerDirectResearchSpecial_Impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ namespace model {
boost::optional<ModelObject> availabilityScheduleAsModelObject() const;

bool setAvailabilityScheduleAsModelObject(const boost::optional<ModelObject>& modelObject);

virtual boost::optional<ZoneHVACComponent> containingZoneHVACComponent() const override;
};

} // namespace detail
Expand Down
27 changes: 27 additions & 0 deletions src/model/EvaporativeCoolerIndirectResearchSpecial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@
#include "EvaporativeCoolerIndirectResearchSpecial_Impl.hpp"
#include "Schedule.hpp"
#include "Schedule_Impl.hpp"
#include "Model.hpp"
#include "Node.hpp"
#include "Node_Impl.hpp"
#include "Curve.hpp"
#include "Curve_Impl.hpp"
#include "ScheduleTypeLimits.hpp"
#include "ScheduleTypeRegistry.hpp"

// containing ZoneHVAC Component
#include "ZoneHVACEvaporativeCoolerUnit.hpp"
#include "ZoneHVACEvaporativeCoolerUnit_Impl.hpp"

#include "../utilities/core/Assert.hpp"
#include "../utilities/data/DataEnums.hpp"

Expand Down Expand Up @@ -261,6 +266,28 @@ namespace model {
return false;
}

boost::optional<ZoneHVACComponent> EvaporativeCoolerIndirectResearchSpecial_Impl::containingZoneHVACComponent() const {

std::vector<ZoneHVACComponent> zoneHVACComponent = this->model().getModelObjects<ZoneHVACComponent>();
for (const auto& elem : zoneHVACComponent) {
switch (elem.iddObject().type().value()) {
case openstudio::IddObjectType::OS_ZoneHVAC_EvaporativeCoolerUnit: {
auto component = elem.cast<ZoneHVACEvaporativeCoolerUnit>();
if (component.firstEvaporativeCooler().handle() == this->handle()) {
return elem;
}
// I guess it's fine since this is optional anyways
// } else if (auto comp_ = component.secondEvaporativeCooler(); comp_ && comp_->handle() == this->handle()) { return elem; }
break;
}
default: {
break;
}
}
}
return boost::none;
}

bool EvaporativeCoolerIndirectResearchSpecial_Impl::setReliefAirInletNode(const Node& node) {
return setPointer(OS_EvaporativeCooler_Indirect_ResearchSpecialFields::ReliefAirInletNode, node.handle());
}
Expand Down
2 changes: 2 additions & 0 deletions src/model/EvaporativeCoolerIndirectResearchSpecial_Impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ namespace model {
protected:
private:
REGISTER_LOGGER("openstudio.model.EvaporativeCoolerIndirectResearchSpecial");

virtual boost::optional<ZoneHVACComponent> containingZoneHVACComponent() const override;
};

} // namespace detail
Expand Down

0 comments on commit 25ff3d2

Please sign in to comment.