diff --git a/.github/workflows/buildCSharp.yml b/.github/workflows/buildCSharp.yml index 67bd5d7d547..ffaeafc2ad7 100644 --- a/.github/workflows/buildCSharp.yml +++ b/.github/workflows/buildCSharp.yml @@ -23,9 +23,9 @@ jobs: name: [Ubuntu, macOS, macOS_arm64, Windows64, Windows32] include: - name: Ubuntu - os: ubuntu-20.04 + os: ubuntu-22.04 - name: macOS - os: macos-11 + os: macos-13 - name: macOS_arm64 os: macos-14 - name: Windows64 diff --git a/ProjectMacros.cmake b/ProjectMacros.cmake index cf944fa06a2..3ca827748ed 100644 --- a/ProjectMacros.cmake +++ b/ProjectMacros.cmake @@ -532,6 +532,7 @@ macro(MAKE_SWIG_TARGET NAME SIMPLENAME KEY_I_FILE I_FILES PARENT_TARGET PARENT_S set( model_names OpenStudioMeasure + OpenStudioAlfalfa OpenStudioModel OpenStudioModelAirflow OpenStudioModelAvailabilityManager diff --git a/csharp/CMakeLists.txt b/csharp/CMakeLists.txt index 995b65987ff..4bffd5e51ac 100644 --- a/csharp/CMakeLists.txt +++ b/csharp/CMakeLists.txt @@ -83,6 +83,7 @@ set(translator_wrappers set(model_wrappers csharp_OpenStudioMeasure_wrap.cxx + csharp_OpenStudioAlfalfa_wrap.cxx csharp_OpenStudioModel_wrap.cxx csharp_OpenStudioModelAirflow_wrap.cxx csharp_OpenStudioModelAvailabilityManager_wrap.cxx diff --git a/src/alfalfa/Alfalfa.i b/src/alfalfa/Alfalfa.i index 1c3956b2b5b..ebe639c05a7 100644 --- a/src/alfalfa/Alfalfa.i +++ b/src/alfalfa/Alfalfa.i @@ -6,6 +6,8 @@ #endif %include +#define ALFALFA_API + %include %import %import @@ -13,7 +15,6 @@ %ignore openstudio::alfalfa::detail; %{ - #include #include #include #include @@ -33,15 +34,14 @@ using namespace openstudio::alfalfa; %} -%ignore openstudio::alfalfa::ComponentBase; +%ignore openstudio::alfalfa::AlfalfaComponentBase; %ignore openstudio::alfalfa::AlfalfaActuator::clone; %ignore openstudio::alfalfa::AlfalfaConstant::clone; %ignore openstudio::alfalfa::AlfalfaMeter::clone; %ignore openstudio::alfalfa::AlfalfaGlobalVariable::clone; %ignore openstudio::alfalfa::AlfalfaOutputVariable::clone; -%include -%include +%include %include %include %include diff --git a/src/alfalfa/AlfalfaActuator.hpp b/src/alfalfa/AlfalfaActuator.hpp index 9bc82dccb29..1ce5c05df2c 100644 --- a/src/alfalfa/AlfalfaActuator.hpp +++ b/src/alfalfa/AlfalfaActuator.hpp @@ -2,13 +2,13 @@ #define ALFALFA_COMPONENT_ACTUATOR_HPP #include "AlfalfaAPI.hpp" -#include "ComponentBase.hpp" +#include "AlfalfaComponentBase.hpp" #include "../utilities/idf/IdfObject.hpp" namespace openstudio { namespace alfalfa { - class ALFALFA_API AlfalfaActuator : public ComponentBase + class ALFALFA_API AlfalfaActuator : public AlfalfaComponentBase { public: /** @@ -26,15 +26,15 @@ namespace alfalfa { Json::Value toJSON() const override; - ComponentCapability capability() const override { - return ComponentCapability::Bidirectional; + AlfalfaComponentCapability capability() const override { + return AlfalfaComponentCapability::Bidirectional; } - ComponentType type() const override { - return ComponentType::Actuator; + AlfalfaComponentType type() const override { + return AlfalfaComponentType::Actuator; } - std::unique_ptr clone() const override { + std::unique_ptr clone() const override { return std::make_unique(*this); } diff --git a/src/alfalfa/AlfalfaComponent.cpp b/src/alfalfa/AlfalfaComponent.cpp index 6b10d5bf702..bde3cae7039 100644 --- a/src/alfalfa/AlfalfaComponent.cpp +++ b/src/alfalfa/AlfalfaComponent.cpp @@ -6,11 +6,11 @@ namespace alfalfa { return m_component->toJSON(); } - ComponentCapability AlfalfaComponent::capability() const { + AlfalfaComponentCapability AlfalfaComponent::capability() const { return m_component->capability(); } - ComponentType AlfalfaComponent::type() const { + AlfalfaComponentType AlfalfaComponent::type() const { return m_component->type(); } diff --git a/src/alfalfa/AlfalfaComponent.hpp b/src/alfalfa/AlfalfaComponent.hpp index b87b3ef5102..951ed4516f9 100644 --- a/src/alfalfa/AlfalfaComponent.hpp +++ b/src/alfalfa/AlfalfaComponent.hpp @@ -5,14 +5,14 @@ #include #include "AlfalfaAPI.hpp" -#include "ComponentBase.hpp" +#include "AlfalfaComponentBase.hpp" namespace openstudio { namespace alfalfa { class ALFALFA_API AlfalfaComponent { public: - template ::value, bool> = true> + template ::value, bool> = true> AlfalfaComponent(T component) : m_component(std::make_unique(std::move(component))) {} AlfalfaComponent(const AlfalfaComponent& other) : m_component(other.m_component->clone()) {} @@ -32,9 +32,9 @@ namespace alfalfa { Json::Value toJSON() const; - ComponentCapability capability() const; + AlfalfaComponentCapability capability() const; - ComponentType type() const; + AlfalfaComponentType type() const; std::string typeName() const; @@ -46,7 +46,7 @@ namespace alfalfa { private: AlfalfaComponent() = default; - std::unique_ptr m_component; + std::unique_ptr m_component; }; inline bool operator==(const AlfalfaComponent& lhs, const AlfalfaComponent& rhs) { diff --git a/src/alfalfa/AlfalfaComponentBase.cpp b/src/alfalfa/AlfalfaComponentBase.cpp new file mode 100644 index 00000000000..1e114f07ced --- /dev/null +++ b/src/alfalfa/AlfalfaComponentBase.cpp @@ -0,0 +1,15 @@ +#include "AlfalfaComponentBase.hpp" + +namespace openstudio { +namespace alfalfa { + + bool AlfalfaComponentBase::canInput() const { + return capability() == AlfalfaComponentCapability::Bidirectional || capability() == AlfalfaComponentCapability::Input; + } + + bool AlfalfaComponentBase::canOutput() const { + return capability() == AlfalfaComponentCapability::Bidirectional || capability() == AlfalfaComponentCapability::Output; + } + +} // namespace alfalfa +} // namespace openstudio diff --git a/src/alfalfa/ComponentBase.hpp b/src/alfalfa/AlfalfaComponentBase.hpp similarity index 52% rename from src/alfalfa/ComponentBase.hpp rename to src/alfalfa/AlfalfaComponentBase.hpp index c85ba317886..b5239deb298 100644 --- a/src/alfalfa/ComponentBase.hpp +++ b/src/alfalfa/AlfalfaComponentBase.hpp @@ -3,27 +3,23 @@ #include "AlfalfaAPI.hpp" -#include "../utilities/core/Enum.hpp" +#include "../utilities/data/DataEnums.hpp" #include namespace openstudio { namespace alfalfa { - OPENSTUDIO_ENUM(ComponentCapability, ((Input))((Output))((Bidirectional))) - - OPENSTUDIO_ENUM(ComponentType, ((Actuator))((Constant))((Meter))((OutputVariable))((GlobalVariable))) - - class ALFALFA_API ComponentBase + class ALFALFA_API AlfalfaComponentBase { public: - virtual ~ComponentBase() = default; + virtual ~AlfalfaComponentBase() = default; virtual Json::Value toJSON() const = 0; - virtual ComponentCapability capability() const = 0; + virtual AlfalfaComponentCapability capability() const = 0; - virtual ComponentType type() const = 0; + virtual AlfalfaComponentType type() const = 0; virtual std::string typeName() const { return type().valueName(); @@ -31,7 +27,7 @@ namespace alfalfa { virtual std::string deriveName() const = 0; - virtual std::unique_ptr clone() const = 0; + virtual std::unique_ptr clone() const = 0; virtual bool canInput() const; diff --git a/src/alfalfa/AlfalfaConstant.hpp b/src/alfalfa/AlfalfaConstant.hpp index 1d74e8b6226..e07403fe387 100644 --- a/src/alfalfa/AlfalfaConstant.hpp +++ b/src/alfalfa/AlfalfaConstant.hpp @@ -3,11 +3,11 @@ #include "AlfalfaAPI.hpp" -#include "ComponentBase.hpp" +#include "AlfalfaComponentBase.hpp" namespace openstudio { namespace alfalfa { - class ALFALFA_API AlfalfaConstant : public ComponentBase + class ALFALFA_API AlfalfaConstant : public AlfalfaComponentBase { public: /** @@ -19,15 +19,15 @@ namespace alfalfa { Json::Value toJSON() const override; - ComponentCapability capability() const override { - return ComponentCapability::Output; + AlfalfaComponentCapability capability() const override { + return AlfalfaComponentCapability::Output; } - ComponentType type() const override { - return ComponentType::Constant; + AlfalfaComponentType type() const override { + return AlfalfaComponentType::Constant; } - std::unique_ptr clone() const override { + std::unique_ptr clone() const override { return std::make_unique(*this); } diff --git a/src/alfalfa/AlfalfaGlobalVariable.hpp b/src/alfalfa/AlfalfaGlobalVariable.hpp index 3f389bb08a4..e62efa171c0 100644 --- a/src/alfalfa/AlfalfaGlobalVariable.hpp +++ b/src/alfalfa/AlfalfaGlobalVariable.hpp @@ -3,13 +3,13 @@ #include "AlfalfaAPI.hpp" -#include "ComponentBase.hpp" +#include "AlfalfaComponentBase.hpp" #include "../utilities/idf/IdfObject.hpp" namespace openstudio { namespace alfalfa { - class ALFALFA_API AlfalfaGlobalVariable : public ComponentBase + class ALFALFA_API AlfalfaGlobalVariable : public AlfalfaComponentBase { public: /** @@ -27,15 +27,15 @@ namespace alfalfa { Json::Value toJSON() const override; - ComponentCapability capability() const override { - return ComponentCapability::Bidirectional; + AlfalfaComponentCapability capability() const override { + return AlfalfaComponentCapability::Bidirectional; } - ComponentType type() const override { - return ComponentType::GlobalVariable; + AlfalfaComponentType type() const override { + return AlfalfaComponentType::GlobalVariable; } - std::unique_ptr clone() const override { + std::unique_ptr clone() const override { return std::make_unique(*this); } diff --git a/src/alfalfa/AlfalfaMeter.hpp b/src/alfalfa/AlfalfaMeter.hpp index 51001bf47af..8d2593764b0 100644 --- a/src/alfalfa/AlfalfaMeter.hpp +++ b/src/alfalfa/AlfalfaMeter.hpp @@ -3,13 +3,13 @@ #include "AlfalfaAPI.hpp" -#include "ComponentBase.hpp" +#include "AlfalfaComponentBase.hpp" #include "../utilities/idf/IdfObject.hpp" namespace openstudio { namespace alfalfa { - class ALFALFA_API AlfalfaMeter : public ComponentBase + class ALFALFA_API AlfalfaMeter : public AlfalfaComponentBase { public: /** @@ -27,15 +27,15 @@ namespace alfalfa { Json::Value toJSON() const override; - ComponentCapability capability() const override { - return ComponentCapability::Output; + AlfalfaComponentCapability capability() const override { + return AlfalfaComponentCapability::Output; } - ComponentType type() const override { - return ComponentType::Meter; + AlfalfaComponentType type() const override { + return AlfalfaComponentType::Meter; } - std::unique_ptr clone() const override { + std::unique_ptr clone() const override { return std::make_unique(*this); } diff --git a/src/alfalfa/AlfalfaOutputVariable.hpp b/src/alfalfa/AlfalfaOutputVariable.hpp index bf6b010a86b..c8d85d8ea71 100644 --- a/src/alfalfa/AlfalfaOutputVariable.hpp +++ b/src/alfalfa/AlfalfaOutputVariable.hpp @@ -3,13 +3,13 @@ #include "AlfalfaAPI.hpp" -#include "ComponentBase.hpp" +#include "AlfalfaComponentBase.hpp" #include "../utilities/idf/IdfObject.hpp" namespace openstudio { namespace alfalfa { - class ALFALFA_API AlfalfaOutputVariable : public ComponentBase + class ALFALFA_API AlfalfaOutputVariable : public AlfalfaComponentBase { public: /** @@ -27,15 +27,15 @@ namespace alfalfa { Json::Value toJSON() const override; - ComponentCapability capability() const override { - return ComponentCapability::Output; + AlfalfaComponentCapability capability() const override { + return AlfalfaComponentCapability::Output; } - ComponentType type() const override { - return ComponentType::OutputVariable; + AlfalfaComponentType type() const override { + return AlfalfaComponentType::OutputVariable; } - std::unique_ptr clone() const override { + std::unique_ptr clone() const override { return std::make_unique(*this); } diff --git a/src/alfalfa/CMakeLists.txt b/src/alfalfa/CMakeLists.txt index c87da18b12d..9fe7e350d15 100644 --- a/src/alfalfa/CMakeLists.txt +++ b/src/alfalfa/CMakeLists.txt @@ -5,8 +5,8 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}/) set(${target_name}_src AlfalfaAPI.hpp - ComponentBase.cpp - ComponentBase.hpp + AlfalfaComponentBase.cpp + AlfalfaComponentBase.hpp AlfalfaComponent.hpp AlfalfaComponent.cpp AlfalfaConstant.hpp @@ -58,4 +58,4 @@ if(BUILD_TESTING) endif() -MAKE_SWIG_TARGET(OpenStudioAlfalfa alfalfa "${CMAKE_CURRENT_SOURCE_DIR}/Alfalfa.i" "${${target_name}_swig_src}" ${target_name} OpenStudioModel) +MAKE_SWIG_TARGET(OpenStudioAlfalfa alfalfa "${CMAKE_CURRENT_SOURCE_DIR}/Alfalfa.i" "${${target_name}_swig_src}" ${target_name} OpenStudioOSVersion) diff --git a/src/alfalfa/ComponentBase.cpp b/src/alfalfa/ComponentBase.cpp deleted file mode 100644 index 4ed339d05da..00000000000 --- a/src/alfalfa/ComponentBase.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "ComponentBase.hpp" - -namespace openstudio { -namespace alfalfa { - - bool ComponentBase::canInput() const { - return capability() == ComponentCapability::Bidirectional || capability() == ComponentCapability::Input; - } - - bool ComponentBase::canOutput() const { - return capability() == ComponentCapability::Bidirectional || capability() == ComponentCapability::Output; - } - -} // namespace alfalfa -} // namespace openstudio diff --git a/src/alfalfa/test/AlfalfaJSON_GTest.cpp b/src/alfalfa/test/AlfalfaJSON_GTest.cpp index 6b5e568871d..eca8a69338a 100644 --- a/src/alfalfa/test/AlfalfaJSON_GTest.cpp +++ b/src/alfalfa/test/AlfalfaJSON_GTest.cpp @@ -201,7 +201,8 @@ TEST(AlfalfaJSON, json_serialization) { TEST(AlfalfaJSON, point_exceptions_logging) { const std::string ID_VALID_CHARS_MSG = "IDs can only contain letters, numbers, and the following special characters _-[]():"; - const std::string DISPLAY_NAME_VALID_CHARS_MSG = "Display name '{}' does not produce a valid point ID. Manually set a valid ID or export will fail."; + const std::string DISPLAY_NAME_VALID_CHARS_MSG = + "Display name '{}' does not produce a valid point ID. Manually set a valid ID or export will fail."; const std::string LOG_CHANNEL = "openstudio.AlfalfaPoint"; StringStreamLogSink ss; ss.setLogLevel(Warn); @@ -303,19 +304,19 @@ TEST(AlfalfaJSON, point_exceptions_logging) { ASSERT_EQ(ss.logMessages().size(), 0); } -class InputComponent : public ComponentBase +class InputComponent : public AlfalfaComponentBase { public: InputComponent() = default; - ComponentCapability capability() const override { - return ComponentCapability::Input; + AlfalfaComponentCapability capability() const override { + return AlfalfaComponentCapability::Input; } - openstudio::alfalfa::ComponentType type() const override { - return openstudio::alfalfa::ComponentType::Constant; + AlfalfaComponentType type() const override { + return AlfalfaComponentType::Constant; } - std::unique_ptr clone() const override { + std::unique_ptr clone() const override { return std::make_unique(*this); } diff --git a/src/gltf/GltfMaterialData.cpp b/src/gltf/GltfMaterialData.cpp index 589737fec35..3a7dc4c0263 100644 --- a/src/gltf/GltfMaterialData.cpp +++ b/src/gltf/GltfMaterialData.cpp @@ -26,7 +26,7 @@ #include -#include +#include #include #include #include diff --git a/src/gltf/GltfMaterialData.hpp b/src/gltf/GltfMaterialData.hpp index 36eeb9f30ce..675ad6783c5 100644 --- a/src/gltf/GltfMaterialData.hpp +++ b/src/gltf/GltfMaterialData.hpp @@ -8,7 +8,7 @@ #include "GltfAPI.hpp" -#include +#include #include #include diff --git a/src/measure/CMakeLists.txt b/src/measure/CMakeLists.txt index 36b249dd111..03c3c771d8e 100644 --- a/src/measure/CMakeLists.txt +++ b/src/measure/CMakeLists.txt @@ -67,4 +67,4 @@ endif() CREATE_TEST_TARGETS(${target_name} "${${target_name}_test_src}" "${${target_name}_test_depends}") -MAKE_SWIG_TARGET(OpenStudioMeasure measure "${CMAKE_CURRENT_SOURCE_DIR}/Measure.i" "${${target_name}_swig_src}" ${target_name} "OpenStudioOSVersion;OpenStudioAlfalfa") +MAKE_SWIG_TARGET(OpenStudioMeasure measure "${CMAKE_CURRENT_SOURCE_DIR}/Measure.i" "${${target_name}_swig_src}" ${target_name} OpenStudioAlfalfa) diff --git a/src/measure/Measure.i b/src/measure/Measure.i index 3b074944e14..18b1d5e8419 100644 --- a/src/measure/Measure.i +++ b/src/measure/Measure.i @@ -7,10 +7,10 @@ %include -%include #define MODEL_API #define STANDARDSINTERFACE_API #define MEASURE_API +#define ALFALFA_API %include %import diff --git a/src/utilities/data/Data.i b/src/utilities/data/Data.i index 348095d4fab..ea034806c3f 100644 --- a/src/utilities/data/Data.i +++ b/src/utilities/data/Data.i @@ -37,6 +37,10 @@ %template(OptionalAppGFuelType) boost::optional; %template(ComponentTypeVector) std::vector; %template(OptionalComponentType) boost::optional; +%template(AlfalfaComponentTypeVector) std::vector; +%template(OptionalAlfalfaComponentType) boost::optional; +%template(AlfalfaComponentCapabilityVector) std::vector; +%template(OptionalAlfalfaComponentCapability) boost::optional; %include %include diff --git a/src/utilities/data/DataEnums.hpp b/src/utilities/data/DataEnums.hpp index c64d977243d..cbe9d7e9921 100644 --- a/src/utilities/data/DataEnums.hpp +++ b/src/utilities/data/DataEnums.hpp @@ -290,6 +290,32 @@ using OptionalComponentType = boost::optional; /** \relates ComponentType */ using ComponentTypeVector = std::vector; + +OPENSTUDIO_ENUM(AlfalfaComponentCapability, + ((Input)) + ((Output)) + ((Bidirectional)) +) +/** \relates AlfalfaComponentCapability */ +using OptionalAlfalfaComponentCapability = boost::optional; + +/** \relates AlfalfaComponentCapability */ +using AlfalfaComponentCapabilityVector = std::vector; + + +OPENSTUDIO_ENUM(AlfalfaComponentType, + ((Actuator)) + ((Constant)) + ((Meter)) + ((OutputVariable)) + ((GlobalVariable)) +) +/** \relates AlfalfaComponentType */ +using OptionalAlfalfaComponentType = boost::optional; + +/** \relates AlfalfaComponentType */ +using AlfalfaComponentTypeVector = std::vector; + // clang-format on inline UTILITIES_API AppGFuelType convertFuelTypeToAppG(FuelType fuelType) {