src/model/SizingParameters.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 "SizingParameters.hpp" | ||
| 7 | #include "SizingParameters_Impl.hpp" | ||
| 8 | |||
| 9 | #include "Model.hpp" | ||
| 10 | #include "Model_Impl.hpp" | ||
| 11 | #include "SimulationControl.hpp" | ||
| 12 | #include "SimulationControl_Impl.hpp" | ||
| 13 | |||
| 14 | #include <utilities/idd/OS_Sizing_Parameters_FieldEnums.hxx> | ||
| 15 | #include <utilities/idd/IddEnums.hxx> | ||
| 16 | |||
| 17 | #include "../utilities/units/Unit.hpp" | ||
| 18 | |||
| 19 | #include "../utilities/core/Assert.hpp" | ||
| 20 | |||
| 21 | namespace openstudio { | ||
| 22 | namespace model { | ||
| 23 | |||
| 24 | namespace detail { | ||
| 25 | |||
| 26 | 1006 | SizingParameters_Impl::SizingParameters_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 27 | 1006 | : ModelObject_Impl(idfObject, model, keepHandle) { | |
| 28 |
4/6✓ Branch 1 taken 1006 times.
✓ Branch 4 taken 1006 times.
✓ Branch 7 taken 1006 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1006 times.
✗ Branch 13 not taken.
|
1006 | OS_ASSERT(idfObject.iddObject().type() == SizingParameters::iddObjectType()); |
| 29 | 1006 | } | |
| 30 | |||
| 31 | 34 | SizingParameters_Impl::SizingParameters_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) | |
| 32 | 34 | : ModelObject_Impl(other, model, keepHandle) { | |
| 33 |
4/6✓ Branch 1 taken 34 times.
✓ Branch 4 taken 34 times.
✓ Branch 7 taken 34 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 34 times.
✗ Branch 13 not taken.
|
34 | OS_ASSERT(other.iddObject().type() == SizingParameters::iddObjectType()); |
| 34 | 34 | } | |
| 35 | |||
| 36 | 57 | SizingParameters_Impl::SizingParameters_Impl(const SizingParameters_Impl& other, Model_Impl* model, bool keepHandle) | |
| 37 | 57 | : ModelObject_Impl(other, model, keepHandle) {} | |
| 38 | |||
| 39 | 1 | boost::optional<ParentObject> SizingParameters_Impl::parent() const { | |
| 40 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | boost::optional<SimulationControl> result = this->model().getOptionalUniqueModelObject<SimulationControl>(); |
| 41 |
1/1✓ Branch 1 taken 1 time.
|
2 | return boost::optional<ParentObject>(result); |
| 42 | 1 | } | |
| 43 | |||
| 44 | ✗ | const std::vector<std::string>& SizingParameters_Impl::outputVariableNames() const { | |
| 45 | ✗ | static const std::vector<std::string> result; | |
| 46 | ✗ | return result; | |
| 47 | } | ||
| 48 | |||
| 49 | 7 | IddObjectType SizingParameters_Impl::iddObjectType() const { | |
| 50 | 7 | return SizingParameters::iddObjectType(); | |
| 51 | } | ||
| 52 | |||
| 53 | 870 | double SizingParameters_Impl::heatingSizingFactor() const { | |
| 54 |
1/1✓ Branch 1 taken 870 times.
|
870 | boost::optional<double> value = getDouble(OS_Sizing_ParametersFields::HeatingSizingFactor, true); |
| 55 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 870 times.
✗ Branch 4 not taken.
|
870 | OS_ASSERT(value); |
| 56 |
1/1✓ Branch 1 taken 870 times.
|
1740 | return value.get(); |
| 57 | } | ||
| 58 | |||
| 59 | 870 | bool SizingParameters_Impl::isHeatingSizingFactorDefaulted() const { | |
| 60 | 870 | return isEmpty(OS_Sizing_ParametersFields::HeatingSizingFactor); | |
| 61 | } | ||
| 62 | |||
| 63 | 870 | double SizingParameters_Impl::coolingSizingFactor() const { | |
| 64 |
1/1✓ Branch 1 taken 870 times.
|
870 | boost::optional<double> value = getDouble(OS_Sizing_ParametersFields::CoolingSizingFactor, true); |
| 65 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 870 times.
✗ Branch 4 not taken.
|
870 | OS_ASSERT(value); |
| 66 |
1/1✓ Branch 1 taken 870 times.
|
1740 | return value.get(); |
| 67 | } | ||
| 68 | |||
| 69 | 870 | bool SizingParameters_Impl::isCoolingSizingFactorDefaulted() const { | |
| 70 | 870 | return isEmpty(OS_Sizing_ParametersFields::CoolingSizingFactor); | |
| 71 | } | ||
| 72 | |||
| 73 | 871 | boost::optional<int> SizingParameters_Impl::timestepsinAveragingWindow() const { | |
| 74 | 871 | return getInt(OS_Sizing_ParametersFields::TimestepsinAveragingWindow, true); | |
| 75 | } | ||
| 76 | |||
| 77 | 1007 | bool SizingParameters_Impl::setHeatingSizingFactor(double heatingSizingFactor) { | |
| 78 | 1007 | bool result = setDouble(OS_Sizing_ParametersFields::HeatingSizingFactor, heatingSizingFactor); | |
| 79 | 1007 | return result; | |
| 80 | } | ||
| 81 | |||
| 82 | ✗ | void SizingParameters_Impl::resetHeatingSizingFactor() { | |
| 83 | ✗ | bool result = setString(OS_Sizing_ParametersFields::HeatingSizingFactor, ""); | |
| 84 | ✗ | OS_ASSERT(result); | |
| 85 | ✗ | } | |
| 86 | |||
| 87 | 1007 | bool SizingParameters_Impl::setCoolingSizingFactor(double coolingSizingFactor) { | |
| 88 | 1007 | bool result = setDouble(OS_Sizing_ParametersFields::CoolingSizingFactor, coolingSizingFactor); | |
| 89 | 1007 | return result; | |
| 90 | } | ||
| 91 | |||
| 92 | ✗ | void SizingParameters_Impl::resetCoolingSizingFactor() { | |
| 93 | ✗ | bool result = setString(OS_Sizing_ParametersFields::CoolingSizingFactor, ""); | |
| 94 | ✗ | OS_ASSERT(result); | |
| 95 | ✗ | } | |
| 96 | |||
| 97 | 3 | bool SizingParameters_Impl::setTimestepsinAveragingWindow(boost::optional<int> timestepsinAveragingWindow) { | |
| 98 | 3 | bool result(false); | |
| 99 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if (timestepsinAveragingWindow) { |
| 100 | 3 | result = setInt(OS_Sizing_ParametersFields::TimestepsinAveragingWindow, timestepsinAveragingWindow.get()); | |
| 101 | } else { | ||
| 102 | ✗ | result = setString(OS_Sizing_ParametersFields::TimestepsinAveragingWindow, ""); | |
| 103 | } | ||
| 104 | 3 | return result; | |
| 105 | } | ||
| 106 | |||
| 107 | ✗ | void SizingParameters_Impl::resetTimestepsinAveragingWindow() { | |
| 108 | ✗ | bool result = setString(OS_Sizing_ParametersFields::TimestepsinAveragingWindow, ""); | |
| 109 | ✗ | OS_ASSERT(result); | |
| 110 | ✗ | } | |
| 111 | |||
| 112 | } // namespace detail | ||
| 113 | |||
| 114 | 12492 | IddObjectType SizingParameters::iddObjectType() { | |
| 115 |
1/1✓ Branch 1 taken 12492 times.
|
12492 | return {IddObjectType::OS_Sizing_Parameters}; |
| 116 | } | ||
| 117 | |||
| 118 | 870 | double SizingParameters::heatingSizingFactor() const { | |
| 119 |
1/1✓ Branch 3 taken 870 times.
|
870 | return getImpl<detail::SizingParameters_Impl>()->heatingSizingFactor(); |
| 120 | } | ||
| 121 | |||
| 122 | 870 | bool SizingParameters::isHeatingSizingFactorDefaulted() const { | |
| 123 |
1/1✓ Branch 3 taken 870 times.
|
870 | return getImpl<detail::SizingParameters_Impl>()->isHeatingSizingFactorDefaulted(); |
| 124 | } | ||
| 125 | |||
| 126 | 870 | double SizingParameters::coolingSizingFactor() const { | |
| 127 |
1/1✓ Branch 3 taken 870 times.
|
870 | return getImpl<detail::SizingParameters_Impl>()->coolingSizingFactor(); |
| 128 | } | ||
| 129 | |||
| 130 | 870 | bool SizingParameters::isCoolingSizingFactorDefaulted() const { | |
| 131 |
1/1✓ Branch 3 taken 870 times.
|
870 | return getImpl<detail::SizingParameters_Impl>()->isCoolingSizingFactorDefaulted(); |
| 132 | } | ||
| 133 | |||
| 134 | 871 | boost::optional<int> SizingParameters::timestepsinAveragingWindow() const { | |
| 135 |
1/1✓ Branch 3 taken 871 times.
|
871 | return getImpl<detail::SizingParameters_Impl>()->timestepsinAveragingWindow(); |
| 136 | } | ||
| 137 | |||
| 138 | 1007 | bool SizingParameters::setHeatingSizingFactor(double heatingSizingFactor) { | |
| 139 |
1/1✓ Branch 3 taken 1007 times.
|
1007 | return getImpl<detail::SizingParameters_Impl>()->setHeatingSizingFactor(heatingSizingFactor); |
| 140 | } | ||
| 141 | |||
| 142 | ✗ | void SizingParameters::resetHeatingSizingFactor() { | |
| 143 | ✗ | getImpl<detail::SizingParameters_Impl>()->resetHeatingSizingFactor(); | |
| 144 | ✗ | } | |
| 145 | |||
| 146 | 1007 | bool SizingParameters::setCoolingSizingFactor(double coolingSizingFactor) { | |
| 147 |
1/1✓ Branch 3 taken 1007 times.
|
1007 | return getImpl<detail::SizingParameters_Impl>()->setCoolingSizingFactor(coolingSizingFactor); |
| 148 | } | ||
| 149 | |||
| 150 | ✗ | void SizingParameters::resetCoolingSizingFactor() { | |
| 151 | ✗ | getImpl<detail::SizingParameters_Impl>()->resetCoolingSizingFactor(); | |
| 152 | ✗ | } | |
| 153 | |||
| 154 | 3 | bool SizingParameters::setTimestepsinAveragingWindow(int timestepsinAveragingWindow) { | |
| 155 |
2/2✓ Branch 3 taken 3 times.
✓ Branch 6 taken 3 times.
|
3 | return getImpl<detail::SizingParameters_Impl>()->setTimestepsinAveragingWindow(timestepsinAveragingWindow); |
| 156 | } | ||
| 157 | |||
| 158 | ✗ | void SizingParameters::resetTimestepsinAveragingWindow() { | |
| 159 | ✗ | getImpl<detail::SizingParameters_Impl>()->resetTimestepsinAveragingWindow(); | |
| 160 | ✗ | } | |
| 161 | |||
| 162 | /// @cond | ||
| 163 |
1/1✓ Branch 3 taken 899 times.
|
899 | SizingParameters::SizingParameters(std::shared_ptr<detail::SizingParameters_Impl> impl) : ModelObject(std::move(impl)) {} |
| 164 | |||
| 165 | 972 | SizingParameters::SizingParameters(Model& model) : ModelObject(SizingParameters::iddObjectType(), model) { | |
| 166 |
1/1✓ Branch 1 taken 972 times.
|
972 | setHeatingSizingFactor(1.25); |
| 167 |
1/1✓ Branch 1 taken 972 times.
|
972 | setCoolingSizingFactor(1.15); |
| 168 | 972 | } | |
| 169 | |||
| 170 | /// @endcond | ||
| 171 | |||
| 172 | } // namespace model | ||
| 173 | } // namespace openstudio | ||
| 174 |