Skip to content

Commit

Permalink
First pass model files cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-robertson committed Jan 16, 2025
1 parent 0156822 commit 5b956bf
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 349 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,10 @@

#include "../ForwardTranslator.hpp"
#include "../../model/Model.hpp"

#include "../../model/AirLoopHVACExhaustSystem.hpp"

// TODO: Check the following class names against object getters and setters.
#include "../../model/ZoneMixers.hpp"
#include "../../model/ZoneMixers_Impl.hpp"

#include "../../model/FansSystemModel.hpp"
#include "../../model/FansSystemModel_Impl.hpp"
#include "../../model/AirLoopHVACExhaustSystem_Impl.hpp"
#include "../../model/HVACComponent.hpp"
#include "../../model/HVACComponent_Impl.hpp"

#include <utilities/idd/AirLoopHVAC_ExhaustSystem_FieldEnums.hxx>
#include <utilities/idd/IddEnums.hxx>
Expand All @@ -52,31 +47,13 @@ namespace energyplus {

// Instantiate an IdfObject of the class to store the values
IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::AirLoopHVAC_ExhaustSystem, modelObject);
// If it doesn't have a name, or if you aren't sure you are going to want to return it
// IdfObject idfObject(openstudio::IddObjectType::AirLoopHVAC_ExhaustSystem);
// m_idfObjects.push_back(idfObject);

// TODO: Note JM 2018-10-17
// You are responsible for implementing any additional logic based on choice fields, etc.
// The ForwardTranslator generator script is meant to facilitate your work, not get you 100% of the way

// TODO: If you keep createRegisterAndNameIdfObject above, you don't need this.
// But in some cases, you'll want to handle failure without pushing to the map
// Name
idfObject.setName(modelObject.nameString());

// Zone Mixer Name: Required Object
ZoneMixers zoneMixer = modelObject.zoneMixer();
if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(zoneMixer)) {
idfObject.setString(AirLoopHVAC_ExhaustSystemFields::ZoneMixerName, wo_->nameString());
}

// Fan Object Type: Required String
const std::string fanObjectType = modelObject.fanObjectType();
idfObject.setString(AirLoopHVAC_ExhaustSystemFields::FanObjectType, fanObjectType);

// Fan Name: Required Object
FansSystemModel fan = modelObject.fan();
HVACComponent fan = modelObject.fan();
if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(fan)) {
idfObject.setString(AirLoopHVAC_ExhaustSystemFields::FanName, wo_->nameString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,12 @@

#include "../ForwardTranslator.hpp"
#include "../../model/Model.hpp"

#include "../../model/ZoneHVACExhaustControl.hpp"

// TODO: Check the following class names against object getters and setters.
#include "../../model/ZoneHVACExhaustControl_Impl.hpp"
#include "../../model/Schedule.hpp"
#include "../../model/Schedule_Impl.hpp"

#include "../../model/Zone.hpp"
#include "../../model/Zone_Impl.hpp"

#include "../../model/ThermalZone.hpp"
#include "../../model/ThermalZone_Impl.hpp"
#include "../../model/Node.hpp"
#include "../../model/Node_Impl.hpp"

Expand All @@ -55,42 +51,27 @@ namespace energyplus {

// Instantiate an IdfObject of the class to store the values
IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::ZoneHVAC_ExhaustControl, modelObject);
// If it doesn't have a name, or if you aren't sure you are going to want to return it
// IdfObject idfObject(openstudio::IddObjectType::ZoneHVAC_ExhaustControl);
// m_idfObjects.push_back(idfObject);

// TODO: Note JM 2018-10-17
// You are responsible for implementing any additional logic based on choice fields, etc.
// The ForwardTranslator generator script is meant to facilitate your work, not get you 100% of the way

// TODO: If you keep createRegisterAndNameIdfObject above, you don't need this.
// But in some cases, you'll want to handle failure without pushing to the map
// Name
idfObject.setName(modelObject.nameString());

// Availability Schedule Name: Optional Object
if (boost::optional<Schedule> availabilitySchedule_ = modelObject.availabilitySchedule()) {
if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(availabilitySchedule_.get())) {
idfObject.setString(ZoneHVAC_ExhaustControlFields::AvailabilityScheduleName, wo_->nameString());
}

// Availability Schedule Name: Required Object
Schedule availabilitySchedule_ = modelObject.availabilitySchedule();
if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(availabilitySchedule_)) {
idfObject.setString(ZoneHVAC_ExhaustControlFields::AvailabilityScheduleName, wo_->nameString());
}

// Zone Name: Required Object
Zone zone = modelObject.zone();
if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(zone)) {
ThermalZone thermalZone = modelObject.thermalZone();
if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(thermalZone)) {
idfObject.setString(ZoneHVAC_ExhaustControlFields::ZoneName, wo_->nameString());
}

