src/model/LifeCycleCost.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 "LifeCycleCost.hpp" | ||
| 7 | #include "LifeCycleCost_Impl.hpp" | ||
| 8 | #include "ConstructionBase.hpp" | ||
| 9 | #include "ConstructionBase_Impl.hpp" | ||
| 10 | #include "LightsDefinition.hpp" | ||
| 11 | #include "LightsDefinition_Impl.hpp" | ||
| 12 | #include "LuminaireDefinition.hpp" | ||
| 13 | #include "LuminaireDefinition_Impl.hpp" | ||
| 14 | #include "ElectricEquipmentDefinition.hpp" | ||
| 15 | #include "ElectricEquipmentDefinition_Impl.hpp" | ||
| 16 | #include "GasEquipmentDefinition.hpp" | ||
| 17 | #include "GasEquipmentDefinition_Impl.hpp" | ||
| 18 | #include "HotWaterEquipmentDefinition.hpp" | ||
| 19 | #include "HotWaterEquipmentDefinition_Impl.hpp" | ||
| 20 | #include "SteamEquipmentDefinition.hpp" | ||
| 21 | #include "SteamEquipmentDefinition_Impl.hpp" | ||
| 22 | #include "Building.hpp" | ||
| 23 | #include "Building_Impl.hpp" | ||
| 24 | #include "Space.hpp" | ||
| 25 | #include "Space_Impl.hpp" | ||
| 26 | #include "ThermalZone.hpp" | ||
| 27 | #include "ThermalZone_Impl.hpp" | ||
| 28 | #include "AirLoopHVAC.hpp" | ||
| 29 | #include "AirLoopHVAC_Impl.hpp" | ||
| 30 | #include "PlantLoop.hpp" | ||
| 31 | #include "PlantLoop_Impl.hpp" | ||
| 32 | #include "HVACComponent.hpp" | ||
| 33 | #include "HVACComponent_Impl.hpp" | ||
| 34 | #include "ZoneHVACComponent.hpp" | ||
| 35 | #include "ZoneHVACComponent_Impl.hpp" | ||
| 36 | #include "Model.hpp" | ||
| 37 | #include "Model_Impl.hpp" | ||
| 38 | |||
| 39 | #include <utilities/idd/IddFactory.hxx> | ||
| 40 | |||
| 41 | #include <utilities/idd/OS_LifeCycleCost_FieldEnums.hxx> | ||
| 42 | #include <utilities/idd/IddEnums.hxx> | ||
| 43 | |||
| 44 | #include <boost/algorithm/string.hpp> | ||
| 45 | |||
| 46 | #include "../utilities/core/Assert.hpp" | ||
| 47 | |||
| 48 | #include <typeinfo> | ||
| 49 | #include <iostream> | ||
| 50 | |||
| 51 | using namespace std; | ||
| 52 | |||
| 53 | using std::string; | ||
| 54 | using std::type_info; | ||
| 55 | |||
| 56 | namespace openstudio { | ||
| 57 | namespace model { | ||
| 58 | namespace detail { | ||
| 59 | |||
| 60 | 63 | LifeCycleCost_Impl::LifeCycleCost_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 61 | 63 | : ModelObject_Impl(idfObject, model, keepHandle) { | |
| 62 |
4/6✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
✓ Branch 7 taken 63 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 63 times.
✗ Branch 13 not taken.
|
63 | OS_ASSERT(idfObject.iddObject().type() == LifeCycleCost::iddObjectType()); |
| 63 | 63 | } | |
| 64 | |||
| 65 | ✗ | LifeCycleCost_Impl::LifeCycleCost_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) | |
| 66 | ✗ | : ModelObject_Impl(other, model, keepHandle) { | |
| 67 | ✗ | OS_ASSERT(other.iddObject().type() == LifeCycleCost::iddObjectType()); | |
| 68 | ✗ | } | |
| 69 | |||
| 70 | 22 | LifeCycleCost_Impl::LifeCycleCost_Impl(const LifeCycleCost_Impl& other, Model_Impl* model, bool keepHandle) | |
| 71 | 22 | : ModelObject_Impl(other, model, keepHandle) {} | |
| 72 | |||
| 73 | 18 | std::string LifeCycleCost_Impl::category() const { | |
| 74 |
1/1✓ Branch 1 taken 18 times.
|
18 | boost::optional<std::string> value = getString(OS_LifeCycleCostFields::Category, true); |
| 75 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 4 not taken.
|
18 | OS_ASSERT(value); |
| 76 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
|
36 | return value.get(); |
| 77 | 18 | } | |
| 78 | |||
| 79 | 163 | std::string LifeCycleCost_Impl::itemType() const { | |
| 80 |
1/1✓ Branch 1 taken 163 times.
|
163 | boost::optional<std::string> value = getString(OS_LifeCycleCostFields::ItemType, true); |
| 81 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 4 not taken.
|
163 | OS_ASSERT(value); |
| 82 |
2/2✓ Branch 1 taken 163 times.
✓ Branch 4 taken 163 times.
|
326 | return value.get(); |
| 83 | 163 | } | |
| 84 | |||
| 85 | 145 | ModelObject LifeCycleCost_Impl::item() const { | |
| 86 |
2/2✓ Branch 1 taken 145 times.
✓ Branch 4 taken 145 times.
|
145 | boost::optional<ModelObject> value = getObject<ModelObject>().getModelObjectTarget<ModelObject>(OS_LifeCycleCostFields::ItemName); |
| 87 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 145 times.
✗ Branch 4 not taken.
|
145 | OS_ASSERT(value); |
| 88 |
2/2✓ Branch 1 taken 145 times.
✓ Branch 4 taken 145 times.
|
290 | return value.get(); |
| 89 | 145 | } | |
| 90 | |||
| 91 | 118 | double LifeCycleCost_Impl::cost() const { | |
| 92 |
1/1✓ Branch 1 taken 118 times.
|
118 | boost::optional<double> value = getDouble(OS_LifeCycleCostFields::Cost, true); |
| 93 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 118 times.
✗ Branch 4 not taken.
|
118 | OS_ASSERT(value); |
| 94 |
1/1✓ Branch 1 taken 118 times.
|
236 | return value.get(); |
| 95 | } | ||
| 96 | |||
| 97 | 162 | std::vector<std::string> LifeCycleCost_Impl::validCostUnitsValues() const { | |
| 98 | 162 | std::vector<std::string> result; | |
| 99 |
1/1✓ Branch 1 taken 162 times.
|
162 | std::string itemType = this->itemType(); |
| 100 |
4/4✓ Branch 1 taken 162 times.
✓ Branch 4 taken 162 times.
✓ Branch 7 taken 24 times.
✓ Branch 8 taken 138 times.
|
324 | if (istringEqual("Construction", itemType)) { |
| 101 |
2/2✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
|
48 | result.push_back("CostPerArea"); |
| 102 |
4/4✓ Branch 1 taken 138 times.
✓ Branch 4 taken 138 times.
✓ Branch 7 taken 30 times.
✓ Branch 8 taken 108 times.
|
276 | } else if (istringEqual("Building", itemType)) { |
| 103 |
2/2✓ Branch 1 taken 30 times.
✓ Branch 4 taken 30 times.
|
60 | result.push_back("CostPerEach"); |
| 104 |
2/2✓ Branch 1 taken 30 times.
✓ Branch 4 taken 30 times.
|
60 | result.push_back("CostPerArea"); |
| 105 |
2/2✓ Branch 1 taken 30 times.
✓ Branch 4 taken 30 times.
|
60 | result.push_back("CostPerThermalZone"); |
| 106 |
4/4✓ Branch 1 taken 108 times.
✓ Branch 4 taken 108 times.
✓ Branch 7 taken 21 times.
✓ Branch 8 taken 87 times.
|
216 | } else if (istringEqual("Space", itemType)) { |
| 107 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
42 | result.push_back("CostPerEach"); |
| 108 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
42 | result.push_back("CostPerArea"); |
| 109 |
4/4✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
✓ Branch 7 taken 9 times.
✓ Branch 8 taken 78 times.
|
174 | } else if (istringEqual("ThermalZone", itemType)) { |
| 110 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
18 | result.push_back("CostPerEach"); |
| 111 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
18 | result.push_back("CostPerArea"); |
| 112 |
4/4✓ Branch 1 taken 78 times.
✓ Branch 4 taken 78 times.
✓ Branch 7 taken 9 times.
✓ Branch 8 taken 69 times.
|
156 | } else if (istringEqual("AirLoop", itemType)) { |
| 113 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
18 | result.push_back("CostPerEach"); |
| 114 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
18 | result.push_back("CostPerThermalZone"); |
| 115 |
4/4✓ Branch 1 taken 69 times.
✓ Branch 4 taken 69 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 66 times.
|
138 | } else if (istringEqual("PlantLoop", itemType)) { |
| 116 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
6 | result.push_back("CostPerEach"); |
| 117 |
4/4✓ Branch 1 taken 66 times.
✓ Branch 4 taken 66 times.
✓ Branch 7 taken 9 times.
✓ Branch 8 taken 57 times.
|
132 | } else if (istringEqual("ZoneHVAC", itemType)) { |
| 118 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
18 | result.push_back("CostPerEach"); |
| 119 |
4/4✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 7 taken 28 times.
✓ Branch 8 taken 29 times.
|
114 | } else if (istringEqual("Lights", itemType)) { |
| 120 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
|
56 | result.push_back("CostPerEach"); |
| 121 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
|
56 | result.push_back("CostPerArea"); |
| 122 |
4/4✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 7 taken 6 times.
✓ Branch 8 taken 23 times.
|
58 | } else if (istringEqual("Luminaire", itemType)) { |
| 123 |
2/2✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
|
12 | result.push_back("CostPerEach"); |
| 124 |
4/4✓ Branch 1 taken 23 times.
✓ Branch 4 taken 23 times.
✓ Branch 7 taken 14 times.
✓ Branch 8 taken 9 times.
|
46 | } else if (istringEqual("Equipment", itemType)) { |
| 125 |
2/2✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
|
28 | result.push_back("CostPerEach"); |
| 126 |
2/2✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
|
28 | result.push_back("CostPerArea"); |
| 127 |
3/4✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✗ Branch 8 not taken.
|
18 | } else if (istringEqual("HVACComponent", itemType)) { |
| 128 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
18 | result.push_back("CostPerEach"); |
| 129 | ✗ | } else if (istringEqual("ZoneHVACComponent", itemType)) { | |
| 130 | ✗ | result.push_back("CostPerEach"); | |
| 131 | } else { | ||
| 132 | ✗ | result.push_back("CostPerEach"); | |
| 133 | } | ||
| 134 | |||
| 135 | 324 | return result; | |
| 136 | 162 | } | |
| 137 | |||
| 138 | 268 | std::string LifeCycleCost_Impl::costUnits() const { | |
| 139 |
1/1✓ Branch 1 taken 268 times.
|
268 | boost::optional<std::string> value = getString(OS_LifeCycleCostFields::CostUnits, true); |
| 140 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 4 not taken.
|
268 | OS_ASSERT(value); |
| 141 |
2/2✓ Branch 1 taken 268 times.
✓ Branch 4 taken 268 times.
|
536 | return value.get(); |
| 142 | 268 | } | |
| 143 | |||
| 144 | 16 | std::string LifeCycleCost_Impl::startOfCosts() const { | |
| 145 |
1/1✓ Branch 1 taken 16 times.
|
16 | boost::optional<std::string> value = getString(OS_LifeCycleCostFields::StartofCosts, true); |
| 146 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 4 not taken.
|
16 | OS_ASSERT(value); |
| 147 |
2/2✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
|
32 | return value.get(); |
| 148 | 16 | } | |
| 149 | |||
| 150 | ✗ | bool LifeCycleCost_Impl::isStartOfCostsDefaulted() const { | |
| 151 | ✗ | return isEmpty(OS_LifeCycleCostFields::StartofCosts); | |
| 152 | } | ||
| 153 | |||
| 154 | 18 | int LifeCycleCost_Impl::yearsFromStart() const { | |
| 155 |
1/1✓ Branch 1 taken 18 times.
|
18 | boost::optional<int> value = getInt(OS_LifeCycleCostFields::YearsfromStart, true); |
| 156 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 4 not taken.
|
18 | OS_ASSERT(value); |
| 157 |
1/1✓ Branch 1 taken 18 times.
|
36 | return value.get(); |
| 158 | } | ||
| 159 | |||
| 160 | 4 | bool LifeCycleCost_Impl::isYearsFromStartDefaulted() const { | |
| 161 | 4 | return isEmpty(OS_LifeCycleCostFields::YearsfromStart); | |
| 162 | } | ||
| 163 | |||
| 164 | 17 | int LifeCycleCost_Impl::monthsFromStart() const { | |
| 165 |
1/1✓ Branch 1 taken 17 times.
|
17 | boost::optional<int> value = getInt(OS_LifeCycleCostFields::MonthsfromStart, true); |
| 166 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✗ Branch 4 not taken.
|
17 | OS_ASSERT(value); |
| 167 |
1/1✓ Branch 1 taken 17 times.
|
34 | return value.get(); |
| 168 | } | ||
| 169 | |||
| 170 | 3 | bool LifeCycleCost_Impl::isMonthsFromStartDefaulted() const { | |
| 171 | 3 | return isEmpty(OS_LifeCycleCostFields::MonthsfromStart); | |
| 172 | } | ||
| 173 | |||
| 174 | 19 | int LifeCycleCost_Impl::repeatPeriodYears() const { | |
| 175 |
1/1✓ Branch 1 taken 19 times.
|
19 | boost::optional<int> value = getInt(OS_LifeCycleCostFields::RepeatPeriodYears, true); |
| 176 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 4 not taken.
|
19 | OS_ASSERT(value); |
| 177 |
1/1✓ Branch 1 taken 19 times.
|
38 | return value.get(); |
| 178 | } | ||
| 179 | |||
| 180 | 4 | bool LifeCycleCost_Impl::isRepeatPeriodYearsDefaulted() const { | |
| 181 | 4 | return isEmpty(OS_LifeCycleCostFields::RepeatPeriodYears); | |
| 182 | } | ||
| 183 | |||
| 184 | 17 | int LifeCycleCost_Impl::repeatPeriodMonths() const { | |
| 185 |
1/1✓ Branch 1 taken 17 times.
|
17 | boost::optional<int> value = getInt(OS_LifeCycleCostFields::RepeatPeriodMonths, true); |
| 186 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✗ Branch 4 not taken.
|
17 | OS_ASSERT(value); |
| 187 |
1/1✓ Branch 1 taken 17 times.
|
34 | return value.get(); |
| 188 | } | ||
| 189 | |||
| 190 | 3 | bool LifeCycleCost_Impl::isRepeatPeriodMonthsDefaulted() const { | |
| 191 | 3 | return isEmpty(OS_LifeCycleCostFields::RepeatPeriodYears); | |
| 192 | } | ||
| 193 | |||
| 194 | 48 | bool LifeCycleCost_Impl::setCategory(const std::string& category) { | |
| 195 | 48 | return setString(OS_LifeCycleCostFields::Category, category); | |
| 196 | } | ||
| 197 | |||
| 198 | 109 | bool LifeCycleCost_Impl::setCost(double cost) { | |
| 199 | 109 | return setDouble(OS_LifeCycleCostFields::Cost, cost); | |
| 200 | } | ||
| 201 | |||
| 202 | 109 | bool LifeCycleCost_Impl::setCostUnits(const std::string& costUnits) { | |
| 203 |
1/1✓ Branch 1 taken 109 times.
|
109 | std::vector<std::string> validCostUnitsValues = this->validCostUnitsValues(); |
| 204 |
3/3✓ Branch 4 taken 109 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 106 times.
|
109 | if (std::find(validCostUnitsValues.begin(), validCostUnitsValues.end(), costUnits) == validCostUnitsValues.end()) { |
| 205 | 3 | return false; | |
| 206 | } | ||
| 207 | |||
| 208 |
1/1✓ Branch 1 taken 106 times.
|
106 | return setString(OS_LifeCycleCostFields::CostUnits, costUnits); |
| 209 | 109 | } | |
| 210 | |||
| 211 | 53 | bool LifeCycleCost_Impl::setStartOfCosts(const std::string& startOfCosts) { | |
| 212 | 53 | return setString(OS_LifeCycleCostFields::StartofCosts, startOfCosts); | |
| 213 | } | ||
| 214 | |||
| 215 | ✗ | void LifeCycleCost_Impl::resetStartOfCosts() { | |
| 216 | ✗ | bool test = setString(OS_LifeCycleCostFields::StartofCosts, ""); | |
| 217 | ✗ | OS_ASSERT(test); | |
| 218 | ✗ | } | |
| 219 | |||
| 220 | 5 | bool LifeCycleCost_Impl::setYearsFromStart(int yearsFromStart) { | |
| 221 | 5 | return setInt(OS_LifeCycleCostFields::YearsfromStart, yearsFromStart); | |
| 222 | } | ||
| 223 | |||
| 224 | ✗ | void LifeCycleCost_Impl::resetYearsFromStart() { | |
| 225 | ✗ | bool test = setString(OS_LifeCycleCostFields::YearsfromStart, ""); | |
| 226 | ✗ | OS_ASSERT(test); | |
| 227 | ✗ | } | |
| 228 | |||
| 229 | ✗ | bool LifeCycleCost_Impl::setMonthsFromStart(int monthsFromStart) { | |
| 230 | ✗ | return setInt(OS_LifeCycleCostFields::MonthsfromStart, monthsFromStart); | |
| 231 | } | ||
| 232 | |||
| 233 | ✗ | void LifeCycleCost_Impl::resetMonthsFromStart() { | |
| 234 | ✗ | bool test = setString(OS_LifeCycleCostFields::MonthsfromStart, ""); | |
| 235 | ✗ | OS_ASSERT(test); | |
| 236 | ✗ | } | |
| 237 | |||
| 238 | 12 | bool LifeCycleCost_Impl::setRepeatPeriodYears(int repeatPeriodYears) { | |
| 239 | 12 | return setInt(OS_LifeCycleCostFields::RepeatPeriodYears, repeatPeriodYears); | |
| 240 | } | ||
| 241 | |||
| 242 | ✗ | void LifeCycleCost_Impl::resetRepeatPeriodYears() { | |
| 243 | ✗ | bool test = setString(OS_LifeCycleCostFields::RepeatPeriodYears, ""); | |
| 244 | ✗ | OS_ASSERT(test); | |
| 245 | ✗ | } | |
| 246 | |||
| 247 | ✗ | bool LifeCycleCost_Impl::setRepeatPeriodMonths(int repeatPeriodMonths) { | |
| 248 | ✗ | return setInt(OS_LifeCycleCostFields::RepeatPeriodMonths, repeatPeriodMonths); | |
| 249 | } | ||
| 250 | |||
| 251 | ✗ | void LifeCycleCost_Impl::resetRepeatPeriodMonths() { | |
| 252 | ✗ | bool test = setString(OS_LifeCycleCostFields::RepeatPeriodMonths, ""); | |
| 253 | ✗ | OS_ASSERT(test); | |
| 254 | ✗ | } | |
| 255 | |||
| 256 | 116 | double LifeCycleCost_Impl::totalCost() const { | |
| 257 | 116 | double result = 0; | |
| 258 |
1/1✓ Branch 1 taken 116 times.
|
116 | std::string costUnits = this->costUnits(); |
| 259 | |||
| 260 |
4/4✓ Branch 1 taken 116 times.
✓ Branch 4 taken 116 times.
✓ Branch 7 taken 35 times.
✓ Branch 8 taken 81 times.
|
232 | if (istringEqual("CostPerEach", costUnits)) { |
| 261 |
1/1✓ Branch 1 taken 35 times.
|
35 | boost::optional<int> costedQuantity = this->costedQuantity(); |
| 262 |
1/2✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
|
35 | if (costedQuantity) { |
| 263 |
2/2✓ Branch 1 taken 35 times.
✓ Branch 4 taken 35 times.
|
35 | result = costedQuantity.get() * this->cost(); |
| 264 | } | ||
| 265 |
4/4✓ Branch 1 taken 81 times.
✓ Branch 4 taken 81 times.
✓ Branch 7 taken 74 times.
✓ Branch 8 taken 7 times.
|
162 | } else if (istringEqual("CostPerArea", costUnits)) { |
| 266 |
1/1✓ Branch 1 taken 74 times.
|
74 | boost::optional<double> costedArea = this->costedArea(); |
| 267 |
1/2✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
|
74 | if (costedArea) { |
| 268 |
2/2✓ Branch 1 taken 74 times.
✓ Branch 4 taken 74 times.
|
74 | result = costedArea.get() * this->cost(); |
| 269 | } | ||
| 270 |
3/4✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
|
14 | } else if (istringEqual("CostPerThermalZone", costUnits)) { |
| 271 |
1/1✓ Branch 1 taken 7 times.
|
7 | boost::optional<int> costedThermalZones = this->costedThermalZones(); |
| 272 |
1/2✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
|
7 | if (costedThermalZones) { |
| 273 |
2/2✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
|
7 | result = costedThermalZones.get() * this->cost(); |
| 274 | } | ||
| 275 | } | ||
| 276 | |||
| 277 | 116 | return result; | |
| 278 | 116 | } | |
| 279 | |||
| 280 | 8 | bool LifeCycleCost_Impl::convertToCostPerEach() { | |
| 281 |
1/1✓ Branch 1 taken 8 times.
|
8 | std::string costUnits = this->costUnits(); |
| 282 |
4/4✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 4 times.
|
16 | if (istringEqual("CostPerEach", costUnits)) { |
| 283 | 4 | return true; | |
| 284 |
3/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
|
8 | } else if (istringEqual("CostPerArea", costUnits)) { |
| 285 |
1/1✓ Branch 1 taken 4 times.
|
4 | boost::optional<double> costedArea = this->costedArea(); |
| 286 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
|
4 | if (!costedArea) { |
| 287 | ✗ | return false; | |
| 288 | } | ||
| 289 | ✗ | } else if (istringEqual("CostPerThermalZone", costUnits)) { | |
| 290 | ✗ | boost::optional<int> costedThermalZones = this->costedThermalZones(); | |
| 291 | ✗ | if (!costedThermalZones) { | |
| 292 | ✗ | return false; | |
| 293 | } | ||
| 294 | } | ||
| 295 | |||
| 296 |
1/1✓ Branch 1 taken 4 times.
|
4 | double totalCost = this->totalCost(); |
| 297 | |||
| 298 |
3/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
|
8 | if (!this->setCostUnits("CostPerEach")) { |
| 299 | ✗ | return false; | |
| 300 | } | ||
| 301 | |||
| 302 |
1/1✓ Branch 1 taken 4 times.
|
4 | bool test = this->setCost(totalCost); |
| 303 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
|
4 | OS_ASSERT(test); |
| 304 | 4 | return true; | |
| 305 | 8 | } | |
| 306 | |||
| 307 | 39 | boost::optional<int> LifeCycleCost_Impl::costedQuantity() const { | |
| 308 | 39 | boost::optional<int> result; | |
| 309 | |||
| 310 |
1/1✓ Branch 1 taken 39 times.
|
39 | std::string costUnits = this->costUnits(); |
| 311 |
4/4✓ Branch 1 taken 39 times.
✓ Branch 4 taken 39 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 35 times.
|
78 | if (!istringEqual("CostPerEach", costUnits)) { |
| 312 | 4 | return boost::none; | |
| 313 | } | ||
| 314 | |||
| 315 |
1/1✓ Branch 1 taken 35 times.
|
35 | ModelObject modelObject = item(); |
| 316 | |||
| 317 |
2/3✓ Branch 1 taken 35 times.
✓ Branch 4 taken 35 times.
✗ Branch 5 not taken.
|
70 | if (modelObject.optionalCast<ConstructionBase>()) { |
| 318 | // no quantity defined | ||
| 319 | |||
| 320 |
3/3✓ Branch 1 taken 35 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 32 times.
|
70 | } else if (modelObject.optionalCast<Building>()) { |
| 321 |
1/1✓ Branch 1 taken 3 times.
|
3 | result = 1; |
| 322 | |||
| 323 |
3/3✓ Branch 1 taken 32 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 28 times.
|
64 | } else if (modelObject.optionalCast<Space>()) { |
| 324 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | result = modelObject.cast<Space>().multiplier(); |
| 325 | |||
| 326 |
3/3✓ Branch 1 taken 28 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 26 times.
|
56 | } else if (modelObject.optionalCast<ThermalZone>()) { |
| 327 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | result = modelObject.cast<ThermalZone>().multiplier(); |
| 328 | |||
| 329 |
3/3✓ Branch 1 taken 26 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 22 times.
|
52 | } else if (modelObject.optionalCast<AirLoopHVAC>()) { |
| 330 |
1/1✓ Branch 1 taken 4 times.
|
4 | result = 1; |
| 331 | |||
| 332 |
3/3✓ Branch 1 taken 22 times.
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 21 times.
|
44 | } else if (modelObject.optionalCast<PlantLoop>()) { |
| 333 |
1/1✓ Branch 1 taken 1 time.
|
1 | result = 1; |
| 334 | |||
| 335 |
3/3✓ Branch 1 taken 21 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 15 times.
|
42 | } else if (modelObject.optionalCast<HVACComponent>()) { |
| 336 |
1/1✓ Branch 1 taken 6 times.
|
6 | result = 1; |
| 337 | |||
| 338 |
2/3✓ Branch 1 taken 15 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
|
30 | } else if (modelObject.optionalCast<ZoneHVACComponent>()) { |
| 339 | ✗ | result = 1; | |
| 340 | |||
| 341 |
2/3✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
|
30 | } else if (modelObject.optionalCast<SpaceLoadDefinition>()) { |
| 342 | // covers lights, equipment, etc | ||
| 343 |
3/3✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
|
15 | result = modelObject.cast<SpaceLoadDefinition>().quantity(); |
| 344 | } | ||
| 345 | |||
| 346 | 35 | return result; | |
| 347 | 39 | } | |
| 348 | |||
| 349 | 86 | boost::optional<double> LifeCycleCost_Impl::costedArea() const { | |
| 350 | 86 | boost::optional<double> result; | |
| 351 | |||
| 352 |
1/1✓ Branch 1 taken 86 times.
|
86 | std::string costUnits = this->costUnits(); |
| 353 |
3/4✓ Branch 1 taken 86 times.
✓ Branch 4 taken 86 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 86 times.
|
172 | if (!istringEqual("CostPerArea", costUnits)) { |
| 354 | ✗ | return boost::none; | |
| 355 | } | ||
| 356 | |||
| 357 |
1/1✓ Branch 1 taken 86 times.
|
86 | ModelObject modelObject = item(); |
| 358 | |||
| 359 |
3/3✓ Branch 1 taken 86 times.
✓ Branch 4 taken 40 times.
✓ Branch 5 taken 46 times.
|
172 | if (modelObject.optionalCast<ConstructionBase>()) { |
| 360 |
3/3✓ Branch 1 taken 40 times.
✓ Branch 4 taken 40 times.
✓ Branch 7 taken 40 times.
|
40 | result = modelObject.cast<ConstructionBase>().getNetArea(); |
| 361 | |||
| 362 |
3/3✓ Branch 1 taken 46 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 41 times.
|
92 | } else if (modelObject.optionalCast<Building>()) { |
| 363 |
3/3✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
|
5 | result = modelObject.cast<Building>().floorArea(); |
| 364 | |||
| 365 |
3/3✓ Branch 1 taken 41 times.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 33 times.
|
82 | } else if (modelObject.optionalCast<Space>()) { |
| 366 |
5/5✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
✓ Branch 10 taken 8 times.
✓ Branch 13 taken 8 times.
|
8 | result = modelObject.cast<Space>().multiplier() * modelObject.cast<Space>().floorArea(); |
| 367 | |||
| 368 |
2/3✓ Branch 1 taken 33 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 33 times.
|
66 | } else if (modelObject.optionalCast<ThermalZone>()) { |
| 369 | ✗ | result = modelObject.cast<ThermalZone>().multiplier() * modelObject.cast<ThermalZone>().floorArea(); | |
| 370 | |||
| 371 |
2/3✓ Branch 1 taken 33 times.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
|
66 | } else if (modelObject.optionalCast<AirLoopHVAC>()) { |
| 372 | // no area defined | ||
| 373 | |||
| 374 |
2/3✓ Branch 1 taken 33 times.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
|
66 | } else if (modelObject.optionalCast<PlantLoop>()) { |
| 375 | // no area defined | ||
| 376 | |||
| 377 |
2/3✓ Branch 1 taken 33 times.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
|
66 | } else if (modelObject.optionalCast<HVACComponent>()) { |
| 378 | // no area defined | ||
| 379 | |||
| 380 |
2/3✓ Branch 1 taken 33 times.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
|
66 | } else if (modelObject.optionalCast<ZoneHVACComponent>()) { |
| 381 | // no area defined | ||
| 382 | |||
| 383 |
2/3✓ Branch 1 taken 33 times.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
|
66 | } else if (modelObject.optionalCast<SpaceLoadDefinition>()) { |
| 384 | // covers lights, equipment, etc | ||
| 385 |
3/3✓ Branch 1 taken 33 times.
✓ Branch 4 taken 33 times.
✓ Branch 7 taken 33 times.
|
33 | result = modelObject.cast<SpaceLoadDefinition>().floorArea(); |
| 386 | } | ||
| 387 | |||
| 388 | 86 | return result; | |
| 389 | 86 | } | |
| 390 | |||
| 391 | 11 | boost::optional<int> LifeCycleCost_Impl::costedThermalZones() const { | |
| 392 | 11 | boost::optional<int> result; | |
| 393 | |||
| 394 |
1/1✓ Branch 1 taken 11 times.
|
11 | std::string costUnits = this->costUnits(); |
| 395 |
4/4✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 7 times.
|
22 | if (!istringEqual("CostPerThermalZone", costUnits)) { |
| 396 | 4 | return boost::none; | |
| 397 | } | ||
| 398 | |||
| 399 |
1/1✓ Branch 1 taken 7 times.
|
7 | ModelObject modelObject = item(); |
| 400 | |||
| 401 |
2/3✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | if (modelObject.optionalCast<ConstructionBase>()) { |
| 402 | // number of thermal zones not defined | ||
| 403 | |||
| 404 |
3/3✓ Branch 1 taken 7 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 4 times.
|
14 | } else if (modelObject.optionalCast<Building>()) { |
| 405 |
1/1✓ Branch 1 taken 3 times.
|
3 | result = 0; |
| 406 |
4/4✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 3 times.
|
5 | for (const ThermalZone& thermalZone : this->model().getConcreteModelObjects<ThermalZone>()) { |
| 407 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | result = result.get() + thermalZone.multiplier(); |
| 408 | 3 | } | |
| 409 | |||
| 410 |
2/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
8 | } else if (modelObject.optionalCast<Space>()) { |
| 411 | // number of thermal zones not defined | ||
| 412 | |||
| 413 |
2/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
8 | } else if (modelObject.optionalCast<ThermalZone>()) { |
| 414 | // number of thermal zones not defined | ||
| 415 | |||
| 416 |
2/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
8 | } else if (modelObject.optionalCast<AirLoopHVAC>()) { |
| 417 |
1/1✓ Branch 1 taken 4 times.
|
4 | result = 0; |
| 418 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 11 taken 5 times.
✓ Branch 12 taken 4 times.
|
9 | for (const ThermalZone& thermalZone : modelObject.cast<AirLoopHVAC>().thermalZones()) { |
| 419 |
3/3✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
|
5 | result = result.get() + thermalZone.multiplier(); |
| 420 | 4 | } | |
| 421 | |||
| 422 | ✗ | } else if (modelObject.optionalCast<PlantLoop>()) { | |
| 423 | // number of thermal zones not defined | ||
| 424 | |||
| 425 | ✗ | } else if (modelObject.optionalCast<ZoneHVACComponent>()) { | |
| 426 | // number of thermal zones not defined | ||
| 427 | |||
| 428 | ✗ | } else if (modelObject.optionalCast<SpaceLoadDefinition>()) { | |
| 429 | // number of thermal zones not defined | ||
| 430 | } | ||
| 431 | |||
| 432 | 7 | return result; | |
| 433 | 11 | } | |
| 434 | |||
| 435 | // Get all output variable names that could be associated with this object. | ||
| 436 | ✗ | const std::vector<std::string>& LifeCycleCost_Impl::outputVariableNames() const { | |
| 437 | ✗ | static const std::vector<std::string> result; | |
| 438 | // Not appropriate: no specific variables | ||
| 439 | ✗ | return result; | |
| 440 | } | ||
| 441 | |||
| 442 | } // namespace detail | ||
| 443 | |||
| 444 | /// LifeCycleCost | ||
| 445 |
3/3✓ Branch 1 taken 58 times.
✓ Branch 4 taken 58 times.
✓ Branch 7 taken 58 times.
|
58 | LifeCycleCost::LifeCycleCost(const ModelObject& modelObject) : ModelObject(LifeCycleCost::iddObjectType(), modelObject.model()) { |
| 446 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
✗ Branch 5 not taken.
|
58 | OS_ASSERT(getImpl<detail::LifeCycleCost_Impl>()); |
| 447 |
2/2✓ Branch 3 taken 58 times.
✓ Branch 6 taken 58 times.
|
58 | bool test = getImpl<detail::LifeCycleCost_Impl>()->setPointer(OS_LifeCycleCostFields::ItemName, modelObject.handle()); |
| 448 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 3 not taken.
|
58 | OS_ASSERT(test); |
| 449 | |||
| 450 |
3/3✓ Branch 1 taken 58 times.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 50 times.
|
116 | if (modelObject.optionalCast<ConstructionBase>()) { |
| 451 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
|
16 | test = setString(OS_LifeCycleCostFields::ItemType, "Construction"); |
| 452 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 3 not taken.
|
8 | OS_ASSERT(test); |
| 453 |
3/3✓ Branch 1 taken 50 times.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 40 times.
|
100 | } else if (modelObject.optionalCast<Building>()) { |
| 454 |
2/2✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
|
20 | test = setString(OS_LifeCycleCostFields::ItemType, "Building"); |
| 455 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 3 not taken.
|
10 | OS_ASSERT(test); |
| 456 |
3/3✓ Branch 1 taken 40 times.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 33 times.
|
80 | } else if (modelObject.optionalCast<Space>()) { |
| 457 |
2/2✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
|
14 | test = setString(OS_LifeCycleCostFields::ItemType, "Space"); |
| 458 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 3 not taken.
|
7 | OS_ASSERT(test); |
| 459 |
3/3✓ Branch 1 taken 33 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 30 times.
|
66 | } else if (modelObject.optionalCast<ThermalZone>()) { |
| 460 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
6 | test = setString(OS_LifeCycleCostFields::ItemType, "ThermalZone"); |
| 461 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
|
3 | OS_ASSERT(test); |
| 462 |
3/3✓ Branch 1 taken 30 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 27 times.
|
60 | } else if (modelObject.optionalCast<AirLoopHVAC>()) { |
| 463 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
6 | test = setString(OS_LifeCycleCostFields::ItemType, "AirLoop"); |
| 464 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
|
3 | OS_ASSERT(test); |
| 465 |
3/3✓ Branch 1 taken 27 times.
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 26 times.
|
54 | } else if (modelObject.optionalCast<PlantLoop>()) { |
| 466 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | test = setString(OS_LifeCycleCostFields::ItemType, "PlantLoop"); |
| 467 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
|
1 | OS_ASSERT(test); |
| 468 |
3/3✓ Branch 1 taken 26 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 23 times.
|
52 | } else if (modelObject.optionalCast<ZoneHVACComponent>()) { |
| 469 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
6 | test = setString(OS_LifeCycleCostFields::ItemType, "ZoneHVAC"); |
| 470 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
|
3 | OS_ASSERT(test); |
| 471 |
3/3✓ Branch 1 taken 23 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 14 times.
|
46 | } else if (modelObject.optionalCast<LightsDefinition>()) { |
| 472 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
18 | test = setString(OS_LifeCycleCostFields::ItemType, "Lights"); |
| 473 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 3 not taken.
|
9 | OS_ASSERT(test); |
| 474 |
3/3✓ Branch 1 taken 14 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 12 times.
|
28 | } else if (modelObject.optionalCast<LuminaireDefinition>()) { |
| 475 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | test = setString(OS_LifeCycleCostFields::ItemType, "Luminaire"); |
| 476 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
|
2 | OS_ASSERT(test); |
| 477 |
3/3✓ Branch 1 taken 12 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 9 times.
|
24 | } else if (modelObject.optionalCast<ElectricEquipmentDefinition>()) { |
| 478 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
6 | test = setString(OS_LifeCycleCostFields::ItemType, "Equipment"); |
| 479 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
|
3 | OS_ASSERT(test); |
| 480 |
3/3✓ Branch 1 taken 9 times.
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 8 times.
|
18 | } else if (modelObject.optionalCast<GasEquipmentDefinition>()) { |
| 481 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | test = setString(OS_LifeCycleCostFields::ItemType, "Equipment"); |
| 482 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
|
1 | OS_ASSERT(test); |
| 483 |
2/3✓ Branch 1 taken 8 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
|
16 | } else if (modelObject.optionalCast<HotWaterEquipmentDefinition>()) { |
| 484 | ✗ | test = setString(OS_LifeCycleCostFields::ItemType, "Equipment"); | |
| 485 | ✗ | OS_ASSERT(test); | |
| 486 |
2/3✓ Branch 1 taken 8 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
|
16 | } else if (modelObject.optionalCast<SteamEquipmentDefinition>()) { |
| 487 | ✗ | test = setString(OS_LifeCycleCostFields::ItemType, "Equipment"); | |
| 488 | ✗ | OS_ASSERT(test); | |
| 489 |
3/3✓ Branch 1 taken 8 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 5 times.
|
16 | } else if (modelObject.optionalCast<HVACComponent>()) { |
| 490 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
6 | test = setString(OS_LifeCycleCostFields::ItemType, "HVACComponent"); |
| 491 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
|
3 | OS_ASSERT(test); |
| 492 | } else { | ||
| 493 |
1/1✓ Branch 1 taken 5 times.
|
5 | this->remove(); |
| 494 |
5/5✓ Branch 2 taken 5 times.
✓ Branch 5 taken 5 times.
✓ Branch 8 taken 5 times.
✓ Branch 11 taken 5 times.
✓ Branch 14 taken 5 times.
|
5 | throw openstudio::Exception("Cannot add cost to unknown model object type '" + modelObject.iddObject().name() + "'"); |
| 495 | } | ||
| 496 | |||
| 497 | // TODO: add ExteriorLoadDefinition? | ||
| 498 | |||
| 499 |
1/1✓ Branch 1 taken 53 times.
|
53 | test = this->setCost(0.0); |
| 500 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 3 not taken.
|
53 | OS_ASSERT(test); |
| 501 | |||
| 502 |
1/1✓ Branch 1 taken 53 times.
|
53 | std::vector<std::string> validCostUnitsValues = this->validCostUnitsValues(); |
| 503 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 53 times.
✗ Branch 4 not taken.
|
53 | OS_ASSERT(!validCostUnitsValues.empty()); |
| 504 |
1/1✓ Branch 2 taken 53 times.
|
53 | test = this->setCostUnits(validCostUnitsValues[0]); |
| 505 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 3 not taken.
|
53 | OS_ASSERT(test); |
| 506 | |||
| 507 |
2/2✓ Branch 1 taken 53 times.
✓ Branch 4 taken 53 times.
|
53 | test = this->setStartOfCosts("ServicePeriod"); |
| 508 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 3 not taken.
|
53 | OS_ASSERT(test); |
| 509 | 58 | } | |
| 510 | |||
| 511 | // constructor | ||
| 512 |
1/1✓ Branch 3 taken 89 times.
|
89 | LifeCycleCost::LifeCycleCost(std::shared_ptr<detail::LifeCycleCost_Impl> impl) : ModelObject(std::move(impl)) {} |
| 513 | |||
| 514 | 8697 | IddObjectType LifeCycleCost::iddObjectType() { | |
| 515 |
1/1✓ Branch 1 taken 8697 times.
|
8697 | IddObjectType result(IddObjectType::OS_LifeCycleCost); |
| 516 | 8697 | return result; | |
| 517 | } | ||
| 518 | |||
| 519 | ✗ | std::vector<std::string> LifeCycleCost::validCategoryValues() { | |
| 520 | ✗ | return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_LifeCycleCostFields::Category); | |
| 521 | } | ||
| 522 | |||
| 523 | ✗ | std::vector<std::string> LifeCycleCost::validItemTypeValues() { | |
| 524 | ✗ | return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_LifeCycleCostFields::ItemType); | |
| 525 | } | ||
| 526 | |||
| 527 | ✗ | std::vector<std::string> LifeCycleCost::validStartOfCostsValues() { | |
| 528 | ✗ | return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_LifeCycleCostFields::StartofCosts); | |
| 529 | } | ||
| 530 | |||
| 531 | 49 | boost::optional<LifeCycleCost> LifeCycleCost::createLifeCycleCost(const std::string& name, const ModelObject& modelObject, double cost, | |
| 532 | const std::string& costUnits, const std::string& category, int repeatPeriodYears, | ||
| 533 | int yearsFromStart) { | ||
| 534 | 49 | boost::optional<LifeCycleCost> result; | |
| 535 | |||
| 536 | try { | ||
| 537 |
2/2✓ Branch 1 taken 49 times.
✓ Branch 4 taken 49 times.
|
49 | result = LifeCycleCost(modelObject); |
| 538 | ✗ | } catch (const std::exception&) { | |
| 539 | ✗ | return boost::none; | |
| 540 | ✗ | } | |
| 541 | |||
| 542 | 49 | bool test = true; | |
| 543 |
5/10✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 49 times.
✓ Branch 6 taken 49 times.
✓ Branch 9 taken 49 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 49 times.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
|
98 | test = test && result->setName(name); |
| 544 |
4/6✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 49 times.
✓ Branch 6 taken 49 times.
✓ Branch 8 taken 49 times.
✗ Branch 9 not taken.
|
49 | test = test && result->setCost(cost); |
| 545 |
5/6✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 49 times.
✓ Branch 6 taken 49 times.
✓ Branch 8 taken 46 times.
✓ Branch 9 taken 3 times.
|
49 | test = test && result->setCostUnits(costUnits); |
| 546 |
5/6✓ Branch 0 taken 46 times.
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 46 times.
✓ Branch 6 taken 46 times.
✓ Branch 8 taken 46 times.
✗ Branch 9 not taken.
|
49 | test = test && result->setCategory(category); |
| 547 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 37 times.
|
49 | if (repeatPeriodYears > 0) { |
| 548 |
4/6✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 12 times.
✓ Branch 6 taken 12 times.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
|
12 | test = test && result->setRepeatPeriodYears(repeatPeriodYears); |
| 549 | } | ||
| 550 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 43 times.
|
49 | if (yearsFromStart > 0) { |
| 551 |
5/6✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 5 times.
✓ Branch 6 taken 5 times.
✓ Branch 8 taken 5 times.
✗ Branch 9 not taken.
|
6 | test = test && result->setYearsFromStart(yearsFromStart); |
| 552 | } | ||
| 553 | |||
| 554 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 46 times.
|
49 | if (!test) { |
| 555 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | result->remove(); |
| 556 | 3 | return boost::none; | |
| 557 | } | ||
| 558 | |||
| 559 | 46 | return result; | |
| 560 | 49 | } | |
| 561 | |||
| 562 | 18 | std::string LifeCycleCost::category() const { | |
| 563 |
1/1✓ Branch 3 taken 18 times.
|
18 | return getImpl<detail::LifeCycleCost_Impl>()->category(); |
| 564 | } | ||
| 565 | |||
| 566 | 1 | std::string LifeCycleCost::itemType() const { | |
| 567 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::LifeCycleCost_Impl>()->itemType(); |
| 568 | } | ||
| 569 | |||
| 570 | 17 | ModelObject LifeCycleCost::item() const { | |
| 571 |
1/1✓ Branch 3 taken 17 times.
|
17 | return getImpl<detail::LifeCycleCost_Impl>()->item(); |
| 572 | } | ||
| 573 | |||
| 574 | 2 | double LifeCycleCost::cost() const { | |
| 575 |
1/1✓ Branch 3 taken 2 times.
|
2 | return getImpl<detail::LifeCycleCost_Impl>()->cost(); |
| 576 | } | ||
| 577 | |||
| 578 | 53 | std::vector<std::string> LifeCycleCost::validCostUnitsValues() const { | |
| 579 |
1/1✓ Branch 3 taken 53 times.
|
53 | return getImpl<detail::LifeCycleCost_Impl>()->validCostUnitsValues(); |
| 580 | } | ||
| 581 | |||
| 582 | 8 | std::string LifeCycleCost::costUnits() const { | |
| 583 |
1/1✓ Branch 3 taken 8 times.
|
8 | return getImpl<detail::LifeCycleCost_Impl>()->costUnits(); |
| 584 | } | ||
| 585 | |||
| 586 | 16 | std::string LifeCycleCost::startOfCosts() const { | |
| 587 |
1/1✓ Branch 3 taken 16 times.
|
16 | return getImpl<detail::LifeCycleCost_Impl>()->startOfCosts(); |
| 588 | } | ||
| 589 | |||
| 590 | ✗ | bool LifeCycleCost::isStartOfCostsDefaulted() const { | |
| 591 | ✗ | return getImpl<detail::LifeCycleCost_Impl>()->isStartOfCostsDefaulted(); | |
| 592 | } | ||
| 593 | |||
| 594 | 18 | int LifeCycleCost::yearsFromStart() const { | |
| 595 |
1/1✓ Branch 3 taken 18 times.
|
18 | return getImpl<detail::LifeCycleCost_Impl>()->yearsFromStart(); |
| 596 | } | ||
| 597 | |||
| 598 | 4 | bool LifeCycleCost::isYearsFromStartDefaulted() const { | |
| 599 |
1/1✓ Branch 3 taken 4 times.
|
4 | return getImpl<detail::LifeCycleCost_Impl>()->isYearsFromStartDefaulted(); |
| 600 | } | ||
| 601 | |||
| 602 | 17 | int LifeCycleCost::monthsFromStart() const { | |
| 603 |
1/1✓ Branch 3 taken 17 times.
|
17 | return getImpl<detail::LifeCycleCost_Impl>()->monthsFromStart(); |
| 604 | } | ||
| 605 | |||
| 606 | 3 | bool LifeCycleCost::isMonthsFromStartDefaulted() const { | |
| 607 |
1/1✓ Branch 3 taken 3 times.
|
3 | return getImpl<detail::LifeCycleCost_Impl>()->isMonthsFromStartDefaulted(); |
| 608 | } | ||
| 609 | |||
| 610 | 19 | int LifeCycleCost::repeatPeriodYears() const { | |
| 611 |
1/1✓ Branch 3 taken 19 times.
|
19 | return getImpl<detail::LifeCycleCost_Impl>()->repeatPeriodYears(); |
| 612 | } | ||
| 613 | |||
| 614 | 4 | bool LifeCycleCost::isRepeatPeriodYearsDefaulted() const { | |
| 615 |
1/1✓ Branch 3 taken 4 times.
|
4 | return getImpl<detail::LifeCycleCost_Impl>()->isRepeatPeriodYearsDefaulted(); |
| 616 | } | ||
| 617 | |||
| 618 | 17 | int LifeCycleCost::repeatPeriodMonths() const { | |
| 619 |
1/1✓ Branch 3 taken 17 times.
|
17 | return getImpl<detail::LifeCycleCost_Impl>()->repeatPeriodMonths(); |
| 620 | } | ||
| 621 | |||
| 622 | 3 | bool LifeCycleCost::isRepeatPeriodMonthsDefaulted() const { | |
| 623 |
1/1✓ Branch 3 taken 3 times.
|
3 | return getImpl<detail::LifeCycleCost_Impl>()->isRepeatPeriodMonthsDefaulted(); |
| 624 | } | ||
| 625 | |||
| 626 | 48 | bool LifeCycleCost::setCategory(const std::string& category) { | |
| 627 |
1/1✓ Branch 3 taken 48 times.
|
48 | return getImpl<detail::LifeCycleCost_Impl>()->setCategory(category); |
| 628 | } | ||
| 629 | |||
| 630 | 105 | bool LifeCycleCost::setCost(double cost) { | |
| 631 |
1/1✓ Branch 3 taken 105 times.
|
105 | return getImpl<detail::LifeCycleCost_Impl>()->setCost(cost); |
| 632 | } | ||
| 633 | |||
| 634 | 105 | bool LifeCycleCost::setCostUnits(const std::string& costUnits) { | |
| 635 |
1/1✓ Branch 3 taken 105 times.
|
105 | return getImpl<detail::LifeCycleCost_Impl>()->setCostUnits(costUnits); |
| 636 | } | ||
| 637 | |||
| 638 | 53 | bool LifeCycleCost::setStartOfCosts(const std::string& startOfCosts) { | |
| 639 |
1/1✓ Branch 3 taken 53 times.
|
53 | return getImpl<detail::LifeCycleCost_Impl>()->setStartOfCosts(startOfCosts); |
| 640 | } | ||
| 641 | |||
| 642 | ✗ | void LifeCycleCost::resetStartOfCosts() { | |
| 643 | ✗ | getImpl<detail::LifeCycleCost_Impl>()->resetStartOfCosts(); | |
| 644 | ✗ | } | |
| 645 | |||
| 646 | 5 | bool LifeCycleCost::setYearsFromStart(int yearsFromStart) { | |
| 647 |
1/1✓ Branch 3 taken 5 times.
|
5 | return getImpl<detail::LifeCycleCost_Impl>()->setYearsFromStart(yearsFromStart); |
| 648 | } | ||
| 649 | |||
| 650 | ✗ | void LifeCycleCost::resetYearsFromStart() { | |
| 651 | ✗ | getImpl<detail::LifeCycleCost_Impl>()->resetYearsFromStart(); | |
| 652 | ✗ | } | |
| 653 | |||
| 654 | ✗ | bool LifeCycleCost::setMonthsFromStart(int monthsFromStart) { | |
| 655 | ✗ | return getImpl<detail::LifeCycleCost_Impl>()->setMonthsFromStart(monthsFromStart); | |
| 656 | } | ||
| 657 | |||
| 658 | ✗ | void LifeCycleCost::resetMonthsFromStart() { | |
| 659 | ✗ | getImpl<detail::LifeCycleCost_Impl>()->resetMonthsFromStart(); | |
| 660 | ✗ | } | |
| 661 | |||
| 662 | 12 | bool LifeCycleCost::setRepeatPeriodYears(int repeatPeriodYears) { | |
| 663 |
1/1✓ Branch 3 taken 12 times.
|
12 | return getImpl<detail::LifeCycleCost_Impl>()->setRepeatPeriodYears(repeatPeriodYears); |
| 664 | } | ||
| 665 | |||
| 666 | ✗ | void LifeCycleCost::resetRepeatPeriodYears() { | |
| 667 | ✗ | getImpl<detail::LifeCycleCost_Impl>()->resetRepeatPeriodYears(); | |
| 668 | ✗ | } | |
| 669 | |||
| 670 | ✗ | bool LifeCycleCost::setRepeatPeriodMonths(int repeatPeriodMonths) { | |
| 671 | ✗ | return getImpl<detail::LifeCycleCost_Impl>()->setRepeatPeriodMonths(repeatPeriodMonths); | |
| 672 | } | ||
| 673 | |||
| 674 | ✗ | void LifeCycleCost::resetRepeatPeriodMonths() { | |
| 675 | ✗ | getImpl<detail::LifeCycleCost_Impl>()->resetRepeatPeriodMonths(); | |
| 676 | ✗ | } | |
| 677 | |||
| 678 | 112 | double LifeCycleCost::totalCost() const { | |
| 679 |
1/1✓ Branch 3 taken 112 times.
|
112 | return getImpl<detail::LifeCycleCost_Impl>()->totalCost(); |
| 680 | } | ||
| 681 | |||
| 682 | 8 | bool LifeCycleCost::convertToCostPerEach() { | |
| 683 |
1/1✓ Branch 3 taken 8 times.
|
8 | return getImpl<detail::LifeCycleCost_Impl>()->convertToCostPerEach(); |
| 684 | } | ||
| 685 | |||
| 686 | 4 | boost::optional<int> LifeCycleCost::costedQuantity() const { | |
| 687 |
1/1✓ Branch 3 taken 4 times.
|
4 | return getImpl<detail::LifeCycleCost_Impl>()->costedQuantity(); |
| 688 | } | ||
| 689 | |||
| 690 | 8 | boost::optional<double> LifeCycleCost::costedArea() const { | |
| 691 |
1/1✓ Branch 3 taken 8 times.
|
8 | return getImpl<detail::LifeCycleCost_Impl>()->costedArea(); |
| 692 | } | ||
| 693 | |||
| 694 | 4 | boost::optional<int> LifeCycleCost::costedThermalZones() const { | |
| 695 |
1/1✓ Branch 3 taken 4 times.
|
4 | return getImpl<detail::LifeCycleCost_Impl>()->costedThermalZones(); |
| 696 | } | ||
| 697 | |||
| 698 | } // namespace model | ||
| 699 | } // namespace openstudio | ||
| 700 |