src/model/AvailabilityManagerNightVentilation.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 "AvailabilityManagerNightVentilation.hpp" | ||
| 7 | #include "AvailabilityManagerNightVentilation_Impl.hpp" | ||
| 8 | #include "Schedule.hpp" | ||
| 9 | #include "Schedule_Impl.hpp" | ||
| 10 | #include "ScheduleRuleset.hpp" | ||
| 11 | #include "ScheduleRuleset_Impl.hpp" | ||
| 12 | #include "ScheduleDay.hpp" | ||
| 13 | #include "ScheduleDay_Impl.hpp" | ||
| 14 | #include "ThermalZone.hpp" | ||
| 15 | #include "ThermalZone_Impl.hpp" | ||
| 16 | #include "Model.hpp" | ||
| 17 | #include "Model_Impl.hpp" | ||
| 18 | #include "ScheduleTypeLimits.hpp" | ||
| 19 | #include "ScheduleTypeRegistry.hpp" | ||
| 20 | #include <utilities/idd/OS_AvailabilityManager_NightVentilation_FieldEnums.hxx> | ||
| 21 | #include <utilities/idd/IddEnums.hxx> | ||
| 22 | #include "../utilities/units/Unit.hpp" | ||
| 23 | #include "../utilities/core/Assert.hpp" | ||
| 24 | |||
| 25 | namespace openstudio { | ||
| 26 | namespace model { | ||
| 27 | |||
| 28 | namespace detail { | ||
| 29 | |||
| 30 | 3 | AvailabilityManagerNightVentilation_Impl::AvailabilityManagerNightVentilation_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 31 | 3 | : AvailabilityManager_Impl(idfObject, model, keepHandle) { | |
| 32 |
4/6✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 3 times.
✗ Branch 13 not taken.
|
3 | OS_ASSERT(idfObject.iddObject().type() == AvailabilityManagerNightVentilation::iddObjectType()); |
| 33 | 3 | } | |
| 34 | |||
| 35 | ✗ | AvailabilityManagerNightVentilation_Impl::AvailabilityManagerNightVentilation_Impl(const openstudio::detail::WorkspaceObject_Impl& other, | |
| 36 | ✗ | Model_Impl* model, bool keepHandle) | |
| 37 | ✗ | : AvailabilityManager_Impl(other, model, keepHandle) { | |
| 38 | ✗ | OS_ASSERT(other.iddObject().type() == AvailabilityManagerNightVentilation::iddObjectType()); | |
| 39 | ✗ | } | |
| 40 | |||
| 41 | 8 | AvailabilityManagerNightVentilation_Impl::AvailabilityManagerNightVentilation_Impl(const AvailabilityManagerNightVentilation_Impl& other, | |
| 42 | 8 | Model_Impl* model, bool keepHandle) | |
| 43 | 8 | : AvailabilityManager_Impl(other, model, keepHandle) {} | |
| 44 | |||
| 45 | ✗ | const std::vector<std::string>& AvailabilityManagerNightVentilation_Impl::outputVariableNames() const { | |
| 46 | ✗ | static const std::vector<std::string> result{"Availability Manager Night Ventilation Control Status"}; | |
| 47 | ✗ | return result; | |
| 48 | ✗ | } | |
| 49 | |||
| 50 | 2 | IddObjectType AvailabilityManagerNightVentilation_Impl::iddObjectType() const { | |
| 51 | 2 | return AvailabilityManagerNightVentilation::iddObjectType(); | |
| 52 | } | ||
| 53 | |||
| 54 | ✗ | std::vector<ScheduleTypeKey> AvailabilityManagerNightVentilation_Impl::getScheduleTypeKeys(const Schedule& schedule) const { | |
| 55 | // TODO: Check schedule display names. | ||
| 56 | ✗ | std::vector<ScheduleTypeKey> result; | |
| 57 | ✗ | UnsignedVector fieldIndices = getSourceIndices(schedule.handle()); | |
| 58 | ✗ | UnsignedVector::const_iterator b(fieldIndices.begin()); | |
| 59 | ✗ | UnsignedVector::const_iterator e(fieldIndices.end()); | |
| 60 | ✗ | if (std::find(b, e, OS_AvailabilityManager_NightVentilationFields::ApplicabilitySchedule) != e) { | |
| 61 | ✗ | result.push_back(ScheduleTypeKey("AvailabilityManagerNightVentilation", "Applicability Schedule")); | |
| 62 | } | ||
| 63 | ✗ | if (std::find(b, e, OS_AvailabilityManager_NightVentilationFields::FanSchedule) != e) { | |
| 64 | ✗ | result.push_back(ScheduleTypeKey("AvailabilityManagerNightVentilation", "Fan Schedule")); | |
| 65 | } | ||
| 66 | ✗ | if (std::find(b, e, OS_AvailabilityManager_NightVentilationFields::VentilationTemperatureSchedule) != e) { | |
| 67 | ✗ | result.push_back(ScheduleTypeKey("AvailabilityManagerNightVentilation", "Ventilation Temperature Schedule")); | |
| 68 | } | ||
| 69 | ✗ | return result; | |
| 70 | ✗ | } | |
| 71 | |||
| 72 | ✗ | Schedule AvailabilityManagerNightVentilation_Impl::applicabilitySchedule() const { | |
| 73 | ✗ | boost::optional<Schedule> value = optionalApplicabilitySchedule(); | |
| 74 | ✗ | if (!value) { | |
| 75 | ✗ | LOG_AND_THROW(briefDescription() << " does not have an Applicability Schedule attached."); | |
| 76 | } | ||
| 77 | ✗ | return value.get(); | |
| 78 | ✗ | } | |
| 79 | |||
| 80 | ✗ | boost::optional<Schedule> AvailabilityManagerNightVentilation_Impl::ventilationTemperatureSchedule() const { | |
| 81 | ✗ | return getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_AvailabilityManager_NightVentilationFields::VentilationTemperatureSchedule); | |
| 82 | } | ||
| 83 | |||
| 84 | ✗ | double AvailabilityManagerNightVentilation_Impl::ventilationTemperatureDifference() const { | |
| 85 | ✗ | boost::optional<double> value = getDouble(OS_AvailabilityManager_NightVentilationFields::VentilationTemperatureDifference, true); | |
| 86 | ✗ | OS_ASSERT(value); | |
| 87 | ✗ | return value.get(); | |
| 88 | } | ||
| 89 | |||
| 90 | ✗ | double AvailabilityManagerNightVentilation_Impl::ventilationTemperatureLowLimit() const { | |
| 91 | ✗ | boost::optional<double> value = getDouble(OS_AvailabilityManager_NightVentilationFields::VentilationTemperatureLowLimit, true); | |
| 92 | ✗ | OS_ASSERT(value); | |
| 93 | ✗ | return value.get(); | |
| 94 | } | ||
| 95 | |||
| 96 | ✗ | double AvailabilityManagerNightVentilation_Impl::nightVentingFlowFraction() const { | |
| 97 | ✗ | boost::optional<double> value = getDouble(OS_AvailabilityManager_NightVentilationFields::NightVentingFlowFraction, true); | |
| 98 | ✗ | OS_ASSERT(value); | |
| 99 | ✗ | return value.get(); | |
| 100 | } | ||
| 101 | |||
| 102 | ✗ | boost::optional<ThermalZone> AvailabilityManagerNightVentilation_Impl::controlZone() const { | |
| 103 | ✗ | return getObject<ModelObject>().getModelObjectTarget<ThermalZone>(OS_AvailabilityManager_NightVentilationFields::ControlZone); | |
| 104 | } | ||
| 105 | |||
| 106 | 3 | bool AvailabilityManagerNightVentilation_Impl::setApplicabilitySchedule(Schedule& schedule) { | |
| 107 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
|
12 | bool result = setSchedule(OS_AvailabilityManager_NightVentilationFields::ApplicabilitySchedule, "AvailabilityManagerNightVentilation", |
| 108 | "Applicability Schedule", schedule); | ||
| 109 | 3 | return result; | |
| 110 | } | ||
| 111 | |||
| 112 | ✗ | bool AvailabilityManagerNightVentilation_Impl::setVentilationTemperatureSchedule(Schedule& schedule) { | |
| 113 | ✗ | bool result = setSchedule(OS_AvailabilityManager_NightVentilationFields::VentilationTemperatureSchedule, "AvailabilityManagerNightVentilation", | |
| 114 | "Ventilation Temperature Schedule", schedule); | ||
| 115 | ✗ | return result; | |
| 116 | } | ||
| 117 | |||
| 118 | ✗ | void AvailabilityManagerNightVentilation_Impl::resetVentilationTemperatureSchedule() { | |
| 119 | ✗ | bool result = setString(OS_AvailabilityManager_NightVentilationFields::VentilationTemperatureSchedule, ""); | |
| 120 | ✗ | OS_ASSERT(result); | |
| 121 | ✗ | } | |
| 122 | |||
| 123 | 3 | bool AvailabilityManagerNightVentilation_Impl::setVentilationTemperatureDifference(double ventilationTemperatureDifference) { | |
| 124 | 3 | bool result = setDouble(OS_AvailabilityManager_NightVentilationFields::VentilationTemperatureDifference, ventilationTemperatureDifference); | |
| 125 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | OS_ASSERT(result); |
| 126 | 3 | return result; | |
| 127 | } | ||
| 128 | |||
| 129 | 3 | bool AvailabilityManagerNightVentilation_Impl::setVentilationTemperatureLowLimit(double ventilationTemperatureLowLimit) { | |
| 130 | 3 | bool result = setDouble(OS_AvailabilityManager_NightVentilationFields::VentilationTemperatureLowLimit, ventilationTemperatureLowLimit); | |
| 131 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | OS_ASSERT(result); |
| 132 | 3 | return result; | |
| 133 | } | ||
| 134 | |||
| 135 | 3 | bool AvailabilityManagerNightVentilation_Impl::setNightVentingFlowFraction(double nightVentingFlowFraction) { | |
| 136 | 3 | bool result = setDouble(OS_AvailabilityManager_NightVentilationFields::NightVentingFlowFraction, nightVentingFlowFraction); | |
| 137 | 3 | return result; | |
| 138 | } | ||
| 139 | |||
| 140 | ✗ | bool AvailabilityManagerNightVentilation_Impl::setControlZone(const boost::optional<ThermalZone>& thermalZone) { | |
| 141 | ✗ | bool result(false); | |
| 142 | ✗ | if (thermalZone) { | |
| 143 | ✗ | result = setPointer(OS_AvailabilityManager_NightVentilationFields::ControlZone, thermalZone.get().handle()); | |
| 144 | } else { | ||
| 145 | ✗ | resetControlZone(); | |
| 146 | ✗ | result = true; | |
| 147 | } | ||
| 148 | ✗ | return result; | |
| 149 | } | ||
| 150 | |||
| 151 | ✗ | void AvailabilityManagerNightVentilation_Impl::resetControlZone() { | |
| 152 | ✗ | bool result = setString(OS_AvailabilityManager_NightVentilationFields::ControlZone, ""); | |
| 153 | ✗ | OS_ASSERT(result); | |
| 154 | ✗ | } | |
| 155 | |||
| 156 | ✗ | boost::optional<Schedule> AvailabilityManagerNightVentilation_Impl::optionalApplicabilitySchedule() const { | |
| 157 | ✗ | return getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_AvailabilityManager_NightVentilationFields::ApplicabilitySchedule); | |
| 158 | } | ||
| 159 | |||
| 160 | } // namespace detail | ||
| 161 | |||
| 162 | 3 | AvailabilityManagerNightVentilation::AvailabilityManagerNightVentilation(const Model& model) | |
| 163 | 3 | : AvailabilityManager(AvailabilityManagerNightVentilation::iddObjectType(), model) { | |
| 164 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 5 not taken.
|
3 | OS_ASSERT(getImpl<detail::AvailabilityManagerNightVentilation_Impl>()); |
| 165 | |||
| 166 | { | ||
| 167 |
1/1✓ Branch 1 taken 3 times.
|
3 | auto schedule = model.alwaysOnDiscreteSchedule(); |
| 168 |
1/1✓ Branch 1 taken 3 times.
|
3 | setApplicabilitySchedule(schedule); |
| 169 | 3 | } | |
| 170 | |||
| 171 |
1/1✓ Branch 1 taken 3 times.
|
3 | setVentilationTemperatureDifference(2.0); |
| 172 |
1/1✓ Branch 1 taken 3 times.
|
3 | setVentilationTemperatureLowLimit(15.0); |
| 173 |
1/1✓ Branch 1 taken 3 times.
|
3 | setNightVentingFlowFraction(0.333); |
| 174 | 3 | } | |
| 175 | |||
| 176 | 7606 | IddObjectType AvailabilityManagerNightVentilation::iddObjectType() { | |
| 177 |
1/1✓ Branch 1 taken 7606 times.
|
7606 | return {IddObjectType::OS_AvailabilityManager_NightVentilation}; |
| 178 | } | ||
| 179 | |||
| 180 | ✗ | Schedule AvailabilityManagerNightVentilation::applicabilitySchedule() const { | |
| 181 | ✗ | return getImpl<detail::AvailabilityManagerNightVentilation_Impl>()->applicabilitySchedule(); | |
| 182 | } | ||
| 183 | |||
| 184 | ✗ | boost::optional<Schedule> AvailabilityManagerNightVentilation::ventilationTemperatureSchedule() const { | |
| 185 | ✗ | return getImpl<detail::AvailabilityManagerNightVentilation_Impl>()->ventilationTemperatureSchedule(); | |
| 186 | } | ||
| 187 | |||
| 188 | ✗ | double AvailabilityManagerNightVentilation::ventilationTemperatureDifference() const { | |
| 189 | ✗ | return getImpl<detail::AvailabilityManagerNightVentilation_Impl>()->ventilationTemperatureDifference(); | |
| 190 | } | ||
| 191 | |||
| 192 | ✗ | double AvailabilityManagerNightVentilation::ventilationTemperatureLowLimit() const { | |
| 193 | ✗ | return getImpl<detail::AvailabilityManagerNightVentilation_Impl>()->ventilationTemperatureLowLimit(); | |
| 194 | } | ||
| 195 | |||
| 196 | ✗ | double AvailabilityManagerNightVentilation::nightVentingFlowFraction() const { | |
| 197 | ✗ | return getImpl<detail::AvailabilityManagerNightVentilation_Impl>()->nightVentingFlowFraction(); | |
| 198 | } | ||
| 199 | |||
| 200 | ✗ | boost::optional<ThermalZone> AvailabilityManagerNightVentilation::controlZone() const { | |
| 201 | ✗ | return getImpl<detail::AvailabilityManagerNightVentilation_Impl>()->controlZone(); | |
| 202 | } | ||
| 203 | |||
| 204 | 3 | bool AvailabilityManagerNightVentilation::setApplicabilitySchedule(Schedule& schedule) { | |
| 205 |
1/1✓ Branch 3 taken 3 times.
|
3 | return getImpl<detail::AvailabilityManagerNightVentilation_Impl>()->setApplicabilitySchedule(schedule); |
| 206 | } | ||
| 207 | |||
| 208 | ✗ | bool AvailabilityManagerNightVentilation::setVentilationTemperatureSchedule(Schedule& schedule) { | |
| 209 | ✗ | return getImpl<detail::AvailabilityManagerNightVentilation_Impl>()->setVentilationTemperatureSchedule(schedule); | |
| 210 | } | ||
| 211 | |||
| 212 | ✗ | void AvailabilityManagerNightVentilation::resetVentilationTemperatureSchedule() { | |
| 213 | ✗ | getImpl<detail::AvailabilityManagerNightVentilation_Impl>()->resetVentilationTemperatureSchedule(); | |
| 214 | ✗ | } | |
| 215 | |||
| 216 | 3 | bool AvailabilityManagerNightVentilation::setVentilationTemperatureDifference(double ventilationTemperatureDifference) { | |
| 217 |
1/1✓ Branch 3 taken 3 times.
|
3 | return getImpl<detail::AvailabilityManagerNightVentilation_Impl>()->setVentilationTemperatureDifference(ventilationTemperatureDifference); |
| 218 | } | ||
| 219 | |||
| 220 | 3 | bool AvailabilityManagerNightVentilation::setVentilationTemperatureLowLimit(double ventilationTemperatureLowLimit) { | |
| 221 |
1/1✓ Branch 3 taken 3 times.
|
3 | return getImpl<detail::AvailabilityManagerNightVentilation_Impl>()->setVentilationTemperatureLowLimit(ventilationTemperatureLowLimit); |
| 222 | } | ||
| 223 | |||
| 224 | 3 | bool AvailabilityManagerNightVentilation::setNightVentingFlowFraction(double nightVentingFlowFraction) { | |
| 225 |
1/1✓ Branch 3 taken 3 times.
|
3 | return getImpl<detail::AvailabilityManagerNightVentilation_Impl>()->setNightVentingFlowFraction(nightVentingFlowFraction); |
| 226 | } | ||
| 227 | |||
| 228 | ✗ | bool AvailabilityManagerNightVentilation::setControlZone(const ThermalZone& thermalZone) { | |
| 229 | ✗ | return getImpl<detail::AvailabilityManagerNightVentilation_Impl>()->setControlZone(thermalZone); | |
| 230 | } | ||
| 231 | |||
| 232 | ✗ | void AvailabilityManagerNightVentilation::resetControlZone() { | |
| 233 | ✗ | getImpl<detail::AvailabilityManagerNightVentilation_Impl>()->resetControlZone(); | |
| 234 | ✗ | } | |
| 235 | |||
| 236 | /// @cond | ||
| 237 | ✗ | AvailabilityManagerNightVentilation::AvailabilityManagerNightVentilation(std::shared_ptr<detail::AvailabilityManagerNightVentilation_Impl> impl) | |
| 238 | ✗ | : AvailabilityManager(std::move(impl)) {} | |
| 239 | /// @endcond | ||
| 240 | |||
| 241 | } // namespace model | ||
| 242 | } // namespace openstudio | ||
| 243 |