Skip to content

Commit

Permalink
#4786 - EMS: Change the last optional field to Zone or Space Name, st…
Browse files Browse the repository at this point in the history
…ore a Space or a ThermalZone in it.
  • Loading branch information
jmarrec committed Mar 15, 2023
1 parent 99e001d commit d76d8c2
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 56 deletions.
9 changes: 7 additions & 2 deletions resources/model/OpenStudio.idd
Original file line number Diff line number Diff line change
Expand Up @@ -36395,9 +36395,14 @@ OS:EnergyManagementSystem:Actuator,
A5, \field Actuated Component Control Type
\required-field
\type alpha
A6; \field Zone Name
A6; \field Zone or Space Name
\note This field is useful for a SpaceLoadInstance that is assigned to a SpaceType
\note because internally E+ will duplicate the instances and you need to access the final name
\note If you are using the Space Translation of the ForwardTranslator (which is defaulted on) this should be set to a Space
\note If not then use a ThermalZone
\type object-list
\object-list AllObjects
\object-list SpaceNames
\object-list ThermalZoneNames

OS:EnergyManagementSystem:ProgramCallingManager,
\extensible:1 - repeat last field, remembering to remove ; from "inner" fields.
Expand Down
100 changes: 59 additions & 41 deletions src/model/EnergyManagementSystemActuator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,6 @@ namespace model {
return result;
}

boost::optional<ModelObject> EnergyManagementSystemActuator_Impl::zoneName() const {
boost::optional<ModelObject> result;
boost::optional<WorkspaceObject> wo = this->getTarget(OS_EnergyManagementSystem_ActuatorFields::ZoneName);
if (wo) {
result = wo->cast<ModelObject>();
}
return result;
}

