src/model/Generator.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 "Generator.hpp" | ||
| 7 | #include "Generator_Impl.hpp" | ||
| 8 | #include "ParentObject.hpp" | ||
| 9 | #include "ParentObject_Impl.hpp" | ||
| 10 | #include "Model.hpp" | ||
| 11 | #include "Model_Impl.hpp" | ||
| 12 | #include "ElectricLoadCenterDistribution.hpp" | ||
| 13 | #include "ElectricLoadCenterDistribution_Impl.hpp" | ||
| 14 | #include "Schedule.hpp" | ||
| 15 | #include "ModelObjectList.hpp" | ||
| 16 | #include "ModelObjectList_Impl.hpp" | ||
| 17 | |||
| 18 | #include "../utilities/core/Assert.hpp" | ||
| 19 | |||
| 20 | namespace openstudio { | ||
| 21 | |||
| 22 | namespace model { | ||
| 23 | |||
| 24 | namespace detail { | ||
| 25 | |||
| 26 | ✗ | Generator_Impl::Generator_Impl(IddObjectType type, Model_Impl* model) : ParentObject_Impl(type, model) {} | |
| 27 | |||
| 28 | 62 | Generator_Impl::Generator_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 29 | 62 | : ParentObject_Impl(idfObject, model, keepHandle) {} | |
| 30 | |||
| 31 | 1 | Generator_Impl::Generator_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) | |
| 32 | 1 | : ParentObject_Impl(other, model, keepHandle) {} | |
| 33 | |||
| 34 | 32 | Generator_Impl::Generator_Impl(const Generator_Impl& other, Model_Impl* model, bool keepHandles) : ParentObject_Impl(other, model, keepHandles) {} | |
| 35 | |||
| 36 | 8 | std::vector<openstudio::IdfObject> Generator_Impl::remove() { | |
| 37 |
1/1✓ Branch 1 taken 8 times.
|
8 | boost::optional<ElectricLoadCenterDistribution> elcd = this->electricLoadCenterDistribution(); |
| 38 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 6 times.
|
8 | if (elcd) { |
| 39 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | elcd->removeGenerator(getObject<Generator>()); |
| 40 | } | ||
| 41 |
1/1✓ Branch 1 taken 8 times.
|
16 | return ParentObject_Impl::remove(); |
| 42 | 8 | } | |
| 43 | |||
| 44 | 88 | boost::optional<ElectricLoadCenterDistribution> Generator_Impl::electricLoadCenterDistribution() const { | |
| 45 | 88 | boost::optional<ElectricLoadCenterDistribution> result; | |
| 46 |
5/5✓ Branch 1 taken 88 times.
✓ Branch 4 taken 88 times.
✓ Branch 7 taken 88 times.
✓ Branch 15 taken 31 times.
✓ Branch 16 taken 57 times.
|
88 | for (const auto& list : getObject<ModelObject>().getModelObjectSources<ModelObjectList>(ModelObjectList::iddObjectType())) { |
| 47 |
2/2✓ Branch 1 taken 31 times.
✓ Branch 4 taken 31 times.
|
31 | auto elcds = list.getModelObjectSources<ElectricLoadCenterDistribution>(ElectricLoadCenterDistribution::iddObjectType()); |
| 48 |
1/2✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
|
31 | if (elcds.empty()) { |
| 49 | // error | ||
| 50 |
1/2✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
|
31 | } else if (elcds.size() == 1u) { |
| 51 |
1/1✓ Branch 2 taken 31 times.
|
31 | return elcds[0]; |
| 52 | } else { | ||
| 53 | // error | ||
| 54 | } | ||
| 55 | 119 | } | |
| 56 | 57 | return boost::none; | |
| 57 | 88 | } | |
| 58 | /* | ||
| 59 | std::vector<EMSActuatorNames> Generator_Impl::emsActuatorNames() const { | ||
| 60 | std::vector<EMSActuatorNames> actuators{{"On-Site Generator Control", "Requested Power"}}; | ||
| 61 | return actuators; | ||
| 62 | } | ||
| 63 | |||
| 64 | std::vector<std::string> Generator_Impl::emsInternalVariableNames() const { | ||
| 65 | std::vector<std::string> types{"Generator Nominal Maximum Power", | ||
| 66 | "Generator Nominal Thermal To Electric Ratio"}; | ||
| 67 | return types; | ||
| 68 | } */ | ||
| 69 | } // namespace detail | ||
| 70 | |||
| 71 | 61 | Generator::Generator(IddObjectType type, const Model& model) : ParentObject(type, model) { | |
| 72 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 61 times.
✗ Branch 5 not taken.
|
61 | OS_ASSERT(getImpl<detail::Generator_Impl>()); |
| 73 | 61 | } | |
| 74 | |||
| 75 |
1/1✓ Branch 3 taken 97 times.
|
97 | Generator::Generator(std::shared_ptr<detail::Generator_Impl> p) : ParentObject(std::move(p)) {} |
| 76 | |||
| 77 | 8 | std::string Generator::generatorObjectType() const { | |
| 78 |
1/1✓ Branch 3 taken 8 times.
|
8 | return getImpl<detail::Generator_Impl>()->generatorObjectType(); |
| 79 | } | ||
| 80 | |||
| 81 | 8 | boost::optional<double> Generator::ratedElectricPowerOutput() const { | |
| 82 |
1/1✓ Branch 3 taken 8 times.
|
8 | return getImpl<detail::Generator_Impl>()->ratedElectricPowerOutput(); |
| 83 | } | ||
| 84 | |||
| 85 | 12 | boost::optional<Schedule> Generator::availabilitySchedule() const { | |
| 86 |
1/1✓ Branch 3 taken 12 times.
|
12 | return getImpl<detail::Generator_Impl>()->availabilitySchedule(); |
| 87 | } | ||
| 88 | |||
| 89 | 11 | boost::optional<double> Generator::ratedThermaltoElectricalPowerRatio() const { | |
| 90 |
1/1✓ Branch 3 taken 11 times.
|
11 | return getImpl<detail::Generator_Impl>()->ratedThermaltoElectricalPowerRatio(); |
| 91 | } | ||
| 92 | |||
| 93 | 80 | boost::optional<ElectricLoadCenterDistribution> Generator::electricLoadCenterDistribution() const { | |
| 94 |
1/1✓ Branch 3 taken 80 times.
|
80 | return getImpl<detail::Generator_Impl>()->electricLoadCenterDistribution(); |
| 95 | } | ||
| 96 | |||
| 97 | } // namespace model | ||
| 98 | |||
| 99 | } // namespace openstudio | ||
| 100 |