// Inlet Node Name: Required Node
Node inletNodeName = modelObject.inletNodeName();
if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(inletNodeName)) {
idfObject.setString(ZoneHVAC_ExhaustControlFields::InletNodeName, wo_->nameString());
// InletNodeName
if (auto node = modelObject.inletNode()) {
idfObject.setString(ZoneHVAC_ExhaustControlFields::InletNodeName, node->name().get());
}

// Outlet Node Name: Required Node
Node outletNodeName = modelObject.outletNodeName();
if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(outletNodeName)) {
idfObject.setString(ZoneHVAC_ExhaustControlFields::OutletNodeName, wo_->nameString());
// OutletNodeName
if (auto node = modelObject.outletNode()) {
idfObject.setString(ZoneHVAC_ExhaustControlFields::OutletNodeName, node->name().get());
}

if (modelObject.isDesignExhaustFlowRateAutosized()) {
Expand All @@ -113,12 +94,6 @@ namespace energyplus {
}
}

// Supply Node or NodeList Name: Optional Node
Node supplyNodeorNodeListName = modelObject.supplyNodeorNodeListName();
if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(supplyNodeorNodeListName)) {
idfObject.setString(ZoneHVAC_ExhaustControlFields::SupplyNodeorNodeListName, wo_->nameString());
}

