src/model/EnergyManagementSystemCurveOrTableIndexVariable.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 "EnergyManagementSystemCurveOrTableIndexVariable.hpp" | ||
| 7 | #include "EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp" | ||
| 8 | #include "Curve.hpp" | ||
| 9 | #include "CurveLinear.hpp" | ||
| 10 | |||
| 11 | // TODO: Check the following class names against object getters and setters. | ||
| 12 | //#include "AllCurves.hpp" | ||
| 13 | //#include "AllCurves_Impl.hpp" | ||
| 14 | |||
| 15 | #include <utilities/idd/IddEnums.hxx> | ||
| 16 | #include <utilities/idd/OS_EnergyManagementSystem_CurveOrTableIndexVariable_FieldEnums.hxx> | ||
| 17 | |||
| 18 | #include "../utilities/core/Assert.hpp" | ||
| 19 | |||
| 20 | namespace openstudio { | ||
| 21 | namespace model { | ||
| 22 | |||
| 23 | namespace detail { | ||
| 24 | |||
| 25 | 4 | EnergyManagementSystemCurveOrTableIndexVariable_Impl::EnergyManagementSystemCurveOrTableIndexVariable_Impl(const IdfObject& idfObject, | |
| 26 | 4 | Model_Impl* model, bool keepHandle) | |
| 27 | 4 | : ModelObject_Impl(idfObject, model, keepHandle) { | |
| 28 |
4/6✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 4 times.
✗ Branch 13 not taken.
|
4 | OS_ASSERT(idfObject.iddObject().type() == EnergyManagementSystemCurveOrTableIndexVariable::iddObjectType()); |
| 29 | 4 | } | |
| 30 | |||
| 31 | ✗ | EnergyManagementSystemCurveOrTableIndexVariable_Impl::EnergyManagementSystemCurveOrTableIndexVariable_Impl( | |
| 32 | ✗ | const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) | |
| 33 | ✗ | : ModelObject_Impl(other, model, keepHandle) { | |
| 34 | ✗ | OS_ASSERT(other.iddObject().type() == EnergyManagementSystemCurveOrTableIndexVariable::iddObjectType()); | |
| 35 | ✗ | } | |
| 36 | |||
| 37 | 2 | EnergyManagementSystemCurveOrTableIndexVariable_Impl::EnergyManagementSystemCurveOrTableIndexVariable_Impl( | |
| 38 | 2 | const EnergyManagementSystemCurveOrTableIndexVariable_Impl& other, Model_Impl* model, bool keepHandle) | |
| 39 | 2 | : ModelObject_Impl(other, model, keepHandle) {} | |
| 40 | |||
| 41 | ✗ | const std::vector<std::string>& EnergyManagementSystemCurveOrTableIndexVariable_Impl::outputVariableNames() const { | |
| 42 | ✗ | static const std::vector<std::string> result; | |
| 43 | ✗ | return result; | |
| 44 | } | ||
| 45 | |||
| 46 | ✗ | IddObjectType EnergyManagementSystemCurveOrTableIndexVariable_Impl::iddObjectType() const { | |
| 47 | ✗ | return EnergyManagementSystemCurveOrTableIndexVariable::iddObjectType(); | |
| 48 | } | ||
| 49 | |||
| 50 | 3 | ModelObject EnergyManagementSystemCurveOrTableIndexVariable_Impl::curveOrTableObject() const { | |
| 51 |
1/1✓ Branch 1 taken 3 times.
|
3 | boost::optional<ModelObject> value = optionalCurveOrTableObject(); |
| 52 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | if (!value) { |
| 53 | ✗ | LOG(Info, " does not have an Curveor Table Object attached."); | |
| 54 | } | ||
| 55 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
6 | return value.get(); |
| 56 | 3 | } | |
| 57 | |||
| 58 | 7 | bool EnergyManagementSystemCurveOrTableIndexVariable_Impl::setCurveOrTableObject(const Curve& allCurves) { | |
| 59 |
2/2✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
|
7 | bool result = setPointer(OS_EnergyManagementSystem_CurveOrTableIndexVariableFields::CurveorTableObjectName, allCurves.handle()); |
| 60 | 7 | return result; | |
| 61 | } | ||
| 62 | |||
| 63 | 3 | boost::optional<ModelObject> EnergyManagementSystemCurveOrTableIndexVariable_Impl::optionalCurveOrTableObject() const { | |
| 64 |
1/1✓ Branch 1 taken 3 times.
|
6 | return getObject<ModelObject>().getModelObjectTarget<ModelObject>( |
| 65 |
1/1✓ Branch 1 taken 3 times.
|
6 | OS_EnergyManagementSystem_CurveOrTableIndexVariableFields::CurveorTableObjectName); |
| 66 | } | ||
| 67 | |||
| 68 | } // namespace detail | ||
| 69 | |||
| 70 | 1 | EnergyManagementSystemCurveOrTableIndexVariable::EnergyManagementSystemCurveOrTableIndexVariable(const Model& model, const Curve& curve) | |
| 71 | 1 | : ModelObject(EnergyManagementSystemCurveOrTableIndexVariable::iddObjectType(), model) { | |
| 72 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 1 time.
✗ Branch 5 not taken.
|
1 | OS_ASSERT(getImpl<detail::EnergyManagementSystemCurveOrTableIndexVariable_Impl>()); |
| 73 |
1/1✓ Branch 1 taken 1 time.
|
1 | bool ok = setCurveOrTableObject(curve); |
| 74 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | if (!ok) { |
| 75 | ✗ | remove(); | |
| 76 | ✗ | LOG_AND_THROW("Unable to set " << briefDescription() << "'s Curve to " << curve.briefDescription() << "."); | |
| 77 | } | ||
| 78 | 1 | } | |
| 79 | |||
| 80 | 3 | EnergyManagementSystemCurveOrTableIndexVariable::EnergyManagementSystemCurveOrTableIndexVariable(const Model& model) | |
| 81 | 3 | : ModelObject(EnergyManagementSystemCurveOrTableIndexVariable::iddObjectType(), model) { | |
| 82 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 5 not taken.
|
3 | OS_ASSERT(getImpl<detail::EnergyManagementSystemCurveOrTableIndexVariable_Impl>()); |
| 83 |
1/1✓ Branch 1 taken 3 times.
|
3 | CurveLinear curve = CurveLinear(model); |
| 84 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | curve.setName("Generic Curve"); |
| 85 |
1/1✓ Branch 1 taken 3 times.
|
3 | setCurveOrTableObject(curve); |
| 86 | 3 | } | |
| 87 | |||
| 88 | 7606 | IddObjectType EnergyManagementSystemCurveOrTableIndexVariable::iddObjectType() { | |
| 89 |
1/1✓ Branch 1 taken 7606 times.
|
7606 | return {IddObjectType::OS_EnergyManagementSystem_CurveOrTableIndexVariable}; |
| 90 | } | ||
| 91 | |||
| 92 | 3 | ModelObject EnergyManagementSystemCurveOrTableIndexVariable::curveOrTableObject() const { | |
| 93 |
1/1✓ Branch 3 taken 3 times.
|
3 | return getImpl<detail::EnergyManagementSystemCurveOrTableIndexVariable_Impl>()->curveOrTableObject(); |
| 94 | } | ||
| 95 | |||
| 96 | 7 | bool EnergyManagementSystemCurveOrTableIndexVariable::setCurveOrTableObject(const Curve& allCurves) { | |
| 97 |
1/1✓ Branch 3 taken 7 times.
|
7 | return getImpl<detail::EnergyManagementSystemCurveOrTableIndexVariable_Impl>()->setCurveOrTableObject(allCurves); |
| 98 | } | ||
| 99 | |||
| 100 | /// @cond | ||
| 101 | 2 | EnergyManagementSystemCurveOrTableIndexVariable::EnergyManagementSystemCurveOrTableIndexVariable( | |
| 102 | 2 | std::shared_ptr<detail::EnergyManagementSystemCurveOrTableIndexVariable_Impl> impl) | |
| 103 |
1/1✓ Branch 3 taken 2 times.
|
2 | : ModelObject(std::move(impl)) {} |
| 104 | /// @endcond | ||
| 105 | |||
| 106 | } // namespace model | ||
| 107 | } // namespace openstudio | ||
| 108 |