src/model/CoilHeatingGasMultiStage.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 "Model.hpp" | ||
| 7 | #include "Model_Impl.hpp" | ||
| 8 | #include "CoilHeatingGasMultiStage.hpp" | ||
| 9 | #include "CoilHeatingGasMultiStage_Impl.hpp" | ||
| 10 | #include "Schedule.hpp" | ||
| 11 | #include "Schedule_Impl.hpp" | ||
| 12 | #include "Curve.hpp" | ||
| 13 | #include "Curve_Impl.hpp" | ||
| 14 | #include "CoilHeatingGasMultiStageStageData.hpp" | ||
| 15 | #include "CoilHeatingGasMultiStageStageData_Impl.hpp" | ||
| 16 | #include "AirLoopHVACUnitarySystem.hpp" | ||
| 17 | #include "AirLoopHVACUnitarySystem_Impl.hpp" | ||
| 18 | #include "AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed.hpp" | ||
| 19 | #include "AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed_Impl.hpp" | ||
| 20 | #include "ScheduleTypeLimits.hpp" | ||
| 21 | #include "ScheduleTypeRegistry.hpp" | ||
| 22 | |||
| 23 | #include <utilities/idd/OS_Coil_Heating_Gas_MultiStage_FieldEnums.hxx> | ||
| 24 | #include <utilities/idd/IddEnums.hxx> | ||
| 25 | #include "../utilities/core/Assert.hpp" | ||
| 26 | #include "../utilities/data/DataEnums.hpp" | ||
| 27 | #include "../utilities/idf/WorkspaceExtensibleGroup.hpp" | ||
| 28 | |||
| 29 | #include "../utilities/core/DeprecatedHelpers.hpp" // For deprecation | ||
| 30 | |||
| 31 | namespace openstudio { | ||
| 32 | namespace model { | ||
| 33 | |||
| 34 | namespace detail { | ||
| 35 | |||
| 36 | 13 | CoilHeatingGasMultiStage_Impl::CoilHeatingGasMultiStage_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 37 | 13 | : StraightComponent_Impl(idfObject, model, keepHandle) { | |
| 38 |
4/6✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
✓ Branch 7 taken 13 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 13 times.
✗ Branch 13 not taken.
|
13 | OS_ASSERT(idfObject.iddObject().type() == CoilHeatingGasMultiStage::iddObjectType()); |
| 39 | 13 | } | |
| 40 | |||
| 41 | 2 | CoilHeatingGasMultiStage_Impl::CoilHeatingGasMultiStage_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, | |
| 42 | 2 | bool keepHandle) | |
| 43 | 2 | : StraightComponent_Impl(other, model, keepHandle) { | |
| 44 |
4/6✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 13 not taken.
|
2 | OS_ASSERT(other.iddObject().type() == CoilHeatingGasMultiStage::iddObjectType()); |
| 45 | 2 | } | |
| 46 | |||
| 47 | 8 | CoilHeatingGasMultiStage_Impl::CoilHeatingGasMultiStage_Impl(const CoilHeatingGasMultiStage_Impl& other, Model_Impl* model, bool keepHandle) | |
| 48 | 8 | : StraightComponent_Impl(other, model, keepHandle) {} | |
| 49 | |||
| 50 | ✗ | const std::vector<std::string>& CoilHeatingGasMultiStage_Impl::outputVariableNames() const { | |
| 51 | static const std::vector<std::string> result{"Heating Coil Heating Energy", | ||
| 52 | "Heating Coil Heating Rate", | ||
| 53 | "Heating Coil Gas Consumption", | ||
| 54 | "Heating Coil Gas Consumption Rate", | ||
| 55 | "Heating Coil Electric Consumption", | ||
| 56 | "Heating Coil Electricity Rate", | ||
| 57 | "Heating Coil Runtime Fraction", | ||
| 58 | "Heating Coil Parasitic Gas Consumption", | ||
| 59 | ✗ | "Heating Coil Parasitic Gas Consumption Rate"}; | |
| 60 | ✗ | return result; | |
| 61 | ✗ | } | |
| 62 | |||
| 63 | 6 | IddObjectType CoilHeatingGasMultiStage_Impl::iddObjectType() const { | |
| 64 | 6 | return CoilHeatingGasMultiStage::iddObjectType(); | |
| 65 | } | ||
| 66 | |||
| 67 | ✗ | std::vector<ScheduleTypeKey> CoilHeatingGasMultiStage_Impl::getScheduleTypeKeys(const Schedule& schedule) const { | |
| 68 | ✗ | std::vector<ScheduleTypeKey> result; | |
| 69 | ✗ | UnsignedVector fieldIndices = getSourceIndices(schedule.handle()); | |
| 70 | ✗ | UnsignedVector::const_iterator b(fieldIndices.begin()); | |
| 71 | ✗ | UnsignedVector::const_iterator e(fieldIndices.end()); | |
| 72 | ✗ | if (std::find(b, e, OS_Coil_Heating_Gas_MultiStageFields::AvailabilitySchedule) != e) { | |
| 73 | ✗ | result.emplace_back("CoilHeatingGasMultiStage", "Availability Schedule"); | |
| 74 | } | ||
| 75 | ✗ | return result; | |
| 76 | ✗ | } | |
| 77 | |||
| 78 | 6 | unsigned CoilHeatingGasMultiStage_Impl::inletPort() const { | |
| 79 | 6 | return OS_Coil_Heating_Gas_MultiStageFields::AirInletNode; | |
| 80 | } | ||
| 81 | |||
| 82 | 6 | unsigned CoilHeatingGasMultiStage_Impl::outletPort() const { | |
| 83 | 6 | return OS_Coil_Heating_Gas_MultiStageFields::AirOutletNode; | |
| 84 | } | ||
| 85 | |||
| 86 | 2 | ModelObject CoilHeatingGasMultiStage_Impl::clone(Model model) const { | |
| 87 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | auto t_clone = StraightComponent_Impl::clone(model).cast<CoilHeatingGasMultiStage>(); |
| 88 | |||
| 89 | // Deal with the stages: we want them cloned, so first clear and then clone + assign each | ||
| 90 |
1/1✓ Branch 1 taken 2 times.
|
2 | t_clone.removeAllStages(); |
| 91 | |||
| 92 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 8 taken 4 times.
✓ Branch 9 taken 2 times.
|
6 | for (const auto& stage : stages()) { |
| 93 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | auto stageClone = stage.clone(model).cast<CoilHeatingGasMultiStageStageData>(); |
| 94 |
1/1✓ Branch 1 taken 4 times.
|
4 | t_clone.addStage(stageClone); |
| 95 | 6 | } | |
| 96 | 4 | return std::move(t_clone); | |
| 97 | 2 | } | |
| 98 | |||
| 99 | 8 | std::vector<ModelObject> CoilHeatingGasMultiStage_Impl::children() const { | |
| 100 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
|
8 | std::vector<ModelObject> result = subsetCastVector<ModelObject>(stages()); |
| 101 | |||
| 102 |
3/3✓ Branch 1 taken 8 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 6 times.
|
16 | if (auto const curve = partLoadFractionCorrelationCurve()) { |
| 103 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | result.push_back(curve.get()); |
| 104 | 8 | } | |
| 105 | |||
| 106 | 8 | return result; | |
| 107 | ✗ | } | |
| 108 | |||
| 109 | 4 | boost::optional<HVACComponent> CoilHeatingGasMultiStage_Impl::containingHVACComponent() const { | |
| 110 | // AirLoopHVACUnitarySystem | ||
| 111 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | std::vector<AirLoopHVACUnitarySystem> airLoopHVACUnitarySystems = this->model().getConcreteModelObjects<AirLoopHVACUnitarySystem>(); |
| 112 | |||
| 113 |
1/2✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
|
4 | for (const auto& airLoopHVACUnitarySystem : airLoopHVACUnitarySystems) { |
| 114 | ✗ | if (boost::optional<HVACComponent> heatingCoil = airLoopHVACUnitarySystem.heatingCoil()) { | |
| 115 | ✗ | if (heatingCoil->handle() == this->handle()) { | |
| 116 | ✗ | return airLoopHVACUnitarySystem; | |
| 117 | } | ||
| 118 | ✗ | } | |
| 119 | } | ||
| 120 | |||
| 121 | // AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed | ||
| 122 | std::vector<AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed> airLoopHVACUnitaryHeatPumpAirToAirMultiSpeeds = | ||
| 123 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | this->model().getConcreteModelObjects<AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed>(); |
| 124 | |||
| 125 |
1/2✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
|
4 | for (const auto& airLoopHVACUnitaryHeatPumpAirToAirMultiSpeed : airLoopHVACUnitaryHeatPumpAirToAirMultiSpeeds) { |
| 126 | ✗ | if (boost::optional<HVACComponent> heatingCoil = airLoopHVACUnitaryHeatPumpAirToAirMultiSpeed.heatingCoil()) { | |
| 127 | ✗ | if (heatingCoil->handle() == this->handle()) { | |
| 128 | ✗ | return airLoopHVACUnitaryHeatPumpAirToAirMultiSpeed; | |
| 129 | } | ||
| 130 | ✗ | } | |
| 131 | } | ||
| 132 | |||
| 133 | 4 | return boost::none; | |
| 134 | 4 | } | |
| 135 | |||
| 136 | 1 | bool CoilHeatingGasMultiStage_Impl::addToNode(Node& node) { | |
| 137 | 1 | return false; | |
| 138 | } | ||
| 139 | |||
| 140 | 6 | boost::optional<Schedule> CoilHeatingGasMultiStage_Impl::optionalAvailabilitySchedule() const { | |
| 141 |
2/2✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
|
6 | return getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_Coil_Heating_Gas_MultiStageFields::AvailabilitySchedule); |
| 142 | } | ||
| 143 | |||
| 144 | 6 | Schedule CoilHeatingGasMultiStage_Impl::availabilitySchedule() const { | |
| 145 |
1/1✓ Branch 1 taken 6 times.
|
6 | boost::optional<Schedule> value = optionalAvailabilitySchedule(); |
| 146 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
|
6 | if (!value) { |
| 147 | // it is an error if we get here, however we don't want to crash | ||
| 148 | // so we hook up to global always on schedule | ||
| 149 | ✗ | LOG(Error, "Required availability schedule not set, using 'Always On' schedule"); | |
| 150 | ✗ | value = this->model().alwaysOnDiscreteSchedule(); | |
| 151 | ✗ | OS_ASSERT(value); | |
| 152 | ✗ | const_cast<CoilHeatingGasMultiStage_Impl*>(this)->setAvailabilitySchedule(*value); | |
| 153 | ✗ | value = optionalAvailabilitySchedule(); | |
| 154 | } | ||
| 155 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 4 not taken.
|
6 | OS_ASSERT(value); |
| 156 |
2/2✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
|
12 | return value.get(); |
| 157 | 6 | } | |
| 158 | |||
| 159 | 16 | boost::optional<Curve> CoilHeatingGasMultiStage_Impl::partLoadFractionCorrelationCurve() const { | |
| 160 |
2/2✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
|
16 | return getObject<ModelObject>().getModelObjectTarget<Curve>(OS_Coil_Heating_Gas_MultiStageFields::PartLoadFractionCorrelationCurve); |
| 161 | } | ||
| 162 | |||
| 163 | 8 | boost::optional<double> CoilHeatingGasMultiStage_Impl::offCycleParasiticGasLoad() const { | |
| 164 | 8 | return getDouble(OS_Coil_Heating_Gas_MultiStageFields::OffCycleParasiticGasLoad, true); | |
| 165 | } | ||
| 166 | |||
| 167 | 14 | bool CoilHeatingGasMultiStage_Impl::setAvailabilitySchedule(Schedule& schedule) { | |
| 168 | bool result = | ||
| 169 |
3/3✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
✓ Branch 7 taken 14 times.
|
56 | setSchedule(OS_Coil_Heating_Gas_MultiStageFields::AvailabilitySchedule, "CoilHeatingGasMultiStage", "Availability Schedule", schedule); |
| 170 | 14 | return result; | |
| 171 | } | ||
| 172 | |||
| 173 | 3 | bool CoilHeatingGasMultiStage_Impl::setPartLoadFractionCorrelationCurve(const boost::optional<Curve>& curve) { | |
| 174 | 3 | bool result(false); | |
| 175 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if (curve) { |
| 176 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
|
3 | result = setPointer(OS_Coil_Heating_Gas_MultiStageFields::PartLoadFractionCorrelationCurve, curve.get().handle()); |
| 177 | } else { | ||
| 178 | ✗ | resetPartLoadFractionCorrelationCurve(); | |
| 179 | ✗ | result = true; | |
| 180 | } | ||
| 181 | 3 | return result; | |
| 182 | } | ||
| 183 | |||
| 184 | 1 | void CoilHeatingGasMultiStage_Impl::resetPartLoadFractionCorrelationCurve() { | |
| 185 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | bool result = setString(OS_Coil_Heating_Gas_MultiStageFields::PartLoadFractionCorrelationCurve, ""); |
| 186 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | OS_ASSERT(result); |
| 187 | 1 | } | |
| 188 | |||
| 189 | 3 | bool CoilHeatingGasMultiStage_Impl::setOffCycleParasiticGasLoad(double offCycleParasiticGasLoad) { | |
| 190 | 3 | bool result = setDouble(OS_Coil_Heating_Gas_MultiStageFields::OffCycleParasiticGasLoad, offCycleParasiticGasLoad); | |
| 191 | 3 | return result; | |
| 192 | } | ||
| 193 | |||
| 194 | 1 | void CoilHeatingGasMultiStage_Impl::resetOffCycleParasiticGasLoad() { | |
| 195 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | bool result = setString(OS_Coil_Heating_Gas_MultiStageFields::OffCycleParasiticGasLoad, ""); |
| 196 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | OS_ASSERT(result); |
| 197 | 1 | } | |
| 198 | |||
| 199 | 25 | unsigned CoilHeatingGasMultiStage_Impl::numberOfStages() const { | |
| 200 | 25 | return numExtensibleGroups(); | |
| 201 | } | ||
| 202 | |||
| 203 | 44 | std::vector<CoilHeatingGasMultiStageStageData> CoilHeatingGasMultiStage_Impl::stages() const { | |
| 204 | 44 | std::vector<CoilHeatingGasMultiStageStageData> result; | |
| 205 |
3/3✓ Branch 1 taken 44 times.
✓ Branch 8 taken 85 times.
✓ Branch 9 taken 44 times.
|
129 | for (const auto& group : extensibleGroups()) { |
| 206 |
3/4✓ Branch 1 taken 85 times.
✓ Branch 4 taken 85 times.
✓ Branch 8 taken 85 times.
✗ Branch 9 not taken.
|
170 | if (auto target = group.cast<WorkspaceExtensibleGroup>().getTarget(OS_Coil_Heating_Gas_MultiStageExtensibleFields::Stage)) { |
| 207 |
3/4✓ Branch 1 taken 85 times.
✓ Branch 4 taken 85 times.
✓ Branch 6 taken 85 times.
✗ Branch 7 not taken.
|
170 | if (auto stage = target->optionalCast<CoilHeatingGasMultiStageStageData>()) { |
| 208 |
2/2✓ Branch 1 taken 85 times.
✓ Branch 4 taken 85 times.
|
85 | result.push_back(stage.get()); |
| 209 | 85 | } | |
| 210 | 85 | } | |
| 211 | 44 | } | |
| 212 | 44 | return result; | |
| 213 | ✗ | } | |
| 214 | |||
| 215 | 7 | boost::optional<unsigned> CoilHeatingGasMultiStage_Impl::stageIndex(const CoilHeatingGasMultiStageStageData& stage) const { | |
| 216 | |||
| 217 | 7 | boost::optional<unsigned> result; | |
| 218 | |||
| 219 |
2/2✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
|
7 | auto egs = castVector<WorkspaceExtensibleGroup>(extensibleGroups()); |
| 220 |
2/2✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
|
7 | auto h = openstudio::toString(stage.handle()); |
| 221 |
1/1✓ Branch 3 taken 7 times.
|
7 | auto it = std::find_if(egs.begin(), egs.end(), [&](const WorkspaceExtensibleGroup& eg) { |
| 222 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | return (eg.getField(OS_Coil_Heating_Gas_MultiStageExtensibleFields::Stage).get() == h); |
| 223 | }); | ||
| 224 | |||
| 225 | // If found, we compute the index by using std::distance between the start of vector and the iterator returned by std::find_if | ||
| 226 |
2/2✓ Branch 2 taken 6 times.
✓ Branch 3 taken 1 time.
|
7 | if (it != egs.end()) { |
| 227 |
1/1✓ Branch 2 taken 6 times.
|
12 | result = std::distance(egs.begin(), it) + 1; |
| 228 | } | ||
| 229 | |||
| 230 | 7 | return result; | |
| 231 | 7 | } | |
| 232 | |||
| 233 | 27 | bool CoilHeatingGasMultiStage_Impl::addStage(const CoilHeatingGasMultiStageStageData& stage) { | |
| 234 |
2/3✓ Branch 1 taken 27 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27 times.
|
54 | if (auto _c = stage.parentCoil()) { |
| 235 | ✗ | if (this->handle() == _c->handle()) { | |
| 236 | ✗ | return true; // already the case | |
| 237 | } else { | ||
| 238 | ✗ | LOG(Error, "For " << briefDescription() << " cannot add " << stage.briefDescription() | |
| 239 | << " since this Stage is already in use by another coil ('" << _c->nameString() << "')."); | ||
| 240 | ✗ | return false; | |
| 241 | } | ||
| 242 | 27 | } | |
| 243 |
3/3✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
✓ Branch 7 taken 27 times.
|
27 | auto group = getObject<ModelObject>().pushExtensibleGroup().cast<WorkspaceExtensibleGroup>(); |
| 244 |
3/3✓ Branch 1 taken 27 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 25 times.
|
27 | if (group.empty()) { |
| 245 |
11/11✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 22 taken 2 times.
✓ Branch 26 taken 2 times.
✓ Branch 29 taken 2 times.
✓ Branch 32 taken 2 times.
|
2 | LOG(Error, "You have reached the maximum number of stages (=" << numberOfStages() << "), occurred for " << briefDescription() << "."); |
| 246 | 2 | return false; | |
| 247 | } | ||
| 248 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
|
25 | bool result = group.setPointer(OS_Coil_Heating_Gas_MultiStageExtensibleFields::Stage, stage.handle()); |
| 249 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 24 times.
|
25 | if (!result) { |
| 250 | // Something went wrong, so erase the new extensible group | ||
| 251 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | getObject<ModelObject>().eraseExtensibleGroup(group.groupIndex()); |
| 252 | } | ||
| 253 | 25 | return result; | |
| 254 | 27 | } | |
| 255 | |||
| 256 | 1 | bool CoilHeatingGasMultiStage_Impl::setStageIndex(const CoilHeatingGasMultiStageStageData& stage, unsigned index) { | |
| 257 |
1/1✓ Branch 1 taken 1 time.
|
1 | boost::optional<unsigned> idx = stageIndex(stage); |
| 258 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (!idx) { |
| 259 | ✗ | LOG(Warn, "For " << briefDescription() << " cannot set the index of stage " << stage.briefDescription() << " since it is not part of it."); | |
| 260 | ✗ | return false; | |
| 261 | } | ||
| 262 | |||
| 263 | // TODO: we could just set via string instead of doing a ton of typechecking below... | ||
| 264 | |||
| 265 |
1/1✓ Branch 1 taken 1 time.
|
1 | std::vector<CoilHeatingGasMultiStageStageData> stageVector = stages(); |
| 266 | |||
| 267 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (index > stageVector.size()) { |
| 268 | ✗ | LOG(Warn, "Requested a stage index of " << index << " to be assigned to " << stage.briefDescription() << ", but " << briefDescription() | |
| 269 | << " only has " << stageVector.size() << " stages, resetting to that."); | ||
| 270 | ✗ | index = stageVector.size(); | |
| 271 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | } else if (index < 1) { |
| 272 | ✗ | LOG(Warn, "Requested a stage index of " << index << " < 1 to be assigned to " << stage.briefDescription() << ", resetting to 1"); | |
| 273 | ✗ | index = 1; | |
| 274 | } | ||
| 275 | |||
| 276 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 8 taken 1 time.
|
1 | stageVector.erase(stageVector.begin() + idx.get() - 1); // stageIndex is 1-indexed, and vector is 0-indexed |
| 277 | |||
| 278 |
1/1✓ Branch 4 taken 1 time.
|
1 | stageVector.insert(stageVector.begin() + (index - 1), stage); |
| 279 | |||
| 280 |
1/1✓ Branch 1 taken 1 time.
|
1 | return setStages(stageVector); |
| 281 | 1 | } | |
| 282 | |||
| 283 | ✗ | bool CoilHeatingGasMultiStage_Impl::addStage(const CoilHeatingGasMultiStageStageData& stage, unsigned index) { | |
| 284 | ✗ | bool ok = addStage(stage); | |
| 285 | ✗ | if (!ok) { | |
| 286 | ✗ | return false; | |
| 287 | } | ||
| 288 | ✗ | ok = setStageIndex(stage, index); | |
| 289 | ✗ | return ok; | |
| 290 | } | ||
| 291 | |||
| 292 | 4 | bool CoilHeatingGasMultiStage_Impl::setStages(const std::vector<CoilHeatingGasMultiStageStageData>& stages) { | |
| 293 | // Clear the extensible groups, and redo them | ||
| 294 | 4 | bool ok = true; | |
| 295 |
1/1✓ Branch 1 taken 4 times.
|
4 | clearExtensibleGroups(); |
| 296 |
2/2✓ Branch 4 taken 13 times.
✓ Branch 5 taken 4 times.
|
17 | for (const CoilHeatingGasMultiStageStageData& s : stages) { |
| 297 |
1/1✓ Branch 1 taken 13 times.
|
13 | ok &= addStage(s); |
| 298 | } | ||
| 299 | 4 | return ok; | |
| 300 | } | ||
| 301 | |||
| 302 | 5 | void CoilHeatingGasMultiStage_Impl::removeAllStages() { | |
| 303 |
1/1✓ Branch 1 taken 5 times.
|
5 | clearExtensibleGroups(); |
| 304 | 5 | } | |
| 305 | |||
| 306 | 2 | bool CoilHeatingGasMultiStage_Impl::removeStage(const CoilHeatingGasMultiStageStageData& stage) { | |
| 307 |
1/1✓ Branch 1 taken 2 times.
|
2 | boost::optional<unsigned> idx = stageIndex(stage); |
| 308 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 2 taken 1 time.
|
2 | if (!idx) { |
| 309 |
11/11✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 27 taken 1 time.
✓ Branch 30 taken 1 time.
✓ Branch 33 taken 1 time.
|
1 | LOG(Warn, "For " << briefDescription() << " cannot remove stage " << stage.briefDescription() << " since it is not part of it."); |
| 310 | 1 | return false; | |
| 311 | } | ||
| 312 | |||
| 313 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | return removeStage(idx.get()); |
| 314 | } | ||
| 315 | |||
| 316 | 2 | bool CoilHeatingGasMultiStage_Impl::removeStage(unsigned index) { | |
| 317 | 2 | bool result = false; | |
| 318 |
3/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
|
2 | if ((index > 0) && (index <= numberOfStages())) { |
| 319 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | getObject<ModelObject>().eraseExtensibleGroup(index - 1); |
| 320 | 2 | result = true; | |
| 321 | } | ||
| 322 | 2 | return result; | |
| 323 | } | ||
| 324 | |||
| 325 | ✗ | ComponentType CoilHeatingGasMultiStage_Impl::componentType() const { | |
| 326 | ✗ | return ComponentType::Heating; | |
| 327 | } | ||
| 328 | |||
| 329 | ✗ | std::vector<FuelType> CoilHeatingGasMultiStage_Impl::coolingFuelTypes() const { | |
| 330 | ✗ | return {}; | |
| 331 | } | ||
| 332 | |||
| 333 | ✗ | std::vector<FuelType> CoilHeatingGasMultiStage_Impl::heatingFuelTypes() const { | |
| 334 | ✗ | return {FuelType::Gas}; | |
| 335 | } | ||
| 336 | |||
| 337 | ✗ | std::vector<AppGFuelType> CoilHeatingGasMultiStage_Impl::appGHeatingFuelTypes() const { | |
| 338 | ✗ | return {AppGFuelType::Fuel}; | |
| 339 | } | ||
| 340 | |||
| 341 | } // namespace detail | ||
| 342 | |||
| 343 | 11 | CoilHeatingGasMultiStage::CoilHeatingGasMultiStage(const Model& model) : StraightComponent(CoilHeatingGasMultiStage::iddObjectType(), model) { | |
| 344 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✗ Branch 5 not taken.
|
11 | OS_ASSERT(getImpl<detail::CoilHeatingGasMultiStage_Impl>()); |
| 345 | |||
| 346 |
1/1✓ Branch 1 taken 11 times.
|
11 | auto always_on = model.alwaysOnDiscreteSchedule(); |
| 347 |
1/1✓ Branch 1 taken 11 times.
|
11 | bool ok = setAvailabilitySchedule(always_on); |
| 348 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 3 not taken.
|
11 | OS_ASSERT(ok); |
| 349 | 11 | } | |
| 350 | |||
| 351 | 7819 | IddObjectType CoilHeatingGasMultiStage::iddObjectType() { | |
| 352 |
1/1✓ Branch 1 taken 7819 times.
|
7819 | return {IddObjectType::OS_Coil_Heating_Gas_MultiStage}; |
| 353 | } | ||
| 354 | |||
| 355 | 6 | Schedule CoilHeatingGasMultiStage::availabilitySchedule() const { | |
| 356 |
1/1✓ Branch 3 taken 6 times.
|
6 | return getImpl<detail::CoilHeatingGasMultiStage_Impl>()->availabilitySchedule(); |
| 357 | } | ||
| 358 | |||
| 359 | 8 | boost::optional<Curve> CoilHeatingGasMultiStage::partLoadFractionCorrelationCurve() const { | |
| 360 |
1/1✓ Branch 3 taken 8 times.
|
8 | return getImpl<detail::CoilHeatingGasMultiStage_Impl>()->partLoadFractionCorrelationCurve(); |
| 361 | } | ||
| 362 | |||
| 363 | // DEPRECATED | ||
| 364 | ✗ | boost::optional<double> CoilHeatingGasMultiStage::parasiticGasLoad() const { | |
| 365 | ✗ | DEPRECATED_AT_MSG(3, 7, 0, "Use offCycleParasiticGasLoad instead."); | |
| 366 | ✗ | return getImpl<detail::CoilHeatingGasMultiStage_Impl>()->offCycleParasiticGasLoad(); | |
| 367 | } | ||
| 368 | |||
| 369 | 8 | boost::optional<double> CoilHeatingGasMultiStage::offCycleParasiticGasLoad() const { | |
| 370 |
1/1✓ Branch 3 taken 8 times.
|
8 | return getImpl<detail::CoilHeatingGasMultiStage_Impl>()->offCycleParasiticGasLoad(); |
| 371 | } | ||
| 372 | |||
| 373 | 14 | bool CoilHeatingGasMultiStage::setAvailabilitySchedule(Schedule& schedule) { | |
| 374 |
1/1✓ Branch 3 taken 14 times.
|
14 | return getImpl<detail::CoilHeatingGasMultiStage_Impl>()->setAvailabilitySchedule(schedule); |
| 375 | } | ||
| 376 | |||
| 377 | 3 | bool CoilHeatingGasMultiStage::setPartLoadFractionCorrelationCurve(const Curve& curve) { | |
| 378 |
2/2✓ Branch 3 taken 3 times.
✓ Branch 6 taken 3 times.
|
3 | return getImpl<detail::CoilHeatingGasMultiStage_Impl>()->setPartLoadFractionCorrelationCurve(curve); |
| 379 | } | ||
| 380 | |||
| 381 | 1 | void CoilHeatingGasMultiStage::resetPartLoadFractionCorrelationCurve() { | |
| 382 |
1/1✓ Branch 3 taken 1 time.
|
1 | getImpl<detail::CoilHeatingGasMultiStage_Impl>()->resetPartLoadFractionCorrelationCurve(); |
| 383 | 1 | } | |
| 384 | |||
| 385 | // DEPRECATED | ||
| 386 | 2 | bool CoilHeatingGasMultiStage::setParasiticGasLoad(double parasiticGasLoad) { | |
| 387 |
5/5✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
|
8 | DEPRECATED_AT_MSG(3, 7, 0, "Use setOffCycleParasiticGasLoad instead."); |
| 388 |
1/1✓ Branch 3 taken 2 times.
|
2 | return getImpl<detail::CoilHeatingGasMultiStage_Impl>()->setOffCycleParasiticGasLoad(parasiticGasLoad); |
| 389 | } | ||
| 390 | |||
| 391 | 1 | bool CoilHeatingGasMultiStage::setOffCycleParasiticGasLoad(double offCycleParasiticGasLoad) { | |
| 392 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::CoilHeatingGasMultiStage_Impl>()->setOffCycleParasiticGasLoad(offCycleParasiticGasLoad); |
| 393 | } | ||
| 394 | |||
| 395 | // DEPRECATED | ||
| 396 | ✗ | void CoilHeatingGasMultiStage::resetParasiticGasLoad() { | |
| 397 | ✗ | DEPRECATED_AT_MSG(3, 7, 0, "Use resetOffCycleParasiticGasLoad instead."); | |
| 398 | ✗ | getImpl<detail::CoilHeatingGasMultiStage_Impl>()->resetOffCycleParasiticGasLoad(); | |
| 399 | ✗ | } | |
| 400 | |||
| 401 | 1 | void CoilHeatingGasMultiStage::resetOffCycleParasiticGasLoad() { | |
| 402 |
1/1✓ Branch 3 taken 1 time.
|
1 | getImpl<detail::CoilHeatingGasMultiStage_Impl>()->resetOffCycleParasiticGasLoad(); |
| 403 | 1 | } | |
| 404 | |||
| 405 | 21 | unsigned CoilHeatingGasMultiStage::numberOfStages() const { | |
| 406 |
1/1✓ Branch 3 taken 21 times.
|
21 | return getImpl<detail::CoilHeatingGasMultiStage_Impl>()->numberOfStages(); |
| 407 | } | ||
| 408 | |||
| 409 | 4 | boost::optional<unsigned> CoilHeatingGasMultiStage::stageIndex(const CoilHeatingGasMultiStageStageData& stage) const { | |
| 410 |
1/1✓ Branch 3 taken 4 times.
|
4 | return getImpl<detail::CoilHeatingGasMultiStage_Impl>()->stageIndex(stage); |
| 411 | } | ||
| 412 | |||
| 413 | 33 | std::vector<CoilHeatingGasMultiStageStageData> CoilHeatingGasMultiStage::stages() const { | |
| 414 |
1/1✓ Branch 3 taken 33 times.
|
33 | return getImpl<detail::CoilHeatingGasMultiStage_Impl>()->stages(); |
| 415 | } | ||
| 416 | |||
| 417 | 14 | bool CoilHeatingGasMultiStage::addStage(const CoilHeatingGasMultiStageStageData& stage) { | |
| 418 |
1/1✓ Branch 3 taken 14 times.
|
14 | return getImpl<detail::CoilHeatingGasMultiStage_Impl>()->addStage(stage); |
| 419 | } | ||
| 420 | |||
| 421 | ✗ | bool CoilHeatingGasMultiStage::addStage(const CoilHeatingGasMultiStageStageData& stage, unsigned index) { | |
| 422 | ✗ | return getImpl<detail::CoilHeatingGasMultiStage_Impl>()->addStage(stage, index); | |
| 423 | } | ||
| 424 | |||
| 425 | 1 | bool CoilHeatingGasMultiStage::setStageIndex(const CoilHeatingGasMultiStageStageData& stage, unsigned index) { | |
| 426 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::CoilHeatingGasMultiStage_Impl>()->setStageIndex(stage, index); |
| 427 | } | ||
| 428 | |||
| 429 | 3 | bool CoilHeatingGasMultiStage::setStages(const std::vector<CoilHeatingGasMultiStageStageData>& stages) { | |
| 430 |
1/1✓ Branch 3 taken 3 times.
|
3 | return getImpl<detail::CoilHeatingGasMultiStage_Impl>()->setStages(stages); |
| 431 | } | ||
| 432 | |||
| 433 | 5 | void CoilHeatingGasMultiStage::removeAllStages() { | |
| 434 |
1/1✓ Branch 3 taken 5 times.
|
5 | getImpl<detail::CoilHeatingGasMultiStage_Impl>()->removeAllStages(); |
| 435 | 5 | } | |
| 436 | |||
| 437 | 2 | bool CoilHeatingGasMultiStage::removeStage(const CoilHeatingGasMultiStageStageData& stage) { | |
| 438 |
1/1✓ Branch 3 taken 2 times.
|
2 | return getImpl<detail::CoilHeatingGasMultiStage_Impl>()->removeStage(stage); |
| 439 | } | ||
| 440 | |||
| 441 | 1 | bool CoilHeatingGasMultiStage::removeStage(unsigned index) { | |
| 442 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::CoilHeatingGasMultiStage_Impl>()->removeStage(index); |
| 443 | } | ||
| 444 | |||
| 445 | /// @cond | ||
| 446 | 16 | CoilHeatingGasMultiStage::CoilHeatingGasMultiStage(std::shared_ptr<detail::CoilHeatingGasMultiStage_Impl> impl) | |
| 447 |
1/1✓ Branch 3 taken 16 times.
|
16 | : StraightComponent(std::move(impl)) {} |
| 448 | /// @endcond | ||
| 449 | |||
| 450 | } // namespace model | ||
| 451 | } // namespace openstudio | ||
| 452 |