// Minimum Zone Temperature Limit Schedule Name: Optional Object
if (boost::optional<Schedule> minimumZoneTemperatureLimitSchedule_ = modelObject.minimumZoneTemperatureLimitSchedule()) {
if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(minimumZoneTemperatureLimitSchedule_.get())) {
Expand Down
63 changes: 14 additions & 49 deletions src/model/AirLoopHVACExhaustSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@
#include "AirLoopHVACExhaustSystem.hpp"
#include "AirLoopHVACExhaustSystem_Impl.hpp"

// TODO: Check the following class names against object getters and setters.
#include "ZoneMixers.hpp"
#include "ZoneMixers_Impl.hpp"
#include "FansSystemModel.hpp"
#include "FansSystemModel_Impl.hpp"
#include "Model.hpp"
#include "Model_Impl.hpp"
#include "HVACComponent.hpp"
#include "HVACComponent_Impl.hpp"

#include "../utilities/core/Assert.hpp"
#include "../utilities/data/DataEnums.hpp"
Expand Down Expand Up @@ -73,73 +72,47 @@ namespace model {
}

ComponentType AirLoopHVACExhaustSystem_Impl::componentType() const {
// TODO
return ComponentType::None;
}

std::vector<FuelType> AirLoopHVACExhaustSystem_Impl::coolingFuelTypes() const {
// TODO
return {};
}

std::vector<FuelType> AirLoopHVACExhaustSystem_Impl::heatingFuelTypes() const {
// TODO
return {};
}

std::vector<AppGFuelType> AirLoopHVACExhaustSystem_Impl::appGHeatingFuelTypes() const {

// TODO
return {};
}

ZoneMixers AirLoopHVACExhaustSystem_Impl::zoneMixer() const {
boost::optional<ZoneMixers> value = optionalZoneMixer();
if (!value) {
LOG_AND_THROW(briefDescription() << " does not have an Zone Mixer attached.");
}
return value.get();
}

FansSystemModel AirLoopHVACExhaustSystem_Impl::fan() const {
boost::optional<FansSystemModel> value = optionalFan();
HVACComponent AirLoopHVACExhaustSystem_Impl::fan() const {
boost::optional<HVACComponent> value = optionalFan();
if (!value) {
LOG_AND_THROW(briefDescription() << " does not have an Fan attached.");
}
return value.get();
}

bool AirLoopHVACExhaustSystem_Impl::setZoneMixer(const ZoneMixers& zoneMixers) {
const bool result = setPointer(OS_AirLoopHVAC_ExhaustSystemFields::ZoneMixerName, zoneMixers.handle());
return result;
}

bool AirLoopHVACExhaustSystem_Impl::setFan(const FansSystemModel& fansSystemModel) {
const bool result = setPointer(OS_AirLoopHVAC_ExhaustSystemFields::FanName, fansSystemModel.handle());
bool AirLoopHVACExhaustSystem_Impl::setFan(const HVACComponent& fan) {
const bool result = setPointer(OS_AirLoopHVAC_ExhaustSystemFields::FanName, fan.handle());
return result;
}

boost::optional<ZoneMixers> AirLoopHVACExhaustSystem_Impl::optionalZoneMixer() const {
return getObject<ModelObject>().getModelObjectTarget<ZoneMixers>(OS_AirLoopHVAC_ExhaustSystemFields::ZoneMixerName);
}

boost::optional<FansSystemModel> AirLoopHVACExhaustSystem_Impl::optionalFan() const {
return getObject<ModelObject>().getModelObjectTarget<FansSystemModel>(OS_AirLoopHVAC_ExhaustSystemFields::FanName);
boost::optional<HVACComponent> AirLoopHVACExhaustSystem_Impl::optionalFan() const {
return getObject<ModelObject>().getModelObjectTarget<HVACComponent>(OS_AirLoopHVAC_ExhaustSystemFields::FanName);
}

} // namespace detail

AirLoopHVACExhaustSystem::AirLoopHVACExhaustSystem(const Model& model) : StraightComponent(AirLoopHVACExhaustSystem::iddObjectType(), model) {
OS_ASSERT(getImpl<detail::AirLoopHVACExhaustSystem_Impl>());

// TODO: consider adding (overloaded or not) explicit ctors taking required objects as argument

// TODO: Appropriately handle the following required object-list fields.
// OS_AirLoopHVAC_ExhaustSystemFields::ZoneMixerName
// OS_AirLoopHVAC_ExhaustSystemFields::FanName
bool ok = true;
// ok = setZoneMixer();
OS_ASSERT(ok);

// ok = setFan();
OS_ASSERT(ok);
}
Expand All @@ -148,20 +121,12 @@ namespace model {
return {IddObjectType::OS_AirLoopHVAC_ExhaustSystem};
}

ZoneMixers AirLoopHVACExhaustSystem::zoneMixer() const {
return getImpl<detail::AirLoopHVACExhaustSystem_Impl>()->zoneMixer();
}

FansSystemModel AirLoopHVACExhaustSystem::fan() const {
HVACComponent AirLoopHVACExhaustSystem::fan() const {
return getImpl<detail::AirLoopHVACExhaustSystem_Impl>()->fan();
}

bool AirLoopHVACExhaustSystem::setZoneMixer(const ZoneMixers& zoneMixers) {
return getImpl<detail::AirLoopHVACExhaustSystem_Impl>()->setZoneMixer(zoneMixers);
}

bool AirLoopHVACExhaustSystem::setFan(const FansSystemModel& fansSystemModel) {
return getImpl<detail::AirLoopHVACExhaustSystem_Impl>()->setFan(fansSystemModel);
bool AirLoopHVACExhaustSystem::setFan(const HVACComponent& fan) {
return getImpl<detail::AirLoopHVACExhaustSystem_Impl>()->setFan(fan);
}

/// @cond
Expand Down
16 changes: 3 additions & 13 deletions src/model/AirLoopHVACExhaustSystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
namespace openstudio {
namespace model {

// TODO: Check the following class names against object getters and setters.
class ZoneMixers;
class FansSystemModel;
class HVACComponent;

namespace detail {

Expand Down Expand Up @@ -69,21 +67,13 @@ namespace model {
/** @name Getters */
//@{

// TODO: Check return type. From object lists, some candidates are: ZoneMixers.
ZoneMixers zoneMixer() const;

// TODO: Check return type. From object lists, some candidates are: FansSystemModel, FansComponentModel.
FansSystemModel fan() const;
HVACComponent fan() const;

//@}
/** @name Setters */
//@{

// TODO: Check argument type. From object lists, some candidates are: ZoneMixers.
bool setZoneMixer(const ZoneMixers& zoneMixers);

// TODO: Check argument type. From object lists, some candidates are: FansSystemModel, FansComponentModel.
bool setFan(const FansSystemModel& fansSystemModel);
bool setFan(const HVACComponent& fan);

//@}
/** @name Other */
Expand Down
23 changes: 4 additions & 19 deletions src/model/AirLoopHVACExhaustSystem_Impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
namespace openstudio {
namespace model {

// TODO: Check the following class names against object getters and setters.
class ZoneMixers;
class FansSystemModel;
class HVACComponent;

namespace detail {

Expand Down Expand Up @@ -74,21 +72,13 @@ namespace model {
/** @name Getters */
//@{

// TODO: Check return type. From object lists, some candidates are: ZoneMixers.
ZoneMixers zoneMixer() const;

// TODO: Check return type. From object lists, some candidates are: FansSystemModel, FansComponentModel.
FansSystemModel fan() const;
HVACComponent fan() const;

//@}
/** @name Setters */
//@{

// TODO: Check argument type. From object lists, some candidates are: ZoneMixers.
bool setZoneMixer(const ZoneMixers& zoneMixers);

// TODO: Check argument type. From object lists, some candidates are: FansSystemModel, FansComponentModel.
bool setFan(const FansSystemModel& fansSystemModel);
bool setFan(const HVACComponent& fan);

//@}
/** @name Other */
Expand All @@ -99,12 +89,7 @@ namespace model {
private:
REGISTER_LOGGER("openstudio.model.AirLoopHVACExhaustSystem");

// TODO: Check the return types of these methods.
// Optional getters for use by methods like children() so can remove() if the constructor fails.
// There are other ways for the public versions of these getters to fail--perhaps all required
// objects should be returned as boost::optionals
boost::optional<ZoneMixers> optionalZoneMixer() const;
boost::optional<FansSystemModel> optionalFan() const;
boost::optional<HVACComponent> optionalFan() const;
};

} // namespace detail
Expand Down
Loading

0 comments on commit 5b956bf

Please sign in to comment.