src/model/RefrigerationSubcoolerMechanical.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 "RefrigerationSubcoolerMechanical.hpp" | ||
| 7 | #include "RefrigerationSubcoolerMechanical_Impl.hpp" | ||
| 8 | |||
| 9 | #include "RefrigerationSystem.hpp" | ||
| 10 | #include "RefrigerationSystem_Impl.hpp" | ||
| 11 | #include "Model.hpp" | ||
| 12 | #include "Model_Impl.hpp" | ||
| 13 | |||
| 14 | #include <utilities/idd/OS_Refrigeration_Subcooler_Mechanical_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 | 14 | RefrigerationSubcoolerMechanical_Impl::RefrigerationSubcoolerMechanical_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 27 | 14 | : ModelObject_Impl(idfObject, model, keepHandle) { | |
| 28 |
4/6✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
✓ Branch 7 taken 14 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 14 times.
✗ Branch 13 not taken.
|
14 | OS_ASSERT(idfObject.iddObject().type() == RefrigerationSubcoolerMechanical::iddObjectType()); |
| 29 | 14 | } | |
| 30 | |||
| 31 | ✗ | RefrigerationSubcoolerMechanical_Impl::RefrigerationSubcoolerMechanical_Impl(const openstudio::detail::WorkspaceObject_Impl& other, | |
| 32 | ✗ | Model_Impl* model, bool keepHandle) | |
| 33 | ✗ | : ModelObject_Impl(other, model, keepHandle) { | |
| 34 | ✗ | OS_ASSERT(other.iddObject().type() == RefrigerationSubcoolerMechanical::iddObjectType()); | |
| 35 | ✗ | } | |
| 36 | |||
| 37 | 18 | RefrigerationSubcoolerMechanical_Impl::RefrigerationSubcoolerMechanical_Impl(const RefrigerationSubcoolerMechanical_Impl& other, | |
| 38 | 18 | Model_Impl* model, bool keepHandle) | |
| 39 | 18 | : ModelObject_Impl(other, model, keepHandle) {} | |
| 40 | |||
| 41 | ✗ | const std::vector<std::string>& RefrigerationSubcoolerMechanical_Impl::outputVariableNames() const { | |
| 42 | static const std::vector<std::string> result{// TODO: implement checks | ||
| 43 | // FOR SUBCOOLERS ON SYSTEMS SERVING CASES AND/OR WALKINS: | ||
| 44 | "Refrigeration System Mechanical Subcooler Heat Transfer Rate", | ||
| 45 | "Refrigeration System Mechanical Subcooler Heat Transfer Energy", | ||
| 46 | // FOR SUBCOOLERS ON SYSTEMS SERVING AIR CHILLERS: | ||
| 47 | "Refrigeration Air Chiller System Mechanical Subcooler Heat Transfer Rate", | ||
| 48 | ✗ | "Refrigeration Air Chiller System Mechanical Subcooler Heat Transfer Energy"}; | |
| 49 | ✗ | return result; | |
| 50 | ✗ | } | |
| 51 | |||
| 52 | ✗ | IddObjectType RefrigerationSubcoolerMechanical_Impl::iddObjectType() const { | |
| 53 | ✗ | return RefrigerationSubcoolerMechanical::iddObjectType(); | |
| 54 | } | ||
| 55 | |||
| 56 | 9 | ModelObject RefrigerationSubcoolerMechanical_Impl::clone(Model model) const { | |
| 57 |
3/3✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
|
9 | auto modelObjectClone = ModelObject_Impl::clone(model).cast<RefrigerationSubcoolerMechanical>(); |
| 58 | |||
| 59 |
1/1✓ Branch 1 taken 9 times.
|
9 | modelObjectClone.resetCapacityProvidingSystem(); |
| 60 | |||
| 61 | 18 | return std::move(modelObjectClone); | |
| 62 | 9 | } | |
| 63 | |||
| 64 | 8 | boost::optional<RefrigerationSystem> RefrigerationSubcoolerMechanical_Impl::capacityProvidingSystem() const { | |
| 65 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
|
8 | return getObject<ModelObject>().getModelObjectTarget<RefrigerationSystem>(OS_Refrigeration_Subcooler_MechanicalFields::CapacityProvidingSystem); |
| 66 | } | ||
| 67 | |||
| 68 | 6 | boost::optional<double> RefrigerationSubcoolerMechanical_Impl::outletControlTemperature() const { | |
| 69 | 6 | return getDouble(OS_Refrigeration_Subcooler_MechanicalFields::OutletControlTemperature, true); | |
| 70 | } | ||
| 71 | |||
| 72 | 5 | bool RefrigerationSubcoolerMechanical_Impl::setCapacityProvidingSystem(const boost::optional<RefrigerationSystem>& refrigerationSystem) { | |
| 73 | 5 | bool result(false); | |
| 74 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | if (refrigerationSystem) { |
| 75 |
3/3✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
|
5 | result = setPointer(OS_Refrigeration_Subcooler_MechanicalFields::CapacityProvidingSystem, refrigerationSystem.get().handle()); |
| 76 | } else { | ||
| 77 | ✗ | resetCapacityProvidingSystem(); | |
| 78 | ✗ | result = true; | |
| 79 | } | ||
| 80 | 5 | return result; | |
| 81 | } | ||
| 82 | |||
| 83 | 9 | void RefrigerationSubcoolerMechanical_Impl::resetCapacityProvidingSystem() { | |
| 84 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
18 | bool result = setString(OS_Refrigeration_Subcooler_MechanicalFields::CapacityProvidingSystem, ""); |
| 85 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | OS_ASSERT(result); |
| 86 | 9 | } | |
| 87 | |||
| 88 | 17 | bool RefrigerationSubcoolerMechanical_Impl::setOutletControlTemperature(boost::optional<double> outletControlTemperature) { | |
| 89 | 17 | bool result(false); | |
| 90 |
1/2✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
|
17 | if (outletControlTemperature) { |
| 91 | 17 | result = setDouble(OS_Refrigeration_Subcooler_MechanicalFields::OutletControlTemperature, outletControlTemperature.get()); | |
| 92 | } else { | ||
| 93 | ✗ | resetOutletControlTemperature(); | |
| 94 | ✗ | result = true; | |
| 95 | } | ||
| 96 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
|
17 | OS_ASSERT(result); |
| 97 | 17 | return result; | |
| 98 | } | ||
| 99 | |||
| 100 | ✗ | void RefrigerationSubcoolerMechanical_Impl::resetOutletControlTemperature() { | |
| 101 | ✗ | bool result = setString(OS_Refrigeration_Subcooler_MechanicalFields::OutletControlTemperature, ""); | |
| 102 | ✗ | OS_ASSERT(result); | |
| 103 | ✗ | } | |
| 104 | |||
| 105 | 16 | boost::optional<RefrigerationSystem> RefrigerationSubcoolerMechanical_Impl::system() const { | |
| 106 | |||
| 107 | 16 | boost::optional<RefrigerationSystem> system; | |
| 108 | // We use getModelObjectSources to check if more than one | ||
| 109 | std::vector<RefrigerationSystem> systems = | ||
| 110 |
3/3✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 7 taken 16 times.
|
16 | getObject<ModelObject>().getModelObjectSources<RefrigerationSystem>(RefrigerationSystem::iddObjectType()); |
| 111 | |||
| 112 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 2 taken 11 times.
|
16 | if (!systems.empty()) { |
| 113 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
|
5 | if (systems.size() > 1u) { |
| 114 | ✗ | LOG(Error, briefDescription() << " is referenced by more than one RefrigerationSystem, returning the first"); | |
| 115 | } | ||
| 116 |
1/1✓ Branch 2 taken 5 times.
|
5 | system = systems[0]; |
| 117 | } | ||
| 118 | 32 | return system; | |
| 119 | 16 | } | |
| 120 | |||
| 121 | } // namespace detail | ||
| 122 | |||
| 123 | 14 | RefrigerationSubcoolerMechanical::RefrigerationSubcoolerMechanical(const Model& model) | |
| 124 | 14 | : ModelObject(RefrigerationSubcoolerMechanical::iddObjectType(), model) { | |
| 125 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✗ Branch 5 not taken.
|
14 | OS_ASSERT(getImpl<detail::RefrigerationSubcoolerMechanical_Impl>()); |
| 126 | |||
| 127 |
1/1✓ Branch 1 taken 14 times.
|
14 | setOutletControlTemperature(10.0); |
| 128 | 14 | } | |
| 129 | |||
| 130 | 7769 | IddObjectType RefrigerationSubcoolerMechanical::iddObjectType() { | |
| 131 |
1/1✓ Branch 1 taken 7769 times.
|
7769 | return {IddObjectType::OS_Refrigeration_Subcooler_Mechanical}; |
| 132 | } | ||
| 133 | |||
| 134 | 8 | boost::optional<RefrigerationSystem> RefrigerationSubcoolerMechanical::capacityProvidingSystem() const { | |
| 135 |
1/1✓ Branch 3 taken 8 times.
|
8 | return getImpl<detail::RefrigerationSubcoolerMechanical_Impl>()->capacityProvidingSystem(); |
| 136 | } | ||
| 137 | |||
| 138 | 6 | boost::optional<double> RefrigerationSubcoolerMechanical::outletControlTemperature() const { | |
| 139 |
1/1✓ Branch 3 taken 6 times.
|
6 | return getImpl<detail::RefrigerationSubcoolerMechanical_Impl>()->outletControlTemperature(); |
| 140 | } | ||
| 141 | |||
| 142 | 5 | bool RefrigerationSubcoolerMechanical::setCapacityProvidingSystem(const RefrigerationSystem& refrigerationSystem) { | |
| 143 |
2/2✓ Branch 3 taken 5 times.
✓ Branch 6 taken 5 times.
|
5 | return getImpl<detail::RefrigerationSubcoolerMechanical_Impl>()->setCapacityProvidingSystem(refrigerationSystem); |
| 144 | } | ||
| 145 | |||
| 146 | 9 | void RefrigerationSubcoolerMechanical::resetCapacityProvidingSystem() { | |
| 147 |
1/1✓ Branch 3 taken 9 times.
|
9 | getImpl<detail::RefrigerationSubcoolerMechanical_Impl>()->resetCapacityProvidingSystem(); |
| 148 | 9 | } | |
| 149 | |||
| 150 | 17 | bool RefrigerationSubcoolerMechanical::setOutletControlTemperature(double outletControlTemperature) { | |
| 151 |
2/2✓ Branch 3 taken 17 times.
✓ Branch 6 taken 17 times.
|
17 | return getImpl<detail::RefrigerationSubcoolerMechanical_Impl>()->setOutletControlTemperature(outletControlTemperature); |
| 152 | } | ||
| 153 | |||
| 154 | ✗ | void RefrigerationSubcoolerMechanical::resetOutletControlTemperature() { | |
| 155 | ✗ | getImpl<detail::RefrigerationSubcoolerMechanical_Impl>()->resetOutletControlTemperature(); | |
| 156 | ✗ | } | |
| 157 | |||
| 158 | 16 | boost::optional<RefrigerationSystem> RefrigerationSubcoolerMechanical::system() const { | |
| 159 |
1/1✓ Branch 3 taken 16 times.
|
16 | return getImpl<detail::RefrigerationSubcoolerMechanical_Impl>()->system(); |
| 160 | } | ||
| 161 | |||
| 162 | /// @cond | ||
| 163 | 46 | RefrigerationSubcoolerMechanical::RefrigerationSubcoolerMechanical(std::shared_ptr<detail::RefrigerationSubcoolerMechanical_Impl> impl) | |
| 164 |
1/1✓ Branch 3 taken 46 times.
|
46 | : ModelObject(std::move(impl)) {} |
| 165 | /// @endcond | ||
| 166 | |||
| 167 | } // namespace model | ||
| 168 | } // namespace openstudio | ||
| 169 |