src/model/ElectricLoadCenterInverterSimple.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 "ElectricLoadCenterInverterSimple.hpp" | ||
| 7 | #include "ElectricLoadCenterInverterSimple_Impl.hpp" | ||
| 8 | |||
| 9 | #include "Schedule.hpp" | ||
| 10 | #include "Schedule_Impl.hpp" | ||
| 11 | #include "ThermalZone.hpp" | ||
| 12 | #include "ThermalZone_Impl.hpp" | ||
| 13 | #include "ScheduleTypeLimits.hpp" | ||
| 14 | #include "ScheduleTypeRegistry.hpp" | ||
| 15 | |||
| 16 | #include <utilities/idd/IddEnums.hxx> | ||
| 17 | #include <utilities/idd/OS_ElectricLoadCenter_Inverter_Simple_FieldEnums.hxx> | ||
| 18 | |||
| 19 | #include "../utilities/units/Unit.hpp" | ||
| 20 | |||
| 21 | #include "../utilities/core/Assert.hpp" | ||
| 22 | |||
| 23 | namespace openstudio { | ||
| 24 | namespace model { | ||
| 25 | |||
| 26 | namespace detail { | ||
| 27 | |||
| 28 | 9 | ElectricLoadCenterInverterSimple_Impl::ElectricLoadCenterInverterSimple_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 29 | 9 | : Inverter_Impl(idfObject, model, keepHandle) { | |
| 30 |
4/6✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 9 times.
✗ Branch 13 not taken.
|
9 | OS_ASSERT(idfObject.iddObject().type() == ElectricLoadCenterInverterSimple::iddObjectType()); |
| 31 | 9 | } | |
| 32 | |||
| 33 | ✗ | ElectricLoadCenterInverterSimple_Impl::ElectricLoadCenterInverterSimple_Impl(const openstudio::detail::WorkspaceObject_Impl& other, | |
| 34 | ✗ | Model_Impl* model, bool keepHandle) | |
| 35 | ✗ | : Inverter_Impl(other, model, keepHandle) { | |
| 36 | ✗ | OS_ASSERT(other.iddObject().type() == ElectricLoadCenterInverterSimple::iddObjectType()); | |
| 37 | ✗ | } | |
| 38 | |||
| 39 | 2 | ElectricLoadCenterInverterSimple_Impl::ElectricLoadCenterInverterSimple_Impl(const ElectricLoadCenterInverterSimple_Impl& other, | |
| 40 | 2 | Model_Impl* model, bool keepHandle) | |
| 41 | 2 | : Inverter_Impl(other, model, keepHandle) {} | |
| 42 | |||
| 43 | ✗ | const std::vector<std::string>& ElectricLoadCenterInverterSimple_Impl::outputVariableNames() const { | |
| 44 | static const std::vector<std::string> result{ | ||
| 45 | "Inverter DC to AC Efficiency", "Inverter DC Input Electricity Rate", "Inverter DC Input Electricity Energy", | ||
| 46 | "Inverter AC Output Electricity Rate", "Inverter AC Output Electricity Energy", "Inverter Conversion Loss Power", | ||
| 47 | "Inverter Conversion Loss Energy", "Inverter Conversion Loss Decrement Energy", "Inverter Thermal Loss Rate", | ||
| 48 | ✗ | "Inverter Thermal Loss Energy", "Inverter Ancillary AC Electricity Rate", "Inverter Ancillary AC Electricity Energy"}; | |
| 49 | ✗ | return result; | |
| 50 | ✗ | } | |
| 51 | |||
| 52 | ✗ | IddObjectType ElectricLoadCenterInverterSimple_Impl::iddObjectType() const { | |
| 53 | ✗ | return ElectricLoadCenterInverterSimple::iddObjectType(); | |
| 54 | } | ||
| 55 | |||
| 56 | ✗ | std::vector<ScheduleTypeKey> ElectricLoadCenterInverterSimple_Impl::getScheduleTypeKeys(const Schedule& schedule) const { | |
| 57 | // TODO: Check schedule display names. | ||
| 58 | ✗ | std::vector<ScheduleTypeKey> result; | |
| 59 | ✗ | UnsignedVector fieldIndices = getSourceIndices(schedule.handle()); | |
| 60 | ✗ | UnsignedVector::const_iterator b(fieldIndices.begin()); | |
| 61 | ✗ | UnsignedVector::const_iterator e(fieldIndices.end()); | |
| 62 | ✗ | if (std::find(b, e, OS_ElectricLoadCenter_Inverter_SimpleFields::AvailabilityScheduleName) != e) { | |
| 63 | ✗ | result.push_back(ScheduleTypeKey("ElectricLoadCenterInverterSimple", "Availability")); | |
| 64 | } | ||
| 65 | ✗ | return result; | |
| 66 | ✗ | } | |
| 67 | |||
| 68 | 7 | boost::optional<Schedule> ElectricLoadCenterInverterSimple_Impl::availabilitySchedule() const { | |
| 69 |
2/2✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
|
7 | return getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_ElectricLoadCenter_Inverter_SimpleFields::AvailabilityScheduleName); |
| 70 | } | ||
| 71 | |||
| 72 | 4 | boost::optional<ThermalZone> ElectricLoadCenterInverterSimple_Impl::thermalZone() const { | |
| 73 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | return getObject<ModelObject>().getModelObjectTarget<ThermalZone>(OS_ElectricLoadCenter_Inverter_SimpleFields::ZoneName); |
| 74 | } | ||
| 75 | |||
| 76 | 7 | boost::optional<double> ElectricLoadCenterInverterSimple_Impl::radiativeFraction() const { | |
| 77 | 7 | return getDouble(OS_ElectricLoadCenter_Inverter_SimpleFields::RadiativeFraction, true); | |
| 78 | } | ||
| 79 | |||
| 80 | 7 | boost::optional<double> ElectricLoadCenterInverterSimple_Impl::inverterEfficiency() const { | |
| 81 | 7 | return getDouble(OS_ElectricLoadCenter_Inverter_SimpleFields::InverterEfficiency, true); | |
| 82 | } | ||
| 83 | |||
| 84 | 2 | bool ElectricLoadCenterInverterSimple_Impl::setAvailabilitySchedule(Schedule& schedule) { | |
| 85 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
8 | bool result = setSchedule(OS_ElectricLoadCenter_Inverter_SimpleFields::AvailabilityScheduleName, "ElectricLoadCenterInverterSimple", |
| 86 | "Availability", schedule); | ||
| 87 | 2 | return result; | |
| 88 | } | ||
| 89 | |||
| 90 | 1 | void ElectricLoadCenterInverterSimple_Impl::resetAvailabilitySchedule() { | |
| 91 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | bool result = setString(OS_ElectricLoadCenter_Inverter_SimpleFields::AvailabilityScheduleName, ""); |
| 92 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | OS_ASSERT(result); |
| 93 | 1 | } | |
| 94 | |||
| 95 | 1 | bool ElectricLoadCenterInverterSimple_Impl::setThermalZone(const ThermalZone& thermalZone) { | |
| 96 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | return setPointer(OS_ElectricLoadCenter_Inverter_SimpleFields::ZoneName, thermalZone.handle()); |
| 97 | } | ||
| 98 | |||
| 99 | ✗ | void ElectricLoadCenterInverterSimple_Impl::resetThermalZone() { | |
| 100 | ✗ | bool result = setString(OS_ElectricLoadCenter_Inverter_SimpleFields::ZoneName, ""); | |
| 101 | ✗ | OS_ASSERT(result); | |
| 102 | ✗ | } | |
| 103 | |||
| 104 | 2 | bool ElectricLoadCenterInverterSimple_Impl::setRadiativeFraction(boost::optional<double> radiativeFraction) { | |
| 105 | 2 | bool result(false); | |
| 106 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (radiativeFraction) { |
| 107 | 2 | result = setDouble(OS_ElectricLoadCenter_Inverter_SimpleFields::RadiativeFraction, radiativeFraction.get()); | |
| 108 | } else { | ||
| 109 | ✗ | resetRadiativeFraction(); | |
| 110 | ✗ | result = true; | |
| 111 | } | ||
| 112 | 2 | return result; | |
| 113 | } | ||
| 114 | |||
| 115 | 1 | void ElectricLoadCenterInverterSimple_Impl::resetRadiativeFraction() { | |
| 116 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | bool result = setString(OS_ElectricLoadCenter_Inverter_SimpleFields::RadiativeFraction, ""); |
| 117 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | OS_ASSERT(result); |
| 118 | 1 | } | |
| 119 | |||
| 120 | 2 | bool ElectricLoadCenterInverterSimple_Impl::setInverterEfficiency(boost::optional<double> inverterEfficiency) { | |
| 121 | 2 | bool result(false); | |
| 122 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (inverterEfficiency) { |
| 123 | 2 | result = setDouble(OS_ElectricLoadCenter_Inverter_SimpleFields::InverterEfficiency, inverterEfficiency.get()); | |
| 124 | } else { | ||
| 125 | ✗ | resetInverterEfficiency(); | |
| 126 | ✗ | result = true; | |
| 127 | } | ||
| 128 | 2 | return result; | |
| 129 | } | ||
| 130 | |||
| 131 | 1 | void ElectricLoadCenterInverterSimple_Impl::resetInverterEfficiency() { | |
| 132 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | bool result = setString(OS_ElectricLoadCenter_Inverter_SimpleFields::InverterEfficiency, ""); |
| 133 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | OS_ASSERT(result); |
| 134 | 1 | } | |
| 135 | |||
| 136 | } // namespace detail | ||
| 137 | |||
| 138 | 9 | ElectricLoadCenterInverterSimple::ElectricLoadCenterInverterSimple(const Model& model) | |
| 139 | 9 | : Inverter(ElectricLoadCenterInverterSimple::iddObjectType(), model) { | |
| 140 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 5 not taken.
|
9 | OS_ASSERT(getImpl<detail::ElectricLoadCenterInverterSimple_Impl>()); |
| 141 | |||
| 142 | // TODO: Appropriately handle the following required object-list fields. | ||
| 143 | 9 | bool ok = true; | |
| 144 | // ok = setHandle(); | ||
| 145 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 3 not taken.
|
9 | OS_ASSERT(ok); |
| 146 | 9 | } | |
| 147 | |||
| 148 | 7616 | IddObjectType ElectricLoadCenterInverterSimple::iddObjectType() { | |
| 149 |
1/1✓ Branch 1 taken 7616 times.
|
7616 | return {IddObjectType::OS_ElectricLoadCenter_Inverter_Simple}; |
| 150 | } | ||
| 151 | |||
| 152 | 7 | boost::optional<Schedule> ElectricLoadCenterInverterSimple::availabilitySchedule() const { | |
| 153 |
1/1✓ Branch 3 taken 7 times.
|
7 | return getImpl<detail::ElectricLoadCenterInverterSimple_Impl>()->availabilitySchedule(); |
| 154 | } | ||
| 155 | |||
| 156 | 7 | boost::optional<double> ElectricLoadCenterInverterSimple::radiativeFraction() const { | |
| 157 |
1/1✓ Branch 3 taken 7 times.
|
7 | return getImpl<detail::ElectricLoadCenterInverterSimple_Impl>()->radiativeFraction(); |
| 158 | } | ||
| 159 | |||
| 160 | 7 | boost::optional<double> ElectricLoadCenterInverterSimple::inverterEfficiency() const { | |
| 161 |
1/1✓ Branch 3 taken 7 times.
|
7 | return getImpl<detail::ElectricLoadCenterInverterSimple_Impl>()->inverterEfficiency(); |
| 162 | } | ||
| 163 | |||
| 164 | 2 | bool ElectricLoadCenterInverterSimple::setAvailabilitySchedule(Schedule& schedule) { | |
| 165 |
1/1✓ Branch 3 taken 2 times.
|
2 | return getImpl<detail::ElectricLoadCenterInverterSimple_Impl>()->setAvailabilitySchedule(schedule); |
| 166 | } | ||
| 167 | |||
| 168 | 1 | void ElectricLoadCenterInverterSimple::resetAvailabilitySchedule() { | |
| 169 |
1/1✓ Branch 3 taken 1 time.
|
1 | getImpl<detail::ElectricLoadCenterInverterSimple_Impl>()->resetAvailabilitySchedule(); |
| 170 | 1 | } | |
| 171 | |||
| 172 | 2 | bool ElectricLoadCenterInverterSimple::setRadiativeFraction(double radiativeFraction) { | |
| 173 |
2/2✓ Branch 3 taken 2 times.
✓ Branch 6 taken 2 times.
|
2 | return getImpl<detail::ElectricLoadCenterInverterSimple_Impl>()->setRadiativeFraction(radiativeFraction); |
| 174 | } | ||
| 175 | |||
| 176 | 1 | void ElectricLoadCenterInverterSimple::resetRadiativeFraction() { | |
| 177 |
1/1✓ Branch 3 taken 1 time.
|
1 | getImpl<detail::ElectricLoadCenterInverterSimple_Impl>()->resetRadiativeFraction(); |
| 178 | 1 | } | |
| 179 | |||
| 180 | 2 | bool ElectricLoadCenterInverterSimple::setInverterEfficiency(double inverterEfficiency) { | |
| 181 |
2/2✓ Branch 3 taken 2 times.
✓ Branch 6 taken 2 times.
|
2 | return getImpl<detail::ElectricLoadCenterInverterSimple_Impl>()->setInverterEfficiency(inverterEfficiency); |
| 182 | } | ||
| 183 | |||
| 184 | 1 | void ElectricLoadCenterInverterSimple::resetInverterEfficiency() { | |
| 185 |
1/1✓ Branch 3 taken 1 time.
|
1 | getImpl<detail::ElectricLoadCenterInverterSimple_Impl>()->resetInverterEfficiency(); |
| 186 | 1 | } | |
| 187 | |||
| 188 | /// @cond | ||
| 189 | 2 | ElectricLoadCenterInverterSimple::ElectricLoadCenterInverterSimple(std::shared_ptr<detail::ElectricLoadCenterInverterSimple_Impl> impl) | |
| 190 |
1/1✓ Branch 3 taken 2 times.
|
2 | : Inverter(std::move(impl)) {} |
| 191 | /// @endcond | ||
| 192 | |||
| 193 | } // namespace model | ||
| 194 | } // namespace openstudio | ||
| 195 |