std::string EnergyManagementSystemActuator_Impl::actuatedComponentControlType() const {
boost::optional<std::string> value = getString(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, true);
if (value) {
Expand All @@ -111,33 +102,38 @@ namespace model {
return setPointer(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentName, modelObject.handle());
}

bool EnergyManagementSystemActuator_Impl::setThermalZone(const ThermalZone& thermalZone) {
return setPointer(OS_EnergyManagementSystem_ActuatorFields::ZoneName, thermalZone.handle());
}

bool EnergyManagementSystemActuator_Impl::setSpace(const Space& space) {
//boost::optional<ThermalZone> tz;
auto tz = space.thermalZone();
if (tz) {
return setPointer(OS_EnergyManagementSystem_ActuatorFields::ZoneName, tz.get().handle());
} else {
LOG(Warn, "Warning, Space object" << space.briefDescription() << " does not have a ThermalZone object.")
return false;
}
}

bool EnergyManagementSystemActuator_Impl::setActuatedComponentControlType(const std::string& actuatedComponentControlType) {
bool result = setString(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, actuatedComponentControlType);
const bool result = setString(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, actuatedComponentControlType);
return result;
}

bool EnergyManagementSystemActuator_Impl::setActuatedComponentType(const std::string& actuatedComponentType) {
bool result = setString(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentType, actuatedComponentType);
const bool result = setString(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentType, actuatedComponentType);
return result;
}

void EnergyManagementSystemActuator_Impl::resetZoneName() {
bool result = setString(OS_EnergyManagementSystem_ActuatorFields::ZoneName, "");
boost::optional<ModelObject> EnergyManagementSystemActuator_Impl::zoneOrSpace() const {
return getObject<ModelObject>().getModelObjectTarget<ModelObject>(OS_EnergyManagementSystem_ActuatorFields::ZoneorSpaceName);
}

boost::optional<ThermalZone> EnergyManagementSystemActuator_Impl::thermalZone() const {
return getObject<ModelObject>().getModelObjectTarget<ThermalZone>(OS_EnergyManagementSystem_ActuatorFields::ZoneorSpaceName);
}

boost::optional<Space> EnergyManagementSystemActuator_Impl::space() const {
return getObject<ModelObject>().getModelObjectTarget<Space>(OS_EnergyManagementSystem_ActuatorFields::ZoneorSpaceName);
}

bool EnergyManagementSystemActuator_Impl::setThermalZone(const ThermalZone& thermalZone) {
return setPointer(OS_EnergyManagementSystem_ActuatorFields::ZoneorSpaceName, thermalZone.handle());
}

bool EnergyManagementSystemActuator_Impl::setSpace(const Space& space) {
return setPointer(OS_EnergyManagementSystem_ActuatorFields::ZoneorSpaceName, space.handle());
}

void EnergyManagementSystemActuator_Impl::resetZoneOrSpace() {
const bool result = setString(OS_EnergyManagementSystem_ActuatorFields::ZoneorSpaceName, "");
OS_ASSERT(result);
}

Expand Down Expand Up @@ -254,10 +250,6 @@ namespace model {
return getImpl<detail::EnergyManagementSystemActuator_Impl>()->actuatedComponent();
}

boost::optional<ModelObject> EnergyManagementSystemActuator::zoneName() const {
return getImpl<detail::EnergyManagementSystemActuator_Impl>()->zoneName();
}

std::string EnergyManagementSystemActuator::actuatedComponentControlType() const {
return getImpl<detail::EnergyManagementSystemActuator_Impl>()->actuatedComponentControlType();
}
Expand All @@ -270,6 +262,26 @@ namespace model {
return getImpl<detail::EnergyManagementSystemActuator_Impl>()->setActuatedComponent(modelObject);
}

bool EnergyManagementSystemActuator::setActuatedComponentControlType(const std::string& actuatedComponentControlType) {
return getImpl<detail::EnergyManagementSystemActuator_Impl>()->setActuatedComponentControlType(actuatedComponentControlType);
}

bool EnergyManagementSystemActuator::setActuatedComponentType(const std::string& actuatedComponentType) {
return getImpl<detail::EnergyManagementSystemActuator_Impl>()->setActuatedComponentType(actuatedComponentType);
}

boost::optional<Space> EnergyManagementSystemActuator::space() const {
return getImpl<detail::EnergyManagementSystemActuator_Impl>()->space();
}

boost::optional<ThermalZone> EnergyManagementSystemActuator::thermalZone() const {
return getImpl<detail::EnergyManagementSystemActuator_Impl>()->thermalZone();
}

boost::optional<ModelObject> EnergyManagementSystemActuator::zoneOrSpace() const {
return getImpl<detail::EnergyManagementSystemActuator_Impl>()->zoneOrSpace();
}

bool EnergyManagementSystemActuator::setThermalZone(const ThermalZone& thermalZone) {
return getImpl<detail::EnergyManagementSystemActuator_Impl>()->setThermalZone(thermalZone);
}
Expand All @@ -278,21 +290,27 @@ namespace model {
return getImpl<detail::EnergyManagementSystemActuator_Impl>()->setSpace(space);
}

bool EnergyManagementSystemActuator::setActuatedComponentControlType(const std::string& actuatedComponentControlType) {
return getImpl<detail::EnergyManagementSystemActuator_Impl>()->setActuatedComponentControlType(actuatedComponentControlType);
void EnergyManagementSystemActuator::resetZoneOrSpace() {
getImpl<detail::EnergyManagementSystemActuator_Impl>()->resetZoneOrSpace();
}

bool EnergyManagementSystemActuator::setActuatedComponentType(const std::string& actuatedComponentType) {
return getImpl<detail::EnergyManagementSystemActuator_Impl>()->setActuatedComponentType(actuatedComponentType);
/// @cond
EnergyManagementSystemActuator::EnergyManagementSystemActuator(std::shared_ptr<detail::EnergyManagementSystemActuator_Impl> impl)
: ModelObject(std::move(impl)) {}

// DEPRECATED

boost::optional<ModelObject> EnergyManagementSystemActuator::zoneName() const {
LOG(Warn, "As of 3.6.0, EnergyManagementSystemActuator::zoneName is deprecated. Use zoneOrSpace instead. "
"It will be removed within three releases.");
return getImpl<detail::EnergyManagementSystemActuator_Impl>()->zoneOrSpace();
}

void EnergyManagementSystemActuator::resetZoneName() {
getImpl<detail::EnergyManagementSystemActuator_Impl>()->resetZoneName();
LOG(Warn, "As of 3.6.0, EnergyManagementSystemActuator::resetZoneName is deprecated. Use resetZoneOrSpace instead. "
"It will be removed within three releases.");
getImpl<detail::EnergyManagementSystemActuator_Impl>()->resetZoneOrSpace();
}

/// @cond
EnergyManagementSystemActuator::EnergyManagementSystemActuator(std::shared_ptr<detail::EnergyManagementSystemActuator_Impl> impl)
: ModelObject(std::move(impl)) {}
/// @endcond

} // namespace model
Expand Down
28 changes: 19 additions & 9 deletions src/model/EnergyManagementSystemActuator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include "ModelAPI.hpp"
#include "ModelObject.hpp"

#include "../utilities/core/Deprecated.hpp"

namespace openstudio {

namespace energyplus {
Expand Down Expand Up @@ -63,11 +65,12 @@ namespace model {
* Upon translation, the SpaceLoadInstances use ZoneLists which are not avail in OS
* The ZoneListName is the SpaceType name
* The Zone's are the Space->ThermalZone names
* So to attach to a future zone, use the TZ or the Space that the SpaceLoadInstance will operate on
**/
* So to attach to a future zone, use the TZ or the Space that the SpaceLoadInstance will operate on **/
// TODO: the first parameter should be a SpaceLoadInstance, not a ModelObject
explicit EnergyManagementSystemActuator(const ModelObject& modelObject, const std::string& actuatedComponentType,
const std::string& actuatedComponentControlType, const ThermalZone& thermalZone);

// TODO: the first parameter should be a SpaceLoadInstance, not a ModelObject
explicit EnergyManagementSystemActuator(const ModelObject& modelObject, const std::string& actuatedComponentType,
const std::string& actuatedComponentControlType, const Space& space);

Expand All @@ -85,13 +88,17 @@ namespace model {
/** @name Getters */
//@{

boost::optional<ModelObject> actuatedComponent() const;
boost::optional<ModelObject> actuatedComponent() const; // TODO: this should NOT be an optional

std::string actuatedComponentControlType() const;

std::string actuatedComponentType() const;

boost::optional<ModelObject> zoneName() const;
OS_DEPRECATED boost::optional<ModelObject> zoneName() const;

boost::optional<ModelObject> zoneOrSpace() const;
boost::optional<ThermalZone> thermalZone() const;
boost::optional<Space> space() const;

//@}
/** @name Setters */
Expand All @@ -107,7 +114,8 @@ namespace model {
//set the ZoneName field to the Space's ThermalZone's name
bool setSpace(const Space& space);

void resetZoneName();
OS_DEPRECATED void resetZoneName();
void resetZoneOrSpace();

//@}
/** @name Other */
Expand All @@ -124,14 +132,16 @@ namespace model {
friend class Model;
friend class IdfObject;
friend class openstudio::detail::IdfObject_Impl;

// These are for the ReverseTranslator
explicit EnergyManagementSystemActuator(const ModelObject& modelObject);

explicit EnergyManagementSystemActuator(const Model& model);

friend class energyplus::ReverseTranslator;
/// @endcond
private:
REGISTER_LOGGER("openstudio.model.EnergyManagementSystemActuator");
//These are for the ReveseTranslator
explicit EnergyManagementSystemActuator(const ModelObject& modelObject);

explicit EnergyManagementSystemActuator(const Model& model);
};

/** \relates EnergyManagementSystemActuator*/
Expand Down
8 changes: 4 additions & 4 deletions src/model/EnergyManagementSystemActuator_Impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ namespace model {

std::string actuatedComponentType() const;

boost::optional<ModelObject> zoneName() const;
boost::optional<ModelObject> zoneOrSpace() const;
boost::optional<ThermalZone> thermalZone() const;
boost::optional<Space> space() const;

//@}
/** @name Setters */
Expand All @@ -87,10 +89,8 @@ namespace model {
bool setActuatedComponentType(const std::string& actuatedComponentType);

bool setThermalZone(const ThermalZone& thermalZone);

bool setSpace(const Space& space);

void resetZoneName();
void resetZoneOrSpace();

//@}
/** @name Other */
Expand Down

0 comments on commit d76d8c2

Please sign in to comment.