src/model/ZoneAirContaminantBalance.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 "ZoneAirContaminantBalance.hpp" | ||
| 7 | #include "ZoneAirContaminantBalance_Impl.hpp" | ||
| 8 | #include "SimulationControl.hpp" | ||
| 9 | #include "SimulationControl_Impl.hpp" | ||
| 10 | |||
| 11 | #include "Model.hpp" | ||
| 12 | #include "Model_Impl.hpp" | ||
| 13 | |||
| 14 | #include "Schedule.hpp" | ||
| 15 | #include "Schedule_Impl.hpp" | ||
| 16 | #include "ScheduleTypeLimits.hpp" | ||
| 17 | #include "ScheduleTypeRegistry.hpp" | ||
| 18 | |||
| 19 | #include <utilities/idd/OS_ZoneAirContaminantBalance_FieldEnums.hxx> | ||
| 20 | #include <utilities/idd/IddEnums.hxx> | ||
| 21 | |||
| 22 | #include "../utilities/core/Assert.hpp" | ||
| 23 | |||
| 24 | namespace openstudio { | ||
| 25 | namespace model { | ||
| 26 | |||
| 27 | namespace detail { | ||
| 28 | |||
| 29 | 17 | ZoneAirContaminantBalance_Impl::ZoneAirContaminantBalance_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 30 | 17 | : ModelObject_Impl(idfObject, model, keepHandle) { | |
| 31 |
4/6✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
✓ Branch 7 taken 17 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 17 times.
✗ Branch 13 not taken.
|
17 | OS_ASSERT(idfObject.iddObject().type() == ZoneAirContaminantBalance::iddObjectType()); |
| 32 | 17 | } | |
| 33 | |||
| 34 | 14 | ZoneAirContaminantBalance_Impl::ZoneAirContaminantBalance_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, | |
| 35 | 14 | bool keepHandle) | |
| 36 | 14 | : ModelObject_Impl(other, model, keepHandle) { | |
| 37 |
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(other.iddObject().type() == ZoneAirContaminantBalance::iddObjectType()); |
| 38 | 14 | } | |
| 39 | |||
| 40 | 47 | ZoneAirContaminantBalance_Impl::ZoneAirContaminantBalance_Impl(const ZoneAirContaminantBalance_Impl& other, Model_Impl* model, bool keepHandle) | |
| 41 | 47 | : ModelObject_Impl(other, model, keepHandle) {} | |
| 42 | |||
| 43 | ✗ | IddObjectType ZoneAirContaminantBalance_Impl::iddObjectType() const { | |
| 44 | ✗ | return ZoneAirContaminantBalance::iddObjectType(); | |
| 45 | } | ||
| 46 | |||
| 47 | // return the parent object in the hierarchy | ||
| 48 | 1 | boost::optional<ParentObject> ZoneAirContaminantBalance_Impl::parent() const { | |
| 49 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | boost::optional<ParentObject> result(model().getUniqueModelObject<SimulationControl>()); |
| 50 | 1 | return result; | |
| 51 | } | ||
| 52 | |||
| 53 | // set the parent, child may have to call methods on the parent | ||
| 54 | ✗ | bool ZoneAirContaminantBalance_Impl::setParent(ParentObject& newParent) { | |
| 55 | ✗ | if (newParent.optionalCast<SimulationControl>() && (newParent.model() == model())) { | |
| 56 | ✗ | return true; | |
| 57 | } | ||
| 58 | ✗ | return false; | |
| 59 | } | ||
| 60 | |||
| 61 | // Get all output variable names that could be associated with this object. | ||
| 62 | ✗ | const std::vector<std::string>& ZoneAirContaminantBalance_Impl::outputVariableNames() const { | |
| 63 | ✗ | static const std::vector<std::string> result; | |
| 64 | // Reported in ThermalZone | ||
| 65 | // The following output variables are available when Carbon Dioxide Concentration = Yes. | ||
| 66 | //result.push_back("Zone Air CO2 Internal Gain Volume Flow Rate"); | ||
| 67 | //result.push_back("Zone Air CO2 Concentration"); | ||
| 68 | // The following output variable is available when Generic Contaminant Concentration = Yes. | ||
| 69 | //result.push_back("Zone Generic Air Contaminant Generation Volume Flow Rate"); | ||
| 70 | //result.push_back("Zone Air Generic Air Contaminant Concentration"); | ||
| 71 | ✗ | return result; | |
| 72 | } | ||
| 73 | |||
| 74 | ✗ | std::vector<ScheduleTypeKey> ZoneAirContaminantBalance_Impl::getScheduleTypeKeys(const Schedule& schedule) const { | |
| 75 | ✗ | std::vector<ScheduleTypeKey> result; | |
| 76 | ✗ | UnsignedVector fieldIndices = getSourceIndices(schedule.handle()); | |
| 77 | ✗ | UnsignedVector::const_iterator b(fieldIndices.begin()); | |
| 78 | ✗ | UnsignedVector::const_iterator e(fieldIndices.end()); | |
| 79 | ✗ | if (std::find(b, e, OS_ZoneAirContaminantBalanceFields::OutdoorCarbonDioxideScheduleName) != e) { | |
| 80 | ✗ | result.push_back(ScheduleTypeKey("ZoneAirContaminantBalance", "Outdoor Carbon Dioxide")); | |
| 81 | } | ||
| 82 | ✗ | return result; | |
| 83 | ✗ | } | |
| 84 | |||
| 85 | 10 | bool ZoneAirContaminantBalance_Impl::carbonDioxideConcentration() const { | |
| 86 |
1/1✓ Branch 1 taken 10 times.
|
10 | boost::optional<std::string> value = getString(OS_ZoneAirContaminantBalanceFields::CarbonDioxideConcentration, true); |
| 87 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 4 not taken.
|
10 | OS_ASSERT(value); |
| 88 |
3/3✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✓ Branch 7 taken 10 times.
|
20 | return openstudio::istringEqual(value.get(), "Yes"); |
| 89 | 10 | } | |
| 90 | |||
| 91 | ✗ | bool ZoneAirContaminantBalance_Impl::isCarbonDioxideConcentrationDefaulted() const { | |
| 92 | ✗ | return isEmpty(OS_ZoneAirContaminantBalanceFields::CarbonDioxideConcentration); | |
| 93 | } | ||
| 94 | |||
| 95 | 10 | boost::optional<Schedule> ZoneAirContaminantBalance_Impl::outdoorCarbonDioxideSchedule() const { | |
| 96 |
2/2✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
|
10 | return getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_ZoneAirContaminantBalanceFields::OutdoorCarbonDioxideScheduleName); |
| 97 | } | ||
| 98 | |||
| 99 | ✗ | bool ZoneAirContaminantBalance_Impl::setCarbonDioxideConcentration(bool carbonDioxideConcentration) { | |
| 100 | ✗ | return setBooleanFieldValue(OS_ZoneAirContaminantBalanceFields::CarbonDioxideConcentration, carbonDioxideConcentration); | |
| 101 | ; | ||
| 102 | } | ||
| 103 | |||
| 104 | ✗ | void ZoneAirContaminantBalance_Impl::resetCarbonDioxideConcentration() { | |
| 105 | ✗ | bool result = setString(OS_ZoneAirContaminantBalanceFields::CarbonDioxideConcentration, ""); | |
| 106 | ✗ | OS_ASSERT(result); | |
| 107 | ✗ | } | |
| 108 | |||
| 109 | ✗ | bool ZoneAirContaminantBalance_Impl::setOutdoorCarbonDioxideSchedule(Schedule& schedule) { | |
| 110 | ✗ | bool result = setSchedule(OS_ZoneAirContaminantBalanceFields::OutdoorCarbonDioxideScheduleName, "ZoneAirContaminantBalance", | |
| 111 | "Outdoor Carbon Dioxide", schedule); | ||
| 112 | ✗ | return result; | |
| 113 | } | ||
| 114 | |||
| 115 | ✗ | void ZoneAirContaminantBalance_Impl::resetOutdoorCarbonDioxideSchedule() { | |
| 116 | ✗ | bool result = setString(OS_ZoneAirContaminantBalanceFields::OutdoorCarbonDioxideScheduleName, ""); | |
| 117 | ✗ | OS_ASSERT(result); | |
| 118 | ✗ | } | |
| 119 | |||
| 120 | ✗ | boost::optional<ModelObject> ZoneAirContaminantBalance_Impl::outdoorCarbonDioxideScheduleAsModelObject() const { | |
| 121 | ✗ | OptionalModelObject result; | |
| 122 | ✗ | OptionalSchedule intermediate = outdoorCarbonDioxideSchedule(); | |
| 123 | ✗ | if (intermediate) { | |
| 124 | ✗ | result = *intermediate; | |
| 125 | } | ||
| 126 | ✗ | return result; | |
| 127 | ✗ | } | |
| 128 | |||
| 129 | ✗ | bool ZoneAirContaminantBalance_Impl::setOutdoorCarbonDioxideScheduleAsModelObject(const boost::optional<ModelObject>& modelObject) { | |
| 130 | ✗ | if (modelObject) { | |
| 131 | ✗ | OptionalSchedule intermediate = modelObject->optionalCast<Schedule>(); | |
| 132 | ✗ | if (intermediate) { | |
| 133 | ✗ | Schedule schedule(*intermediate); | |
| 134 | ✗ | return setOutdoorCarbonDioxideSchedule(schedule); | |
| 135 | ✗ | } else { | |
| 136 | ✗ | return false; | |
| 137 | } | ||
| 138 | ✗ | } else { | |
| 139 | ✗ | resetOutdoorCarbonDioxideSchedule(); | |
| 140 | } | ||
| 141 | ✗ | return true; | |
| 142 | } | ||
| 143 | |||
| 144 | } // namespace detail | ||
| 145 | |||
| 146 | 8522 | IddObjectType ZoneAirContaminantBalance::iddObjectType() { | |
| 147 |
1/1✓ Branch 1 taken 8522 times.
|
8522 | return {IddObjectType::OS_ZoneAirContaminantBalance}; |
| 148 | } | ||
| 149 | |||
| 150 | 10 | bool ZoneAirContaminantBalance::carbonDioxideConcentration() const { | |
| 151 |
1/1✓ Branch 3 taken 10 times.
|
10 | return getImpl<detail::ZoneAirContaminantBalance_Impl>()->carbonDioxideConcentration(); |
| 152 | } | ||
| 153 | |||
| 154 | ✗ | bool ZoneAirContaminantBalance::isCarbonDioxideConcentrationDefaulted() const { | |
| 155 | ✗ | return getImpl<detail::ZoneAirContaminantBalance_Impl>()->isCarbonDioxideConcentrationDefaulted(); | |
| 156 | } | ||
| 157 | |||
| 158 | 10 | boost::optional<Schedule> ZoneAirContaminantBalance::outdoorCarbonDioxideSchedule() const { | |
| 159 |
1/1✓ Branch 3 taken 10 times.
|
10 | return getImpl<detail::ZoneAirContaminantBalance_Impl>()->outdoorCarbonDioxideSchedule(); |
| 160 | } | ||
| 161 | |||
| 162 | ✗ | bool ZoneAirContaminantBalance::setCarbonDioxideConcentration(bool carbonDioxideConcentration) { | |
| 163 | ✗ | return getImpl<detail::ZoneAirContaminantBalance_Impl>()->setCarbonDioxideConcentration(carbonDioxideConcentration); | |
| 164 | } | ||
| 165 | |||
| 166 | ✗ | void ZoneAirContaminantBalance::setCarbonDioxideConcentrationNoFail(bool carbonDioxideConcentration) { | |
| 167 | ✗ | bool result = getImpl<detail::ZoneAirContaminantBalance_Impl>()->setCarbonDioxideConcentration(carbonDioxideConcentration); | |
| 168 | ✗ | OS_ASSERT(result); | |
| 169 | ✗ | } | |
| 170 | |||
| 171 | ✗ | void ZoneAirContaminantBalance::resetCarbonDioxideConcentration() { | |
| 172 | ✗ | getImpl<detail::ZoneAirContaminantBalance_Impl>()->resetCarbonDioxideConcentration(); | |
| 173 | ✗ | } | |
| 174 | |||
| 175 | ✗ | bool ZoneAirContaminantBalance::setOutdoorCarbonDioxideSchedule(Schedule& schedule) { | |
| 176 | ✗ | return getImpl<detail::ZoneAirContaminantBalance_Impl>()->setOutdoorCarbonDioxideSchedule(schedule); | |
| 177 | } | ||
| 178 | |||
| 179 | ✗ | void ZoneAirContaminantBalance::resetOutdoorCarbonDioxideSchedule() { | |
| 180 | ✗ | getImpl<detail::ZoneAirContaminantBalance_Impl>()->resetOutdoorCarbonDioxideSchedule(); | |
| 181 | ✗ | } | |
| 182 | |||
| 183 | /// @cond | ||
| 184 |
1/1✓ Branch 3 taken 30 times.
|
30 | ZoneAirContaminantBalance::ZoneAirContaminantBalance(std::shared_ptr<detail::ZoneAirContaminantBalance_Impl> impl) : ModelObject(std::move(impl)) {} |
| 185 | |||
| 186 | 3 | ZoneAirContaminantBalance::ZoneAirContaminantBalance(Model& model) : ModelObject(ZoneAirContaminantBalance::iddObjectType(), model) { | |
| 187 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 5 not taken.
|
3 | OS_ASSERT(getImpl<detail::ZoneAirContaminantBalance_Impl>()); |
| 188 | 3 | } | |
| 189 | |||
| 190 | /// @endcond | ||
| 191 | |||
| 192 | } // namespace model | ||
| 193 | } // namespace openstudio | ||
| 194 |