src/model/LoadingIndex.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 "LoadingIndex.hpp" | ||
| 7 | #include "LoadingIndex_Impl.hpp" | ||
| 8 | |||
| 9 | #include "Curve.hpp" | ||
| 10 | #include "Curve_Impl.hpp" | ||
| 11 | #include "Model.hpp" | ||
| 12 | #include "Model_Impl.hpp" | ||
| 13 | |||
| 14 | #include <utilities/idd/IddEnums.hxx> | ||
| 15 | #include <utilities/idd/OS_AirConditioner_VariableRefrigerantFlow_FluidTemperatureControl_LoadingIndex_FieldEnums.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 | 80 | LoadingIndex_Impl::LoadingIndex_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 27 | 80 | : ParentObject_Impl(idfObject, model, keepHandle) { | |
| 28 |
4/6✓ Branch 1 taken 80 times.
✓ Branch 4 taken 80 times.
✓ Branch 7 taken 80 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 80 times.
✗ Branch 13 not taken.
|
80 | OS_ASSERT(idfObject.iddObject().type() == LoadingIndex::iddObjectType()); |
| 29 | 80 | } | |
| 30 | |||
| 31 | ✗ | LoadingIndex_Impl::LoadingIndex_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) | |
| 32 | ✗ | : ParentObject_Impl(other, model, keepHandle) { | |
| 33 | ✗ | OS_ASSERT(other.iddObject().type() == LoadingIndex::iddObjectType()); | |
| 34 | ✗ | } | |
| 35 | |||
| 36 | 48 | LoadingIndex_Impl::LoadingIndex_Impl(const LoadingIndex_Impl& other, Model_Impl* model, bool keepHandle) | |
| 37 | 48 | : ParentObject_Impl(other, model, keepHandle) {} | |
| 38 | |||
| 39 | ✗ | const std::vector<std::string>& LoadingIndex_Impl::outputVariableNames() const { | |
| 40 | ✗ | static std::vector<std::string> result; | |
| 41 | ✗ | return result; | |
| 42 | } | ||
| 43 | |||
| 44 | ✗ | IddObjectType LoadingIndex_Impl::iddObjectType() const { | |
| 45 | ✗ | return LoadingIndex::iddObjectType(); | |
| 46 | } | ||
| 47 | |||
| 48 | 12 | ModelObject LoadingIndex_Impl::clone(Model model) const { | |
| 49 | // Don't clone the curves (listed as children) | ||
| 50 |
3/3✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
|
12 | return ModelObject_Impl::clone(model).cast<LoadingIndex>(); // NOLINT(bugprone-parent-virtual-call) |
| 51 | } | ||
| 52 | |||
| 53 | 18 | std::vector<ModelObject> LoadingIndex_Impl::children() const { | |
| 54 |
3/5✓ Branch 1 taken 18 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 18 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
|
72 | return {evaporativeCapacityMultiplierFunctionofTemperatureCurve(), compressorPowerMultiplierFunctionofTemperatureCurve()}; |
| 55 | 18 | } | |
| 56 | |||
| 57 | 22 | double LoadingIndex_Impl::compressorSpeed() const { | |
| 58 | boost::optional<double> value = | ||
| 59 |
1/1✓ Branch 1 taken 22 times.
|
22 | getDouble(OS_AirConditioner_VariableRefrigerantFlow_FluidTemperatureControl_LoadingIndexFields::CompressorSpeed, true); |
| 60 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 4 not taken.
|
22 | OS_ASSERT(value); |
| 61 |
1/1✓ Branch 1 taken 22 times.
|
44 | return value.get(); |
| 62 | } | ||
| 63 | |||
| 64 | 40 | Curve LoadingIndex_Impl::evaporativeCapacityMultiplierFunctionofTemperatureCurve() const { | |
| 65 |
1/1✓ Branch 1 taken 40 times.
|
40 | boost::optional<Curve> value = optionalEvaporativeCapacityMultiplierFunctionofTemperatureCurve(); |
| 66 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
|
40 | if (!value) { |
| 67 | ✗ | LOG_AND_THROW(briefDescription() << " does not have an Evaporative Capacity Multiplier Function of Temperature Curve attached."); | |
| 68 | } | ||
| 69 |
2/2✓ Branch 1 taken 40 times.
✓ Branch 4 taken 40 times.
|
80 | return value.get(); |
| 70 | 40 | } | |
| 71 | |||
| 72 | 40 | Curve LoadingIndex_Impl::compressorPowerMultiplierFunctionofTemperatureCurve() const { | |
| 73 |
1/1✓ Branch 1 taken 40 times.
|
40 | boost::optional<Curve> value = optionalCompressorPowerMultiplierFunctionofTemperatureCurve(); |
| 74 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
|
40 | if (!value) { |
| 75 | ✗ | LOG_AND_THROW(briefDescription() << " does not have an Compressor Power Multiplier Function of Temperature Curve attached."); | |
| 76 | } | ||
| 77 |
2/2✓ Branch 1 taken 40 times.
✓ Branch 4 taken 40 times.
|
80 | return value.get(); |
| 78 | 40 | } | |
| 79 | |||
| 80 | 80 | bool LoadingIndex_Impl::setCompressorSpeed(double compressorSpeed) { | |
| 81 | 80 | bool result = setDouble(OS_AirConditioner_VariableRefrigerantFlow_FluidTemperatureControl_LoadingIndexFields::CompressorSpeed, compressorSpeed); | |
| 82 | 80 | return result; | |
| 83 | } | ||
| 84 | |||
| 85 | 80 | bool LoadingIndex_Impl::setEvaporativeCapacityMultiplierFunctionofTemperatureCurve(const Curve& curve) { | |
| 86 |
1/1✓ Branch 1 taken 80 times.
|
80 | bool result = setPointer(OS_AirConditioner_VariableRefrigerantFlow_FluidTemperatureControl_LoadingIndexFields:: |
| 87 | EvaporativeCapacityMultiplierFunctionofTemperatureCurveName, | ||
| 88 |
1/1✓ Branch 1 taken 80 times.
|
80 | curve.handle()); |
| 89 | 80 | return result; | |
| 90 | } | ||
| 91 | |||
| 92 | 80 | bool LoadingIndex_Impl::setCompressorPowerMultiplierFunctionofTemperatureCurve(const Curve& curve) { | |
| 93 |
1/1✓ Branch 1 taken 80 times.
|
80 | bool result = setPointer( |
| 94 | OS_AirConditioner_VariableRefrigerantFlow_FluidTemperatureControl_LoadingIndexFields::CompressorPowerMultiplierFunctionofTemperatureCurveName, | ||
| 95 |
1/1✓ Branch 1 taken 80 times.
|
80 | curve.handle()); |
| 96 | 80 | return result; | |
| 97 | } | ||
| 98 | |||
| 99 | 40 | boost::optional<Curve> LoadingIndex_Impl::optionalEvaporativeCapacityMultiplierFunctionofTemperatureCurve() const { | |
| 100 |
1/1✓ Branch 1 taken 40 times.
|
80 | return getObject<ModelObject>().getModelObjectTarget<Curve>( |
| 101 | OS_AirConditioner_VariableRefrigerantFlow_FluidTemperatureControl_LoadingIndexFields:: | ||
| 102 |
1/1✓ Branch 1 taken 40 times.
|
80 | EvaporativeCapacityMultiplierFunctionofTemperatureCurveName); |
| 103 | } | ||
| 104 | |||
| 105 | 40 | boost::optional<Curve> LoadingIndex_Impl::optionalCompressorPowerMultiplierFunctionofTemperatureCurve() const { | |
| 106 |
1/1✓ Branch 1 taken 40 times.
|
80 | return getObject<ModelObject>().getModelObjectTarget<Curve>( |
| 107 | OS_AirConditioner_VariableRefrigerantFlow_FluidTemperatureControl_LoadingIndexFields:: | ||
| 108 |
1/1✓ Branch 1 taken 40 times.
|
80 | CompressorPowerMultiplierFunctionofTemperatureCurveName); |
| 109 | } | ||
| 110 | |||
| 111 | } // namespace detail | ||
| 112 | |||
| 113 | 80 | LoadingIndex::LoadingIndex(const Model& model, double compressorSpeed, const Curve& evaporativeCapacityMultiplierFunctionofTemperatureCurve, | |
| 114 | 80 | const Curve& compressorPowerMultiplierFunctionofTemperatureCurve) | |
| 115 | 80 | : ParentObject(LoadingIndex::iddObjectType(), model) { | |
| 116 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 80 times.
✗ Branch 5 not taken.
|
80 | OS_ASSERT(getImpl<detail::LoadingIndex_Impl>()); |
| 117 | |||
| 118 | 80 | bool ok = true; | |
| 119 |
1/1✓ Branch 1 taken 80 times.
|
80 | ok = setCompressorSpeed(compressorSpeed); |
| 120 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 3 not taken.
|
80 | OS_ASSERT(ok); |
| 121 |
1/1✓ Branch 1 taken 80 times.
|
80 | ok = setEvaporativeCapacityMultiplierFunctionofTemperatureCurve(evaporativeCapacityMultiplierFunctionofTemperatureCurve); |
| 122 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
|
80 | if (!ok) { |
| 123 | ✗ | remove(); | |
| 124 | ✗ | LOG_AND_THROW("Unable to set " << briefDescription() << "'s Evaporative Capacity Multiplier Function of Temperature Curve to " | |
| 125 | << evaporativeCapacityMultiplierFunctionofTemperatureCurve.briefDescription() << "."); | ||
| 126 | } | ||
| 127 |
1/1✓ Branch 1 taken 80 times.
|
80 | ok = setCompressorPowerMultiplierFunctionofTemperatureCurve(compressorPowerMultiplierFunctionofTemperatureCurve); |
| 128 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
|
80 | if (!ok) { |
| 129 | ✗ | remove(); | |
| 130 | ✗ | LOG_AND_THROW("Unable to set " << briefDescription() << "'s Compressor Power Multiplier Function of Temperature Curve to " | |
| 131 | << compressorPowerMultiplierFunctionofTemperatureCurve.briefDescription() << "."); | ||
| 132 | } | ||
| 133 | 80 | } | |
| 134 | |||
| 135 | 7906 | IddObjectType LoadingIndex::iddObjectType() { | |
| 136 |
1/1✓ Branch 1 taken 7906 times.
|
7906 | return IddObjectType(IddObjectType::OS_AirConditioner_VariableRefrigerantFlow_FluidTemperatureControl_LoadingIndex); |
| 137 | } | ||
| 138 | |||
| 139 | 22 | double LoadingIndex::compressorSpeed() const { | |
| 140 |
1/1✓ Branch 3 taken 22 times.
|
22 | return getImpl<detail::LoadingIndex_Impl>()->compressorSpeed(); |
| 141 | } | ||
| 142 | |||
| 143 | 22 | Curve LoadingIndex::evaporativeCapacityMultiplierFunctionofTemperatureCurve() const { | |
| 144 |
1/1✓ Branch 3 taken 22 times.
|
22 | return getImpl<detail::LoadingIndex_Impl>()->evaporativeCapacityMultiplierFunctionofTemperatureCurve(); |
| 145 | } | ||
| 146 | |||
| 147 | 22 | Curve LoadingIndex::compressorPowerMultiplierFunctionofTemperatureCurve() const { | |
| 148 |
1/1✓ Branch 3 taken 22 times.
|
22 | return getImpl<detail::LoadingIndex_Impl>()->compressorPowerMultiplierFunctionofTemperatureCurve(); |
| 149 | } | ||
| 150 | |||
| 151 | 80 | bool LoadingIndex::setCompressorSpeed(double compressorSpeed) { | |
| 152 |
1/1✓ Branch 3 taken 80 times.
|
80 | return getImpl<detail::LoadingIndex_Impl>()->setCompressorSpeed(compressorSpeed); |
| 153 | } | ||
| 154 | |||
| 155 | 80 | bool LoadingIndex::setEvaporativeCapacityMultiplierFunctionofTemperatureCurve(const Curve& curve) { | |
| 156 |
1/1✓ Branch 3 taken 80 times.
|
80 | return getImpl<detail::LoadingIndex_Impl>()->setEvaporativeCapacityMultiplierFunctionofTemperatureCurve(curve); |
| 157 | } | ||
| 158 | |||
| 159 | 80 | bool LoadingIndex::setCompressorPowerMultiplierFunctionofTemperatureCurve(const Curve& curve) { | |
| 160 |
1/1✓ Branch 3 taken 80 times.
|
80 | return getImpl<detail::LoadingIndex_Impl>()->setCompressorPowerMultiplierFunctionofTemperatureCurve(curve); |
| 161 | } | ||
| 162 | |||
| 163 | /// @cond | ||
| 164 |
1/1✓ Branch 3 taken 128 times.
|
128 | LoadingIndex::LoadingIndex(std::shared_ptr<detail::LoadingIndex_Impl> impl) : ParentObject(std::move(impl)) {} |
| 165 | /// @endcond | ||
| 166 | |||
| 167 | } // namespace model | ||
| 168 | } // namespace openstudio | ||
| 169 |